Skip to content

Commit 5b24e11

Browse files
committed
Remove instructions used by old br_table legalization
1 parent 783bb1f commit 5b24e11

14 files changed

Lines changed: 4 additions & 198 deletions

File tree

cranelift/codegen/meta/src/cdsl/instructions.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ pub(crate) struct InstructionContent {
7070
pub is_terminator: bool,
7171
/// True for all branch or jump instructions.
7272
pub is_branch: bool,
73-
/// True for all indirect branch or jump instructions.',
74-
pub is_indirect_branch: bool,
7573
/// Is this a call instruction?
7674
pub is_call: bool,
7775
/// Is this a return instruction?
@@ -145,7 +143,6 @@ pub(crate) struct InstructionBuilder {
145143
// See Instruction comments for the meaning of these fields.
146144
is_terminator: bool,
147145
is_branch: bool,
148-
is_indirect_branch: bool,
149146
is_call: bool,
150147
is_return: bool,
151148
is_ghost: bool,
@@ -168,7 +165,6 @@ impl InstructionBuilder {
168165

169166
is_terminator: false,
170167
is_branch: false,
171-
is_indirect_branch: false,
172168
is_call: false,
173169
is_return: false,
174170
is_ghost: false,
@@ -210,12 +206,6 @@ impl InstructionBuilder {
210206
self
211207
}
212208

213-
#[allow(clippy::wrong_self_convention)]
214-
pub fn is_indirect_branch(mut self, val: bool) -> Self {
215-
self.is_indirect_branch = val;
216-
self
217-
}
218-
219209
#[allow(clippy::wrong_self_convention)]
220210
pub fn is_call(mut self, val: bool) -> Self {
221211
self.is_call = val;
@@ -300,7 +290,6 @@ impl InstructionBuilder {
300290
imm_opnums,
301291
is_terminator: self.is_terminator,
302292
is_branch: self.is_branch,
303-
is_indirect_branch: self.is_indirect_branch,
304293
is_call: self.is_call,
305294
is_return: self.is_return,
306295
is_ghost: self.is_ghost,

cranelift/codegen/meta/src/gen_inst.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,6 @@ fn gen_opcodes(all_inst: &AllInstructions, fmt: &mut Formatter) {
468468
"True for all branch or jump instructions.",
469469
fmt,
470470
);
471-
gen_bool_accessor(
472-
all_inst,
473-
|inst| inst.is_indirect_branch,
474-
"is_indirect_branch",
475-
"True for all indirect branch or jump instructions.",
476-
fmt,
477-
);
478471
gen_bool_accessor(
479472
all_inst,
480473
|inst| inst.is_call,

cranelift/codegen/meta/src/shared/formats.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ pub(crate) struct Formats {
1313
pub(crate) branch_icmp: Rc<InstructionFormat>,
1414
pub(crate) branch_int: Rc<InstructionFormat>,
1515
pub(crate) branch_table: Rc<InstructionFormat>,
16-
pub(crate) branch_table_base: Rc<InstructionFormat>,
17-
pub(crate) branch_table_entry: Rc<InstructionFormat>,
1816
pub(crate) call: Rc<InstructionFormat>,
1917
pub(crate) call_indirect: Rc<InstructionFormat>,
2018
pub(crate) cond_trap: Rc<InstructionFormat>,
@@ -23,7 +21,6 @@ pub(crate) struct Formats {
2321
pub(crate) float_cond_trap: Rc<InstructionFormat>,
2422
pub(crate) func_addr: Rc<InstructionFormat>,
2523
pub(crate) heap_addr: Rc<InstructionFormat>,
26-
pub(crate) indirect_jump: Rc<InstructionFormat>,
2724
pub(crate) int_compare: Rc<InstructionFormat>,
2825
pub(crate) int_compare_imm: Rc<InstructionFormat>,
2926
pub(crate) int_cond: Rc<InstructionFormat>,
@@ -172,22 +169,6 @@ impl Formats {
172169
.imm(&entities.jump_table)
173170
.build(),
174171

175-
branch_table_entry: Builder::new("BranchTableEntry")
176-
.value()
177-
.value()
178-
.imm(&imm.uimm8)
179-
.imm(&entities.jump_table)
180-
.build(),
181-
182-
branch_table_base: Builder::new("BranchTableBase")
183-
.imm(&entities.jump_table)
184-
.build(),
185-
186-
indirect_jump: Builder::new("IndirectJump")
187-
.value()
188-
.imm(&entities.jump_table)
189-
.build(),
190-
191172
call: Builder::new("Call")
192173
.imm(&entities.func_ref)
193174
.varargs()

cranelift/codegen/meta/src/shared/instructions.rs

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -214,68 +214,6 @@ fn define_control_flow(
214214
TypeSetBuilder::new().ints(32..64).refs(32..64).build(),
215215
);
216216

217-
{
218-
let x = &Operand::new("x", iAddr).with_doc("index into jump table");
219-
let addr = &Operand::new("addr", iAddr);
220-
let Size = &Operand::new("Size", &imm.uimm8).with_doc("Size in bytes");
221-
let JT = &Operand::new("JT", &entities.jump_table);
222-
let entry = &Operand::new("entry", iAddr).with_doc("entry of jump table");
223-
224-
ig.push(
225-
Inst::new(
226-
"jump_table_entry",
227-
r#"
228-
Get an entry from a jump table.
229-
230-
Load a serialized ``entry`` from a jump table ``JT`` at a given index
231-
``addr`` with a specific ``Size``. The retrieved entry may need to be
232-
decoded after loading, depending upon the jump table type used.
233-
234-
Currently, the only type supported is entries which are relative to the
235-
base of the jump table.
236-
"#,
237-
&formats.branch_table_entry,
238-
)
239-
.operands_in(vec![x, addr, Size, JT])
240-
.operands_out(vec![entry])
241-
.can_load(true),
242-
);
243-
244-
ig.push(
245-
Inst::new(
246-
"jump_table_base",
247-
r#"
248-
Get the absolute base address of a jump table.
249-
250-
This is used for jump tables wherein the entries are stored relative to
251-
the base of jump table. In order to use these, generated code should first
252-
load an entry using ``jump_table_entry``, then use this instruction to add
253-
the relative base back to it.
254-
"#,
255-
&formats.branch_table_base,
256-
)
257-
.operands_in(vec![JT])
258-
.operands_out(vec![addr]),
259-
);
260-
261-
ig.push(
262-
Inst::new(
263-
"indirect_jump_table_br",
264-
r#"
265-
Branch indirectly via a jump table entry.
266-
267-
Unconditionally jump via a jump table entry that was previously loaded
268-
with the ``jump_table_entry`` instruction.
269-
"#,
270-
&formats.indirect_jump,
271-
)
272-
.operands_in(vec![addr, JT])
273-
.is_indirect_branch(true)
274-
.is_terminator(true)
275-
.is_branch(true),
276-
);
277-
}
278-
279217
ig.push(
280218
Inst::new(
281219
"debugtrap",

cranelift/codegen/src/ir/instructions.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ impl InstructionData {
229229
Self::BranchTable {
230230
table, destination, ..
231231
} => BranchInfo::Table(table, Some(destination)),
232-
Self::IndirectJump { table, .. } => BranchInfo::Table(table, None),
233232
_ => {
234233
debug_assert!(!self.opcode().is_branch());
235234
BranchInfo::NotABranch
@@ -248,7 +247,7 @@ impl InstructionData {
248247
| Self::BranchInt { destination, .. }
249248
| Self::BranchFloat { destination, .. }
250249
| Self::BranchIcmp { destination, .. } => Some(destination),
251-
Self::BranchTable { .. } | Self::IndirectJump { .. } => None,
250+
Self::BranchTable { .. } => None,
252251
_ => {
253252
debug_assert!(!self.opcode().is_branch());
254253
None
@@ -282,7 +281,7 @@ impl InstructionData {
282281
ref mut destination,
283282
..
284283
} => Some(destination),
285-
Self::BranchTable { .. } | Self::IndirectJump { .. } => None,
284+
Self::BranchTable { .. } => None,
286285
_ => {
287286
debug_assert!(!self.opcode().is_branch());
288287
None
@@ -297,8 +296,7 @@ impl InstructionData {
297296
&InstructionData::UnaryBool { imm, .. } => Some(DataValue::from(imm)),
298297
// 8-bit.
299298
&InstructionData::BinaryImm8 { imm, .. }
300-
| &InstructionData::TernaryImm8 { imm, .. }
301-
| &InstructionData::BranchTableEntry { imm, .. } => Some(DataValue::from(imm as i8)), // Note the switch from unsigned to signed.
299+
| &InstructionData::TernaryImm8 { imm, .. } => Some(DataValue::from(imm as i8)), // Note the switch from unsigned to signed.
302300
// 32-bit
303301
&InstructionData::UnaryIeee32 { imm, .. } => Some(DataValue::from(imm)),
304302
&InstructionData::HeapAddr { imm, .. } => {

cranelift/codegen/src/isa/aarch64/lower_inst.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,10 +2029,6 @@ pub(crate) fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
20292029
}
20302030
}
20312031

2032-
Opcode::JumpTableEntry | Opcode::JumpTableBase => {
2033-
panic!("Should not appear: we handle BrTable directly");
2034-
}
2035-
20362032
Opcode::Debugtrap => {
20372033
ctx.emit(Inst::Brk);
20382034
}
@@ -2180,7 +2176,6 @@ pub(crate) fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
21802176
| Opcode::BrIcmp
21812177
| Opcode::Brif
21822178
| Opcode::Brff
2183-
| Opcode::IndirectJumpTableBr
21842179
| Opcode::BrTable => {
21852180
panic!("Branch opcode reached non-branch lowering logic!");
21862181
}

cranelift/codegen/src/isa/s390x/lower.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,14 +2915,10 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
29152915
| Opcode::BrIcmp
29162916
| Opcode::Brif
29172917
| Opcode::Brff
2918-
| Opcode::IndirectJumpTableBr
29192918
| Opcode::BrTable => {
29202919
panic!("Branch opcode reached non-branch lowering logic!");
29212920
}
29222921

2923-
Opcode::JumpTableEntry | Opcode::JumpTableBase => {
2924-
panic!("Should not appear: we handle BrTable directly");
2925-
}
29262922

29272923
Opcode::Safepoint => {
29282924
panic!("safepoint instructions not used by new backend's safepoints!");

cranelift/codegen/src/isa/x64/lower.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6874,10 +6874,6 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
68746874
panic!("Unused opcode should not be encountered.");
68756875
}
68766876

6877-
Opcode::JumpTableEntry | Opcode::JumpTableBase => {
6878-
panic!("Should not appear: we handle BrTable directly");
6879-
}
6880-
68816877
Opcode::Trapz | Opcode::Trapnz | Opcode::ResumableTrapnz => {
68826878
panic!("trapz / trapnz / resumable_trapnz should have been removed by legalization!");
68836879
}
@@ -6889,7 +6885,6 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
68896885
| Opcode::BrIcmp
68906886
| Opcode::Brif
68916887
| Opcode::Brff
6892-
| Opcode::IndirectJumpTableBr
68936888
| Opcode::BrTable => {
68946889
panic!("Branch opcode reached non-branch lowering logic!");
68956890
}

cranelift/codegen/src/verifier/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -663,11 +663,6 @@ impl<'a> Verifier<'a> {
663663
self.verify_block(inst, destination, errors)?;
664664
self.verify_jump_table(inst, table, errors)?;
665665
}
666-
BranchTableBase { table, .. }
667-
| BranchTableEntry { table, .. }
668-
| IndirectJump { table, .. } => {
669-
self.verify_jump_table(inst, table, errors)?;
670-
}
671666
Call {
672667
func_ref, ref args, ..
673668
} => {

cranelift/codegen/src/write.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,6 @@ pub fn write_operands(w: &mut dyn Write, dfg: &DataFlowGraph, inst: Inst) -> fmt
462462
table,
463463
..
464464
} => write!(w, " {}, {}, {}", arg, destination, table),
465-
BranchTableBase { table, .. } => write!(w, " {}", table),
466-
BranchTableEntry {
467-
args, imm, table, ..
468-
} => write!(w, " {}, {}, {}, {}", args[0], args[1], imm, table),
469-
IndirectJump { arg, table, .. } => write!(w, " {}, {}", arg, table),
470465
Call {
471466
func_ref, ref args, ..
472467
} => write!(w, " {}({})", func_ref, DisplayValues(args.as_slice(pool))),

0 commit comments

Comments
 (0)