#![allow(non_snake_case)]
#![allow(unused)]
use crate::error::Result;
use crate::utils::*;
use super::super::formatter::*;
use super::super::instruction::*;
use super::super::operand::*;
use super::super::consts::*;
use super::super::config::*;
use super::super::decoder::*;
pub(crate) struct IclassAddSpIT1;
impl IclassAddSpIT1 {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rd = (data >> 8) & 7;
let Rd_post = Rd;
let SP = (data >> 11) & 1;
let SP_post = SP;
let imm8 = (data >> 0) & 255;
let imm8_post = imm8;
let field_15 = (data >> 12) & 15;
let field_15_post = field_15;
return AddSpIT1::decode(data as u32, decoder);
unreachable!()
}
}
pub struct AddSpIT1;
impl AddSpIT1 {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::ADD
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
ConditionalInstruction::Condition(0, false, false)
}
pub fn size(_instr: &Instruction) -> usize {2}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rd = (data >> 8) & 7;
let Rd_post = Rd;
let imm8 = (data >> 0) & 255;
let imm8_post = imm8;
let imm8_post = (imm8) * 4;
let Rd_post = Rd;
let op_0 = MnemonicCondition::Al;
let op_1 = Register::decode(Rd_post)?;
let op_2 = Register::SP;
let op_3 = imm8_post as u32;
let mut instr = Instruction::builder(Code::ADD_SP_i_T1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rd_pre = instr.op1().as_register()?.encode();
let imm8_pre = instr.op3().as_unsigned_immediate()? as u32;
let Rd = (Rd_pre & 7);
let imm8_pre = (imm8_pre) / 4;
let imm8 = (imm8_pre & 255);
let mut instr: u32 = 0b1010100000000000;
instr |= (Rd & 7) << 8;
instr |= (imm8 & 255) << 0;
let instr = instr as u16;
buf.extend(instr.to_le_bytes());
Ok(2)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(Register::SP) = op {
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::SignedImmediate(i) = op {
if *i < 0 || *i > 1020 {
todo!()
}
return Ok(())
}
if let Operand::UnsignedImmediate(i) = op {
if !(0..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
fmt.format_mnemonic(output, &config.global, &config.instructions.add_sp_i_t1, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t1, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.add_sp_i_t1, &instr, FormatterQualifier::Narrow, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t1, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t1, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t1, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t1, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t1, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t1, &instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t1, &instr, 3)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum AddSpIT1Aliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum AddSpIT1Encodings {
None
}
pub(crate) struct IclassAddSpIT2;
impl IclassAddSpIT2 {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm7 = (data >> 0) & 127;
let imm7_post = imm7;
let field_11 = (data >> 8) & 15;
let field_11_post = field_11;
let S = (data >> 7) & 1;
let S_post = S;
let field_15 = (data >> 12) & 15;
let field_15_post = field_15;
return AddSpIT2::decode(data as u32, decoder);
unreachable!()
}
}
pub struct AddSpIT2;
impl AddSpIT2 {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::ADD
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
ConditionalInstruction::Condition(0, false, false)
}
pub fn size(_instr: &Instruction) -> usize {2}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm7 = (data >> 0) & 127;
let imm7_post = imm7;
let imm7_post = (imm7) * 4;
let op_0 = MnemonicCondition::Al;
let op_1 = Register::SP;
let op_2 = Register::SP;
let op_3 = imm7_post as u32;
let mut instr = Instruction::builder(Code::ADD_SP_i_T2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let imm7_pre = instr.op3().as_unsigned_immediate()? as u32;
let imm7_pre = (imm7_pre) / 4;
let imm7 = (imm7_pre & 127);
let mut instr: u32 = 0b1011000000000000;
instr |= (imm7 & 127) << 0;
let instr = instr as u16;
buf.extend(instr.to_le_bytes());
Ok(2)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(Register::SP) = op {
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(Register::SP) = op {
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::SignedImmediate(i) = op {
if *i < 0 || *i > 508 {
todo!()
}
return Ok(())
}
if let Operand::UnsignedImmediate(i) = op {
if !(0..=508).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
fmt.format_mnemonic(output, &config.global, &config.instructions.add_sp_i_t2, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t2, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.add_sp_i_t2, &instr, FormatterQualifier::Narrow, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t2, &instr, FormatterTextKind::Space)?;
if !config.global.syntax.omit_src_dst_same_reg {
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t2, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t2, &instr, FormatterTextKind::Comma)?;
};
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t2, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t2, &instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t2, &instr, 3)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum AddSpIT2Aliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum AddSpIT2Encodings {
None
}
pub(crate) struct IclassAddSpIT3;
impl IclassAddSpIT3 {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm8 = (data >> 0) & 255;
let imm8_post = imm8;
let imm3 = (data >> 12) & 7;
let imm3_post = imm3;
let S = (data >> 20) & 1;
let S_post = S;
let i = (data >> 26) & 1;
let i_post = i;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let field_25 = (data >> 25) & 1;
let field_25_post = field_25;
let field_15 = (data >> 15) & 1;
let field_15_post = field_15;
let Rd = (data >> 8) & 15;
let Rd_post = Rd;
let op1 = (data >> 21) & 15;
let op1_post = op1;
let field_31 = (data >> 27) & 31;
let field_31_post = field_31;
if (S_post == 0) {
return AddSpIT3::decode(data as u32, decoder);
}
if ((S_post == 1) && (Rd_post != 15)) {
return AddsSpIT3::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct AddSpIT3;
impl AddSpIT3 {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::ADD,
Encoding::Alt2 => Mnemonic::ADD,
_ => todo!()
}
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
match instr.encoding {
Encoding::Alt1 => {
ConditionalInstruction::Condition(0, false, false)
}
Encoding::Alt2 => {
ConditionalInstruction::Condition(0, false, false)
}
_ => todo!()
}
}
pub fn size(instr: &Instruction) -> usize {
match instr.encoding {
Encoding::Alt2 => 4,
Encoding::Alt1 => 4,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let i = (data >> 26) & 1;
let i_post = i;
let imm3 = (data >> 12) & 7;
let imm3_post = imm3;
let Rd = (data >> 8) & 15;
let Rd_post = Rd;
let imm8 = (data >> 0) & 255;
let imm8_post = imm8;
let Rd_post = Rd;
let i_imm3_imm8_post = (i << 11) | (imm3 << 8) | imm8;
if let Some(encoding) = decoder.config.instructions.add_sp_i_t3.encodings {
match encoding {
AddSpIT3Encodings::Alt2 => {
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let op_2 = Register::SP;
let i_imm3_imm8_post = (i << 11) | (imm3 << 8) | imm8;
let op_3 = ModifiedImmediate::decode(i_imm3_imm8_post);
let mut instr = Instruction::builder_multi(Code::ADD_SP_i_T3, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
AddSpIT3Encodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let op_2 = Register::SP;
let i_imm3_imm8_post = (i << 11) | (imm3 << 8) | imm8;
let op_3 = ModifiedImmediate::decode(i_imm3_imm8_post);
let mut instr = Instruction::builder_multi(Code::ADD_SP_i_T3, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
}
}
if ((Rd_post <= 7 && i_imm3_imm8_post <= 1020) || (i_imm3_imm8_post <= 508)) {
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let op_2 = Register::SP;
let i_imm3_imm8_post = (i << 11) | (imm3 << 8) | imm8;
let op_3 = ModifiedImmediate::decode(i_imm3_imm8_post);
let mut instr = Instruction::builder_multi(Code::ADD_SP_i_T3, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let op_2 = Register::SP;
let i_imm3_imm8_post = (i << 11) | (imm3 << 8) | imm8;
let op_3 = ModifiedImmediate::decode(i_imm3_imm8_post);
let mut instr = Instruction::builder_multi(Code::ADD_SP_i_T3, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt2 => {
let Rd_pre = instr.op1().as_register()?.encode();
let i_imm3_imm8_pre = instr.op3().as_modified_immediate()?.encode();
let Rd = (Rd_pre & 15);
let imm8 = (i_imm3_imm8_pre & 255);
let imm3 = (i_imm3_imm8_pre >> 8) & 7;
let i = (i_imm3_imm8_pre >> 11) & 1;
let mut instr: u32 = 0b11110001000011010000000000000000;
instr |= (Rd & 15) << 8;
instr |= (imm8 & 255) << 0;
instr |= (imm3 & 7) << 12;
instr |= (i & 1) << 26;
let instr_1 = (instr & 0xffff) as u16;
let instr_2 = ((instr >> 16) & 0xffff) as u16;
buf.extend(instr_2.to_le_bytes());
buf.extend(instr_1.to_le_bytes());
return Ok(4);
}
Encoding::Alt1 => {
let Rd_pre = instr.op1().as_register()?.encode();
let i_imm3_imm8_pre = instr.op3().as_modified_immediate()?.encode();
let Rd = (Rd_pre & 15);
let imm8 = (i_imm3_imm8_pre & 255);
let imm3 = (i_imm3_imm8_pre >> 8) & 7;
let i = (i_imm3_imm8_pre >> 11) & 1;
let mut instr: u32 = 0b11110001000011010000000000000000;
instr |= (Rd & 15) << 8;
instr |= (imm8 & 255) << 0;
instr |= (imm3 & 7) << 12;
instr |= (i & 1) << 26;
let instr_1 = (instr & 0xffff) as u16;
let instr_2 = ((instr >> 16) & 0xffff) as u16;
buf.extend(instr_2.to_le_bytes());
buf.extend(instr_1.to_le_bytes());
return Ok(4);
}
_ => todo!()
}
unreachable!()
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
match instr.encoding {
Encoding::Alt2 => {
Self::encode(instr, buf)
}
Encoding::Alt1 => {
Self::encode(instr, buf)
}
_ => todo!()
}
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::Register(Register::SP) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::Register(Register::SP) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::ModifiedImmediate(i) = op {
if i.0 >= 1 << 13 {
todo!()
}
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::ModifiedImmediate(i) = op {
if i.0 >= 1 << 13 {
todo!()
}
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
todo!()
}
Encoding::Alt1 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
todo!()
}
Encoding::Alt1 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
todo!()
}
Encoding::Alt1 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.add_sp_i_t3, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t3, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.add_sp_i_t3, &instr, FormatterQualifier::Wide, true, true)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t3, &instr, FormatterTextKind::Space)?;
if !instr.op1().is_none() {
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t3, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t3, &instr, FormatterTextKind::Comma)?;
};
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t3, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t3, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t3, &instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t3, &instr, 3)?;
return Ok(());
}
Encoding::Alt1 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.add_sp_i_t3, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t3, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.add_sp_i_t3, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t3, &instr, FormatterTextKind::Space)?;
if !instr.op1().is_none() {
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t3, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t3, &instr, FormatterTextKind::Comma)?;
};
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t3, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t3, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t3, &instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t3, &instr, 3)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum AddSpIT3Aliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum AddSpIT3Encodings {
Alt2,
Alt1,
}
pub struct AddsSpIT3;
impl AddsSpIT3 {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::ADDS
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
ConditionalInstruction::Condition(0, false, false)
}
pub fn size(_instr: &Instruction) -> usize {4}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let i = (data >> 26) & 1;
let i_post = i;
let imm3 = (data >> 12) & 7;
let imm3_post = imm3;
let Rd = (data >> 8) & 15;
let Rd_post = Rd;
let imm8 = (data >> 0) & 255;
let imm8_post = imm8;
let Rd_post = Rd;
let i_imm3_imm8_post = (i << 11) | (imm3 << 8) | imm8;
let op_0 = MnemonicCondition::Al;
let op_1 = Register::decode(Rd_post)?;
let op_2 = Register::SP;
let op_3 = ModifiedImmediate::decode(i_imm3_imm8_post);
let mut instr = Instruction::builder(Code::ADDS_SP_i_T3)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rd_pre = instr.op1().as_register()?.encode();
let i_imm3_imm8_pre = instr.op3().as_modified_immediate()?.encode();
let Rd = (Rd_pre & 15);
let imm8 = (i_imm3_imm8_pre & 255);
let imm3 = (i_imm3_imm8_pre >> 8) & 7;
let i = (i_imm3_imm8_pre >> 11) & 1;
let mut instr: u32 = 0b11110001000111010000000000000000;
instr |= (Rd & 15) << 8;
instr |= (imm8 & 255) << 0;
instr |= (imm3 & 7) << 12;
instr |= (i & 1) << 26;
let instr_1 = (instr & 0xffff) as u16;
let instr_2 = ((instr >> 16) & 0xffff) as u16;
buf.extend(instr_2.to_le_bytes());
buf.extend(instr_1.to_le_bytes());
Ok(4)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(Register::SP) = op {
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::ModifiedImmediate(i) = op {
if i.0 >= 1 << 13 {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
fmt.format_mnemonic(output, &config.global, &config.instructions.adds_sp_i_t3, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.adds_sp_i_t3, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.adds_sp_i_t3, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.adds_sp_i_t3, &instr, FormatterTextKind::Space)?;
if !instr.op1().is_none() {
fmt.format_operand(output, &config.global, &config.instructions.adds_sp_i_t3, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.adds_sp_i_t3, &instr, FormatterTextKind::Comma)?;
};
fmt.format_operand(output, &config.global, &config.instructions.adds_sp_i_t3, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.adds_sp_i_t3, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.adds_sp_i_t3, &instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.adds_sp_i_t3, &instr, 3)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum AddsSpIT3Aliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum AddsSpIT3Encodings {
None
}
pub(crate) struct IclassAddSpIT4;
impl IclassAddSpIT4 {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let field_22 = (data >> 22) & 1;
let field_22_post = field_22;
let field_20 = (data >> 20) & 1;
let field_20_post = field_20;
let imm3 = (data >> 12) & 7;
let imm3_post = imm3;
let imm8 = (data >> 0) & 255;
let imm8_post = imm8;
let field_28 = (data >> 27) & 3;
let field_28_post = field_28;
let o1 = (data >> 23) & 1;
let o1_post = o1;
let o2 = (data >> 21) & 1;
let o2_post = o2;
let i = (data >> 26) & 1;
let i_post = i;
let field_31 = (data >> 29) & 7;
let field_31_post = field_31;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let field_25 = (data >> 25) & 1;
let field_25_post = field_25;
let field_15 = (data >> 15) & 1;
let field_15_post = field_15;
let Rd = (data >> 8) & 15;
let Rd_post = Rd;
let field_24 = (data >> 24) & 1;
let field_24_post = field_24;
return AddSpIT4::decode(data as u32, decoder);
unreachable!()
}
}
pub struct AddSpIT4;
impl AddSpIT4 {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::ADD,
Encoding::Alt2 => Mnemonic::ADDW,
_ => todo!()
}
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
match instr.encoding {
Encoding::Alt1 => {
ConditionalInstruction::Condition(0, false, false)
}
Encoding::Alt2 => {
ConditionalInstruction::Condition(0, false, false)
}
_ => todo!()
}
}
pub fn size(instr: &Instruction) -> usize {
match instr.encoding {
Encoding::Alt1 => 4,
Encoding::Alt2 => 4,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let i = (data >> 26) & 1;
let i_post = i;
let imm3 = (data >> 12) & 7;
let imm3_post = imm3;
let Rd = (data >> 8) & 15;
let Rd_post = Rd;
let imm8 = (data >> 0) & 255;
let imm8_post = imm8;
let Rd_post = Rd;
let i_imm3_imm8_post = (i << 11) | (imm3 << 8) | imm8;
if let Some(encoding) = decoder.config.instructions.add_sp_i_t4.encodings {
match encoding {
AddSpIT4Encodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let op_2 = Register::SP;
let i_imm3_imm8_post = (i << 11) | (imm3 << 8) | imm8;
let op_3 = i_imm3_imm8_post as u32;
let mut instr = Instruction::builder_multi(Code::ADD_SP_i_T4, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
AddSpIT4Encodings::Alt2 => {
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let op_2 = Register::SP;
let i_imm3_imm8_post = (i << 11) | (imm3 << 8) | imm8;
let op_3 = i_imm3_imm8_post as u32;
let mut instr = Instruction::builder_multi(Code::ADD_SP_i_T4, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
}
}
if (!((i_imm3_imm8_post <= 1020) || (i_imm3_imm8_post <= 508) || (is_modified_immediate(i_imm3_imm8_post.into())))) {
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let op_2 = Register::SP;
let i_imm3_imm8_post = (i << 11) | (imm3 << 8) | imm8;
let op_3 = i_imm3_imm8_post as u32;
let mut instr = Instruction::builder_multi(Code::ADD_SP_i_T4, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
if ((i_imm3_imm8_post <= 1020) || (i_imm3_imm8_post <= 508) || (is_modified_immediate(i_imm3_imm8_post.into()))) {
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let op_2 = Register::SP;
let i_imm3_imm8_post = (i << 11) | (imm3 << 8) | imm8;
let op_3 = i_imm3_imm8_post as u32;
let mut instr = Instruction::builder_multi(Code::ADD_SP_i_T4, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
let Rd_pre = instr.op1().as_register()?.encode();
let i_imm3_imm8_pre = instr.op3().as_unsigned_immediate()? as u32;
let Rd = (Rd_pre & 15);
let i_imm3_imm8_pre = i_imm3_imm8_pre;
let imm8 = (i_imm3_imm8_pre & 255);
let imm3 = (i_imm3_imm8_pre >> 8) & 7;
let i = (i_imm3_imm8_pre >> 11) & 1;
let mut instr: u32 = 0b11110010000011010000000000000000;
instr |= (Rd & 15) << 8;
instr |= (imm8 & 255) << 0;
instr |= (imm3 & 7) << 12;
instr |= (i & 1) << 26;
let instr_1 = (instr & 0xffff) as u16;
let instr_2 = ((instr >> 16) & 0xffff) as u16;
buf.extend(instr_2.to_le_bytes());
buf.extend(instr_1.to_le_bytes());
return Ok(4);
}
Encoding::Alt2 => {
let Rd_pre = instr.op1().as_register()?.encode();
let i_imm3_imm8_pre = instr.op3().as_unsigned_immediate()? as u32;
let Rd = (Rd_pre & 15);
let i_imm3_imm8_pre = i_imm3_imm8_pre;
let imm8 = (i_imm3_imm8_pre & 255);
let imm3 = (i_imm3_imm8_pre >> 8) & 7;
let i = (i_imm3_imm8_pre >> 11) & 1;
let mut instr: u32 = 0b11110010000011010000000000000000;
instr |= (Rd & 15) << 8;
instr |= (imm8 & 255) << 0;
instr |= (imm3 & 7) << 12;
instr |= (i & 1) << 26;
let instr_1 = (instr & 0xffff) as u16;
let instr_2 = ((instr >> 16) & 0xffff) as u16;
buf.extend(instr_2.to_le_bytes());
buf.extend(instr_1.to_le_bytes());
return Ok(4);
}
_ => todo!()
}
unreachable!()
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
Self::encode(instr, buf)
}
Encoding::Alt2 => {
Self::encode(instr, buf)
}
_ => todo!()
}
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(Register::SP) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(Register::SP) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::SignedImmediate(i) = op {
if *i < 0 || *i > 4095 {
todo!()
}
return Ok(())
}
if let Operand::UnsignedImmediate(i) = op {
if !(0..=4095).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::SignedImmediate(i) = op {
if *i < 0 || *i > 4095 {
todo!()
}
return Ok(())
}
if let Operand::UnsignedImmediate(i) = op {
if !(0..=4095).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.add_sp_i_t4, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t4, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.add_sp_i_t4, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t4, &instr, FormatterTextKind::Space)?;
if !instr.op1().is_none() {
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t4, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t4, &instr, FormatterTextKind::Comma)?;
};
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t4, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t4, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t4, &instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t4, &instr, 3)?;
return Ok(());
}
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.add_sp_i_t4, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t4, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.add_sp_i_t4, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t4, &instr, FormatterTextKind::Space)?;
if !instr.op1().is_none() {
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t4, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t4, &instr, FormatterTextKind::Comma)?;
};
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t4, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t4, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.add_sp_i_t4, &instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.add_sp_i_t4, &instr, 3)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum AddSpIT4Aliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum AddSpIT4Encodings {
Alt1,
Alt2,
}