summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKito Cheng <kito.cheng@gmail.com>2019-09-17 08:19:17 +0000
committerKito Cheng <kito.cheng@gmail.com>2019-09-17 08:19:17 +0000
commit88c01a9d02e08086ef46b1f3090a13edb67e0dd5 (patch)
treeba9d5e175a853341ac54e80d7b910bd0c0e34a6f
parent4f5495d1369407d0798c577d0c47d5d2ce990d45 (diff)
downloadclang-88c01a9d02e08086ef46b1f3090a13edb67e0dd5.tar.gz
[RISCV] Add option aliases: -mcmodel=medany and -mcmodel=medlow
RISC-V GCC use -mcmodel=medany and -mcmodel=medlow, but LLVM use -mcmodel=small and -mcmodel=medium. Add those two option aliases for provide same user interface between GCC and LLVM. Reviewed By: lenary Differential Revision: https://reviews.llvm.org/D67066 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372080 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Driver/Options.td6
-rw-r--r--test/Preprocessor/riscv-cmodel.c10
2 files changed, 16 insertions, 0 deletions
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index ff39343c91..31798e0c0f 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -2177,6 +2177,12 @@ def msave_restore : Flag<["-"], "msave-restore">, Group<m_riscv_Features_Group>,
HelpText<"Enable using library calls for save and restore">;
def mno_save_restore : Flag<["-"], "mno-save-restore">, Group<m_riscv_Features_Group>,
HelpText<"Disable using library calls for save and restore">;
+def mcmodel_EQ_medlow : Flag<["-"], "mcmodel=medlow">, Group<m_riscv_Features_Group>,
+ Flags<[CC1Option]>, Alias<mcmodel_EQ>, AliasArgs<["small"]>,
+ HelpText<"Equivalent to -mcmodel=small, compatible with RISC-V gcc.">;
+def mcmodel_EQ_medany : Flag<["-"], "mcmodel=medany">, Group<m_riscv_Features_Group>,
+ Flags<[CC1Option]>, Alias<mcmodel_EQ>, AliasArgs<["medium"]>,
+ HelpText<"Equivalent to -mcmodel=medium, compatible with RISC-V gcc.">;
def munaligned_access : Flag<["-"], "munaligned-access">, Group<m_arm_Features_Group>,
HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">;
diff --git a/test/Preprocessor/riscv-cmodel.c b/test/Preprocessor/riscv-cmodel.c
index b28c27c9cc..c0b85eba16 100644
--- a/test/Preprocessor/riscv-cmodel.c
+++ b/test/Preprocessor/riscv-cmodel.c
@@ -8,6 +8,11 @@
// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
// RUN: -mcmodel=small -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -mcmodel=medlow -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -mcmodel=medlow -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+
// CHECK-MEDLOW: #define __riscv_cmodel_medlow 1
// CHECK-MEDLOW-NOT: __riscv_cmodel_medany
@@ -16,5 +21,10 @@
// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
// RUN: -mcmodel=medium -o - | FileCheck --check-prefix=CHECK-MEDANY %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -mcmodel=medany -o - | FileCheck --check-prefix=CHECK-MEDANY %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -mcmodel=medany -o - | FileCheck --check-prefix=CHECK-MEDANY %s
+
// CHECK-MEDANY: #define __riscv_cmodel_medany 1
// CHECK-MEDANY-NOT: __riscv_cmodel_medlow