Implement jump tables (#453)

* Add 'jump_table_entry' and 'indirect_jump' instructions.

* Update CodeSink to keep track of code size. Pretty up clif-util's disassembly output.

* Only disassemble the machine portion of output. Pretty print the read-only data after it.

* Update switch frontend code to use new br_table instruction w/ default.
This commit is contained in:
Tyler McMullen
2018-10-03 11:04:21 -06:00
committed by Dan Gohman
parent de1d82b4ba
commit 79cea5e18b
39 changed files with 627 additions and 100 deletions

View File

@@ -117,6 +117,22 @@ pub enum SerInstData {
destination: String,
},
BranchTable {
opcode: String,
arg: String,
destination: String,
table: String,
},
BranchTableEntry {
opcode: String,
args: [String; 2],
imm: String,
table: String,
},
BranchTableBase {
opcode: String,
table: String,
},
IndirectJump {
opcode: String,
arg: String,
table: String,
@@ -445,7 +461,36 @@ pub fn get_inst_data(inst_index: Inst, func: &Function) -> SerInstData {
destination: destination.to_string(),
}
}
InstructionData::BranchTable { opcode, arg, table } => SerInstData::BranchTable {
InstructionData::BranchTable {
opcode,
arg,
destination,
table,
} => SerInstData::BranchTable {
opcode: opcode.to_string(),
arg: arg.to_string(),
destination: destination.to_string(),
table: table.to_string(),
},
InstructionData::BranchTableBase { opcode, table } => SerInstData::BranchTableBase {
opcode: opcode.to_string(),
table: table.to_string(),
},
InstructionData::BranchTableEntry {
opcode,
args,
imm,
table,
} => {
let hold_args = [args[0].to_string(), args[1].to_string()];
SerInstData::BranchTableEntry {
opcode: opcode.to_string(),
args: hold_args,
imm: imm.to_string(),
table: table.to_string(),
}
}
InstructionData::IndirectJump { opcode, arg, table } => SerInstData::IndirectJump {
opcode: opcode.to_string(),
arg: arg.to_string(),
table: table.to_string(),