[llvm-dev] difference between --target, -mcpu, -march

Krzysztof Parzyszek via llvm-dev llvm-dev at lists.llvm.org
Sat Mar 19 09:08:11 PDT 2016


On 3/19/2016 5:54 AM, Bruce Hoult via llvm-dev wrote:
> Would it be fair to say that an -march chooses an instruction set, while
> -mcpu will affect scheduling things such as how many instructions can be
> run in parallel and their latency etc?

 From what I remember, the meaning of march/mcpu differs between clang 
and LLVM's utilities (llc, etc.)  In clang, mcpu and march have a lot of 
overlap in terms of usage, and it seems to differ from one target to the 
next.  What you say would make sense, but, for example, we have legacy 
code that used -march=hexagonv5, where "hexagonv5" is actually a CPU 
version, something that intuitively should belong in "mcpu".  Hexagon 
doesn't seem to be the only one where "march" and "mcpu" are treated 
almost identically, I saw what looked like CPU names in the march string 
in other toolchains as well.

The clang documentation states:

   Target Selection Options
   ~~~~~~~~~~~~~~~~~~~~~~~~
   [...]
     .. option:: -arch <architecture>

     Specify the architecture to build for.
   [...]

   .. option:: -march=<cpu>

     Specify that Clang should generate code for a specific processor 
family
     member and later.  For example, if you specify -march=i486, the 
compiler is
     allowed to generate instructions that are valid on i486 and later 
processors,
     but which may not exist on earlier ones.

mcpu is not mentioned at all.

For better or worse, clang is trying to emulate GCC's options, which 
have a long history behind them.  There is some general idea there, but 
I think the target/processor selection scheme has evolved beyond the 
point where it makes sense on all levels.

-Krzysztof


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation


More information about the llvm-dev mailing list