Add x86 recipe for vconst

This commit is contained in:
Andrew Brown
2019-07-23 11:04:11 -07:00
committed by Dan Gohman
parent 407d24c013
commit 684721ca29
2 changed files with 23 additions and 1 deletions

View File

@@ -399,6 +399,7 @@ pub fn define<'shared>(
let f_unary_ieee32 = formats.by_name("UnaryIeee32"); let f_unary_ieee32 = formats.by_name("UnaryIeee32");
let f_unary_ieee64 = formats.by_name("UnaryIeee64"); let f_unary_ieee64 = formats.by_name("UnaryIeee64");
let f_unary_imm = formats.by_name("UnaryImm"); let f_unary_imm = formats.by_name("UnaryImm");
let f_unary_imm128 = formats.by_name("UnaryImm128");
// Predicates shorthands. // Predicates shorthands.
let use_sse41 = settings.predicate_by_name("use_sse41"); let use_sse41 = settings.predicate_by_name("use_sse41");
@@ -2382,6 +2383,19 @@ pub fn define<'shared>(
), ),
); );
recipes.add_template_recipe(
EncodingRecipeBuilder::new("vconst", f_unary_imm128, 5)
.operands_out(vec![fpr])
.clobbers_flags(false)
.emit(
r#"
{{PUT_OP}}(bits, rex2(0, out_reg0), sink);
modrm_riprel(out_reg0, sink);
const_disp4(imm, func, sink);
"#,
),
);
recipes.add_template_recipe( recipes.add_template_recipe(
EncodingRecipeBuilder::new("jt_base", f_branch_table_base, 5) EncodingRecipeBuilder::new("jt_base", f_branch_table_base, 5)
.operands_out(vec![gpr]) .operands_out(vec![gpr])

View File

@@ -4,7 +4,7 @@ use super::enc_tables::{needs_offset, needs_sib_byte};
use super::registers::RU; use super::registers::RU;
use crate::binemit::{bad_encoding, CodeSink, Reloc}; use crate::binemit::{bad_encoding, CodeSink, Reloc};
use crate::ir::condcodes::{CondCode, FloatCC, IntCC}; use crate::ir::condcodes::{CondCode, FloatCC, IntCC};
use crate::ir::{Ebb, Function, Inst, InstructionData, JumpTable, Opcode, TrapCode}; use crate::ir::{Constant, Ebb, Function, Inst, InstructionData, JumpTable, Opcode, TrapCode};
use crate::isa::{RegUnit, StackBase, StackBaseMask, StackRef, TargetIsa}; use crate::isa::{RegUnit, StackBase, StackBaseMask, StackRef, TargetIsa};
use crate::regalloc::RegDiversions; use crate::regalloc::RegDiversions;
@@ -341,3 +341,11 @@ fn jt_disp4<CS: CodeSink + ?Sized>(jt: JumpTable, func: &Function, sink: &mut CS
sink.put4(delta); sink.put4(delta);
sink.reloc_jt(Reloc::X86PCRelRodata4, jt); sink.reloc_jt(Reloc::X86PCRelRodata4, jt);
} }
/// Emit a four-byte displacement to `constant`
fn const_disp4<CS: CodeSink + ?Sized>(constant: Constant, func: &Function, sink: &mut CS) {
let offset = func.dfg.constants.get_offset(constant);
let delta = offset.wrapping_sub(sink.offset() + 4);
sink.put4(delta);
sink.reloc_constant(Reloc::X86PCRelRodata4, offset);
}