-
Notifications
You must be signed in to change notification settings - Fork 15k
[IntrinsicEmitter] Make AttributesMap PackedID type-adaptive #158383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
elvinw-intel
wants to merge
1
commit into
llvm:main
Choose a base branch
from
elvinw-intel:elvinw-llvm-0004
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+26
−19
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -617,9 +617,7 @@ static AttributeSet getIntrinsicFnAttributeSet(LLVMContext &C, unsigned ID) { | |
} | ||
OS << R"( | ||
} | ||
} // getIntrinsicFnAttributeSet | ||
|
||
static constexpr uint16_t IntrinsicsToAttributesMap[] = {)"; | ||
} // getIntrinsicFnAttributeSet)"; | ||
|
||
// Compute unique argument attributes. | ||
std::map<const CodeGenIntrinsic *, unsigned, AttributeComparator> | ||
|
@@ -633,17 +631,25 @@ static constexpr uint16_t IntrinsicsToAttributesMap[] = {)"; | |
// Note, ID `-1` is used to indicate no function attributes. | ||
const uint8_t UniqFnAttributesBitSize = | ||
Log2_32_Ceil(UniqFnAttributes.size() + 2); | ||
const uint16_t NoFunctionAttrsID = | ||
maskTrailingOnes<uint16_t>(UniqFnAttributesBitSize); | ||
if (UniqAttributesBitSize + UniqFnAttributesBitSize > 16) | ||
PrintFatalError( | ||
"More than 16 bits are used for IntrinsicsToAttributesMap's entry!"); | ||
|
||
// Assign a 16-bit packed ID for each intrinsic. The lower bits will be its | ||
const uint32_t NoFunctionAttrsID = | ||
maskTrailingOnes<uint32_t>(UniqFnAttributesBitSize); | ||
uint8_t AttributesMapDataBitSize = | ||
PowerOf2Ceil(UniqAttributesBitSize + UniqFnAttributesBitSize); | ||
if (AttributesMapDataBitSize < 8) | ||
AttributesMapDataBitSize = 8; | ||
else if (AttributesMapDataBitSize > 64) | ||
PrintFatalError("Packed ID of IntrinsicsToAttributesMap exceeds 64b!"); | ||
else if (AttributesMapDataBitSize > 16) | ||
PrintWarning("Packed ID of IntrinsicsToAttributesMap exceeds 16b, " | ||
"this may cause performance drop!"); | ||
|
||
// Assign a packed ID for each intrinsic. The lower bits will be its | ||
// "argument attribute ID" (index in UniqAttributes) and upper bits will be | ||
// its "function attribute ID" (index in UniqFnAttributes). | ||
OS << formatv("\nstatic constexpr uint{}_t IntrinsicsToAttributesMap[] = {{", | ||
AttributesMapDataBitSize); | ||
for (const CodeGenIntrinsic &Int : Ints) { | ||
uint16_t FnAttrIndex = | ||
uint32_t FnAttrIndex = | ||
hasFnAttributes(Int) ? UniqFnAttributes[&Int] : NoFunctionAttrsID; | ||
OS << formatv("\n {} << {} | {}, // {}", FnAttrIndex, | ||
UniqAttributesBitSize, UniqAttributes[&Int], Int.Name); | ||
|
@@ -751,9 +757,9 @@ AttributeList Intrinsic::getAttributes(LLVMContext &C, ID id, | |
if (id == 0) | ||
return AttributeList(); | ||
|
||
uint16_t PackedID = IntrinsicsToAttributesMap[id - 1]; | ||
uint16_t FnAttrID = PackedID >> ({}); | ||
uint16_t ArgAttrID = PackedID & ({}); | ||
uint{}_t PackedID = IntrinsicsToAttributesMap[id - 1]; | ||
uint32_t FnAttrID = PackedID >> ({}); | ||
uint32_t ArgAttrID = PackedID & ({}); | ||
using PairTy = std::pair<unsigned, AttributeSet>; | ||
alignas(PairTy) char ASStorage[sizeof(PairTy) * {}]; | ||
PairTy *AS = reinterpret_cast<PairTy *>(ASStorage); | ||
|
@@ -779,16 +785,17 @@ AttributeList Intrinsic::getAttributes(LLVMContext &C, ID id, | |
AttributeSet Intrinsic::getFnAttributes(LLVMContext &C, ID id) { | ||
if (id == 0) | ||
return AttributeSet(); | ||
uint16_t PackedID = IntrinsicsToAttributesMap[id - 1]; | ||
uint16_t FnAttrID = PackedID >> ({}); | ||
uint{}_t PackedID = IntrinsicsToAttributesMap[id - 1]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The format string Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
uint32_t FnAttrID = PackedID >> ({}); | ||
return getIntrinsicFnAttributeSet(C, FnAttrID); | ||
} | ||
#endif // GET_INTRINSIC_ATTRIBUTES | ||
|
||
)", | ||
UniqAttributesBitSize, | ||
AttributesMapDataBitSize, UniqAttributesBitSize, | ||
maskTrailingOnes<uint16_t>(UniqAttributesBitSize), MaxNumAttrs, | ||
NoFunctionAttrsID, UniqAttributesBitSize); | ||
NoFunctionAttrsID, AttributesMapDataBitSize, | ||
UniqAttributesBitSize); | ||
} | ||
|
||
void IntrinsicEmitter::EmitIntrinsicToBuiltinMap( | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format string
uint{}_t
is used without the bit size parameter. This should beuint{}_t
with theAttributesMapDataBitSize
parameter passed toformatv
to properly substitute the bit size.Copilot uses AI. Check for mistakes.