[llvm] 0aeaec3 - llvm/test/TableGen/intrinsic-*.td: Use Intrinsics.td instead of mock

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 19 15:11:55 PDT 2023


Author: NAKAMURA Takumi
Date: 2023-03-20T06:48:14+09:00
New Revision: 0aeaec3bee15eb1fa2f99d214a560d35f460cc31

URL: https://github.com/llvm/llvm-project/commit/0aeaec3bee15eb1fa2f99d214a560d35f460cc31
DIFF: https://github.com/llvm/llvm-project/commit/0aeaec3bee15eb1fa2f99d214a560d35f460cc31.diff

LOG: llvm/test/TableGen/intrinsic-*.td: Use Intrinsics.td instead of mock

- `intrinsic-pointer-to-any.td`
- `intrinsic-varargs.td`

They used their own mock.

I have introduced `TEST_INTRINSICS_SUPPRESS_DEFS` in `Intrinsics.td`.
Tests of intrinsics may use it.

Differential Revision: https://reviews.llvm.org/D146147

Added: 
    

Modified: 
    llvm/include/llvm/IR/Intrinsics.td
    llvm/test/TableGen/intrinsic-pointer-to-any.td
    llvm/test/TableGen/intrinsic-varargs.td

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index f42998a109988..0e32ca9c8c7e4 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -404,6 +404,7 @@ class MSBuiltin<string name> {
   string MSBuiltinName = name;
 }
 
+#ifndef TEST_INTRINSICS_SUPPRESS_DEFS
 
 //===--------------- Variable Argument Handling Intrinsics ----------------===//
 //
@@ -2203,3 +2204,5 @@ include "llvm/IR/IntrinsicsSPIRV.td"
 include "llvm/IR/IntrinsicsVE.td"
 include "llvm/IR/IntrinsicsDirectX.td"
 include "llvm/IR/IntrinsicsLoongArch.td"
+
+#endif // TEST_INTRINSICS_SUPPRESS_DEFS

diff  --git a/llvm/test/TableGen/intrinsic-pointer-to-any.td b/llvm/test/TableGen/intrinsic-pointer-to-any.td
index 77001c415aa5d..1b090b98cef45 100644
--- a/llvm/test/TableGen/intrinsic-pointer-to-any.td
+++ b/llvm/test/TableGen/intrinsic-pointer-to-any.td
@@ -1,4 +1,4 @@
-// RUN: llvm-tblgen -gen-intrinsic-impl %s | FileCheck %s
+// RUN: llvm-tblgen -gen-intrinsic-impl -I %p/../../include %s -DTEST_INTRINSICS_SUPPRESS_DEFS | FileCheck %s
 
 // This test is validating that it an Intrinsic with an LLVMPointerType to
 // llvm_any_ty still properly work after r363233. That patch rewrote the
@@ -6,52 +6,7 @@
 // case, so TableGen would hit an assertion in EncodeFixedType that was checking
 // to ensure that the substitution being processed was correctly replaced.
 
-class IntrinsicProperty<bit is_default = 0> {
-  bit IsDefault = is_default;
-}
-
-class SDNodeProperty;
-
-class ValueType<int size, int value> {
-  string Namespace = "MVT";
-  int Size = size;
-  int Value = value;
-}
-
-def iPTR   : ValueType<0  , 254>;
-def Any    : ValueType<0  , 255>;
-
-class LLVMType<ValueType vt> {
-  ValueType VT = vt;
-  int isAny = 0;
-}
-
-
-class Intrinsic<list<LLVMType> ret_types> {
-  string LLVMName = "";
-  string TargetPrefix = "";   // Set to a prefix for target-specific intrinsics.
-  list<LLVMType> RetTypes = ret_types;
-  list<LLVMType> ParamTypes = [];
-  list<IntrinsicProperty> IntrProperties = [];
-  list<SDNodeProperty> Properties = [];
-  bit isTarget = 0;
-  bit DisableDefaultAttributes = 1;
-}
-
-class LLVMQualPointerType<LLVMType elty>
-  : LLVMType<iPTR>{
-  LLVMType ElTy = elty;
-  int AddrSpace = 0;
-}
-
-class LLVMPointerType<LLVMType elty>
-  : LLVMQualPointerType<elty>;
-
-let isAny = 1 in {
-  def llvm_any_ty        : LLVMType<Any>;
-}
-def i8 : ValueType<8, 5>;
-def llvm_i8_ty : LLVMType<i8>;
+include "llvm/IR/Intrinsics.td"
 
 def int_has_ptr_to_any : Intrinsic<[LLVMPointerType<llvm_any_ty>, llvm_i8_ty]>;
 // CHECK: /* 0 */ 21, 14, 15, 0, 2, 0

diff  --git a/llvm/test/TableGen/intrinsic-varargs.td b/llvm/test/TableGen/intrinsic-varargs.td
index da860ed0129c8..3634e16e20565 100644
--- a/llvm/test/TableGen/intrinsic-varargs.td
+++ b/llvm/test/TableGen/intrinsic-varargs.td
@@ -1,29 +1,7 @@
-// RUN: llvm-tblgen -gen-intrinsic-impl -I %p/../../include %s | FileCheck %s
+// RUN: llvm-tblgen -gen-intrinsic-impl -I %p/../../include %s -DTEST_INTRINSICS_SUPPRESS_DEFS | FileCheck %s
 // XFAIL: vg_leak
 
-include "llvm/CodeGen/ValueTypes.td"
-
-class IntrinsicProperty<bit is_default = 0> {
-  bit IsDefault = is_default;
-}
-class SDNodeProperty;
-
-class LLVMType<ValueType vt> {
-  ValueType VT = vt;
-}
-
-class Intrinsic<string name, list<LLVMType> param_types = []> {
-  string LLVMName = name;
-  bit isTarget = 0;
-  string TargetPrefix = "";
-  list<LLVMType> RetTypes = [];
-  list<LLVMType> ParamTypes = param_types;
-  list<IntrinsicProperty> IntrProperties = [];
-  list<SDNodeProperty> Properties = [];
-  bit DisableDefaultAttributes = 1;
-}
-
-def llvm_vararg_ty : LLVMType<isVoid>;   // this means vararg here
+include "llvm/IR/Intrinsics.td"
 
 // CHECK: /* 0 */ 0, 29, 0,
-def int_foo : Intrinsic<"llvm.foo", [llvm_vararg_ty]>;
+def int_foo : Intrinsic<[], [llvm_vararg_ty]>;


        


More information about the llvm-commits mailing list