Skip to content

integrated assembler should convert and foo, bar, immediate into bic foo, bar, ~immediate if immediate doesn't fit into the immediate field bit ~immediate does #26094

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

Closed
nico opened this issue Dec 2, 2015 · 5 comments
Assignees
Labels
backend:ARM bugzilla Issues migrated from bugzilla

Comments

@nico
Copy link
Contributor

nico commented Dec 2, 2015

Bugzilla Link 25720
Resolution FIXED
Resolved on Dec 08, 2015 12:11
Version trunk
OS Linux
Blocks #20796
CC @Arnaud-de-Grandmaison-ARM,@jmolloy,@rengolin,@TNorthover

Extended Description

When trying to build boringssl with clang's integrated assembler, it complains about this:

thakis@thakis:/src/chrome/src$ cat arm.S
.fpu neon
.text
.align 4
.global foo
.hidden foo
.type foo, %function
and sp, sp, #​0xffffffe0
thakis@thakis:
/src/chrome/src$ third_party/llvm-build/Release+Asserts/bin/clang -c arm.S -march=armv7-a -target arm-linux-androideab
arm.S:7:14: error: invalid operand for instruction
and sp, sp, #​0xffffffe0
^

gas accepts this without complaints and converts it into a BIC instruction (a and not b), as ~0xffffffe0 = 1f fits into the 8bit unshifted immediate. The integrated assembler should do this too:

thakis@thakis:/src/chrome/src$ third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -c arm.S
thakis@thakis:
/src/chrome/src$ third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objdump -D -marm arm.o

arm.o: file format elf32-littlearm

Disassembly of section .text:

00000000 <.text>:
0: e3cdd01f bic sp, sp, #​31
4: e1a00000 nop ; (mov r0, r0)
8: e1a00000 nop ; (mov r0, r0)
c: e1a00000 nop ; (mov r0, r0)

@nico
Copy link
Contributor Author

nico commented Dec 2, 2015

assigned to @rengolin

@TNorthover
Copy link
Contributor

Implementation will obviously have to make sure the real AND gets prioritised if both forms are valid, but this seems likely to be a fairly simple and uncontroversial one to implement.

@rengolin
Copy link
Member

rengolin commented Dec 8, 2015

So, it appears support was added many years ago, and the only problem with your example wasn't the negative, but the use of SP, which wasn't included in the pattern. I'll be submitting a patch soon.

@TNorthover
Copy link
Contributor

Ah, that would explain why the whole thing seemed familiar!

@rengolin
Copy link
Member

rengolin commented Dec 8, 2015

Expanded to all registers (on ARM only) in r255034, with some more tests. Your example works now.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:ARM bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

3 participants