Skip to content
tyfkda edited this page Apr 12, 2023 · 12 revisions

Specification

Misc

Optimization

SSA

Register allocation

ABI

Variable Argument Lists

  • System V ABI AMD64 Specification 3.5.7 Variable Argument Lists

  • %raxにxmmの個数を入れて渡す

  • Offset:

    • %rdi 0
    • %rsi 8
    • %rdx 16
    • %rcx 24
    • %r8 32
    • %r9 40
    • %xmm0 48
    • %xmm1 64
    • . . .
    • %xmm15 288
typedef struct {
  unsigned int gp_offset;                                                                           
  unsigned int fp_offset;                                                                           
  void *overflow_arg_area;                                                                          
  void *reg_save_area;                                                                              
} va_list[1];                                                                                       
  movl l->gp_offset, %eax
  cmpl $48, %eax  ;; Is register available?
  jae stack  ;; If not, use stack
  leal $8(%rax), %edx  ;; Next available register
  addq l->reg_save_area, %rax  ;; Address of saved register
  movl %edx, l->gp_offset  ;; Update gp_offset
  jmp fetch
stack: movq l->overflow_arg_area, %rax  ;; Address of stack slot
  leaq 8(%rax), %rdx  ;; Next available stack slot
  movq %rdx,l->overflow_arg_area  ;; Update
fetch: movl (%rax), %eax  ;; Load argument

Environment

For macOS

Library functions, algorithm

float => string

//

Clone this wiki locally