Nicolai Haehnle | 7bf0a7f | 2018-04-01 17:08:58 +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 | class IntrinsicProperty; |
| 7 | class SDNodeProperty; |
| 8 | |
| 9 | class ValueType<int size, int value> { |
| 10 | string Namespace = "MVT"; |
| 11 | int Size = size; |
| 12 | int Value = value; |
| 13 | } |
| 14 | |
| 15 | class LLVMType<ValueType vt> { |
| 16 | ValueType VT = vt; |
| 17 | } |
| 18 | |
| 19 | class Intrinsic<list<LLVMType> param_types = []> { |
| 20 | string LLVMName = ""; |
| 21 | bit isTarget = 0; |
| 22 | string TargetPrefix = ""; |
| 23 | list<LLVMType> RetTypes = []; |
| 24 | list<LLVMType> ParamTypes = param_types; |
| 25 | list<IntrinsicProperty> IntrProperties = []; |
| 26 | list<SDNodeProperty> Properties = []; |
| 27 | } |
| 28 | |
| 29 | def iAny : ValueType<0, 253>; |
| 30 | def llvm_anyint_ty : LLVMType<iAny>; |
| 31 | |
| 32 | def int_abc : Intrinsic<[llvm_anyint_ty]>; |
| 33 | def int_xyz : Intrinsic<[llvm_anyint_ty]>; |
| 34 | |
| 35 | let isTarget = 1, TargetPrefix = "gtarget" in { |
| 36 | def int_gtarget_def : Intrinsic<[llvm_anyint_ty]>; |
| 37 | def int_gtarget_defg : Intrinsic<[llvm_anyint_ty]>; |
| 38 | def int_gtarget_uvw : Intrinsic<[llvm_anyint_ty]>; |
| 39 | } |
| 40 | |
| 41 | let isTarget = 1, TargetPrefix = "ftarget" in { |
| 42 | def int_ftarget_ghi : Intrinsic<[llvm_anyint_ty]>; |
| 43 | def int_ftarget_ghi_x : Intrinsic<[llvm_anyint_ty]>; |
| 44 | def int_ftarget_rst : Intrinsic<[llvm_anyint_ty]>; |
| 45 | } |
| 46 | |
| 47 | class Table<Intrinsic intr, int payload> : SearchableTable { |
| 48 | let SearchableFields = ["Intr"]; |
| 49 | let EnumNameField = ?; |
| 50 | |
| 51 | Intrinsic Intr = !cast<Intrinsic>(intr); |
| 52 | bits<16> Payload = payload; |
| 53 | } |
| 54 | |
| 55 | // CHECK-LABEL: TablesList[] = { |
Nicolai Haehnle | 2b1cd51 | 2018-06-21 13:36:22 +0000 | [diff] [blame] | 56 | // CHECK-DAG: { Intrinsic::abc, 0x0 }, |
| 57 | // CHECK-DAG: { Intrinsic::xyz, 0x1 }, |
| 58 | // CHECK-DAG: { Intrinsic::gtarget_def, 0x10 }, |
| 59 | // CHECK-DAG: { Intrinsic::gtarget_defg, 0x11 }, |
| 60 | // CHECK-DAG: { Intrinsic::gtarget_uvw, 0x12 }, |
| 61 | // CHECK-DAG: { Intrinsic::ftarget_ghi, 0x20 }, |
| 62 | // CHECK-DAG: { Intrinsic::ftarget_ghi_x, 0x21 }, |
| 63 | // CHECK-DAG: { Intrinsic::ftarget_rst, 0x22 }, |
Nicolai Haehnle | 7bf0a7f | 2018-04-01 17:08:58 +0000 | [diff] [blame] | 64 | |
| 65 | // Check that the index is in the correct order, consistent with the ordering |
| 66 | // of enums: alphabetically, but target intrinsics after generic intrinsics |
| 67 | // |
Nicolai Haehnle | 2b1cd51 | 2018-06-21 13:36:22 +0000 | [diff] [blame] | 68 | // CHECK-LABEL: lookupTableByIntr(unsigned Intr) { |
| 69 | // CHECK: Index[] = { |
Nicolai Haehnle | 7bf0a7f | 2018-04-01 17:08:58 +0000 | [diff] [blame] | 70 | // CHECK-NEXT: Intrinsic::abc |
| 71 | // CHECK-NEXT: Intrinsic::xyz |
| 72 | // CHECK-NEXT: Intrinsic::ftarget_ghi |
| 73 | // CHECK-NEXT: Intrinsic::ftarget_ghi_x |
| 74 | // CHECK-NEXT: Intrinsic::ftarget_rst |
| 75 | // CHECK-NEXT: Intrinsic::gtarget_def |
| 76 | // CHECK-NEXT: Intrinsic::gtarget_defg |
| 77 | // CHECK-NEXT: Intrinsic::gtarget_uvw |
| 78 | |
| 79 | def : Table<int_abc, 0x0>; |
| 80 | def : Table<int_xyz, 0x1>; |
| 81 | def : Table<int_gtarget_def, 0x10>; |
| 82 | def : Table<int_gtarget_defg, 0x11>; |
| 83 | def : Table<int_gtarget_uvw, 0x12>; |
| 84 | def : Table<int_ftarget_ghi, 0x20>; |
| 85 | def : Table<int_ftarget_ghi_x, 0x21>; |
| 86 | def : Table<int_ftarget_rst, 0x22>; |