Add more comments explaining ghost instructions.

This commit is contained in:
Dan Gohman
2018-11-06 10:44:28 -08:00
committed by Benjamin Bouvier
parent 26da67b394
commit 997424a4c5
3 changed files with 9 additions and 2 deletions

View File

@@ -92,7 +92,8 @@ class Instruction(object):
:param is_indirect_branch: This is an indirect branch instruction.
:param is_call: This is a call instruction.
:param is_return: This is a return instruction.
:param is_ghost: This is a ghost instruction.
:param is_ghost: This is a ghost instruction, which has no encoding and no
other register allocation constraints.
:param can_trap: This instruction can trap.
:param can_load: This instruction can load from memory.
:param can_store: This instruction can store to memory.

View File

@@ -166,6 +166,8 @@ impl<'a> Context<'a> {
while let Some(inst) = self.cur.next_inst() {
self.cur.use_srcloc(inst);
if !self.cur.func.dfg[inst].opcode().is_ghost() {
// This is an instruction which either has an encoding or carries ABI-related
// register allocation constraints.
let enc = self.cur.func.encodings[inst];
let constraints = self.encinfo.operand_constraints(enc);
if self.visit_inst(inst, constraints, tracker, &mut regs) {
@@ -175,7 +177,7 @@ impl<'a> Context<'a> {
self.cur.goto_inst(inst);
}
} else {
// This is a ghost instruction with no encoding.
// This is a ghost instruction with no encoding and no extra constraints.
let (_throughs, kills) = tracker.process_ghost(inst);
self.process_ghost_kills(kills, &mut regs);
}

View File

@@ -126,10 +126,14 @@ impl<'a> Context<'a> {
// visit_ebb_header() places us at the first interesting instruction in the EBB.
while let Some(inst) = self.cur.current_inst() {
if !self.cur.func.dfg[inst].opcode().is_ghost() {
// This instruction either has an encoding or has ABI constraints, so visit it to
// insert spills and fills as needed.
let encoding = self.cur.func.encodings[inst];
self.visit_inst(ebb, inst, encoding, tracker);
tracker.drop_dead(inst);
} else {
// This is a ghost instruction with no encoding and no extra constraints, so we can
// just skip over it.
self.cur.next_inst();
}
}