Add a regmove instruction.

This will be used to locally change the register locations of values in
order to satisfy instruction constraints.
This commit is contained in:
Jakob Stoklund Olesen
2017-05-02 11:32:12 -07:00
parent 6fe4aa2f8d
commit 8cd67f08a9
11 changed files with 114 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ use ir::{Opcode, Type, Inst, Value, Ebb, JumpTable, SigRef, FuncRef, StackSlot,
MemFlags};
use ir::immediates::{Imm64, Uimm8, Ieee32, Ieee64, Offset32, Uoffset32};
use ir::condcodes::{IntCC, FloatCC};
use isa::RegUnit;
/// Base trait for instruction builders.
///

View File

@@ -687,7 +687,7 @@ impl<'a> fmt::Display for DisplayInst<'a> {
} else {
write!(f, "{}.{}", inst.opcode(), typevar)?;
}
write_operands(f, dfg, self.1)
write_operands(f, dfg, None, self.1)
}
}

View File

@@ -14,6 +14,7 @@ use ir::{Value, Type, Ebb, JumpTable, SigRef, FuncRef, StackSlot, MemFlags};
use ir::immediates::{Imm64, Uimm8, Ieee32, Ieee64, Offset32, Uoffset32};
use ir::condcodes::*;
use ir::types;
use isa::RegUnit;
use entity_list;
use ref_slice::{ref_slice, ref_slice_mut};
@@ -203,6 +204,12 @@ pub enum InstructionData {
args: [Value; 2],
offset: Offset32,
},
RegMove {
opcode: Opcode,
arg: Value,
src: RegUnit,
dst: RegUnit,
},
}
/// A variable list of `Value` operands used for function call arguments and passing arguments to

View File

@@ -284,7 +284,8 @@ impl<'a> Verifier<'a> {
&HeapLoad { .. } |
&HeapStore { .. } |
&Load { .. } |
&Store { .. } => {}
&Store { .. } |
&RegMove { .. } => {}
}
Ok(())

View File

@@ -225,12 +225,16 @@ fn write_instruction(w: &mut Write,
None => write!(w, "{}", opcode)?,
}
write_operands(w, &func.dfg, inst)?;
write_operands(w, &func.dfg, isa, inst)?;
writeln!(w, "")
}
/// Write the operands of `inst` to `w` with a prepended space.
pub fn write_operands(w: &mut Write, dfg: &DataFlowGraph, inst: Inst) -> Result {
pub fn write_operands(w: &mut Write,
dfg: &DataFlowGraph,
isa: Option<&TargetIsa>,
inst: Inst)
-> Result {
let pool = &dfg.value_lists;
use ir::instructions::InstructionData::*;
match dfg[inst] {
@@ -321,6 +325,19 @@ pub fn write_operands(w: &mut Write, dfg: &DataFlowGraph, inst: Inst) -> Result
offset,
..
} => write!(w, "{} {}, {}{}", flags, args[0], args[1], offset),
RegMove { arg, src, dst, .. } => {
if let Some(isa) = isa {
let regs = isa.register_info();
write!(w,
" {}, {} -> {}",
arg,
regs.display_regunit(src),
regs.display_regunit(dst))
} else {
write!(w, " {}, %{} -> %{}", arg, src, dst)
}
}
}
}