Skip to content

Commit d6ba8ec

Browse files
committed
[ARM] Add handling of t2LDRSB/t2LDRSH in Constant Island Pass
These constant pool loads should be treated similarly to t2LDRB/t2LDRH, acting on the same offset ranges. Add handling and a simple test.
1 parent 37eca08 commit d6ba8ec

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

llvm/lib/Target/ARM/ARMConstantIslandPass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,9 @@ initializeFunctionInfo(const std::vector<MachineInstr*> &CPEMIs) {
850850
case ARM::LDRcp:
851851
case ARM::t2LDRpci:
852852
case ARM::t2LDRHpci:
853+
case ARM::t2LDRSHpci:
853854
case ARM::t2LDRBpci:
855+
case ARM::t2LDRSBpci:
854856
Bits = 12; // +-offset_12
855857
NegOk = true;
856858
break;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2+
# RUN: llc -mtriple=thumbv8.1m.main-none-eabi -run-pass=arm-cp-islands -o - %s | FileCheck %s
3+
4+
# CHECK-NOT: Unknown addressing mode for CP reference
5+
6+
--- |
7+
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
8+
target triple = "thumbv8.1m.main-arm-none-eabi"
9+
10+
define void @t2LDRSBpci() { ret void }
11+
define void @t2LDRSHpci() { ret void }
12+
13+
...
14+
---
15+
name: t2LDRSBpci
16+
alignment: 4
17+
tracksRegLiveness: true
18+
constants:
19+
- id: 0
20+
value: 'i32 0'
21+
alignment: 4
22+
body: |
23+
bb.0:
24+
$sp = frame-setup tSUBspi $sp, 3, 14 /* CC::al */, $noreg
25+
frame-setup CFI_INSTRUCTION def_cfa_offset 12
26+
renamable $r0 = t2LDRSBpci %const.0, 14 /* CC::al */, $noreg :: (dereferenceable load 1, align 4)
27+
renamable $r1 = tMOVr $sp, 14 /* CC::al */, $noreg
28+
tCMPr killed renamable $r1, killed renamable $r0, 14 /* CC::al */, $noreg, implicit-def $cpsr
29+
$r1 = t2MOVi16 target-flags(arm-lo16) @t2LDRSBpci, 14 /* CC::al */, $noreg
30+
renamable $r0 = t2CSINC $zr, $zr, 3, implicit killed $cpsr
31+
$r1 = t2MOVTi16 killed $r1, target-flags(arm-hi16) @t2LDRSBpci, 14 /* CC::al */, $noreg
32+
tSTRi killed renamable $r0, killed renamable $r1, 0, 14 /* CC::al */, $noreg :: (store 4)
33+
$sp = frame-destroy tADDspi $sp, 3, 14 /* CC::al */, $noreg
34+
tBX_RET 14 /* CC::al */, $noreg
35+
36+
...
37+
---
38+
name: t2LDRSHpci
39+
alignment: 4
40+
tracksRegLiveness: true
41+
constants:
42+
- id: 0
43+
value: 'i32 0'
44+
alignment: 4
45+
body: |
46+
bb.0:
47+
$sp = frame-setup tSUBspi $sp, 3, 14 /* CC::al */, $noreg
48+
frame-setup CFI_INSTRUCTION def_cfa_offset 12
49+
renamable $r0 = t2LDRSHpci %const.0, 14 /* CC::al */, $noreg :: (dereferenceable load 1, align 4)
50+
renamable $r1 = tMOVr $sp, 14 /* CC::al */, $noreg
51+
tCMPr killed renamable $r1, killed renamable $r0, 14 /* CC::al */, $noreg, implicit-def $cpsr
52+
$r1 = t2MOVi16 target-flags(arm-lo16) @t2LDRSHpci, 14 /* CC::al */, $noreg
53+
renamable $r0 = t2CSINC $zr, $zr, 3, implicit killed $cpsr
54+
$r1 = t2MOVTi16 killed $r1, target-flags(arm-hi16) @t2LDRSHpci, 14 /* CC::al */, $noreg
55+
tSTRi killed renamable $r0, killed renamable $r1, 0, 14 /* CC::al */, $noreg :: (store 4)
56+
$sp = frame-destroy tADDspi $sp, 3, 14 /* CC::al */, $noreg
57+
tBX_RET 14 /* CC::al */, $noreg
58+
59+
...

0 commit comments

Comments
 (0)