1 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu | FileCheck %s 2 3 %myStruct = type { i64 , i8, i32 } 4 5 @var8 = global i8 0 6 @var8_2 = global i8 0 7 @var32 = global i32 0 8 @var64 = global i64 0 9 @var128 = global i128 0 10 @varfloat = global float 0.0 11 @varfloat_2 = global float 0.0 12 @vardouble = global double 0.0 13 @varstruct = global %myStruct zeroinitializer 14 @varsmallstruct = global [2 x i64] zeroinitializer 15 16 declare void @take_i8s(i8 %val1, i8 %val2) 17 declare void @take_floats(float %val1, float %val2) 18 19 define void @simple_args() { 20 ; CHECK-LABEL: simple_args: 21 %char1 = load i8* @var8 22 %char2 = load i8* @var8_2 23 call void @take_i8s(i8 %char1, i8 %char2) 24 ; CHECK: ldrb w0, [{{x[0-9]+}}, #:lo12:var8] 25 ; CHECK: ldrb w1, [{{x[0-9]+}}, #:lo12:var8_2] 26 ; CHECK: bl take_i8s 27 28 %float1 = load float* @varfloat 29 %float2 = load float* @varfloat_2 30 call void @take_floats(float %float1, float %float2) 31 ; CHECK: ldr s1, [{{x[0-9]+}}, #:lo12:varfloat_2] 32 ; CHECK: ldr s0, [{{x[0-9]+}}, #:lo12:varfloat] 33 ; CHECK: bl take_floats 34 35 ret void 36 } 37 38 declare i32 @return_int() 39 declare double @return_double() 40 declare [2 x i64] @return_smallstruct() 41 declare void @return_large_struct(%myStruct* sret %retval) 42 43 define void @simple_rets() { 44 ; CHECK-LABEL: simple_rets: 45 46 %int = call i32 @return_int() 47 store i32 %int, i32* @var32 48 ; CHECK: bl return_int 49 ; CHECK: str w0, [{{x[0-9]+}}, #:lo12:var32] 50 51 %dbl = call double @return_double() 52 store double %dbl, double* @vardouble 53 ; CHECK: bl return_double 54 ; CHECK: str d0, [{{x[0-9]+}}, #:lo12:vardouble] 55 56 %arr = call [2 x i64] @return_smallstruct() 57 store [2 x i64] %arr, [2 x i64]* @varsmallstruct 58 ; CHECK: bl return_smallstruct 59 ; CHECK: str x1, [{{x[0-9]+}}, #8] 60 ; CHECK: str x0, [{{x[0-9]+}}, #:lo12:varsmallstruct] 61 62 call void @return_large_struct(%myStruct* sret @varstruct) 63 ; CHECK: add x8, {{x[0-9]+}}, #:lo12:varstruct 64 ; CHECK: bl return_large_struct 65 66 ret void 67 } 68 69 70 declare i32 @struct_on_stack(i8 %var0, i16 %var1, i32 %var2, i64 %var3, i128 %var45, 71 i32* %var6, %myStruct* byval %struct, i32 %stacked, 72 double %notstacked) 73 declare void @stacked_fpu(float %var0, double %var1, float %var2, float %var3, 74 float %var4, float %var5, float %var6, float %var7, 75 float %var8) 76 77 define void @check_stack_args() { 78 call i32 @struct_on_stack(i8 0, i16 12, i32 42, i64 99, i128 1, 79 i32* @var32, %myStruct* byval @varstruct, 80 i32 999, double 1.0) 81 ; Want to check that the final double is passed in registers and 82 ; that varstruct is passed on the stack. Rather dependent on how a 83 ; memcpy gets created, but the following works for now. 84 ; CHECK: mov x0, sp 85 ; CHECK: str {{w[0-9]+}}, [x0] 86 ; CHECK: str {{w[0-9]+}}, [x0, #12] 87 ; CHECK: fmov d0, 88 ; CHECK: bl struct_on_stack 89 90 call void @stacked_fpu(float -1.0, double 1.0, float 4.0, float 2.0, 91 float -2.0, float -8.0, float 16.0, float 1.0, 92 float 64.0) 93 ; CHECK: ldr s[[STACKEDREG:[0-9]+]], [{{x[0-9]+}}, #:lo12:.LCPI 94 ; CHECK: mov x0, sp 95 ; CHECK: str d[[STACKEDREG]], [x0] 96 ; CHECK: bl stacked_fpu 97 ret void 98 } 99 100 101 declare void @check_i128_stackalign(i32 %val0, i32 %val1, i32 %val2, i32 %val3, 102 i32 %val4, i32 %val5, i32 %val6, i32 %val7, 103 i32 %stack1, i128 %stack2) 104 105 declare void @check_i128_regalign(i32 %val0, i128 %val1) 106 107 108 define void @check_i128_align() { 109 ; CHECK-LABEL: check_i128_align: 110 %val = load i128* @var128 111 call void @check_i128_stackalign(i32 0, i32 1, i32 2, i32 3, 112 i32 4, i32 5, i32 6, i32 7, 113 i32 42, i128 %val) 114 ; CHECK: ldr [[I128LO:x[0-9]+]], [{{x[0-9]+}}, #:lo12:var128] 115 ; CHECK: ldr [[I128HI:x[0-9]+]], [{{x[0-9]+}}, #8] 116 ; CHECK: mov x[[SPREG:[0-9]+]], sp 117 ; CHECK: str [[I128HI]], [x[[SPREG]], #24] 118 ; CHECK: str [[I128LO]], [x[[SPREG]], #16] 119 ; CHECK: bl check_i128_stackalign 120 121 call void @check_i128_regalign(i32 0, i128 42) 122 ; CHECK-NOT: mov x1 123 ; CHECK: movz x2, #42 124 ; CHECK: mov x3, xzr 125 ; CHECK: bl check_i128_regalign 126 127 ret void 128 } 129 130 @fptr = global void()* null 131 132 define void @check_indirect_call() { 133 ; CHECK-LABEL: check_indirect_call: 134 %func = load void()** @fptr 135 call void %func() 136 ; CHECK: ldr [[FPTR:x[0-9]+]], [{{x[0-9]+}}, #:lo12:fptr] 137 ; CHECK: blr [[FPTR]] 138 139 ret void 140 } 141