[llvm] r295104 - GlobalISel: deal with new G_PTR_MASK instruction on AArch64.
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 14 12:56:29 PST 2017
Author: tnorthover
Date: Tue Feb 14 14:56:29 2017
New Revision: 295104
URL: http://llvm.org/viewvc/llvm-project?rev=295104&view=rev
Log:
GlobalISel: deal with new G_PTR_MASK instruction on AArch64.
It's just an AND-immediate instruction for us, surprisingly simple to select.
Modified:
llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
llvm/trunk/lib/Target/AArch64/AArch64LegalizerInfo.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir
Modified: llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp?rev=295104&r1=295103&r2=295104&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp Tue Feb 14 14:56:29 2017
@@ -816,6 +816,17 @@ bool AArch64InstructionSelector::select(
return constrainSelectedInstRegOperands(I, TII, TRI, RBI);
}
+ case TargetOpcode::G_PTR_MASK: {
+ uint64_t Align = I.getOperand(2).getImm();
+ if (Align >= 64 || Align == 0)
+ return false;
+
+ uint64_t Mask = ~((1ULL << Align) - 1);
+ I.setDesc(TII.get(AArch64::ANDXri));
+ I.getOperand(2).setImm(AArch64_AM::encodeLogicalImmediate(Mask, 64));
+
+ return constrainSelectedInstRegOperands(I, TII, TRI, RBI);
+ }
case TargetOpcode::G_PTRTOINT:
case TargetOpcode::G_TRUNC: {
const LLT DstTy = MRI.getType(I.getOperand(0).getReg());
Modified: llvm/trunk/lib/Target/AArch64/AArch64LegalizerInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64LegalizerInfo.cpp?rev=295104&r1=295103&r2=295104&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64LegalizerInfo.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64LegalizerInfo.cpp Tue Feb 14 14:56:29 2017
@@ -52,6 +52,8 @@ AArch64LegalizerInfo::AArch64LegalizerIn
for (auto Ty : {s1, s8, s16, s32})
setAction({G_GEP, 1, Ty}, WidenScalar);
+ setAction({G_PTR_MASK, p0}, Legal);
+
for (unsigned BinOp : {G_LSHR, G_ASHR, G_SDIV, G_UDIV}) {
for (auto Ty : {s32, s64})
setAction({BinOp, Ty}, Legal);
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir?rev=295104&r1=295103&r2=295104&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir Tue Feb 14 14:56:29 2017
@@ -114,6 +114,8 @@
define i8* @gep(i8* %in) { ret i8* undef }
+ define i8* @ptr_mask(i8* %in) { ret i8* undef }
+
@var_local = global i8 0
define i8* @global_local() { ret i8* undef }
@@ -2044,6 +2046,21 @@ body: |
...
---
+# CHECK-LABEL: name: ptr_mask
+name: ptr_mask
+legalized: true
+regBankSelected: true
+
+# CHECK: body:
+# CHECK: %1 = ANDXri %0, 8060
+body: |
+ bb.0:
+ liveins: %x0
+ %0:gpr(p0) = COPY %x0
+ %1:gpr(p0) = G_PTR_MASK %0, 3
+...
+
+---
# Global defined in the same linkage unit so no GOT is needed
# CHECK-LABEL: name: global_local
name: global_local
More information about the llvm-commits
mailing list