Home | History | Annotate | Download | only in AArch64
      1 ; RUN: llc -verify-machineinstrs -mtriple=arm64-linux-gnu -pre-RA-sched=linearize -enable-misched=false < %s | FileCheck %s
      2 
      3 %va_list = type {i8*, i8*, i8*, i32, i32}
      4 
      5 @var = global %va_list zeroinitializer, align 8
      6 
      7 declare void @llvm.va_start(i8*)
      8 
      9 define void @test_simple(i32 %n, ...) {
     10 ; CHECK-LABEL: test_simple:
     11 ; CHECK: sub sp, sp, #[[STACKSIZE:[0-9]+]]
     12 ; CHECK: add [[STACK_TOP:x[0-9]+]], sp, #[[STACKSIZE]]
     13 
     14 ; CHECK: adrp x[[VA_LIST_HI:[0-9]+]], var
     15 
     16 ; CHECK: stp x1, x2, [sp, #[[GR_BASE:[0-9]+]]]
     17 ; ... omit middle ones ...
     18 ; CHECK: str x7, [sp, #
     19 
     20 ; CHECK: stp q0, q1, [sp]
     21 ; ... omit middle ones ...
     22 ; CHECK: stp q6, q7, [sp, #
     23 
     24 ; CHECK: str [[STACK_TOP]], [x[[VA_LIST_HI]], :lo12:var]
     25 
     26 ; CHECK: add [[GR_TOPTMP:x[0-9]+]], sp, #[[GR_BASE]]
     27 ; CHECK: add [[GR_TOP:x[0-9]+]], [[GR_TOPTMP]], #56
     28 ; CHECK: add x[[VA_LIST:[0-9]+]], {{x[0-9]+}}, :lo12:var
     29 ; CHECK: str [[GR_TOP]], [x[[VA_LIST]], #8]
     30 
     31 ; CHECK: mov [[VR_TOPTMP:x[0-9]+]], sp
     32 ; CHECK: add [[VR_TOP:x[0-9]+]], [[VR_TOPTMP]], #128
     33 ; CHECK: str [[VR_TOP]], [x[[VA_LIST]], #16]
     34 
     35 ; CHECK: movn [[GR_OFFS:w[0-9]+]], #0x37
     36 ; CHECK: str [[GR_OFFS]], [x[[VA_LIST]], #24]
     37 
     38 ; CHECK: orr [[VR_OFFS:w[0-9]+]], wzr, #0xffffff80
     39 ; CHECK: str [[VR_OFFS]], [x[[VA_LIST]], #28]
     40 
     41   %addr = bitcast %va_list* @var to i8*
     42   call void @llvm.va_start(i8* %addr)
     43 
     44   ret void
     45 }
     46 
     47 define void @test_fewargs(i32 %n, i32 %n1, i32 %n2, float %m, ...) {
     48 ; CHECK-LABEL: test_fewargs:
     49 ; CHECK: sub sp, sp, #[[STACKSIZE:[0-9]+]]
     50 ; CHECK: add [[STACK_TOP:x[0-9]+]], sp, #[[STACKSIZE]]
     51 
     52 ; CHECK: adrp x[[VA_LIST_HI:[0-9]+]], var
     53 
     54 ; CHECK: stp x3, x4, [sp, #[[GR_BASE:[0-9]+]]]
     55 ; ... omit middle ones ...
     56 ; CHECK: str x7, [sp, #
     57 
     58 ; CHECK: stp q1, q2, [sp]
     59 ; ... omit middle ones ...
     60 ; CHECK: str q7, [sp, #
     61 
     62 ; CHECK: str [[STACK_TOP]], [x[[VA_LIST_HI]], :lo12:var]
     63 
     64 ; CHECK: add [[GR_TOPTMP:x[0-9]+]], sp, #[[GR_BASE]]
     65 ; CHECK: add [[GR_TOP:x[0-9]+]], [[GR_TOPTMP]], #40
     66 ; CHECK: add x[[VA_LIST:[0-9]+]], {{x[0-9]+}}, :lo12:var
     67 ; CHECK: str [[GR_TOP]], [x[[VA_LIST]], #8]
     68 
     69 ; CHECK: mov [[VR_TOPTMP:x[0-9]+]], sp
     70 ; CHECK: add [[VR_TOP:x[0-9]+]], [[VR_TOPTMP]], #112
     71 ; CHECK: str [[VR_TOP]], [x[[VA_LIST]], #16]
     72 
     73 ; CHECK: movn [[GR_OFFS:w[0-9]+]], #0x27
     74 ; CHECK: str [[GR_OFFS]], [x[[VA_LIST]], #24]
     75 
     76 ; CHECK: movn [[VR_OFFS:w[0-9]+]], #0x6f
     77 ; CHECK: str [[VR_OFFS]], [x[[VA_LIST]], #28]
     78 
     79   %addr = bitcast %va_list* @var to i8*
     80   call void @llvm.va_start(i8* %addr)
     81 
     82   ret void
     83 }
     84 
     85 define void @test_nospare([8 x i64], [8 x float], ...) {
     86 ; CHECK-LABEL: test_nospare:
     87 
     88   %addr = bitcast %va_list* @var to i8*
     89   call void @llvm.va_start(i8* %addr)
     90 ; CHECK-NOT: sub sp, sp
     91 ; CHECK: mov [[STACK:x[0-9]+]], sp
     92 ; CHECK: str [[STACK]], [{{x[0-9]+}}, :lo12:var]
     93 
     94   ret void
     95 }
     96 
     97 ; If there are non-variadic arguments on the stack (here two i64s) then the
     98 ; __stack field should point just past them.
     99 define void @test_offsetstack([10 x i64], [3 x float], ...) {
    100 ; CHECK-LABEL: test_offsetstack:
    101 ; CHECK: sub sp, sp, #80
    102 ; CHECK: add [[STACK_TOP:x[0-9]+]], sp, #96
    103 ; CHECK: str [[STACK_TOP]], [{{x[0-9]+}}, :lo12:var]
    104 
    105   %addr = bitcast %va_list* @var to i8*
    106   call void @llvm.va_start(i8* %addr)
    107   ret void
    108 }
    109 
    110 declare void @llvm.va_end(i8*)
    111 
    112 define void @test_va_end() nounwind {
    113 ; CHECK-LABEL: test_va_end:
    114 ; CHECK-NEXT: BB#0
    115 
    116   %addr = bitcast %va_list* @var to i8*
    117   call void @llvm.va_end(i8* %addr)
    118 
    119   ret void
    120 ; CHECK-NEXT: ret
    121 }
    122 
    123 declare void @llvm.va_copy(i8* %dest, i8* %src)
    124 
    125 @second_list = global %va_list zeroinitializer
    126 
    127 define void @test_va_copy() {
    128 ; CHECK-LABEL: test_va_copy:
    129   %srcaddr = bitcast %va_list* @var to i8*
    130   %dstaddr = bitcast %va_list* @second_list to i8*
    131   call void @llvm.va_copy(i8* %dstaddr, i8* %srcaddr)
    132 
    133 ; CHECK: add x[[SRC:[0-9]+]], {{x[0-9]+}}, :lo12:var
    134 
    135 ; CHECK: ldr [[BLOCK:q[0-9]+]], [x[[SRC]]]
    136 ; CHECK: add x[[DST:[0-9]+]], {{x[0-9]+}}, :lo12:second_list
    137 ; CHECK: str [[BLOCK]], [x[[DST]]]
    138 
    139 ; CHECK: ldr [[BLOCK:q[0-9]+]], [x[[SRC]], #16]
    140 ; CHECK: str [[BLOCK]], [x[[DST]], #16]
    141   ret void
    142 ; CHECK: ret
    143 }
    144