xref: /llvm-project/llvm/test/CodeGen/LoongArch/mir-target-flags.ll (revision 0288d065eecb1208971dc4cdcc71731e34c6fca0)
1; RUN: llc --mtriple=loongarch64 -mattr=+d,-relax --stop-after loongarch-prera-expand-pseudo \
2; RUN:     --relocation-model=pic --code-model=small %s -o %t.mir
3; RUN: llc --mtriple=loongarch64 -mattr=+d,-relax --run-pass loongarch-prera-expand-pseudo \
4; RUN:     %t.mir -o - | FileCheck %s
5; RUN: llc --mtriple=loongarch64 -mattr=+d,-relax --stop-after loongarch-prera-expand-pseudo \
6; RUN:     --relocation-model=pic --enable-tlsdesc --code-model=small %s -o %t.desc.mir
7; RUN: llc --mtriple=loongarch64 -mattr=+d,-relax --run-pass loongarch-prera-expand-pseudo \
8; RUN:     %t.desc.mir -o - | FileCheck %s --check-prefix=DESC
9
10; RUN: llc --mtriple=loongarch64 -mattr=+d,-relax --stop-after loongarch-prera-expand-pseudo \
11; RUN:     --relocation-model=pic --code-model=medium %s -o %t.med.mir
12; RUN: llc --mtriple=loongarch64 -mattr=+d,-relax --run-pass loongarch-prera-expand-pseudo \
13; RUN:     --code-model=medium %t.med.mir -o - | FileCheck %s
14; RUN: llc --mtriple=loongarch64 -mattr=+d,-relax --run-pass loongarch-expand-pseudo \
15; RUN:     --code-model=medium %t.med.mir -o - | FileCheck %s --check-prefixes=CALL36
16
17;; This tests the LoongArch-specific serialization and deserialization of
18;; `target-flags(...)`
19
20@g_e = external global i32
21@g_i = internal global i32 0
22@t_un = external thread_local global i32
23@t_ld = external thread_local(localdynamic) global i32
24@t_ie = external thread_local(initialexec) global i32
25@t_le = external thread_local(localexec) global i32
26
27declare void @callee1() nounwind
28declare dso_local void @callee2() nounwind
29declare dso_local void @callee3() nounwind
30
31define void @caller() nounwind {
32; CHECK-LABEL: name: caller
33; CHECK:      target-flags(loongarch-got-pc-hi) @g_e
34; CHECK-NEXT: target-flags(loongarch-got-pc-lo) @g_e
35; CHECK:      target-flags(loongarch-pcrel-hi) @g_i
36; CHECK-NEXT: target-flags(loongarch-pcrel-lo) @g_i
37; CHECK:      target-flags(loongarch-gd-pc-hi) @t_un
38; CHECK-NEXT: target-flags(loongarch-got-pc-lo) @t_un
39; DESC:       target-flags(loongarch-desc-pc-hi) @t_un
40; DESC-NEXT:  target-flags(loongarch-desc-pc-lo) @t_un
41; DESC-NEXT:  target-flags(loongarch-desc-ld) @t_un
42; DESC-NEXT:  target-flags(loongarch-desc-call) @t_un
43; CHECK:      target-flags(loongarch-ld-pc-hi) @t_ld
44; CHECK-NEXT: target-flags(loongarch-got-pc-lo) @t_ld
45; DESC:       target-flags(loongarch-desc-pc-hi) @t_ld
46; DESC-NEXT:  target-flags(loongarch-desc-pc-lo) @t_ld
47; DESC-NEXT:  target-flags(loongarch-desc-ld) @t_ld
48; DESC-NEXT:  target-flags(loongarch-desc-call) @t_ld
49; CHECK:      target-flags(loongarch-ie-pc-hi) @t_ie
50; CHECK-NEXT: target-flags(loongarch-ie-pc-lo) @t_ie
51; CHECK:      target-flags(loongarch-le-hi-r) @t_le
52; CHECK-NEXT: target-flags(loongarch-le-add-r) @t_le
53; CHECK-NEXT: target-flags(loongarch-le-lo-r) @t_le
54; CHECK:      target-flags(loongarch-call-plt) @callee1
55; CALL36:     target-flags(loongarch-call36) @callee1
56; CHECK:      target-flags(loongarch-call) @callee2
57; CALL36:     target-flags(loongarch-call36) @callee2
58; CHECK:      target-flags(loongarch-call) @callee3
59; CALL36:     target-flags(loongarch-call36) @callee3
60  %a = load volatile i32, ptr @g_e
61  %b = load volatile i32, ptr @g_i
62  %c = load volatile i32, ptr @t_un
63  %d = load volatile i32, ptr @t_ld
64  %e = load volatile i32, ptr @t_ie
65  %f = load volatile i32, ptr @t_le
66  call i32 @callee1()
67  call i32 @callee2()
68  tail call i32 @callee3()
69  ret void
70}
71