Encode iconst.i32 for RISC-V.

For large constants with the low 12 bits clear, we already have the
"lui" encoding. Add "addi %x0" encodings for signed 12-bit constants.
This commit is contained in:
Jakob Stoklund Olesen
2017-06-22 12:11:54 -07:00
parent e83e2ccf17
commit 9e02b9818f
5 changed files with 27 additions and 2 deletions

View File

@@ -160,6 +160,18 @@ fn recipe_i<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut CS) {
}
}
fn recipe_iz<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut CS) {
if let InstructionData::UnaryImm { imm, .. } = func.dfg[inst] {
put_i(func.encodings[inst].bits(),
0,
imm.into(),
func.locations[func.dfg.first_result(inst)].unwrap_reg(),
sink);
} else {
panic!("Expected UnaryImm format: {:?}", func.dfg[inst]);
}
}
fn recipe_iicmp<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut CS) {
if let InstructionData::IntCompareImm { arg, imm, .. } = func.dfg[inst] {
put_i(func.encodings[inst].bits(),