-
Notifications
You must be signed in to change notification settings - Fork 18.1k
[NFC][AMDGPU] Move AMDGPU related code out of generic TargetParser.cpp #198433
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
Merged
Merged
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
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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| #include "AMDGPU.h" | ||
| #include "clang/Basic/MacroBuilder.h" | ||
| #include "clang/Basic/TargetBuiltins.h" | ||
| #include "llvm/TargetParser/TargetParser.h" | ||
| #include "llvm/TargetParser/AMDGPUTargetParser.h" | ||
|
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. Same here. |
||
|
|
||
| using namespace clang; | ||
| using namespace clang::targets; | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -22,8 +22,8 @@ | |
| #include "llvm/Support/Path.h" | ||
| #include "llvm/Support/Process.h" | ||
| #include "llvm/Support/VirtualFileSystem.h" | ||
| #include "llvm/TargetParser/AMDGPUTargetParser.h" | ||
|
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. Same. |
||
| #include "llvm/TargetParser/Host.h" | ||
| #include "llvm/TargetParser/TargetParser.h" | ||
| #include <optional> | ||
| #include <system_error> | ||
|
|
||
|
|
||
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
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,109 @@ | ||
| //===-- AMDGPUTargetParser - Parser for AMDGPU features ---------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file implements a target parser to recognise AMDGPU hardware features. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_TARGETPARSER_AMDGPUTARGETPARSER_H | ||
| #define LLVM_TARGETPARSER_AMDGPUTARGETPARSER_H | ||
|
|
||
| #include "llvm/ADT/StringMap.h" | ||
| #include "llvm/ADT/StringRef.h" | ||
| #include "llvm/Support/Compiler.h" | ||
| #include <cstdint> | ||
| #include <utility> | ||
|
|
||
| namespace llvm { | ||
|
|
||
| template <typename T> class SmallVectorImpl; | ||
| class Triple; | ||
|
|
||
| namespace AMDGPU { | ||
|
|
||
| /// GPU kinds supported by the AMDGPU target. | ||
| enum GPUKind : uint32_t { | ||
| // Not specified processor. | ||
| GK_NONE = 0, | ||
|
|
||
| #define R600_GPU(NAME, ENUM, FEATURES) ENUM, | ||
| #define AMDGCN_GPU(NAME, ENUM, ISAVERSION, FEATURES) ENUM, | ||
| #include "AMDGPUTargetParser.def" | ||
|
|
||
| GK_AMDGCN_GENERIC_FIRST = GK_GFX9_GENERIC, | ||
| GK_AMDGCN_GENERIC_LAST = GK_GFX12_5_GENERIC, | ||
| }; | ||
|
|
||
| /// Instruction set architecture version. | ||
| struct IsaVersion { | ||
| unsigned Major; | ||
| unsigned Minor; | ||
| unsigned Stepping; | ||
| }; | ||
|
|
||
| // This isn't comprehensive for now, just things that are needed from the | ||
| // frontend driver. | ||
| enum ArchFeatureKind : uint32_t { | ||
| FEATURE_NONE = 0, | ||
|
|
||
| // These features only exist for r600, and are implied true for amdgcn. | ||
| FEATURE_FMA = 1 << 1, | ||
| FEATURE_LDEXP = 1 << 2, | ||
| FEATURE_FP64 = 1 << 3, | ||
|
|
||
| // Common features. | ||
| FEATURE_FAST_FMA_F32 = 1 << 4, | ||
| FEATURE_FAST_DENORMAL_F32 = 1 << 5, | ||
|
|
||
| // Wavefront 32 is available. | ||
| FEATURE_WAVE32 = 1 << 6, | ||
|
|
||
| // Xnack is available. | ||
| FEATURE_XNACK = 1 << 7, | ||
|
|
||
| // Sram-ecc is available. | ||
| FEATURE_SRAMECC = 1 << 8, | ||
|
|
||
| // WGP mode is supported. | ||
| FEATURE_WGP = 1 << 9, | ||
|
|
||
| // Xnack is available by default | ||
| FEATURE_XNACK_ALWAYS = 1 << 10 | ||
| }; | ||
|
|
||
| enum FeatureError : uint32_t { | ||
| NO_ERROR = 0, | ||
| INVALID_FEATURE_COMBINATION, | ||
| UNSUPPORTED_TARGET_FEATURE | ||
| }; | ||
|
|
||
| LLVM_ABI StringRef getArchFamilyNameAMDGCN(GPUKind AK); | ||
|
|
||
| LLVM_ABI StringRef getArchNameAMDGCN(GPUKind AK); | ||
| LLVM_ABI StringRef getArchNameR600(GPUKind AK); | ||
| LLVM_ABI StringRef getCanonicalArchName(const Triple &T, StringRef Arch); | ||
| LLVM_ABI GPUKind parseArchAMDGCN(StringRef CPU); | ||
| LLVM_ABI GPUKind parseArchR600(StringRef CPU); | ||
| LLVM_ABI unsigned getArchAttrAMDGCN(GPUKind AK); | ||
| LLVM_ABI unsigned getArchAttrR600(GPUKind AK); | ||
|
|
||
| LLVM_ABI void fillValidArchListAMDGCN(SmallVectorImpl<StringRef> &Values); | ||
| LLVM_ABI void fillValidArchListR600(SmallVectorImpl<StringRef> &Values); | ||
|
|
||
| LLVM_ABI IsaVersion getIsaVersion(StringRef GPU); | ||
|
|
||
| /// Fills Features map with default values for given target GPU. | ||
| /// \p Features contains overriding target features and this function returns | ||
| /// default target features with entries overridden by \p Features. | ||
| LLVM_ABI std::pair<FeatureError, StringRef> | ||
| fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, StringMap<bool> &Features); | ||
| } // namespace AMDGPU | ||
|
|
||
| } // namespace llvm | ||
|
|
||
| #endif |
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
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
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
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.
You already have it included in the
AMDGPU.h.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.
Right, but my understanding is that the best practice is to include the headers we actually need instead of relying on transitive includes from other headers, since those headers might later stop including the ones we depend on.
That probably won't happen with
AMDGPU.h, since it's basically a giant all-in-one header included by almost every AMDGPU source file, but IMHO that's not really a good thing.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.
Up to you.