-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[ADT] Add implementations for mulhs and mulhu to APInt #84609
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
Closed
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5478873
Add APIntOps::mulhs / APIntOps::mulhu
Sh0g0-1758 abdc2f8
Removed older case statements
Sh0g0-1758 c81a474
Removed Braces
Sh0g0-1758 bd7cd46
Ran clang formatter
Sh0g0-1758 32ec343
Refactored KnownBitsTest
Sh0g0-1758 3b7b3a4
Ran clang formatter
Sh0g0-1758 2d6804a
added same-bitwidth assertion
Sh0g0-1758 b80b94d
Minor Bug Fix
Sh0g0-1758 2bd2d18
revert
Sh0g0-1758 0d3edd5
Added Docs and Refactored Functions
Sh0g0-1758 6fb4b4a
Ran clang Formatter
Sh0g0-1758 02d896e
Updated MLIR files
Sh0g0-1758 abce2ad
Ran clang Formatter
Sh0g0-1758 6816c6a
Add namespace
Sh0g0-1758 4f0a94a
Ran Clang Formatter
Sh0g0-1758 6e24505
Update llvm/include/llvm/ADT/APInt.h
Sh0g0-1758 f94a279
Update llvm/include/llvm/ADT/APInt.h
Sh0g0-1758 db910c4
Replaced Lamda Function
Sh0g0-1758 58f0613
Ran clang Formatter
Sh0g0-1758 8aee6cd
Bringing back lamda functions
Sh0g0-1758 a60ffdc
Ran Clang Formatter
Sh0g0-1758 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
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 |
---|---|---|
|
@@ -3067,6 +3067,22 @@ void llvm::StoreIntToMemory(const APInt &IntVal, uint8_t *Dst, | |
} | ||
} | ||
|
||
APInt APIntOps::mulhu(const APInt &C1, const APInt &C2) { | ||
// Return higher order bits for unsigned (C1 * C2) | ||
unsigned FullWidth = C1.getBitWidth() * 2; | ||
APInt C1Ext = C1.zext(FullWidth); | ||
APInt C2Ext = C2.zext(FullWidth); | ||
return (C1Ext * C2Ext).extractBits(C1.getBitWidth(), C1.getBitWidth()); | ||
} | ||
|
||
APInt APIntOps::mulhs(const APInt &C1, const APInt &C2) { | ||
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. add same-bitwidth assertion: 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. Ditto. |
||
// Return higher order bits for signed (C1 * C2) | ||
unsigned FullWidth = C1.getBitWidth() * 2; | ||
APInt C1Ext = C1.sext(FullWidth); | ||
APInt C2Ext = C2.sext(FullWidth); | ||
return (C1Ext * C2Ext).extractBits(C1.getBitWidth(), C1.getBitWidth()); | ||
} | ||
|
||
/// LoadIntFromMemory - Loads the integer stored in the LoadBytes bytes starting | ||
/// from Src into IntVal, which is assumed to be wide enough and to hold zero. | ||
void llvm::LoadIntFromMemory(APInt &IntVal, const uint8_t *Src, | ||
|
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
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
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
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.
add same-bitwidth assertion:
assert(C1.BitWidth == C2.BitWidth && "Bit widths must be the same");
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.
It should be
C1.getBitWidth()
. Updated the code with it.