[PATCH] D67066: [RISCV] Add option aliases: -mcmodel=medany and -mcmodel=medlow

Kito Cheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 2 02:16:33 PDT 2019


kito-cheng created this revision.
kito-cheng added reviewers: asb, apazos.
Herald added subscribers: cfe-commits, pzheng, s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar.
Herald added a project: clang.
kito-cheng added a parent revision: D67065: [RISCV] Define __riscv_cmodel_medlow and __riscv_cmodel_medany correctly.

RISC-V GCC use -mcmodel=medany and -mcmodel=medlow, but LLVM use -mcmodel=small and -mcmodel=medium.

Add those two option aliases to provide same user interface between GCC and LLVM.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67066

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Preprocessor/riscv-cmodel.c


Index: clang/test/Preprocessor/riscv-cmodel.c
===================================================================
--- clang/test/Preprocessor/riscv-cmodel.c
+++ clang/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
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2166,6 +2166,12 @@
   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)">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67066.218313.patch
Type: text/x-patch
Size: 2407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190902/e7452e5f/attachment.bin>


More information about the cfe-commits mailing list