Enable zbb for riscv android
authorAdityaK <1894981+hiraditya@users.noreply.github.com>
Tue, 13 Jun 2023 19:22:46 +0000 (12:22 -0700)
committerAdityaK <1894981+hiraditya@users.noreply.github.com>
Tue, 13 Jun 2023 19:30:04 +0000 (12:30 -0700)
Differential Revision: https://reviews.llvm.org/D152729
Reviewers: enh, pirama, jrtc27

clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Driver/riscv-features.c

index f47a6a5..1c342d5 100644 (file)
@@ -292,8 +292,12 @@ StringRef riscv::getRISCVArch(const llvm::opt::ArgList &Args,
       return "rv32e";
     else if (MABI.starts_with_insensitive("ilp32"))
       return "rv32imafdc";
-    else if (MABI.starts_with_insensitive("lp64"))
+    else if (MABI.starts_with_insensitive("lp64")) {
+      if (Triple.isAndroid())
+        return "rv64imafdc_zbb";
+
       return "rv64imafdc";
+    }
   }
 
   // 4. Choose a default based on the triple
@@ -309,6 +313,8 @@ StringRef riscv::getRISCVArch(const llvm::opt::ArgList &Args,
   } else {
     if (Triple.getOS() == llvm::Triple::UnknownOS)
       return "rv64imac";
+    else if (Triple.isAndroid())
+      return "rv64imafdc_zbb";
     else
       return "rv64imafdc";
   }
index b189fde..78d3b2d 100644 (file)
@@ -1,5 +1,7 @@
 // RUN: %clang --target=riscv32-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv64-linux-android -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=ANDROID,DEFAULT
+// RUN: %clang -mabi=lp64d --target=riscv64-linux-android -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=ANDROID,DEFAULT
 
 // CHECK: fno-signed-char
 
@@ -8,6 +10,7 @@
 // RUN: %clang --target=riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck %s -check-prefix=RELAX
 // RUN: %clang --target=riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck %s -check-prefix=NO-RELAX
 
+// ANDROID: "-target-feature" "+zbb"
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
 // DEFAULT: "-target-feature" "+relax"