[PATCH] D69383: [RISCV] Match GCC `-march`/`-mabi` driver defaults

Roger Ferrer Ibanez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 09:48:32 PDT 2019


rogfer01 added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:475
+
+    if (MArch.startswith_lower("rv32")) {
+      if (MArch.substr(4).contains_lower("d") ||
----------------
`llvm::StringSwitch` has a method `StartsWithLower` which might help make the logic a bit clearer

Something like this (I haven't tested it!)

```lang=cpp
StringRef ABIFromMarch = StringSwitch(MArch)
   .StartsWithLower("rv32d", "ilp32d")
   .StartsWithLower("rv32g", "ilp32d")
   .StartsWithLower("rv32e", "ilp32e")
   .StartsWithLower("rv32", "ilp32")

   .StartsWithLower("rv64d", "lp64d")
   .StartsWithLower("rv64g", "lp64d")
   .StartsWithLower("rv64", "lp64").

   .Default("");

if (!ABIFromMarch.empty()) return ABIFromMarch;
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69383/new/

https://reviews.llvm.org/D69383





More information about the cfe-commits mailing list