[llvm] [LLVM][TableGen] Decrease code size of `getAttributes` (PR #110573)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 1 07:19:53 PDT 2024
================
@@ -576,75 +582,79 @@ static AttributeSet getIntrinsicFnAttributeSet(LLVMContext &C, unsigned ID) {
AttributeList Intrinsic::getAttributes(LLVMContext &C, ID id) {
)";
- // Compute the maximum number of attribute arguments and the map.
- typedef std::map<const CodeGenIntrinsic *, unsigned, AttributeComparator>
- UniqAttrMapTy;
- UniqAttrMapTy UniqAttributes;
- unsigned MaxArgAttrs = 0;
- unsigned AttrNum = 0;
+ // Compute the maximum number of attribute arguments and the map. For function
+ // attributes, we only consider whether the intrinsics has any function
+ // arguments or not.
+ std::map<const CodeGenIntrinsic *, unsigned, AttributeComparator>
+ UniqAttributes;
for (const CodeGenIntrinsic &Int : Ints) {
- MaxArgAttrs =
- std::max(MaxArgAttrs, unsigned(Int.ArgumentAttributes.size()));
- unsigned &N = UniqAttributes[&Int];
- if (N)
- continue;
- N = ++AttrNum;
- assert(N < 65536 && "Too many unique attributes for table!");
+ unsigned ID = UniqAttributes.size();
+ UniqAttributes.try_emplace(&Int, ID);
}
+ // Assign a 16-bit packed ID for each intrinsic. The lower 8-bits will be its
+ // "argument attribute ID" (index in UniqAttributes) and upper 8 bits will be
+ // its "function attribute ID" (index in UniqFnAttributes).
+ assert(UniqAttributes.size() < 256 &&
+ "Too many unique argument attributes for table!");
+ assert(UniqFnAttributes.size() < 256 &&
+ "Too many unique function attributes for table!");
----------------
jurahul wrote:
Done.
https://github.com/llvm/llvm-project/pull/110573
More information about the llvm-commits
mailing list