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