Closed 4ntoine closed 9 years ago
https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html for AVR:
AVR family—config/avr/constraints.md
l
Registers from r0 to r15
a
Registers from r16 to r23
d
Registers from r16 to r31
w
Registers from r24 to r31. These registers can be used in ‘adiw’ command
e
Pointer register (r26–r31)
b
Base pointer register (r28–r31)
q
Stack pointer register (SPH:SPL)
t
Temporary register r0
x
Register pair X (r27:r26)
y
Register pair Y (r29:r28)
z
Register pair Z (r31:r30)
I
Constant greater than −1, less than 64
J
Constant greater than −64, less than 1
K
Constant integer 2
L
Constant integer 0
M
Constant that fits in 8 bits
N
Constant integer −1
O
Constant integer 8, 16, or 24
P
Constant integer 1
G
A floating point constant 0.0
Q
A memory address based on Y or Z pointer with displacement.
I believe that clang passes the assembly constraints as strings to LLVM. This document describes inline assembler expressions in LLVM.
Clang has a list of possible supported constraints for all targets here. I'd assume you would just add the missing constraints for AVR, and then clang will automatically pass them onto LLVM.
Here is a list of constraints that AVR supports, under the title Input and Output Operands.
Reproduced here:
Constraint | Used for | Range |
---|---|---|
a | Simple upper registers | r16 to r23 |
b | Base pointer registers pairs | y, z |
d | Upper register | r16 to r31 |
e | Pointer register pairs | x, y, z |
q | Stack pointer register | SPH:SPL |
r | Any register | r0 to r31 |
t | Temporary register | r0 |
w | Special upper register pairs | r24, r26, r28, r30 |
x | Pointer register pair X | x (r27:r26) |
y | Pointer register pair Y | y (r29:r28) |
z | Pointer register pair Z | z (r31:r30) |
G | Floating point constant | 0.0 |
I | 6-bit positive integer constant | 0 to 63 |
J | 6-bit negative integer constant | -63 to 0 |
K | Integer constant | 2 |
L | Integer constant | 0 |
l | Lower registers | r0 to r15 |
M | 8-bit integer constant | 0 to 255 |
N | Integer constant | -1 |
O | Integer constant | 8, 16, 24 |
P | Integer constant | 1 |
Q | A memory address based on Y or Z pointer with displacement | |
R | Integer constant | -6 to 5 |
already in progress
Note Clang only validates constraints, still need to implement AVRAsmParser
https://github.com/dylanmckay/avr-llvm/issues/21 https://github.com/dylanmckay/avr-llvm/issues/20 https://github.com/dylanmckay/avr-llvm/issues/19
Asm code is validated by Clang and then should be passed to unimplemented
AvrAsmParser
classes. At the moment asm code is validated by Clang and it's not recognized as valid.