diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/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, HelpText<"Disable using library calls for save and restore">; +def mcmodel_EQ_medlow : Flag<["-"], "mcmodel=medlow">, Group, + Flags<[CC1Option]>, Alias, AliasArgs<["small"]>, + HelpText<"Equivalent to -mcmodel=small, compatible with RISC-V gcc.">; +def mcmodel_EQ_medany : Flag<["-"], "mcmodel=medany">, Group, + Flags<[CC1Option]>, Alias, AliasArgs<["medium"]>, + HelpText<"Equivalent to -mcmodel=medium, compatible with RISC-V gcc.">; def munaligned_access : Flag<["-"], "munaligned-access">, Group, HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">; diff --git a/clang/test/Preprocessor/riscv-cmodel.c b/clang/test/Preprocessor/riscv-cmodel.c --- a/clang/test/Preprocessor/riscv-cmodel.c +++ b/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