Add copy_special instruction.

This commit is contained in:
Tyler McMullen
2017-11-22 19:18:11 -08:00
committed by Jakob Stoklund Olesen
parent 8ed37e352e
commit cdf70ccb77
6 changed files with 36 additions and 0 deletions

View File

@@ -64,6 +64,7 @@ StackStore = InstructionFormat(VALUE, stack_slot, offset32)
HeapAddr = InstructionFormat(heap, VALUE, uimm32)
RegMove = InstructionFormat(VALUE, ('src', regunit), ('dst', regunit))
CopySpecial = InstructionFormat(('src', regunit), ('dst', regunit))
RegSpill = InstructionFormat(
VALUE, ('src', regunit), ('dst', entities.stack_slot))
RegFill = InstructionFormat(

View File

@@ -537,6 +537,13 @@ regmove = Instruction(
ins=(x, src, dst),
other_side_effects=True)
copy_special = Instruction(
'copy_special', r"""
Copies a value from one special register to another. e.g. rbp -> rsp.
""",
ins=(src, dst),
other_side_effects=True)
regspill = Instruction(
'regspill', r"""
Temporarily divert ``x`` from ``src`` to ``SS``.

View File

@@ -236,6 +236,11 @@ pub enum InstructionData {
src: RegUnit,
dst: RegUnit,
},
CopySpecial {
opcode: Opcode,
src: RegUnit,
dst: RegUnit,
},
RegSpill {
opcode: Opcode,
arg: Value,

View File

@@ -358,6 +358,7 @@ impl<'a> Verifier<'a> {
Load { .. } |
Store { .. } |
RegMove { .. } |
CopySpecial { .. } |
Trap { .. } |
CondTrap { .. } |
NullAry { .. } => {}

View File

@@ -394,6 +394,19 @@ pub fn write_operands(
write!(w, " {}, %{} -> %{}", arg, src, dst)
}
}
CopySpecial { src, dst, .. } => {
if let Some(isa) = isa {
let regs = isa.register_info();
write!(
w,
" {} -> {}",
regs.display_regunit(src),
regs.display_regunit(dst)
)
} else {
write!(w, " %{} -> %{}", src, dst)
}
}
RegSpill { arg, src, dst, .. } => {
if let Some(isa) = isa {
let regs = isa.register_info();

View File

@@ -2270,6 +2270,15 @@ impl<'a> Parser<'a> {
dst,
}
}
InstructionFormat::CopySpecial => {
let src = self.match_regunit(ctx.unique_isa)?;
self.match_token(
Token::Arrow,
"expected '->' between register units",
)?;
let dst = self.match_regunit(ctx.unique_isa)?;
InstructionData::CopySpecial { opcode, src, dst }
}
InstructionFormat::RegSpill => {
let arg = self.match_value("expected SSA value operand")?;
self.match_token(