Add Intel iconst.i32 encoding.

This commit is contained in:
Jakob Stoklund Olesen
2017-06-30 11:41:06 -07:00
parent 9766fc3fcd
commit 3608be35a9
4 changed files with 26 additions and 3 deletions

View File

@@ -133,6 +133,19 @@ fn recipe_op1rid<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut
}
}
fn recipe_op1uid<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut CS) {
if let InstructionData::UnaryImm { imm, .. } = func.dfg[inst] {
let bits = func.encodings[inst].bits();
let reg = func.locations[func.dfg.first_result(inst)].unwrap_reg();
// The destination register is encoded in the low bits of the opcode. No ModR/M
put_op1(bits | (reg & 7), sink);
let imm: i64 = imm.into();
sink.put4(imm as u32);
} else {
panic!("Expected UnaryImm format: {:?}", func.dfg[inst]);
}
}
// Store recipes.
fn recipe_op1st<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut CS) {