xref: /aosp_15_r20/external/llvm/test/CodeGen/Mips/inlineasmmemop.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mipsel -relocation-model=pic < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Simple memory
4*9880d681SAndroid Build Coastguard Worker@g1 = external global i32
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdefine i32 @f1(i32 %x) nounwind {
7*9880d681SAndroid Build Coastguard Workerentry:
8*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f1:
9*9880d681SAndroid Build Coastguard Worker; CHECK: #APP
10*9880d681SAndroid Build Coastguard Worker; CHECK: sw $4, [[OFFSET:[0-9]+]]($sp)
11*9880d681SAndroid Build Coastguard Worker; CHECK: #NO_APP
12*9880d681SAndroid Build Coastguard Worker; CHECK: lw  $[[T1:[0-9]+]], %got(g1)
13*9880d681SAndroid Build Coastguard Worker; CHECK: #APP
14*9880d681SAndroid Build Coastguard Worker; CHECK: lw $[[T3:[0-9]+]], [[OFFSET]]($sp)
15*9880d681SAndroid Build Coastguard Worker; CHECK: #NO_APP
16*9880d681SAndroid Build Coastguard Worker; CHECK: sw  $[[T3]], 0($[[T1]])
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker  %l1 = alloca i32, align 4
19*9880d681SAndroid Build Coastguard Worker  call void asm "sw $1, $0", "=*m,r"(i32* %l1, i32 %x) nounwind
20*9880d681SAndroid Build Coastguard Worker  %0 = call i32 asm "lw $0, $1", "=r,*m"(i32* %l1) nounwind
21*9880d681SAndroid Build Coastguard Worker  store i32 %0, i32* @g1, align 4
22*9880d681SAndroid Build Coastguard Worker  ret i32 %0
23*9880d681SAndroid Build Coastguard Worker}
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: main:
26*9880d681SAndroid Build Coastguard Worker; "D": Second word of a double word. This works for any memory element
27*9880d681SAndroid Build Coastguard Worker; double or single.
28*9880d681SAndroid Build Coastguard Worker; CHECK: #APP
29*9880d681SAndroid Build Coastguard Worker; CHECK: lw ${{[0-9]+}}, 16(${{[0-9]+}})
30*9880d681SAndroid Build Coastguard Worker; CHECK: #NO_APP
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker; No "D": First word of a double word. This works for any memory element
33*9880d681SAndroid Build Coastguard Worker; double or single.
34*9880d681SAndroid Build Coastguard Worker; CHECK: #APP
35*9880d681SAndroid Build Coastguard Worker; CHECK: lw ${{[0-9]+}}, 12(${{[0-9]+}})
36*9880d681SAndroid Build Coastguard Worker; CHECK: #NO_APP
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker@b = common global [20 x i32] zeroinitializer, align 4
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Workerdefine void @main() {
41*9880d681SAndroid Build Coastguard Workerentry:
42*9880d681SAndroid Build Coastguard Worker; Second word:
43*9880d681SAndroid Build Coastguard Worker  tail call void asm sideeffect "    lw    $0, ${1:D}", "r,*m,~{$11}"(i32 undef, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @b, i32 0, i32 3))
44*9880d681SAndroid Build Coastguard Worker; First word. Notice, no 'D':
45*9880d681SAndroid Build Coastguard Worker  tail call void asm sideeffect "    lw    $0, ${1}", "r,*m,~{$11}"(i32 undef, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @b, i32 0, i32 3))
46*9880d681SAndroid Build Coastguard Worker  ret void
47*9880d681SAndroid Build Coastguard Worker}
48