1 # RUN: llc -O0 -mtriple thumb-linux -relocation-model=pic -mattr=+v6t2,+no-movt -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,ELF
2 # RUN: llc -O0 -mtriple thumb-linux-linux -relocation-model=pic -mattr=+v6t2,-no-movt -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,ELF
3 # RUN: llc -O0 -mtriple thumb-linux-darwin -relocation-model=pic -mattr=+v6t2,+no-movt -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,DARWIN-NOMOVT
4 # RUN: llc -O0 -mtriple thumb-linux-darwin -relocation-model=pic -mattr=+v6t2,-no-movt -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,DARWIN-MOVT
6 @internal_global = internal global i32 42
7 define void @test_internal_global() { ret void }
9 @external_global = external global i32
10 define void @test_external_global() { ret void }
12 @internal_constant = internal constant i32 42
13 define void @test_internal_constant() { ret void }
15 @external_constant = external constant i32
16 define void @test_external_constant() { ret void }
19 name: test_internal_global
20 # CHECK-LABEL: name: test_internal_global
24 # CHECK: selected: true
26 - { id: 0, class: gprb }
27 - { id: 1, class: gprb }
30 %0(p0) = G_GLOBAL_VALUE @internal_global
31 ; DARWIN-MOVT: [[G:%[0-9]+]]:rgpr = t2MOV_ga_pcrel target-flags(arm-nonlazy) @internal_global
32 ; DARWIN-NOMOVT: [[G:%[0-9]+]]:tgpr = tLDRLIT_ga_pcrel target-flags(arm-nonlazy) @internal_global
33 ; ELF: [[G:%[0-9]+]]:tgpr = tLDRLIT_ga_pcrel @internal_global
35 %1(s32) = G_LOAD %0(p0) :: (load 4 from @internal_global)
36 ; CHECK: [[V:%[0-9]+]]:gpr = t2LDRi12 [[G]], 0, 14, $noreg :: (load 4 from @internal_global)
39 ; CHECK: $r0 = COPY [[V]]
41 tBX_RET 14, $noreg, implicit $r0
42 ; CHECK: tBX_RET 14, $noreg, implicit $r0
45 name: test_external_global
46 # CHECK-LABEL: name: test_external_global
50 # CHECK: selected: true
52 - { id: 0, class: gprb }
53 - { id: 1, class: gprb }
56 %0(p0) = G_GLOBAL_VALUE @external_global
57 ; DARWIN-MOVT: [[G_GOT:%[0-9]+]]:rgpr = t2MOV_ga_pcrel target-flags(arm-nonlazy) @external_global
58 ; DARWIN-MOVT: [[G:%[0-9]+]]:gpr = t2LDRi12 [[G_GOT]], 0, 14, $noreg :: (load 4 from got)
59 ; DARWIN-NOMOVT: [[G_GOT:%[0-9]+]]:tgpr = tLDRLIT_ga_pcrel target-flags(arm-nonlazy) @external_global
60 ; DARWIN-NOMOVT: [[G:%[0-9]+]]:gpr = t2LDRi12 [[G_GOT]], 0, 14, $noreg :: (load 4 from got)
61 ; ELF: [[G_GOT:%[0-9]+]]:tgpr = tLDRLIT_ga_pcrel target-flags(arm-got) @external_global
62 ; ELF: [[G:%[0-9]+]]:gpr = t2LDRi12 [[G_GOT]], 0, 14, $noreg :: (load 4 from got)
64 %1(s32) = G_LOAD %0(p0) :: (load 4 from @external_global)
65 ; CHECK: [[V:%[0-9]+]]:gpr = t2LDRi12 [[G]], 0, 14, $noreg :: (load 4 from @external_global)
68 ; CHECK: $r0 = COPY [[V]]
70 tBX_RET 14, $noreg, implicit $r0
71 ; CHECK: tBX_RET 14, $noreg, implicit $r0
74 name: test_internal_constant
75 # CHECK-LABEL: name: test_internal_constant
79 # CHECK: selected: true
81 - { id: 0, class: gprb }
82 - { id: 1, class: gprb }
85 %0(p0) = G_GLOBAL_VALUE @internal_constant
86 ; DARWIN-MOVT: [[G:%[0-9]+]]:rgpr = t2MOV_ga_pcrel target-flags(arm-nonlazy) @internal_constant
87 ; DARWIN-NOMOVT: [[G:%[0-9]+]]:tgpr = tLDRLIT_ga_pcrel target-flags(arm-nonlazy) @internal_constant
88 ; ELF: [[G:%[0-9]+]]:tgpr = tLDRLIT_ga_pcrel @internal_constant
90 %1(s32) = G_LOAD %0(p0) :: (load 4 from @internal_constant)
91 ; CHECK: [[V:%[0-9]+]]:gpr = t2LDRi12 [[G]], 0, 14, $noreg :: (load 4 from @internal_constant)
94 ; CHECK: $r0 = COPY [[V]]
96 tBX_RET 14, $noreg, implicit $r0
97 ; CHECK: tBX_RET 14, $noreg, implicit $r0
100 name: test_external_constant
101 # CHECK-LABEL: name: test_external_constant
103 regBankSelected: true
105 # CHECK: selected: true
107 - { id: 0, class: gprb }
108 - { id: 1, class: gprb }
111 %0(p0) = G_GLOBAL_VALUE @external_constant
112 ; DARWIN-MOVT: [[G_GOT:%[0-9]+]]:rgpr = t2MOV_ga_pcrel target-flags(arm-nonlazy) @external_constant
113 ; DARWIN-MOVT: [[G:%[0-9]+]]:gpr = t2LDRi12 [[G_GOT]], 0, 14, $noreg :: (load 4 from got)
114 ; DARWIN-NOMOVT: [[G_GOT:%[0-9]+]]:tgpr = tLDRLIT_ga_pcrel target-flags(arm-nonlazy) @external_constant
115 ; DARWIN-NOMOVT: [[G:%[0-9]+]]:gpr = t2LDRi12 [[G_GOT]], 0, 14, $noreg :: (load 4 from got)
116 ; ELF: [[G_GOT:%[0-9]+]]:tgpr = tLDRLIT_ga_pcrel target-flags(arm-got) @external_constant
117 ; ELF: [[G:%[0-9]+]]:gpr = t2LDRi12 [[G_GOT]], 0, 14, $noreg :: (load 4 from got)
119 %1(s32) = G_LOAD %0(p0) :: (load 4 from @external_constant)
120 ; CHECK: [[V:%[0-9]+]]:gpr = t2LDRi12 [[G]], 0, 14, $noreg :: (load 4 from @external_constant)
123 ; CHECK: $r0 = COPY [[V]]
125 tBX_RET 14, $noreg, implicit $r0
126 ; CHECK: tBX_RET 14, $noreg, implicit $r0