1; RUN: llc -mtriple=aarch64-apple-ios -O0 -stop-after=irtranslator -global-isel -verify-machineinstrs %s -o - 2>&1 | FileCheck %s 2 3 4; CHECK-LABEL: name: test_stack_slots 5; CHECK: fixedStack: 6; CHECK-DAG: - { id: [[STACK0:[0-9]+]], type: default, offset: 0, size: 1, 7; CHECK-DAG: - { id: [[STACK8:[0-9]+]], type: default, offset: 1, size: 1, 8; CHECK: [[LHS_ADDR:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.[[STACK0]] 9; CHECK: [[LHS:%[0-9]+]]:_(s8) = G_LOAD [[LHS_ADDR]](p0) :: (invariant load 1 from %fixed-stack.[[STACK0]], align 16) 10; CHECK: [[RHS_ADDR:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.[[STACK8]] 11; CHECK: [[RHS:%[0-9]+]]:_(s8) = G_LOAD [[RHS_ADDR]](p0) :: (invariant load 1 from %fixed-stack.[[STACK8]]) 12; CHECK: [[SUM:%[0-9]+]]:_(s8) = G_ADD [[LHS]], [[RHS]] 13; CHECK: [[SUM32:%[0-9]+]]:_(s32) = G_SEXT [[SUM]](s8) 14; CHECK: $w0 = COPY [[SUM32]](s32) 15define signext i8 @test_stack_slots([8 x i64], i8 signext %lhs, i8 signext %rhs) { 16 %sum = add i8 %lhs, %rhs 17 ret i8 %sum 18} 19 20; CHECK-LABEL: name: test_call_stack 21; CHECK: [[C42:%[0-9]+]]:_(s8) = G_CONSTANT i8 42 22; CHECK: [[C12:%[0-9]+]]:_(s8) = G_CONSTANT i8 12 23; CHECK: [[SP:%[0-9]+]]:_(p0) = COPY $sp 24; CHECK: [[C42_OFFS:%[0-9]+]]:_(s64) = G_CONSTANT i64 0 25; CHECK: [[C42_LOC:%[0-9]+]]:_(p0) = G_PTR_ADD [[SP]], [[C42_OFFS]](s64) 26; CHECK: G_STORE [[C42]](s8), [[C42_LOC]](p0) :: (store 1 into stack) 27; CHECK: [[C12_OFFS:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 28; CHECK: [[C12_LOC:%[0-9]+]]:_(p0) = G_PTR_ADD [[SP]], [[C12_OFFS]](s64) 29; CHECK: G_STORE [[C12]](s8), [[C12_LOC]](p0) :: (store 1 into stack + 1) 30; CHECK: BL @test_stack_slots 31define void @test_call_stack() { 32 call signext i8 @test_stack_slots([8 x i64] undef, i8 signext 42, i8 signext 12) 33 ret void 34} 35 36; CHECK-LABEL: name: test_128bit_struct 37; CHECK: $x0 = COPY 38; CHECK: $x1 = COPY 39; CHECK: $x2 = COPY 40; CHECK: BL @take_128bit_struct 41define void @test_128bit_struct([2 x i64]* %ptr) { 42 %struct = load [2 x i64], [2 x i64]* %ptr 43 call void @take_128bit_struct([2 x i64]* null, [2 x i64] %struct) 44 ret void 45} 46 47; CHECK-LABEL: name: take_128bit_struct 48; CHECK: {{%.*}}:_(p0) = COPY $x0 49; CHECK: {{%.*}}:_(s64) = COPY $x1 50; CHECK: {{%.*}}:_(s64) = COPY $x2 51define void @take_128bit_struct([2 x i64]* %ptr, [2 x i64] %in) { 52 store [2 x i64] %in, [2 x i64]* %ptr 53 ret void 54} 55 56; CHECK-LABEL: name: test_split_struct 57; CHECK: [[LD1:%[0-9]+]]:_(s64) = G_LOAD %0(p0) :: (load 8 from %ir.ptr) 58; CHECK: [[CST:%[0-9]+]]:_(s64) = G_CONSTANT i64 8 59; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_PTR_ADD %0, [[CST]](s64) 60; CHECK: [[LD2:%[0-9]+]]:_(s64) = G_LOAD %3(p0) :: (load 8 from %ir.ptr + 8) 61 62; CHECK: [[SP:%[0-9]+]]:_(p0) = COPY $sp 63; CHECK: [[OFF:%[0-9]+]]:_(s64) = G_CONSTANT i64 0 64; CHECK: [[ADDR:%[0-9]+]]:_(p0) = G_PTR_ADD [[SP]], [[OFF]](s64) 65; CHECK: G_STORE [[LD1]](s64), [[ADDR]](p0) :: (store 8 into stack, align 1) 66 67; CHECK: [[ADDR:%[0-9]+]]:_(p0) = G_PTR_ADD [[SP]], [[CST]] 68; CHECK: G_STORE [[LD2]](s64), [[ADDR]](p0) :: (store 8 into stack + 8, align 1) 69define void @test_split_struct([2 x i64]* %ptr) { 70 %struct = load [2 x i64], [2 x i64]* %ptr 71 call void @take_split_struct([2 x i64]* null, i64 1, i64 2, i64 3, 72 i64 4, i64 5, i64 6, 73 [2 x i64] %struct) 74 ret void 75} 76 77; CHECK-LABEL: name: take_split_struct 78; CHECK: fixedStack: 79; CHECK-DAG: - { id: [[LO_FRAME:[0-9]+]], type: default, offset: 0, size: 8 80; CHECK-DAG: - { id: [[HI_FRAME:[0-9]+]], type: default, offset: 8, size: 8 81 82; CHECK: [[LOPTR:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.[[LO_FRAME]] 83; CHECK: [[LO:%[0-9]+]]:_(s64) = G_LOAD [[LOPTR]](p0) :: (invariant load 8 from %fixed-stack.[[LO_FRAME]], align 16) 84 85; CHECK: [[HIPTR:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.[[HI_FRAME]] 86; CHECK: [[HI:%[0-9]+]]:_(s64) = G_LOAD [[HIPTR]](p0) :: (invariant load 8 from %fixed-stack.[[HI_FRAME]]) 87define void @take_split_struct([2 x i64]* %ptr, i64, i64, i64, 88 i64, i64, i64, 89 [2 x i64] %in) { 90 store [2 x i64] %in, [2 x i64]* %ptr 91 ret void 92} 93