summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/TableGen/trydecode-emission.td43
-rw-r--r--llvm/test/TableGen/trydecode-emission2.td44
-rw-r--r--llvm/test/TableGen/trydecode-emission3.td44
3 files changed, 131 insertions, 0 deletions
diff --git a/llvm/test/TableGen/trydecode-emission.td b/llvm/test/TableGen/trydecode-emission.td
new file mode 100644
index 00000000000..91c0e123857
--- /dev/null
+++ b/llvm/test/TableGen/trydecode-emission.td
@@ -0,0 +1,43 @@
+// RUN: llvm-tblgen -gen-disassembler -I %p/../../include %s | FileCheck %s
+
+// Check that if decoding of an instruction fails and the instruction does not
+// have a complete decoder method that can determine if the bitpattern is valid
+// or not then the decoder tries to find a more general instruction that
+// matches the bitpattern too.
+
+include "llvm/Target/Target.td"
+
+def archInstrInfo : InstrInfo { }
+
+def arch : Target {
+ let InstructionSet = archInstrInfo;
+}
+
+class TestInstruction : Instruction {
+ let Size = 1;
+ let OutOperandList = (outs);
+ let InOperandList = (ins);
+ field bits<8> Inst;
+ field bits<8> SoftFail = 0;
+}
+
+def InstA : TestInstruction {
+ let Inst = {0,0,0,0,?,?,?,?};
+ let AsmString = "InstA";
+}
+
+def InstB : TestInstruction {
+ let Inst = {0,0,0,0,0,0,?,?};
+ let AsmString = "InstB";
+ let DecoderMethod = "DecodeInstB";
+ let hasCompleteDecoder = 0;
+}
+
+// CHECK: /* 0 */ MCD::OPC_ExtractField, 4, 4, // Inst{7-4} ...
+// CHECK-NEXT: /* 3 */ MCD::OPC_FilterValue, 0, 14, 0, // Skip to: 21
+// CHECK-NEXT: /* 7 */ MCD::OPC_CheckField, 2, 2, 0, 5, 0, // Skip to: 18
+// CHECK-NEXT: /* 13 */ MCD::OPC_TryDecode, 24, 0, 0, 0, // Opcode: InstB, skip to: 18
+// CHECK-NEXT: /* 18 */ MCD::OPC_Decode, 23, 1, // Opcode: InstA
+// CHECK-NEXT: /* 21 */ MCD::OPC_Fail,
+
+// CHECK: if (DecodeInstB(MI, insn, Address, Decoder) == MCDisassembler::Fail) { DecodeComplete = false; return MCDisassembler::Fail; }
diff --git a/llvm/test/TableGen/trydecode-emission2.td b/llvm/test/TableGen/trydecode-emission2.td
new file mode 100644
index 00000000000..56ca6d33c24
--- /dev/null
+++ b/llvm/test/TableGen/trydecode-emission2.td
@@ -0,0 +1,44 @@
+// RUN: llvm-tblgen -gen-disassembler -I %p/../../include %s | FileCheck %s
+
+include "llvm/Target/Target.td"
+
+def archInstrInfo : InstrInfo { }
+
+def arch : Target {
+ let InstructionSet = archInstrInfo;
+}
+
+class TestInstruction : Instruction {
+ let Size = 1;
+ let OutOperandList = (outs);
+ let InOperandList = (ins);
+ field bits<8> Inst;
+ field bits<8> SoftFail = 0;
+}
+
+def InstA : TestInstruction {
+ let Inst = {0,0,0,0,0,0,?,?};
+ let AsmString = "InstA";
+ let DecoderMethod = "DecodeInstA";
+ let hasCompleteDecoder = 0;
+}
+
+def InstB : TestInstruction {
+ let Inst = {0,0,0,?,?,0,1,1};
+ let AsmString = "InstB";
+ let DecoderMethod = "DecodeInstB";
+ let hasCompleteDecoder = 0;
+}
+
+// CHECK: /* 0 */ MCD::OPC_ExtractField, 2, 1, // Inst{2} ...
+// CHECK-NEXT: /* 3 */ MCD::OPC_FilterValue, 0, 29, 0, // Skip to: 36
+// CHECK-NEXT: /* 7 */ MCD::OPC_ExtractField, 5, 3, // Inst{7-5} ...
+// CHECK-NEXT: /* 10 */ MCD::OPC_FilterValue, 0, 22, 0, // Skip to: 36
+// CHECK-NEXT: /* 14 */ MCD::OPC_CheckField, 0, 2, 3, 5, 0, // Skip to: 25
+// CHECK-NEXT: /* 20 */ MCD::OPC_TryDecode, 24, 0, 0, 0, // Opcode: InstB, skip to: 25
+// CHECK-NEXT: /* 25 */ MCD::OPC_CheckField, 3, 2, 0, 5, 0, // Skip to: 36
+// CHECK-NEXT: /* 31 */ MCD::OPC_TryDecode, 23, 1, 0, 0, // Opcode: InstA, skip to: 36
+// CHECK-NEXT: /* 36 */ MCD::OPC_Fail,
+
+// CHECK: if (DecodeInstB(MI, insn, Address, Decoder) == MCDisassembler::Fail) { DecodeComplete = false; return MCDisassembler::Fail; }
+// CHECK: if (DecodeInstA(MI, insn, Address, Decoder) == MCDisassembler::Fail) { DecodeComplete = false; return MCDisassembler::Fail; }
diff --git a/llvm/test/TableGen/trydecode-emission3.td b/llvm/test/TableGen/trydecode-emission3.td
new file mode 100644
index 00000000000..ad21eefa897
--- /dev/null
+++ b/llvm/test/TableGen/trydecode-emission3.td
@@ -0,0 +1,44 @@
+// RUN: llvm-tblgen -gen-disassembler -I %p/../../include %s | FileCheck %s
+
+include "llvm/Target/Target.td"
+
+def archInstrInfo : InstrInfo { }
+
+def arch : Target {
+ let InstructionSet = archInstrInfo;
+}
+
+class TestInstruction : Instruction {
+ let Size = 1;
+ let OutOperandList = (outs);
+ let InOperandList = (ins);
+ field bits<8> Inst;
+ field bits<8> SoftFail = 0;
+}
+
+def InstA : TestInstruction {
+ let Inst = {0,0,0,0,?,?,?,?};
+ let AsmString = "InstA";
+}
+
+def InstBOp : Operand<i32> {
+ let DecoderMethod = "DecodeInstBOp";
+ let hasCompleteDecoder = 0;
+}
+
+def InstB : TestInstruction {
+ bits<2> op;
+ let Inst{7-2} = {0,0,0,0,0,0};
+ let Inst{1-0} = op;
+ let OutOperandList = (outs InstBOp:$op);
+ let AsmString = "InstB";
+}
+
+// CHECK: /* 0 */ MCD::OPC_ExtractField, 4, 4, // Inst{7-4} ...
+// CHECK-NEXT: /* 3 */ MCD::OPC_FilterValue, 0, 14, 0, // Skip to: 21
+// CHECK-NEXT: /* 7 */ MCD::OPC_CheckField, 2, 2, 0, 5, 0, // Skip to: 18
+// CHECK-NEXT: /* 13 */ MCD::OPC_TryDecode, 24, 0, 0, 0, // Opcode: InstB, skip to: 18
+// CHECK-NEXT: /* 18 */ MCD::OPC_Decode, 23, 1, // Opcode: InstA
+// CHECK-NEXT: /* 21 */ MCD::OPC_Fail,
+
+// CHECK: if (DecodeInstBOp(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { DecodeComplete = false; return MCDisassembler::Fail; }
OpenPOWER on IntegriCloud