diff options
| author | Diana Picus <diana.picus@linaro.org> | 2017-09-01 11:13:39 +0000 |
|---|---|---|
| committer | Diana Picus <diana.picus@linaro.org> | 2017-09-01 11:13:39 +0000 |
| commit | f9597911896743f56eef86eee7bcf891d90cf85b (patch) | |
| tree | 04b14397e51492210e8a54b5199226fa58b00af9 /llvm/lib/Target/ARM | |
| parent | 65130e2d8daaaf8dd6646f7840f27fac6709d5cf (diff) | |
| download | bcm5719-llvm-f9597911896743f56eef86eee7bcf891d90cf85b.tar.gz bcm5719-llvm-f9597911896743f56eef86eee7bcf891d90cf85b.zip | |
[ARM] GlobalISel: Support ROPI global variables
In the ROPI relocation model, read-only variables are accessed relative
to the PC. We use the (MOV|LDRLIT)_ga_pcrel pseudoinstructions for this.
llvm-svn: 312323
Diffstat (limited to 'llvm/lib/Target/ARM')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMInstructionSelector.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp index e2f94666252..fb5a3714954 100644 --- a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp +++ b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp @@ -488,8 +488,13 @@ bool ARMInstructionSelector::insertComparison(CmpConstants Helper, InsertInfo I, bool ARMInstructionSelector::selectGlobal(MachineInstrBuilder &MIB, MachineRegisterInfo &MRI) const { - if (TII.getSubtarget().isROPI() || TII.getSubtarget().isRWPI()) { - DEBUG(dbgs() << "ROPI and RWPI not supported yet\n"); + if (TII.getSubtarget().isRWPI()) { + DEBUG(dbgs() << "RWPI not supported yet\n"); + return false; + } + + if (STI.isROPI() && !STI.isTargetELF()) { + DEBUG(dbgs() << "ROPI only supported for ELF\n"); return false; } @@ -527,6 +532,13 @@ bool ARMInstructionSelector::selectGlobal(MachineInstrBuilder &MIB, return true; } + bool isReadOnly = STI.getTargetLowering()->isReadOnly(GV); + if (STI.isROPI() && isReadOnly) { + unsigned Opc = UseMovt ? ARM::MOV_ga_pcrel : ARM::LDRLIT_ga_pcrel; + MIB->setDesc(TII.get(Opc)); + return constrainSelectedInstRegOperands(*MIB, TII, TRI, RBI); + } + if (ObjectFormat == Triple::ELF) { if (UseMovt) { MIB->setDesc(TII.get(ARM::MOVi32imm)); |

