Skip to content

Commit 2a586a8

Browse files
authored
[TableGen][DecoderEmitter] Remove dead OPC_Fail (#155229)
It can never be reached. It could be reached if we emitted an opcode that could fall outside the outermost scope, but emission of all such opcodes is guarded by `!isOutermostScope()`. That also means we never add fixups to the outermost scope, so avoid pushing an entry for it onto the stack.
1 parent d1cbe6e commit 2a586a8

File tree

12 files changed

+43
-61
lines changed

12 files changed

+43
-61
lines changed

llvm/include/llvm/MC/MCDecoderOps.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ enum DecoderOps {
3030
// nts_t NumToSkip)
3131
OPC_TryDecodeOrFail, // OPC_TryDecodeOrFail(uleb128 Opcode, uleb128 DIdx)
3232
OPC_SoftFail, // OPC_SoftFail(uleb128 PMask, uleb128 NMask)
33-
OPC_Fail // OPC_Fail()
3433
};
3534

3635
} // namespace llvm::MCD

llvm/test/TableGen/FixedLenDecoderEmitter/additional-encoding.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class I<dag out_ops, dag in_ops> : Instruction {
4747
// CHECK-NEXT: /* 59 */ MCD::OPC_CheckField, 6, 6, 0, 4, 0, // Skip to: 69
4848
// CHECK-NEXT: /* 65 */ MCD::OPC_Decode, {{[0-9]+}}, 2, 0, // Opcode: {{.*}}:NOP
4949
// CHECK-NEXT: /* 69 */ MCD::OPC_TryDecodeOrFail, {{[0-9]+}}, 2, 1,
50-
// CHECK-NEXT: /* 73 */ MCD::OPC_Fail,
5150

5251
class SHIFT<bits<2> opc> : I<(outs), (ins ShAmtOp:$shamt)>, EncSHIFT<opc>;
5352
def SHIFT0 : SHIFT<0>;

llvm/test/TableGen/FixedLenDecoderEmitter/big-filter.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ class I : Instruction {
1111

1212
// Check that a 64-bit filter with all bits set does not confuse DecoderEmitter.
1313
//
14-
// CHECK-LABEL: static const uint8_t DecoderTable128[35] = {
14+
// CHECK-LABEL: static const uint8_t DecoderTable128[34] = {
1515
// CHECK-NEXT: MCD::OPC_ExtractField, 0, 64,
1616
// CHECK-NEXT: MCD::OPC_FilterValue, 1, 8, 0,
1717
// CHECK-NEXT: MCD::OPC_CheckFieldOrFail, 127, 1, 1,
1818
// CHECK-NEXT: MCD::OPC_Decode, 187, 2, 0,
1919
// CHECK-NEXT: MCD::OPC_FilterValueOrFail, 255, 255, 255, 255, 255, 255, 255, 255, 255, 1,
2020
// CHECK-NEXT: MCD::OPC_CheckFieldOrFail, 127, 1, 0,
2121
// CHECK-NEXT: MCD::OPC_Decode, 186, 2, 0,
22-
// CHECK-NEXT: MCD::OPC_Fail,
2322
// CHECK-NEXT: };
2423

2524
def I1 : I {

llvm/test/TableGen/HwModeEncodeDecode.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ def baz : Instruction {
7070
}
7171
}
7272

73-
// DECODER-LABEL: DecoderTable_ModeA32[22] =
73+
// DECODER-LABEL: DecoderTable_ModeA32
7474
// DECODER-DAG: Opcode: fooTypeEncA:foo
7575
// DECODER-DAG: Opcode: bar
76-
// DECODER-LABEL: DecoderTable_ModeB32[30] =
76+
// DECODER-LABEL: DecoderTable_ModeB32
7777
// DECODER-DAG: Opcode: fooTypeEncB:foo
7878
// DECODER-DAG: Opcode: fooTypeEncA:baz
7979
// DECODER-DAG: Opcode: bar

llvm/test/TableGen/HwModeEncodeDecode2.td

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,26 @@ let OutOperandList = (outs) in {
9393
}
9494
}
9595

96-
// DECODER-LABEL: DecoderTable_ModeA32[22] =
96+
// DECODER-LABEL: DecoderTable_ModeA32
9797
// DECODER-DAG: Opcode: fooTypeEncA:foo
9898
// DECODER-DAG: Opcode: bar
99-
// DECODER-LABEL: DecoderTable_ModeB32[30] =
99+
// DECODER-LABEL: DecoderTable_ModeB32
100100
// DECODER-DAG: Opcode: fooTypeEncB:foo
101101
// DECODER-DAG: Opcode: fooTypeEncA:baz
102102
// DECODER-DAG: Opcode: bar
103-
// DECODER-LABEL: DecoderTableAlt_ModeA32[9] =
103+
// DECODER-LABEL: DecoderTableAlt_ModeA32
104104
// DECODER-DAG: Opcode: unrelated
105-
// DECODER-LABEL: DecoderTableAlt_ModeB32[9] =
105+
// DECODER-LABEL: DecoderTableAlt_ModeB32
106106
// DECODER-DAG: Opcode: unrelated
107107

108-
// DECODER-SUPPRESS-LABEL: DecoderTable32[9] =
108+
// DECODER-SUPPRESS-LABEL: DecoderTable32
109109
// DECODER-SUPPRESS-DAG: Opcode: bar
110-
// DECODER-SUPPRESS-LABEL: DecoderTable_ModeA32[9] =
110+
// DECODER-SUPPRESS-LABEL: DecoderTable_ModeA32
111111
// DECODER-SUPPRESS-DAG: Opcode: fooTypeEncA:foo
112112
// DECODER-SUPPRESS-NOT: Opcode: bar
113-
// DECODER-SUPPRESS-LABEL: DecoderTable_ModeB32[22] =
113+
// DECODER-SUPPRESS-LABEL: DecoderTable_ModeB32
114114
// DECODER-SUPPRESS-DAG: Opcode: fooTypeEncB:foo
115115
// DECODER-SUPPRESS-DAG: Opcode: fooTypeEncA:baz
116116
// DECODER-SUPPRESS-NOT: Opcode: bar
117-
// DECODER-SUPPRESS-LABEL: DecoderTableAlt32[9] =
117+
// DECODER-SUPPRESS-LABEL: DecoderTableAlt32
118118
// DECODER-SUPPRESS-DAG: Opcode: unrelated

llvm/test/TableGen/HwModeEncodeDecode3.td

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,46 +116,46 @@ def unrelated: Instruction {
116116
// significant duplication of DecoderTables. The four tables ‘DecoderTableAlt32’,
117117
// ‘DecoderTableAlt_ModeA32’, ‘DecoderTableAlt_ModeB32’ and 'DecoderTable_ModeC32' are
118118
// exact duplicates and could effectively be merged into one.
119-
// DECODER-LABEL: DecoderTable32[9] =
119+
// DECODER-LABEL: DecoderTable32
120120
// DECODER-DAG: Opcode: bar
121-
// DECODER-LABEL: DecoderTable64[9] =
121+
// DECODER-LABEL: DecoderTable64
122122
// DECODER-DAG: Opcode: fooTypeEncDefault:foo
123-
// DECODER-LABEL: DecoderTable_ModeA32[22] =
123+
// DECODER-LABEL: DecoderTable_ModeA32
124124
// DECODER-DAG: Opcode: fooTypeEncA:foo
125125
// DECODER-DAG: Opcode: bar
126-
// DECODER-LABEL: DecoderTable_ModeB32[30] =
126+
// DECODER-LABEL: DecoderTable_ModeB32
127127
// DECODER-DAG: Opcode: fooTypeEncB:foo
128128
// DECODER-DAG: Opcode: fooTypeEncA:baz
129129
// DECODER-DAG: Opcode: bar
130-
// DECODER-LABEL: DecoderTable_ModeC32[22] =
130+
// DECODER-LABEL: DecoderTable_ModeC32
131131
// DECODER-DAG: Opcode: fooTypeEncC:foo
132132
// DECODER-DAG: Opcode: bar
133-
// DECODER-LABEL: DecoderTableAlt32[9] =
133+
// DECODER-LABEL: DecoderTableAlt32
134134
// DECODER-DAG: Opcode: unrelated
135-
// DECODER-LABEL: DecoderTableAlt_ModeA32[9] =
135+
// DECODER-LABEL: DecoderTableAlt_ModeA32
136136
// DECODER-DAG: Opcode: unrelated
137-
// DECODER-LABEL: DecoderTableAlt_ModeB32[9] =
137+
// DECODER-LABEL: DecoderTableAlt_ModeB32
138138
// DECODER-DAG: Opcode: unrelated
139-
// DECODER-LABEL: DecoderTableAlt_ModeC32[9] =
139+
// DECODER-LABEL: DecoderTableAlt_ModeC32
140140
// DECODER-DAG: Opcode: unrelated
141141

142142
// Under the 'O1' optimization level, unnecessary duplicate tables will be eliminated,
143143
// reducing the four ‘Alt’ tables down to just one.
144-
// DECODER-SUPPRESS-O1-LABEL: DecoderTable32[9] =
144+
// DECODER-SUPPRESS-O1-LABEL: DecoderTable32
145145
// DECODER-SUPPRESS-O1-DAG: Opcode: bar
146-
// DECODER-SUPPRESS-O1-LABEL: DecoderTable64[9] =
146+
// DECODER-SUPPRESS-O1-LABEL: DecoderTable64
147147
// DECODER-SUPPRESS-O1-DAG: Opcode: fooTypeEncDefault:foo
148-
// DECODER-SUPPRESS-O1-LABEL: DecoderTable_ModeA32[22] =
148+
// DECODER-SUPPRESS-O1-LABEL: DecoderTable_ModeA32
149149
// DECODER-SUPPRESS-O1-DAG: Opcode: fooTypeEncA:foo
150150
// DECODER-SUPPRESS-O1-DAG: Opcode: bar
151-
// DECODER-SUPPRESS-O1-LABEL: DecoderTable_ModeB32[30] =
151+
// DECODER-SUPPRESS-O1-LABEL: DecoderTable_ModeB32
152152
// DECODER-SUPPRESS-O1-DAG: Opcode: fooTypeEncB:foo
153153
// DECODER-SUPPRESS-O1-DAG: Opcode: fooTypeEncA:baz
154154
// DECODER-SUPPRESS-O1-DAG: Opcode: bar
155-
// DECODER-SUPPRESS-O1-LABEL: DecoderTable_ModeC32[22] =
155+
// DECODER-SUPPRESS-O1-LABEL: DecoderTable_ModeC32
156156
// DECODER-SUPPRESS-O1-DAG: Opcode: fooTypeEncC:foo
157157
// DECODER-SUPPRESS-O1-DAG: Opcode: bar
158-
// DECODER-SUPPRESS-O1-LABEL: DecoderTableAlt32[9] =
158+
// DECODER-SUPPRESS-O1-LABEL: DecoderTableAlt32
159159
// DECODER-SUPPRESS-O1-DAG: Opcode: unrelated
160160

161161
// Under the 'O2' optimization condition, instructions possessing the 'EncodingByHwMode'
@@ -164,22 +164,22 @@ def unrelated: Instruction {
164164
// attribute but are within the same DecoderNamespace will be stored in the 'Default' table. This
165165
// approach will significantly reduce instruction redundancy, but it necessitates users to thoroughly
166166
// consider the interplay between HwMode and DecoderNamespace for their instructions.
167-
// DECODER-SUPPRESS-O2-LABEL: DecoderTable32[9] =
167+
// DECODER-SUPPRESS-O2-LABEL: DecoderTable32
168168
// DECODER-SUPPRESS-O2-DAG: Opcode: bar
169-
// DECODER-SUPPRESS-O2-LABEL: DecoderTable64[9] =
169+
// DECODER-SUPPRESS-O2-LABEL: DecoderTable64
170170
// DECODER-SUPPRESS-O2-NOT: Opcode: bar
171171
// DECODER-SUPPRESS-O2-DAG: Opcode: fooTypeEncDefault:foo
172-
// DECODER-SUPPRESS-O2-LABEL: DecoderTable_ModeA32[9] =
172+
// DECODER-SUPPRESS-O2-LABEL: DecoderTable_ModeA32
173173
// DECODER-SUPPRESS-O2-DAG: Opcode: fooTypeEncA:foo
174174
// DECODER-SUPPRESS-O2-NOT: Opcode: bar
175-
// DECODER-SUPPRESS-O2-LABEL: DecoderTable_ModeB32[22] =
175+
// DECODER-SUPPRESS-O2-LABEL: DecoderTable_ModeB32
176176
// DECODER-SUPPRESS-O2-DAG: Opcode: fooTypeEncB:foo
177177
// DECODER-SUPPRESS-O2-DAG: Opcode: fooTypeEncA:baz
178178
// DECODER-SUPPRESS-O2-NOT: Opcode: bar
179-
// DECODER-SUPPRESS-O2-LABEL: DecoderTable_ModeC32[13] =
179+
// DECODER-SUPPRESS-O2-LABEL: DecoderTable_ModeC32
180180
// DECODER-SUPPRESS-O2-DAG: Opcode: fooTypeEncC:foo
181181
// DECODER-SUPPRESS-O2-NOT: Opcode: bar
182-
// DECODER-SUPPRESS-O2-LABEL: DecoderTableAlt32[9] =
182+
// DECODER-SUPPRESS-O2-LABEL: DecoderTableAlt32
183183
// DECODER-SUPPRESS-O2-DAG: Opcode: unrelated
184184

185185
// For 'bar' and 'unrelated', we didn't assign any HwModes for them,

llvm/test/TableGen/VarLenDecoder.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ def FOO32 : MyVarInst<MemOp32> {
5252
// CHECK-SMALL-NEXT: /* 7 */ MCD::OPC_Decode, {{[0-9]+}}, {{[0-9]+}}, 0, // Opcode: FOO16
5353
// CHECK-SMALL-NEXT: /* 11 */ MCD::OPC_FilterValueOrFail, 9,
5454
// CHECK-SMALL-NEXT: /* 13 */ MCD::OPC_Decode, {{[0-9]+}}, {{[0-9]+}}, 1, // Opcode: FOO32
55-
// CHECK-SMALL-NEXT: /* 17 */ MCD::OPC_Fail,
55+
// CHECK-SMALL-NEXT: };
5656

5757
// CHECK-LARGE: /* 0 */ MCD::OPC_ExtractField, 3, 5, // Inst{7-3} ...
5858
// CHECK-LARGE-NEXT: /* 3 */ MCD::OPC_FilterValue, 8, 4, 0, 0, // Skip to: 12
5959
// CHECK-LARGE-NEXT: /* 8 */ MCD::OPC_Decode, {{[0-9]+}}, {{[0-9]+}}, 0, // Opcode: FOO16
6060
// CHECK-LARGE-NEXT: /* 12 */ MCD::OPC_FilterValueOrFail, 9,
6161
// CHECK-LARGE-NEXT: /* 14 */ MCD::OPC_Decode, {{[0-9]+}}, {{[0-9]+}}, 1, // Opcode: FOO32
62-
// CHECK-LARGE-NEXT: /* 18 */ MCD::OPC_Fail,
62+
// CHECK-LARGE-NEXT: };
6363

6464
// Instruction length table
6565
// CHECK: 27,

llvm/test/TableGen/trydecode-emission.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def InstB : TestInstruction {
3939
// CHECK-NEXT: /* 5 */ MCD::OPC_CheckField, 2, 2, 0, 6, 0, // Skip to: 17
4040
// CHECK-NEXT: /* 11 */ MCD::OPC_TryDecode, {{[0-9]+}}, {{[0-9]+}}, 0, 0, 0, // Opcode: InstB, DecodeIdx: {{[0-9]+}}, Skip to: 17
4141
// CHECK-NEXT: /* 17 */ MCD::OPC_Decode, {{[0-9]+}}, {{[0-9]+}}, 1, // Opcode: InstA, DecodeIdx: {{[0-9]+}}
42-
// CHECK-NEXT: /* 21 */ MCD::OPC_Fail,
42+
// CHECK-NEXT: };
4343

4444
// CHECK: if (!Check(S, DecodeInstB(MI, insn, Address, Decoder))) { DecodeComplete = false; return MCDisassembler::Fail; }
4545

@@ -52,7 +52,7 @@ def InstB : TestInstruction {
5252
// CHECK-LARGE-NEXT: /* 5 */ MCD::OPC_CheckField, 2, 2, 0, 7, 0, 0, // Skip to: 19
5353
// CHECK-LARGE-NEXT: /* 12 */ MCD::OPC_TryDecode, {{[0-9]+}}, {{[0-9]+}}, 0, 0, 0, 0, // Opcode: InstB, DecodeIdx: {{[0-9]+}}, Skip to: 19
5454
// CHECK-LARGE-NEXT: /* 19 */ MCD::OPC_Decode, {{[0-9]+}}, {{[0-9]+}}, 1, // Opcode: InstA, DecodeIdx: {{[0-9]+}}
55-
// CHECK-LARGE-NEXT: /* 23 */ MCD::OPC_Fail,
55+
// CHECK-LARGE-NEXT: };
5656

5757
// CHECK-LARGE: if (!Check(S, DecodeInstB(MI, insn, Address, Decoder))) { DecodeComplete = false; return MCDisassembler::Fail; }
5858

llvm/test/TableGen/trydecode-emission2.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def InstB : TestInstruction {
3939
// CHECK-NEXT: /* 16 */ MCD::OPC_TryDecode, {{[0-9]+}}, {{[0-9]+}}, 0, 0, 0, // Opcode: InstB, DecodeIdx: {{[0-9]+}}, Skip to: 22
4040
// CHECK-NEXT: /* 22 */ MCD::OPC_CheckFieldOrFail, 3, 2, 0,
4141
// CHECK-NEXT: /* 26 */ MCD::OPC_TryDecodeOrFail, {{[0-9]+}}, {{[0-9]+}}, 1,
42-
// CHECK-NEXT: /* 30 */ MCD::OPC_Fail,
42+
// CHECK-NEXT: };
4343

4444
// CHECK: if (!Check(S, DecodeInstB(MI, insn, Address, Decoder))) { DecodeComplete = false; return MCDisassembler::Fail; }
4545
// CHECK: if (!Check(S, DecodeInstA(MI, insn, Address, Decoder))) { DecodeComplete = false; return MCDisassembler::Fail; }
@@ -52,7 +52,7 @@ def InstB : TestInstruction {
5252
// CHECK-LARGE-NEXT: /* 17 */ MCD::OPC_TryDecode, {{[0-9]+}}, {{[0-9]+}}, 0, 0, 0, 0, // Opcode: InstB, DecodeIdx: {{[0-9]+}}, Skip to: 24
5353
// CHECK-LARGE-NEXT: /* 24 */ MCD::OPC_CheckFieldOrFail, 3, 2, 0,
5454
// CHECK-LARGE-NEXT: /* 28 */ MCD::OPC_TryDecodeOrFail, {{[0-9]+}}, {{[0-9]+}}, 1,
55-
// CHECK-LARGE-NEXT: /* 32 */ MCD::OPC_Fail,
55+
// CHECK-LARGE-NEXT: };
5656

5757
// CHECK-LARGE: if (!Check(S, DecodeInstB(MI, insn, Address, Decoder))) { DecodeComplete = false; return MCDisassembler::Fail; }
5858
// CHECK-LARGE: if (!Check(S, DecodeInstA(MI, insn, Address, Decoder))) { DecodeComplete = false; return MCDisassembler::Fail; }

llvm/test/TableGen/trydecode-emission3.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def InstB : TestInstruction {
4040
// CHECK-NEXT: /* 5 */ MCD::OPC_CheckField, 2, 2, 0, 6, 0, // Skip to: 17
4141
// CHECK-NEXT: /* 11 */ MCD::OPC_TryDecode, {{[0-9]+}}, {{[0-9]+}}, 0, 0, 0, // Opcode: InstB, DecodeIdx: {{[0-9]+}}, Skip to: 17
4242
// CHECK-NEXT: /* 17 */ MCD::OPC_Decode, {{[0-9]+}}, {{[0-9]+}}, 1, // Opcode: InstA
43-
// CHECK-NEXT: /* 21 */ MCD::OPC_Fail,
43+
// CHECK-NEXT: };
4444

4545
// CHECK: if (!Check(S, DecodeInstBOp(MI, tmp, Address, Decoder))) { DecodeComplete = false; return MCDisassembler::Fail; }
4646

@@ -49,6 +49,6 @@ def InstB : TestInstruction {
4949
// CHECK-LARGE-NEXT: /* 5 */ MCD::OPC_CheckField, 2, 2, 0, 7, 0, 0, // Skip to: 19
5050
// CHECK-LARGE-NEXT: /* 12 */ MCD::OPC_TryDecode, {{[0-9]+}}, {{[0-9]+}}, 0, 0, 0, 0, // Opcode: InstB, DecodeIdx: {{[0-9]+}}, Skip to: 19
5151
// CHECK-LARGE-NEXT: /* 19 */ MCD::OPC_Decode, {{[0-9]+}}, {{[0-9]+}}, 1, // Opcode: InstA, DecodeIdx: {{[0-9]+}}
52-
// CHECK-LARGE-NEXT: /* 23 */ MCD::OPC_Fail,
52+
// CHECK-LARGE-NEXT: };
5353

5454
// CHECK-LARGE: if (!Check(S, DecodeInstBOp(MI, tmp, Address, Decoder))) { DecodeComplete = false; return MCDisassembler::Fail; }

0 commit comments

Comments
 (0)