[PATCH] D140693: [Driver][RISCV] Adjust the priority between -mcpu, -mtune and -march

Kito Cheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 12 08:14:30 PST 2023


kito-cheng marked 3 inline comments as done.
kito-cheng added a comment.

> (I probably need to update my https://maskray.me/blog/2022-08-28-march-mcpu-mtune)

At least the behavior of RISC-V GCC need to update:

Architecture extension:

- Take from -march if present.
- Take from -mcpu if present.
- Use the default architecture (TARGET_RISCV_DEFAULT_ARCH, set by --with-arch, implementation by `spec` here <https://github.com/gcc-mirror/gcc/blob/master/gcc/config/riscv/riscv.h#L68>)

---

> "Architecture extension has quite complicated behavior now:" looks too complex.
> Take union from -march and -mcpu if both are present.

Yeah, and actually more like buggy behavior now, it seems like take from `-march` if both are given from the clang view, because the architecture test macro are only defined the part of `-march`, but the union behavior will performed by LLVM backend by `-target-cpu` option.

---

> I'd like that we just take -march= and report an error if it is incompatible with -mcpu=

I would prefer using same `*` behavior as RISC-V GCC, one reason is RISC-V GCC implement that behavior since GCC 11 (and implemented at Oct. 2020).

- Take from -march if present.
- Take from -mcpu if present.
- Implied from -mabi if present.
- Use the default architecture depending on the target triple

`*` Okay, it's actually not same, it's just similar because GCC won't implied arch from `-mabi`.



================
Comment at: llvm/lib/Support/RISCVISAInfo.cpp:14
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Errc.h"
----------------
craig.topper wrote:
> Why is this needed?
Added during my first attempt, apparently I forgot to clean this up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140693



More information about the llvm-commits mailing list