diff options
| author | Diana Picus <diana.picus@linaro.org> | 2019-04-10 09:14:24 +0000 |
|---|---|---|
| committer | Diana Picus <diana.picus@linaro.org> | 2019-04-10 09:14:24 +0000 |
| commit | 3533ad6801e5f52b0ec6d554529a7caca8df2ba5 (patch) | |
| tree | ae9be0e67861daf35e3cecba2ba2b1949552eee3 /llvm/lib/Target | |
| parent | 165846b031c828a6a136de76ade7827a7833ff79 (diff) | |
| download | bcm5719-llvm-3533ad6801e5f52b0ec6d554529a7caca8df2ba5.tar.gz bcm5719-llvm-3533ad6801e5f52b0ec6d554529a7caca8df2ba5.zip | |
[ARM GlobalISel] Select G_FCONSTANT into pools
Put all floating point constants into constant pools and load their
values from there.
llvm-svn: 358062
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMInstructionSelector.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp index 6df74eca6ea..0f56504d06b 100644 --- a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp +++ b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp @@ -958,6 +958,27 @@ bool ARMInstructionSelector::select(MachineInstr &I, MIB.add(predOps(ARMCC::AL)).add(condCodeOp()); break; } + case G_FCONSTANT: { + // Load from constant pool + unsigned Size = MRI.getType(I.getOperand(0).getReg()).getSizeInBits() / 8; + unsigned Alignment = Size; + + assert((Size == 4 || Size == 8) && "Unsupported FP constant type"); + auto LoadOpcode = Size == 4 ? ARM::VLDRS : ARM::VLDRD; + + auto ConstPool = MF.getConstantPool(); + auto CPIndex = + ConstPool->getConstantPoolIndex(I.getOperand(1).getFPImm(), Alignment); + MIB->setDesc(TII.get(LoadOpcode)); + MIB->RemoveOperand(1); + MIB.addConstantPoolIndex(CPIndex, /*Offset*/ 0, /*TargetFlags*/ 0) + .addMemOperand( + MF.getMachineMemOperand(MachinePointerInfo::getConstantPool(MF), + MachineMemOperand::MOLoad, Size, Alignment)) + .addImm(0) + .add(predOps(ARMCC::AL)); + break; + } case G_INTTOPTR: case G_PTRTOINT: { auto SrcReg = I.getOperand(1).getReg(); |

