[clang] [clang] Add GCC-compatible code model names for sparc64 (PR #79485)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 25 10:54:44 PST 2024
https://github.com/koachan created https://github.com/llvm/llvm-project/pull/79485
This adds GCC-compatible names for code model selection on 64-bit SPARC with absolute code.
(32-bit target does not have selectable code models)
>From 99caee180932a8b41c91d9a5d5826d463e816093 Mon Sep 17 00:00:00 2001
From: Koakuma <koachan at protonmail.com>
Date: Fri, 26 Jan 2024 01:48:46 +0700
Subject: [PATCH] [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.
(32-bit target does not have selectable code models)
---
clang/lib/Driver/ToolChains/Clang.cpp | 8 ++++++++
clang/test/Driver/sparc64-codemodel.c | 6 ++++++
2 files changed, 14 insertions(+)
create mode 100644 clang/test/Driver/sparc64-codemodel.c
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 5dc614e11aab599..f3d624fb5489e06 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5779,6 +5779,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// NVPTX/AMDGPU does not care about the code model and will accept
// whatever works for the host.
Ok = true;
+ } else if (Triple.isSPARC64()) {
+ if (CM == "medlow")
+ CM = "small";
+ else if (CM == "medmid")
+ CM = "medium";
+ else if (CM == "medany")
+ CM = "large";
+ Ok = CM == "small" || CM == "medium" || CM == "large";
}
if (Ok) {
CmdArgs.push_back(Args.MakeArgString("-mcmodel=" + CM));
diff --git a/clang/test/Driver/sparc64-codemodel.c b/clang/test/Driver/sparc64-codemodel.c
new file mode 100644
index 000000000000000..e4b01fd61b6fac2
--- /dev/null
+++ b/clang/test/Driver/sparc64-codemodel.c
@@ -0,0 +1,6 @@
+// RUN: %clang --target=sparc64 -mcmodel=medlow %s -### 2>&1 | FileCheck -check-prefix=MEDLOW %s
+// RUN: %clang --target=sparc64 -mcmodel=medmid %s -### 2>&1 | FileCheck -check-prefix=MEDMID %s
+// RUN: %clang --target=sparc64 -mcmodel=medany %s -### 2>&1 | FileCheck -check-prefix=MEDANY %s
+// MEDLOW: "-mcmodel=small"
+// MEDMID: "-mcmodel=medium"
+// MEDANY: "-mcmodel=large"
More information about the cfe-commits
mailing list