1 ; RUN: llc -mtriple=aarch64-apple-ios -O0 -stop-after=irtranslator -global-isel -verify-machineinstrs %s -o - 2>&1 | FileCheck %s
4 ; CHECK-LABEL: name: test_stack_slots
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: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
9 ; CHECK: [[LOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[FRAME_INDEX]](p0) :: (invariant load (s8) from %fixed-stack.1, align 16)
10 ; CHECK: [[ASSERT_SEXT:%[0-9]+]]:_(s32) = G_ASSERT_SEXT [[LOAD]], 8
11 ; CHECK: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[ASSERT_SEXT]](s32)
12 ; CHECK: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
13 ; CHECK: [[LOAD1:%[0-9]+]]:_(s32) = G_SEXTLOAD [[FRAME_INDEX1]](p0) :: (invariant load (s8) from %fixed-stack.0)
14 ; CHECK: [[ASSERT_SEXT1:%[0-9]+]]:_(s32) = G_ASSERT_SEXT [[LOAD1]], 8
15 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[ASSERT_SEXT1]](s32)
16 ; CHECK: [[ADD:%[0-9]+]]:_(s8) = G_ADD [[TRUNC]], [[TRUNC1]]
17 ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[ADD]](s8)
18 ; CHECK: $w0 = COPY [[SEXT]](s32)
19 ; CHECK: RET_ReallyLR implicit $w0
20 define signext i8 @test_stack_slots([8 x i64], i8 signext %lhs, i8 signext %rhs) {
21 %sum = add i8 %lhs, %rhs
25 ; CHECK-LABEL: name: test_call_stack
26 ; CHECK: [[C42:%[0-9]+]]:_(s8) = G_CONSTANT i8 42
27 ; CHECK: [[C12:%[0-9]+]]:_(s8) = G_CONSTANT i8 12
28 ; CHECK: [[SP:%[0-9]+]]:_(p0) = COPY $sp
29 ; CHECK: [[C42_OFFS:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
30 ; CHECK: [[C42_LOC:%[0-9]+]]:_(p0) = G_PTR_ADD [[SP]], [[C42_OFFS]](s64)
31 ; CHECK: G_STORE [[C42]](s8), [[C42_LOC]](p0) :: (store (s8) into stack)
32 ; CHECK: [[C12_OFFS:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
33 ; CHECK: [[C12_LOC:%[0-9]+]]:_(p0) = G_PTR_ADD [[SP]], [[C12_OFFS]](s64)
34 ; CHECK: G_STORE [[C12]](s8), [[C12_LOC]](p0) :: (store (s8) into stack + 1)
35 ; CHECK: BL @test_stack_slots
36 define void @test_call_stack() {
37 call signext i8 @test_stack_slots([8 x i64] undef, i8 signext 42, i8 signext 12)
41 ; CHECK-LABEL: name: test_128bit_struct
45 ; CHECK: BL @take_128bit_struct
46 define void @test_128bit_struct(ptr %ptr) {
47 %struct = load [2 x i64], ptr %ptr
48 call void @take_128bit_struct(ptr null, [2 x i64] %struct)
52 ; CHECK-LABEL: name: take_128bit_struct
53 ; CHECK: {{%.*}}:_(p0) = COPY $x0
54 ; CHECK: {{%.*}}:_(s64) = COPY $x1
55 ; CHECK: {{%.*}}:_(s64) = COPY $x2
56 define void @take_128bit_struct(ptr %ptr, [2 x i64] %in) {
57 store [2 x i64] %in, ptr %ptr
61 ; CHECK-LABEL: name: test_split_struct
62 ; CHECK: [[LD1:%[0-9]+]]:_(s64) = G_LOAD %0(p0) :: (load (s64) from %ir.ptr)
63 ; CHECK: [[CST:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
64 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_PTR_ADD %0, [[CST]](s64)
65 ; CHECK: [[LD2:%[0-9]+]]:_(s64) = G_LOAD %3(p0) :: (load (s64) from %ir.ptr + 8)
67 ; CHECK: [[SP:%[0-9]+]]:_(p0) = COPY $sp
68 ; CHECK: [[OFF:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
69 ; CHECK: [[ADDR:%[0-9]+]]:_(p0) = G_PTR_ADD [[SP]], [[OFF]](s64)
70 ; CHECK: G_STORE [[LD1]](s64), [[ADDR]](p0) :: (store (s64) into stack, align 1)
72 ; CHECK: [[ADDR:%[0-9]+]]:_(p0) = G_PTR_ADD [[SP]], [[CST]]
73 ; CHECK: G_STORE [[LD2]](s64), [[ADDR]](p0) :: (store (s64) into stack + 8, align 1)
74 define void @test_split_struct(ptr %ptr) {
75 %struct = load [2 x i64], ptr %ptr
76 call void @take_split_struct(ptr null, i64 1, i64 2, i64 3,
82 ; CHECK-LABEL: name: take_split_struct
84 ; CHECK-DAG: - { id: [[LO_FRAME:[0-9]+]], type: default, offset: 0, size: 8
85 ; CHECK-DAG: - { id: [[HI_FRAME:[0-9]+]], type: default, offset: 8, size: 8
87 ; CHECK: [[LOPTR:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.[[LO_FRAME]]
88 ; CHECK: [[LO:%[0-9]+]]:_(s64) = G_LOAD [[LOPTR]](p0) :: (invariant load (s64) from %fixed-stack.[[LO_FRAME]], align 16)
90 ; CHECK: [[HIPTR:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.[[HI_FRAME]]
91 ; CHECK: [[HI:%[0-9]+]]:_(s64) = G_LOAD [[HIPTR]](p0) :: (invariant load (s64) from %fixed-stack.[[HI_FRAME]])
92 define void @take_split_struct(ptr %ptr, i64, i64, i64,
95 store [2 x i64] %in, ptr %ptr