It's just an AND-immediate instruction for us, surprisingly simple to select.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295104
91177308-0d34-0410-b5e6-
96231b3b80d8
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());
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);
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 }
%2(p0) = G_GEP %0, %1(s64)
...
+---
+# 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