ARM: inline asm does not support pre-UAL conditional LDRH etc
| Bugzilla Link | 11855 |
| Resolution | WONTFIX |
| Resolved on | Jul 05, 2013 04:27 |
| Version | trunk |
| OS | Linux |
| Reporter | LLVM Bugzilla Contributor |
| CC | @efriedma-quic,@rengolin,@TNorthover |
Extended Description
The inline asm parser should accept the old forms of conditional LDRH and friends, e.g. LDREQH should be an alias for LDRHEQ. GCC supports only these forms in ARM mode, so this is essential for compatibility.
Test case: void foo(void) { asm ("ldreqh r0, [r1]"); }
Fails like this:
asm.c:3:14: error: invalid instruction
asm ("ldreqh r0, [r1]");
^
I'd just like to add one more comment about this.
Pre-UAL syntax is not forbidden and should not be considered wrong. My main point is to make UAL support in LLVM production ready, and until that happens, pre-UAL has zero priority.
However, once UAL is good, and the integrated assembler is enabled by default, it shouldn't be hard to add the pre-UAL aliases, as long as they don't change the assembler's behaviour, or introduce dualities in the codegen.
The main problem, as Tim Northover noted in the NOPs case, is that the result of the assembler should be the same as the disassembler. So, if the original code had pre-UAL, and it gets converted into an MCInst that gets lowered back as an UAL instruction, the output will be different. Solving this problem is not trivial and will mess up the current UAL development.
As they are, the current solutions to pre-UAL syntax are wrong, and should be removed.
Patches welcome, said the GCC folks. ;)
Basically we should bark at binutils/gas to get them to use the UAL syntax and then rewrite the asm codebase.
Mans, others,
I had extensive talks with key ARM people spanning across multiple compiler toolchains, companies and countries (some of them replied to this post), and I have reached the conclusion that it's not profitable, not even desirable, to implement non-UAL assembly directives in LLVM. It is a unanimous opinion that there is no future for non-UAL assembly.
Other toolchains already had pre-UAL support, and maintaining them costs almost nothing, so there is no incentive to remove the feature. But implementing them in LLVM makes no sense. GCC's lack of support for UAL is troubling and should be dealt with on its own, without affecting the direction of LLVM. The cost associated with implementing it in LLVM is big and the benefit is small. We'd rather focus our attention to other matters, including UAL assembly support.
LLVM-based compilers, especially Clang, focus on being standards compliant, not GNU compliant, and that's an important tool for the rest of the community, that uses the fact that we have now two powerful open source C/C++ compilers, with which they can test and find more errors on their programs. If Clang follows GCC on every step, the community at large would lose that ability, and there would be little point for LLVM.
Although we understand that legacy code cannot be compiled with Clang, this is not an entirely bad thing, as we currently have two solutions for this:
- Use GAS, GCC etc, as little as possible, on the restricted subset where Clang+LLVM can't compile
The same is true for any other legacy compiler, including the Intel and the ARM compilers. There's nothing new here, and as an example of their quality, projects that rely on their idiosyncrasies are summarily abandoned when they hit the open source world.
- Work with the developers to upgrade their code, use new libraries, write new code.
It's a very noble activity that of updating your software. Machines are not what they used to be, algorithms get better, compilers get better, standards get better. The more we encourage people to stick to standards, the better. Especially since the number of reasons not to is getting smaller every decade.
I'm closing this bug as "wontfix", and I hope not to offend anyone with this, but there needs to be a line drawn somewhere. We will continue to accept the removal of pre-UAL syntax from LLVM as a means to get the integrated assembler production quality for ARM as soon as possible.
Feel free to reference this text on other/future bugs about non-UAL syntax.
Me too. The older syntax was deprecated for a reason, and supporting it in LLVM would be quite a burden both short and long-term. Also, if GCC doesn't support UAL that's a far bigger problem for GCC than for us (in my view).
I agree. In fact, the more I've thought about this issue, my position has shifted a bit. Barring very strong reasons for adding any particular bit of support, I don't think we should be adding additional divided syntax handling at all. We should be moving in the opposite direction, working with project owners as necessary to update their code to the supported UAL syntax and actively deprecating divided syntax. Pragmatism makes that complicated, of course, and it'll be a long road, but the eventual outcome will be a better place.
Jim, Mans,
ARM's stance has changed and I think most people involved in the ARM back-end agree that moving towards UAL-only is the best route for now. Recent changes to deprecate pre-UAL syntax (such as NOPs) is in line with that strategy.
Pre-UAL code will not compile, I agree it's not ideal, but maintaining several dialects while trying to make it work for the first time (the integrated assembler is not enabled by default yet because it's not complete) is not the best use of our resources. We don't have an extensive team of ARM experts, nor do we have an already fully compliant assembler, so until UAL is fully implemented, I don't think we should even try to support pre-UAL.
I don't speak for the whole LLVM+ARM community and this is my opinion only, but I think we should not accept patches that add pre-UAL code until UAL support is complete.
Thanks! I'll have a look.
Recognise pre-UAL condition code placement Oops, first patch was broken. This one should work.
Recognise pre-UAL condition code placement Patch added.
There's no philosophical objection to supporting pre-UAL syntax. There's just no active plans to do anything about it that I'm aware of.
Patches welcome, though, if you care that deeply about it.
That is a most unfortunate stance to take. It means a lot of code will never compile with clang.
The integrated assembler is unified syntax only. There are no plans for that to change.