[clang] dee058f - [RISCV] Emit predefined macro __riscv_cmodel_large for large code model (#108131)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 12 19:37:52 PDT 2024
Author: Jim Lin
Date: 2024-09-13T10:37:48+08:00
New Revision: dee058f9e3ae95b8f4b95034b65c3d7408060c8e
URL: https://github.com/llvm/llvm-project/commit/dee058f9e3ae95b8f4b95034b65c3d7408060c8e
DIFF: https://github.com/llvm/llvm-project/commit/dee058f9e3ae95b8f4b95034b65c3d7408060c8e.diff
LOG: [RISCV] Emit predefined macro __riscv_cmodel_large for large code model (#108131)
Co-authored-by: patrick <patrick at andestech.com>
Added:
Modified:
clang/lib/Basic/Targets/RISCV.cpp
clang/test/Preprocessor/riscv-cmodel.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp
index 6f9d050fc71a90..223ac66b5f219d 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -146,6 +146,8 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__riscv_cmodel_medlow");
else if (CodeModel == "medium")
Builder.defineMacro("__riscv_cmodel_medany");
+ else if (CodeModel == "large")
+ Builder.defineMacro("__riscv_cmodel_large");
StringRef ABIName = getABI();
if (ABIName == "ilp32f" || ABIName == "lp64f")
diff --git a/clang/test/Preprocessor/riscv-cmodel.c b/clang/test/Preprocessor/riscv-cmodel.c
index 45b9a93de6f78a..0a531c7b1b3e4f 100644
--- a/clang/test/Preprocessor/riscv-cmodel.c
+++ b/clang/test/Preprocessor/riscv-cmodel.c
@@ -15,6 +15,7 @@
// CHECK-MEDLOW: #define __riscv_cmodel_medlow 1
// CHECK-MEDLOW-NOT: __riscv_cmodel_medany
+// CHECK-MEDLOW-NOT: __riscv_cmodel_large
// RUN: %clang --target=riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
// RUN: -mcmodel=medium -o - | FileCheck --check-prefix=CHECK-MEDANY %s
@@ -28,3 +29,11 @@
// CHECK-MEDANY: #define __riscv_cmodel_medany 1
// CHECK-MEDANY-NOT: __riscv_cmodel_medlow
+// CHECK-MEDANY-NOT: __riscv_cmodel_large
+
+// RUN: %clang --target=riscv64-unknown-linux-gnu -march=rv64i -fno-pic -x c -E -dM %s \
+// RUN: -mcmodel=large -o - | FileCheck --check-prefix=CHECK-LARGE %s
+
+// CHECK-LARGE: #define __riscv_cmodel_large 1
+// CHECK-LARGE-NOT: __riscv_cmodel_medlow
+// CHECK-LARGE-NOT: __riscv_cmodel_medany
More information about the cfe-commits
mailing list