-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[Clang] Add standalone AMDGPU SPIR-V toolchain #144576
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
Changes from all commits
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 |
---|---|---|
|
@@ -417,3 +417,15 @@ void HIPAMDToolChain::checkTargetID( | |
getDriver().Diag(clang::diag::err_drv_bad_target_id) | ||
<< *PTID.OptionalTargetID; | ||
} | ||
|
||
SPIRVAMDToolChain::SPIRVAMDToolChain(const Driver &D, | ||
const llvm::Triple &Triple, | ||
const ArgList &Args) | ||
: ROCMToolChain(D, Triple, Args) { | ||
getProgramPaths().push_back(getDriver().Dir); | ||
} | ||
|
||
Tool *SPIRVAMDToolChain::buildLinker() const { | ||
assert(getTriple().getArch() == llvm::Triple::spirv64); | ||
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. assert will do nothing w/o assertion enabled. if it definitely shouldn't be creating the toolchain, probably do a llvm_unreachable? 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. llvm_unreachable will also do nothing without asserts enabled 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. This is copied from elsewhere, and is mostly just a sanity check since it's impossible to hit this code path with 32-bit triples. |
||
return new tools::AMDGCN::Linker(*this); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// RUN: %clang -### -ccc-print-phases --target=spirv64-amd-amdhsa %s 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=PHASES | ||
// PHASES: 0: input, "[[INPUT:.+]]", c | ||
// PHASES: 1: preprocessor, {0}, cpp-output | ||
// PHASES: 2: compiler, {1}, ir | ||
// PHASES: 3: backend, {2}, assembler | ||
// PHASES: 4: assembler, {3}, object | ||
// PHASES: 5: linker, {4}, image | ||
|
||
// RUN: %clang -### -ccc-print-bindings --target=spirv64-amd-amdhsa %s 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=BINDINGS | ||
// BINDINGS: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[OUTPUT:.+]]" | ||
// BINDINGS: # "spirv64-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OUTPUT]]"], output: "a.out" | ||
|
||
// RUN: %clang -### --target=spirv64-amd-amdhsa %s -nogpulib -nogpuinc 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=INVOCATION | ||
// INVOCATION: "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-o" "[[OUTPUT:.+]]" "-x" "c" | ||
// INVOCATION: "{{.*}}llvm-link" "-o" "a.out" "[[OUTPUT]]" | ||
// INVOCATION: "{{.*}}llvm-spirv" "--spirv-max-version=1.6" "--spirv-ext=+all" "--spirv-allow-unknown-intrinsics" "--spirv-lower-const-expr" "--spirv-preserve-auxdata" "--spirv-debug-info-version=nonsemantic-shader-200" "a.out" "-o" "a.out" |
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 looks like we use
SPIRVAMDToolChain
forspirv32
orspirv64
but we assert it'sspirv64
here. Canspirv32
never hit this?Should we add a
spirv32
test case?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.
32-bit SPIR-V isn't supported by AMD as far as I know, maybe @AlexVlx can clarify. Definitely shouldn't be creating the toolchain.