-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: invalid operand for instruction in arch/arm/vfp/vfpinstr.h #306
Comments
It seems to me that the LLVM assembler really does not support p10 operand here. GNU assembler uses the following flags:
|
It seems that Co-Processor 10 and 11 (we use
We probably should just use the VFP/NEON specific instructions I guess? @smithp35 any thoughts on this? |
There is a long discussion on https://llvm.org/pr20025 which is the source of those lines. Beforehand no architecture was permitted to use 10 and 11. As far as I can tell there isn't anything in what counts for the assembly language specification that prohibits use of 10 and 11 on ARMv7 and above. It seems to be a policy choice to prevent someone from misusing them given that any use for something else would conflict with Neon/VFP and given that specific instructions exist why not use them. Personally if you are able to use the new instructions then I suggest doing so. There is a case where code has to assemble on multiple architectures even if they don't support the instructions, which is mentioned in the PR. For that case this could be worked around by using a .arch directive to locally change to a pre-armv7-a. If all that fails then I guess we'll need to provide a good enough argument as to why the restriction should be removed. Personally I tend to prefer Postel's law of be liberal in what you accept and be specific in what you output, but I may be in the minority. |
Dropping the cp10/cp11 check in LLVM allows me to compile and assemble the complete kernel using Clang/LLVM (all c files, for the assembly files I still use integrated-as). The kernel also boots fine. There are about 5 macros or inline assembly preprocessor defines which use Given that allowing cp10/11 in LLVM is rather trivial, I'd rather prefer to go this route (maybe behind an option)? Just for clarity: E.g. the The Arm ARM describes the spec_reg argument, which can be one of
|
In a quick test I use
This is compiled with |
Yes the co-processor instructions with cp10 and cp11 will assemble to the same bitpattern. You should be able to confirm this by disassembling the object. The disassembler will prefer the VFP decoding. The vmsr is complaining about cr8, clang only accepts the <spec_reg> form of FPEXC whereas gcc will accept cr8. The Arm ARM doesn't mention anything about cr8, all is says is FPEXC reg='1000' so in this case I don't think that there is a problem with clang. For removing the restriction on cp10 and cp11 I think that is worth having the debate upstream. rengolin was the author and it will be worth including him on any review. |
Another possibility if there is resistance to removing the check might be to issue a warning if cp10 and cp11 are used on v7, something like "Warning, cp10 and cp11 are reserved for Floating-Point and Advanced SIMD extensions." that should catch mistakes as well as permitting system level software that needs to assemble on multiple architectures. |
Thanks for the hints, using
It seems that those registers fail the same check in LLVM (parseCoprocNumOperand). I still have some instances where I am not sure what the correct replacements are, e.g. the vfp_(get|put)_(float|double) in arch/arm/vfp/vfphw.S. Typically Linux tries to be warn-free, so if we add a warning there should be an option to explicitly disable it... Where is the right place to start a debate on this upstream? |
A similar case are deprecated warnings when using co-processor instructions for data-barriers:
Those warnings can be suppressed using It almost seems it would be more consistent to convert the VFP case into a similar warning. The patch is actually rather trivial:
@smithp35 thoughts? |
I don't think we can use deprecated here as it has a specific meaning in the Arm ARM and there isn't anywhere in the v7 or v8 Arm ARM that says using the coprocessor mnemonics is deprecated. In the other case you mention for "mcr p15, 0, r0, c7, c10, 4" this is a deprecated encoding as well as mnemonic and is specifically mentioned in the v7 Arm ARM as deprecated. I think we could say: The instructions in vfp_get_float and vfp_put_float should correspond to various forms of VMOV For the debate upstream I think it is niche enough to address with a patch to LLVM that implements the behaviour with supporting examples from the kernel. I'd think the following set of reviewers would be enough: rengolin, olista01, t.p.northover, efriedma |
Created a patch for LLVM: https://reviews.llvm.org/D59733 |
tentatively marking as a bug in LLVM; feel free to change labels if you disagree. |
Hm, there have been related changes nearby: https://reviews.llvm.org/D63863 Working on a rebased version. |
I reviewed this case a bit since we discussed alternative solutions by using assembly directives such as However, there is one case which I think there won't be a solution in
This leads to:
GNU objdump disassembles this to:
@arndb any thoughts? |
Hey @agners landed https://reviews.llvm.org/D59733! Marking this as fixed? (or is there more to do here?) |
@nickdesaulniers yes this can be marked solved. I plan to send a related patch to the Linux ML as well which uses new mnemonics where available/possible, but I track this with a separate bug #905 already. |
Compiling with integrated-as for c files fails for
arch/arm/kernel/perf_event_v7.c
.Update: Changed this ticket to only reflect
perf_event_v7.c
problem. The issue ofarch/arm/vfp/vfpmodule.c
has been moved to #905.The text was updated successfully, but these errors were encountered: