-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[NFC] Various Cleanup in StackColoring, StackSlotColoring, LiveStacks #143931
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
base: main
Are you sure you want to change the base?
Changes from all commits
feacb3e
02267f9
86edf33
023dce9
1b8eeaf
4c0706f
0163007
8dac020
aed5832
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -795,6 +795,41 @@ using stack_float_t = volatile float; | |
| using stack_float_t = float; | ||
| #endif | ||
|
|
||
| /// Returns the number of digits in the given integer. | ||
| inline int NumDigitsBase10(uint64_t X) { | ||
|
Contributor
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. Probably should move this out of line. Also in general Support/ADT patches should be split out into a separate PR
Collaborator
Author
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. Here is the split off. #165479
Collaborator
Author
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. I will update this MR once this one is merged since it uses it. |
||
| static constexpr struct ConstexprData { | ||
| uint8_t AtLeast[65] = {}; | ||
| uint64_t Boundaries[20] = {}; | ||
| static constexpr int NumDigitsConstexpr(uint64_t N) { | ||
| int res = 1; | ||
| while (N >= 10) { | ||
| res++; | ||
| N /= 10; | ||
| } | ||
| return res; | ||
| } | ||
| constexpr ConstexprData() { | ||
| uint64_t Val = ~0ull; | ||
| for (uint64_t i = 0; i <= 64; i++) { | ||
| uint64_t Digits = NumDigitsConstexpr(Val) - 1; | ||
| AtLeast[i] = Digits; | ||
| Val >>= 1; | ||
| } | ||
| // Special case because X=0 should return 1 and not 0 | ||
| Boundaries[0] = 0; | ||
| Val = 10; | ||
| for (uint64_t i = 1; i < 20; i++) { | ||
| Boundaries[i] = Val; | ||
| Val *= 10; | ||
| } | ||
| } | ||
| } Data; | ||
|
|
||
| uint64_t Base2 = X ? countl_zero(X) : 64; | ||
| uint64_t Digits = Data.AtLeast[Base2]; | ||
| return Digits + (X >= Data.Boundaries[Digits]); | ||
| } | ||
|
|
||
| } // namespace llvm | ||
|
|
||
| #endif | ||
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.
Switching the map strategy should be a separate patch from the cosmetic changes
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.
Ok, #165477