Skip to content

Commit b0f0bab

Browse files
authored
[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
1 parent 9dfdea6 commit b0f0bab

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
@@ -5781,6 +5781,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
57815781
// NVPTX/AMDGPU does not care about the code model and will accept
57825782
// whatever works for the host.
57835783
Ok = true;
5784+
} else if (Triple.isSPARC64()) {
5785+
if (CM == "medlow")
5786+
CM = "small";
5787+
else if (CM == "medmid")
5788+
CM = "medium";
5789+
else if (CM == "medany")
5790+
CM = "large";
5791+
Ok = CM == "small" || CM == "medium" || CM == "large";
57845792
}
57855793
if (Ok) {
57865794
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)