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:
committed by
Dan Gohman
parent
de1d82b4ba
commit
79cea5e18b
@@ -156,8 +156,7 @@ impl Switch {
|
||||
|
||||
bx.switch_to_block(jt_ebb);
|
||||
let discr = bx.ins().iadd_imm(val, (first_index as i64).wrapping_neg());
|
||||
bx.ins().br_table(discr, jump_table);
|
||||
bx.ins().jump(otherwise, &[]);
|
||||
bx.ins().br_table(discr, otherwise, jump_table);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,8 +255,7 @@ ebb0:
|
||||
|
||||
ebb3:
|
||||
v3 = iadd_imm.i32 v1, 0
|
||||
br_table v3, jt0
|
||||
jump ebb0"
|
||||
br_table v3, ebb0, jt0"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -308,13 +306,11 @@ ebb8:
|
||||
|
||||
ebb11:
|
||||
v7 = iadd_imm.i32 v1, 0
|
||||
br_table v7, jt0
|
||||
jump ebb0
|
||||
br_table v7, ebb0, jt0
|
||||
|
||||
ebb10:
|
||||
v8 = iadd_imm.i32 v1, -10
|
||||
br_table v8, jt1
|
||||
jump ebb0"
|
||||
br_table v8, ebb0, jt1"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user