#include "llvm/Pass.h"
#include "llvm/Support/Allocator.h"
#include <algorithm>
+#include <optional>
#include <utility>
namespace llvm {
bool getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name);
/// Find named metadata for a loop with an integer value.
-llvm::Optional<int>
-getOptionalIntLoopAttribute(const Loop *TheLoop, StringRef Name);
+std::optional<int> getOptionalIntLoopAttribute(const Loop *TheLoop,
+ StringRef Name);
/// Find named metadata for a loop with an integer value. Return \p Default if
/// not set.
return getOptionalBoolLoopAttribute(TheLoop, Name).value_or(false);
}
-llvm::Optional<int> llvm::getOptionalIntLoopAttribute(const Loop *TheLoop,
- StringRef Name) {
+std::optional<int> llvm::getOptionalIntLoopAttribute(const Loop *TheLoop,
+ StringRef Name) {
const MDOperand *AttrMD =
findStringMetadataForLoop(TheLoop, Name).value_or(nullptr);
if (!AttrMD)
- return None;
+ return std::nullopt;
ConstantInt *IntMD = mdconst::extract_or_null<ConstantInt>(AttrMD->get());
if (!IntMD)
- return None;
+ return std::nullopt;
return IntMD->getSExtValue();
}
LLVM_DEBUG(dbgs() << "Leftover vectorization transformation\n");
Optional<ElementCount> VectorizeWidth =
getOptionalElementCountLoopAttribute(L);
- Optional<int> InterleaveCount =
+ std::optional<int> InterleaveCount =
getOptionalIntLoopAttribute(L, "llvm.loop.interleave.count");
if (!VectorizeWidth || VectorizeWidth->isVector())
Optional<ElementCount>
llvm::getOptionalElementCountLoopAttribute(const Loop *TheLoop) {
- Optional<int> Width =
+ std::optional<int> Width =
getOptionalIntLoopAttribute(TheLoop, "llvm.loop.vectorize.width");
if (Width) {
- Optional<int> IsScalable = getOptionalIntLoopAttribute(
+ std::optional<int> IsScalable = getOptionalIntLoopAttribute(
TheLoop, "llvm.loop.vectorize.scalable.enable");
return ElementCount::get(*Width, IsScalable.value_or(false));
}
if (getBooleanLoopAttribute(L, "llvm.loop.unroll.disable"))
return TM_SuppressedByUser;
- Optional<int> Count =
+ std::optional<int> Count =
getOptionalIntLoopAttribute(L, "llvm.loop.unroll.count");
if (Count)
return Count.value() == 1 ? TM_SuppressedByUser : TM_ForcedByUser;
if (getBooleanLoopAttribute(L, "llvm.loop.unroll_and_jam.disable"))
return TM_SuppressedByUser;
- Optional<int> Count =
+ std::optional<int> Count =
getOptionalIntLoopAttribute(L, "llvm.loop.unroll_and_jam.count");
if (Count)
return Count.value() == 1 ? TM_SuppressedByUser : TM_ForcedByUser;
Optional<ElementCount> VectorizeWidth =
getOptionalElementCountLoopAttribute(L);
- Optional<int> InterleaveCount =
+ std::optional<int> InterleaveCount =
getOptionalIntLoopAttribute(L, "llvm.loop.interleave.count");
// 'Forcing' vector width and interleave count to one effectively disables