[llvm] r364364 - Teach TableGen Intrin Emitter to handle LLVMPointerType<llvm_any_ty>

Erich Keane via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 17:08:23 PDT 2019


Author: erichkeane
Date: Tue Jun 25 17:08:22 2019
New Revision: 364364

URL: http://llvm.org/viewvc/llvm-project?rev=364364&view=rev
Log:
Teach TableGen Intrin Emitter to handle LLVMPointerType<llvm_any_ty>

r363233 rewrote a bunch of the Intrin Emitter code, however the new
function to update the arg codes did not properly consider a pointer to
an any.  This patch adds that logic.

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

Added:
    llvm/trunk/test/TableGen/intrinsic-pointer-to-any.td
Modified:
    llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp

Added: llvm/trunk/test/TableGen/intrinsic-pointer-to-any.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/intrinsic-pointer-to-any.td?rev=364364&view=auto
==============================================================================
--- llvm/trunk/test/TableGen/intrinsic-pointer-to-any.td (added)
+++ llvm/trunk/test/TableGen/intrinsic-pointer-to-any.td Tue Jun 25 17:08:22 2019
@@ -0,0 +1,53 @@
+// RUN: llvm-tblgen -gen-intrinsic-impl %s | 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
+// substitution handling code in the Intrinsic Emitter, and didn't consider this
+// case, so TableGen would hit an assertion in EncodeFixedType that was checking
+// to ensure that the substitution being processed was correctly replaced.
+
+class IntrinsicProperty;
+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;
+}
+
+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, 3>;
+def llvm_i8_ty : LLVMType<i8>;
+
+def int_has_ptr_to_any : Intrinsic<[LLVMPointerType<llvm_any_ty>, llvm_i8_ty]>;
+// CHECK: /* 0 */ 21, 14, 15, 0, 2, 0

Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=364364&r1=364363&r2=364364&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Tue Jun 25 17:08:22 2019
@@ -372,6 +372,9 @@ static void UpdateArgCodes(Record *R, st
   unsigned Tmp = 0;
   switch (getValueType(R->getValueAsDef("VT"))) {
   default: break;
+  case MVT::iPTR:
+    UpdateArgCodes(R->getValueAsDef("ElTy"), ArgCodes, NumInserted, Mapping);
+    break;
   case MVT::iPTRAny:
     ++Tmp;
     LLVM_FALLTHROUGH;




More information about the llvm-commits mailing list