Compiler projects using llvm
# RUN: llc -O0 -mtriple arm-linux -relocation-model=ropi -mattr=-no-movt,+v8m -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,RW-DEFAULT-MOVT,ROPI-MOVT
# RUN: llc -O0 -mtriple arm-linux -relocation-model=ropi -mattr=+no-movt -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,RW-DEFAULT-NOMOVT,ROPI-NOMOVT
# RUN: llc -O0 -mtriple arm-linux -relocation-model=rwpi -mattr=-no-movt,+v8m -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,RWPI-MOVT,RWPI,RO-DEFAULT-MOVT
# RUN: llc -O0 -mtriple arm-linux -relocation-model=rwpi -mattr=+no-movt -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,RWPI-NOMOVT,RWPI,RO-DEFAULT-NOMOVT
# RUN: llc -O0 -mtriple arm-linux -relocation-model=ropi-rwpi -mattr=-no-movt,+v8m -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,RWPI-MOVT,RWPI,ROPI-MOVT
# RUN: llc -O0 -mtriple arm-linux -relocation-model=ropi-rwpi -mattr=+no-movt -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=CHECK,RWPI-NOMOVT,RWPI,ROPI-NOMOVT
--- |
  @internal_global = internal global i32 42
  define void @test_internal_global() { ret void }

  @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
# CHECK-LABEL: name: test_internal_global
legalized:       true
regBankSelected: true
selected:        false
# CHECK: selected: true
registers:
  - { id: 0, class: gprb }
  - { id: 1, class: gprb }
# RW-DEFAULT-NOMOVT: constants:
# RW-DEFAULT-NOMOVT: id: 0
# RW-DEFAULT-NOMOVT: value: 'ptr @internal_global'
# RWPI-NOMOVT: constants:
# RWPI-NOMOVT: id: 0
# RWPI-NOMOVT: value: 'internal_global(SBREL)'
body:             |
  bb.0:
    %0(p0) = G_GLOBAL_VALUE @internal_global
    ; RW-DEFAULT-MOVT: [[G:%[0-9]+]]:gpr = MOVi32imm @internal_global
    ; RW-DEFAULT-NOMOVT: [[G:%[0-9]+]]:gpr = LDRi12 %const.0, 0, 14 /* CC::al */, $noreg :: (load (p0) from constant-pool)
    ; RWPI-MOVT: [[OFF:%[0-9]+]]:gpr = MOVi32imm target-flags(arm-sbrel) @internal_global
    ; RWPI-NOMOVT: [[OFF:%[0-9]+]]:gpr = LDRi12 %const.0, 0, 14 /* CC::al */, $noreg :: (load (p0) from constant-pool)
    ; RWPI: [[G:%[0-9]+]]:gpr = ADDrr $r9, [[OFF]], 14 /* CC::al */, $noreg, $noreg

    %1(s32) = G_LOAD %0(p0) :: (load (s32) from @internal_global)
    ; CHECK: [[V:%[0-9]+]]:gpr = LDRi12 [[G]], 0, 14 /* CC::al */, $noreg :: (load (s32) from @internal_global)

    $r0 = COPY %1(s32)
    ; CHECK: $r0 = COPY [[V]]

    BX_RET 14, $noreg, implicit $r0
    ; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $r0
...
---
name:            test_external_global
# CHECK-LABEL: name: test_external_global
legalized:       true
regBankSelected: true
selected:        false
# CHECK: selected: true
registers:
  - { id: 0, class: gprb }
  - { id: 1, class: gprb }
# RW-DEFAULT-NOMOVT: constants:
# RW-DEFAULT-NOMOVT: id: 0
# RW-DEFAULT-NOMOVT: value: 'ptr @external_global'
# RWPI-NOMOVT: constants:
# RWPI-NOMOVT: id: 0
# RWPI-NOMOVT: value: 'external_global(SBREL)'
body:             |
  bb.0:
    %0(p0) = G_GLOBAL_VALUE @external_global
    ; RW-DEFAULT-MOVT: [[G:%[0-9]+]]:gpr = MOVi32imm @external_global
    ; RW-DEFAULT-NOMOVT: [[G:%[0-9]+]]:gpr = LDRi12 %const.0, 0, 14 /* CC::al */, $noreg :: (load (p0) from constant-pool)
    ; RWPI-MOVT: [[OFF:%[0-9]+]]:gpr = MOVi32imm target-flags(arm-sbrel) @external_global
    ; RWPI-NOMOVT: [[OFF:%[0-9]+]]:gpr = LDRi12 %const.0, 0, 14 /* CC::al */, $noreg :: (load (p0) from constant-pool)
    ; RWPI: [[G:%[0-9]+]]:gpr = ADDrr $r9, [[OFF]], 14 /* CC::al */, $noreg, $noreg

    %1(s32) = G_LOAD %0(p0) :: (load (s32) from @external_global)
    ; CHECK: [[V:%[0-9]+]]:gpr = LDRi12 [[G]], 0, 14 /* CC::al */, $noreg :: (load (s32) from @external_global)

    $r0 = COPY %1(s32)
    ; CHECK: $r0 = COPY [[V]]

    BX_RET 14, $noreg, implicit $r0
    ; CHECK: BX_RET 14 /* CC::al */, $noreg, 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 }
# RO-DEFAULT-NOMOVT: constants:
# RO-DEFAULT-NOMOVT: id: 0
# RO-DEFAULT-NOMOVT: value: 'ptr @internal_constant'
body:             |
  bb.0:
    %0(p0) = G_GLOBAL_VALUE @internal_constant
    ; ROPI-MOVT: [[G:%[0-9]+]]:gpr = MOV_ga_pcrel @internal_constant
    ; ROPI-NOMOVT: [[G:%[0-9]+]]:gpr = LDRLIT_ga_pcrel @internal_constant
    ; RO-DEFAULT-MOVT: [[G:%[0-9]+]]:gpr = MOVi32imm @internal_constant
    ; RO-DEFAULT-NOMOVT: [[G:%[0-9]+]]:gpr = LDRi12 %const.0, 0, 14 /* CC::al */, $noreg :: (load (p0) from constant-pool)

    %1(s32) = G_LOAD %0(p0) :: (load (s32) from @internal_constant)
    ; CHECK: [[V:%[0-9]+]]:gpr = LDRi12 [[G]], 0, 14 /* CC::al */, $noreg :: (load (s32) from @internal_constant)

    $r0 = COPY %1(s32)
    ; CHECK: $r0 = COPY [[V]]

    BX_RET 14, $noreg, implicit $r0
    ; CHECK: BX_RET 14 /* CC::al */, $noreg, 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 }
# RO-DEFAULT-NOMOVT: constants:
# RO-DEFAULT-NOMOVT: id: 0
# RO-DEFAULT-NOMOVT: value: 'ptr @external_constant'
body:             |
  bb.0:
    %0(p0) = G_GLOBAL_VALUE @external_constant
    ; ROPI-MOVT: [[G:%[0-9]+]]:gpr = MOV_ga_pcrel @external_constant
    ; ROPI-NOMOVT: [[G:%[0-9]+]]:gpr = LDRLIT_ga_pcrel @external_constant
    ; RO-DEFAULT-MOVT: [[G:%[0-9]+]]:gpr = MOVi32imm @external_constant
    ; RO-DEFAULT-NOMOVT: [[G:%[0-9]+]]:gpr = LDRi12 %const.0, 0, 14 /* CC::al */, $noreg :: (load (p0) from constant-pool)

    %1(s32) = G_LOAD %0(p0) :: (load (s32) from @external_constant)
    ; CHECK: [[V:%[0-9]+]]:gpr = LDRi12 [[G]], 0, 14 /* CC::al */, $noreg :: (load (s32) from @external_constant)

    $r0 = COPY %1(s32)
    ; CHECK: $r0 = COPY [[V]]

    BX_RET 14, $noreg, implicit $r0
    ; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $r0
...