#![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 IclassBraa64pBranchReg;
impl IclassBraa64pBranchReg {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let M = (data >> 10) & 1;
let M_post = M;
let Rm = (data >> 0) & 31;
let Rm_post = Rm;
let op = (data >> 21) & 3;
let op_post = op;
let Z = (data >> 24) & 1;
let Z_post = Z;
let field_31 = (data >> 25) & 127;
let field_31_post = field_31;
let field_15 = (data >> 12) & 15;
let field_15_post = field_15;
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let A = (data >> 11) & 1;
let A_post = A;
let field_23 = (data >> 23) & 1;
let field_23_post = field_23;
let op2 = (data >> 16) & 31;
let op2_post = op2;
if ((Z_post == 1) && (M_post == 0)) {
return Braa64pBranchReg::decode(data as u32, decoder);
}
if ((Z_post == 0) && ((M_post == 0) && (Rm_post == 31))) {
return Braaz64BranchReg::decode(data as u32, decoder);
}
if ((Z_post == 1) && (M_post == 1)) {
return Brab64pBranchReg::decode(data as u32, decoder);
}
if ((Z_post == 0) && ((M_post == 1) && (Rm_post == 31))) {
return Brabz64BranchReg::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct Braa64pBranchReg;
impl Braa64pBranchReg {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::BRAA
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let Rm = (data >> 0) & 31;
let Rm_post = Rm;
let Rn_post = Rn;
let op_0 = Register::aarch64(Rn_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch64(Rm_post, true)?;
let mut instr = Instruction::builder(Code::BRAA_64P_branch_reg)
.operand(0, op_0)?
.operand(1, op_1)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rn_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let Rn = (Rn_pre & 31);
let Rm = (Rm_pre & 31);
let mut instr: u32 = 0b11010111000111110000100000000000;
instr |= (Rn & 31) << 5;
instr |= (Rm & 31) << 0;
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> {
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::XZR {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
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.braa_64p_branch_reg, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.braa_64p_branch_reg, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.braa_64p_branch_reg, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.braa_64p_branch_reg, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.braa_64p_branch_reg, instr, 1)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Braa64pBranchRegAliases {
None,
}
pub struct Braaz64BranchReg;
impl Braaz64BranchReg {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::BRAAZ
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let Rn_post = Rn;
let op_0 = Register::aarch64(Rn_post, false)?;
let mut instr = Instruction::builder(Code::BRAAZ_64_branch_reg)
.operand(0, op_0)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rn_pre = instr.op0().as_register()?.encode();
let Rn = (Rn_pre & 31);
let mut instr: u32 = 0b11010110000111110000100000011111;
instr |= (Rn & 31) << 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> {
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<()> {
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
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.braaz_64_branch_reg, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.braaz_64_branch_reg, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.braaz_64_branch_reg, instr, 0)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Braaz64BranchRegAliases {
None,
}
pub struct Brab64pBranchReg;
impl Brab64pBranchReg {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::BRAB
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let Rm = (data >> 0) & 31;
let Rm_post = Rm;
let Rn_post = Rn;
let op_0 = Register::aarch64(Rn_post, false)?;
let Rm_post = Rm;
let op_1 = Register::aarch64(Rm_post, true)?;
let mut instr = Instruction::builder(Code::BRAB_64P_branch_reg)
.operand(0, op_0)?
.operand(1, op_1)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rn_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let Rn = (Rn_pre & 31);
let Rm = (Rm_pre & 31);
let mut instr: u32 = 0b11010111000111110000110000000000;
instr |= (Rn & 31) << 5;
instr |= (Rm & 31) << 0;
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> {
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::XZR {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
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.brab_64p_branch_reg, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.brab_64p_branch_reg, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.brab_64p_branch_reg, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.brab_64p_branch_reg, instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.brab_64p_branch_reg, instr, 1)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Brab64pBranchRegAliases {
None,
}
pub struct Brabz64BranchReg;
impl Brabz64BranchReg {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::BRABZ
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let Rn_post = Rn;
let op_0 = Register::aarch64(Rn_post, false)?;
let mut instr = Instruction::builder(Code::BRABZ_64_branch_reg)
.operand(0, op_0)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rn_pre = instr.op0().as_register()?.encode();
let Rn = (Rn_pre & 31);
let mut instr: u32 = 0b11010110000111110000110000011111;
instr |= (Rn & 31) << 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> {
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<()> {
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
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.brabz_64_branch_reg, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.brabz_64_branch_reg, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.brabz_64_branch_reg, instr, 0)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Brabz64BranchRegAliases {
None,
}