Skip to content

Commit 990daa0

Browse files
koachantstellar
authored andcommitted
[clang] Add GCC-compatible code model names for sparc64
This adds GCC-compatible names for code model selection on 64-bit SPARC with absolute code. Testing with a 2-stage build then running codegen tests works okay under all of the supported code models. (32-bit target does not have selectable code models) Reviewed By: @brad0, @MaskRay (cherry picked from commit b0f0bab)
1 parent 5ee0d4e commit 990daa0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5779,6 +5779,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
57795779
// NVPTX/AMDGPU does not care about the code model and will accept
57805780
// whatever works for the host.
57815781
Ok = true;
5782+
} else if (Triple.isSPARC64()) {
5783+
if (CM == "medlow")
5784+
CM = "small";
5785+
else if (CM == "medmid")
5786+
CM = "medium";
5787+
else if (CM == "medany")
5788+
CM = "large";
5789+
Ok = CM == "small" || CM == "medium" || CM == "large";
57825790
}
57835791
if (Ok) {
57845792
CmdArgs.push_back(Args.MakeArgString("-mcmodel=" + CM));

clang/test/Driver/sparc64-codemodel.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %clang --target=sparc64 -mcmodel=medlow %s -### 2>&1 | FileCheck -check-prefix=MEDLOW %s
2+
// RUN: %clang --target=sparc64 -mcmodel=medmid %s -### 2>&1 | FileCheck -check-prefix=MEDMID %s
3+
// RUN: %clang --target=sparc64 -mcmodel=medany %s -### 2>&1 | FileCheck -check-prefix=MEDANY %s
4+
// MEDLOW: "-mcmodel=small"
5+
// MEDMID: "-mcmodel=medium"
6+
// MEDANY: "-mcmodel=large"

0 commit comments

Comments
 (0)