#![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 IclassCbgt32Imm;
impl IclassCbgt32Imm {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let field_14 = (data >> 14) & 1;
let field_14_post = field_14;
let cc = (data >> 21) & 7;
let cc_post = cc;
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 imm6 = (data >> 15) & 63;
let imm6_post = imm6;
if ((sf_post == 0) && (cc_post == 0)) {
return Cbgt32Imm::decode(data as u32, decoder);
}
if ((sf_post == 0) && (cc_post == 1)) {
return Cblt32Imm::decode(data as u32, decoder);
}
if ((sf_post == 0) && (cc_post == 2)) {
return Cbhi32Imm::decode(data as u32, decoder);
}
if ((sf_post == 0) && (cc_post == 3)) {
return Cblo32Imm::decode(data as u32, decoder);
}
if ((sf_post == 0) && (cc_post == 6)) {
return Cbeq32Imm::decode(data as u32, decoder);
}
if ((sf_post == 0) && (cc_post == 7)) {
return Cbne32Imm::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 0)) {
return Cbgt64Imm::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 1)) {
return Cblt64Imm::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 2)) {
return Cbhi64Imm::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 3)) {
return Cblo64Imm::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 6)) {
return Cbeq64Imm::decode(data as u32, decoder);
}
if ((sf_post == 1) && (cc_post == 7)) {
return Cbne64Imm::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct Cbgt32Imm;
impl Cbgt32Imm {
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 imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
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_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110101000000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_32_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_32_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_32_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_32_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_32_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbgt32ImmAliases {
None,
}
pub struct Cblt32Imm;
impl Cblt32Imm {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBLT
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBLT_32_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110101001000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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.cblt_32_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblt_32_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cblt_32_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblt_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblt_32_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cblt_32_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblt_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cblt_32_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cblt32ImmAliases {
None,
}
pub struct Cbhi32Imm;
impl Cbhi32Imm {
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 imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
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_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110101010000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_32_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_32_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_32_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_32_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_32_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbhi32ImmAliases {
None,
}
pub struct Cblo32Imm;
impl Cblo32Imm {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBLO
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBLO_32_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110101011000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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.cblo_32_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblo_32_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cblo_32_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblo_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblo_32_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cblo_32_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblo_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cblo_32_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cblo32ImmAliases {
None,
}
pub struct Cbeq32Imm;
impl Cbeq32Imm {
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 imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
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_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110101110000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_32_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_32_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_32_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_32_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_32_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbeq32ImmAliases {
None,
}
pub struct Cbne32Imm;
impl Cbne32Imm {
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 imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
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_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b01110101111000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_32_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_32_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_32_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_32_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_32_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_32_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbne32ImmAliases {
None,
}
pub struct Cbgt64Imm;
impl Cbgt64Imm {
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 imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
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_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110101000000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_64_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_64_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_64_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_64_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbgt_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbgt_64_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbgt64ImmAliases {
None,
}
pub struct Cblt64Imm;
impl Cblt64Imm {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBLT
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBLT_64_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110101001000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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.cblt_64_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblt_64_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cblt_64_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblt_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblt_64_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cblt_64_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblt_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cblt_64_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cblt64ImmAliases {
None,
}
pub struct Cbhi64Imm;
impl Cbhi64Imm {
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 imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
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_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110101010000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_64_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_64_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_64_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_64_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbhi_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbhi_64_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbhi64ImmAliases {
None,
}
pub struct Cblo64Imm;
impl Cblo64Imm {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::CBLO
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
let imm9_post = ((((imm9) as i64) * 4) << 53) >> 53;
let op_2 = Label::decode(imm9_post.into());
let mut instr = Instruction::builder(Code::CBLO_64_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110101011000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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.cblo_64_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblo_64_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cblo_64_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblo_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblo_64_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cblo_64_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cblo_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cblo_64_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cblo64ImmAliases {
None,
}
pub struct Cbeq64Imm;
impl Cbeq64Imm {
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 imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
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_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110101110000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_64_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_64_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_64_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_64_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbeq_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbeq_64_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbeq64ImmAliases {
None,
}
pub struct Cbne64Imm;
impl Cbne64Imm {
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 imm6 = (data >> 15) & 63;
let imm6_post = imm6;
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 imm6_post = imm6;
let op_1 = imm6_post as u32;
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_imm)
.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 imm6_pre = instr.op1().as_unsigned_immediate()? as u32;
let imm9_pre = instr.op2().as_label()?.encode()?;
let Rt = (Rt_pre & 31);
let imm6_pre = imm6_pre;
let imm6 = (imm6_pre & 63);
let imm9_pre = ((imm9_pre) / 4) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b11110101111000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (imm6 & 63) << 15;
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::UnsignedImmediate(i) = op {
if !(0..=63).contains(i) {
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_imm, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_64_imm, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_64_imm, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_64_imm, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_64_imm, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.cbne_64_imm, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.cbne_64_imm, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Cbne64ImmAliases {
None,
}