• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: llvm-tblgen -gen-searchable-tables -I %p/../../include %s | FileCheck %s
2// XFAIL: vg_leak
3
4include "llvm/TableGen/SearchableTable.td"
5
6class IntrinsicProperty;
7class SDNodeProperty;
8
9class ValueType<int size, int value> {
10  string Namespace = "MVT";
11  int Size = size;
12  int Value = value;
13}
14
15class LLVMType<ValueType vt> {
16  ValueType VT = vt;
17}
18
19class 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
29def iAny : ValueType<0, 253>;
30def llvm_anyint_ty : LLVMType<iAny>;
31
32def int_abc : Intrinsic<[llvm_anyint_ty]>;
33def int_xyz : Intrinsic<[llvm_anyint_ty]>;
34
35let 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
41let 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
47class 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[] = {
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 },
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//
68// CHECK-LABEL: lookupTableByIntr(unsigned Intr) {
69// CHECK: Index[] = {
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
79def : Table<int_abc, 0x0>;
80def : Table<int_xyz, 0x1>;
81def : Table<int_gtarget_def, 0x10>;
82def : Table<int_gtarget_defg, 0x11>;
83def : Table<int_gtarget_uvw, 0x12>;
84def : Table<int_ftarget_ghi, 0x20>;
85def : Table<int_ftarget_ghi_x, 0x21>;
86def : Table<int_ftarget_rst, 0x22>;
87