Skip to content

Commit 1c984b8

Browse files
authored
[LLVM][TableGen] Adopt !listflatten for Intrinsic type signature (#109884)
Intrinisc type signature is a `list<list<int>>` that hold IIT encoding for each param/ret type (outer list) where the IIT encoding for each type itself can be 0 or more integers (the inner list). Intrinsic emitter flatten this list into generate the type signature in `ComputeTypeSignature`. Use the new !listflatten() operator to instead flatten the list in the TableGen definition and eliminate flattening in the emitter code. Verified that `-gen-intrinsic-impl` output for Intrinsics.td is identical with and without the change.
1 parent 786dc5a commit 1c984b8

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,15 +626,15 @@ class TypeInfoGen<
626626
list<LLVMType> Types = !foreach(ty, AllTypes,
627627
!if(!isa<LLVMMatchType>(ty), ACTys[MappingRIdxs[ty.Number]], ty));
628628

629-
list<list<int>> TypeSig = !listconcat(
629+
list<int> TypeSig = !listflatten(!listconcat(
630630
[IIT_RetNumbers[!size(RetTypes)]],
631631
!foreach(i, !range(AllTypes),
632632
!foreach(a, AllTypes[i].Sig,
633633
ResolveArgCode<
634634
MappingRIdxs,
635635
ArgCodes,
636636
ACIdxs[i],
637-
a>.ret)));
637+
a>.ret))));
638638
}
639639

640640
//===----------------------------------------------------------------------===//

llvm/utils/TableGen/IntrinsicEmitter.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,10 @@ using TypeSigTy = SmallVector<unsigned char>;
276276
static TypeSigTy ComputeTypeSignature(const CodeGenIntrinsic &Int) {
277277
TypeSigTy TypeSig;
278278
const Record *TypeInfo = Int.TheDef->getValueAsDef("TypeInfo");
279-
const ListInit *OuterList = TypeInfo->getValueAsListInit("TypeSig");
279+
const ListInit *TypeList = TypeInfo->getValueAsListInit("TypeSig");
280280

281-
for (const auto *Outer : OuterList->getValues()) {
282-
for (const auto *Inner : cast<ListInit>(Outer)->getValues())
283-
TypeSig.emplace_back(cast<IntInit>(Inner)->getValue());
284-
}
281+
for (const auto *TypeListEntry : TypeList->getValues())
282+
TypeSig.emplace_back(cast<IntInit>(TypeListEntry)->getValue());
285283
return TypeSig;
286284
}
287285

0 commit comments

Comments
 (0)