1 # RUN: llc -O0 -mtriple arm-linux -relocation-model=pic -mattr=+no-movt -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,ELF
2 # RUN: llc -O0 -mtriple arm-linux -relocation-model=pic -mattr=-no-movt,+v8m -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,ELF
3 # RUN: llc -O0 -mtriple arm-darwin -relocation-model=pic -mattr=+no-movt -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,DARWIN-NOMOVT
4 # RUN: llc -O0 -mtriple arm-darwin -relocation-model=pic -mattr=-no-movt,+v8m -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]+]]:gpr = MOV_ga_pcrel target-flags(arm-nonlazy) @internal_global
32 ; DARWIN-NOMOVT: [[G:%[0-9]+]]:gpr = LDRLIT_ga_pcrel target-flags(arm-nonlazy) @internal_global
33 ; ELF: [[G:%[0-9]+]]:gpr = LDRLIT_ga_pcrel @internal_global
35 %1(s32) = G_LOAD %0(p0) :: (load (s32) from @internal_global)
36 ; CHECK: [[V:%[0-9]+]]:gpr = LDRi12 [[G]], 0, 14 /* CC::al */, $noreg :: (load (s32) from @internal_global)
39 ; CHECK: $r0 = COPY [[V]]
41 BX_RET 14, $noreg, implicit $r0
42 ; CHECK: BX_RET 14 /* CC::al */, $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:%[0-9]+]]:gpr = MOV_ga_pcrel_ldr target-flags(arm-nonlazy) @external_global :: (load (s32) from got)
58 ; DARWIN-NOMOVT: [[G:%[0-9]+]]:gpr = LDRLIT_ga_pcrel_ldr target-flags(arm-nonlazy) @external_global :: (load (s32) from got)
59 ; ELF: [[G:%[0-9]+]]:gpr = LDRLIT_ga_pcrel_ldr target-flags(arm-got) @external_global :: (load (s32) from got)
61 %1(s32) = G_LOAD %0(p0) :: (load (s32) from @external_global)
62 ; CHECK: [[V:%[0-9]+]]:gpr = LDRi12 [[G]], 0, 14 /* CC::al */, $noreg :: (load (s32) from @external_global)
65 ; CHECK: $r0 = COPY [[V]]
67 BX_RET 14, $noreg, implicit $r0
68 ; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $r0
71 name: test_internal_constant
72 # CHECK-LABEL: name: test_internal_constant
76 # CHECK: selected: true
78 - { id: 0, class: gprb }
79 - { id: 1, class: gprb }
82 %0(p0) = G_GLOBAL_VALUE @internal_constant
83 ; DARWIN-MOVT: [[G:%[0-9]+]]:gpr = MOV_ga_pcrel target-flags(arm-nonlazy) @internal_constant
84 ; DARWIN-NOMOVT: [[G:%[0-9]+]]:gpr = LDRLIT_ga_pcrel target-flags(arm-nonlazy) @internal_constant
85 ; ELF: [[G:%[0-9]+]]:gpr = LDRLIT_ga_pcrel @internal_constant
87 %1(s32) = G_LOAD %0(p0) :: (load (s32) from @internal_constant)
88 ; CHECK: [[V:%[0-9]+]]:gpr = LDRi12 [[G]], 0, 14 /* CC::al */, $noreg :: (load (s32) from @internal_constant)
91 ; CHECK: $r0 = COPY [[V]]
93 BX_RET 14, $noreg, implicit $r0
94 ; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $r0
97 name: test_external_constant
98 # CHECK-LABEL: name: test_external_constant
100 regBankSelected: true
102 # CHECK: selected: true
104 - { id: 0, class: gprb }
105 - { id: 1, class: gprb }
108 %0(p0) = G_GLOBAL_VALUE @external_constant
109 ; DARWIN-MOVT: [[G:%[0-9]+]]:gpr = MOV_ga_pcrel_ldr target-flags(arm-nonlazy) @external_constant :: (load (s32) from got)
110 ; DARWIN-NOMOVT: [[G:%[0-9]+]]:gpr = LDRLIT_ga_pcrel_ldr target-flags(arm-nonlazy) @external_constant :: (load (s32) from got)
111 ; ELF: [[G:%[0-9]+]]:gpr = LDRLIT_ga_pcrel_ldr target-flags(arm-got) @external_constant :: (load (s32) from got)
113 %1(s32) = G_LOAD %0(p0) :: (load (s32) from @external_constant)
114 ; CHECK: [[V:%[0-9]+]]:gpr = LDRi12 [[G]], 0, 14 /* CC::al */, $noreg :: (load (s32) from @external_constant)
117 ; CHECK: $r0 = COPY [[V]]
119 BX_RET 14, $noreg, implicit $r0
120 ; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $r0