From 8910947d9af344a29fce3b2b44db5c6ba2360b32 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Wed, 26 Jun 2019 00:08:22 +0000 Subject: [PATCH] Teach TableGen Intrin Emitter to handle LLVMPointerType 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364364 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/TableGen/intrinsic-pointer-to-any.td | 53 +++++++++++++++++++++++ utils/TableGen/IntrinsicEmitter.cpp | 3 ++ 2 files changed, 56 insertions(+) create mode 100644 test/TableGen/intrinsic-pointer-to-any.td diff --git a/test/TableGen/intrinsic-pointer-to-any.td b/test/TableGen/intrinsic-pointer-to-any.td new file mode 100644 index 00000000000..c58595acfde --- /dev/null +++ b/test/TableGen/intrinsic-pointer-to-any.td @@ -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 { + string Namespace = "MVT"; + int Size = size; + int Value = value; +} + +def iPTR : ValueType<0 , 254>; +def Any : ValueType<0 , 255>; + +class LLVMType { + ValueType VT = vt; + int isAny = 0; +} + + +class Intrinsic ret_types> { + string LLVMName = ""; + string TargetPrefix = ""; // Set to a prefix for target-specific intrinsics. + list RetTypes = ret_types; + list ParamTypes = []; + list IntrProperties = []; + list Properties = []; + bit isTarget = 0; +} + +class LLVMQualPointerType + : LLVMType{ + LLVMType ElTy = elty; + int AddrSpace = 0; +} + +class LLVMPointerType + : LLVMQualPointerType; + +let isAny = 1 in { + def llvm_any_ty : LLVMType; +} +def i8 : ValueType<8, 3>; +def llvm_i8_ty : LLVMType; + +def int_has_ptr_to_any : Intrinsic<[LLVMPointerType, llvm_i8_ty]>; +// CHECK: /* 0 */ 21, 14, 15, 0, 2, 0 diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index ab2f2d8c5dc..bcb8af2fc56 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -372,6 +372,9 @@ static void UpdateArgCodes(Record *R, std::vector &ArgCodes, 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; -- 2.50.1