Nicolai Haehnle | 2b1cd51 | 2018-06-21 13:36:22 +0000 | [diff] [blame] | 1 | // RUN: llvm-tblgen -gen-searchable-tables -I %p/../../include %s | FileCheck %s |
| 2 | // XFAIL: vg_leak |
| 3 | |
| 4 | include "llvm/TableGen/SearchableTable.td" |
| 5 | |
| 6 | // CHECK-LABEL: GET_InstrTable_IMPL |
| 7 | // CHECK: const MyInstr InstrTable[] = { |
| 8 | // CHECK: { B, 0xA }, |
| 9 | // CHECK: { C, 0x0 }, |
| 10 | // CHECK: { A, 0x5 }, |
| 11 | // CHECK: { D, 0x8 }, |
| 12 | // CHECK: }; |
| 13 | |
| 14 | class Instruction { |
| 15 | bit isPseudo = 0; |
| 16 | } |
| 17 | |
| 18 | class MyInstr<int op> : Instruction { |
| 19 | Instruction Opcode = !cast<Instruction>(NAME); |
| 20 | bits<16> CustomEncoding = op; |
| 21 | } |
| 22 | |
| 23 | def A : MyInstr<5>; |
| 24 | def D : MyInstr<8>; |
| 25 | let isPseudo = 1 in { |
| 26 | def C : MyInstr<0>; |
| 27 | def B : MyInstr<10>; |
| 28 | } |
| 29 | |
| 30 | def InstrTable : GenericTable { |
| 31 | let FilterClass = "MyInstr"; |
| 32 | let Fields = ["Opcode", "CustomEncoding"]; |
| 33 | |
| 34 | let PrimaryKey = ["Opcode"]; |
| 35 | let PrimaryKeyName = "getCustomEncodingHelper"; |
| 36 | } |