[PATCH] D71124: [RISCV] support clang driver to select cpu

Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 19 22:34:56 PST 2019


khchen planned changes to this revision.
khchen marked an inline comment as done.
khchen added a comment.

The problem is how `-mcpu` interact with explicitly specified `-march` (or target features).

1. in GCC, -mcpu is only used to chose the pipeline model,



2. I also read this <https://community.arm.com/developer/tools-software/tools/b/tools-software-ides-blog/posts/compiler-flags-across-architectures-march-mtune-and-mcpu> article talking about the X86 and ARM to handle those options.

-march=X: Tells the compiler that X is the minimal architecture the binary must run on.  The compiler is free to use architecture-specific instructions.  This flag behaves differently on Arm and x86.  On Arm, -march does not override -mtune, but on x86 -march will override both -mtune and -mcpu.
-mtune=X: Tells the compiler to optimize for microarchitecture X but does not allow the compiler to change the ABI or make assumptions about available instructions.  This flag has the more-or-less the same meaning on Arm and x86. 
-mcpu=X: On Arm, this flag is a combination of -march and -mtune.  It simultaneously specifies the target architecture and optimizes for a given microarchitecture. On x86 this flag is a deprecated synonym for -mtune.

So maybe it makes sense to treat those flags behaves differently on different target .

3. I also tried llc to specific -mcpu and -attr (similar to -march, target-feature) in ARM, -attr will over write the default target-feature in -mcpu.

on RISC-V, in sometime (or most?) we have same pipeline model but support different extension combination, 
so I think maybe distinguishing the purpose of -mcpu and -march and make them with no interaction is a good idea. (behavior is equal to GCC)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71124





More information about the cfe-commits mailing list