diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -106,6 +106,8 @@ break; case llvm::Triple::aarch64: [[fallthrough]]; + case llvm::Triple::riscv64: + [[fallthrough]]; case llvm::Triple::x86_64: getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false); break; diff --git a/flang/test/Driver/code-gen-rv64.f90 b/flang/test/Driver/code-gen-rv64.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Driver/code-gen-rv64.f90 @@ -0,0 +1,13 @@ +! Test -emit-obj (RISC-V 64) + +! RUN: rm -f %t.o +! RUN: %flang_fc1 -triple riscv64-unknown-linux-gnu \ +! RUN: -target-feature +d -target-feature +c -emit-obj %s -o %t.o +! RUN: llvm-readelf -h %t.o | FileCheck %s + +! RUN: rm -f %t.o +! RUN: %flang --target=riscv64-unknown-linux-gnu -c %s -o %t.o +! RUN: llvm-readelf -h %t.o | FileCheck %s + +! CHECK: Flags: 0x5, RVC, double-float ABI +end program diff --git a/flang/test/Driver/target-cpu-features.f90 b/flang/test/Driver/target-cpu-features.f90 --- a/flang/test/Driver/target-cpu-features.f90 +++ b/flang/test/Driver/target-cpu-features.f90 @@ -22,6 +22,9 @@ ! RUN: %flang --target=x86_64h-linux-gnu -c %s -### 2>&1 \ ! RUN: | FileCheck %s -check-prefix=CHECK-X86_64H +! RUN: %flang --target=riscv64-linux-gnu -c %s -### 2>&1 \ +! RUN: | FileCheck %s -check-prefix=CHECK-RV64 + ! Test that invalid cpu and features are ignored. @@ -52,5 +55,9 @@ ! CHECK-X86_64H: "-fc1" "-triple" "x86_64h-unknown-linux-gnu" ! CHECK-X86_64H-SAME: "-target-cpu" "x86-64" "-target-feature" "-rdrnd" "-target-feature" "-aes" "-target-feature" "-pclmul" "-target-feature" "-rtm" "-target-feature" "-fsgsbase" +! CHECK-RV64: "-fc1" "-triple" "riscv64-unknown-linux-gnu" +! CHECK-RV64-SAME: "-target-cpu" "generic-rv64" "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+c" + + ! CHECK-INVALID-CPU: 'supercpu' is not a recognized processor for this target (ignoring processor) ! CHECK-INVALID-FEATURE: '+superspeed' is not a recognized feature for this target (ignoring feature)