#![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 IclassCbgt32Regs;
impl IclassCbgt32Regs {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let field_30 = (data >> 24) & 127;
let field_30_post = field_30;
let sf = (data >> 31) & 1;
let sf_post = sf;
let cc = (data >> 21) & 7;
let cc_post = cc;
let field_15 = (data >> 14) & 3;
let field_15_post = field_15;
if ((sf_post == 0) && (cc_post == 0)) {
return Cbgt32Regs::decode(data as u32, decoder);
}
if ((sf_post == 0) && (cc_post == 1)) {
return Cbge32Regs::decode(data as u32, decoder);
}
if ((sf_post == 0) && (cc_post == 2)) {
return Cbhi32Regs::decode(data as u32, decoder);
}
if ((sf_post == 0) && (cc_post == 3)) {
return Cbhs32Regs::decode(data as u32, decoder);
}
if ((sf_post == 0) && (cc_post == 6)) {
return Cbeq32Regs::decode(data as u32, decoder);
}
if ((sf_post == 0) && (cc_post == 7)) {
return Cbne32Regs::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 0)) {
return Cbgt64Regs::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 1)) {
return Cbge64Regs::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 2)) {
return Cbhi64Regs::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 3)) {
return Cbhs64Regs::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 6)) {
return Cbeq64Regs::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 7)) {
return Cbne64Regs::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct Cbgt32Regs;
impl Cbgt32Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBGT
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch32(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch32(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBGT_32_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110100000000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbgt_32_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_32_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_32_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_32_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_32_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbgt32RegsAliases {
None,
}
pub struct Cbge32Regs;
impl Cbge32Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBGE
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch32(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch32(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBGE_32_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110100001000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbge_32_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbge_32_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbge_32_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbge_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbge_32_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbge_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbge_32_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbge32RegsAliases {
None,
}
pub struct Cbhi32Regs;
impl Cbhi32Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBHI
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch32(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch32(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBHI_32_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110100010000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbhi_32_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_32_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_32_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_32_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_32_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbhi32RegsAliases {
None,
}
pub struct Cbhs32Regs;
impl Cbhs32Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBHS
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch32(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch32(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBHS_32_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110100011000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbhs_32_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhs_32_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhs_32_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhs_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhs_32_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhs_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhs_32_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbhs32RegsAliases {
None,
}
pub struct Cbeq32Regs;
impl Cbeq32Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBEQ
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch32(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch32(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBEQ_32_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110100110000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbeq_32_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_32_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_32_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_32_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_32_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbeq32RegsAliases {
None,
}
pub struct Cbne32Regs;
impl Cbne32Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBNE
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch32(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch32(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBNE_32_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110100111000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbne_32_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_32_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_32_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_32_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_32_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_32_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbne32RegsAliases {
None,
}
pub struct Cbgt64Regs;
impl Cbgt64Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBGT
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch64(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch64(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBGT_64_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110100000000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbgt_64_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_64_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_64_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_64_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_64_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbgt64RegsAliases {
None,
}
pub struct Cbge64Regs;
impl Cbge64Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBGE
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch64(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch64(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBGE_64_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110100001000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbge_64_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbge_64_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbge_64_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbge_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbge_64_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbge_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbge_64_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbge64RegsAliases {
None,
}
pub struct Cbhi64Regs;
impl Cbhi64Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBHI
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch64(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch64(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBHI_64_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110100010000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbhi_64_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_64_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_64_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_64_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_64_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbhi64RegsAliases {
None,
}
pub struct Cbhs64Regs;
impl Cbhs64Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBHS
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch64(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch64(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBHS_64_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110100011000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbhs_64_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhs_64_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhs_64_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhs_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhs_64_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhs_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhs_64_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbhs64RegsAliases {
None,
}
pub struct Cbeq64Regs;
impl Cbeq64Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBEQ
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch64(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch64(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBEQ_64_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110100110000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbeq_64_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_64_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_64_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_64_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_64_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbeq64RegsAliases {
None,
}
pub struct Cbne64Regs;
impl Cbne64Regs {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBNE
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 31;
let Rm_post = Rm;
let imm9 = (data >> 5) & 511;
let imm9_post = imm9;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch64(Rt_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch64(Rm_post, false)?;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBNE_64_regs)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
if decoder.block_decoding {
let pc = match instr.op2().as_label()? {
Label::Label(imm) => (decoder.pc as i128 + imm as i128) as u64,
_ => unreachable!(),
};
decoder.labels.insert(pc);
instr.set_op(2, Label::LabelName(pc as u64))?;
}
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let Rm = (Rm_pre & 31);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110100111000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rm & 31) << 16;
instr |= (imm9 & 511) << 5;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
if let Label::LabelName(label_name) = instr.op2().as_label()? {
if let Some(label_pc) = labels.get(&label_name) {
let pc = *label_pc as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
} else {
let pc = label_name as i128 - instr.pc as i128;
instr.set_op(2, Label::decode(pc as i64))?;
}
}
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Label(Label::LabelName(_)) = op {
return Ok(())
}
if let Operand::Label(Label::Label(i)) = op {
if !(-1024..=1020).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.cbne_64_regs, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_64_regs, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_64_regs, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_64_regs, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_64_regs, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_64_regs, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbne64RegsAliases {
None,
}