1; RUN: llc -march=mips -mattr=-long-calls %s -o - \
2; RUN:   | FileCheck -check-prefix=OFF %s
3; RUN: llc -march=mips -mattr=+long-calls,+noabicalls %s -o - \
4; RUN:   | FileCheck -check-prefix=ON32 %s
5
6; RUN: llc -march=mips -mattr=+long-calls,-noabicalls %s -o - \
7; RUN:   | FileCheck -check-prefix=OFF %s
8
9; RUN: llc -march=mips64 -target-abi n32 -mattr=-long-calls %s -o - \
10; RUN:   | FileCheck -check-prefix=OFF %s
11; RUN: llc -march=mips64 -target-abi n32 -mattr=+long-calls,+noabicalls %s -o - \
12; RUN:   | FileCheck -check-prefix=ON32 %s
13
14; RUN: llc -march=mips64 -target-abi n64 -mattr=-long-calls %s -o - \
15; RUN:   | FileCheck -check-prefix=OFF %s
16; RUN: llc -march=mips64 -target-abi n64 -mattr=+long-calls,+noabicalls %s -o - \
17; RUN:   | FileCheck -check-prefix=ON64 %s
18
19declare void @callee()
20declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1)
21
22@val = internal unnamed_addr global [20 x i32] zeroinitializer, align 4
23
24define void @caller() {
25
26; Use `jal` instruction with R_MIPS_26 relocation.
27; OFF: jal callee
28; OFF: jal memset
29
30; Save the `callee` and `memset` addresses in $25 register
31; and use `jalr` for the jumps.
32; ON32: lui    $1, %hi(callee)
33; ON32: addiu  $25, $1, %lo(callee)
34; ON32: jalr   $25
35
36; ON32: lui    $1, %hi(memset)
37; ON32: addiu  $25, $1, %lo(memset)
38; ON32: jalr   $25
39
40; ON64: lui     $1, %highest(callee)
41; ON64: daddiu  $1, $1, %higher(callee)
42; ON64: daddiu  $1, $1, %hi(callee)
43; ON64: daddiu  $25, $1, %lo(callee)
44; ON64: jalr    $25
45
46; ON64: lui     $2, %highest(memset)
47; ON64: daddiu  $1, $2, %higher(memset)
48; ON64: dsll    $1, $1, 16
49; ON64: daddiu  $1, $1, %hi(memset)
50; ON64: dsll    $1, $1, 16
51; ON64: daddiu  $25, $1, %lo(memset)
52; ON64: jalr    $25
53
54  call void @callee()
55  call void @llvm.memset.p0i8.i32(i8* align 4 bitcast ([20 x i32]* @val to i8*), i8 0, i32 80, i1 false)
56  ret  void
57}
58