Skip to content

Commit 42fe2fc

Browse files
committed
[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 llvm-svn: 372080
1 parent 5c17323 commit 42fe2fc

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,12 @@ def msave_restore : Flag<["-"], "msave-restore">, Group<m_riscv_Features_Group>,
21772177
HelpText<"Enable using library calls for save and restore">;
21782178
def mno_save_restore : Flag<["-"], "mno-save-restore">, Group<m_riscv_Features_Group>,
21792179
HelpText<"Disable using library calls for save and restore">;
2180+
def mcmodel_EQ_medlow : Flag<["-"], "mcmodel=medlow">, Group<m_riscv_Features_Group>,
2181+
Flags<[CC1Option]>, Alias<mcmodel_EQ>, AliasArgs<["small"]>,
2182+
HelpText<"Equivalent to -mcmodel=small, compatible with RISC-V gcc.">;
2183+
def mcmodel_EQ_medany : Flag<["-"], "mcmodel=medany">, Group<m_riscv_Features_Group>,
2184+
Flags<[CC1Option]>, Alias<mcmodel_EQ>, AliasArgs<["medium"]>,
2185+
HelpText<"Equivalent to -mcmodel=medium, compatible with RISC-V gcc.">;
21802186

21812187
def munaligned_access : Flag<["-"], "munaligned-access">, Group<m_arm_Features_Group>,
21822188
HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">;

clang/test/Preprocessor/riscv-cmodel.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
99
// RUN: -mcmodel=small -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
1010

11+
// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
12+
// RUN: -mcmodel=medlow -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
13+
// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
14+
// RUN: -mcmodel=medlow -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
15+
1116
// CHECK-MEDLOW: #define __riscv_cmodel_medlow 1
1217
// CHECK-MEDLOW-NOT: __riscv_cmodel_medany
1318

@@ -16,5 +21,10 @@
1621
// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
1722
// RUN: -mcmodel=medium -o - | FileCheck --check-prefix=CHECK-MEDANY %s
1823

24+
// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
25+
// RUN: -mcmodel=medany -o - | FileCheck --check-prefix=CHECK-MEDANY %s
26+
// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
27+
// RUN: -mcmodel=medany -o - | FileCheck --check-prefix=CHECK-MEDANY %s
28+
1929
// CHECK-MEDANY: #define __riscv_cmodel_medany 1
2030
// CHECK-MEDANY-NOT: __riscv_cmodel_medlow

0 commit comments

Comments
 (0)