-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[Analysis] Move TargetLibraryInfo data to TableGen #165009
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
redstar
wants to merge
6
commits into
main
Choose a base branch
from
users/redstar/tlitablegen
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.
+2,074
−2,777
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b20c203
[Analysis] Move TargetLibraryInfo data to TableGen
redstar 22dace5
Store the length of the strings to avoid call to `strlen()`.
redstar dea0479
Fix formatting
redstar 92f18b1
Fix another formatting problem
redstar 0bf60b1
Split signature list into return type and argument types.
redstar 09be493
Reformat the .td file
redstar 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| set(LLVM_TARGET_DEFINITIONS TargetLibraryInfo.td) | ||
| tablegen(LLVM TargetLibraryInfo.inc -gen-target-library-info) | ||
| add_public_tablegen_target(analysis_gen) |
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| #define LLVM_ANALYSIS_TARGETLIBRARYINFO_H | ||
|
|
||
| #include "llvm/ADT/DenseMap.h" | ||
| #include "llvm/ADT/StringTable.h" | ||
| #include "llvm/IR/Constants.h" | ||
| #include "llvm/IR/InstrTypes.h" | ||
| #include "llvm/IR/Module.h" | ||
|
|
@@ -69,13 +70,8 @@ class VecDesc { | |
| LLVM_ABI std::string getVectorFunctionABIVariantString() const; | ||
| }; | ||
|
|
||
| enum LibFunc : unsigned { | ||
| #define TLI_DEFINE_ENUM | ||
| #include "llvm/Analysis/TargetLibraryInfo.def" | ||
|
|
||
| NumLibFuncs, | ||
| NotLibFunc | ||
| }; | ||
| #define GET_TARGET_LIBRARY_INFO_ENUM | ||
| #include "llvm/Analysis/TargetLibraryInfo.inc" | ||
|
|
||
| /// Implementation of the target library information. | ||
| /// | ||
|
|
@@ -88,7 +84,8 @@ class TargetLibraryInfoImpl { | |
|
|
||
| unsigned char AvailableArray[(NumLibFuncs+3)/4]; | ||
| DenseMap<unsigned, std::string> CustomNames; | ||
| LLVM_ABI static StringLiteral const StandardNames[NumLibFuncs]; | ||
| #define GET_TARGET_LIBRARY_INFO_IMPL_DECL | ||
| #include "llvm/Analysis/TargetLibraryInfo.inc" | ||
| bool ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param, ShouldSignExtI32Return; | ||
| unsigned SizeOfInt; | ||
|
|
||
|
|
@@ -177,7 +174,7 @@ class TargetLibraryInfoImpl { | |
| /// Forces a function to be marked as available and provide an alternate name | ||
| /// that must be used. | ||
| void setAvailableWithName(LibFunc F, StringRef Name) { | ||
| if (StandardNames[F] != Name) { | ||
| if (StandardNamesStrTable.getCString(StandardNamesOffsets[F]) != Name) { | ||
| setState(F, CustomName); | ||
| CustomNames[F] = std::string(Name); | ||
| assert(CustomNames.contains(F)); | ||
|
|
@@ -455,15 +452,17 @@ class TargetLibraryInfo { | |
| /// Return the canonical name for a LibFunc. This should not be used for | ||
| /// semantic purposes, use getName instead. | ||
| static StringRef getStandardName(LibFunc F) { | ||
| return TargetLibraryInfoImpl::StandardNames[F]; | ||
| return TargetLibraryInfoImpl::StandardNamesStrTable.getCString( | ||
| TargetLibraryInfoImpl::StandardNamesOffsets[F]); | ||
| } | ||
|
|
||
| StringRef getName(LibFunc F) const { | ||
| auto State = getState(F); | ||
| if (State == TargetLibraryInfoImpl::Unavailable) | ||
| return StringRef(); | ||
| if (State == TargetLibraryInfoImpl::StandardName) | ||
| return Impl->StandardNames[F]; | ||
| return Impl->StandardNamesStrTable.getCString( | ||
|
||
| Impl->StandardNamesOffsets[F]); | ||
| assert(State == TargetLibraryInfoImpl::CustomName); | ||
| return Impl->CustomNames.find(F)->second; | ||
| } | ||
|
|
||
Oops, something went wrong.
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.
It's better to include the string lengths and void the strlen cost here
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.
Changed.