Infer REX prefix for SIMD store and vconst instructions
This commit is contained in:
@@ -1795,14 +1795,14 @@ fn define_simd(
|
||||
|
||||
let is_zero_128bit =
|
||||
InstructionPredicate::new_is_all_zeroes(&*formats.unary_const, "constant_handle");
|
||||
let template = rec_vconst_optimized.nonrex().opcodes(&PXOR);
|
||||
let template = rec_vconst_optimized.opcodes(&PXOR).infer_rex();
|
||||
e.enc_32_64_func(instruction.clone(), template, |builder| {
|
||||
builder.inst_predicate(is_zero_128bit)
|
||||
});
|
||||
|
||||
let is_ones_128bit =
|
||||
InstructionPredicate::new_is_all_ones(&*formats.unary_const, "constant_handle");
|
||||
let template = rec_vconst_optimized.nonrex().opcodes(&PCMPEQB);
|
||||
let template = rec_vconst_optimized.opcodes(&PCMPEQB).infer_rex();
|
||||
e.enc_32_64_func(instruction, template, |builder| {
|
||||
builder.inst_predicate(is_ones_128bit)
|
||||
});
|
||||
@@ -1816,7 +1816,7 @@ fn define_simd(
|
||||
// in memory) but some performance measurements are needed.
|
||||
for ty in ValueType::all_lane_types().filter(allowed_simd_type) {
|
||||
let instruction = vconst.bind(vector(ty, sse_vector_size));
|
||||
let template = rec_vconst.nonrex().opcodes(&MOVUPS_LOAD);
|
||||
let template = rec_vconst.opcodes(&MOVUPS_LOAD).infer_rex();
|
||||
e.enc_32_64_maybe_isap(instruction, template, None); // from SSE
|
||||
}
|
||||
|
||||
@@ -1826,7 +1826,10 @@ fn define_simd(
|
||||
for ty in ValueType::all_lane_types().filter(allowed_simd_type) {
|
||||
// Store
|
||||
let bound_store = store.bind(vector(ty, sse_vector_size)).bind(Any);
|
||||
e.enc_32_64(bound_store.clone(), rec_fst.opcodes(&MOVUPS_STORE));
|
||||
e.enc_32_64(
|
||||
bound_store.clone(),
|
||||
rec_fst.opcodes(&MOVUPS_STORE).infer_rex(),
|
||||
);
|
||||
e.enc_32_64(bound_store.clone(), rec_fstDisp8.opcodes(&MOVUPS_STORE));
|
||||
e.enc_32_64(bound_store, rec_fstDisp32.opcodes(&MOVUPS_STORE));
|
||||
|
||||
|
||||
@@ -46,6 +46,16 @@ impl<'builder> RecipeGroup<'builder> {
|
||||
self.templates.push(template.clone());
|
||||
template
|
||||
}
|
||||
fn add_template_inferred(
|
||||
&mut self,
|
||||
recipe: EncodingRecipeBuilder,
|
||||
infer_function: &'static str,
|
||||
) -> Rc<Template<'builder>> {
|
||||
let template =
|
||||
Rc::new(Template::new(recipe, self.regs).inferred_rex_compute_size(infer_function));
|
||||
self.templates.push(template.clone());
|
||||
template
|
||||
}
|
||||
fn add_template(&mut self, template: Template<'builder>) -> Rc<Template<'builder>> {
|
||||
let template = Rc::new(template);
|
||||
self.templates.push(template.clone());
|
||||
@@ -1481,7 +1491,7 @@ pub(crate) fn define<'shared>(
|
||||
);
|
||||
|
||||
// XX /r register-indirect store of FPR with no offset.
|
||||
recipes.add_template_recipe(
|
||||
recipes.add_template_inferred(
|
||||
EncodingRecipeBuilder::new("fst", &formats.store, 1)
|
||||
.operands_in(vec![fpr, gpr])
|
||||
.inst_predicate(has_no_offset)
|
||||
@@ -1504,6 +1514,7 @@ pub(crate) fn define<'shared>(
|
||||
}
|
||||
"#,
|
||||
),
|
||||
"size_plus_maybe_sib_or_offset_inreg1_plus_rex_prefix_for_inreg0_inreg1",
|
||||
);
|
||||
|
||||
let has_small_offset =
|
||||
@@ -2515,7 +2526,7 @@ pub(crate) fn define<'shared>(
|
||||
),
|
||||
);
|
||||
|
||||
recipes.add_template_recipe(
|
||||
recipes.add_template_inferred(
|
||||
EncodingRecipeBuilder::new("vconst", &formats.unary_const, 5)
|
||||
.operands_out(vec![fpr])
|
||||
.clobbers_flags(false)
|
||||
@@ -2526,9 +2537,10 @@ pub(crate) fn define<'shared>(
|
||||
const_disp4(constant_handle, func, sink);
|
||||
"#,
|
||||
),
|
||||
"size_with_inferred_rex_for_outreg0",
|
||||
);
|
||||
|
||||
recipes.add_template_recipe(
|
||||
recipes.add_template_inferred(
|
||||
EncodingRecipeBuilder::new("vconst_optimized", &formats.unary_const, 1)
|
||||
.operands_out(vec![fpr])
|
||||
.clobbers_flags(false)
|
||||
@@ -2538,6 +2550,7 @@ pub(crate) fn define<'shared>(
|
||||
modrm_rr(out_reg0, out_reg0, sink);
|
||||
"#,
|
||||
),
|
||||
"size_with_inferred_rex_for_outreg0",
|
||||
);
|
||||
|
||||
recipes.add_template_recipe(
|
||||
|
||||
Reference in New Issue
Block a user