diff options
author | Diana Picus <diana.picus@linaro.org> | 2017-12-22 11:09:18 +0000 |
---|---|---|
committer | Diana Picus <diana.picus@linaro.org> | 2017-12-22 11:09:18 +0000 |
commit | 68773859c83eae33a6b02be8e647ed9ce2afcd7a (patch) | |
tree | 118b33925437f150c33c2a7f2d2b38ed8cc192dd /llvm/lib/Target/ARM/ARMInstructionSelector.cpp | |
parent | b8318155eb071ae2ad6ba94fd7865395e36c35b4 (diff) | |
download | bcm5719-llvm-68773859c83eae33a6b02be8e647ed9ce2afcd7a.tar.gz bcm5719-llvm-68773859c83eae33a6b02be8e647ed9ce2afcd7a.zip |
[ARM GlobalISel] Support pointer constants
Pointer constants are pretty rare, since we usually represent them as
integer constants and then cast to pointer. One notable exception is the
null pointer constant, which is represented directly as a G_CONSTANT 0
with pointer type. Mark it as legal and make sure it is selected like
any other integer constant.
llvm-svn: 321354
Diffstat (limited to 'llvm/lib/Target/ARM/ARMInstructionSelector.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/ARMInstructionSelector.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp index de2f79df49b..2e8e7a7d967 100644 --- a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp +++ b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp @@ -669,13 +669,22 @@ bool ARMInstructionSelector::select(MachineInstr &I, return true; } + using namespace TargetOpcode; + if (I.getOpcode() == G_CONSTANT) { + // Pointer constants should be treated the same as 32-bit integer constants. + // Change the type and let TableGen handle it. + unsigned ResultReg = I.getOperand(0).getReg(); + LLT Ty = MRI.getType(ResultReg); + if (Ty.isPointer()) + MRI.setType(ResultReg, LLT::scalar(32)); + } + if (selectImpl(I, CoverageInfo)) return true; MachineInstrBuilder MIB{MF, I}; bool isSExt = false; - using namespace TargetOpcode; switch (I.getOpcode()) { case G_SEXT: isSExt = true; |