xref: /aosp_15_r20/external/llvm/test/CodeGen/MSP430/byval.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16"
4*9880d681SAndroid Build Coastguard Workertarget triple = "msp430---elf"
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker%struct.Foo = type { i16, i16, i16 }
7*9880d681SAndroid Build Coastguard Worker@foo = global %struct.Foo { i16 1, i16 2, i16 3 }, align 2
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdefine i16 @callee(%struct.Foo* byval %f) nounwind {
10*9880d681SAndroid Build Coastguard Workerentry:
11*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: callee:
12*9880d681SAndroid Build Coastguard Worker; CHECK: mov.w 2(r1), r15
13*9880d681SAndroid Build Coastguard Worker  %0 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 0
14*9880d681SAndroid Build Coastguard Worker  %1 = load i16, i16* %0, align 2
15*9880d681SAndroid Build Coastguard Worker  ret i16 %1
16*9880d681SAndroid Build Coastguard Worker}
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Workerdefine void @caller() nounwind {
19*9880d681SAndroid Build Coastguard Workerentry:
20*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: caller:
21*9880d681SAndroid Build Coastguard Worker; CHECK: mov.w &foo+4, 4(r1)
22*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: mov.w &foo+2, 2(r1)
23*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: mov.w &foo, 0(r1)
24*9880d681SAndroid Build Coastguard Worker  %call = call i16 @callee(%struct.Foo* byval @foo)
25*9880d681SAndroid Build Coastguard Worker  ret void
26*9880d681SAndroid Build Coastguard Worker}
27