From 2216d8f6b8675b4135a21290bda027c1c34d0a28 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Wed, 28 Sep 2022 14:58:15 -0700 Subject: [PATCH] [Hexagon] Replace llvm::Optional with std::optional, NFC --- llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp | 32 +++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp index 33bfd8b..b0b9e55 100644 --- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -74,7 +75,7 @@ public: // Create a ConstantInt of type returned by getIntTy with the value Val. ConstantInt *getConstInt(int Val) const; // Get the integer value of V, if it exists. - Optional getIntValue(const Value *Val) const; + std::optional getIntValue(const Value *Val) const; // Is V a constant 0, or a vector of 0s? bool isZero(const Value *Val) const; // Is V an undef value? @@ -106,7 +107,7 @@ public: Value *createHvxIntrinsic(IRBuilder<> &Builder, Intrinsic::ID IntID, Type *RetTy, ArrayRef Args) const; - Optional calculatePointerDifference(Value *Ptr0, Value *Ptr1) const; + std::optional calculatePointerDifference(Value *Ptr0, Value *Ptr1) const; template > bool isSafeToMoveBeforeInBB(const Instruction &In, @@ -222,8 +223,8 @@ private: }; Align getAlignFromValue(const Value *V) const; - Optional getLocation(const Instruction &In) const; - Optional getAddrInfo(Instruction &In) const; + std::optional getLocation(const Instruction &In) const; + std::optional getAddrInfo(Instruction &In) const; bool isHvx(const AddrInfo &AI) const; // This function is only used for assertions at the moment. [[maybe_unused]] bool isSectorTy(Type *Ty) const; @@ -378,7 +379,8 @@ auto AlignVectors::getAlignFromValue(const Value *V) const -> Align { return C->getAlignValue(); } -auto AlignVectors::getAddrInfo(Instruction &In) const -> Optional { +auto AlignVectors::getAddrInfo(Instruction &In) const + -> std::optional { if (auto *L = isCandidate(&In)) return AddrInfo(HVC, L, L->getPointerOperand(), L->getType(), L->getAlign()); @@ -397,7 +399,7 @@ auto AlignVectors::getAddrInfo(Instruction &In) const -> Optional { getAlignFromValue(II->getArgOperand(2))); } } - return Optional(); + return std::nullopt; } auto AlignVectors::isHvx(const AddrInfo &AI) const -> bool { @@ -977,10 +979,10 @@ auto HexagonVectorCombine::isZero(const Value *Val) const -> bool { } auto HexagonVectorCombine::getIntValue(const Value *Val) const - -> Optional { + -> std::optional { if (auto *CI = dyn_cast(Val)) return CI->getValue(); - return None; + return std::nullopt; } auto HexagonVectorCombine::isUndef(const Value *Val) const -> bool { @@ -1308,7 +1310,7 @@ auto HexagonVectorCombine::createHvxIntrinsic(IRBuilder<> &Builder, auto HexagonVectorCombine::calculatePointerDifference(Value *Ptr0, Value *Ptr1) const - -> Optional { + -> std::optional { struct Builder : IRBuilder<> { Builder(BasicBlock *B) : IRBuilder<>(B) {} ~Builder() { @@ -1344,19 +1346,19 @@ auto HexagonVectorCombine::calculatePointerDifference(Value *Ptr0, Ptr0 = StripBitCast(Ptr0); Ptr1 = StripBitCast(Ptr1); if (!isa(Ptr0) || !isa(Ptr1)) - return None; + return std::nullopt; auto *Gep0 = cast(Ptr0); auto *Gep1 = cast(Ptr1); if (Gep0->getPointerOperand() != Gep1->getPointerOperand()) - return None; + return std::nullopt; Builder B(Gep0->getParent()); int Scale = getSizeOf(Gep0->getSourceElementType(), Alloc); // FIXME: for now only check GEPs with a single index. if (Gep0->getNumOperands() != 2 || Gep1->getNumOperands() != 2) - return None; + return std::nullopt; Value *Idx0 = Gep0->getOperand(1); Value *Idx1 = Gep1->getOperand(1); @@ -1370,7 +1372,7 @@ auto HexagonVectorCombine::calculatePointerDifference(Value *Ptr0, KnownBits Known1 = computeKnownBits(Idx1, DL, 0, &AC, Gep1, &DT); APInt Unknown = ~(Known0.Zero | Known0.One) | ~(Known1.Zero | Known1.One); if (Unknown.isAllOnes()) - return None; + return std::nullopt; Value *MaskU = ConstantInt::get(Idx0->getType(), Unknown); Value *AndU0 = Simplify(CallBuilder(B, CreateAnd(Idx0, MaskU))); @@ -1380,7 +1382,7 @@ auto HexagonVectorCombine::calculatePointerDifference(Value *Ptr0, if (auto *C = dyn_cast(SubU)) { Diff0 = C->getSExtValue(); } else { - return None; + return std::nullopt; } Value *MaskK = ConstantInt::get(MaskU->getType(), ~Unknown); @@ -1391,7 +1393,7 @@ auto HexagonVectorCombine::calculatePointerDifference(Value *Ptr0, if (auto *C = dyn_cast(SubK)) { Diff1 = C->getSExtValue(); } else { - return None; + return std::nullopt; } return (Diff0 + Diff1) * Scale; -- 2.7.4