diff options
author | Jay Foad <jay.foad@amd.com> | 2024-02-13 08:21:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-13 08:21:35 +0000 |
commit | d57515bd107bc76df5a042ffee2b7dc6125ffef1 (patch) | |
tree | 9f88dc9d5b6a4b7bf2dea5d9a75e2cd1c0e3e762 /llvm/lib | |
parent | 346e7c7f6881afaade5a71ad97475d70639dadcf (diff) | |
download | llvm-d57515bd107bc76df5a042ffee2b7dc6125ffef1.zip llvm-d57515bd107bc76df5a042ffee2b7dc6125ffef1.tar.gz llvm-d57515bd107bc76df5a042ffee2b7dc6125ffef1.tar.bz2 |
[LLT] Add and use isPointerVector and isPointerOrPointerVector. NFC. (#81283)
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineVerifier.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | 5 |
6 files changed, 16 insertions, 23 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp index 464ff08..e39fdae 100644 --- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp +++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp @@ -1716,8 +1716,7 @@ Register LegalizerHelper::coerceToScalar(Register Val) { Register NewVal = Val; assert(Ty.isVector()); - LLT EltTy = Ty.getElementType(); - if (EltTy.isPointer()) + if (Ty.isPointerVector()) NewVal = MIRBuilder.buildPtrToInt(NewTy, NewVal).getReg(0); return MIRBuilder.buildBitcast(NewTy, NewVal).getReg(0); } @@ -7964,7 +7963,7 @@ LegalizerHelper::LegalizeResult LegalizerHelper::lowerSelect(MachineInstr &MI) { auto [DstReg, DstTy, MaskReg, MaskTy, Op1Reg, Op1Ty, Op2Reg, Op2Ty] = MI.getFirst4RegLLTs(); - bool IsEltPtr = DstTy.getScalarType().isPointer(); + bool IsEltPtr = DstTy.isPointerOrPointerVector(); if (IsEltPtr) { LLT ScalarPtrTy = LLT::scalar(DstTy.getScalarSizeInBits()); LLT NewTy = DstTy.changeElementType(ScalarPtrTy); diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp index a5827c2..d58b628 100644 --- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp +++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp @@ -199,7 +199,7 @@ void MachineIRBuilder::validateShiftOp(const LLT Res, const LLT Op0, MachineInstrBuilder MachineIRBuilder::buildPtrAdd(const DstOp &Res, const SrcOp &Op0, const SrcOp &Op1, std::optional<unsigned> Flags) { - assert(Res.getLLTTy(*getMRI()).getScalarType().isPointer() && + assert(Res.getLLTTy(*getMRI()).isPointerOrPointerVector() && Res.getLLTTy(*getMRI()) == Op0.getLLTTy(*getMRI()) && "type mismatch"); assert(Op1.getLLTTy(*getMRI()).getScalarType().isScalar() && "invalid offset type"); diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index c65e917..2632b5b 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -1288,10 +1288,10 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { if (!DstTy.isValid() || !PtrTy.isValid() || !OffsetTy.isValid()) break; - if (!PtrTy.getScalarType().isPointer()) + if (!PtrTy.isPointerOrPointerVector()) report("gep first operand must be a pointer", MI); - if (OffsetTy.getScalarType().isPointer()) + if (OffsetTy.isPointerOrPointerVector()) report("gep offset operand must not be a pointer", MI); // TODO: Is the offset allowed to be a scalar with a vector? @@ -1304,7 +1304,7 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { if (!DstTy.isValid() || !SrcTy.isValid() || !MaskTy.isValid()) break; - if (!DstTy.getScalarType().isPointer()) + if (!DstTy.isPointerOrPointerVector()) report("ptrmask result type must be a pointer", MI); if (!MaskTy.getScalarType().isScalar()) @@ -1330,15 +1330,13 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { if (!DstTy.isValid() || !SrcTy.isValid()) break; - LLT DstElTy = DstTy.getScalarType(); - LLT SrcElTy = SrcTy.getScalarType(); - if (DstElTy.isPointer() || SrcElTy.isPointer()) + if (DstTy.isPointerOrPointerVector() || SrcTy.isPointerOrPointerVector()) report("Generic extend/truncate can not operate on pointers", MI); verifyVectorElementMatch(DstTy, SrcTy, MI); - unsigned DstSize = DstElTy.getSizeInBits(); - unsigned SrcSize = SrcElTy.getSizeInBits(); + unsigned DstSize = DstTy.getScalarSizeInBits(); + unsigned SrcSize = SrcTy.getScalarSizeInBits(); switch (MI->getOpcode()) { default: if (DstSize <= SrcSize) diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp index 9d51a7f..ac80485 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -2091,7 +2091,7 @@ bool AArch64InstructionSelector::preISelLower(MachineInstr &I) { case AArch64::G_DUP: { // Convert the type from p0 to s64 to help selection. LLT DstTy = MRI.getType(I.getOperand(0).getReg()); - if (!DstTy.getElementType().isPointer()) + if (!DstTy.isPointerVector()) return false; auto NewSrc = MIB.buildCopy(LLT::scalar(64), I.getOperand(1).getReg()); MRI.setType(I.getOperand(0).getReg(), diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp index cbf56557..ab25e2b 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -343,10 +343,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) auto IsPtrVecPred = [=](const LegalityQuery &Query) { const LLT &ValTy = Query.Types[0]; - if (!ValTy.isVector()) - return false; - const LLT EltTy = ValTy.getElementType(); - return EltTy.isPointer() && EltTy.getAddressSpace() == 0; + return ValTy.isPointerVector() && ValTy.getAddressSpace() == 0; }; getActionDefinitionsBuilder(G_LOAD) @@ -521,7 +518,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) [=](const LegalityQuery &Query) { const LLT &Ty = Query.Types[0]; const LLT &SrcTy = Query.Types[1]; - return Ty.isVector() && !SrcTy.getElementType().isPointer() && + return Ty.isVector() && !SrcTy.isPointerVector() && Ty.getElementType() != SrcTy.getElementType(); }, 0, 1) @@ -555,7 +552,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) [=](const LegalityQuery &Query) { const LLT &Ty = Query.Types[0]; const LLT &SrcTy = Query.Types[1]; - return Ty.isVector() && !SrcTy.getElementType().isPointer() && + return Ty.isVector() && !SrcTy.isPointerVector() && Ty.getElementType() != SrcTy.getElementType(); }, 0, 1) @@ -1649,7 +1646,7 @@ bool AArch64LegalizerInfo::legalizeLoadStore( return true; } - if (!ValTy.isVector() || !ValTy.getElementType().isPointer() || + if (!ValTy.isPointerVector() || ValTy.getElementType().getAddressSpace() != 0) { LLVM_DEBUG(dbgs() << "Tried to do custom legalization on wrong load/store"); return false; diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp index def08cc..f3716f9 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp @@ -498,11 +498,10 @@ static bool loadStoreBitcastWorkaround(const LLT Ty) { if (!Ty.isVector()) return true; - LLT EltTy = Ty.getElementType(); - if (EltTy.isPointer()) + if (Ty.isPointerVector()) return true; - unsigned EltSize = EltTy.getSizeInBits(); + unsigned EltSize = Ty.getScalarSizeInBits(); return EltSize != 32 && EltSize != 64; } |