[meta] Remove name lookups in formats;
This does a lot at once, since there was no clear way to split the three commits: - Instruction need to be passed an explicit InstructionFormat, - InstructionFormat deduplication is checked once all entities have been defined;
This commit is contained in:
@@ -374,7 +374,7 @@ pub(crate) fn define(
|
||||
r: &RecipeGroup,
|
||||
) -> PerCpuModeEncodings {
|
||||
let shared = &shared_defs.instructions;
|
||||
let formats = &shared_defs.format_registry;
|
||||
let formats = &shared_defs.formats;
|
||||
|
||||
// Shorthands for instructions.
|
||||
let adjust_sp_down = shared.by_name("adjust_sp_down");
|
||||
@@ -774,8 +774,8 @@ pub(crate) fn define(
|
||||
e.enc64(iconst.bind(I32), rec_pu_id.opcodes(&MOV_IMM));
|
||||
|
||||
// The 32-bit immediate movl also zero-extends to 64 bits.
|
||||
let f_unary_imm = formats.by_name("UnaryImm");
|
||||
let is_unsigned_int32 = InstructionPredicate::new_is_unsigned_int(&*f_unary_imm, "imm", 32, 0);
|
||||
let is_unsigned_int32 =
|
||||
InstructionPredicate::new_is_unsigned_int(&*formats.unary_imm, "imm", 32, 0);
|
||||
|
||||
e.enc64_func(
|
||||
iconst.bind(I64),
|
||||
@@ -801,7 +801,7 @@ pub(crate) fn define(
|
||||
}
|
||||
e.enc64(bconst.bind(B64), rec_pu_id_bool.opcodes(&MOV_IMM).rex());
|
||||
|
||||
let is_zero_int = InstructionPredicate::new_is_zero_int(f_unary_imm, "imm");
|
||||
let is_zero_int = InstructionPredicate::new_is_zero_int(&formats.unary_imm, "imm");
|
||||
e.enc_both_instp(
|
||||
iconst.bind(I8),
|
||||
rec_u_id_z.opcodes(&XORB),
|
||||
@@ -880,8 +880,8 @@ pub(crate) fn define(
|
||||
e.enc64_isap(ctz.bind(I32), rec_urm.opcodes(&TZCNT), use_bmi1);
|
||||
|
||||
// Loads and stores.
|
||||
let f_load_complex = formats.by_name("LoadComplex");
|
||||
let is_load_complex_length_two = InstructionPredicate::new_length_equals(&*f_load_complex, 2);
|
||||
let is_load_complex_length_two =
|
||||
InstructionPredicate::new_length_equals(&*formats.load_complex, 2);
|
||||
|
||||
for recipe in &[rec_ldWithIndex, rec_ldWithIndexDisp8, rec_ldWithIndexDisp32] {
|
||||
e.enc_i32_i64_instp(
|
||||
@@ -925,9 +925,8 @@ pub(crate) fn define(
|
||||
);
|
||||
}
|
||||
|
||||
let f_store_complex = formats.by_name("StoreComplex");
|
||||
let is_store_complex_length_three =
|
||||
InstructionPredicate::new_length_equals(&*f_store_complex, 3);
|
||||
InstructionPredicate::new_length_equals(&*formats.store_complex, 3);
|
||||
|
||||
for recipe in &[rec_stWithIndex, rec_stWithIndexDisp8, rec_stWithIndexDisp32] {
|
||||
e.enc_i32_i64_instp(
|
||||
@@ -1233,8 +1232,8 @@ pub(crate) fn define(
|
||||
);
|
||||
|
||||
// 64-bit, colocated, both PIC and non-PIC. Use the lea instruction's pc-relative field.
|
||||
let f_func_addr = formats.by_name("FuncAddr");
|
||||
let is_colocated_func = InstructionPredicate::new_is_colocated_func(&*f_func_addr, "func_ref");
|
||||
let is_colocated_func =
|
||||
InstructionPredicate::new_is_colocated_func(&*formats.func_addr, "func_ref");
|
||||
e.enc64_instp(
|
||||
func_addr.bind(I64),
|
||||
rec_pcrel_fnaddr8.opcodes(&LEA).rex().w(),
|
||||
@@ -1293,8 +1292,7 @@ pub(crate) fn define(
|
||||
e.enc32(call, rec_call_id.opcodes(&CALL_RELATIVE));
|
||||
|
||||
// 64-bit, colocated, both PIC and non-PIC. Use the call instruction's pc-relative field.
|
||||
let f_call = formats.by_name("Call");
|
||||
let is_colocated_func = InstructionPredicate::new_is_colocated_func(&*f_call, "func_ref");
|
||||
let is_colocated_func = InstructionPredicate::new_is_colocated_func(&*formats.call, "func_ref");
|
||||
e.enc64_instp(call, rec_call_id.opcodes(&CALL_RELATIVE), is_colocated_func);
|
||||
|
||||
// 64-bit, non-colocated, PIC. There is no 64-bit non-colocated non-PIC version, since non-PIC
|
||||
@@ -1564,18 +1562,16 @@ pub(crate) fn define(
|
||||
|
||||
// Floating-point constants equal to 0.0 can be encoded using either `xorps` or `xorpd`, for
|
||||
// 32-bit and 64-bit floats respectively.
|
||||
let f_unary_ieee32 = formats.by_name("UnaryIeee32");
|
||||
let is_zero_32_bit_float =
|
||||
InstructionPredicate::new_is_zero_32bit_float(&*f_unary_ieee32, "imm");
|
||||
InstructionPredicate::new_is_zero_32bit_float(&*formats.unary_ieee32, "imm");
|
||||
e.enc32_instp(
|
||||
f32const,
|
||||
rec_f32imm_z.opcodes(&XORPS),
|
||||
is_zero_32_bit_float.clone(),
|
||||
);
|
||||
|
||||
let f_unary_ieee64 = formats.by_name("UnaryIeee64");
|
||||
let is_zero_64_bit_float =
|
||||
InstructionPredicate::new_is_zero_64bit_float(&*f_unary_ieee64, "imm");
|
||||
InstructionPredicate::new_is_zero_64bit_float(&*formats.unary_ieee64, "imm");
|
||||
e.enc32_instp(
|
||||
f64const,
|
||||
rec_f64imm_z.opcodes(&XORPD),
|
||||
@@ -1847,18 +1843,17 @@ pub(crate) fn define(
|
||||
// this must be encoded prior to the MOVUPS implementation (below) so the compiler sees this
|
||||
// encoding first
|
||||
for ty in ValueType::all_lane_types().filter(allowed_simd_type) {
|
||||
let f_unary_const = formats.by_name("UnaryConst");
|
||||
let instruction = vconst.bind(vector(ty, sse_vector_size));
|
||||
|
||||
let is_zero_128bit =
|
||||
InstructionPredicate::new_is_all_zeroes(&*f_unary_const, "constant_handle");
|
||||
InstructionPredicate::new_is_all_zeroes(&*formats.unary_const, "constant_handle");
|
||||
let template = rec_vconst_optimized.nonrex().opcodes(&PXOR);
|
||||
e.enc_32_64_func(instruction.clone(), template, |builder| {
|
||||
builder.inst_predicate(is_zero_128bit)
|
||||
});
|
||||
|
||||
let is_ones_128bit =
|
||||
InstructionPredicate::new_is_all_ones(&*f_unary_const, "constant_handle");
|
||||
InstructionPredicate::new_is_all_ones(&*formats.unary_const, "constant_handle");
|
||||
let template = rec_vconst_optimized.nonrex().opcodes(&PCMPEQB);
|
||||
e.enc_32_64_func(instruction, template, |builder| {
|
||||
builder.inst_predicate(is_ones_128bit)
|
||||
@@ -2038,9 +2033,11 @@ pub(crate) fn define(
|
||||
};
|
||||
|
||||
let instruction = icmp.bind(vector(ty, sse_vector_size));
|
||||
let f_int_compare = formats.by_name("IntCompare");
|
||||
let has_eq_condition_code =
|
||||
InstructionPredicate::new_has_condition_code(&*f_int_compare, IntCC::Equal, "cond");
|
||||
let has_eq_condition_code = InstructionPredicate::new_has_condition_code(
|
||||
&*formats.int_compare,
|
||||
IntCC::Equal,
|
||||
"cond",
|
||||
);
|
||||
let template = rec_icscc_fpr.nonrex().opcodes(opcodes);
|
||||
e.enc_32_64_func(instruction, template, |builder| {
|
||||
let builder = builder.inst_predicate(has_eq_condition_code);
|
||||
|
||||
Reference in New Issue
Block a user