ret i32 %v
}
+@internal_constant = internal constant i32 42
+define i32 @test_internal_constant() {
+; CHECK-LABEL: test_internal_constant:
+; ELF: ldr [[OFFSET:r[0-9]+]], [[LABEL:.L[[:alnum:]_]+]]
+; ELF: [[ANCHOR:.L[[:alnum:]_]+]]:
+; DARWIN-NOMOVT: ldr [[OFFSET:r[0-9]+]], [[LABEL:L[[:alnum:]_]+]]
+; DARWIN-MOVT: movw [[OFFSET:r[0-9]+]], :lower16:(_internal_constant-([[ANCHOR:L[[:alnum:]_]+]]+8))
+; DARWIN-MOVT-NEXT: movt [[OFFSET]], :upper16:(_internal_constant-([[ANCHOR]]+8))
+; DARWIN: [[ANCHOR:L[[:alnum:]_]+]]:
+; CHECK-NEXT: add r[[ADDR:[0-9]+]], pc, [[OFFSET]]
+; CHECK-NEXT: ldr r0, [r[[ADDR]]]
+; CHECK-NEXT: bx lr
+; ELF: [[LABEL]]:
+; ELF-NEXT: .long internal_constant-([[ANCHOR]]+8)
+; DARWIN-NOMOVT: [[LABEL]]:
+; DARWIN-NOMOVT-NEXT: .long _internal_constant-([[ANCHOR]]+8)
+; DARWIN-MOVT-NOT: .long _internal_constant
+
+entry:
+ %v = load i32, i32* @internal_constant
+ ret i32 %v
+}
+
+@external_constant = external constant i32
+define i32 @test_external_constant() {
+; CHECK-LABEL: test_external_constant:
+; ELF: ldr [[OFFSET:r[0-9]+]], [[LABEL:.L[[:alnum:]_]+]]
+; ELF: [[ANCHOR:.L[[:alnum:]_]+]]:
+; ELF-NEXT: ldr r[[ADDR:[0-9]+]], [pc, [[OFFSET]]]
+; DARWIN-NOMOVT: ldr [[OFFSET:r[0-9]+]], [[LABEL:L[[:alnum:]_]+]]
+; DARWIN-MOVT: movw [[OFFSET:r[0-9]+]], :lower16:(L_external_constant$non_lazy_ptr-([[ANCHOR:L[[:alnum:]_]+]]+8))
+; DARWIN-MOVT: movt [[OFFSET]], :upper16:(L_external_constant$non_lazy_ptr-([[ANCHOR]]+8))
+; DARWIN: [[ANCHOR:L[[:alnum:]_]+]]:
+; DARWIN: ldr r[[ADDR:[0-9]+]], [pc, [[OFFSET]]]
+; CHECK-NEXT: ldr r0, [r[[ADDR]]]
+; CHECK-NEXT: bx lr
+; ELF: [[LABEL]]:
+; ELF: [[TMPLABEL:.L[[:alnum:]_]+]]:
+; ELF: .long external_constant(GOT_PREL)-(([[ANCHOR]]+8)-[[TMPLABEL]])
+; DARWIN-NOMOVT: [[LABEL]]:
+; DARWIN-NOMOVT: .long L_external_constant$non_lazy_ptr-([[ANCHOR]]+8)
+; DARWIN-NOMOVT-NOT: .long L_external_constant
+entry:
+ %v = load i32, i32* @external_constant
+ ret i32 %v
+}
+
; ELF: internal_global:
; DARWIN: _internal_global:
; CHECK: .long 42
; ELF: .size internal_global, 4
-; DARWIN: L_external_global$non_lazy_ptr:
-; DARWIN: .indirect_symbol _external_global
+
+; ELF: internal_constant:
+; DARWIN: _internal_constant:
+; CHECK: .long 42
+; ELF: .size internal_constant, 4
+
+; DARWIN-DAG: L_external_global$non_lazy_ptr:
+; DARWIN-DAG: .indirect_symbol _external_global
+
+; DARWIN-DAG: L_external_constant$non_lazy_ptr:
+; DARWIN-DAG: .indirect_symbol _external_constant
@external_global = external global i32
define void @test_external_global() { ret void }
+
+ @internal_constant = internal constant i32 42
+ define void @test_internal_constant() { ret void }
+
+ @external_constant = external constant i32
+ define void @test_external_constant() { ret void }
...
---
name: test_internal_global
BX_RET 14, _, implicit %r0
; CHECK: BX_RET 14, _, implicit %r0
...
+---
+name: test_internal_constant
+# CHECK-LABEL: name: test_internal_constant
+legalized: true
+regBankSelected: true
+selected: false
+# CHECK: selected: true
+registers:
+ - { id: 0, class: gprb }
+ - { id: 1, class: gprb }
+body: |
+ bb.0:
+ %0(p0) = G_GLOBAL_VALUE @internal_constant
+ ; DARWIN-MOVT: [[G:%[0-9]+]] = MOV_ga_pcrel {{.*}}@internal_constant
+ ; DARWIN-NOMOVT: [[G:%[0-9]+]] = LDRLIT_ga_pcrel {{.*}}@internal_constant
+ ; ELF: [[G:%[0-9]+]] = LDRLIT_ga_pcrel {{.*}}@internal_constant
+
+ %1(s32) = G_LOAD %0(p0) :: (load 4 from @internal_constant)
+ ; CHECK: [[V:%[0-9]+]] = LDRi12 [[G]], 0, 14, _ :: (load 4 from @internal_constant)
+
+ %r0 = COPY %1(s32)
+ ; CHECK: %r0 = COPY [[V]]
+
+ BX_RET 14, _, implicit %r0
+ ; CHECK: BX_RET 14, _, implicit %r0
+...
+---
+name: test_external_constant
+# CHECK-LABEL: name: test_external_constant
+legalized: true
+regBankSelected: true
+selected: false
+# CHECK: selected: true
+registers:
+ - { id: 0, class: gprb }
+ - { id: 1, class: gprb }
+body: |
+ bb.0:
+ %0(p0) = G_GLOBAL_VALUE @external_constant
+ ; DARWIN-MOVT: [[G:%[0-9]+]] = MOV_ga_pcrel_ldr {{.*}} @external_constant :: (load 4 from got)
+ ; DARWIN-NOMOVT: [[G:%[0-9]+]] = LDRLIT_ga_pcrel_ldr {{.*}}@external_constant :: (load 4 from got)
+ ; ELF: [[G:%[0-9]+]] = LDRLIT_ga_pcrel_ldr @external_constant :: (load 4 from got)
+
+ %1(s32) = G_LOAD %0(p0) :: (load 4 from @external_constant)
+ ; CHECK: [[V:%[0-9]+]] = LDRi12 [[G]], 0, 14, _ :: (load 4 from @external_constant)
+
+ %r0 = COPY %1(s32)
+ ; CHECK: %r0 = COPY [[V]]
+
+ BX_RET 14, _, implicit %r0
+ ; CHECK: BX_RET 14, _, implicit %r0
+...