use super::consts::config::ConfigInstructions;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, Default)]
pub struct Config {
pub global: ConfigGlobal,
pub instructions: ConfigInstructions,
}
impl Config {
pub fn new() -> Self {
Self::default()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, Default)]
pub struct ConfigGlobal {
pub syntax: FormatSyntaxGlobal,
pub aliases: FormatAliasGlobal,
}
impl ConfigGlobal {
pub fn new() -> Self {
Self::default()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub struct ConfigInstruction<A> {
pub syntax: FormatSyntax,
pub aliases: Option<FormatAliasInstruction<A>>,
}
impl<A> ConfigInstruction<A> {
pub fn new() -> Self {
Self::default()
}
}
impl<A> Default for ConfigInstruction<A> {
fn default() -> Self {
Self {
syntax: FormatSyntax::default(),
aliases: None,
}
}
}
pub trait HasConfigInstruction {
fn syntax(&self) -> &FormatSyntax;
}
impl<A> HasConfigInstruction for ConfigInstruction<A> {
fn syntax(&self) -> &FormatSyntax {
&self.syntax
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, Default)]
pub enum FormatAliasGlobal {
Never,
#[default]
Recommended,
Always,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, Default)]
pub enum FormatAliasInstruction<A> {
Never,
#[default]
Recommended,
Preferred(A),
Always(A),
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, Default)]
pub enum FormatInteger {
#[default]
DecimalSigned,
DecimalUnsigned,
HexadecimalSigned,
HexadecimalUnsigned,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, Default)]
pub struct FormatSyntaxGlobal {
pub omit_src_dst_same_reg: bool,
pub omit_src_dst_diff_reg: bool,
pub omit_deref_null_const: bool,
pub positive_integer_format: FormatInteger,
pub negative_integer_format: FormatInteger,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, Default)]
pub struct FormatSyntax {
pub omit_src_dst_same_reg: Option<bool>,
pub omit_src_dst_diff_reg: Option<bool>,
pub omit_deref_null_const: Option<bool>,
pub positive_integer_format: Option<FormatInteger>,
pub negative_integer_format: Option<FormatInteger>,
}
impl FormatSyntax {
pub fn new() -> Self {
Self::default()
}
pub fn get_omit_src_dst_same_reg(&self, global: &FormatSyntaxGlobal) -> bool {
if let Some(value) = self.omit_src_dst_same_reg {
return value;
}
global.omit_src_dst_same_reg
}
pub fn get_omit_src_dst_diff_reg(&self, global: &FormatSyntaxGlobal) -> bool {
if let Some(value) = self.omit_src_dst_diff_reg {
return value;
}
global.omit_src_dst_diff_reg
}
pub fn get_positive_integer_format(&self, global: &FormatSyntaxGlobal) -> FormatInteger {
if let Some(value) = self.positive_integer_format {
return value;
}
global.positive_integer_format
}
pub fn get_negative_integer_format(&self, global: &FormatSyntaxGlobal) -> FormatInteger {
if let Some(value) = self.negative_integer_format {
return value;
}
global.negative_integer_format
}
}
pub struct ConfigLLVM {}
impl ConfigLLVM {
pub fn new() -> Config {
let mut config = Config::default();
config.global.syntax.omit_src_dst_same_reg = true;
config.global.syntax.omit_src_dst_diff_reg = false;
config.global.syntax.omit_deref_null_const = true;
config
.instructions
.and_32_log_imm
.syntax
.positive_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.and_32_log_imm
.syntax
.negative_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.and_64_log_imm
.syntax
.positive_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.and_64_log_imm
.syntax
.negative_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.ands_32s_log_imm
.syntax
.positive_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.ands_32s_log_imm
.syntax
.negative_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.ands_64s_log_imm
.syntax
.positive_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.ands_64s_log_imm
.syntax
.negative_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.eor_32_log_imm
.syntax
.positive_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.eor_32_log_imm
.syntax
.negative_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.eor_64_log_imm
.syntax
.positive_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.eor_64_log_imm
.syntax
.negative_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.orr_32_log_imm
.syntax
.positive_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.orr_32_log_imm
.syntax
.negative_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.orr_64_log_imm
.syntax
.positive_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.orr_64_log_imm
.syntax
.negative_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.tst_ands_32s_log_imm
.syntax
.positive_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.tst_ands_32s_log_imm
.syntax
.negative_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.tst_ands_64s_log_imm
.syntax
.positive_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config
.instructions
.tst_ands_64s_log_imm
.syntax
.negative_integer_format = Some(FormatInteger::HexadecimalUnsigned);
config.instructions.ldtadd_32_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.ldtadd_64_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.ldtaddl_32_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.ldtaddl_64_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.ldtclr_32_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.ldtclr_64_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.ldtclrl_32_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.ldtclrl_64_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.ldtset_32_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.ldtset_64_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.ldtsetl_32_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.ldtsetl_64_memop_unpriv.aliases = Some(FormatAliasInstruction::Never);
config.instructions.subps_64s_dp_2src.aliases = Some(FormatAliasInstruction::Never);
config
}
}