Skip to content

Commit ad28bef

Browse files
author
Erich Keane
committed
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 llvm-svn: 364364
1 parent ae9e42f commit ad28bef

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// RUN: llvm-tblgen -gen-intrinsic-impl %s | FileCheck %s
2+
3+
// This test is validating that it an Intrinsic with an LLVMPointerType to
4+
// llvm_any_ty still properly work after r363233. That patch rewrote the
5+
// substitution handling code in the Intrinsic Emitter, and didn't consider this
6+
// case, so TableGen would hit an assertion in EncodeFixedType that was checking
7+
// to ensure that the substitution being processed was correctly replaced.
8+
9+
class IntrinsicProperty;
10+
class SDNodeProperty;
11+
12+
class ValueType<int size, int value> {
13+
string Namespace = "MVT";
14+
int Size = size;
15+
int Value = value;
16+
}
17+
18+
def iPTR : ValueType<0 , 254>;
19+
def Any : ValueType<0 , 255>;
20+
21+
class LLVMType<ValueType vt> {
22+
ValueType VT = vt;
23+
int isAny = 0;
24+
}
25+
26+
27+
class Intrinsic<list<LLVMType> ret_types> {
28+
string LLVMName = "";
29+
string TargetPrefix = ""; // Set to a prefix for target-specific intrinsics.
30+
list<LLVMType> RetTypes = ret_types;
31+
list<LLVMType> ParamTypes = [];
32+
list<IntrinsicProperty> IntrProperties = [];
33+
list<SDNodeProperty> Properties = [];
34+
bit isTarget = 0;
35+
}
36+
37+
class LLVMQualPointerType<LLVMType elty>
38+
: LLVMType<iPTR>{
39+
LLVMType ElTy = elty;
40+
int AddrSpace = 0;
41+
}
42+
43+
class LLVMPointerType<LLVMType elty>
44+
: LLVMQualPointerType<elty>;
45+
46+
let isAny = 1 in {
47+
def llvm_any_ty : LLVMType<Any>;
48+
}
49+
def i8 : ValueType<8, 3>;
50+
def llvm_i8_ty : LLVMType<i8>;
51+
52+
def int_has_ptr_to_any : Intrinsic<[LLVMPointerType<llvm_any_ty>, llvm_i8_ty]>;
53+
// CHECK: /* 0 */ 21, 14, 15, 0, 2, 0

llvm/utils/TableGen/IntrinsicEmitter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ static void UpdateArgCodes(Record *R, std::vector<unsigned char> &ArgCodes,
372372
unsigned Tmp = 0;
373373
switch (getValueType(R->getValueAsDef("VT"))) {
374374
default: break;
375+
case MVT::iPTR:
376+
UpdateArgCodes(R->getValueAsDef("ElTy"), ArgCodes, NumInserted, Mapping);
377+
break;
375378
case MVT::iPTRAny:
376379
++Tmp;
377380
LLVM_FALLTHROUGH;

0 commit comments

Comments
 (0)