1 // RUN: llvm-tblgen -gen-searchable-tables -I %p/../../include %s | FileCheck %s
4 include "llvm/TableGen/SearchableTable.td"
6 class IntrinsicProperty;
9 class ValueType<int size, int value> {
10 string Namespace = "MVT";
15 class LLVMType<ValueType vt> {
19 class Intrinsic<list<LLVMType> param_types = []> {
22 string TargetPrefix = "";
23 list<LLVMType> RetTypes = [];
24 list<LLVMType> ParamTypes = param_types;
25 list<IntrinsicProperty> IntrProperties = [];
26 list<SDNodeProperty> Properties = [];
29 def iAny : ValueType<0, 253>;
30 def llvm_anyint_ty : LLVMType<iAny>;
32 def int_abc : Intrinsic<[llvm_anyint_ty]>;
33 def int_xyz : Intrinsic<[llvm_anyint_ty]>;
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]>;
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]>;
47 class Table<Intrinsic intr, int payload> : SearchableTable {
48 let SearchableFields = ["Intr"];
49 let EnumNameField = ?;
51 Intrinsic Intr = !cast<Intrinsic>(intr);
52 bits<16> Payload = payload;
55 // CHECK-LABEL: TablesList[] = {
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 },
65 // Check that the index is in the correct order, consistent with the ordering
66 // of enums: alphabetically, but target intrinsics after generic intrinsics
68 // CHECK-LABEL: lookupTableByIntr(unsigned Intr) {
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
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>;