mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 11:02:04 +08:00
[mlir] Use std::optional instead of llvm::Optional (NFC)
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
This commit is contained in:
@@ -129,13 +129,13 @@ public:
|
||||
|
||||
/// Expression class for a return operator.
|
||||
class ReturnExprAST : public ExprAST {
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
ReturnExprAST(Location loc, std::optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
std::optional<ExprAST *> getExpr() {
|
||||
if (expr.has_value())
|
||||
return expr->get();
|
||||
return std::nullopt;
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
lexer.consume(tok_return);
|
||||
|
||||
// return takes an optional argument
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
if (lexer.getCurToken() != ';') {
|
||||
expr = parseExpression();
|
||||
if (!expr)
|
||||
|
||||
@@ -129,13 +129,13 @@ public:
|
||||
|
||||
/// Expression class for a return operator.
|
||||
class ReturnExprAST : public ExprAST {
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
ReturnExprAST(Location loc, std::optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
std::optional<ExprAST *> getExpr() {
|
||||
if (expr.has_value())
|
||||
return expr->get();
|
||||
return std::nullopt;
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
lexer.consume(tok_return);
|
||||
|
||||
// return takes an optional argument
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
if (lexer.getCurToken() != ';') {
|
||||
expr = parseExpression();
|
||||
if (!expr)
|
||||
|
||||
@@ -129,13 +129,13 @@ public:
|
||||
|
||||
/// Expression class for a return operator.
|
||||
class ReturnExprAST : public ExprAST {
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
ReturnExprAST(Location loc, std::optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
std::optional<ExprAST *> getExpr() {
|
||||
if (expr.has_value())
|
||||
return expr->get();
|
||||
return std::nullopt;
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
lexer.consume(tok_return);
|
||||
|
||||
// return takes an optional argument
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
if (lexer.getCurToken() != ';') {
|
||||
expr = parseExpression();
|
||||
if (!expr)
|
||||
|
||||
@@ -129,13 +129,13 @@ public:
|
||||
|
||||
/// Expression class for a return operator.
|
||||
class ReturnExprAST : public ExprAST {
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
ReturnExprAST(Location loc, std::optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
std::optional<ExprAST *> getExpr() {
|
||||
if (expr.has_value())
|
||||
return expr->get();
|
||||
return std::nullopt;
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
lexer.consume(tok_return);
|
||||
|
||||
// return takes an optional argument
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
if (lexer.getCurToken() != ';') {
|
||||
expr = parseExpression();
|
||||
if (!expr)
|
||||
|
||||
@@ -129,13 +129,13 @@ public:
|
||||
|
||||
/// Expression class for a return operator.
|
||||
class ReturnExprAST : public ExprAST {
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
ReturnExprAST(Location loc, std::optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
std::optional<ExprAST *> getExpr() {
|
||||
if (expr.has_value())
|
||||
return expr->get();
|
||||
return std::nullopt;
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
lexer.consume(tok_return);
|
||||
|
||||
// return takes an optional argument
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
if (lexer.getCurToken() != ';') {
|
||||
expr = parseExpression();
|
||||
if (!expr)
|
||||
|
||||
@@ -129,13 +129,13 @@ public:
|
||||
|
||||
/// Expression class for a return operator.
|
||||
class ReturnExprAST : public ExprAST {
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
ReturnExprAST(Location loc, std::optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
std::optional<ExprAST *> getExpr() {
|
||||
if (expr.has_value())
|
||||
return expr->get();
|
||||
return std::nullopt;
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
lexer.consume(tok_return);
|
||||
|
||||
// return takes an optional argument
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
if (lexer.getCurToken() != ';') {
|
||||
expr = parseExpression();
|
||||
if (!expr)
|
||||
|
||||
@@ -149,13 +149,13 @@ public:
|
||||
|
||||
/// Expression class for a return operator.
|
||||
class ReturnExprAST : public ExprAST {
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
ReturnExprAST(Location loc, std::optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
std::optional<ExprAST *> getExpr() {
|
||||
if (expr.has_value())
|
||||
return expr->get();
|
||||
return std::nullopt;
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
lexer.consume(tok_return);
|
||||
|
||||
// return takes an optional argument
|
||||
llvm::Optional<std::unique_ptr<ExprAST>> expr;
|
||||
std::optional<std::unique_ptr<ExprAST>> expr;
|
||||
if (lexer.getCurToken() != ';') {
|
||||
expr = parseExpression();
|
||||
if (!expr)
|
||||
|
||||
@@ -271,7 +271,7 @@ private:
|
||||
}
|
||||
|
||||
/// Return the numeric member index of the given struct access expression.
|
||||
llvm::Optional<size_t> getMemberIndex(BinaryExprAST &accessOp) {
|
||||
std::optional<size_t> getMemberIndex(BinaryExprAST &accessOp) {
|
||||
assert(accessOp.getOp() == '.' && "expected access operation");
|
||||
|
||||
// Lookup the struct node for the LHS.
|
||||
@@ -313,7 +313,7 @@ private:
|
||||
|
||||
// If this is an access operation, handle it immediately.
|
||||
if (binop.getOp() == '.') {
|
||||
llvm::Optional<size_t> accessIndex = getMemberIndex(binop);
|
||||
std::optional<size_t> accessIndex = getMemberIndex(binop);
|
||||
if (!accessIndex) {
|
||||
emitError(location, "invalid access into struct expression");
|
||||
return nullptr;
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
|
||||
private:
|
||||
/// The constant value.
|
||||
Optional<Attribute> constant;
|
||||
std::optional<Attribute> constant;
|
||||
/// A dialect instance that can be used to materialize the constant.
|
||||
Dialect *dialect = nullptr;
|
||||
};
|
||||
|
||||
@@ -221,7 +221,7 @@ private:
|
||||
|
||||
/// Get the constant values of the operands of the operation. Returns none if
|
||||
/// any of the operand lattices are uninitialized.
|
||||
Optional<SmallVector<Attribute>> getOperandValues(Operation *op);
|
||||
std::optional<SmallVector<Attribute>> getOperandValues(Operation *op);
|
||||
|
||||
/// The top-level operation the analysis is running on. This is used to detect
|
||||
/// if a callable is outside the scope of the analysis and thus must be
|
||||
|
||||
@@ -362,12 +362,12 @@ public:
|
||||
///
|
||||
/// Returns an integer sample point if one exists, or an empty Optional
|
||||
/// otherwise. The returned value also includes values of local ids.
|
||||
Optional<SmallVector<MPInt, 8>> findIntegerSample() const;
|
||||
std::optional<SmallVector<MPInt, 8>> findIntegerSample() const;
|
||||
|
||||
/// Compute an overapproximation of the number of integer points in the
|
||||
/// relation. Symbol vars currently not supported. If the computed
|
||||
/// overapproximation is infinite, an empty optional is returned.
|
||||
Optional<MPInt> computeVolume() const;
|
||||
std::optional<MPInt> computeVolume() const;
|
||||
|
||||
/// Returns true if the given point satisfies the constraints, or false
|
||||
/// otherwise. Takes the values of all vars including locals.
|
||||
@@ -377,9 +377,9 @@ public:
|
||||
}
|
||||
/// Given the values of non-local vars, return a satisfying assignment to the
|
||||
/// local if one exists, or an empty optional otherwise.
|
||||
Optional<SmallVector<MPInt, 8>>
|
||||
std::optional<SmallVector<MPInt, 8>>
|
||||
containsPointNoLocal(ArrayRef<MPInt> point) const;
|
||||
Optional<SmallVector<MPInt, 8>>
|
||||
std::optional<SmallVector<MPInt, 8>>
|
||||
containsPointNoLocal(ArrayRef<int64_t> point) const {
|
||||
return containsPointNoLocal(getMPIntVec(point));
|
||||
}
|
||||
@@ -473,20 +473,20 @@ public:
|
||||
/// equality). Ex: if the lower bound is [(s0 + s2 - 1) floordiv 32] for a
|
||||
/// system with three symbolic variables, *lb = [1, 0, 1], lbDivisor = 32. See
|
||||
/// comments at function definition for examples.
|
||||
Optional<MPInt> getConstantBoundOnDimSize(
|
||||
std::optional<MPInt> getConstantBoundOnDimSize(
|
||||
unsigned pos, SmallVectorImpl<MPInt> *lb = nullptr,
|
||||
MPInt *boundFloorDivisor = nullptr, SmallVectorImpl<MPInt> *ub = nullptr,
|
||||
unsigned *minLbPos = nullptr, unsigned *minUbPos = nullptr) const;
|
||||
/// The same, but casts to int64_t. This is unsafe and will assert-fail if the
|
||||
/// value does not fit in an int64_t.
|
||||
Optional<int64_t> getConstantBoundOnDimSize64(
|
||||
std::optional<int64_t> getConstantBoundOnDimSize64(
|
||||
unsigned pos, SmallVectorImpl<int64_t> *lb = nullptr,
|
||||
int64_t *boundFloorDivisor = nullptr,
|
||||
SmallVectorImpl<int64_t> *ub = nullptr, unsigned *minLbPos = nullptr,
|
||||
unsigned *minUbPos = nullptr) const {
|
||||
SmallVector<MPInt, 8> ubMPInt, lbMPInt;
|
||||
MPInt boundFloorDivisorMPInt;
|
||||
Optional<MPInt> result = getConstantBoundOnDimSize(
|
||||
std::optional<MPInt> result = getConstantBoundOnDimSize(
|
||||
pos, &lbMPInt, &boundFloorDivisorMPInt, &ubMPInt, minLbPos, minUbPos);
|
||||
if (lb)
|
||||
*lb = getInt64Vec(lbMPInt);
|
||||
@@ -499,10 +499,11 @@ public:
|
||||
|
||||
/// Returns the constant bound for the pos^th variable if there is one;
|
||||
/// std::nullopt otherwise.
|
||||
Optional<MPInt> getConstantBound(BoundType type, unsigned pos) const;
|
||||
std::optional<MPInt> getConstantBound(BoundType type, unsigned pos) const;
|
||||
/// The same, but casts to int64_t. This is unsafe and will assert-fail if the
|
||||
/// value does not fit in an int64_t.
|
||||
Optional<int64_t> getConstantBound64(BoundType type, unsigned pos) const {
|
||||
std::optional<int64_t> getConstantBound64(BoundType type,
|
||||
unsigned pos) const {
|
||||
return llvm::transformOptional(getConstantBound(type, pos), int64FromMPInt);
|
||||
}
|
||||
|
||||
@@ -683,11 +684,11 @@ protected:
|
||||
/// Returns the constant lower bound bound if isLower is true, and the upper
|
||||
/// bound if isLower is false.
|
||||
template <bool isLower>
|
||||
Optional<MPInt> computeConstantLowerOrUpperBound(unsigned pos);
|
||||
std::optional<MPInt> computeConstantLowerOrUpperBound(unsigned pos);
|
||||
/// The same, but casts to int64_t. This is unsafe and will assert-fail if the
|
||||
/// value does not fit in an int64_t.
|
||||
template <bool isLower>
|
||||
Optional<int64_t> computeConstantLowerOrUpperBound64(unsigned pos) {
|
||||
std::optional<int64_t> computeConstantLowerOrUpperBound64(unsigned pos) {
|
||||
return computeConstantLowerOrUpperBound<isLower>(pos).map(int64FromMPInt);
|
||||
}
|
||||
|
||||
|
||||
@@ -176,8 +176,8 @@ public:
|
||||
PresburgerSet getDomain() const;
|
||||
|
||||
/// Return the output of the function at the given point.
|
||||
Optional<SmallVector<MPInt, 8>> valueAt(ArrayRef<MPInt> point) const;
|
||||
Optional<SmallVector<MPInt, 8>> valueAt(ArrayRef<int64_t> point) const {
|
||||
std::optional<SmallVector<MPInt, 8>> valueAt(ArrayRef<MPInt> point) const;
|
||||
std::optional<SmallVector<MPInt, 8>> valueAt(ArrayRef<int64_t> point) const {
|
||||
return valueAt(getMPIntVec(point));
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
/// This currently just sums up the overapproximations of the volumes of the
|
||||
/// disjuncts, so the approximation might be far from the true volume in the
|
||||
/// case when there is a lot of overlap between disjuncts.
|
||||
Optional<MPInt> computeVolume() const;
|
||||
std::optional<MPInt> computeVolume() const;
|
||||
|
||||
/// Simplifies the representation of a PresburgerRelation.
|
||||
///
|
||||
|
||||
@@ -264,7 +264,7 @@ protected:
|
||||
/// Returns an empty optional if no pivot is possible, which happens only when
|
||||
/// the column unknown is a variable and no constraint has a non-zero
|
||||
/// coefficient for it.
|
||||
Optional<unsigned> findAnyPivotRow(unsigned col);
|
||||
std::optional<unsigned> findAnyPivotRow(unsigned col);
|
||||
|
||||
/// Swap the row with the column in the tableau's data structures but not the
|
||||
/// tableau itself. This is used by pivot.
|
||||
@@ -523,11 +523,11 @@ private:
|
||||
|
||||
/// Get a constraint row that is violated, if one exists.
|
||||
/// Otherwise, return an empty optional.
|
||||
Optional<unsigned> maybeGetViolatedRow() const;
|
||||
std::optional<unsigned> maybeGetViolatedRow() const;
|
||||
|
||||
/// Get a row corresponding to a var that has a non-integral sample value, if
|
||||
/// one exists. Otherwise, return an empty optional.
|
||||
Optional<unsigned> maybeGetNonIntegralVarRow() const;
|
||||
std::optional<unsigned> maybeGetNonIntegralVarRow() const;
|
||||
};
|
||||
|
||||
/// Represents the result of a symbolic lexicographic minimization computation.
|
||||
@@ -634,11 +634,11 @@ private:
|
||||
LogicalResult doNonBranchingPivots();
|
||||
|
||||
/// Get a row that is always violated in the current domain, if one exists.
|
||||
Optional<unsigned> maybeGetAlwaysViolatedRow();
|
||||
std::optional<unsigned> maybeGetAlwaysViolatedRow();
|
||||
|
||||
/// Get a row corresponding to a variable with non-integral sample value, if
|
||||
/// one exists.
|
||||
Optional<unsigned> maybeGetNonIntegralVarRow();
|
||||
std::optional<unsigned> maybeGetNonIntegralVarRow();
|
||||
|
||||
/// Given a row that has a non-integer sample value, cut away this fractional
|
||||
/// sample value witahout removing any integer points, i.e., the integer
|
||||
@@ -782,7 +782,7 @@ public:
|
||||
|
||||
/// Returns an integer sample point if one exists, or std::nullopt
|
||||
/// otherwise. This should only be called for bounded sets.
|
||||
Optional<SmallVector<MPInt, 8>> findIntegerSample();
|
||||
std::optional<SmallVector<MPInt, 8>> findIntegerSample();
|
||||
|
||||
enum class IneqType { Redundant, Cut, Separate };
|
||||
|
||||
@@ -806,11 +806,11 @@ public:
|
||||
|
||||
/// Returns the current sample point if it is integral. Otherwise, returns
|
||||
/// std::nullopt.
|
||||
Optional<SmallVector<MPInt, 8>> getSamplePointIfIntegral() const;
|
||||
std::optional<SmallVector<MPInt, 8>> getSamplePointIfIntegral() const;
|
||||
|
||||
/// Returns the current sample point, which may contain non-integer (rational)
|
||||
/// coordinates. Returns an empty optional when the tableau is empty.
|
||||
Optional<SmallVector<Fraction, 8>> getRationalSample() const;
|
||||
std::optional<SmallVector<Fraction, 8>> getRationalSample() const;
|
||||
|
||||
private:
|
||||
friend class GBRSimplex;
|
||||
@@ -829,7 +829,7 @@ private:
|
||||
///
|
||||
/// Returns a (row, col) pair denoting a pivot, or an empty Optional if
|
||||
/// no valid pivot exists.
|
||||
Optional<Pivot> findPivot(int row, Direction direction) const;
|
||||
std::optional<Pivot> findPivot(int row, Direction direction) const;
|
||||
|
||||
/// Find a row that can be used to pivot the column in the specified
|
||||
/// direction. If skipRow is not null, then this row is excluded
|
||||
@@ -839,8 +839,8 @@ private:
|
||||
///
|
||||
/// Returns the row to pivot to, or an empty Optional if the column
|
||||
/// is unbounded in the specified direction.
|
||||
Optional<unsigned> findPivotRow(Optional<unsigned> skipRow,
|
||||
Direction direction, unsigned col) const;
|
||||
std::optional<unsigned> findPivotRow(std::optional<unsigned> skipRow,
|
||||
Direction direction, unsigned col) const;
|
||||
|
||||
/// Undo the addition of the last constraint while preserving tableau
|
||||
/// consistency.
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
bool isUnbounded() const { return kind == OptimumKind::Unbounded; }
|
||||
bool isEmpty() const { return kind == OptimumKind::Empty; }
|
||||
|
||||
Optional<T> getOptimumIfBounded() const { return optimum; }
|
||||
std::optional<T> getOptimumIfBounded() const { return optimum; }
|
||||
const T &getBoundedOptimum() const {
|
||||
assert(kind == OptimumKind::Bounded &&
|
||||
"This should be called only for bounded optima");
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
// For a given point containing values for each variable other than the
|
||||
// division variables, try to find the values for each division variable from
|
||||
// their division representation.
|
||||
SmallVector<Optional<MPInt>, 4> divValuesAt(ArrayRef<MPInt> point) const;
|
||||
SmallVector<std::optional<MPInt>, 4> divValuesAt(ArrayRef<MPInt> point) const;
|
||||
|
||||
// Get the `i^th` denominator.
|
||||
MPInt &getDenom(unsigned i) { return denoms[i]; }
|
||||
|
||||
@@ -22,7 +22,7 @@ class OperationPass;
|
||||
/// If log1pBenefit is present, use it instead of benefit for the Log1p op.
|
||||
void populateMathToLibmConversionPatterns(
|
||||
RewritePatternSet &patterns, PatternBenefit benefit,
|
||||
llvm::Optional<PatternBenefit> log1pBenefit = std::nullopt);
|
||||
std::optional<PatternBenefit> log1pBenefit = std::nullopt);
|
||||
|
||||
/// Create a pass to convert Math operations to libm calls.
|
||||
std::unique_ptr<OperationPass<ModuleOp>> createConvertMathToLibmPass();
|
||||
|
||||
@@ -141,9 +141,9 @@ struct DependenceComponent {
|
||||
// The AffineForOp Operation associated with this dependence component.
|
||||
Operation *op = nullptr;
|
||||
// The lower bound of the dependence distance.
|
||||
Optional<int64_t> lb;
|
||||
std::optional<int64_t> lb;
|
||||
// The upper bound of the dependence distance (inclusive).
|
||||
Optional<int64_t> ub;
|
||||
std::optional<int64_t> ub;
|
||||
DependenceComponent() : lb(std::nullopt), ub(std::nullopt) {}
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
unsigned numReservedEqualities,
|
||||
unsigned numReservedCols, unsigned numDims,
|
||||
unsigned numSymbols, unsigned numLocals,
|
||||
ArrayRef<Optional<Value>> valArgs = {})
|
||||
ArrayRef<std::optional<Value>> valArgs = {})
|
||||
: IntegerPolyhedron(numReservedInequalities, numReservedEqualities,
|
||||
numReservedCols,
|
||||
presburger::PresburgerSpace::getSetSpace(
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
/// dimensions and symbols.
|
||||
FlatAffineValueConstraints(unsigned numDims = 0, unsigned numSymbols = 0,
|
||||
unsigned numLocals = 0,
|
||||
ArrayRef<Optional<Value>> valArgs = {})
|
||||
ArrayRef<std::optional<Value>> valArgs = {})
|
||||
: FlatAffineValueConstraints(/*numReservedInequalities=*/0,
|
||||
/*numReservedEqualities=*/0,
|
||||
/*numReservedCols=*/numDims + numSymbols +
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
numDims, numSymbols, numLocals, valArgs) {}
|
||||
|
||||
FlatAffineValueConstraints(const IntegerPolyhedron &fac,
|
||||
ArrayRef<Optional<Value>> valArgs = {})
|
||||
ArrayRef<std::optional<Value>> valArgs = {})
|
||||
: IntegerPolyhedron(fac) {
|
||||
assert(valArgs.empty() || valArgs.size() == getNumDimAndSymbolVars());
|
||||
if (valArgs.empty())
|
||||
@@ -437,11 +437,11 @@ public:
|
||||
getValues(0, getNumDimAndSymbolVars(), values);
|
||||
}
|
||||
|
||||
inline ArrayRef<Optional<Value>> getMaybeValues() const {
|
||||
inline ArrayRef<std::optional<Value>> getMaybeValues() const {
|
||||
return {values.data(), values.size()};
|
||||
}
|
||||
|
||||
inline ArrayRef<Optional<Value>>
|
||||
inline ArrayRef<std::optional<Value>>
|
||||
getMaybeValues(presburger::VarKind kind) const {
|
||||
assert(kind != VarKind::Local &&
|
||||
"Local variables do not have any value attached to them.");
|
||||
@@ -511,7 +511,7 @@ protected:
|
||||
/// constraint system appearing in the order the variables correspond to
|
||||
/// columns. Variables that aren't associated with any Value are set to
|
||||
/// None.
|
||||
SmallVector<Optional<Value>, 8> values;
|
||||
SmallVector<std::optional<Value>, 8> values;
|
||||
};
|
||||
|
||||
/// A FlatAffineRelation represents a set of ordered pairs (domain -> range)
|
||||
@@ -525,7 +525,7 @@ public:
|
||||
unsigned numReservedEqualities, unsigned numReservedCols,
|
||||
unsigned numDomainDims, unsigned numRangeDims,
|
||||
unsigned numSymbols, unsigned numLocals,
|
||||
ArrayRef<Optional<Value>> valArgs = {})
|
||||
ArrayRef<std::optional<Value>> valArgs = {})
|
||||
: FlatAffineValueConstraints(
|
||||
numReservedInequalities, numReservedEqualities, numReservedCols,
|
||||
numDomainDims + numRangeDims, numSymbols, numLocals, valArgs),
|
||||
|
||||
@@ -41,7 +41,7 @@ void getTripCountMapAndOperands(AffineForOp forOp, AffineMap *map,
|
||||
/// Returns the trip count of the loop if it's a constant, std::nullopt
|
||||
/// otherwise. This uses affine expression analysis and is able to determine
|
||||
/// constant trip count in non-trivial cases.
|
||||
Optional<uint64_t> getConstantTripCount(AffineForOp forOp);
|
||||
std::optional<uint64_t> getConstantTripCount(AffineForOp forOp);
|
||||
|
||||
/// Returns the greatest known integral divisor of the trip count. Affine
|
||||
/// expression analysis is used (indirectly through getTripCount), and
|
||||
|
||||
@@ -115,7 +115,7 @@ struct ComputationSliceState {
|
||||
/// cannot determine if the slice is maximal or not.
|
||||
// TODO: Cache 'isMaximal' so that we don't recompute it when the slice
|
||||
// information hasn't changed.
|
||||
Optional<bool> isMaximal() const;
|
||||
std::optional<bool> isMaximal() const;
|
||||
|
||||
/// Checks the validity of the slice computed. This is done using the
|
||||
/// following steps:
|
||||
@@ -131,7 +131,7 @@ struct ComputationSliceState {
|
||||
/// return false as it implies that the effective fusion results in at least
|
||||
/// one iteration of the slice that was not originally in the source's domain.
|
||||
/// If the validity cannot be determined, returns std::nullopt.
|
||||
Optional<bool> isSliceValid();
|
||||
std::optional<bool> isSliceValid();
|
||||
|
||||
void dump() const;
|
||||
|
||||
@@ -141,7 +141,7 @@ private:
|
||||
/// and the dst loops for those dimensions have the same bounds. Returns false
|
||||
/// if both the src and the dst loops don't have the same bounds. Returns
|
||||
/// std::nullopt if none of the above can be proven.
|
||||
Optional<bool> isSliceMaximalFastCheck() const;
|
||||
std::optional<bool> isSliceMaximalFastCheck() const;
|
||||
};
|
||||
|
||||
/// Computes the computation slice loop bounds for one loop nest as affine maps
|
||||
@@ -303,7 +303,7 @@ struct MemRefRegion {
|
||||
/// int64_t. `lbs` are set to the lower bounds for each of the rank
|
||||
/// dimensions, and lbDivisors contains the corresponding denominators for
|
||||
/// floorDivs.
|
||||
Optional<int64_t> getConstantBoundingSizeAndShape(
|
||||
std::optional<int64_t> getConstantBoundingSizeAndShape(
|
||||
SmallVectorImpl<int64_t> *shape = nullptr,
|
||||
std::vector<SmallVector<int64_t, 4>> *lbs = nullptr,
|
||||
SmallVectorImpl<int64_t> *lbDivisors = nullptr) const;
|
||||
@@ -317,7 +317,7 @@ struct MemRefRegion {
|
||||
/// 'pos' corresponds to the position of the memref shape's dimension (major
|
||||
/// to minor) which matches 1:1 with the dimensional variable positions in
|
||||
/// 'cst'.
|
||||
Optional<int64_t>
|
||||
std::optional<int64_t>
|
||||
getConstantBoundOnDimSize(unsigned pos,
|
||||
SmallVectorImpl<int64_t> *lb = nullptr,
|
||||
int64_t *lbFloorDivisor = nullptr) const {
|
||||
@@ -326,7 +326,7 @@ struct MemRefRegion {
|
||||
}
|
||||
|
||||
/// Returns the size of this MemRefRegion in bytes.
|
||||
Optional<int64_t> getRegionSize();
|
||||
std::optional<int64_t> getRegionSize();
|
||||
|
||||
// Wrapper around FlatAffineValueConstraints::unionBoundingBox.
|
||||
LogicalResult unionBoundingBox(const MemRefRegion &other);
|
||||
@@ -357,7 +357,7 @@ struct MemRefRegion {
|
||||
|
||||
/// Returns the size of memref data in bytes if it's statically shaped,
|
||||
/// std::nullopt otherwise.
|
||||
Optional<uint64_t> getMemRefSizeInBytes(MemRefType memRefType);
|
||||
std::optional<uint64_t> getMemRefSizeInBytes(MemRefType memRefType);
|
||||
|
||||
/// Checks a load or store op for an out of bound access; returns failure if the
|
||||
/// access is out of bounds along any of the dimensions, success otherwise.
|
||||
@@ -371,8 +371,8 @@ unsigned getNumCommonSurroundingLoops(Operation &a, Operation &b);
|
||||
|
||||
/// Gets the memory footprint of all data touched in the specified memory space
|
||||
/// in bytes; if the memory space is unspecified, considers all memory spaces.
|
||||
Optional<int64_t> getMemoryFootprintBytes(AffineForOp forOp,
|
||||
int memorySpace = -1);
|
||||
std::optional<int64_t> getMemoryFootprintBytes(AffineForOp forOp,
|
||||
int memorySpace = -1);
|
||||
|
||||
/// Simplify the integer set by simplifying the underlying affine expressions by
|
||||
/// flattening and some simple inference. Also, drop any duplicate constraints.
|
||||
|
||||
@@ -186,14 +186,14 @@ struct AffineCopyOptions {
|
||||
/// encountered.
|
||||
LogicalResult affineDataCopyGenerate(Block::iterator begin, Block::iterator end,
|
||||
const AffineCopyOptions ©Options,
|
||||
Optional<Value> filterMemRef,
|
||||
std::optional<Value> filterMemRef,
|
||||
DenseSet<Operation *> ©Nests);
|
||||
|
||||
/// A convenience version of affineDataCopyGenerate for all ops in the body of
|
||||
/// an AffineForOp.
|
||||
LogicalResult affineDataCopyGenerate(AffineForOp forOp,
|
||||
const AffineCopyOptions ©Options,
|
||||
Optional<Value> filterMemRef,
|
||||
std::optional<Value> filterMemRef,
|
||||
DenseSet<Operation *> ©Nests);
|
||||
|
||||
/// Result for calling generateCopyForMemRegion.
|
||||
|
||||
@@ -301,10 +301,10 @@ Value expandAffineExpr(OpBuilder &builder, Location loc, AffineExpr expr,
|
||||
|
||||
/// Create a sequence of operations that implement the `affineMap` applied to
|
||||
/// the given `operands` (as it it were an AffineApplyOp).
|
||||
Optional<SmallVector<Value, 8>> expandAffineMap(OpBuilder &builder,
|
||||
Location loc,
|
||||
AffineMap affineMap,
|
||||
ValueRange operands);
|
||||
std::optional<SmallVector<Value, 8>> expandAffineMap(OpBuilder &builder,
|
||||
Location loc,
|
||||
AffineMap affineMap,
|
||||
ValueRange operands);
|
||||
|
||||
/// Holds the result of (div a, b) and (mod a, b).
|
||||
struct DivModValue {
|
||||
|
||||
@@ -333,7 +333,7 @@ def Async_AwaitOp : Async_Op<"await"> {
|
||||
];
|
||||
|
||||
let extraClassDeclaration = [{
|
||||
Optional<Type> getResultType() {
|
||||
std::optional<Type> getResultType() {
|
||||
if (getResultTypes().empty()) return std::nullopt;
|
||||
return getResultTypes()[0];
|
||||
}
|
||||
|
||||
@@ -204,9 +204,9 @@ struct BufferizationOptions {
|
||||
bool isOpAllowed(Operation *op) const;
|
||||
|
||||
/// Helper functions for allocation, deallocation, memory copying.
|
||||
Optional<AllocationFn> allocationFn;
|
||||
Optional<DeallocationFn> deallocationFn;
|
||||
Optional<MemCpyFn> memCpyFn;
|
||||
std::optional<AllocationFn> allocationFn;
|
||||
std::optional<DeallocationFn> deallocationFn;
|
||||
std::optional<MemCpyFn> memCpyFn;
|
||||
|
||||
/// Create a memref allocation with the given type and dynamic extents.
|
||||
FailureOr<Value> createAlloc(OpBuilder &b, Location loc, MemRefType type,
|
||||
@@ -233,7 +233,7 @@ struct BufferizationOptions {
|
||||
/// The default memory space that should be used when it cannot be inferred
|
||||
/// from the context. If case of std::nullopt, bufferization fails when the
|
||||
/// memory space cannot be inferred at any point.
|
||||
Optional<Attribute> defaultMemorySpace = Attribute();
|
||||
std::optional<Attribute> defaultMemorySpace = Attribute();
|
||||
|
||||
/// Certain ops have aliasing OpOperand/OpResult invariants (e.g., scf.for).
|
||||
/// If this flag is set to `false`, those invariants are no longer enforced
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
namespace mlir {
|
||||
/// Performs constant folding `calculate` with element-wise behavior on the two
|
||||
/// attributes in `operands` and returns the result if possible.
|
||||
template <
|
||||
class AttrElementT, class ElementValueT = typename AttrElementT::ValueType,
|
||||
class CalculationT =
|
||||
function_ref<Optional<ElementValueT>(ElementValueT, ElementValueT)>>
|
||||
template <class AttrElementT,
|
||||
class ElementValueT = typename AttrElementT::ValueType,
|
||||
class CalculationT = function_ref<
|
||||
std::optional<ElementValueT>(ElementValueT, ElementValueT)>>
|
||||
Attribute constFoldBinaryOpConditional(ArrayRef<Attribute> operands,
|
||||
const CalculationT &calculate) {
|
||||
assert(operands.size() == 2 && "binary op takes two operands");
|
||||
@@ -96,16 +96,17 @@ Attribute constFoldBinaryOp(ArrayRef<Attribute> operands,
|
||||
const CalculationT &calculate) {
|
||||
return constFoldBinaryOpConditional<AttrElementT>(
|
||||
operands,
|
||||
[&](ElementValueT a, ElementValueT b) -> Optional<ElementValueT> {
|
||||
[&](ElementValueT a, ElementValueT b) -> std::optional<ElementValueT> {
|
||||
return calculate(a, b);
|
||||
});
|
||||
}
|
||||
|
||||
/// Performs constant folding `calculate` with element-wise behavior on the one
|
||||
/// attributes in `operands` and returns the result if possible.
|
||||
template <
|
||||
class AttrElementT, class ElementValueT = typename AttrElementT::ValueType,
|
||||
class CalculationT = function_ref<Optional<ElementValueT>(ElementValueT)>>
|
||||
template <class AttrElementT,
|
||||
class ElementValueT = typename AttrElementT::ValueType,
|
||||
class CalculationT =
|
||||
function_ref<std::optional<ElementValueT>(ElementValueT)>>
|
||||
Attribute constFoldUnaryOpConditional(ArrayRef<Attribute> operands,
|
||||
const CalculationT &&calculate) {
|
||||
assert(operands.size() == 1 && "unary op takes one operands");
|
||||
@@ -154,8 +155,9 @@ template <class AttrElementT,
|
||||
Attribute constFoldUnaryOp(ArrayRef<Attribute> operands,
|
||||
const CalculationT &&calculate) {
|
||||
return constFoldUnaryOpConditional<AttrElementT>(
|
||||
operands,
|
||||
[&](ElementValueT a) -> Optional<ElementValueT> { return calculate(a); });
|
||||
operands, [&](ElementValueT a) -> std::optional<ElementValueT> {
|
||||
return calculate(a);
|
||||
});
|
||||
}
|
||||
|
||||
template <
|
||||
|
||||
@@ -61,20 +61,22 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
using DecomposeValueConversionCallFn = std::function<Optional<LogicalResult>(
|
||||
OpBuilder &, Location, Type, Value, SmallVectorImpl<Value> &)>;
|
||||
using DecomposeValueConversionCallFn =
|
||||
std::function<std::optional<LogicalResult>(
|
||||
OpBuilder &, Location, Type, Value, SmallVectorImpl<Value> &)>;
|
||||
|
||||
/// Generate a wrapper for the given decompose value conversion callback.
|
||||
template <typename T, typename FnT>
|
||||
DecomposeValueConversionCallFn
|
||||
wrapDecomposeValueConversionCallback(FnT &&callback) {
|
||||
return [callback = std::forward<FnT>(callback)](
|
||||
OpBuilder &builder, Location loc, Type type, Value value,
|
||||
SmallVectorImpl<Value> &newValues) -> Optional<LogicalResult> {
|
||||
if (T derivedType = type.dyn_cast<T>())
|
||||
return callback(builder, loc, derivedType, value, newValues);
|
||||
return std::nullopt;
|
||||
};
|
||||
return
|
||||
[callback = std::forward<FnT>(callback)](
|
||||
OpBuilder &builder, Location loc, Type type, Value value,
|
||||
SmallVectorImpl<Value> &newValues) -> std::optional<LogicalResult> {
|
||||
if (T derivedType = type.dyn_cast<T>())
|
||||
return callback(builder, loc, derivedType, value, newValues);
|
||||
return std::nullopt;
|
||||
};
|
||||
}
|
||||
|
||||
SmallVector<DecomposeValueConversionCallFn, 2> decomposeValueConversions;
|
||||
|
||||
@@ -330,7 +330,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
|
||||
/// Returns the block size this kernel will be launched with along
|
||||
/// dimension `dim` if known. The value of gpu.thread_id dim will be strictly
|
||||
/// less than this size.
|
||||
Optional<uint32_t> getKnownBlockSize(gpu::Dimension dim) {
|
||||
std::optional<uint32_t> getKnownBlockSize(gpu::Dimension dim) {
|
||||
if (auto array =
|
||||
(*this)->getAttrOfType<DenseI32ArrayAttr>(getKnownBlockSizeAttrName())) {
|
||||
return array[static_cast<uint32_t>(dim)];
|
||||
@@ -341,7 +341,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
|
||||
/// Returns the grid size this kernel will be launched with along
|
||||
/// dimension `dim` if known. The value of gpu.block_id dim will be strictly
|
||||
/// less than this size.
|
||||
Optional<uint32_t> getKnownGridSize(gpu::Dimension dim) {
|
||||
std::optional<uint32_t> getKnownGridSize(gpu::Dimension dim) {
|
||||
if (auto array =
|
||||
(*this)->getAttrOfType<DenseI32ArrayAttr>(getKnownGridSizeAttrName())) {
|
||||
return array[static_cast<uint32_t>(dim)];
|
||||
|
||||
@@ -107,8 +107,8 @@ private:
|
||||
std::unique_ptr<llvm::TargetMachine> createTargetMachine();
|
||||
|
||||
/// Translates the module to ISA
|
||||
Optional<std::string> translateToISA(llvm::Module &llvmModule,
|
||||
llvm::TargetMachine &targetMachine);
|
||||
std::optional<std::string> translateToISA(llvm::Module &llvmModule,
|
||||
llvm::TargetMachine &targetMachine);
|
||||
|
||||
/// Serializes the target ISA to binary form.
|
||||
virtual std::unique_ptr<std::vector<char>>
|
||||
|
||||
@@ -70,9 +70,9 @@ def LoopOptionsAttr : LLVM_Attr<"LoopOptions", "loopopts"> {
|
||||
let extraClassDeclaration = [{
|
||||
using OptionValuePair = std::pair<LoopOptionCase, int64_t>;
|
||||
using OptionsArray = ArrayRef<std::pair<LoopOptionCase, int64_t>>;
|
||||
Optional<bool> disableUnroll();
|
||||
Optional<bool> disableLICM();
|
||||
Optional<int64_t> interleaveCount();
|
||||
std::optional<bool> disableUnroll();
|
||||
std::optional<bool> disableLICM();
|
||||
std::optional<int64_t> interleaveCount();
|
||||
}];
|
||||
|
||||
let builders = [
|
||||
|
||||
@@ -81,31 +81,31 @@ public:
|
||||
|
||||
/// Set the `disable_licm` option to the provided value. If no value
|
||||
/// is provided the option is deleted.
|
||||
LoopOptionsAttrBuilder &setDisableLICM(Optional<bool> value);
|
||||
LoopOptionsAttrBuilder &setDisableLICM(std::optional<bool> value);
|
||||
|
||||
/// Set the `interleave_count` option to the provided value. If no value
|
||||
/// is provided the option is deleted.
|
||||
LoopOptionsAttrBuilder &setInterleaveCount(Optional<uint64_t> count);
|
||||
LoopOptionsAttrBuilder &setInterleaveCount(std::optional<uint64_t> count);
|
||||
|
||||
/// Set the `disable_unroll` option to the provided value. If no value
|
||||
/// is provided the option is deleted.
|
||||
LoopOptionsAttrBuilder &setDisableUnroll(Optional<bool> value);
|
||||
LoopOptionsAttrBuilder &setDisableUnroll(std::optional<bool> value);
|
||||
|
||||
/// Set the `disable_pipeline` option to the provided value. If no value
|
||||
/// is provided the option is deleted.
|
||||
LoopOptionsAttrBuilder &setDisablePipeline(Optional<bool> value);
|
||||
LoopOptionsAttrBuilder &setDisablePipeline(std::optional<bool> value);
|
||||
|
||||
/// Set the `pipeline_initiation_interval` option to the provided value.
|
||||
/// If no value is provided the option is deleted.
|
||||
LoopOptionsAttrBuilder &
|
||||
setPipelineInitiationInterval(Optional<uint64_t> count);
|
||||
setPipelineInitiationInterval(std::optional<uint64_t> count);
|
||||
|
||||
/// Returns true if any option has been set.
|
||||
bool empty() { return options.empty(); }
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
LoopOptionsAttrBuilder &setOption(LoopOptionCase tag, Optional<T> value);
|
||||
LoopOptionsAttrBuilder &setOption(LoopOptionCase tag, std::optional<T> value);
|
||||
|
||||
friend class LoopOptionsAttr;
|
||||
SmallVector<LoopOptionsAttr::OptionValuePair> options;
|
||||
|
||||
@@ -787,7 +787,7 @@ def LLVM_CondBrOp : LLVM_TerminatorOp<"cond_br",
|
||||
OpBuilder<(ins "Value":$condition, "Block *":$trueDest,
|
||||
"ValueRange":$trueOperands, "Block *":$falseDest,
|
||||
"ValueRange":$falseOperands,
|
||||
CArg<"Optional<std::pair<uint32_t, uint32_t>>", "{}">:$weights),
|
||||
CArg<"std::optional<std::pair<uint32_t, uint32_t>>", "{}">:$weights),
|
||||
[{
|
||||
ElementsAttr weightsAttr;
|
||||
if (weights) {
|
||||
@@ -1500,7 +1500,7 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
|
||||
CArg<"CConv", "CConv::C">:$cconv,
|
||||
CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs,
|
||||
CArg<"ArrayRef<DictionaryAttr>", "{}">:$argAttrs,
|
||||
CArg<"Optional<uint64_t>", "{}">:$functionEntryCount)>
|
||||
CArg<"std::optional<uint64_t>", "{}">:$functionEntryCount)>
|
||||
];
|
||||
|
||||
let extraClassDeclaration = [{
|
||||
|
||||
@@ -286,7 +286,8 @@ enum class PtrDLEntryPos { Size = 0, Abi = 1, Preferred = 2, Index = 3 };
|
||||
/// Returns `std::nullopt` if `pos` is not present in the entry.
|
||||
/// Currently only `PtrDLEntryPos::Index` is optional, and all other positions
|
||||
/// may be assumed to be present.
|
||||
Optional<unsigned> extractPointerSpecValue(Attribute attr, PtrDLEntryPos pos);
|
||||
std::optional<unsigned> extractPointerSpecValue(Attribute attr,
|
||||
PtrDLEntryPos pos);
|
||||
|
||||
} // namespace LLVM
|
||||
} // namespace mlir
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
}
|
||||
// Return the indexing map of the operand/result in `opView` specified in
|
||||
// the owning LinalgOp. If the owner is not a LinalgOp returns std::nullopt.
|
||||
static Optional<AffineMap> getIndexingMap(OpView opView) {
|
||||
static std::optional<AffineMap> getIndexingMap(OpView opView) {
|
||||
auto owner = dyn_cast<LinalgOp>(getOwner(opView));
|
||||
if (!owner)
|
||||
return std::nullopt;
|
||||
@@ -89,14 +89,14 @@ public:
|
||||
}
|
||||
// Return the operand number if the `opView` is an OpOperand *. Otherwise
|
||||
// return std::nullopt.
|
||||
static Optional<unsigned> getOperandNumber(OpView opView) {
|
||||
static std::optional<unsigned> getOperandNumber(OpView opView) {
|
||||
if (OpOperand *operand = opView.dyn_cast<OpOperand *>())
|
||||
return operand->getOperandNumber();
|
||||
return std::nullopt;
|
||||
}
|
||||
// Return the result number if the `opView` is an OpResult. Otherwise return
|
||||
// std::nullopt.
|
||||
static Optional<unsigned> getResultNumber(OpView opView) {
|
||||
static std::optional<unsigned> getResultNumber(OpView opView) {
|
||||
if (OpResult result = opView.dyn_cast<Value>().cast<OpResult>())
|
||||
return result.getResultNumber();
|
||||
return std::nullopt;
|
||||
@@ -116,37 +116,37 @@ public:
|
||||
|
||||
// If the dependent OpView is an operand, return operand number. Return
|
||||
// std::nullopt otherwise.
|
||||
Optional<unsigned> getDependentOpViewOperandNum() const {
|
||||
std::optional<unsigned> getDependentOpViewOperandNum() const {
|
||||
return getOperandNumber(dependentOpView);
|
||||
}
|
||||
|
||||
// If the indexing OpView is an operand, return operand number. Return
|
||||
// std::nullopt otherwise.
|
||||
Optional<unsigned> getIndexingOpViewOperandNum() const {
|
||||
std::optional<unsigned> getIndexingOpViewOperandNum() const {
|
||||
return getOperandNumber(indexingOpView);
|
||||
}
|
||||
|
||||
// If the dependent OpView is a result value, return the result
|
||||
// number. Return std::nullopt otherwise.
|
||||
Optional<unsigned> getDependentOpViewResultNum() const {
|
||||
std::optional<unsigned> getDependentOpViewResultNum() const {
|
||||
return getResultNumber(dependentOpView);
|
||||
}
|
||||
|
||||
// If the dependent OpView is a result value, return the result
|
||||
// number. Return std::nullopt otherwise.
|
||||
Optional<unsigned> getIndexingOpViewResultNum() const {
|
||||
std::optional<unsigned> getIndexingOpViewResultNum() const {
|
||||
return getResultNumber(indexingOpView);
|
||||
}
|
||||
|
||||
// Return the indexing map of the operand/result in the dependent OpView as
|
||||
// specified in the owner of the OpView.
|
||||
Optional<AffineMap> getDependentOpViewIndexingMap() const {
|
||||
std::optional<AffineMap> getDependentOpViewIndexingMap() const {
|
||||
return getIndexingMap(dependentOpView);
|
||||
}
|
||||
|
||||
// Return the indexing map of the operand/result in the indexing OpView as
|
||||
// specified in the owner of the OpView.
|
||||
Optional<AffineMap> getIndexingOpViewIndexingMap() const {
|
||||
std::optional<AffineMap> getIndexingOpViewIndexingMap() const {
|
||||
return getIndexingMap(indexingOpView);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -64,7 +64,7 @@ SmallVector<AffineExpr, 4> makeAffineDimExprs(unsigned num, unsigned &startIdx,
|
||||
|
||||
/// Returns `maybeMap.get()` if `maybeMap` is set, otherwise returns the
|
||||
/// symbol-less identity map of `rank`.
|
||||
AffineMap extractOrIdentityMap(Optional<AffineMap> maybeMap, unsigned rank,
|
||||
AffineMap extractOrIdentityMap(std::optional<AffineMap> maybeMap, unsigned rank,
|
||||
MLIRContext *context);
|
||||
|
||||
/// Return the vector that is the concatenation of `a` and `b`.
|
||||
|
||||
@@ -135,12 +135,12 @@ GenericOp makeMemRefCopyOp(OpBuilder &b, Location loc, Value from, Value to);
|
||||
/// and offset is 0. Strictly speaking the offset 0 is not required in general,
|
||||
/// but non-zero offsets are not handled by SPIR-V backend at this point (and
|
||||
/// potentially cannot be handled).
|
||||
Optional<SmallVector<ReassociationIndices>>
|
||||
std::optional<SmallVector<ReassociationIndices>>
|
||||
getReassociationMapForFoldingUnitDims(ArrayRef<OpFoldResult> mixedSizes);
|
||||
|
||||
/// Return the identity numeric value associated to the give op. Return
|
||||
/// std::nullopt if there is no known neutral element.
|
||||
Optional<Attribute> getNeutralElement(Operation *op);
|
||||
std::optional<Attribute> getNeutralElement(Operation *op);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Fusion / Tiling utilities
|
||||
@@ -224,7 +224,7 @@ computeSliceParameters(OpBuilder &builder, Location loc, Value valueToTile,
|
||||
///
|
||||
/// Some of the `valuesToTile` won't be affected by tiling. For these values,
|
||||
/// std::nullopt will be returned.
|
||||
SmallVector<Optional<SliceParameters>>
|
||||
SmallVector<std::optional<SliceParameters>>
|
||||
computeAllSliceParameters(OpBuilder &builder, Location loc, LinalgOp linalgOp,
|
||||
ValueRange valuesToTile, ArrayRef<OpFoldResult> ivs,
|
||||
ArrayRef<OpFoldResult> tileSizes,
|
||||
@@ -397,7 +397,7 @@ public:
|
||||
LogicalResult
|
||||
tileRootOp(OpBuilder &b, ArrayRef<int64_t> tileSizes,
|
||||
ArrayRef<int64_t> tileInterchange,
|
||||
Optional<LinalgLoopDistributionOptions> tileDistribution);
|
||||
std::optional<LinalgLoopDistributionOptions> tileDistribution);
|
||||
|
||||
/// Fuse the producer of `consumerOpOperand` into the tile loop nest. Returns
|
||||
/// the fused producer or fails if fusion is not possible.
|
||||
@@ -467,7 +467,7 @@ struct RegionMatcher {
|
||||
/// linalg.yield %0: <scalar-type>
|
||||
/// }
|
||||
/// ```
|
||||
static Optional<BinaryOpKind> matchAsScalarBinaryOp(GenericOp op);
|
||||
static std::optional<BinaryOpKind> matchAsScalarBinaryOp(GenericOp op);
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -53,7 +53,7 @@ Type getTensorTypeFromMemRefType(Type type);
|
||||
/// Finds a single dealloc operation for the given allocated value. If there
|
||||
/// are > 1 deallocates for `allocValue`, returns std::nullopt, else returns the
|
||||
/// single deallocate if it exists or nullptr.
|
||||
Optional<Operation *> findDealloc(Value allocValue);
|
||||
std::optional<Operation *> findDealloc(Value allocValue);
|
||||
|
||||
/// Return the dimensions of the given memref value.
|
||||
SmallVector<OpFoldResult> getMixedSizes(OpBuilder &builder, Location loc,
|
||||
|
||||
@@ -354,7 +354,7 @@ def PDL_OperationOp : PDL_Op<"operation", [AttrSizedOperandSegments]> {
|
||||
}];
|
||||
|
||||
let builders = [
|
||||
OpBuilder<(ins CArg<"Optional<StringRef>", "std::nullopt">:$name,
|
||||
OpBuilder<(ins CArg<"std::optional<StringRef>", "std::nullopt">:$name,
|
||||
CArg<"ValueRange", "std::nullopt">:$operandValues,
|
||||
CArg<"ArrayRef<StringRef>", "std::nullopt">:$attrNames,
|
||||
CArg<"ValueRange", "std::nullopt">:$attrValues,
|
||||
@@ -419,8 +419,8 @@ def PDL_PatternOp : PDL_Op<"pattern", [
|
||||
}];
|
||||
|
||||
let builders = [
|
||||
OpBuilder<(ins CArg<"Optional<uint16_t>", "1">:$benefit,
|
||||
CArg<"Optional<StringRef>", "std::nullopt">:$name)>,
|
||||
OpBuilder<(ins CArg<"std::optional<uint16_t>", "1">:$benefit,
|
||||
CArg<"std::optional<StringRef>", "std::nullopt">:$name)>,
|
||||
];
|
||||
let extraClassDeclaration = [{
|
||||
//===------------------------------------------------------------------===//
|
||||
|
||||
@@ -113,7 +113,7 @@ bool getInnermostParallelLoops(Operation *rootOp,
|
||||
/// from scf.for or scf.parallel loop.
|
||||
/// if `loopFilter` is passed, the filter determines which loop to consider.
|
||||
/// Other induction variables are ignored.
|
||||
Optional<std::pair<AffineExpr, AffineExpr>>
|
||||
std::optional<std::pair<AffineExpr, AffineExpr>>
|
||||
getSCFMinMaxExpr(Value value, SmallVectorImpl<Value> &dims,
|
||||
SmallVectorImpl<Value> &symbols,
|
||||
llvm::function_ref<bool(Operation *)> loopFilter = nullptr);
|
||||
|
||||
@@ -134,7 +134,7 @@ def SPIRV_BranchConditionalOp : SPIRV_Op<"BranchConditional", [
|
||||
OpBuilder<(ins "Value":$condition, "Block *":$trueBlock,
|
||||
"ValueRange":$trueArguments, "Block *":$falseBlock,
|
||||
"ValueRange":$falseArguments,
|
||||
CArg<"Optional<std::pair<uint32_t, uint32_t>>", "{}">:$weights),
|
||||
CArg<"std::optional<std::pair<uint32_t, uint32_t>>", "{}">:$weights),
|
||||
[{
|
||||
ArrayAttr weightsAttr;
|
||||
if (weights) {
|
||||
|
||||
@@ -36,13 +36,13 @@ public:
|
||||
bool allows(Capability) const;
|
||||
/// Returns the first allowed one if any of the given capabilities is allowed.
|
||||
/// Returns std::nullopt otherwise.
|
||||
Optional<Capability> allows(ArrayRef<Capability>) const;
|
||||
std::optional<Capability> allows(ArrayRef<Capability>) const;
|
||||
|
||||
/// Returns true if the given extension is allowed.
|
||||
bool allows(Extension) const;
|
||||
/// Returns the first allowed one if any of the given extensions is allowed.
|
||||
/// Returns std::nullopt otherwise.
|
||||
Optional<Extension> allows(ArrayRef<Extension>) const;
|
||||
std::optional<Extension> allows(ArrayRef<Extension>) const;
|
||||
|
||||
/// Returns the vendor ID.
|
||||
Vendor getVendorID() const;
|
||||
|
||||
@@ -296,19 +296,19 @@ public:
|
||||
return getDimLevelType(tensor(b), index(b));
|
||||
}
|
||||
|
||||
Optional<unsigned> getLoopIdx(unsigned t, unsigned dim) const {
|
||||
std::optional<unsigned> getLoopIdx(unsigned t, unsigned dim) const {
|
||||
assert(t < numTensors && dim < numLoops);
|
||||
return dimToLoopIdx[t][dim];
|
||||
}
|
||||
|
||||
/// Gets the dimension number of the the `t`th tensor on `i`th loop.
|
||||
Optional<unsigned> getDimNum(unsigned t, unsigned i) const {
|
||||
std::optional<unsigned> getDimNum(unsigned t, unsigned i) const {
|
||||
assert(t < numTensors && i < numLoops);
|
||||
return loopIdxToDim[t][i];
|
||||
}
|
||||
|
||||
/// Gets the dimension number of `b`.
|
||||
Optional<unsigned> getDimNum(unsigned b) const {
|
||||
std::optional<unsigned> getDimNum(unsigned b) const {
|
||||
return getDimNum(tensor(b), index(b));
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ public:
|
||||
// corresponding tensor dimension and invokes the callback.
|
||||
void foreachTidDimPairInBits(
|
||||
const BitVector &bits,
|
||||
function_ref<void(unsigned b, unsigned tid, Optional<unsigned> dim,
|
||||
function_ref<void(unsigned b, unsigned tid, std::optional<unsigned> dim,
|
||||
DimLevelType dlt)>
|
||||
cb) {
|
||||
for (unsigned b : bits.set_bits())
|
||||
@@ -360,7 +360,7 @@ public:
|
||||
|
||||
/// Builds a tensor expression from the given Linalg operation.
|
||||
/// Returns index of the root expression on success.
|
||||
Optional<unsigned> buildTensorExpFromLinalg(linalg::GenericOp op);
|
||||
std::optional<unsigned> buildTensorExpFromLinalg(linalg::GenericOp op);
|
||||
|
||||
/// Rebuilds SSA format from a tensor expression.
|
||||
Value buildExp(RewriterBase &rewriter, Location loc, unsigned e, Value v0,
|
||||
@@ -373,7 +373,7 @@ private:
|
||||
Type inferType(unsigned e, Value src);
|
||||
|
||||
/// Traverses the SSA tree (possibly a DAG) to build a tensor expression.
|
||||
Optional<unsigned> buildTensorExp(linalg::GenericOp op, Value v);
|
||||
std::optional<unsigned> buildTensorExp(linalg::GenericOp op, Value v);
|
||||
|
||||
/// Merger data structures.
|
||||
const unsigned outTensor;
|
||||
@@ -389,10 +389,10 @@ private:
|
||||
|
||||
// Map that converts pair<tensor id, loop id> to the corresponding
|
||||
// dimension.
|
||||
std::vector<std::vector<Optional<unsigned>>> loopIdxToDim;
|
||||
std::vector<std::vector<std::optional<unsigned>>> loopIdxToDim;
|
||||
|
||||
// Map that converts pair<tensor id, dim> to the corresponding loop id.
|
||||
std::vector<std::vector<Optional<unsigned>>> dimToLoopIdx;
|
||||
std::vector<std::vector<std::optional<unsigned>>> dimToLoopIdx;
|
||||
|
||||
llvm::SmallVector<TensorExp> tensorExps;
|
||||
llvm::SmallVector<LatPoint> latPoints;
|
||||
|
||||
@@ -1761,7 +1761,7 @@ def Tensor_PackOp : Tensor_RelayoutOp<"pack", [
|
||||
OpBuilder<(ins "Value":$source, "Value":$dest,
|
||||
"ArrayRef<int64_t>":$innerDimsPos,
|
||||
"ArrayRef<OpFoldResult>":$innerTiles,
|
||||
CArg<"Optional<Value>", "std::nullopt">:$paddingValue,
|
||||
CArg<"std::optional<Value>", "std::nullopt">:$paddingValue,
|
||||
CArg<"ArrayRef<int64_t>", "{}">:$outerDimsPerm)>
|
||||
];
|
||||
|
||||
|
||||
@@ -45,9 +45,9 @@ bool validIntegerRange(IntegerType ty, int64_t value);
|
||||
// Checks for a dynamic batch dim in any of the passed parameters of an op.
|
||||
// The batch dimention must be #0 and the rest of the dimensions must be static.
|
||||
template <typename Op>
|
||||
Optional<SmallVector<Value>> checkHasDynamicBatchDims(PatternRewriter &rewriter,
|
||||
Op op,
|
||||
ArrayRef<Value> params) {
|
||||
std::optional<SmallVector<Value>>
|
||||
checkHasDynamicBatchDims(PatternRewriter &rewriter, Op op,
|
||||
ArrayRef<Value> params) {
|
||||
SmallVector<ShapedType> dynTypes;
|
||||
SmallVector<Value> dynamicDims;
|
||||
for (const Value ¶m : params) {
|
||||
|
||||
@@ -190,7 +190,7 @@ private:
|
||||
template <typename OpTy>
|
||||
void TransformDialect::addOperationIfNotRegistered() {
|
||||
StringRef name = OpTy::getOperationName();
|
||||
Optional<RegisteredOperationName> opName =
|
||||
std::optional<RegisteredOperationName> opName =
|
||||
RegisteredOperationName::lookup(name, getContext());
|
||||
if (!opName) {
|
||||
addOperations<OpTy>();
|
||||
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
|
||||
/// Attaches a note to the last diagnostic.
|
||||
/// Expects this object to be a silenceable failure.
|
||||
Diagnostic &attachNote(Optional<Location> loc = std::nullopt) {
|
||||
Diagnostic &attachNote(std::optional<Location> loc = std::nullopt) {
|
||||
assert(isSilenceableFailure() &&
|
||||
"can only attach notes to silenceable failures");
|
||||
return diagnostics.back().attachNote(loc);
|
||||
@@ -201,7 +201,7 @@ public:
|
||||
}
|
||||
|
||||
/// Attaches a note to the error.
|
||||
Diagnostic &attachNote(Optional<Location> loc = std::nullopt) {
|
||||
Diagnostic &attachNote(std::optional<Location> loc = std::nullopt) {
|
||||
return diag.attachNote(loc);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ SmallVector<int64_t> computeElementwiseMul(ArrayRef<int64_t> v1,
|
||||
/// derived as {42(leading shape dim), 2/2, 10/5, 32/2}.
|
||||
/// - shapeRatio({42, 2, 11, 32}, {2, 5, 2}) returns std::nullopt which is
|
||||
/// derived as {42(leading shape dim), 2/2, 11/5(not divisible), 32/2}.
|
||||
Optional<SmallVector<int64_t>> computeShapeRatio(ArrayRef<int64_t> shape,
|
||||
ArrayRef<int64_t> subShape);
|
||||
std::optional<SmallVector<int64_t>>
|
||||
computeShapeRatio(ArrayRef<int64_t> shape, ArrayRef<int64_t> subShape);
|
||||
|
||||
/// Return the number of elements of basis (i.e. the max linear index).
|
||||
/// Return `0` if `basis` is empty.
|
||||
|
||||
@@ -42,7 +42,7 @@ constexpr StringRef getReassociationAttrName() { return "reassociation"; }
|
||||
/// is folded into
|
||||
///
|
||||
/// result = [[0, 1, 2], [3, 4]].
|
||||
Optional<SmallVector<ReassociationIndices>> composeReassociationIndices(
|
||||
std::optional<SmallVector<ReassociationIndices>> composeReassociationIndices(
|
||||
ArrayRef<ReassociationIndices> producerReassociations,
|
||||
ArrayRef<ReassociationIndices> consumerReassociations,
|
||||
MLIRContext *context);
|
||||
@@ -67,12 +67,12 @@ SmallVector<ReassociationIndices, 2> convertReassociationMapsToIndices(
|
||||
/// Return the reassociations maps to use to reshape given the source type and
|
||||
/// the target type when possible. Return std::nullopt when this computation
|
||||
/// failed.
|
||||
Optional<SmallVector<ReassociationIndices>>
|
||||
std::optional<SmallVector<ReassociationIndices>>
|
||||
getReassociationIndicesForReshape(ShapedType sourceType, ShapedType targetType);
|
||||
|
||||
/// Returns the reassociation maps to collapse `sourceShape` to `targetShape` if
|
||||
/// possible.
|
||||
Optional<SmallVector<ReassociationIndices>>
|
||||
std::optional<SmallVector<ReassociationIndices>>
|
||||
getReassociationIndicesForCollapse(ArrayRef<int64_t> sourceShape,
|
||||
ArrayRef<int64_t> targetShape);
|
||||
|
||||
@@ -186,7 +186,7 @@ struct ComposeReassociativeReshapeOps : public OpRewritePattern<ReshapeOpTy> {
|
||||
hasNonIdentityLayout(reshapeOp.getResult().getType()))
|
||||
return failure();
|
||||
|
||||
Optional<SmallVector<ReassociationIndices>> reassociationIndices =
|
||||
std::optional<SmallVector<ReassociationIndices>> reassociationIndices =
|
||||
composeReassociationIndices(srcReshapeOp.getReassociationIndices(),
|
||||
reshapeOp.getReassociationIndices(),
|
||||
rewriter.getContext());
|
||||
@@ -341,7 +341,7 @@ struct ComposeExpandOfCollapseOp : public OpRewritePattern<ExpandOpTy> {
|
||||
private:
|
||||
// Attempts to find a way to collapse `srcShape` to `resultShape` by
|
||||
// collapsing subshapes defined by the reassociation indices.
|
||||
Optional<SmallVector<ReassociationIndices>> findCollapsingReassociation(
|
||||
std::optional<SmallVector<ReassociationIndices>> findCollapsingReassociation(
|
||||
ArrayRef<ReassociationIndices> srcReassociation,
|
||||
ArrayRef<ReassociationIndices> resultReassociation,
|
||||
ArrayRef<int64_t> srcShape, ArrayRef<int64_t> resultShape) const {
|
||||
@@ -476,7 +476,7 @@ struct CollapseShapeRankReducingSliceSimplificationInfo {
|
||||
RankedTensorType sliceResultType;
|
||||
/// The reassociation indices for the new collapse shape op, if required. If
|
||||
/// `None`, the slice should replace the collapse shape op.
|
||||
Optional<SmallVector<ReassociationIndices>> newReassociationIndices;
|
||||
std::optional<SmallVector<ReassociationIndices>> newReassociationIndices;
|
||||
};
|
||||
|
||||
/// A collapsing reshape operation can sometimes be simplified or eliminated by
|
||||
|
||||
@@ -112,7 +112,7 @@ struct UnrollVectorOptions {
|
||||
}
|
||||
|
||||
using NativeShapeFnType =
|
||||
std::function<Optional<SmallVector<int64_t>>(Operation *op)>;
|
||||
std::function<std::optional<SmallVector<int64_t>>(Operation *op)>;
|
||||
/// Function that returns the shape of the vector to unroll to for a given
|
||||
/// operation. The unrolling is aborted if the function returns
|
||||
/// `std::nullopt`.
|
||||
@@ -125,7 +125,7 @@ struct UnrollVectorOptions {
|
||||
/// Set the native shape to use for unrolling.
|
||||
UnrollVectorOptions &setNativeShape(ArrayRef<int64_t> shape) {
|
||||
SmallVector<int64_t> tsShape(shape.begin(), shape.end());
|
||||
nativeShape = [=](Operation *) -> Optional<SmallVector<int64_t>> {
|
||||
nativeShape = [=](Operation *) -> std::optional<SmallVector<int64_t>> {
|
||||
return tsShape;
|
||||
};
|
||||
return *this;
|
||||
@@ -136,7 +136,7 @@ struct UnrollVectorOptions {
|
||||
/// be used when unrolling the given operation into units of the native vector
|
||||
/// size.
|
||||
using UnrollTraversalOrderFnType =
|
||||
std::function<Optional<SmallVector<int64_t>>(Operation *op)>;
|
||||
std::function<std::optional<SmallVector<int64_t>>(Operation *op)>;
|
||||
UnrollTraversalOrderFnType traversalOrderCallback = nullptr;
|
||||
UnrollVectorOptions &
|
||||
setUnrollTraversalOrderFn(UnrollTraversalOrderFnType traversalOrderFn) {
|
||||
|
||||
@@ -68,7 +68,7 @@ struct ExecutionEngineOptions {
|
||||
|
||||
/// `jitCodeGenOptLevel`, when provided, is used as the optimization level for
|
||||
/// target code generation.
|
||||
Optional<llvm::CodeGenOpt::Level> jitCodeGenOptLevel = std::nullopt;
|
||||
std::optional<llvm::CodeGenOpt::Level> jitCodeGenOptLevel = std::nullopt;
|
||||
|
||||
/// If `sharedLibPaths` are provided, the underlying JIT-compilation will
|
||||
/// open and link the shared libraries for symbol resolution.
|
||||
|
||||
@@ -102,7 +102,7 @@ makeStridedMemRefDescriptor(T *ptr, T *alignedPtr, ArrayRef<int64_t> shape = {},
|
||||
template <typename T>
|
||||
std::pair<T *, T *>
|
||||
allocAligned(size_t nElements, AllocFunType allocFun = &::malloc,
|
||||
llvm::Optional<uint64_t> alignment = llvm::Optional<uint64_t>()) {
|
||||
std::optional<uint64_t> alignment = std::optional<uint64_t>()) {
|
||||
assert(sizeof(T) <= UINT_MAX && "Elemental type overflows");
|
||||
auto size = nElements * sizeof(T);
|
||||
auto desiredAlignment = alignment.value_or(nextPowerOf2(sizeof(T)));
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
OwningMemRef(
|
||||
ArrayRef<int64_t> shape, ArrayRef<int64_t> shapeAlloc = {},
|
||||
ElementWiseVisitor<T> init = {},
|
||||
llvm::Optional<uint64_t> alignment = llvm::Optional<uint64_t>(),
|
||||
std::optional<uint64_t> alignment = std::optional<uint64_t>(),
|
||||
AllocFunType allocFun = &::malloc,
|
||||
std::function<void(StridedMemRefType<T, Rank>)> freeFun =
|
||||
[](StridedMemRefType<T, Rank> descriptor) {
|
||||
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
/// Extracts the first result position where `input` dimension resides.
|
||||
/// Returns `std::nullopt` if `input` is not a dimension expression or cannot
|
||||
/// be found in results.
|
||||
Optional<unsigned> getResultPosition(AffineExpr input) const;
|
||||
std::optional<unsigned> getResultPosition(AffineExpr input) const;
|
||||
|
||||
/// Return true if any affine expression involves AffineDimExpr `position`.
|
||||
bool isFunctionOfDim(unsigned position) const {
|
||||
|
||||
@@ -440,7 +440,7 @@ private:
|
||||
/// Helper for sanity checking preconditions for create* methods below.
|
||||
template <typename OpT>
|
||||
RegisteredOperationName getCheckRegisteredInfo(MLIRContext *ctx) {
|
||||
Optional<RegisteredOperationName> opName =
|
||||
std::optional<RegisteredOperationName> opName =
|
||||
RegisteredOperationName::lookup(OpT::getOperationName(), ctx);
|
||||
if (LLVM_UNLIKELY(!opName)) {
|
||||
llvm::report_fatal_error(
|
||||
|
||||
@@ -300,7 +300,7 @@ auto ElementsAttrRange<IteratorT>::operator[](ArrayRef<uint64_t> index) const
|
||||
/// Return the elements of this attribute as a value of type 'T'.
|
||||
template <typename T>
|
||||
auto ElementsAttr::value_begin() const -> DefaultValueCheckT<T, iterator<T>> {
|
||||
if (Optional<iterator<T>> iterator = try_value_begin<T>())
|
||||
if (std::optional<iterator<T>> iterator = try_value_begin<T>())
|
||||
return std::move(*iterator);
|
||||
llvm::errs()
|
||||
<< "ElementsAttr does not provide iteration facilities for type `"
|
||||
@@ -309,7 +309,7 @@ auto ElementsAttr::value_begin() const -> DefaultValueCheckT<T, iterator<T>> {
|
||||
}
|
||||
template <typename T>
|
||||
auto ElementsAttr::try_value_begin() const
|
||||
-> DefaultValueCheckT<T, Optional<iterator<T>>> {
|
||||
-> DefaultValueCheckT<T, std::optional<iterator<T>>> {
|
||||
FailureOr<detail::ElementsAttrIndexer> indexer =
|
||||
getValuesImpl(TypeID::get<T>());
|
||||
if (failed(indexer))
|
||||
|
||||
@@ -395,18 +395,18 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> {
|
||||
/// If this attribute supports iterating over element values of type `T`,
|
||||
/// return the iterable range. Otherwise, return std::nullopt.
|
||||
template <typename T>
|
||||
DefaultValueCheckT<T, Optional<iterator_range<T>>> tryGetValues() const {
|
||||
if (Optional<iterator<T>> beginIt = try_value_begin<T>())
|
||||
DefaultValueCheckT<T, std::optional<iterator_range<T>>> tryGetValues() const {
|
||||
if (std::optional<iterator<T>> beginIt = try_value_begin<T>())
|
||||
return iterator_range<T>(getType(), *beginIt, value_end<T>());
|
||||
return std::nullopt;
|
||||
}
|
||||
template <typename T>
|
||||
DefaultValueCheckT<T, Optional<iterator<T>>> try_value_begin() const;
|
||||
DefaultValueCheckT<T, std::optional<iterator<T>>> try_value_begin() const;
|
||||
|
||||
/// If this attribute supports iterating over element values of type `T`,
|
||||
/// return the iterable range. Otherwise, return std::nullopt.
|
||||
template <typename T, typename = DerivedAttrValueCheckT<T>>
|
||||
Optional<DerivedAttrValueIteratorRange<T>> tryGetValues() const {
|
||||
std::optional<DerivedAttrValueIteratorRange<T>> tryGetValues() const {
|
||||
auto values = tryGetValues<Attribute>();
|
||||
if (!values)
|
||||
return std::nullopt;
|
||||
@@ -418,7 +418,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> {
|
||||
);
|
||||
}
|
||||
template <typename T, typename = DerivedAttrValueCheckT<T>>
|
||||
Optional<DerivedAttrValueIterator<T>> try_value_begin() const {
|
||||
std::optional<DerivedAttrValueIterator<T>> try_value_begin() const {
|
||||
if (auto values = tryGetValues<T>())
|
||||
return values->begin();
|
||||
return std::nullopt;
|
||||
|
||||
@@ -786,7 +786,7 @@ public:
|
||||
|
||||
/// Return the data of this attribute as an ArrayRef<T> if it is present,
|
||||
/// returns std::nullopt otherwise.
|
||||
Optional<ArrayRef<T>> tryGetAsArrayRef() const;
|
||||
std::optional<ArrayRef<T>> tryGetAsArrayRef() const;
|
||||
|
||||
/// Support for isa<>/cast<>.
|
||||
static bool classof(Attribute attr);
|
||||
|
||||
@@ -531,8 +531,8 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", [
|
||||
Attribute get(StringAttr name) const;
|
||||
|
||||
/// Return the specified named attribute if present, std::nullopt otherwise.
|
||||
Optional<NamedAttribute> getNamed(StringRef name) const;
|
||||
Optional<NamedAttribute> getNamed(StringAttr name) const;
|
||||
std::optional<NamedAttribute> getNamed(StringRef name) const;
|
||||
std::optional<NamedAttribute> getNamed(StringAttr name) const;
|
||||
|
||||
/// Return whether the specified attribute is present.
|
||||
bool contains(StringRef name) const;
|
||||
@@ -560,7 +560,7 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", [
|
||||
/// Returns an entry with a duplicate name in `array`, if it exists, else
|
||||
/// returns std::nullopt. If `isSorted` is true, the array is assumed to be
|
||||
/// sorted else it will be sorted in place before finding the duplicate entry.
|
||||
static Optional<NamedAttribute>
|
||||
static std::optional<NamedAttribute>
|
||||
findDuplicate(SmallVectorImpl<NamedAttribute> &array, bool isSorted);
|
||||
|
||||
/// Return the specified attribute if present and is an instance of
|
||||
|
||||
@@ -245,7 +245,7 @@ public:
|
||||
/// Attaches a note to this diagnostic. A new location may be optionally
|
||||
/// provided, if not, then the location defaults to the one specified for this
|
||||
/// diagnostic. Notes may not be attached to other notes.
|
||||
Diagnostic &attachNote(Optional<Location> noteLoc = std::nullopt);
|
||||
Diagnostic &attachNote(std::optional<Location> noteLoc = std::nullopt);
|
||||
|
||||
using note_iterator = llvm::pointee_iterator<NoteVector::iterator>;
|
||||
using const_note_iterator =
|
||||
@@ -343,7 +343,7 @@ public:
|
||||
}
|
||||
|
||||
/// Attaches a note to this diagnostic.
|
||||
Diagnostic &attachNote(Optional<Location> noteLoc = std::nullopt) {
|
||||
Diagnostic &attachNote(std::optional<Location> noteLoc = std::nullopt) {
|
||||
assert(isActive() && "diagnostic not active");
|
||||
return impl->attachNote(noteLoc);
|
||||
}
|
||||
@@ -394,7 +394,7 @@ private:
|
||||
DiagnosticEngine *owner = nullptr;
|
||||
|
||||
/// The raw diagnostic that is inflight to be reported.
|
||||
Optional<Diagnostic> impl;
|
||||
std::optional<Diagnostic> impl;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -596,7 +596,7 @@ private:
|
||||
|
||||
/// Given a location, returns the first nested location (including 'loc') that
|
||||
/// can be shown to the user.
|
||||
Optional<Location> findLocToShow(Location loc);
|
||||
std::optional<Location> findLocToShow(Location loc);
|
||||
|
||||
/// The maximum depth that a call stack will be printed.
|
||||
/// TODO: This should be a tunable flag.
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
BlobEntry &operator=(BlobEntry &&) = delete;
|
||||
|
||||
/// Initialize this entry with the given key and blob.
|
||||
void initialize(StringRef newKey, Optional<AsmResourceBlob> newBlob) {
|
||||
void initialize(StringRef newKey, std::optional<AsmResourceBlob> newBlob) {
|
||||
key = newKey;
|
||||
blob = std::move(newBlob);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
StringRef key;
|
||||
|
||||
/// The blob that is referenced by this entry if it is valid.
|
||||
Optional<AsmResourceBlob> blob;
|
||||
std::optional<AsmResourceBlob> blob;
|
||||
|
||||
/// Allow access to the constructors.
|
||||
friend DialectResourceBlobManager;
|
||||
@@ -83,12 +83,12 @@ public:
|
||||
/// Insert a new entry with the provided name and optional blob data. The name
|
||||
/// may be modified during insertion if another entry already exists with that
|
||||
/// name. Returns the inserted entry.
|
||||
BlobEntry &insert(StringRef name, Optional<AsmResourceBlob> blob = {});
|
||||
BlobEntry &insert(StringRef name, std::optional<AsmResourceBlob> blob = {});
|
||||
/// Insertion method that returns a dialect specific handle to the inserted
|
||||
/// entry.
|
||||
template <typename HandleT>
|
||||
HandleT insert(typename HandleT::Dialect *dialect, StringRef name,
|
||||
Optional<AsmResourceBlob> blob = {}) {
|
||||
std::optional<AsmResourceBlob> blob = {}) {
|
||||
BlobEntry &entry = insert(name, std::move(blob));
|
||||
return HandleT(&entry, dialect);
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
/// data. The name may be modified during insertion if another entry already
|
||||
/// exists with that name. Returns a dialect specific handle to the inserted
|
||||
/// entry.
|
||||
HandleT insert(StringRef name, Optional<AsmResourceBlob> blob = {}) {
|
||||
HandleT insert(StringRef name, std::optional<AsmResourceBlob> blob = {}) {
|
||||
return getBlobManager().template insert<HandleT>(
|
||||
cast<typename HandleT::Dialect>(getDialect()), name, std::move(blob));
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
ParseResult operator*() const { return value(); }
|
||||
|
||||
private:
|
||||
Optional<ParseResult> impl;
|
||||
std::optional<ParseResult> impl;
|
||||
};
|
||||
|
||||
// These functions are out-of-line utilities, which avoids them being template
|
||||
@@ -1673,8 +1673,9 @@ public:
|
||||
/// interfaces for the concrete operation.
|
||||
template <typename... Models>
|
||||
static void attachInterface(MLIRContext &context) {
|
||||
Optional<RegisteredOperationName> info = RegisteredOperationName::lookup(
|
||||
ConcreteType::getOperationName(), &context);
|
||||
std::optional<RegisteredOperationName> info =
|
||||
RegisteredOperationName::lookup(ConcreteType::getOperationName(),
|
||||
&context);
|
||||
if (!info)
|
||||
llvm::report_fatal_error(
|
||||
"Attempting to attach an interface to an unregistered operation " +
|
||||
@@ -1907,7 +1908,8 @@ protected:
|
||||
OperationName name = op->getName();
|
||||
|
||||
// Access the raw interface from the operation info.
|
||||
if (Optional<RegisteredOperationName> rInfo = name.getRegisteredInfo()) {
|
||||
if (std::optional<RegisteredOperationName> rInfo =
|
||||
name.getRegisteredInfo()) {
|
||||
if (auto *opIface = rInfo->getInterface<ConcreteType>())
|
||||
return opIface;
|
||||
// Fallback to the dialect to provide it with a chance to implement this
|
||||
|
||||
@@ -757,7 +757,7 @@ public:
|
||||
StringRef keyword;
|
||||
|
||||
/// The result of the switch statement or none if currently unknown.
|
||||
Optional<ResultT> result;
|
||||
std::optional<ResultT> result;
|
||||
};
|
||||
|
||||
/// Parse a given keyword.
|
||||
@@ -1286,7 +1286,7 @@ public:
|
||||
/// which case an OpaqueLoc is set and will be resolved when parsing
|
||||
/// completes.
|
||||
virtual ParseResult
|
||||
parseOptionalLocationSpecifier(Optional<Location> &result) = 0;
|
||||
parseOptionalLocationSpecifier(std::optional<Location> &result) = 0;
|
||||
|
||||
/// Return the name of the specified result in the specified syntax, as well
|
||||
/// as the sub-element in the name. It returns an empty string and ~0U for
|
||||
@@ -1340,12 +1340,13 @@ public:
|
||||
/// skip parsing that component.
|
||||
virtual ParseResult parseGenericOperationAfterOpName(
|
||||
OperationState &result,
|
||||
Optional<ArrayRef<UnresolvedOperand>> parsedOperandType = std::nullopt,
|
||||
Optional<ArrayRef<Block *>> parsedSuccessors = std::nullopt,
|
||||
Optional<MutableArrayRef<std::unique_ptr<Region>>> parsedRegions =
|
||||
std::optional<ArrayRef<UnresolvedOperand>> parsedOperandType =
|
||||
std::nullopt,
|
||||
Optional<ArrayRef<NamedAttribute>> parsedAttributes = std::nullopt,
|
||||
Optional<FunctionType> parsedFnType = std::nullopt) = 0;
|
||||
std::optional<ArrayRef<Block *>> parsedSuccessors = std::nullopt,
|
||||
std::optional<MutableArrayRef<std::unique_ptr<Region>>> parsedRegions =
|
||||
std::nullopt,
|
||||
std::optional<ArrayRef<NamedAttribute>> parsedAttributes = std::nullopt,
|
||||
std::optional<FunctionType> parsedFnType = std::nullopt) = 0;
|
||||
|
||||
/// Parse a single SSA value operand name along with a result number if
|
||||
/// `allowResultNumber` is true.
|
||||
@@ -1452,7 +1453,7 @@ public:
|
||||
UnresolvedOperand ssaName; // SourceLoc, SSA name, result #.
|
||||
Type type; // Type.
|
||||
DictionaryAttr attrs; // Attributes if present.
|
||||
Optional<Location> sourceLoc; // Source location specifier if present.
|
||||
std::optional<Location> sourceLoc; // Source location specifier if present.
|
||||
};
|
||||
|
||||
/// Parse a single argument with the following syntax:
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
|
||||
/// If this operation has a registered operation description, return it.
|
||||
/// Otherwise return std::nullopt.
|
||||
Optional<RegisteredOperationName> getRegisteredInfo() {
|
||||
std::optional<RegisteredOperationName> getRegisteredInfo() {
|
||||
return getName().getRegisteredInfo();
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
|
||||
/// If this operation is registered, returns the registered information,
|
||||
/// std::nullopt otherwise.
|
||||
Optional<RegisteredOperationName> getRegisteredInfo() const;
|
||||
std::optional<RegisteredOperationName> getRegisteredInfo() const;
|
||||
|
||||
/// This hook implements a generalized folder for this operation. Operations
|
||||
/// can implement this to provide simplifications rules that are applied by
|
||||
@@ -412,8 +412,8 @@ public:
|
||||
|
||||
/// Lookup the registered operation information for the given operation.
|
||||
/// Returns std::nullopt if the operation isn't registered.
|
||||
static Optional<RegisteredOperationName> lookup(StringRef name,
|
||||
MLIRContext *ctx);
|
||||
static std::optional<RegisteredOperationName> lookup(StringRef name,
|
||||
MLIRContext *ctx);
|
||||
|
||||
/// Register a new operation in a Dialect object.
|
||||
/// This constructor is used by Dialect objects when they register the list
|
||||
@@ -446,10 +446,10 @@ private:
|
||||
friend OperationName;
|
||||
};
|
||||
|
||||
inline Optional<RegisteredOperationName>
|
||||
inline std::optional<RegisteredOperationName>
|
||||
OperationName::getRegisteredInfo() const {
|
||||
return isRegistered() ? RegisteredOperationName(impl)
|
||||
: Optional<RegisteredOperationName>();
|
||||
: std::optional<RegisteredOperationName>();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -518,10 +518,10 @@ Attribute getAttrFromSortedRange(IteratorT first, IteratorT last, NameT name) {
|
||||
/// Get an attribute from a sorted range of named attributes. Returns
|
||||
/// std::nullopt if the attribute was not found.
|
||||
template <typename IteratorT, typename NameT>
|
||||
Optional<NamedAttribute>
|
||||
std::optional<NamedAttribute>
|
||||
getNamedAttrFromSortedRange(IteratorT first, IteratorT last, NameT name) {
|
||||
std::pair<IteratorT, bool> result = findAttrSorted(first, last, name);
|
||||
return result.second ? *result.first : Optional<NamedAttribute>();
|
||||
return result.second ? *result.first : std::optional<NamedAttribute>();
|
||||
}
|
||||
|
||||
} // namespace impl
|
||||
@@ -606,7 +606,7 @@ public:
|
||||
|
||||
/// Returns an entry with a duplicate name the list, if it exists, else
|
||||
/// returns std::nullopt.
|
||||
Optional<NamedAttribute> findDuplicate() const;
|
||||
std::optional<NamedAttribute> findDuplicate() const;
|
||||
|
||||
/// Return a dictionary attribute for the underlying dictionary. This will
|
||||
/// return an empty dictionary attribute if empty rather than null.
|
||||
@@ -620,8 +620,8 @@ public:
|
||||
Attribute get(StringRef name) const;
|
||||
|
||||
/// Return the specified named attribute if present, std::nullopt otherwise.
|
||||
Optional<NamedAttribute> getNamed(StringRef name) const;
|
||||
Optional<NamedAttribute> getNamed(StringAttr name) const;
|
||||
std::optional<NamedAttribute> getNamed(StringRef name) const;
|
||||
std::optional<NamedAttribute> getNamed(StringAttr name) const;
|
||||
|
||||
/// If the an attribute exists with the specified name, change it to the new
|
||||
/// value. Otherwise, add a new attribute with the specified name/value.
|
||||
@@ -844,7 +844,7 @@ public:
|
||||
bool shouldElideElementsAttr(ElementsAttr attr) const;
|
||||
|
||||
/// Return the size limit for printing large ElementsAttr.
|
||||
Optional<int64_t> getLargeElementsAttrLimit() const;
|
||||
std::optional<int64_t> getLargeElementsAttrLimit() const;
|
||||
|
||||
/// Return if debug information should be printed.
|
||||
bool shouldPrintDebugInfo() const;
|
||||
@@ -867,7 +867,7 @@ public:
|
||||
private:
|
||||
/// Elide large elements attributes if the number of elements is larger than
|
||||
/// the upper limit.
|
||||
Optional<int64_t> elementsAttrElementLimit;
|
||||
std::optional<int64_t> elementsAttrElementLimit;
|
||||
|
||||
/// Print debug information.
|
||||
bool printDebugInfoFlag : 1;
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
/// Return the interface ID used to match the root operation of this pattern.
|
||||
/// If the pattern does not use an interface ID for deciding the root match,
|
||||
/// this returns std::nullopt.
|
||||
Optional<TypeID> getRootInterfaceID() const {
|
||||
std::optional<TypeID> getRootInterfaceID() const {
|
||||
if (rootKind == RootKind::InterfaceID)
|
||||
return TypeID::getFromOpaquePointer(rootValue);
|
||||
return std::nullopt;
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
/// Return the trait ID used to match the root operation of this pattern.
|
||||
/// If the pattern does not use a trait ID for deciding the root match, this
|
||||
/// returns std::nullopt.
|
||||
Optional<TypeID> getRootTraitID() const {
|
||||
std::optional<TypeID> getRootTraitID() const {
|
||||
if (rootKind == RootKind::TraitID)
|
||||
return TypeID::getFromOpaquePointer(rootValue);
|
||||
return std::nullopt;
|
||||
@@ -655,7 +655,7 @@ public:
|
||||
/// value is not an instance of `T`.
|
||||
template <typename T,
|
||||
typename ResultT = std::conditional_t<
|
||||
std::is_convertible<T, bool>::value, T, Optional<T>>>
|
||||
std::is_convertible<T, bool>::value, T, std::optional<T>>>
|
||||
ResultT dyn_cast() const {
|
||||
return isa<T>() ? castImpl<T>() : ResultT();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
/// signal the element wasn't handled), or a pair of the replacement element
|
||||
/// and a WalkResult.
|
||||
template <typename T>
|
||||
using ReplaceFnResult = Optional<std::pair<T, WalkResult>>;
|
||||
using ReplaceFnResult = std::optional<std::pair<T, WalkResult>>;
|
||||
template <typename T>
|
||||
using ReplaceFn = std::function<ReplaceFnResult<T>(T)>;
|
||||
|
||||
@@ -70,13 +70,13 @@ public:
|
||||
/// forms(where `T` is a class derived from `Type` or `Attribute`, and `BaseT`
|
||||
/// is either `Type` or `Attribute` respectively):
|
||||
///
|
||||
/// * Optional<BaseT>(T)
|
||||
/// * std::optional<BaseT>(T)
|
||||
/// - This either returns a valid Attribute/Type in the case of success,
|
||||
/// nullptr in the case of failure, or `std::nullopt` to signify that
|
||||
/// additional replacement functions may be applied (i.e. this function
|
||||
/// doesn't handle that instance).
|
||||
///
|
||||
/// * Optional<std::pair<BaseT, WalkResult>>(T)
|
||||
/// * std::optional<std::pair<BaseT, WalkResult>>(T)
|
||||
/// - Similar to the above, but also allows specifying a WalkResult to
|
||||
/// control the replacement of sub elements of a given attribute or
|
||||
/// type. Returning a `skip` result, for example, will not recursively
|
||||
@@ -106,8 +106,8 @@ public:
|
||||
addReplacement([callback = std::forward<FnT>(callback)](
|
||||
BaseT base) -> ReplaceFnResult<BaseT> {
|
||||
if (auto derived = dyn_cast<T>(base)) {
|
||||
if constexpr (std::is_convertible_v<ResultT, Optional<BaseT>>) {
|
||||
Optional<BaseT> result = callback(derived);
|
||||
if constexpr (std::is_convertible_v<ResultT, std::optional<BaseT>>) {
|
||||
std::optional<BaseT> result = callback(derived);
|
||||
return result ? std::make_pair(*result, WalkResult::advance())
|
||||
: ReplaceFnResult<BaseT>();
|
||||
} else {
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
/// Slice this range into a sub range, with the additional operand segment.
|
||||
MutableOperandRange
|
||||
slice(unsigned subStart, unsigned subLen,
|
||||
Optional<OperandSegment> segment = std::nullopt) const;
|
||||
std::optional<OperandSegment> segment = std::nullopt) const;
|
||||
|
||||
/// Append the given values to the range.
|
||||
void append(ValueRange values);
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
/// If either the signed or unsigned interpretations of the range
|
||||
/// indicate that the value it bounds is a constant, return that constant
|
||||
/// value.
|
||||
Optional<APInt> getConstantValue() const;
|
||||
std::optional<APInt> getConstantValue() const;
|
||||
|
||||
friend raw_ostream &operator<<(raw_ostream &os,
|
||||
const ConstantIntRanges &range);
|
||||
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
|
||||
/// Get a cached analysis instance if one exists, otherwise return null.
|
||||
template <typename AnalysisT>
|
||||
Optional<std::reference_wrapper<AnalysisT>> getCachedAnalysis() const {
|
||||
std::optional<std::reference_wrapper<AnalysisT>> getCachedAnalysis() const {
|
||||
auto res = analyses.find(TypeID::get<AnalysisT>());
|
||||
if (res == analyses.end())
|
||||
return std::nullopt;
|
||||
@@ -302,7 +302,7 @@ public:
|
||||
/// Query for a cached analysis on the given parent operation. The analysis
|
||||
/// may not exist and if it does it may be out-of-date.
|
||||
template <typename AnalysisT>
|
||||
Optional<std::reference_wrapper<AnalysisT>>
|
||||
std::optional<std::reference_wrapper<AnalysisT>>
|
||||
getCachedParentAnalysis(Operation *parentOp) const {
|
||||
const detail::NestedAnalysisMap *curParent = impl;
|
||||
while (auto *parentAM = curParent->getParent()) {
|
||||
@@ -329,7 +329,7 @@ public:
|
||||
|
||||
/// Query for a cached entry of the given analysis on the current operation.
|
||||
template <typename AnalysisT>
|
||||
Optional<std::reference_wrapper<AnalysisT>> getCachedAnalysis() const {
|
||||
std::optional<std::reference_wrapper<AnalysisT>> getCachedAnalysis() const {
|
||||
return impl->analyses.getCachedAnalysis<AnalysisT>();
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ public:
|
||||
|
||||
/// Query for a cached analysis of a child operation, or return null.
|
||||
template <typename AnalysisT>
|
||||
Optional<std::reference_wrapper<AnalysisT>>
|
||||
std::optional<std::reference_wrapper<AnalysisT>>
|
||||
getCachedChildAnalysis(Operation *op) const {
|
||||
assert(op->getParentOp() == impl->getOperation());
|
||||
auto it = impl->childAnalyses.find(op);
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
|
||||
/// Returns the name of the operation that this pass operates on, or
|
||||
/// std::nullopt if this is a generic OperationPass.
|
||||
Optional<StringRef> getOpName() const { return opName; }
|
||||
std::optional<StringRef> getOpName() const { return opName; }
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Options
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit Pass(TypeID passID, Optional<StringRef> opName = std::nullopt)
|
||||
explicit Pass(TypeID passID, std::optional<StringRef> opName = std::nullopt)
|
||||
: passID(passID), opName(opName) {}
|
||||
Pass(const Pass &other) : Pass(other.passID, other.opName) {}
|
||||
|
||||
@@ -228,7 +228,7 @@ protected:
|
||||
/// Query a cached instance of an analysis for the current ir unit if one
|
||||
/// exists.
|
||||
template <typename AnalysisT>
|
||||
Optional<std::reference_wrapper<AnalysisT>> getCachedAnalysis() {
|
||||
std::optional<std::reference_wrapper<AnalysisT>> getCachedAnalysis() {
|
||||
return getAnalysisManager().getCachedAnalysis<AnalysisT>();
|
||||
}
|
||||
|
||||
@@ -248,21 +248,21 @@ protected:
|
||||
|
||||
/// Returns the analysis for the given parent operation if it exists.
|
||||
template <typename AnalysisT>
|
||||
Optional<std::reference_wrapper<AnalysisT>>
|
||||
std::optional<std::reference_wrapper<AnalysisT>>
|
||||
getCachedParentAnalysis(Operation *parent) {
|
||||
return getAnalysisManager().getCachedParentAnalysis<AnalysisT>(parent);
|
||||
}
|
||||
|
||||
/// Returns the analysis for the parent operation if it exists.
|
||||
template <typename AnalysisT>
|
||||
Optional<std::reference_wrapper<AnalysisT>> getCachedParentAnalysis() {
|
||||
std::optional<std::reference_wrapper<AnalysisT>> getCachedParentAnalysis() {
|
||||
return getAnalysisManager().getCachedParentAnalysis<AnalysisT>(
|
||||
getOperation()->getParentOp());
|
||||
}
|
||||
|
||||
/// Returns the analysis for the given child operation if it exists.
|
||||
template <typename AnalysisT>
|
||||
Optional<std::reference_wrapper<AnalysisT>>
|
||||
std::optional<std::reference_wrapper<AnalysisT>>
|
||||
getCachedChildAnalysis(Operation *child) {
|
||||
return getAnalysisManager().getCachedChildAnalysis<AnalysisT>(child);
|
||||
}
|
||||
@@ -303,10 +303,10 @@ private:
|
||||
|
||||
/// The name of the operation that this pass operates on, or std::nullopt if
|
||||
/// this is a generic OperationPass.
|
||||
Optional<StringRef> opName;
|
||||
std::optional<StringRef> opName;
|
||||
|
||||
/// The current execution state for the pass.
|
||||
Optional<detail::PassExecutionState> passState;
|
||||
std::optional<detail::PassExecutionState> passState;
|
||||
|
||||
/// The set of statistics held by this pass.
|
||||
std::vector<Statistic *> statistics;
|
||||
|
||||
@@ -45,14 +45,14 @@ public:
|
||||
/// the name of the operation type being operated on, or std::nullopt if the
|
||||
/// pipeline is op-agnostic, and information related to the parent that
|
||||
/// spawned this pipeline.
|
||||
virtual void runBeforePipeline(Optional<OperationName> name,
|
||||
virtual void runBeforePipeline(std::optional<OperationName> name,
|
||||
const PipelineParentInfo &parentInfo);
|
||||
|
||||
/// A callback to run after a pass pipeline has executed. This function takes
|
||||
/// the name of the operation type being operated on, or std::nullopt if the
|
||||
/// pipeline is op-agnostic, and information related to the parent that
|
||||
/// spawned this pipeline.
|
||||
virtual void runAfterPipeline(Optional<OperationName> name,
|
||||
virtual void runAfterPipeline(std::optional<OperationName> name,
|
||||
const PipelineParentInfo &parentInfo);
|
||||
|
||||
/// A callback to run before a pass is executed. This function takes a pointer
|
||||
@@ -93,12 +93,12 @@ public:
|
||||
|
||||
/// See PassInstrumentation::runBeforePipeline for details.
|
||||
void
|
||||
runBeforePipeline(Optional<OperationName> name,
|
||||
runBeforePipeline(std::optional<OperationName> name,
|
||||
const PassInstrumentation::PipelineParentInfo &parentInfo);
|
||||
|
||||
/// See PassInstrumentation::runAfterPipeline for details.
|
||||
void
|
||||
runAfterPipeline(Optional<OperationName> name,
|
||||
runAfterPipeline(std::optional<OperationName> name,
|
||||
const PassInstrumentation::PipelineParentInfo &parentInfo);
|
||||
|
||||
/// See PassInstrumentation::runBeforePass for details.
|
||||
|
||||
@@ -128,11 +128,11 @@ public:
|
||||
|
||||
/// Return the operation name that this pass manager operates on, or
|
||||
/// std::nullopt if this is an op-agnostic pass manager.
|
||||
Optional<OperationName> getOpName(MLIRContext &context) const;
|
||||
std::optional<OperationName> getOpName(MLIRContext &context) const;
|
||||
|
||||
/// Return the operation name that this pass manager operates on, or
|
||||
/// std::nullopt if this is an op-agnostic pass manager.
|
||||
Optional<StringRef> getOpName() const;
|
||||
std::optional<StringRef> getOpName() const;
|
||||
|
||||
/// Return the name used to anchor this pass manager. This is either the name
|
||||
/// of an operation, or the result of `getAnyOpAnchorName()` in the case of an
|
||||
@@ -429,7 +429,7 @@ private:
|
||||
MLIRContext *context;
|
||||
|
||||
/// Flag that specifies if pass statistics should be dumped.
|
||||
Optional<PassDisplayMode> passStatisticsMode;
|
||||
std::optional<PassDisplayMode> passStatisticsMode;
|
||||
|
||||
/// A manager for pass instrumentations.
|
||||
std::unique_ptr<PassInstrumentor> instrumentor;
|
||||
|
||||
@@ -260,7 +260,7 @@ private:
|
||||
std::unique_ptr<detail::PassPipelineCLParserImpl> impl;
|
||||
|
||||
llvm::cl::opt<std::string> passPipeline;
|
||||
Optional<llvm::cl::alias> passPipelineAlias;
|
||||
std::optional<llvm::cl::alias> passPipelineAlias;
|
||||
};
|
||||
|
||||
/// This class implements a command-line parser specifically for MLIR pass
|
||||
@@ -296,9 +296,9 @@ struct PassReproducerOptions {
|
||||
LogicalResult apply(PassManager &pm) const;
|
||||
|
||||
private:
|
||||
Optional<std::string> pipeline;
|
||||
Optional<bool> verifyEach;
|
||||
Optional<bool> disableThreading;
|
||||
std::optional<std::string> pipeline;
|
||||
std::optional<bool> verifyEach;
|
||||
std::optional<bool> disableThreading;
|
||||
};
|
||||
|
||||
} // namespace mlir
|
||||
|
||||
@@ -76,7 +76,7 @@ inline bool failed(LogicalResult result) { return result.failed(); }
|
||||
/// value of type `T`. This allows for integrating with LogicalResult, while
|
||||
/// also providing a value on the success path.
|
||||
template <typename T>
|
||||
class [[nodiscard]] FailureOr : public Optional<T> {
|
||||
class [[nodiscard]] FailureOr : public std::optional<T> {
|
||||
public:
|
||||
/// Allow constructing from a LogicalResult. The result *must* be a failure.
|
||||
/// Success results should use a proper instance of type `T`.
|
||||
@@ -85,19 +85,20 @@ public:
|
||||
"success should be constructed with an instance of 'T'");
|
||||
}
|
||||
FailureOr() : FailureOr(failure()) {}
|
||||
FailureOr(T &&y) : Optional<T>(std::forward<T>(y)) {}
|
||||
FailureOr(const T &y) : Optional<T>(y) {}
|
||||
FailureOr(T &&y) : std::optional<T>(std::forward<T>(y)) {}
|
||||
FailureOr(const T &y) : std::optional<T>(y) {}
|
||||
template <typename U,
|
||||
std::enable_if_t<std::is_constructible<T, U>::value> * = nullptr>
|
||||
FailureOr(const FailureOr<U> &other)
|
||||
: Optional<T>(failed(other) ? Optional<T>() : Optional<T>(*other)) {}
|
||||
: std::optional<T>(failed(other) ? std::optional<T>()
|
||||
: std::optional<T>(*other)) {}
|
||||
|
||||
operator LogicalResult() const { return success(this->has_value()); }
|
||||
|
||||
private:
|
||||
/// Hide the bool conversion as it easily creates confusion.
|
||||
using Optional<T>::operator bool;
|
||||
using Optional<T>::has_value;
|
||||
using std::optional<T>::operator bool;
|
||||
using std::optional<T>::has_value;
|
||||
};
|
||||
|
||||
/// Wrap a value on the success path in a FailureOr of the same value type.
|
||||
|
||||
@@ -141,7 +141,7 @@ protected:
|
||||
/// collection of timing samples is disabled. This will cause the timers
|
||||
/// constructed from the manager to be tombstones which can be skipped
|
||||
/// quickly.
|
||||
virtual Optional<void *> rootTimer() = 0;
|
||||
virtual std::optional<void *> rootTimer() = 0;
|
||||
|
||||
/// Start the timer with the given handle.
|
||||
virtual void startTimer(void *handle) = 0;
|
||||
@@ -399,7 +399,7 @@ public:
|
||||
|
||||
protected:
|
||||
// `TimingManager` callbacks
|
||||
Optional<void *> rootTimer() override;
|
||||
std::optional<void *> rootTimer() override;
|
||||
void startTimer(void *handle) override;
|
||||
void stopTimer(void *handle) override;
|
||||
void *nestTimer(void *handle, const void *id,
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
|
||||
/// Attach a note to this diagnostic.
|
||||
Diagnostic &attachNote(const Twine &msg,
|
||||
Optional<SMRange> noteLoc = std::nullopt) {
|
||||
std::optional<SMRange> noteLoc = std::nullopt) {
|
||||
assert(getSeverity() != Severity::DK_Note &&
|
||||
"cannot attach a Note to a Note");
|
||||
notes.emplace_back(
|
||||
@@ -129,7 +129,7 @@ private:
|
||||
DiagnosticEngine *owner = nullptr;
|
||||
|
||||
/// The raw diagnostic that is inflight to be reported.
|
||||
Optional<Diagnostic> impl;
|
||||
std::optional<Diagnostic> impl;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -510,7 +510,7 @@ public:
|
||||
ArrayRef<NamedAttributeDecl *> attributes);
|
||||
|
||||
/// Return the name of the operation, or std::nullopt if there isn't one.
|
||||
Optional<StringRef> getName() const;
|
||||
std::optional<StringRef> getName() const;
|
||||
|
||||
/// Return the declaration of the operation name.
|
||||
const OpNameDecl *getNameDecl() const { return nameDecl; }
|
||||
@@ -670,7 +670,7 @@ public:
|
||||
|
||||
/// Return the documentation comment attached to this decl if it has been set.
|
||||
/// Otherwise, returns std::nullopt.
|
||||
Optional<StringRef> getDocComment() const { return docComment; }
|
||||
std::optional<StringRef> getDocComment() const { return docComment; }
|
||||
|
||||
protected:
|
||||
Decl(TypeID typeID, SMRange loc, const Name *name = nullptr)
|
||||
@@ -683,7 +683,7 @@ private:
|
||||
|
||||
/// The documentation comment attached to this decl. Defaults to None if
|
||||
/// the comment is unset/unknown.
|
||||
Optional<StringRef> docComment;
|
||||
std::optional<StringRef> docComment;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -766,7 +766,7 @@ public:
|
||||
const OpNameDecl *nameDecl = nullptr);
|
||||
|
||||
/// Return the name of the operation, or std::nullopt if there isn't one.
|
||||
Optional<StringRef> getName() const;
|
||||
std::optional<StringRef> getName() const;
|
||||
|
||||
/// Return the declaration of the operation name.
|
||||
const OpNameDecl *getNameDecl() const { return nameDecl; }
|
||||
@@ -875,8 +875,9 @@ public:
|
||||
/// Create a native constraint with the given optional code block.
|
||||
static UserConstraintDecl *
|
||||
createNative(Context &ctx, const Name &name, ArrayRef<VariableDecl *> inputs,
|
||||
ArrayRef<VariableDecl *> results, Optional<StringRef> codeBlock,
|
||||
Type resultType, ArrayRef<StringRef> nativeInputTypes = {}) {
|
||||
ArrayRef<VariableDecl *> results,
|
||||
std::optional<StringRef> codeBlock, Type resultType,
|
||||
ArrayRef<StringRef> nativeInputTypes = {}) {
|
||||
return createImpl(ctx, name, inputs, nativeInputTypes, results, codeBlock,
|
||||
/*body=*/nullptr, resultType);
|
||||
}
|
||||
@@ -904,7 +905,7 @@ public:
|
||||
|
||||
/// Return the explicit native type to use for the given input. Returns
|
||||
/// std::nullopt if no explicit type was set.
|
||||
Optional<StringRef> getNativeInputType(unsigned index) const;
|
||||
std::optional<StringRef> getNativeInputType(unsigned index) const;
|
||||
|
||||
/// Return the explicit results of the constraint declaration. May be empty,
|
||||
/// even if the constraint has results (e.g. in the case of inferred results).
|
||||
@@ -917,7 +918,7 @@ public:
|
||||
|
||||
/// Return the optional code block of this constraint, if this is a native
|
||||
/// constraint with a provided implementation.
|
||||
Optional<StringRef> getCodeBlock() const { return codeBlock; }
|
||||
std::optional<StringRef> getCodeBlock() const { return codeBlock; }
|
||||
|
||||
/// Return the body of this constraint if this constraint is a PDLL
|
||||
/// constraint, otherwise returns nullptr.
|
||||
@@ -932,16 +933,18 @@ public:
|
||||
private:
|
||||
/// Create either a PDLL constraint or a native constraint with the given
|
||||
/// components.
|
||||
static UserConstraintDecl *
|
||||
createImpl(Context &ctx, const Name &name, ArrayRef<VariableDecl *> inputs,
|
||||
ArrayRef<StringRef> nativeInputTypes,
|
||||
ArrayRef<VariableDecl *> results, Optional<StringRef> codeBlock,
|
||||
const CompoundStmt *body, Type resultType);
|
||||
static UserConstraintDecl *createImpl(Context &ctx, const Name &name,
|
||||
ArrayRef<VariableDecl *> inputs,
|
||||
ArrayRef<StringRef> nativeInputTypes,
|
||||
ArrayRef<VariableDecl *> results,
|
||||
std::optional<StringRef> codeBlock,
|
||||
const CompoundStmt *body,
|
||||
Type resultType);
|
||||
|
||||
UserConstraintDecl(const Name &name, unsigned numInputs,
|
||||
bool hasNativeInputTypes, unsigned numResults,
|
||||
Optional<StringRef> codeBlock, const CompoundStmt *body,
|
||||
Type resultType)
|
||||
std::optional<StringRef> codeBlock,
|
||||
const CompoundStmt *body, Type resultType)
|
||||
: Base(name.getLoc(), &name), numInputs(numInputs),
|
||||
numResults(numResults), codeBlock(codeBlock), constraintBody(body),
|
||||
resultType(resultType), hasNativeInputTypes(hasNativeInputTypes) {}
|
||||
@@ -953,7 +956,7 @@ private:
|
||||
unsigned numResults;
|
||||
|
||||
/// The optional code block of this constraint.
|
||||
Optional<StringRef> codeBlock;
|
||||
std::optional<StringRef> codeBlock;
|
||||
|
||||
/// The optional body of this constraint.
|
||||
const CompoundStmt *constraintBody;
|
||||
@@ -1007,9 +1010,9 @@ public:
|
||||
static OpNameDecl *create(Context &ctx, SMRange loc);
|
||||
|
||||
/// Return the name of this operation, or none if the name is unknown.
|
||||
Optional<StringRef> getName() const {
|
||||
std::optional<StringRef> getName() const {
|
||||
const Name *name = Decl::getName();
|
||||
return name ? Optional<StringRef>(name->getName()) : std::nullopt;
|
||||
return name ? std::optional<StringRef>(name->getName()) : std::nullopt;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -1025,12 +1028,12 @@ private:
|
||||
class PatternDecl : public Node::NodeBase<PatternDecl, Decl> {
|
||||
public:
|
||||
static PatternDecl *create(Context &ctx, SMRange location, const Name *name,
|
||||
Optional<uint16_t> benefit,
|
||||
std::optional<uint16_t> benefit,
|
||||
bool hasBoundedRecursion,
|
||||
const CompoundStmt *body);
|
||||
|
||||
/// Return the benefit of this pattern if specified, or std::nullopt.
|
||||
Optional<uint16_t> getBenefit() const { return benefit; }
|
||||
std::optional<uint16_t> getBenefit() const { return benefit; }
|
||||
|
||||
/// Return if this pattern has bounded rewrite recursion.
|
||||
bool hasBoundedRewriteRecursion() const { return hasBoundedRecursion; }
|
||||
@@ -1044,13 +1047,13 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
PatternDecl(SMRange loc, const Name *name, Optional<uint16_t> benefit,
|
||||
PatternDecl(SMRange loc, const Name *name, std::optional<uint16_t> benefit,
|
||||
bool hasBoundedRecursion, const CompoundStmt *body)
|
||||
: Base(loc, name), benefit(benefit),
|
||||
hasBoundedRecursion(hasBoundedRecursion), patternBody(body) {}
|
||||
|
||||
/// The benefit of the pattern if it was explicitly specified, None otherwise.
|
||||
Optional<uint16_t> benefit;
|
||||
std::optional<uint16_t> benefit;
|
||||
|
||||
/// If the pattern has properly bounded rewrite recursion or not.
|
||||
bool hasBoundedRecursion;
|
||||
@@ -1082,7 +1085,7 @@ public:
|
||||
static UserRewriteDecl *createNative(Context &ctx, const Name &name,
|
||||
ArrayRef<VariableDecl *> inputs,
|
||||
ArrayRef<VariableDecl *> results,
|
||||
Optional<StringRef> codeBlock,
|
||||
std::optional<StringRef> codeBlock,
|
||||
Type resultType) {
|
||||
return createImpl(ctx, name, inputs, results, codeBlock, /*body=*/nullptr,
|
||||
resultType);
|
||||
@@ -1120,7 +1123,7 @@ public:
|
||||
|
||||
/// Return the optional code block of this rewrite, if this is a native
|
||||
/// rewrite with a provided implementation.
|
||||
Optional<StringRef> getCodeBlock() const { return codeBlock; }
|
||||
std::optional<StringRef> getCodeBlock() const { return codeBlock; }
|
||||
|
||||
/// Return the body of this rewrite if this rewrite is a PDLL rewrite,
|
||||
/// otherwise returns nullptr.
|
||||
@@ -1138,11 +1141,11 @@ private:
|
||||
static UserRewriteDecl *createImpl(Context &ctx, const Name &name,
|
||||
ArrayRef<VariableDecl *> inputs,
|
||||
ArrayRef<VariableDecl *> results,
|
||||
Optional<StringRef> codeBlock,
|
||||
std::optional<StringRef> codeBlock,
|
||||
const CompoundStmt *body, Type resultType);
|
||||
|
||||
UserRewriteDecl(const Name &name, unsigned numInputs, unsigned numResults,
|
||||
Optional<StringRef> codeBlock, const CompoundStmt *body,
|
||||
std::optional<StringRef> codeBlock, const CompoundStmt *body,
|
||||
Type resultType)
|
||||
: Base(name.getLoc(), &name), numInputs(numInputs),
|
||||
numResults(numResults), codeBlock(codeBlock), rewriteBody(body),
|
||||
@@ -1155,7 +1158,7 @@ private:
|
||||
unsigned numResults;
|
||||
|
||||
/// The optional code block of this rewrite.
|
||||
Optional<StringRef> codeBlock;
|
||||
std::optional<StringRef> codeBlock;
|
||||
|
||||
/// The optional body of this rewrite.
|
||||
const CompoundStmt *rewriteBody;
|
||||
@@ -1207,7 +1210,7 @@ public:
|
||||
|
||||
/// Return the optional code block of this callable, if this is a native
|
||||
/// callable with a provided implementation.
|
||||
Optional<StringRef> getCodeBlock() const {
|
||||
std::optional<StringRef> getCodeBlock() const {
|
||||
if (const auto *cst = dyn_cast<UserConstraintDecl>(this))
|
||||
return cst->getCodeBlock();
|
||||
return cast<UserRewriteDecl>(this)->getCodeBlock();
|
||||
|
||||
@@ -162,12 +162,12 @@ public:
|
||||
/// Return an instance of the Operation type with an optional operation name.
|
||||
/// If no name is provided, this type may refer to any operation.
|
||||
static OperationType get(Context &context,
|
||||
Optional<StringRef> name = std::nullopt,
|
||||
std::optional<StringRef> name = std::nullopt,
|
||||
const ods::Operation *odsOp = nullptr);
|
||||
|
||||
/// Return the name of this operation type, or std::nullopt if it doesn't have
|
||||
/// on.
|
||||
Optional<StringRef> getName() const;
|
||||
std::optional<StringRef> getName() const;
|
||||
|
||||
/// Return the ODS operation that this type refers to, or nullptr if the ODS
|
||||
/// operation is unknown.
|
||||
|
||||
@@ -77,12 +77,12 @@ public:
|
||||
|
||||
/// Signal code completion for the signature of an operation's operands.
|
||||
virtual void
|
||||
codeCompleteOperationOperandsSignature(Optional<StringRef> opName,
|
||||
codeCompleteOperationOperandsSignature(std::optional<StringRef> opName,
|
||||
unsigned currentNumOperands) {}
|
||||
|
||||
/// Signal code completion for the signature of an operation's results.
|
||||
virtual void
|
||||
codeCompleteOperationResultsSignature(Optional<StringRef> opName,
|
||||
codeCompleteOperationResultsSignature(std::optional<StringRef> opName,
|
||||
unsigned currentNumResults) {}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -62,7 +62,7 @@ class Translation {
|
||||
public:
|
||||
Translation() = default;
|
||||
Translation(TranslateFunction function, StringRef description,
|
||||
Optional<llvm::Align> inputAlignment)
|
||||
std::optional<llvm::Align> inputAlignment)
|
||||
: function(std::move(function)), description(description),
|
||||
inputAlignment(inputAlignment) {}
|
||||
|
||||
@@ -70,7 +70,9 @@ public:
|
||||
StringRef getDescription() const { return description; }
|
||||
|
||||
/// Return the optional alignment desired for the input of the translation.
|
||||
Optional<llvm::Align> getInputAlignment() const { return inputAlignment; }
|
||||
std::optional<llvm::Align> getInputAlignment() const {
|
||||
return inputAlignment;
|
||||
}
|
||||
|
||||
/// Invoke the translation function with the given input and output streams.
|
||||
LogicalResult operator()(const std::shared_ptr<llvm::SourceMgr> &sourceMgr,
|
||||
@@ -87,7 +89,7 @@ private:
|
||||
StringRef description;
|
||||
|
||||
/// An optional alignment desired for the input of the translation.
|
||||
Optional<llvm::Align> inputAlignment;
|
||||
std::optional<llvm::Align> inputAlignment;
|
||||
};
|
||||
|
||||
/// Use Translate[ToMLIR|FromMLIR]Registration as an initializer that
|
||||
@@ -111,19 +113,19 @@ struct TranslateToMLIRRegistration {
|
||||
const TranslateSourceMgrToMLIRFunction &function,
|
||||
const DialectRegistrationFunction &dialectRegistration =
|
||||
[](DialectRegistry &) {},
|
||||
Optional<llvm::Align> inputAlignment = std::nullopt);
|
||||
std::optional<llvm::Align> inputAlignment = std::nullopt);
|
||||
TranslateToMLIRRegistration(
|
||||
llvm::StringRef name, llvm::StringRef description,
|
||||
const TranslateRawSourceMgrToMLIRFunction &function,
|
||||
const DialectRegistrationFunction &dialectRegistration =
|
||||
[](DialectRegistry &) {},
|
||||
Optional<llvm::Align> inputAlignment = std::nullopt);
|
||||
std::optional<llvm::Align> inputAlignment = std::nullopt);
|
||||
TranslateToMLIRRegistration(
|
||||
llvm::StringRef name, llvm::StringRef description,
|
||||
const TranslateStringRefToMLIRFunction &function,
|
||||
const DialectRegistrationFunction &dialectRegistration =
|
||||
[](DialectRegistry &) {},
|
||||
Optional<llvm::Align> inputAlignment = std::nullopt);
|
||||
std::optional<llvm::Align> inputAlignment = std::nullopt);
|
||||
};
|
||||
|
||||
struct TranslateFromMLIRRegistration {
|
||||
|
||||
@@ -209,13 +209,13 @@ LogicalResult inlineRegion(InlinerInterface &interface, Region *src,
|
||||
Operation *inlinePoint, IRMapping &mapper,
|
||||
ValueRange resultsToReplace,
|
||||
TypeRange regionResultTypes,
|
||||
Optional<Location> inlineLoc = std::nullopt,
|
||||
std::optional<Location> inlineLoc = std::nullopt,
|
||||
bool shouldCloneInlinedRegion = true);
|
||||
LogicalResult inlineRegion(InlinerInterface &interface, Region *src,
|
||||
Block *inlineBlock, Block::iterator inlinePoint,
|
||||
IRMapping &mapper, ValueRange resultsToReplace,
|
||||
TypeRange regionResultTypes,
|
||||
Optional<Location> inlineLoc = std::nullopt,
|
||||
std::optional<Location> inlineLoc = std::nullopt,
|
||||
bool shouldCloneInlinedRegion = true);
|
||||
|
||||
/// This function is an overload of the above 'inlineRegion' that allows for
|
||||
@@ -224,13 +224,13 @@ LogicalResult inlineRegion(InlinerInterface &interface, Region *src,
|
||||
LogicalResult inlineRegion(InlinerInterface &interface, Region *src,
|
||||
Operation *inlinePoint, ValueRange inlinedOperands,
|
||||
ValueRange resultsToReplace,
|
||||
Optional<Location> inlineLoc = std::nullopt,
|
||||
std::optional<Location> inlineLoc = std::nullopt,
|
||||
bool shouldCloneInlinedRegion = true);
|
||||
LogicalResult inlineRegion(InlinerInterface &interface, Region *src,
|
||||
Block *inlineBlock, Block::iterator inlinePoint,
|
||||
ValueRange inlinedOperands,
|
||||
ValueRange resultsToReplace,
|
||||
Optional<Location> inlineLoc = std::nullopt,
|
||||
std::optional<Location> inlineLoc = std::nullopt,
|
||||
bool shouldCloneInlinedRegion = true);
|
||||
|
||||
/// This function inlines a given region, 'src', of a callable operation,
|
||||
|
||||
@@ -311,7 +311,7 @@ void DeadCodeAnalysis::visitCallOperation(CallOpInterface call) {
|
||||
/// Get the constant values of the operands of an operation. If any of the
|
||||
/// constant value lattices are uninitialized, return none to indicate the
|
||||
/// analysis should bail out.
|
||||
static Optional<SmallVector<Attribute>> getOperandValuesImpl(
|
||||
static std::optional<SmallVector<Attribute>> getOperandValuesImpl(
|
||||
Operation *op,
|
||||
function_ref<const Lattice<ConstantValue> *(Value)> getLattice) {
|
||||
SmallVector<Attribute> operands;
|
||||
@@ -326,7 +326,7 @@ static Optional<SmallVector<Attribute>> getOperandValuesImpl(
|
||||
return operands;
|
||||
}
|
||||
|
||||
Optional<SmallVector<Attribute>>
|
||||
std::optional<SmallVector<Attribute>>
|
||||
DeadCodeAnalysis::getOperandValues(Operation *op) {
|
||||
return getOperandValuesImpl(op, [&](Value value) {
|
||||
auto *lattice = getOrCreate<Lattice<ConstantValue>>(value);
|
||||
@@ -337,7 +337,7 @@ DeadCodeAnalysis::getOperandValues(Operation *op) {
|
||||
|
||||
void DeadCodeAnalysis::visitBranchOperation(BranchOpInterface branch) {
|
||||
// Try to deduce a single successor for the branch.
|
||||
Optional<SmallVector<Attribute>> operands = getOperandValues(branch);
|
||||
std::optional<SmallVector<Attribute>> operands = getOperandValues(branch);
|
||||
if (!operands)
|
||||
return;
|
||||
|
||||
@@ -353,7 +353,7 @@ void DeadCodeAnalysis::visitBranchOperation(BranchOpInterface branch) {
|
||||
void DeadCodeAnalysis::visitRegionBranchOperation(
|
||||
RegionBranchOpInterface branch) {
|
||||
// Try to deduce which regions are executable.
|
||||
Optional<SmallVector<Attribute>> operands = getOperandValues(branch);
|
||||
std::optional<SmallVector<Attribute>> operands = getOperandValues(branch);
|
||||
if (!operands)
|
||||
return;
|
||||
|
||||
@@ -377,7 +377,7 @@ void DeadCodeAnalysis::visitRegionBranchOperation(
|
||||
|
||||
void DeadCodeAnalysis::visitRegionTerminator(Operation *op,
|
||||
RegionBranchOpInterface branch) {
|
||||
Optional<SmallVector<Attribute>> operands = getOperandValues(op);
|
||||
std::optional<SmallVector<Attribute>> operands = getOperandValues(op);
|
||||
if (!operands)
|
||||
return;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ void IntegerValueRangeLattice::onUpdate(DataFlowSolver *solver) const {
|
||||
|
||||
// If the integer range can be narrowed to a constant, update the constant
|
||||
// value of the SSA value.
|
||||
Optional<APInt> constant = getValue().getValue().getConstantValue();
|
||||
std::optional<APInt> constant = getValue().getValue().getConstantValue();
|
||||
auto value = point.get<Value>();
|
||||
auto *cv = solver->getOrCreateState<Lattice<ConstantValue>>(value);
|
||||
if (!constant)
|
||||
|
||||
@@ -764,7 +764,8 @@ bool IntegerRelation::isIntegerEmpty() const { return !findIntegerSample(); }
|
||||
///
|
||||
/// Concatenating the samples from B and C gives a sample v in S*T, so the
|
||||
/// returned sample T*v is a sample in S.
|
||||
Optional<SmallVector<MPInt, 8>> IntegerRelation::findIntegerSample() const {
|
||||
std::optional<SmallVector<MPInt, 8>>
|
||||
IntegerRelation::findIntegerSample() const {
|
||||
// First, try the GCD test heuristic.
|
||||
if (isEmptyByGCDTest())
|
||||
return {};
|
||||
@@ -803,7 +804,7 @@ Optional<SmallVector<MPInt, 8>> IntegerRelation::findIntegerSample() const {
|
||||
boundedSet.removeVarRange(numBoundedDims, boundedSet.getNumVars());
|
||||
|
||||
// 3) Try to obtain a sample from the bounded set.
|
||||
Optional<SmallVector<MPInt, 8>> boundedSample =
|
||||
std::optional<SmallVector<MPInt, 8>> boundedSample =
|
||||
Simplex(boundedSet).findIntegerSample();
|
||||
if (!boundedSample)
|
||||
return {};
|
||||
@@ -902,7 +903,7 @@ bool IntegerRelation::containsPoint(ArrayRef<MPInt> point) const {
|
||||
/// compute the values of the locals that have division representations and
|
||||
/// only use the integer emptiness check for the locals that don't have this.
|
||||
/// Handling this correctly requires ordering the divs, though.
|
||||
Optional<SmallVector<MPInt, 8>>
|
||||
std::optional<SmallVector<MPInt, 8>>
|
||||
IntegerRelation::containsPointNoLocal(ArrayRef<MPInt> point) const {
|
||||
assert(point.size() == getNumVars() - getNumLocalVars() &&
|
||||
"Point should contain all vars except locals!");
|
||||
@@ -1081,7 +1082,7 @@ void IntegerRelation::removeRedundantConstraints() {
|
||||
equalities.resizeVertically(pos);
|
||||
}
|
||||
|
||||
Optional<MPInt> IntegerRelation::computeVolume() const {
|
||||
std::optional<MPInt> IntegerRelation::computeVolume() const {
|
||||
assert(getNumSymbolVars() == 0 && "Symbols are not yet supported!");
|
||||
|
||||
Simplex simplex(*this);
|
||||
@@ -1391,7 +1392,7 @@ void IntegerRelation::constantFoldVarRange(unsigned pos, unsigned num) {
|
||||
// s0 + s1 + 16 <= d0 <= s0 + s1 + 31, returns 16.
|
||||
// s0 - 7 <= 8*j <= s0 returns 1 with lb = s0, lbDivisor = 8 (since lb =
|
||||
// ceil(s0 - 7 / 8) = floor(s0 / 8)).
|
||||
Optional<MPInt> IntegerRelation::getConstantBoundOnDimSize(
|
||||
std::optional<MPInt> IntegerRelation::getConstantBoundOnDimSize(
|
||||
unsigned pos, SmallVectorImpl<MPInt> *lb, MPInt *boundFloorDivisor,
|
||||
SmallVectorImpl<MPInt> *ub, unsigned *minLbPos, unsigned *minUbPos) const {
|
||||
assert(pos < getNumDimVars() && "Invalid variable position");
|
||||
@@ -1456,7 +1457,7 @@ Optional<MPInt> IntegerRelation::getConstantBoundOnDimSize(
|
||||
/*eqIndices=*/nullptr, /*offset=*/0,
|
||||
/*num=*/getNumDimVars());
|
||||
|
||||
Optional<MPInt> minDiff;
|
||||
std::optional<MPInt> minDiff;
|
||||
unsigned minLbPosition = 0, minUbPosition = 0;
|
||||
for (auto ubPos : ubIndices) {
|
||||
for (auto lbPos : lbIndices) {
|
||||
@@ -1517,7 +1518,7 @@ Optional<MPInt> IntegerRelation::getConstantBoundOnDimSize(
|
||||
}
|
||||
|
||||
template <bool isLower>
|
||||
Optional<MPInt>
|
||||
std::optional<MPInt>
|
||||
IntegerRelation::computeConstantLowerOrUpperBound(unsigned pos) {
|
||||
assert(pos < getNumVars() && "invalid position");
|
||||
// Project to 'pos'.
|
||||
@@ -1539,7 +1540,7 @@ IntegerRelation::computeConstantLowerOrUpperBound(unsigned pos) {
|
||||
// If it doesn't, there isn't a bound on it.
|
||||
return std::nullopt;
|
||||
|
||||
Optional<MPInt> minOrMaxConst;
|
||||
std::optional<MPInt> minOrMaxConst;
|
||||
|
||||
// Take the max across all const lower bounds (or min across all constant
|
||||
// upper bounds).
|
||||
@@ -1574,8 +1575,8 @@ IntegerRelation::computeConstantLowerOrUpperBound(unsigned pos) {
|
||||
return minOrMaxConst;
|
||||
}
|
||||
|
||||
Optional<MPInt> IntegerRelation::getConstantBound(BoundType type,
|
||||
unsigned pos) const {
|
||||
std::optional<MPInt> IntegerRelation::getConstantBound(BoundType type,
|
||||
unsigned pos) const {
|
||||
if (type == BoundType::LB)
|
||||
return IntegerRelation(*this)
|
||||
.computeConstantLowerOrUpperBound</*isLower=*/true>(pos);
|
||||
@@ -1584,13 +1585,13 @@ Optional<MPInt> IntegerRelation::getConstantBound(BoundType type,
|
||||
.computeConstantLowerOrUpperBound</*isLower=*/false>(pos);
|
||||
|
||||
assert(type == BoundType::EQ && "expected EQ");
|
||||
Optional<MPInt> lb =
|
||||
std::optional<MPInt> lb =
|
||||
IntegerRelation(*this).computeConstantLowerOrUpperBound</*isLower=*/true>(
|
||||
pos);
|
||||
Optional<MPInt> ub =
|
||||
std::optional<MPInt> ub =
|
||||
IntegerRelation(*this)
|
||||
.computeConstantLowerOrUpperBound</*isLower=*/false>(pos);
|
||||
return (lb && ub && *lb == *ub) ? Optional<MPInt>(*ub) : std::nullopt;
|
||||
return (lb && ub && *lb == *ub) ? std::optional<MPInt>(*ub) : std::nullopt;
|
||||
}
|
||||
|
||||
// A simple (naive and conservative) check for hyper-rectangularity.
|
||||
|
||||
@@ -63,11 +63,11 @@ MultiAffineFunction::valueAt(ArrayRef<MPInt> point) const {
|
||||
|
||||
SmallVector<MPInt, 8> pointHomogenous{llvm::to_vector(point)};
|
||||
// Get the division values at this point.
|
||||
SmallVector<Optional<MPInt>, 8> divValues = divs.divValuesAt(point);
|
||||
SmallVector<std::optional<MPInt>, 8> divValues = divs.divValuesAt(point);
|
||||
// The given point didn't include the values of the divs which the output is a
|
||||
// function of; we have computed one possible set of values and use them here.
|
||||
pointHomogenous.reserve(pointHomogenous.size() + divValues.size());
|
||||
for (const Optional<MPInt> &divVal : divValues)
|
||||
for (const std::optional<MPInt> &divVal : divValues)
|
||||
pointHomogenous.push_back(*divVal);
|
||||
// The matrix `output` has an affine expression in the ith row, corresponding
|
||||
// to the expression for the ith value in the output vector. The last column
|
||||
@@ -424,7 +424,7 @@ void PWMAFunction::removeOutputs(unsigned start, unsigned end) {
|
||||
piece.output.removeOutputs(start, end);
|
||||
}
|
||||
|
||||
Optional<SmallVector<MPInt, 8>>
|
||||
std::optional<SmallVector<MPInt, 8>>
|
||||
PWMAFunction::valueAt(ArrayRef<MPInt> point) const {
|
||||
assert(point.size() == getNumDomainVars() + getNumSymbolVars());
|
||||
|
||||
|
||||
@@ -463,7 +463,8 @@ bool PresburgerRelation::isIntegerEmpty() const {
|
||||
bool PresburgerRelation::findIntegerSample(SmallVectorImpl<MPInt> &sample) {
|
||||
// A sample exists iff any of the disjuncts contains a sample.
|
||||
for (const IntegerRelation &disjunct : disjuncts) {
|
||||
if (Optional<SmallVector<MPInt, 8>> opt = disjunct.findIntegerSample()) {
|
||||
if (std::optional<SmallVector<MPInt, 8>> opt =
|
||||
disjunct.findIntegerSample()) {
|
||||
sample = std::move(*opt);
|
||||
return true;
|
||||
}
|
||||
@@ -471,13 +472,13 @@ bool PresburgerRelation::findIntegerSample(SmallVectorImpl<MPInt> &sample) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<MPInt> PresburgerRelation::computeVolume() const {
|
||||
std::optional<MPInt> PresburgerRelation::computeVolume() const {
|
||||
assert(getNumSymbolVars() == 0 && "Symbols are not yet supported!");
|
||||
// The sum of the volumes of the disjuncts is a valid overapproximation of the
|
||||
// volume of their union, even if they overlap.
|
||||
MPInt result(0);
|
||||
for (const IntegerRelation &disjunct : disjuncts) {
|
||||
Optional<MPInt> volume = disjunct.computeVolume();
|
||||
std::optional<MPInt> volume = disjunct.computeVolume();
|
||||
if (!volume)
|
||||
return {};
|
||||
result += *volume;
|
||||
|
||||
@@ -272,7 +272,7 @@ LogicalResult LexSimplexBase::addCut(unsigned row) {
|
||||
return moveRowUnknownToColumn(cutRow);
|
||||
}
|
||||
|
||||
Optional<unsigned> LexSimplex::maybeGetNonIntegralVarRow() const {
|
||||
std::optional<unsigned> LexSimplex::maybeGetNonIntegralVarRow() const {
|
||||
for (const Unknown &u : var) {
|
||||
if (u.orientation == Orientation::Column)
|
||||
continue;
|
||||
@@ -292,7 +292,7 @@ MaybeOptimum<SmallVector<MPInt, 8>> LexSimplex::findIntegerLexMin() {
|
||||
return OptimumKind::Empty;
|
||||
|
||||
// Then, if the sample value is integral, we are done.
|
||||
while (Optional<unsigned> maybeRow = maybeGetNonIntegralVarRow()) {
|
||||
while (std::optional<unsigned> maybeRow = maybeGetNonIntegralVarRow()) {
|
||||
// Otherwise, for the variable whose row has a non-integral sample value,
|
||||
// we add a cut, a constraint that remove this rational point
|
||||
// while preserving all integer points, thus keeping the lexmin the same.
|
||||
@@ -478,7 +478,7 @@ void SymbolicLexSimplex::recordOutput(SymbolicLexMin &result) const {
|
||||
MultiAffineFunction(funcSpace, output, domainPoly.getLocalReprs())});
|
||||
}
|
||||
|
||||
Optional<unsigned> SymbolicLexSimplex::maybeGetAlwaysViolatedRow() {
|
||||
std::optional<unsigned> SymbolicLexSimplex::maybeGetAlwaysViolatedRow() {
|
||||
// First look for rows that are clearly violated just from the big M
|
||||
// coefficient, without needing to perform any simplex queries on the domain.
|
||||
for (unsigned row = 0, e = getNumRows(); row < e; ++row)
|
||||
@@ -496,7 +496,7 @@ Optional<unsigned> SymbolicLexSimplex::maybeGetAlwaysViolatedRow() {
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<unsigned> SymbolicLexSimplex::maybeGetNonIntegralVarRow() {
|
||||
std::optional<unsigned> SymbolicLexSimplex::maybeGetNonIntegralVarRow() {
|
||||
for (const Unknown &u : var) {
|
||||
if (u.orientation == Orientation::Column)
|
||||
continue;
|
||||
@@ -510,7 +510,7 @@ Optional<unsigned> SymbolicLexSimplex::maybeGetNonIntegralVarRow() {
|
||||
/// The non-branching pivots are just the ones moving the rows
|
||||
/// that are always violated in the symbol domain.
|
||||
LogicalResult SymbolicLexSimplex::doNonBranchingPivots() {
|
||||
while (Optional<unsigned> row = maybeGetAlwaysViolatedRow())
|
||||
while (std::optional<unsigned> row = maybeGetAlwaysViolatedRow())
|
||||
if (moveRowUnknownToColumn(*row).failed())
|
||||
return failure();
|
||||
return success();
|
||||
@@ -612,7 +612,7 @@ SymbolicLexMin SymbolicLexSimplex::computeSymbolicIntegerLexMin() {
|
||||
|
||||
// The tableau is rationally consistent for the current domain.
|
||||
// Now we look for non-integral sample values and add cuts for them.
|
||||
if (Optional<unsigned> row = maybeGetNonIntegralVarRow()) {
|
||||
if (std::optional<unsigned> row = maybeGetNonIntegralVarRow()) {
|
||||
if (addSymbolicCut(*row).failed()) {
|
||||
// No integral points; return.
|
||||
--level;
|
||||
@@ -675,7 +675,7 @@ bool LexSimplex::rowIsViolated(unsigned row) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<unsigned> LexSimplex::maybeGetViolatedRow() const {
|
||||
std::optional<unsigned> LexSimplex::maybeGetViolatedRow() const {
|
||||
for (unsigned row = 0, e = getNumRows(); row < e; ++row)
|
||||
if (rowIsViolated(row))
|
||||
return row;
|
||||
@@ -688,7 +688,7 @@ Optional<unsigned> LexSimplex::maybeGetViolatedRow() const {
|
||||
LogicalResult LexSimplex::restoreRationalConsistency() {
|
||||
if (empty)
|
||||
return failure();
|
||||
while (Optional<unsigned> maybeViolatedRow = maybeGetViolatedRow())
|
||||
while (std::optional<unsigned> maybeViolatedRow = maybeGetViolatedRow())
|
||||
if (moveRowUnknownToColumn(*maybeViolatedRow).failed())
|
||||
return failure();
|
||||
return success();
|
||||
@@ -865,8 +865,8 @@ unsigned LexSimplexBase::getLexMinPivotColumn(unsigned row, unsigned colA,
|
||||
///
|
||||
/// If multiple columns are valid, we break ties by considering a lexicographic
|
||||
/// ordering where we prefer unknowns with lower index.
|
||||
Optional<SimplexBase::Pivot> Simplex::findPivot(int row,
|
||||
Direction direction) const {
|
||||
std::optional<SimplexBase::Pivot>
|
||||
Simplex::findPivot(int row, Direction direction) const {
|
||||
std::optional<unsigned> col;
|
||||
for (unsigned j = 2, e = getNumColumns(); j < e; ++j) {
|
||||
MPInt elem = tableau(row, j);
|
||||
@@ -885,7 +885,7 @@ Optional<SimplexBase::Pivot> Simplex::findPivot(int row,
|
||||
|
||||
Direction newDirection =
|
||||
tableau(row, *col) < 0 ? flippedDirection(direction) : direction;
|
||||
Optional<unsigned> maybePivotRow = findPivotRow(row, newDirection, *col);
|
||||
std::optional<unsigned> maybePivotRow = findPivotRow(row, newDirection, *col);
|
||||
return Pivot{maybePivotRow.value_or(row), *col};
|
||||
}
|
||||
|
||||
@@ -977,7 +977,7 @@ LogicalResult Simplex::restoreRow(Unknown &u) {
|
||||
"unknown should be in row position");
|
||||
|
||||
while (tableau(u.pos, 1) < 0) {
|
||||
Optional<Pivot> maybePivot = findPivot(u.pos, Direction::Up);
|
||||
std::optional<Pivot> maybePivot = findPivot(u.pos, Direction::Up);
|
||||
if (!maybePivot)
|
||||
break;
|
||||
|
||||
@@ -1010,10 +1010,10 @@ LogicalResult Simplex::restoreRow(Unknown &u) {
|
||||
/// 0 and hence saturates the bound it imposes. We break ties between rows that
|
||||
/// impose the same bound by considering a lexicographic ordering where we
|
||||
/// prefer unknowns with lower index value.
|
||||
Optional<unsigned> Simplex::findPivotRow(Optional<unsigned> skipRow,
|
||||
Direction direction,
|
||||
unsigned col) const {
|
||||
Optional<unsigned> retRow;
|
||||
std::optional<unsigned> Simplex::findPivotRow(std::optional<unsigned> skipRow,
|
||||
Direction direction,
|
||||
unsigned col) const {
|
||||
std::optional<unsigned> retRow;
|
||||
// Initialize these to zero in order to silence a warning about retElem and
|
||||
// retConst being used uninitialized in the initialization of `diff` below. In
|
||||
// reality, these are always initialized when that line is reached since these
|
||||
@@ -1152,7 +1152,7 @@ void SimplexBase::removeLastConstraintRowOrientation() {
|
||||
//
|
||||
// If we have a variable, then the column has zero coefficients for every row
|
||||
// iff no constraints have been added with a non-zero coefficient for this row.
|
||||
Optional<unsigned> SimplexBase::findAnyPivotRow(unsigned col) {
|
||||
std::optional<unsigned> SimplexBase::findAnyPivotRow(unsigned col) {
|
||||
for (unsigned row = nRedundant, e = getNumRows(); row < e; ++row)
|
||||
if (tableau(row, col) != 0)
|
||||
return row;
|
||||
@@ -1173,13 +1173,14 @@ void Simplex::undoLastConstraint() {
|
||||
// coefficient for the column. findAnyPivotRow will always be able to
|
||||
// find such a row for a constraint.
|
||||
unsigned column = con.back().pos;
|
||||
if (Optional<unsigned> maybeRow = findPivotRow({}, Direction::Up, column)) {
|
||||
if (std::optional<unsigned> maybeRow =
|
||||
findPivotRow({}, Direction::Up, column)) {
|
||||
pivot(*maybeRow, column);
|
||||
} else if (Optional<unsigned> maybeRow =
|
||||
} else if (std::optional<unsigned> maybeRow =
|
||||
findPivotRow({}, Direction::Down, column)) {
|
||||
pivot(*maybeRow, column);
|
||||
} else {
|
||||
Optional<unsigned> row = findAnyPivotRow(column);
|
||||
std::optional<unsigned> row = findAnyPivotRow(column);
|
||||
assert(row && "Pivot should always exist for a constraint!");
|
||||
pivot(*row, column);
|
||||
}
|
||||
@@ -1198,7 +1199,7 @@ void LexSimplexBase::undoLastConstraint() {
|
||||
// snapshot, so what pivots we perform while undoing doesn't matter as
|
||||
// long as we get the unknown to row orientation and remove it.
|
||||
unsigned column = con.back().pos;
|
||||
Optional<unsigned> row = findAnyPivotRow(column);
|
||||
std::optional<unsigned> row = findAnyPivotRow(column);
|
||||
assert(row && "Pivot should always exist for a constraint!");
|
||||
pivot(*row, column);
|
||||
}
|
||||
@@ -1324,7 +1325,7 @@ void SimplexBase::intersectIntegerRelation(const IntegerRelation &rel) {
|
||||
MaybeOptimum<Fraction> Simplex::computeRowOptimum(Direction direction,
|
||||
unsigned row) {
|
||||
// Keep trying to find a pivot for the row in the specified direction.
|
||||
while (Optional<Pivot> maybePivot = findPivot(row, direction)) {
|
||||
while (std::optional<Pivot> maybePivot = findPivot(row, direction)) {
|
||||
// If findPivot returns a pivot involving the row itself, then the optimum
|
||||
// is unbounded, so we return std::nullopt.
|
||||
if (maybePivot->row == row)
|
||||
@@ -1357,7 +1358,7 @@ MaybeOptimum<Fraction> Simplex::computeOptimum(Direction direction,
|
||||
return OptimumKind::Empty;
|
||||
if (u.orientation == Orientation::Column) {
|
||||
unsigned column = u.pos;
|
||||
Optional<unsigned> pivotRow = findPivotRow({}, direction, column);
|
||||
std::optional<unsigned> pivotRow = findPivotRow({}, direction, column);
|
||||
// If no pivot is returned, the constraint is unbounded in the specified
|
||||
// direction.
|
||||
if (!pivotRow)
|
||||
@@ -1424,7 +1425,8 @@ void Simplex::detectRedundant(unsigned offset, unsigned count) {
|
||||
Unknown &u = con[offset + i];
|
||||
if (u.orientation == Orientation::Column) {
|
||||
unsigned column = u.pos;
|
||||
Optional<unsigned> pivotRow = findPivotRow({}, Direction::Down, column);
|
||||
std::optional<unsigned> pivotRow =
|
||||
findPivotRow({}, Direction::Down, column);
|
||||
// If no downward pivot is returned, the constraint is unbounded below
|
||||
// and hence not redundant.
|
||||
if (!pivotRow)
|
||||
@@ -1546,7 +1548,7 @@ Simplex Simplex::makeProduct(const Simplex &a, const Simplex &b) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Optional<SmallVector<Fraction, 8>> Simplex::getRationalSample() const {
|
||||
std::optional<SmallVector<Fraction, 8>> Simplex::getRationalSample() const {
|
||||
if (empty)
|
||||
return {};
|
||||
|
||||
@@ -1601,7 +1603,7 @@ MaybeOptimum<SmallVector<Fraction, 8>> LexSimplex::getRationalSample() const {
|
||||
return sample;
|
||||
}
|
||||
|
||||
Optional<SmallVector<MPInt, 8>> Simplex::getSamplePointIfIntegral() const {
|
||||
std::optional<SmallVector<MPInt, 8>> Simplex::getSamplePointIfIntegral() const {
|
||||
// If the tableau is empty, no sample point exists.
|
||||
if (empty)
|
||||
return {};
|
||||
@@ -1969,7 +1971,7 @@ void Simplex::reduceBasis(Matrix &basis, unsigned level) {
|
||||
///
|
||||
/// To avoid potentially arbitrarily large recursion depths leading to stack
|
||||
/// overflows, this algorithm is implemented iteratively.
|
||||
Optional<SmallVector<MPInt, 8>> Simplex::findIntegerSample() {
|
||||
std::optional<SmallVector<MPInt, 8>> Simplex::findIntegerSample() {
|
||||
if (empty)
|
||||
return {};
|
||||
|
||||
|
||||
@@ -378,11 +378,11 @@ SmallVector<MPInt, 8> presburger::getComplementIneq(ArrayRef<MPInt> ineq) {
|
||||
return coeffs;
|
||||
}
|
||||
|
||||
SmallVector<Optional<MPInt>, 4>
|
||||
SmallVector<std::optional<MPInt>, 4>
|
||||
DivisionRepr::divValuesAt(ArrayRef<MPInt> point) const {
|
||||
assert(point.size() == getNumNonDivs() && "Incorrect point size");
|
||||
|
||||
SmallVector<Optional<MPInt>, 4> divValues(getNumDivs(), std::nullopt);
|
||||
SmallVector<std::optional<MPInt>, 4> divValues(getNumDivs(), std::nullopt);
|
||||
bool changed = true;
|
||||
while (changed) {
|
||||
changed = false;
|
||||
|
||||
@@ -287,7 +287,7 @@ public:
|
||||
|
||||
// Check for a hexadecimal float value.
|
||||
if (curTok.is(Token::integer)) {
|
||||
Optional<APFloat> apResult;
|
||||
std::optional<APFloat> apResult;
|
||||
if (failed(parser.parseFloatFromIntegerLiteral(
|
||||
apResult, curTok, isNegative, APFloat::IEEEdouble(),
|
||||
/*typeSizeInBits=*/64)))
|
||||
|
||||
@@ -356,8 +356,8 @@ Attribute Parser::parseFloatAttr(Type type, bool isNegative) {
|
||||
|
||||
/// Construct an APint from a parsed value, a known attribute type and
|
||||
/// sign.
|
||||
static Optional<APInt> buildAttributeAPInt(Type type, bool isNegative,
|
||||
StringRef spelling) {
|
||||
static std::optional<APInt> buildAttributeAPInt(Type type, bool isNegative,
|
||||
StringRef spelling) {
|
||||
// Parse the integer value into an APInt that is big enough to hold the value.
|
||||
APInt result;
|
||||
bool isHex = spelling.size() > 1 && spelling[1] == 'x';
|
||||
@@ -417,7 +417,7 @@ Attribute Parser::parseDecOrHexAttr(Type type, bool isNegative) {
|
||||
}
|
||||
|
||||
if (auto floatType = type.dyn_cast<FloatType>()) {
|
||||
Optional<APFloat> result;
|
||||
std::optional<APFloat> result;
|
||||
if (failed(parseFloatFromIntegerLiteral(result, tok, isNegative,
|
||||
floatType.getFloatSemantics(),
|
||||
floatType.getWidth())))
|
||||
@@ -435,7 +435,7 @@ Attribute Parser::parseDecOrHexAttr(Type type, bool isNegative) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Optional<APInt> apInt = buildAttributeAPInt(type, isNegative, spelling);
|
||||
std::optional<APInt> apInt = buildAttributeAPInt(type, isNegative, spelling);
|
||||
if (!apInt)
|
||||
return emitError(loc, "integer constant out of range for attribute"),
|
||||
nullptr;
|
||||
@@ -450,7 +450,7 @@ Attribute Parser::parseDecOrHexAttr(Type type, bool isNegative) {
|
||||
/// stored into 'result'.
|
||||
static ParseResult parseElementAttrHexValues(Parser &parser, Token tok,
|
||||
std::string &result) {
|
||||
if (Optional<std::string> value = tok.getHexStringValue()) {
|
||||
if (std::optional<std::string> value = tok.getHexStringValue()) {
|
||||
result = std::move(*value);
|
||||
return success();
|
||||
}
|
||||
@@ -636,7 +636,7 @@ TensorLiteralParser::getIntAttrElements(SMLoc loc, Type eltTy,
|
||||
}
|
||||
|
||||
// Create APInt values for each element with the correct bitwidth.
|
||||
Optional<APInt> apInt =
|
||||
std::optional<APInt> apInt =
|
||||
buildAttributeAPInt(eltTy, isNegative, token.getSpelling());
|
||||
if (!apInt)
|
||||
return p.emitError(tokenLoc, "integer constant out of range for type");
|
||||
@@ -656,7 +656,7 @@ TensorLiteralParser::getFloatAttrElements(SMLoc loc, FloatType eltTy,
|
||||
|
||||
// Handle hexadecimal float literals.
|
||||
if (token.is(Token::integer) && token.getSpelling().startswith("0x")) {
|
||||
Optional<APFloat> result;
|
||||
std::optional<APFloat> result;
|
||||
if (failed(p.parseFloatFromIntegerLiteral(result, token, isNegative,
|
||||
eltTy.getFloatSemantics(),
|
||||
eltTy.getWidth())))
|
||||
@@ -880,7 +880,7 @@ ParseResult DenseArrayElementParser::parseIntegerElement(Parser &p) {
|
||||
bool isNegative = p.consumeIf(Token::minus);
|
||||
|
||||
// Parse an integer literal as an APInt.
|
||||
Optional<APInt> value;
|
||||
std::optional<APInt> value;
|
||||
StringRef spelling = p.getToken().getSpelling();
|
||||
if (p.getToken().isAny(Token::kw_true, Token::kw_false)) {
|
||||
if (!type.isInteger(1))
|
||||
@@ -903,7 +903,7 @@ ParseResult DenseArrayElementParser::parseFloatElement(Parser &p) {
|
||||
bool isNegative = p.consumeIf(Token::minus);
|
||||
|
||||
Token token = p.getToken();
|
||||
Optional<APFloat> result;
|
||||
std::optional<APFloat> result;
|
||||
auto floatType = type.cast<FloatType>();
|
||||
if (p.consumeIf(Token::integer)) {
|
||||
// Parse an integer literal as a float.
|
||||
@@ -913,7 +913,7 @@ ParseResult DenseArrayElementParser::parseFloatElement(Parser &p) {
|
||||
return failure();
|
||||
} else if (p.consumeIf(Token::floatliteral)) {
|
||||
// Parse a floating point literal.
|
||||
Optional<double> val = token.getFloatingPointValue();
|
||||
std::optional<double> val = token.getFloatingPointValue();
|
||||
if (!val)
|
||||
return failure();
|
||||
result = APFloat(isNegative ? -*val : *val);
|
||||
@@ -1150,7 +1150,7 @@ Attribute Parser::parseStridedLayoutAttr() {
|
||||
// Parses either an integer token or a question mark token. Reports an error
|
||||
// and returns std::nullopt if the current token is neither. The integer token
|
||||
// must fit into int64_t limits.
|
||||
auto parseStrideOrOffset = [&]() -> Optional<int64_t> {
|
||||
auto parseStrideOrOffset = [&]() -> std::optional<int64_t> {
|
||||
if (consumeIf(Token::question))
|
||||
return ShapedType::kDynamic;
|
||||
|
||||
@@ -1163,7 +1163,7 @@ Attribute Parser::parseStridedLayoutAttr() {
|
||||
bool negative = consumeIf(Token::minus);
|
||||
|
||||
if (getToken().is(Token::integer)) {
|
||||
Optional<uint64_t> value = getToken().getUInt64IntegerValue();
|
||||
std::optional<uint64_t> value = getToken().getUInt64IntegerValue();
|
||||
if (!value ||
|
||||
*value > static_cast<uint64_t>(std::numeric_limits<int64_t>::max()))
|
||||
return emitWrongTokenError();
|
||||
@@ -1182,7 +1182,7 @@ Attribute Parser::parseStridedLayoutAttr() {
|
||||
SmallVector<int64_t> strides;
|
||||
if (!getToken().is(Token::r_square)) {
|
||||
do {
|
||||
Optional<int64_t> stride = parseStrideOrOffset();
|
||||
std::optional<int64_t> stride = parseStrideOrOffset();
|
||||
if (!stride)
|
||||
return nullptr;
|
||||
strides.push_back(*stride);
|
||||
@@ -1205,7 +1205,7 @@ Attribute Parser::parseStridedLayoutAttr() {
|
||||
failed(parseToken(Token::colon, "expected ':' after 'offset'")))
|
||||
return nullptr;
|
||||
|
||||
Optional<int64_t> offset = parseStrideOrOffset();
|
||||
std::optional<int64_t> offset = parseStrideOrOffset();
|
||||
if (!offset || failed(parseToken(Token::greater, "expected '>'")))
|
||||
return nullptr;
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ OptionalParseResult Parser::parseOptionalInteger(APInt &result) {
|
||||
|
||||
/// Parse a floating point value from an integer literal token.
|
||||
ParseResult Parser::parseFloatFromIntegerLiteral(
|
||||
Optional<APFloat> &result, const Token &tok, bool isNegative,
|
||||
std::optional<APFloat> &result, const Token &tok, bool isNegative,
|
||||
const llvm::fltSemantics &semantics, size_t typeSizeInBits) {
|
||||
SMLoc loc = tok.getLoc();
|
||||
StringRef spelling = tok.getSpelling();
|
||||
@@ -292,7 +292,7 @@ ParseResult Parser::parseFloatFromIntegerLiteral(
|
||||
"leading minus");
|
||||
}
|
||||
|
||||
Optional<uint64_t> value = tok.getUInt64IntegerValue();
|
||||
std::optional<uint64_t> value = tok.getUInt64IntegerValue();
|
||||
if (!value)
|
||||
return emitError(loc, "hexadecimal float constant out of range for type");
|
||||
|
||||
@@ -534,12 +534,13 @@ public:
|
||||
/// skip parsing that component.
|
||||
ParseResult parseGenericOperationAfterOpName(
|
||||
OperationState &result,
|
||||
Optional<ArrayRef<UnresolvedOperand>> parsedOperandUseInfo = std::nullopt,
|
||||
Optional<ArrayRef<Block *>> parsedSuccessors = std::nullopt,
|
||||
Optional<MutableArrayRef<std::unique_ptr<Region>>> parsedRegions =
|
||||
std::optional<ArrayRef<UnresolvedOperand>> parsedOperandUseInfo =
|
||||
std::nullopt,
|
||||
Optional<ArrayRef<NamedAttribute>> parsedAttributes = std::nullopt,
|
||||
Optional<FunctionType> parsedFnType = std::nullopt);
|
||||
std::optional<ArrayRef<Block *>> parsedSuccessors = std::nullopt,
|
||||
std::optional<MutableArrayRef<std::unique_ptr<Region>>> parsedRegions =
|
||||
std::nullopt,
|
||||
std::optional<ArrayRef<NamedAttribute>> parsedAttributes = std::nullopt,
|
||||
std::optional<FunctionType> parsedFnType = std::nullopt);
|
||||
|
||||
/// Parse an operation instance that is in the generic form and insert it at
|
||||
/// the provided insertion point.
|
||||
@@ -1250,11 +1251,11 @@ struct CleanupOpStateRegions {
|
||||
|
||||
ParseResult OperationParser::parseGenericOperationAfterOpName(
|
||||
OperationState &result,
|
||||
Optional<ArrayRef<UnresolvedOperand>> parsedOperandUseInfo,
|
||||
Optional<ArrayRef<Block *>> parsedSuccessors,
|
||||
Optional<MutableArrayRef<std::unique_ptr<Region>>> parsedRegions,
|
||||
Optional<ArrayRef<NamedAttribute>> parsedAttributes,
|
||||
Optional<FunctionType> parsedFnType) {
|
||||
std::optional<ArrayRef<UnresolvedOperand>> parsedOperandUseInfo,
|
||||
std::optional<ArrayRef<Block *>> parsedSuccessors,
|
||||
std::optional<MutableArrayRef<std::unique_ptr<Region>>> parsedRegions,
|
||||
std::optional<ArrayRef<NamedAttribute>> parsedAttributes,
|
||||
std::optional<FunctionType> parsedFnType) {
|
||||
|
||||
// Parse the operand list, if not explicitly provided.
|
||||
SmallVector<UnresolvedOperand, 8> opInfo;
|
||||
@@ -1436,7 +1437,8 @@ public:
|
||||
// This can happen if an attribute set during parsing is also specified in
|
||||
// the attribute dictionary in the assembly, or the attribute is set
|
||||
// multiple during parsing.
|
||||
Optional<NamedAttribute> duplicate = opState.attributes.findDuplicate();
|
||||
std::optional<NamedAttribute> duplicate =
|
||||
opState.attributes.findDuplicate();
|
||||
if (duplicate)
|
||||
return emitError(getNameLoc(), "attribute '")
|
||||
<< duplicate->getName().getValue()
|
||||
@@ -1455,11 +1457,11 @@ public:
|
||||
|
||||
ParseResult parseGenericOperationAfterOpName(
|
||||
OperationState &result,
|
||||
Optional<ArrayRef<UnresolvedOperand>> parsedUnresolvedOperands,
|
||||
Optional<ArrayRef<Block *>> parsedSuccessors,
|
||||
Optional<MutableArrayRef<std::unique_ptr<Region>>> parsedRegions,
|
||||
Optional<ArrayRef<NamedAttribute>> parsedAttributes,
|
||||
Optional<FunctionType> parsedFnType) final {
|
||||
std::optional<ArrayRef<UnresolvedOperand>> parsedUnresolvedOperands,
|
||||
std::optional<ArrayRef<Block *>> parsedSuccessors,
|
||||
std::optional<MutableArrayRef<std::unique_ptr<Region>>> parsedRegions,
|
||||
std::optional<ArrayRef<NamedAttribute>> parsedAttributes,
|
||||
std::optional<FunctionType> parsedFnType) final {
|
||||
return parser.parseGenericOperationAfterOpName(
|
||||
result, parsedUnresolvedOperands, parsedSuccessors, parsedRegions,
|
||||
parsedAttributes, parsedFnType);
|
||||
@@ -1777,7 +1779,7 @@ public:
|
||||
|
||||
/// Parse a loc(...) specifier if present, filling in result if so.
|
||||
ParseResult
|
||||
parseOptionalLocationSpecifier(Optional<Location> &result) override {
|
||||
parseOptionalLocationSpecifier(std::optional<Location> &result) override {
|
||||
// If there is a 'loc' we parse a trailing location.
|
||||
if (!parser.consumeIf(Token::kw_loc))
|
||||
return success();
|
||||
@@ -1825,7 +1827,7 @@ FailureOr<OperationName> OperationParser::parseCustomOperationName() {
|
||||
consumeToken();
|
||||
|
||||
// Check to see if this operation name is already registered.
|
||||
Optional<RegisteredOperationName> opInfo =
|
||||
std::optional<RegisteredOperationName> opInfo =
|
||||
RegisteredOperationName::lookup(opName, getContext());
|
||||
if (opInfo)
|
||||
return *opInfo;
|
||||
@@ -2395,7 +2397,7 @@ public:
|
||||
// Blob data within then textual format is represented as a hex string.
|
||||
// TODO: We could avoid an additional alloc+copy here if we pre-allocated
|
||||
// the buffer to use during hex processing.
|
||||
Optional<std::string> blobData =
|
||||
std::optional<std::string> blobData =
|
||||
value.is(Token::string) ? value.getHexStringValue() : std::nullopt;
|
||||
if (!blobData)
|
||||
return p.emitError(value.getLoc(),
|
||||
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
OptionalParseResult parseOptionalInteger(APInt &result);
|
||||
|
||||
/// Parse a floating point value from an integer literal token.
|
||||
ParseResult parseFloatFromIntegerLiteral(Optional<APFloat> &result,
|
||||
ParseResult parseFloatFromIntegerLiteral(std::optional<APFloat> &result,
|
||||
const Token &tok, bool isNegative,
|
||||
const llvm::fltSemantics &semantics,
|
||||
size_t typeSizeInBits);
|
||||
|
||||
@@ -26,7 +26,7 @@ SMRange Token::getLocRange() const { return SMRange(getLoc(), getEndLoc()); }
|
||||
|
||||
/// For an integer token, return its value as an unsigned. If it doesn't fit,
|
||||
/// return std::nullopt.
|
||||
Optional<unsigned> Token::getUnsignedIntegerValue() const {
|
||||
std::optional<unsigned> Token::getUnsignedIntegerValue() const {
|
||||
bool isHex = spelling.size() > 1 && spelling[1] == 'x';
|
||||
|
||||
unsigned result = 0;
|
||||
@@ -37,7 +37,7 @@ Optional<unsigned> Token::getUnsignedIntegerValue() const {
|
||||
|
||||
/// For an integer token, return its value as a uint64_t. If it doesn't fit,
|
||||
/// return std::nullopt.
|
||||
Optional<uint64_t> Token::getUInt64IntegerValue(StringRef spelling) {
|
||||
std::optional<uint64_t> Token::getUInt64IntegerValue(StringRef spelling) {
|
||||
bool isHex = spelling.size() > 1 && spelling[1] == 'x';
|
||||
|
||||
uint64_t result = 0;
|
||||
@@ -48,7 +48,7 @@ Optional<uint64_t> Token::getUInt64IntegerValue(StringRef spelling) {
|
||||
|
||||
/// For a floatliteral, return its value as a double. Return std::nullopt if the
|
||||
/// value underflows or overflows.
|
||||
Optional<double> Token::getFloatingPointValue() const {
|
||||
std::optional<double> Token::getFloatingPointValue() const {
|
||||
double result = 0;
|
||||
if (spelling.getAsDouble(result))
|
||||
return std::nullopt;
|
||||
@@ -56,7 +56,7 @@ Optional<double> Token::getFloatingPointValue() const {
|
||||
}
|
||||
|
||||
/// For an inttype token, return its bitwidth.
|
||||
Optional<unsigned> Token::getIntTypeBitwidth() const {
|
||||
std::optional<unsigned> Token::getIntTypeBitwidth() const {
|
||||
assert(getKind() == inttype);
|
||||
unsigned bitwidthStart = (spelling[0] == 'i' ? 1 : 2);
|
||||
unsigned result = 0;
|
||||
@@ -65,7 +65,7 @@ Optional<unsigned> Token::getIntTypeBitwidth() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
Optional<bool> Token::getIntTypeSignedness() const {
|
||||
std::optional<bool> Token::getIntTypeSignedness() const {
|
||||
assert(getKind() == inttype);
|
||||
if (spelling[0] == 'i')
|
||||
return std::nullopt;
|
||||
@@ -127,7 +127,7 @@ std::string Token::getStringValue() const {
|
||||
|
||||
/// Given a token containing a hex string literal, return its value or
|
||||
/// std::nullopt if the token does not contain a valid hex string.
|
||||
Optional<std::string> Token::getHexStringValue() const {
|
||||
std::optional<std::string> Token::getHexStringValue() const {
|
||||
assert(getKind() == string);
|
||||
|
||||
// Get the internal string data, without the quotes.
|
||||
@@ -158,7 +158,7 @@ std::string Token::getSymbolReference() const {
|
||||
/// Given a hash_identifier token like #123, try to parse the number out of
|
||||
/// the identifier, returning std::nullopt if it is a named identifier like #x
|
||||
/// or if the integer doesn't fit.
|
||||
Optional<unsigned> Token::getHashIdentifierNumber() const {
|
||||
std::optional<unsigned> Token::getHashIdentifierNumber() const {
|
||||
assert(getKind() == hash_identifier);
|
||||
unsigned result = 0;
|
||||
if (spelling.drop_front().getAsInteger(10, result))
|
||||
|
||||
@@ -76,31 +76,31 @@ public:
|
||||
|
||||
/// For an integer token, return its value as an unsigned. If it doesn't fit,
|
||||
/// return std::nullopt.
|
||||
Optional<unsigned> getUnsignedIntegerValue() const;
|
||||
std::optional<unsigned> getUnsignedIntegerValue() const;
|
||||
|
||||
/// For an integer token, return its value as an uint64_t. If it doesn't fit,
|
||||
/// return std::nullopt.
|
||||
static Optional<uint64_t> getUInt64IntegerValue(StringRef spelling);
|
||||
Optional<uint64_t> getUInt64IntegerValue() const {
|
||||
static std::optional<uint64_t> getUInt64IntegerValue(StringRef spelling);
|
||||
std::optional<uint64_t> getUInt64IntegerValue() const {
|
||||
return getUInt64IntegerValue(getSpelling());
|
||||
}
|
||||
|
||||
/// For a floatliteral token, return its value as a double. Returns
|
||||
/// std::nullopt in the case of underflow or overflow.
|
||||
Optional<double> getFloatingPointValue() const;
|
||||
std::optional<double> getFloatingPointValue() const;
|
||||
|
||||
/// For an inttype token, return its bitwidth.
|
||||
Optional<unsigned> getIntTypeBitwidth() const;
|
||||
std::optional<unsigned> getIntTypeBitwidth() const;
|
||||
|
||||
/// For an inttype token, return its signedness semantics: std::nullopt means
|
||||
/// no signedness semantics; true means signed integer type; false means
|
||||
/// unsigned integer type.
|
||||
Optional<bool> getIntTypeSignedness() const;
|
||||
std::optional<bool> getIntTypeSignedness() const;
|
||||
|
||||
/// Given a hash_identifier token like #123, try to parse the number out of
|
||||
/// the identifier, returning std::nullopt if it is a named identifier like #x
|
||||
/// or if the integer doesn't fit.
|
||||
Optional<unsigned> getHashIdentifierNumber() const;
|
||||
std::optional<unsigned> getHashIdentifierNumber() const;
|
||||
|
||||
/// Given a token containing a string literal, return its value, including
|
||||
/// removing the quote characters and unescaping the contents of the string.
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
/// std::nullopt if the token does not contain a valid hex string. A hex
|
||||
/// string literal is a string starting with `0x` and only containing hex
|
||||
/// digits.
|
||||
Optional<std::string> getHexStringValue() const;
|
||||
std::optional<std::string> getHexStringValue() const;
|
||||
|
||||
/// Given a token containing a symbol reference, return the unescaped string
|
||||
/// value.
|
||||
|
||||
@@ -281,7 +281,7 @@ Type Parser::parseNonFunctionType() {
|
||||
}
|
||||
|
||||
IntegerType::SignednessSemantics signSemantics = IntegerType::Signless;
|
||||
if (Optional<bool> signedness = getToken().getIntTypeSignedness())
|
||||
if (std::optional<bool> signedness = getToken().getIntTypeSignedness())
|
||||
signSemantics = *signedness ? IntegerType::Signed : IntegerType::Unsigned;
|
||||
|
||||
consumeToken(Token::inttype);
|
||||
@@ -561,7 +561,7 @@ ParseResult Parser::parseIntegerInDimensionList(int64_t &value) {
|
||||
consumeToken();
|
||||
} else {
|
||||
// Make sure this integer value is in bound and valid.
|
||||
Optional<uint64_t> dimension = getToken().getUInt64IntegerValue();
|
||||
std::optional<uint64_t> dimension = getToken().getUInt64IntegerValue();
|
||||
if (!dimension ||
|
||||
*dimension > (uint64_t)std::numeric_limits<int64_t>::max())
|
||||
return emitError("invalid dimension");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user