clarify the abi
This commit is contained in:
parent
ff63704790
commit
f8cd43adc4
1 changed files with 14 additions and 11 deletions
25
lisc/ABI
25
lisc/ABI
|
@ -14,31 +14,34 @@ Classification:
|
||||||
1. The size of each argument gets rounded up to eightbytes.
|
1. The size of each argument gets rounded up to eightbytes.
|
||||||
(It keeps the stack always 8 bytes aligned.)
|
(It keeps the stack always 8 bytes aligned.)
|
||||||
2. _Bool, char, short, int, long, long long and pointers
|
2. _Bool, char, short, int, long, long long and pointers
|
||||||
are in the INTEGER class
|
are in the INTEGER class.
|
||||||
3. float and double are in the SSE class
|
3. float and double are in the SSE class.
|
||||||
4. If the size of an object is larger than two eightbytes
|
4. If the size of an object is larger than two eightbytes
|
||||||
or if contains unaligned fields, it has class MEMORY.
|
or if contains unaligned fields, it has class MEMORY.
|
||||||
5. Otherwise, pack all fields into two eighbytes and
|
5. Otherwise, recursively classify fields and determine
|
||||||
recursively classify them. If any of them is MEMORY
|
the class of the two eightbytes using the classes of
|
||||||
the result is MEMORY, if any is INTEGER the result
|
their components. If any of them is MEMORY the result
|
||||||
is INTEGER, otherwise the result is SSE.
|
is MEMORY (but I don't think it can happen), if any is
|
||||||
|
INTEGER the result is INTEGER, otherwise the result
|
||||||
|
is SSE.
|
||||||
|
|
||||||
Passing:
|
Passing:
|
||||||
- Classify arguments in order.
|
- Classify arguments in order.
|
||||||
- INTEGER arguments use in order %rdi %rsi %rdx %rcx
|
- INTEGER arguments use in order %rdi %rsi %rdx %rcx
|
||||||
%r8 %r9
|
%r8 %r9.
|
||||||
- SSE arguments use in order %xmm0 - %xmm7
|
- SSE arguments use in order %xmm0 - %xmm7.
|
||||||
- MEMORY gets passed on the stack
|
- MEMORY gets passed on the stack.
|
||||||
- When we run out of registers for an aggregate, revert
|
- When we run out of registers for an aggregate, revert
|
||||||
the assignment for the first eightbytes and pass it
|
the assignment for the first eightbytes and pass it
|
||||||
on the stack.
|
on the stack.
|
||||||
- When all registers are taken, write arguments on the
|
- When all registers are taken, write arguments on the
|
||||||
stack from right to left.
|
stack from right to left.
|
||||||
|
- Registers %rbx, %r12 - %r15 are callee-save.
|
||||||
|
|
||||||
Returning.
|
Returning.
|
||||||
- Classify the return type.
|
- Classify the return type.
|
||||||
- Use %rax and %rdx in order for INTEGER return values
|
- Use %rax and %rdx in order for INTEGER return values.
|
||||||
- Use %xmm0 and %xmm1 in order for SSE return values
|
- Use %xmm0 and %xmm1 in order for SSE return values.
|
||||||
- I the return value's class is MEMORY, the first
|
- I the return value's class is MEMORY, the first
|
||||||
argument of the function %rdi was a pointer to an
|
argument of the function %rdi was a pointer to an
|
||||||
area big enough to fit the return value. The function
|
area big enough to fit the return value. The function
|
||||||
|
|
Loading…
Add table
Reference in a new issue