-march=armv8.1-m.main+mve.fp+nomve -mfpu=none should disable FP registers and
instructions moving to/from FP registers.
This patch fixes the case when "+mve" (added to the feature list by "+mve.fp"),
is followed by "-mve" (added by "+nomve").
Differential D72633
[ARM][MVE] Fix a corner case of checking for MVE-I with -mfpu=none chill on Jan 13 2020, 10:46 AM. Authored by
Details -march=armv8.1-m.main+mve.fp+nomve -mfpu=none should disable FP registers and This patch fixes the case when "+mve" (added to the feature list by "+mve.fp"),
Diff Detail
Event TimelineComment Actions I guess this makes probably sense, but just checking why this should have the effect of enabling MVE-I? Is there prior art -mfpu=none has a similar effect? Has this been synchronised with the GCC community? Comment Actions Probably if I was designing these flags from scratch, I wouldn't choose the semantics of "-mfpu=none is *very* similar to -mfloat-abi=soft, only that it should not disable MVE-I.", but I guess we're following gcc here?
Comment Actions The overall theme is that MVE-I can be present without an FPU. Thus -mfpu=none should not disable MVE-I, whether explicitly requested by +mve or
GCC does not have -mfpu=none.
No, this patch does not change TargetParser, thus by itself does not require extra tests in TargetParser unit tests. MVE-I without an FPU is an architectural feature, so it only makes sense leaving MVE-I enabled after -mfpu=none.
Comment Actions In terms of the user-visible behavior, I guess my question is whether it would make sense to add "-mfpu=mve"/"-mfpu=mve.fp", and make "-mfpu=none" mean "no FP registers". I'm not sure why a user would specify "-mfpu=none" if they didn't want to disable the floating-point registers altogether.
Comment Actions I don't find this approach particularly natural and unsurprising. When a user says -mfpu=X, "X" ought to be some FPU designation, -mfpu=none would make sense in combinations like -mcpu=Foo -mfpu=none, where "Foo" is some future core, that has an FPU. Comment Actions
So then "-mfloat-abi=hard -mfpu=none" means "pass floating-point values in registers, but don't use any other floating-point operations"? Does the behavior vary depending on whether the target supports floating-point registers due to MVE, vs. some other "FP" feature?
We already use -mfpu to enable instructions that aren't actually floating-point operations. For example, -mfpu=neon enables integer vector operations. Comment Actions While we're on the subject, it's always seemed odd to me in the first place that -mfloat-abi=soft prevents all use of the FP registers! By a literal reading of the option name, it surely ought to only disallow use of the FP registers at function call boundaries. I'd expect it to mean "Make my functions ABI-compatible with code built for a CPU with no FP regs at all, but within that constraint, do whatever will get the job done fastest"; using FP registers and hardware FP operations inside a function ought still to be legitimate, provided you transfer the return value back into the right integer register(s) once you've finished computing it. Comment Actions No, it does not mean that, at least not yet, and it's not immediately obvious if that would be of any advantage. But it does affect integer vectors.
Fair enough, but it also enables floating-point operations, which a hypothetical -mfpu=mve would not and should not. Indeed, -mfpu=mve.fp is no worse than tl;dr: IMHO, -march=...+mve+mve.fp is more natural than -mfpu=mve/-mfpu=mve.fp or -march=...+mve -mfpu=mve.fp. Comment Actions There are three alternatives here I can think of:
(3) seems very unintuitive. Yes, passing values in float registers when there isn't any arithmetic is slightly strange, but there's precedent: -mfloat-abi=hard -mfpu=vfpv4-sp-d16 passes double-precision values in float registers.
You don't need to specify -mfpu at all, if you just want whatever the "-march/-mfloat-abi" implies. Actually, can we just forbid using -mfpu for MVE targets? It doesn't really seem useful if the only legal value is "-mfpu=none". Comment Actions I'm sorry, I lied here a bit. With regard to scalar floating-point arguments/returns, if FP registers are present, they will be used
That should not be illegal. With Armv8.1-M, it's valid to have FP registers and not have FPU/FP-operations.
Yes, it should be legal and -mfloat-abi=hard has an effect.
What are the options there (baseline -march=...+mve):
Certainly, some of the options may prove to make the wrong tradeoffs, but I don't think any of them stands out as obviously ridiculous.
No, it's not the only legal value, an MVE-I target does not imply an FPU at all, and an MVE-FP target does not imply double-precision scalar operations. Comment Actions I don't like fiddling with the ABI based on CPU features; it's common to mix code with different CPU features enabled (particularly for desktop/mobile CPUs; less so on microcontrollers, but it can still happen). If we want to support some other ABI for performance reasons, we should make the user request it explicitly.
Let me see if I understand the potential combinations: "-march=armv8.1-m.main+mve.fp" allows mve, vfp-single, and mve.fp, but not vfp-double All of the above allow all vfp mov/load/store instructions; the only way to restrict those on a target with MVE is "-mfloat-abi=soft". Is this right? Do we have documentation that describes this? Comment Actions Absolutely, we are definitely not proposing a new ABI.
Yes, except enabling the FPU. That's IMHO the ideal behaviour, but FPU is enabled by default for Armv8.x-M.Mainline (perhaps an oversight, the default differs even between 8.0-M and 8.1-M).
Ideally this ought to give an error, since there's no NEON fort armv8-M.
Yes.
We have the Armv8-M ARM, which describes the dependencies between optional architecture extensions (https://developer.arm.com/docs/ddi0553/latest). Comment Actions Okay, the combinations make sense, then. It would be nice to add some documentation on the clang side; we currently have no documentation at all for -march or -mfpu in https://clang.llvm.org/docs/ .
|
How many times can "+mve"/"-mve" appear in the list? If more than once, do you need to use rfind?
"const auto&" doesn't really make sense here; you can just use "auto".