diff --git a/mlir/docs/Tutorials/Toy/Ch-7.md b/mlir/docs/Tutorials/Toy/Ch-7.md --- a/mlir/docs/Tutorials/Toy/Ch-7.md +++ b/mlir/docs/Tutorials/Toy/Ch-7.md @@ -268,7 +268,7 @@ SmallVector elementTypes; do { // Parse the current element type. - llvm::SMLoc typeLoc = parser.getCurrentLocation(); + SMLoc typeLoc = parser.getCurrentLocation(); mlir::Type elementType; if (parser.parseType(elementType)) return nullptr; diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -44,7 +44,7 @@ static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { SmallVector operands; - llvm::SMLoc operandsLoc = parser.getCurrentLocation(); + SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || parser.parseOptionalAttrDict(result.attributes) || diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -44,7 +44,7 @@ static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { SmallVector operands; - llvm::SMLoc operandsLoc = parser.getCurrentLocation(); + SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || parser.parseOptionalAttrDict(result.attributes) || diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -100,7 +100,7 @@ static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { SmallVector operands; - llvm::SMLoc operandsLoc = parser.getCurrentLocation(); + SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || parser.parseOptionalAttrDict(result.attributes) || diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -100,7 +100,7 @@ static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { SmallVector operands; - llvm::SMLoc operandsLoc = parser.getCurrentLocation(); + SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || parser.parseOptionalAttrDict(result.attributes) || diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -100,7 +100,7 @@ static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { SmallVector operands; - llvm::SMLoc operandsLoc = parser.getCurrentLocation(); + SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || parser.parseOptionalAttrDict(result.attributes) || diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -87,7 +87,7 @@ static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { SmallVector operands; - llvm::SMLoc operandsLoc = parser.getCurrentLocation(); + SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || parser.parseOptionalAttrDict(result.attributes) || @@ -501,7 +501,7 @@ SmallVector elementTypes; do { // Parse the current element type. - llvm::SMLoc typeLoc = parser.getCurrentLocation(); + SMLoc typeLoc = parser.getCurrentLocation(); mlir::Type elementType; if (parser.parseType(elementType)) return nullptr; diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h --- a/mlir/include/mlir/IR/Diagnostics.h +++ b/mlir/include/mlir/IR/Diagnostics.h @@ -564,7 +564,7 @@ private: /// Convert a location into the given memory buffer into an SMLoc. - llvm::SMLoc convertLocToSMLoc(FileLineColLoc loc); + SMLoc convertLocToSMLoc(FileLineColLoc loc); /// Given a location, returns the first nested location (including 'loc') that /// can be shown to the user. diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -367,14 +367,14 @@ MLIRContext *getContext() const; /// Return the location of the original name token. - virtual llvm::SMLoc getNameLoc() const = 0; + virtual SMLoc getNameLoc() const = 0; //===--------------------------------------------------------------------===// // Utilities //===--------------------------------------------------------------------===// /// Emit a diagnostic at the specified location and return failure. - virtual InFlightDiagnostic emitError(llvm::SMLoc loc, + virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message = {}) = 0; /// Return a builder which provides useful access to MLIRContext, global @@ -383,8 +383,8 @@ /// Get the location of the next token and store it into the argument. This /// always succeeds. - virtual llvm::SMLoc getCurrentLocation() = 0; - ParseResult getCurrentLocation(llvm::SMLoc *loc) { + virtual SMLoc getCurrentLocation() = 0; + ParseResult getCurrentLocation(SMLoc *loc) { *loc = getCurrentLocation(); return success(); } @@ -392,7 +392,7 @@ /// Re-encode the given source location as an MLIR location and return it. /// Note: This method should only be used when a `Location` is necessary, as /// the encoding process is not efficient. - virtual Location getEncodedSourceLoc(llvm::SMLoc loc) = 0; + virtual Location getEncodedSourceLoc(SMLoc loc) = 0; //===--------------------------------------------------------------------===// // Token Parsing @@ -627,7 +627,7 @@ /// unlike `OpBuilder::getType`, this method does not implicitly insert a /// context parameter. template - T getChecked(llvm::SMLoc loc, ParamsT &&... params) { + T getChecked(SMLoc loc, ParamsT &&... params) { return T::getChecked([&] { return emitError(loc); }, std::forward(params)...); } @@ -656,7 +656,7 @@ /// Parse an attribute of a specific kind and type. template ParseResult parseAttribute(AttrType &result, Type type = {}) { - llvm::SMLoc loc = getCurrentLocation(); + SMLoc loc = getCurrentLocation(); // Parse any kind of attribute. Attribute attr; @@ -690,7 +690,7 @@ template ParseResult parseAttribute(AttrType &result, Type type, StringRef attrName, NamedAttrList &attrs) { - llvm::SMLoc loc = getCurrentLocation(); + SMLoc loc = getCurrentLocation(); // Parse any kind of attribute. Attribute attr; @@ -721,7 +721,7 @@ std::enable_if_t::value, ParseResult> parseCustomAttributeWithFallback(AttrType &result, Type type, StringRef attrName, NamedAttrList &attrs) { - llvm::SMLoc loc = getCurrentLocation(); + SMLoc loc = getCurrentLocation(); // Parse any kind of attribute. Attribute attr; @@ -757,7 +757,7 @@ template std::enable_if_t::value, ParseResult> parseCustomAttributeWithFallback(AttrType &result) { - llvm::SMLoc loc = getCurrentLocation(); + SMLoc loc = getCurrentLocation(); // Parse any kind of attribute. Attribute attr; @@ -868,7 +868,7 @@ /// Parse a type of a specific type. template ParseResult parseType(TypeT &result) { - llvm::SMLoc loc = getCurrentLocation(); + SMLoc loc = getCurrentLocation(); // Parse any kind of type. Type type; @@ -897,7 +897,7 @@ template std::enable_if_t::value, ParseResult> parseCustomTypeWithFallback(TypeT &result) { - llvm::SMLoc loc = getCurrentLocation(); + SMLoc loc = getCurrentLocation(); // Parse any kind of Type. Type type; @@ -945,7 +945,7 @@ /// Parse a colon followed by a type of a specific kind, e.g. a FunctionType. template ParseResult parseColonType(TypeType &result) { - llvm::SMLoc loc = getCurrentLocation(); + SMLoc loc = getCurrentLocation(); // Parse any kind of type. Type type; @@ -1084,7 +1084,7 @@ /// This is the representation of an operand reference. struct OperandType { - llvm::SMLoc location; // Location of the token. + SMLoc location; // Location of the token. StringRef name; // Value name, e.g. %42 or %abc unsigned number; // Number, e.g. 12 for an operand like %xyz#12 }; @@ -1152,7 +1152,7 @@ /// emitting an error and returning failure, or appending the results /// to the list on success. ParseResult resolveOperands(ArrayRef operands, - ArrayRef types, llvm::SMLoc loc, + ArrayRef types, SMLoc loc, SmallVectorImpl &result) { if (operands.size() != types.size()) return emitError(loc) @@ -1165,14 +1165,14 @@ return success(); } template - ParseResult resolveOperands(Operands &&operands, Type type, llvm::SMLoc loc, + ParseResult resolveOperands(Operands &&operands, Type type, SMLoc loc, SmallVectorImpl &result) { return resolveOperands(std::forward(operands), ArrayRef(type), loc, result); } template std::enable_if_t::value, ParseResult> - resolveOperands(Operands &&operands, Types &&types, llvm::SMLoc loc, + resolveOperands(Operands &&operands, Types &&types, SMLoc loc, SmallVectorImpl &result) { size_t operandSize = std::distance(operands.begin(), operands.end()); size_t typeSize = std::distance(types.begin(), types.end()); diff --git a/mlir/include/mlir/Parser/AsmParserState.h b/mlir/include/mlir/Parser/AsmParserState.h --- a/mlir/include/mlir/Parser/AsmParserState.h +++ b/mlir/include/mlir/Parser/AsmParserState.h @@ -35,19 +35,19 @@ /// values, Blocks, and Symbols. struct SMDefinition { SMDefinition() = default; - SMDefinition(llvm::SMRange loc) : loc(loc) {} + SMDefinition(SMRange loc) : loc(loc) {} /// The source location of the definition. - llvm::SMRange loc; + SMRange loc; /// The source location of all uses of the definition. - SmallVector uses; + SmallVector uses; }; /// This class represents the information for an operation definition within /// an input file. struct OperationDefinition { struct ResultGroupDefinition { - ResultGroupDefinition(unsigned index, llvm::SMRange loc) + ResultGroupDefinition(unsigned index, SMRange loc) : startIndex(index), definition(loc) {} /// The result number that starts this group. @@ -56,31 +56,31 @@ SMDefinition definition; }; - OperationDefinition(Operation *op, llvm::SMRange loc, llvm::SMLoc endLoc) + OperationDefinition(Operation *op, SMRange loc, SMLoc endLoc) : op(op), loc(loc), scopeLoc(loc.Start, endLoc) {} /// The operation representing this definition. Operation *op; /// The source location for the operation, i.e. the location of its name. - llvm::SMRange loc; + SMRange loc; /// The full source range of the operation definition, i.e. a range /// encompassing the start and end of the full operation definition. - llvm::SMRange scopeLoc; + SMRange scopeLoc; /// Source definitions for any result groups of this operation. SmallVector resultGroups; /// If this operation is a symbol operation, this vector contains symbol /// uses of this operation. - SmallVector symbolUses; + SmallVector symbolUses; }; /// This class represents the information for a block definition within the /// input file. struct BlockDefinition { - BlockDefinition(Block *block, llvm::SMRange loc = {}) + BlockDefinition(Block *block, SMRange loc = {}) : block(block), definition(loc) {} /// The block representing this definition. @@ -124,7 +124,7 @@ /// Returns (heuristically) the range of an identifier given a SMLoc /// corresponding to the start of an identifier location. - static llvm::SMRange convertIdLocToRange(llvm::SMLoc loc); + static SMRange convertIdLocToRange(SMLoc loc); //===--------------------------------------------------------------------===// // Populate State @@ -142,8 +142,8 @@ /// Finalize the most recently started operation definition. void finalizeOperationDefinition( - Operation *op, llvm::SMRange nameLoc, llvm::SMLoc endLoc, - ArrayRef> resultGroups = llvm::None); + Operation *op, SMRange nameLoc, SMLoc endLoc, + ArrayRef> resultGroups = llvm::None); /// Start a definition for a region nested under the current operation. void startRegionDefinition(); @@ -152,18 +152,18 @@ void finalizeRegionDefinition(); /// Add a definition of the given entity. - void addDefinition(Block *block, llvm::SMLoc location); - void addDefinition(BlockArgument blockArg, llvm::SMLoc location); + void addDefinition(Block *block, SMLoc location); + void addDefinition(BlockArgument blockArg, SMLoc location); /// Add a source uses of the given value. - void addUses(Value value, ArrayRef locations); - void addUses(Block *block, ArrayRef locations); + void addUses(Value value, ArrayRef locations); + void addUses(Block *block, ArrayRef locations); /// Add source uses for all the references nested under `refAttr`. The /// provided `locations` should match 1-1 with the number of references in /// `refAttr`, i.e.: /// nestedReferences.size() + /*leafReference=*/1 == refLocations.size() - void addUses(SymbolRefAttr refAttr, ArrayRef refLocations); + void addUses(SymbolRefAttr refAttr, ArrayRef refLocations); /// Refine the `oldValue` to the `newValue`. This is used to indicate that /// `oldValue` was a placeholder, and the uses of it should really refer to diff --git a/mlir/include/mlir/Support/LLVM.h b/mlir/include/mlir/Support/LLVM.h --- a/mlir/include/mlir/Support/LLVM.h +++ b/mlir/include/mlir/Support/LLVM.h @@ -71,6 +71,8 @@ template class function_ref; template class iterator_range; class raw_ostream; +class SMLoc; +class SMRange; } // namespace llvm namespace mlir { @@ -127,6 +129,8 @@ template using function_ref = llvm::function_ref; using llvm::iterator_range; using llvm::raw_ostream; +using llvm::SMLoc; +using llvm::SMRange; } // namespace mlir #endif // MLIR_SUPPORT_LLVM_H diff --git a/mlir/include/mlir/TableGen/AttrOrTypeDef.h b/mlir/include/mlir/TableGen/AttrOrTypeDef.h --- a/mlir/include/mlir/TableGen/AttrOrTypeDef.h +++ b/mlir/include/mlir/TableGen/AttrOrTypeDef.h @@ -196,7 +196,7 @@ Optional getExtraDecls() const; // Get the code location (for error printing). - ArrayRef getLoc() const; + ArrayRef getLoc() const; // Returns true if the default get/getChecked methods should be skipped during // generation. diff --git a/mlir/include/mlir/TableGen/Builder.h b/mlir/include/mlir/TableGen/Builder.h --- a/mlir/include/mlir/TableGen/Builder.h +++ b/mlir/include/mlir/TableGen/Builder.h @@ -62,7 +62,7 @@ }; /// Construct a builder from the given Record instance. - Builder(const llvm::Record *record, ArrayRef loc); + Builder(const llvm::Record *record, ArrayRef loc); /// Return a list of parameters used in this build method. ArrayRef getParameters() const { return parameters; } diff --git a/mlir/include/mlir/TableGen/Operator.h b/mlir/include/mlir/TableGen/Operator.h --- a/mlir/include/mlir/TableGen/Operator.h +++ b/mlir/include/mlir/TableGen/Operator.h @@ -222,7 +222,7 @@ const_trait_iterator trait_end() const; llvm::iterator_range getTraits() const; - ArrayRef getLoc() const; + ArrayRef getLoc() const; // Query functions for the documentation of the operator. bool hasDescription() const; diff --git a/mlir/include/mlir/TableGen/Pattern.h b/mlir/include/mlir/TableGen/Pattern.h --- a/mlir/include/mlir/TableGen/Pattern.h +++ b/mlir/include/mlir/TableGen/Pattern.h @@ -245,7 +245,7 @@ // values in a suitable way. class SymbolInfoMap { public: - explicit SymbolInfoMap(ArrayRef loc) : loc(loc) {} + explicit SymbolInfoMap(ArrayRef loc) : loc(loc) {} // Class for information regarding a symbol. class SymbolInfo { @@ -445,7 +445,7 @@ // Pattern instantiation location. This is intended to be used as parameter // to PrintFatalError() to report errors. - ArrayRef loc; + ArrayRef loc; }; // Wrapper class providing helper methods for accessing MLIR Pattern defined diff --git a/mlir/include/mlir/TableGen/Predicate.h b/mlir/include/mlir/TableGen/Predicate.h --- a/mlir/include/mlir/TableGen/Predicate.h +++ b/mlir/include/mlir/TableGen/Predicate.h @@ -54,7 +54,7 @@ bool isCombined() const; // Get the location of the predicate. - ArrayRef getLoc() const; + ArrayRef getLoc() const; // Records are pointer-comparable. bool operator==(const Pred &other) const { return def == other.def; } diff --git a/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h b/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h --- a/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h @@ -37,14 +37,14 @@ StringRef getMessage() const { return message; } /// Return the location of this diagnostic. - llvm::SMRange getLocation() const { return location; } + SMRange getLocation() const { return location; } /// Return the notes of this diagnostic. auto getNotes() const { return llvm::make_pointee_range(notes); } /// Attach a note to this diagnostic. Diagnostic &attachNote(const Twine &msg, - Optional noteLoc = llvm::None) { + Optional noteLoc = llvm::None) { assert(getSeverity() != Severity::DK_Note && "cannot attach a Note to a Note"); notes.emplace_back( @@ -57,7 +57,7 @@ operator LogicalResult() const { return failure(); } private: - Diagnostic(Severity severity, llvm::SMRange loc, const Twine &msg) + Diagnostic(Severity severity, SMRange loc, const Twine &msg) : severity(severity), message(msg.str()), location(loc) {} // Allow access to the constructor. @@ -68,7 +68,7 @@ /// The message held by this diagnostic. std::string message; /// The raw location of this diagnostic. - llvm::SMRange location; + SMRange location; /// Any additional note diagnostics attached to this diagnostic. std::vector> notes; }; @@ -142,11 +142,11 @@ using HandlerFn = llvm::unique_function; /// Emit an error to the diagnostic engine. - InFlightDiagnostic emitError(llvm::SMRange loc, const Twine &msg) { + InFlightDiagnostic emitError(SMRange loc, const Twine &msg) { return InFlightDiagnostic( this, Diagnostic(Diagnostic::Severity::DK_Error, loc, msg)); } - InFlightDiagnostic emitWarning(llvm::SMRange loc, const Twine &msg) { + InFlightDiagnostic emitWarning(SMRange loc, const Twine &msg) { return InFlightDiagnostic( this, Diagnostic(Diagnostic::Severity::DK_Warning, loc, msg)); } diff --git a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h --- a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h @@ -35,25 +35,25 @@ /// contains a string name as well as the source location for that name. struct Name { static const Name &create(Context &ctx, StringRef name, - llvm::SMRange location); + SMRange location); /// Return the raw string name. StringRef getName() const { return name; } /// Get the location of this name. - llvm::SMRange getLoc() const { return location; } + SMRange getLoc() const { return location; } private: Name() = delete; Name(const Name &) = delete; Name &operator=(const Name &) = delete; - Name(StringRef name, llvm::SMRange location) + Name(StringRef name, SMRange location) : name(name), location(location) {} /// The string name of the decl. StringRef name; /// The location of the decl name. - llvm::SMRange location; + SMRange location; }; //===----------------------------------------------------------------------===// @@ -118,7 +118,7 @@ protected: template - explicit NodeBase(llvm::SMRange loc, Args &&...args) + explicit NodeBase(SMRange loc, Args &&...args) : BaseT(TypeID::get(), loc, std::forward(args)...) {} }; @@ -126,20 +126,20 @@ TypeID getTypeID() const { return typeID; } /// Return the location of this node. - llvm::SMRange getLoc() const { return loc; } + SMRange getLoc() const { return loc; } /// Print this node to the given stream. void print(raw_ostream &os) const; protected: - Node(TypeID typeID, llvm::SMRange loc) : typeID(typeID), loc(loc) {} + Node(TypeID typeID, SMRange loc) : typeID(typeID), loc(loc) {} private: /// A unique type identifier for this node. TypeID typeID; /// The location of this node. - llvm::SMRange loc; + SMRange loc; }; //===----------------------------------------------------------------------===// @@ -164,7 +164,7 @@ class CompoundStmt final : public Node::NodeBase, private llvm::TrailingObjects { public: - static CompoundStmt *create(Context &ctx, llvm::SMRange location, + static CompoundStmt *create(Context &ctx, SMRange location, ArrayRef children); /// Return the children of this compound statement. @@ -178,7 +178,7 @@ ArrayRef::iterator end() const { return getChildren().end(); } private: - CompoundStmt(llvm::SMRange location, unsigned numChildren) + CompoundStmt(SMRange location, unsigned numChildren) : Base(location), numChildren(numChildren) {} /// The number of held children statements. @@ -196,14 +196,14 @@ /// to define variables. class LetStmt final : public Node::NodeBase { public: - static LetStmt *create(Context &ctx, llvm::SMRange loc, + static LetStmt *create(Context &ctx, SMRange loc, VariableDecl *varDecl); /// Return the variable defined by this statement. VariableDecl *getVarDecl() const { return varDecl; } private: - LetStmt(llvm::SMRange loc, VariableDecl *varDecl) + LetStmt(SMRange loc, VariableDecl *varDecl) : Base(loc), varDecl(varDecl) {} /// The variable defined by this statement. @@ -225,7 +225,7 @@ Expr *getRootOpExpr() const { return rootOp; } protected: - OpRewriteStmt(TypeID typeID, llvm::SMRange loc, Expr *rootOp) + OpRewriteStmt(TypeID typeID, SMRange loc, Expr *rootOp) : Stmt(typeID, loc), rootOp(rootOp) {} protected: @@ -241,10 +241,10 @@ /// PatternRewriter::eraseOp API. class EraseStmt final : public Node::NodeBase { public: - static EraseStmt *create(Context &ctx, llvm::SMRange loc, Expr *rootOp); + static EraseStmt *create(Context &ctx, SMRange loc, Expr *rootOp); private: - EraseStmt(llvm::SMRange loc, Expr *rootOp) : Base(loc, rootOp) {} + EraseStmt(SMRange loc, Expr *rootOp) : Base(loc, rootOp) {} }; //===----------------------------------------------------------------------===// @@ -256,7 +256,7 @@ class ReplaceStmt final : public Node::NodeBase, private llvm::TrailingObjects { public: - static ReplaceStmt *create(Context &ctx, llvm::SMRange loc, Expr *rootOp, + static ReplaceStmt *create(Context &ctx, SMRange loc, Expr *rootOp, ArrayRef replExprs); /// Return the replacement values of this statement. @@ -268,7 +268,7 @@ } private: - ReplaceStmt(llvm::SMRange loc, Expr *rootOp, unsigned numReplExprs) + ReplaceStmt(SMRange loc, Expr *rootOp, unsigned numReplExprs) : Base(loc, rootOp), numReplExprs(numReplExprs) {} /// The number of replacement values within this statement. @@ -286,14 +286,14 @@ /// rewrites that span across multiple statements, which may be unconnected. class RewriteStmt final : public Node::NodeBase { public: - static RewriteStmt *create(Context &ctx, llvm::SMRange loc, Expr *rootOp, + static RewriteStmt *create(Context &ctx, SMRange loc, Expr *rootOp, CompoundStmt *rewriteBody); /// Return the compound rewrite body. CompoundStmt *getRewriteBody() const { return rewriteBody; } private: - RewriteStmt(llvm::SMRange loc, Expr *rootOp, CompoundStmt *rewriteBody) + RewriteStmt(SMRange loc, Expr *rootOp, CompoundStmt *rewriteBody) : Base(loc, rootOp), rewriteBody(rewriteBody) {} /// The body of nested rewriters within this statement. @@ -314,7 +314,7 @@ static bool classof(const Node *node); protected: - Expr(TypeID typeID, llvm::SMRange loc, Type type) + Expr(TypeID typeID, SMRange loc, Type type) : Stmt(typeID, loc), type(type) {} private: @@ -330,7 +330,7 @@ /// textual assembly format of that attribute. class AttributeExpr : public Node::NodeBase { public: - static AttributeExpr *create(Context &ctx, llvm::SMRange loc, + static AttributeExpr *create(Context &ctx, SMRange loc, StringRef value); /// Get the raw value of this expression. This is the textual assembly format @@ -338,7 +338,7 @@ StringRef getValue() const { return value; } private: - AttributeExpr(Context &ctx, llvm::SMRange loc, StringRef value) + AttributeExpr(Context &ctx, SMRange loc, StringRef value) : Base(loc, AttributeType::get(ctx)), value(value) {} /// The value referenced by this expression. @@ -352,14 +352,14 @@ /// This expression represents a reference to a Decl node. class DeclRefExpr : public Node::NodeBase { public: - static DeclRefExpr *create(Context &ctx, llvm::SMRange loc, Decl *decl, + static DeclRefExpr *create(Context &ctx, SMRange loc, Decl *decl, Type type); /// Get the decl referenced by this expression. Decl *getDecl() const { return decl; } private: - DeclRefExpr(llvm::SMRange loc, Decl *decl, Type type) + DeclRefExpr(SMRange loc, Decl *decl, Type type) : Base(loc, type), decl(decl) {} /// The decl referenced by this expression. @@ -374,7 +374,7 @@ /// expression. class MemberAccessExpr : public Node::NodeBase { public: - static MemberAccessExpr *create(Context &ctx, llvm::SMRange loc, + static MemberAccessExpr *create(Context &ctx, SMRange loc, const Expr *parentExpr, StringRef memberName, Type type); @@ -385,7 +385,7 @@ StringRef getMemberName() const { return memberName; } private: - MemberAccessExpr(llvm::SMRange loc, const Expr *parentExpr, + MemberAccessExpr(SMRange loc, const Expr *parentExpr, StringRef memberName, Type type) : Base(loc, type), parentExpr(parentExpr), memberName(memberName) {} @@ -406,7 +406,7 @@ /// Return the member name used for the "all-results" access. static StringRef getMemberName() { return "$results"; } - static AllResultsMemberAccessExpr *create(Context &ctx, llvm::SMRange loc, + static AllResultsMemberAccessExpr *create(Context &ctx, SMRange loc, const Expr *parentExpr, Type type) { return cast( MemberAccessExpr::create(ctx, loc, parentExpr, getMemberName(), type)); @@ -431,7 +431,7 @@ private llvm::TrailingObjects { public: - static OperationExpr *create(Context &ctx, llvm::SMRange loc, + static OperationExpr *create(Context &ctx, SMRange loc, const OpNameDecl *nameDecl, ArrayRef operands, ArrayRef resultTypes, @@ -445,7 +445,7 @@ /// Return the location of the name of the operation expression, or an invalid /// location if there isn't a name. - llvm::SMRange getNameLoc() const { return nameLoc; } + SMRange getNameLoc() const { return nameLoc; } /// Return the operands of this operation. MutableArrayRef getOperands() { @@ -472,9 +472,9 @@ } private: - OperationExpr(llvm::SMRange loc, Type type, const OpNameDecl *nameDecl, + OperationExpr(SMRange loc, Type type, const OpNameDecl *nameDecl, unsigned numOperands, unsigned numResultTypes, - unsigned numAttributes, llvm::SMRange nameLoc) + unsigned numAttributes, SMRange nameLoc) : Base(loc, type), nameDecl(nameDecl), numOperands(numOperands), numResultTypes(numResultTypes), numAttributes(numAttributes), nameLoc(nameLoc) {} @@ -486,7 +486,7 @@ unsigned numOperands, numResultTypes, numAttributes; /// The location of the operation name in the expression if it has a name. - llvm::SMRange nameLoc; + SMRange nameLoc; /// TrailingObject utilities. friend llvm::TrailingObjects; @@ -503,7 +503,7 @@ class TupleExpr final : public Node::NodeBase, private llvm::TrailingObjects { public: - static TupleExpr *create(Context &ctx, llvm::SMRange loc, + static TupleExpr *create(Context &ctx, SMRange loc, ArrayRef elements, ArrayRef elementNames); @@ -519,7 +519,7 @@ TupleType getType() const { return Base::getType().cast(); } private: - TupleExpr(llvm::SMRange loc, TupleType type) : Base(loc, type) {} + TupleExpr(SMRange loc, TupleType type) : Base(loc, type) {} /// TrailingObject utilities. friend class llvm::TrailingObjects; @@ -533,14 +533,14 @@ /// assembly format of that type. class TypeExpr : public Node::NodeBase { public: - static TypeExpr *create(Context &ctx, llvm::SMRange loc, StringRef value); + static TypeExpr *create(Context &ctx, SMRange loc, StringRef value); /// Get the raw value of this expression. This is the textual assembly format /// of the MLIR Type. StringRef getValue() const { return value; } private: - TypeExpr(Context &ctx, llvm::SMRange loc, StringRef value) + TypeExpr(Context &ctx, SMRange loc, StringRef value) : Base(loc, TypeType::get(ctx)), value(value) {} /// The value referenced by this expression. @@ -561,7 +561,7 @@ static bool classof(const Node *node); protected: - Decl(TypeID typeID, llvm::SMRange loc, const Name *name = nullptr) + Decl(TypeID typeID, SMRange loc, const Name *name = nullptr) : Node(typeID, loc), name(name) {} private: @@ -582,20 +582,20 @@ static bool classof(const Node *node); protected: - ConstraintDecl(TypeID typeID, llvm::SMRange loc, const Name *name = nullptr) + ConstraintDecl(TypeID typeID, SMRange loc, const Name *name = nullptr) : Decl(typeID, loc, name) {} }; /// This class represents a reference to a constraint, and contains a constraint /// and the location of the reference. struct ConstraintRef { - ConstraintRef(const ConstraintDecl *constraint, llvm::SMRange refLoc) + ConstraintRef(const ConstraintDecl *constraint, SMRange refLoc) : constraint(constraint), referenceLoc(refLoc) {} explicit ConstraintRef(const ConstraintDecl *constraint) : ConstraintRef(constraint, constraint->getLoc()) {} const ConstraintDecl *constraint; - llvm::SMRange referenceLoc; + SMRange referenceLoc; }; //===----------------------------------------------------------------------===// @@ -611,7 +611,7 @@ static bool classof(const Node *node); protected: - CoreConstraintDecl(TypeID typeID, llvm::SMRange loc, + CoreConstraintDecl(TypeID typeID, SMRange loc, const Name *name = nullptr) : ConstraintDecl(typeID, loc, name) {} }; @@ -624,7 +624,7 @@ class AttrConstraintDecl : public Node::NodeBase { public: - static AttrConstraintDecl *create(Context &ctx, llvm::SMRange loc, + static AttrConstraintDecl *create(Context &ctx, SMRange loc, Expr *typeExpr = nullptr); /// Return the optional type the attribute is constrained to. @@ -632,7 +632,7 @@ const Expr *getTypeExpr() const { return typeExpr; } protected: - AttrConstraintDecl(llvm::SMRange loc, Expr *typeExpr) + AttrConstraintDecl(SMRange loc, Expr *typeExpr) : Base(loc), typeExpr(typeExpr) {} /// An optional type that the attribute is constrained to. @@ -647,7 +647,7 @@ class OpConstraintDecl : public Node::NodeBase { public: - static OpConstraintDecl *create(Context &ctx, llvm::SMRange loc, + static OpConstraintDecl *create(Context &ctx, SMRange loc, const OpNameDecl *nameDecl = nullptr); /// Return the name of the operation, or None if there isn't one. @@ -657,7 +657,7 @@ const OpNameDecl *getNameDecl() const { return nameDecl; } protected: - explicit OpConstraintDecl(llvm::SMRange loc, const OpNameDecl *nameDecl) + explicit OpConstraintDecl(SMRange loc, const OpNameDecl *nameDecl) : Base(loc), nameDecl(nameDecl) {} /// The operation name of this constraint. @@ -672,7 +672,7 @@ class TypeConstraintDecl : public Node::NodeBase { public: - static TypeConstraintDecl *create(Context &ctx, llvm::SMRange loc); + static TypeConstraintDecl *create(Context &ctx, SMRange loc); protected: using Base::Base; @@ -686,7 +686,7 @@ class TypeRangeConstraintDecl : public Node::NodeBase { public: - static TypeRangeConstraintDecl *create(Context &ctx, llvm::SMRange loc); + static TypeRangeConstraintDecl *create(Context &ctx, SMRange loc); protected: using Base::Base; @@ -700,7 +700,7 @@ class ValueConstraintDecl : public Node::NodeBase { public: - static ValueConstraintDecl *create(Context &ctx, llvm::SMRange loc, + static ValueConstraintDecl *create(Context &ctx, SMRange loc, Expr *typeExpr); /// Return the optional type the value is constrained to. @@ -708,7 +708,7 @@ const Expr *getTypeExpr() const { return typeExpr; } protected: - ValueConstraintDecl(llvm::SMRange loc, Expr *typeExpr) + ValueConstraintDecl(SMRange loc, Expr *typeExpr) : Base(loc), typeExpr(typeExpr) {} /// An optional type that the value is constrained to. @@ -723,7 +723,7 @@ class ValueRangeConstraintDecl : public Node::NodeBase { public: - static ValueRangeConstraintDecl *create(Context &ctx, llvm::SMRange loc, + static ValueRangeConstraintDecl *create(Context &ctx, SMRange loc, Expr *typeExpr); /// Return the optional type the value range is constrained to. @@ -731,7 +731,7 @@ const Expr *getTypeExpr() const { return typeExpr; } protected: - ValueRangeConstraintDecl(llvm::SMRange loc, Expr *typeExpr) + ValueRangeConstraintDecl(SMRange loc, Expr *typeExpr) : Base(loc), typeExpr(typeExpr) {} /// An optional type that the value range is constrained to. @@ -771,7 +771,7 @@ class OpNameDecl : public Node::NodeBase { public: static OpNameDecl *create(Context &ctx, const Name &name); - static OpNameDecl *create(Context &ctx, llvm::SMRange loc); + static OpNameDecl *create(Context &ctx, SMRange loc); /// Return the name of this operation, or none if the name is unknown. Optional getName() const { @@ -781,7 +781,7 @@ private: explicit OpNameDecl(const Name &name) : Base(name.getLoc(), &name) {} - explicit OpNameDecl(llvm::SMRange loc) : Base(loc) {} + explicit OpNameDecl(SMRange loc) : Base(loc) {} }; //===----------------------------------------------------------------------===// @@ -791,7 +791,7 @@ /// This Decl represents a single Pattern. class PatternDecl : public Node::NodeBase { public: - static PatternDecl *create(Context &ctx, llvm::SMRange location, + static PatternDecl *create(Context &ctx, SMRange location, const Name *name, Optional benefit, bool hasBoundedRecursion, const CompoundStmt *body); @@ -811,7 +811,7 @@ } private: - PatternDecl(llvm::SMRange loc, const Name *name, Optional benefit, + PatternDecl(SMRange loc, const Name *name, Optional benefit, bool hasBoundedRecursion, const CompoundStmt *body) : Base(loc, name), benefit(benefit), hasBoundedRecursion(hasBoundedRecursion), patternBody(body) {} @@ -884,7 +884,7 @@ class Module final : public Node::NodeBase, private llvm::TrailingObjects { public: - static Module *create(Context &ctx, llvm::SMLoc loc, + static Module *create(Context &ctx, SMLoc loc, ArrayRef children); /// Return the children of this module. @@ -896,8 +896,8 @@ } private: - Module(llvm::SMLoc loc, unsigned numChildren) - : Base(llvm::SMRange{loc, loc}), numChildren(numChildren) {} + Module(SMLoc loc, unsigned numChildren) + : Base(SMRange{loc, loc}), numChildren(numChildren) {} /// The number of decls held by this module. unsigned numChildren; diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -1384,7 +1384,7 @@ } // Get the attribute location. - llvm::SMLoc attrLoc = p.getCurrentLocation(); + SMLoc attrLoc = p.getCurrentLocation(); Attribute boundAttr; if (p.parseAttribute(boundAttr, builder.getIndexType(), boundAttrName, @@ -1458,7 +1458,7 @@ AffineForOp::getStepAttrName(), builder.getIntegerAttr(builder.getIndexType(), /*value=*/1)); } else { - llvm::SMLoc stepLoc = parser.getCurrentLocation(); + SMLoc stepLoc = parser.getCurrentLocation(); IntegerAttr stepAttr; if (parser.parseAttribute(stepAttr, builder.getIndexType(), AffineForOp::getStepAttrName().data(), diff --git a/mlir/lib/Dialect/DLTI/DLTI.cpp b/mlir/lib/Dialect/DLTI/DLTI.cpp --- a/mlir/lib/Dialect/DLTI/DLTI.cpp +++ b/mlir/lib/Dialect/DLTI/DLTI.cpp @@ -71,7 +71,7 @@ Type type = nullptr; std::string identifier; - llvm::SMLoc idLoc = parser.getCurrentLocation(); + SMLoc idLoc = parser.getCurrentLocation(); OptionalParseResult parsedType = parser.parseOptionalType(type); if (parsedType.hasValue() && failed(parsedType.getValue())) return {}; diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp --- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp +++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp @@ -170,7 +170,7 @@ if (parser.parseLess()) return Attribute(); std::string value; - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); if (parser.parseOptionalString(&value)) { parser.emitError(loc) << "expected string"; return Attribute(); @@ -197,7 +197,7 @@ if (parser.parseLess()) return Type(); std::string value; - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); if (parser.parseOptionalString(&value) || value.empty()) { parser.emitError(loc) << "expected non empty string"; return Type(); diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -141,7 +141,7 @@ return AsyncTokenType::get(context); if (keyword == "mma_matrix") { - llvm::SMLoc beginLoc = parser.getNameLoc(); + SMLoc beginLoc = parser.getNameLoc(); // Parse '<'. if (parser.parseLess()) diff --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp --- a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp @@ -357,7 +357,7 @@ llvm::SourceMgr srcMgr; srcMgr.AddNewSourceBuffer(llvm::MemoryBuffer::getMemBuffer(isa), - llvm::SMLoc()); + SMLoc()); const llvm::MCTargetOptions mcOptions; std::unique_ptr mri( diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -115,7 +115,7 @@ StringAttr predicateAttr; OpAsmParser::OperandType lhs, rhs; Type type; - llvm::SMLoc predicateLoc, trailingTypeLoc; + SMLoc predicateLoc, trailingTypeLoc; if (parser.getCurrentLocation(&predicateLoc) || parser.parseAttribute(predicateAttr, "predicate", result.attributes) || parser.parseOperand(lhs) || parser.parseComma() || @@ -194,7 +194,7 @@ static ParseResult parseAllocaOp(OpAsmParser &parser, OperationState &result) { OpAsmParser::OperandType arraySize; Type type, elemType; - llvm::SMLoc trailingTypeLoc; + SMLoc trailingTypeLoc; if (parser.parseOperand(arraySize) || parser.parseKeyword("x") || parser.parseType(elemType) || parser.parseOptionalAttrDict(result.attributes) || parser.parseColon() || @@ -642,7 +642,7 @@ // Extract the pointee type from the LLVM pointer type wrapped in MLIR. Return // the resulting type wrapped in MLIR, or nullptr on error. static Type getLoadStoreElementType(OpAsmParser &parser, Type type, - llvm::SMLoc trailingTypeLoc) { + SMLoc trailingTypeLoc) { auto llvmTy = type.dyn_cast(); if (!llvmTy) return parser.emitError(trailingTypeLoc, "expected LLVM pointer type"), @@ -654,7 +654,7 @@ static ParseResult parseLoadOp(OpAsmParser &parser, OperationState &result) { OpAsmParser::OperandType addr; Type type; - llvm::SMLoc trailingTypeLoc; + SMLoc trailingTypeLoc; if (succeeded(parser.parseOptionalKeyword("volatile"))) result.addAttribute(kVolatileAttrName, parser.getBuilder().getUnitAttr()); @@ -706,7 +706,7 @@ static ParseResult parseStoreOp(OpAsmParser &parser, OperationState &result) { OpAsmParser::OperandType addr, value; Type type; - llvm::SMLoc trailingTypeLoc; + SMLoc trailingTypeLoc; if (succeeded(parser.parseOptionalKeyword("volatile"))) result.addAttribute(kVolatileAttrName, parser.getBuilder().getUnitAttr()); @@ -790,7 +790,7 @@ SmallVector operands; FunctionType funcType; SymbolRefAttr funcAttr; - llvm::SMLoc trailingTypeLoc; + SMLoc trailingTypeLoc; Block *normalDest, *unwindDest; SmallVector normalOperands, unwindOperands; Builder &builder = parser.getBuilder(); @@ -1081,7 +1081,7 @@ SmallVector operands; Type type; SymbolRefAttr funcAttr; - llvm::SMLoc trailingTypeLoc; + SMLoc trailingTypeLoc; // Parse an operand list that will, in practice, contain 0 or 1 operand. In // case of an indirect call, there will be 1 operand before `(`. In case of a @@ -1182,7 +1182,7 @@ // attribute-dict? `:` type static ParseResult parseExtractElementOp(OpAsmParser &parser, OperationState &result) { - llvm::SMLoc loc; + SMLoc loc; OpAsmParser::OperandType vector, position; Type type, positionType; if (parser.getCurrentLocation(&loc) || parser.parseOperand(vector) || @@ -1231,8 +1231,8 @@ static Type getInsertExtractValueElementType(OpAsmParser &parser, Type containerType, ArrayAttr positionAttr, - llvm::SMLoc attributeLoc, - llvm::SMLoc typeLoc) { + SMLoc attributeLoc, + SMLoc typeLoc) { Type llvmType = containerType; if (!isCompatibleType(containerType)) return parser.emitError(typeLoc, "expected LLVM IR Dialect type"), nullptr; @@ -1322,7 +1322,7 @@ OpAsmParser::OperandType container; Type containerType; ArrayAttr positionAttr; - llvm::SMLoc attributeLoc, trailingTypeLoc; + SMLoc attributeLoc, trailingTypeLoc; if (parser.parseOperand(container) || parser.getCurrentLocation(&attributeLoc) || @@ -1396,7 +1396,7 @@ // attribute-dict? `:` type static ParseResult parseInsertElementOp(OpAsmParser &parser, OperationState &result) { - llvm::SMLoc loc; + SMLoc loc; OpAsmParser::OperandType vector, value, position; Type vectorType, positionType; if (parser.getCurrentLocation(&loc) || parser.parseOperand(value) || @@ -1449,7 +1449,7 @@ OpAsmParser::OperandType container, value; Type containerType; ArrayAttr positionAttr; - llvm::SMLoc attributeLoc, trailingTypeLoc; + SMLoc attributeLoc, trailingTypeLoc; if (parser.parseOperand(value) || parser.parseComma() || parser.parseOperand(container) || @@ -1918,7 +1918,7 @@ // attribute-dict? `:` type static ParseResult parseShuffleVectorOp(OpAsmParser &parser, OperationState &result) { - llvm::SMLoc loc; + SMLoc loc; OpAsmParser::OperandType v1, v2; ArrayAttr maskAttr; Type typeV1, typeV2; @@ -1985,7 +1985,7 @@ // Returns a null type if any of the types provided are non-LLVM types, or if // there is more than one output type. static Type -buildLLVMFunctionType(OpAsmParser &parser, llvm::SMLoc loc, +buildLLVMFunctionType(OpAsmParser &parser, SMLoc loc, ArrayRef inputs, ArrayRef outputs, function_interface_impl::VariadicFlag variadicFlag) { Builder &b = parser.getBuilder(); @@ -2216,7 +2216,7 @@ // state. static ParseResult parseAtomicBinOp(OpAsmParser &parser, OperationState &result, StringRef attrName) { - llvm::SMLoc loc; + SMLoc loc; StringRef keyword; if (parser.getCurrentLocation(&loc) || parser.parseKeyword(&keyword)) return failure(); @@ -2243,7 +2243,7 @@ static ParseResult parseAtomicOrdering(OpAsmParser &parser, OperationState &result, StringRef attrName) { - llvm::SMLoc loc; + SMLoc loc; StringRef ordering; if (parser.getCurrentLocation(&loc) || parser.parseKeyword(&ordering)) return failure(); diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp @@ -177,7 +177,7 @@ /// Parses an LLVM dialect function type. /// llvm-type :: = `func<` llvm-type `(` llvm-type-list `...`? `)>` static LLVMFunctionType parseFunctionType(AsmParser &parser) { - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); Type returnType; if (parser.parseLess() || dispatchParse(parser, returnType) || parser.parseLParen()) @@ -216,7 +216,7 @@ /// Parses an LLVM dialect pointer type. /// llvm-type ::= `ptr<` llvm-type (`,` integer)? `>` static LLVMPointerType parsePointerType(AsmParser &parser) { - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); Type elementType; if (parser.parseLess() || dispatchParse(parser, elementType)) return LLVMPointerType(); @@ -235,9 +235,9 @@ /// Supports both fixed and scalable vectors. static Type parseVectorType(AsmParser &parser) { SmallVector dims; - llvm::SMLoc dimPos, typePos; + SMLoc dimPos, typePos; Type elementType; - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); if (parser.parseLess() || parser.getCurrentLocation(&dimPos) || parser.parseDimensionList(dims, /*allowDynamic=*/true) || parser.getCurrentLocation(&typePos) || @@ -271,9 +271,9 @@ /// llvm-type ::= `array<` integer `x` llvm-type `>` static LLVMArrayType parseArrayType(AsmParser &parser) { SmallVector dims; - llvm::SMLoc sizePos; + SMLoc sizePos; Type elementType; - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); if (parser.parseLess() || parser.getCurrentLocation(&sizePos) || parser.parseDimensionList(dims, /*allowDynamic=*/false) || dispatchParse(parser, elementType) || parser.parseGreater()) @@ -292,7 +292,7 @@ static LLVMStructType trySetStructBody(LLVMStructType type, ArrayRef subtypes, bool isPacked, AsmParser &parser, - llvm::SMLoc subtypesLoc) { + SMLoc subtypesLoc) { for (Type t : subtypes) { if (!LLVMStructType::isValidElementType(t)) { parser.emitError(subtypesLoc) @@ -352,7 +352,7 @@ } // Handle intentionally opaque structs. - llvm::SMLoc kwLoc = parser.getCurrentLocation(); + SMLoc kwLoc = parser.getCurrentLocation(); if (succeeded(parser.parseOptionalKeyword("opaque"))) { if (!isIdentified) return parser.emitError(kwLoc, "only identified structs can be opaque"), @@ -388,7 +388,7 @@ // Parse subtypes. For identified structs, put the identifier of the struct on // the stack to support self-references in the recursive calls. SmallVector subtypes; - llvm::SMLoc subtypesLoc = parser.getCurrentLocation(); + SMLoc subtypesLoc = parser.getCurrentLocation(); do { if (isIdentified) knownStructNames.insert(name); @@ -417,7 +417,7 @@ /// prefix), and on failure fall back to parsing the short-hand version of the /// LLVM dialect types without the `!llvm` prefix. static Type dispatchParse(AsmParser &parser, bool allowAny = true) { - llvm::SMLoc keyLoc = parser.getCurrentLocation(); + SMLoc keyLoc = parser.getCurrentLocation(); // Try parsing any MLIR type. Type type; @@ -464,7 +464,7 @@ /// Parses one of the LLVM dialect types. Type mlir::LLVM::detail::parseType(DialectAsmParser &parser) { - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); Type type = dispatchParse(parser, /*allowAny=*/false); if (!type) return type; diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -1104,7 +1104,7 @@ static ParseResult parseYieldOp(OpAsmParser &parser, OperationState &result) { SmallVector opInfo; SmallVector types; - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); return failure(parser.parseOperandList(opInfo) || parser.parseOptionalAttrDict(result.attributes) || (!opInfo.empty() && parser.parseColonTypeList(types)) || @@ -1318,7 +1318,7 @@ SmallVector inputs, inputRegionArgs; SmallVector inputTypes; if (succeeded(parser.parseOptionalKeyword("ins"))) { - llvm::SMLoc inputsOperandsLoc = parser.getCurrentLocation(); + SMLoc inputsOperandsLoc = parser.getCurrentLocation(); if (parser.parseAssignmentListWithTypes(inputRegionArgs, inputs, inputTypes)) @@ -1333,7 +1333,7 @@ SmallVector outputs, outputRegionArgs; SmallVector outputTypes; if (succeeded(parser.parseOptionalKeyword("outs"))) { - llvm::SMLoc outputsOperandsLoc = parser.getCurrentLocation(); + SMLoc outputsOperandsLoc = parser.getCurrentLocation(); if (parser.parseAssignmentListWithTypes(outputRegionArgs, outputs, outputTypes)) @@ -1943,7 +1943,7 @@ parseCommonStructuredOpParts(OpAsmParser &parser, OperationState &result, SmallVectorImpl &inputTypes, SmallVectorImpl &outputTypes) { - llvm::SMLoc inputsOperandsLoc, outputsOperandsLoc; + SMLoc inputsOperandsLoc, outputsOperandsLoc; SmallVector inputsOperands, outputsOperands; parser.parseOptionalAttrDict(result.attributes); diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp --- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp +++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp @@ -2296,7 +2296,7 @@ SmallVector sizesInfo; auto indexType = parser.getBuilder().getIndexType(); Type srcType, dstType; - llvm::SMLoc offsetLoc; + SMLoc offsetLoc; if (parser.parseOperand(srcInfo) || parser.getCurrentLocation(&offsetLoc) || parser.parseOperandList(offsetInfo, OpAsmParser::Delimiter::Square)) return failure(); diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp --- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp +++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp @@ -573,7 +573,7 @@ StringRef attrName, StringRef name) { using ClauseT = decltype(std::declval().getValue()); StringRef enumStr; - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); if (parser.parseLParen() || parser.parseKeyword(&enumStr) || parser.parseRParen()) return failure(); @@ -749,7 +749,7 @@ clauseSegments[pos[allocateClause] + 1] = allocators.size(); } else if (clauseKeyword == "default") { StringRef defval; - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); if (checkAllowed(defaultClause) || parser.parseLParen() || parser.parseKeyword(&defval) || parser.parseRParen()) return failure(); @@ -937,7 +937,7 @@ "invalid schedule kind"); } if (!modifiers.empty()) { - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); if (Optional mod = symbolizeScheduleModifier(modifiers[0])) { result.addAttribute( diff --git a/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp b/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp --- a/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp +++ b/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp @@ -69,7 +69,7 @@ if (parser.parseLess()) return Type(); - llvm::SMLoc elementLoc = parser.getCurrentLocation(); + SMLoc elementLoc = parser.getCurrentLocation(); Type elementType = parsePDLType(parser); if (!elementType || parser.parseGreater()) return Type(); diff --git a/mlir/lib/Dialect/Quant/IR/TypeParser.cpp b/mlir/lib/Dialect/Quant/IR/TypeParser.cpp --- a/mlir/lib/Dialect/Quant/IR/TypeParser.cpp +++ b/mlir/lib/Dialect/Quant/IR/TypeParser.cpp @@ -78,7 +78,7 @@ } // Explicit storage min and storage max. - llvm::SMLoc minLoc = parser.getCurrentLocation(), maxLoc; + SMLoc minLoc = parser.getCurrentLocation(), maxLoc; if (parser.parseInteger(storageTypeMin) || parser.parseColon() || parser.getCurrentLocation(&maxLoc) || parser.parseInteger(storageTypeMax) || parser.parseGreater()) @@ -252,7 +252,7 @@ } // Parse scales/zeroPoints. - llvm::SMLoc scaleZPLoc = parser.getCurrentLocation(); + SMLoc scaleZPLoc = parser.getCurrentLocation(); do { scales.resize(scales.size() + 1); zeroPoints.resize(zeroPoints.size() + 1); diff --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp --- a/mlir/lib/Dialect/SCF/SCF.cpp +++ b/mlir/lib/Dialect/SCF/SCF.cpp @@ -2189,7 +2189,7 @@ return failure(); FunctionType functionType; - llvm::SMLoc typeLoc = parser.getCurrentLocation(); + SMLoc typeLoc = parser.getCurrentLocation(); if (failed(parser.parseColonType(functionType))) return failure(); diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp @@ -155,7 +155,7 @@ static Type parseAndVerifyType(SPIRVDialect const &dialect, DialectAsmParser &parser) { Type type; - llvm::SMLoc typeLoc = parser.getCurrentLocation(); + SMLoc typeLoc = parser.getCurrentLocation(); if (parser.parseType(type)) return Type(); @@ -199,7 +199,7 @@ static Type parseAndVerifyMatrixType(SPIRVDialect const &dialect, DialectAsmParser &parser) { Type type; - llvm::SMLoc typeLoc = parser.getCurrentLocation(); + SMLoc typeLoc = parser.getCurrentLocation(); if (parser.parseType(type)) return Type(); @@ -235,7 +235,7 @@ static Type parseAndVerifySampledImageType(SPIRVDialect const &dialect, DialectAsmParser &parser) { Type type; - llvm::SMLoc typeLoc = parser.getCurrentLocation(); + SMLoc typeLoc = parser.getCurrentLocation(); if (parser.parseType(type)) return Type(); @@ -263,7 +263,7 @@ if (parser.parseKeyword("stride") || parser.parseEqual()) return failure(); - llvm::SMLoc strideLoc = parser.getCurrentLocation(); + SMLoc strideLoc = parser.getCurrentLocation(); Optional optStride = parseAndVerify(dialect, parser); if (!optStride) return failure(); @@ -288,7 +288,7 @@ return Type(); SmallVector countDims; - llvm::SMLoc countLoc = parser.getCurrentLocation(); + SMLoc countLoc = parser.getCurrentLocation(); if (parser.parseDimensionList(countDims, /*allowDynamic=*/false)) return Type(); if (countDims.size() != 1) { @@ -326,7 +326,7 @@ return Type(); SmallVector dims; - llvm::SMLoc countLoc = parser.getCurrentLocation(); + SMLoc countLoc = parser.getCurrentLocation(); if (parser.parseDimensionList(dims, /*allowDynamic=*/false)) return Type(); @@ -367,7 +367,7 @@ return Type(); StringRef storageClassSpec; - llvm::SMLoc storageClassLoc = parser.getCurrentLocation(); + SMLoc storageClassLoc = parser.getCurrentLocation(); if (parser.parseComma() || parser.parseKeyword(&storageClassSpec)) return Type(); @@ -409,7 +409,7 @@ return Type(); SmallVector countDims; - llvm::SMLoc countLoc = parser.getCurrentLocation(); + SMLoc countLoc = parser.getCurrentLocation(); if (parser.parseDimensionList(countDims, /*allowDynamic=*/false)) return Type(); if (countDims.size() != 1) { @@ -442,7 +442,7 @@ static Optional parseAndVerify(SPIRVDialect const &dialect, DialectAsmParser &parser) { StringRef enumSpec; - llvm::SMLoc enumLoc = parser.getCurrentLocation(); + SMLoc enumLoc = parser.getCurrentLocation(); if (parser.parseKeyword(&enumSpec)) { return llvm::None; } @@ -568,7 +568,7 @@ SmallVectorImpl &memberDecorationInfo) { // Check if the first element is offset. - llvm::SMLoc offsetLoc = parser.getCurrentLocation(); + SMLoc offsetLoc = parser.getCurrentLocation(); StructType::OffsetInfo offset = 0; OptionalParseResult offsetParseResult = parser.parseOptionalInteger(offset); if (offsetParseResult.hasValue()) { @@ -875,7 +875,7 @@ /// of the parsed keyword, and returns failure if any error occurs. static ParseResult parseKeywordList( DialectAsmParser &parser, - function_ref processKeyword) { + function_ref processKeyword) { if (parser.parseLSquare()) return failure(); @@ -992,10 +992,10 @@ ArrayAttr capabilitiesAttr; { SmallVector capabilities; - llvm::SMLoc errorloc; + SMLoc errorloc; StringRef errorKeyword; - auto processCapability = [&](llvm::SMLoc loc, StringRef capability) { + auto processCapability = [&](SMLoc loc, StringRef capability) { if (auto capSymbol = spirv::symbolizeCapability(capability)) { capabilities.push_back( builder.getI32IntegerAttr(static_cast(*capSymbol))); @@ -1015,10 +1015,10 @@ ArrayAttr extensionsAttr; { SmallVector extensions; - llvm::SMLoc errorloc; + SMLoc errorloc; StringRef errorKeyword; - auto processExtension = [&](llvm::SMLoc loc, StringRef extension) { + auto processExtension = [&](SMLoc loc, StringRef extension) { if (spirv::symbolizeExtension(extension)) { extensions.push_back(builder.getStringAttr(extension)); return success(); diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp @@ -695,7 +695,7 @@ } static Type getElementType(Type type, Attribute indices, OpAsmParser &parser, - llvm::SMLoc loc) { + SMLoc loc) { auto errorFn = [&](StringRef err) -> InFlightDiagnostic { return parser.emitError(loc, err); }; @@ -721,7 +721,7 @@ SmallVector operandInfo; OpAsmParser::OperandType ptrInfo, valueInfo; Type type; - llvm::SMLoc loc; + SMLoc loc; if (parseEnumStrAttr(scope, parser, state, kMemoryScopeAttrName) || parseEnumStrAttr(memoryScope, parser, state, kSemanticsAttrName) || parser.parseOperandList(operandInfo, (hasValue ? 2 : 1)) || @@ -1508,7 +1508,7 @@ OpAsmParser::OperandType compositeInfo; Attribute indicesAttr; Type compositeType; - llvm::SMLoc attrLocation; + SMLoc attrLocation; if (parser.parseOperand(compositeInfo) || parser.getCurrentLocation(&attrLocation) || diff --git a/mlir/lib/Dialect/Vector/VectorOps.cpp b/mlir/lib/Dialect/Vector/VectorOps.cpp --- a/mlir/lib/Dialect/Vector/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/VectorOps.cpp @@ -900,7 +900,7 @@ } static ParseResult parseExtractOp(OpAsmParser &parser, OperationState &result) { - llvm::SMLoc attributeLoc, typeLoc; + SMLoc attributeLoc, typeLoc; NamedAttrList attrs; OpAsmParser::OperandType vector; Type type; @@ -2695,7 +2695,7 @@ static ParseResult parseTransferReadOp(OpAsmParser &parser, OperationState &result) { auto &builder = parser.getBuilder(); - llvm::SMLoc typesLoc; + SMLoc typesLoc; OpAsmParser::OperandType sourceInfo; SmallVector indexInfo; OpAsmParser::OperandType paddingInfo; @@ -3075,7 +3075,7 @@ static ParseResult parseTransferWriteOp(OpAsmParser &parser, OperationState &result) { auto &builder = parser.getBuilder(); - llvm::SMLoc typesLoc; + SMLoc typesLoc; OpAsmParser::OperandType vectorInfo, sourceInfo; SmallVector indexInfo; SmallVector types; diff --git a/mlir/lib/ExecutionEngine/JitRunner.cpp b/mlir/lib/ExecutionEngine/JitRunner.cpp --- a/mlir/lib/ExecutionEngine/JitRunner.cpp +++ b/mlir/lib/ExecutionEngine/JitRunner.cpp @@ -121,7 +121,7 @@ } llvm::SourceMgr sourceMgr; - sourceMgr.AddNewSourceBuffer(std::move(file), llvm::SMLoc()); + sourceMgr.AddNewSourceBuffer(std::move(file), SMLoc()); return OwningModuleRef(parseSourceFile(sourceMgr, context)); } diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp --- a/mlir/lib/IR/Diagnostics.cpp +++ b/mlir/lib/IR/Diagnostics.cpp @@ -364,7 +364,7 @@ // Otherwise, try to load the source file. std::string ignored; unsigned id = - mgr.AddIncludeFile(std::string(filename), llvm::SMLoc(), ignored); + mgr.AddIncludeFile(std::string(filename), SMLoc(), ignored); filenameToBufId[filename] = id; return id; } @@ -449,7 +449,7 @@ if (!loc.isa()) strOS << loc << ": "; strOS << message; - return mgr.PrintMessage(os, llvm::SMLoc(), getDiagKind(kind), strOS.str()); + return mgr.PrintMessage(os, SMLoc(), getDiagKind(kind), strOS.str()); } // Otherwise if we are displaying the source line, try to convert the file @@ -562,15 +562,15 @@ /// Get a memory buffer for the given file, or the main file of the source /// manager if one doesn't exist. This always returns non-null. -llvm::SMLoc SourceMgrDiagnosticHandler::convertLocToSMLoc(FileLineColLoc loc) { +SMLoc SourceMgrDiagnosticHandler::convertLocToSMLoc(FileLineColLoc loc) { // The column and line may be zero to represent unknown column and/or unknown /// line/column information. if (loc.getLine() == 0 || loc.getColumn() == 0) - return llvm::SMLoc(); + return SMLoc(); unsigned bufferId = impl->getSourceMgrBufferIDForFile(mgr, loc.getFilename()); if (!bufferId) - return llvm::SMLoc(); + return SMLoc(); return mgr.FindLocForLineAndColumn(bufferId, loc.getLine(), loc.getColumn()); } @@ -586,7 +586,7 @@ DiagnosticSeverity kind; unsigned lineNo; StringRef substring; - llvm::SMLoc fileLoc; + SMLoc fileLoc; bool matched; }; @@ -669,7 +669,7 @@ } // Point to the start of expected-*. - auto expectedStart = llvm::SMLoc::getFromPointer(matches[0].data()); + auto expectedStart = SMLoc::getFromPointer(matches[0].data()); DiagnosticSeverity kind; if (matches[1] == "error") @@ -755,8 +755,8 @@ for (auto &err : expectedDiagsPair.second) { if (err.matched) continue; - llvm::SMRange range(err.fileLoc, - llvm::SMLoc::getFromPointer(err.fileLoc.getPointer() + + SMRange range(err.fileLoc, + SMLoc::getFromPointer(err.fileLoc.getPointer() + err.substring.size())); mgr.PrintMessage(os, err.fileLoc, llvm::SourceMgr::DK_Error, "expected " + getDiagKindStr(err.kind) + " \"" + diff --git a/mlir/lib/IR/FunctionImplementation.cpp b/mlir/lib/IR/FunctionImplementation.cpp --- a/mlir/lib/IR/FunctionImplementation.cpp +++ b/mlir/lib/IR/FunctionImplementation.cpp @@ -25,7 +25,7 @@ // types, or just be a type list. It isn't ok to sometimes have SSA ID's and // sometimes not. auto parseArgument = [&]() -> ParseResult { - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); // Parse argument name if present. OpAsmParser::OperandType argument; @@ -80,7 +80,7 @@ if (parseArgument()) return failure(); - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); if (argTypes.size() == numTypedArguments && succeeded(parser.parseOptionalComma())) return parser.emitError( @@ -212,7 +212,7 @@ return failure(); // Parse the function signature. - llvm::SMLoc signatureLocation = parser.getCurrentLocation(); + SMLoc signatureLocation = parser.getCurrentLocation(); bool isVariadic = false; if (parseFunctionSignature(parser, allowVariadic, entryArgs, argTypes, argAttrs, argLocations, isVariadic, resultTypes, @@ -231,7 +231,7 @@ // If function attributes are present, parse them. NamedAttrList parsedAttributes; - llvm::SMLoc attributeDictLocation = parser.getCurrentLocation(); + SMLoc attributeDictLocation = parser.getCurrentLocation(); if (parser.parseOptionalAttrDictWithKeyword(parsedAttributes)) return failure(); @@ -256,7 +256,7 @@ // Parse the optional function body. The printer will not print the body if // its empty, so disallow parsing of empty body in the parser. auto *body = result.addRegion(); - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); OptionalParseResult parseResult = parser.parseOptionalRegion( *body, entryArgs, entryArgs.empty() ? ArrayRef() : argTypes, entryArgs.empty() ? ArrayRef() : argLocations, diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -1144,7 +1144,7 @@ Type type; // If the operand list is in-between parentheses, then we have a generic form. // (see the fallback in `printOneResultOp`). - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); if (!parser.parseOptionalLParen()) { if (parser.parseOperandList(ops) || parser.parseRParen() || parser.parseOptionalAttrDict(result.attributes) || diff --git a/mlir/lib/Parser/AffineParser.cpp b/mlir/lib/Parser/AffineParser.cpp --- a/mlir/lib/Parser/AffineParser.cpp +++ b/mlir/lib/Parser/AffineParser.cpp @@ -17,7 +17,6 @@ using namespace mlir; using namespace mlir::detail; -using llvm::SMLoc; namespace { @@ -81,13 +80,13 @@ AffineExpr parseSymbolSSAIdExpr(); AffineExpr getAffineBinaryOpExpr(AffineHighPrecOp op, AffineExpr lhs, - AffineExpr rhs, llvm::SMLoc opLoc); + AffineExpr rhs, SMLoc opLoc); AffineExpr getAffineBinaryOpExpr(AffineLowPrecOp op, AffineExpr lhs, AffineExpr rhs); AffineExpr parseAffineOperandExpr(AffineExpr lhs); AffineExpr parseAffineLowPrecOpExpr(AffineExpr llhs, AffineLowPrecOp llhsOp); AffineExpr parseAffineHighPrecOpExpr(AffineExpr llhs, AffineHighPrecOp llhsOp, - llvm::SMLoc llhsOpLoc); + SMLoc llhsOpLoc); AffineExpr parseAffineConstraint(bool *isEq); private: @@ -683,7 +682,7 @@ return AffineParser(state).parseAffineMapOrIntegerSetInline(map, set); } ParseResult Parser::parseAffineMapReference(AffineMap &map) { - llvm::SMLoc curLoc = getToken().getLoc(); + SMLoc curLoc = getToken().getLoc(); IntegerSet set; if (parseAffineMapOrIntegerSetReference(map, set)) return failure(); @@ -692,7 +691,7 @@ return success(); } ParseResult Parser::parseIntegerSetReference(IntegerSet &set) { - llvm::SMLoc curLoc = getToken().getLoc(); + SMLoc curLoc = getToken().getLoc(); AffineMap map; if (parseAffineMapOrIntegerSetReference(map, set)) return failure(); diff --git a/mlir/lib/Parser/AsmParserImpl.h b/mlir/lib/Parser/AsmParserImpl.h --- a/mlir/lib/Parser/AsmParserImpl.h +++ b/mlir/lib/Parser/AsmParserImpl.h @@ -25,12 +25,12 @@ template class AsmParserImpl : public BaseT { public: - AsmParserImpl(llvm::SMLoc nameLoc, Parser &parser) + AsmParserImpl(SMLoc nameLoc, Parser &parser) : nameLoc(nameLoc), parser(parser) {} ~AsmParserImpl() override = default; /// Return the location of the original name token. - llvm::SMLoc getNameLoc() const override { return nameLoc; } + SMLoc getNameLoc() const override { return nameLoc; } //===--------------------------------------------------------------------===// // Utilities @@ -40,7 +40,7 @@ bool didEmitError() const { return emittedError; } /// Emit a diagnostic at the specified location and return failure. - InFlightDiagnostic emitError(llvm::SMLoc loc, const Twine &message) override { + InFlightDiagnostic emitError(SMLoc loc, const Twine &message) override { emittedError = true; return parser.emitError(loc, message); } @@ -51,12 +51,12 @@ /// Get the location of the next token and store it into the argument. This /// always succeeds. - llvm::SMLoc getCurrentLocation() override { + SMLoc getCurrentLocation() override { return parser.getToken().getLoc(); } /// Re-encode the given source location as an MLIR location and return it. - Location getEncodedSourceLoc(llvm::SMLoc loc) override { + Location getEncodedSourceLoc(SMLoc loc) override { return parser.getEncodedSourceLocation(loc); } @@ -291,7 +291,7 @@ ParseResult parseFloat(double &result) override { bool isNegative = parser.consumeIf(Token::minus); Token curTok = parser.getToken(); - llvm::SMLoc loc = curTok.getLoc(); + SMLoc loc = curTok.getLoc(); // Check for a floating point value. if (curTok.is(Token::floatliteral)) { @@ -491,7 +491,7 @@ protected: /// The source location of the dialect symbol. - llvm::SMLoc nameLoc; + SMLoc nameLoc; /// The main parser. Parser &parser; diff --git a/mlir/lib/Parser/AsmParserState.cpp b/mlir/lib/Parser/AsmParserState.cpp --- a/mlir/lib/Parser/AsmParserState.cpp +++ b/mlir/lib/Parser/AsmParserState.cpp @@ -19,7 +19,7 @@ struct AsmParserState::Impl { /// A map from a SymbolRefAttr to a range of uses. using SymbolUseMap = - DenseMap, 0>>; + DenseMap, 0>>; struct PartialOpDef { explicit PartialOpDef(const OperationName &opName) { @@ -48,7 +48,7 @@ /// A set of value definitions that are placeholders for forward references. /// This map should be empty if the parser finishes successfully. - DenseMap> placeholderValueUses; + DenseMap> placeholderValueUses; /// The symbol table operations within the IR. SmallVector>> @@ -75,7 +75,7 @@ opAndUseMapIt.first, it.first.cast(), symbolOps))) continue; - for (ArrayRef useRange : it.second) { + for (ArrayRef useRange : it.second) { for (const auto &symIt : llvm::zip(symbolOps, useRange)) { auto opIt = operationToIdx.find(std::get<0>(symIt)); if (opIt != operationToIdx.end()) @@ -121,9 +121,9 @@ : &*impl->operations[it->second]; } -llvm::SMRange AsmParserState::convertIdLocToRange(llvm::SMLoc loc) { +SMRange AsmParserState::convertIdLocToRange(SMLoc loc) { if (!loc.isValid()) - return llvm::SMRange(); + return SMRange(); // Return if the given character is a valid identifier character. auto isIdentifierChar = [](char c) { @@ -133,7 +133,7 @@ const char *curPtr = loc.getPointer(); while (*curPtr && isIdentifierChar(*(++curPtr))) continue; - return llvm::SMRange(loc, llvm::SMLoc::getFromPointer(curPtr)); + return SMRange(loc, SMLoc::getFromPointer(curPtr)); } //===----------------------------------------------------------------------===// @@ -166,8 +166,8 @@ } void AsmParserState::finalizeOperationDefinition( - Operation *op, llvm::SMRange nameLoc, llvm::SMLoc endLoc, - ArrayRef> resultGroups) { + Operation *op, SMRange nameLoc, SMLoc endLoc, + ArrayRef> resultGroups) { assert(!impl->partialOperations.empty() && "expected valid partial operation definition"); Impl::PartialOpDef partialOpDef = impl->partialOperations.pop_back_val(); @@ -210,7 +210,7 @@ impl->symbolUseScopes.pop_back(); } -void AsmParserState::addDefinition(Block *block, llvm::SMLoc location) { +void AsmParserState::addDefinition(Block *block, SMLoc location) { auto it = impl->blocksToIdx.find(block); if (it == impl->blocksToIdx.end()) { impl->blocksToIdx.try_emplace(block, impl->blocks.size()); @@ -225,7 +225,7 @@ } void AsmParserState::addDefinition(BlockArgument blockArg, - llvm::SMLoc location) { + SMLoc location) { auto it = impl->blocksToIdx.find(blockArg.getOwner()); assert(it != impl->blocksToIdx.end() && "expected owner block to have an entry"); @@ -237,7 +237,7 @@ def.arguments[argIdx] = SMDefinition(convertIdLocToRange(location)); } -void AsmParserState::addUses(Value value, ArrayRef locations) { +void AsmParserState::addUses(Value value, ArrayRef locations) { // Handle the case where the value is an operation result. if (OpResult result = value.dyn_cast()) { // Check to see if a definition for the parent operation has been recorded. @@ -258,7 +258,7 @@ OperationDefinition &def = *impl->operations[existingIt->second]; for (auto &resultGroup : llvm::reverse(def.resultGroups)) { if (resultNo >= resultGroup.startIndex) { - for (llvm::SMLoc loc : locations) + for (SMLoc loc : locations) resultGroup.definition.uses.push_back(convertIdLocToRange(loc)); return; } @@ -273,11 +273,11 @@ "expected valid block definition for block argument"); BlockDefinition &blockDef = *impl->blocks[existingIt->second]; SMDefinition &argDef = blockDef.arguments[arg.getArgNumber()]; - for (llvm::SMLoc loc : locations) + for (SMLoc loc : locations) argDef.uses.emplace_back(convertIdLocToRange(loc)); } -void AsmParserState::addUses(Block *block, ArrayRef locations) { +void AsmParserState::addUses(Block *block, ArrayRef locations) { auto it = impl->blocksToIdx.find(block); if (it == impl->blocksToIdx.end()) { it = impl->blocksToIdx.try_emplace(block, impl->blocks.size()).first; @@ -285,12 +285,12 @@ } BlockDefinition &def = *impl->blocks[it->second]; - for (llvm::SMLoc loc : locations) + for (SMLoc loc : locations) def.definition.uses.push_back(convertIdLocToRange(loc)); } void AsmParserState::addUses(SymbolRefAttr refAttr, - ArrayRef locations) { + ArrayRef locations) { // Ignore this symbol if no scopes are active. if (impl->symbolUseScopes.empty()) return; diff --git a/mlir/lib/Parser/AttributeParser.cpp b/mlir/lib/Parser/AttributeParser.cpp --- a/mlir/lib/Parser/AttributeParser.cpp +++ b/mlir/lib/Parser/AttributeParser.cpp @@ -154,7 +154,7 @@ case Token::at_identifier: { // When populating the parser state, this is a list of locations for all of // the nested references. - SmallVector referenceLocations; + SmallVector referenceLocations; if (state.asmState) referenceLocations.push_back(getToken().getLocRange()); @@ -372,7 +372,7 @@ Attribute Parser::parseDecOrHexAttr(Type type, bool isNegative) { Token tok = getToken(); StringRef spelling = tok.getSpelling(); - llvm::SMLoc loc = tok.getLoc(); + SMLoc loc = tok.getLoc(); consumeToken(Token::integer); if (!type) { @@ -439,24 +439,24 @@ /// Build a dense attribute instance with the parsed elements and the given /// shaped type. - DenseElementsAttr getAttr(llvm::SMLoc loc, ShapedType type); + DenseElementsAttr getAttr(SMLoc loc, ShapedType type); ArrayRef getShape() const { return shape; } private: /// Get the parsed elements for an integer attribute. - ParseResult getIntAttrElements(llvm::SMLoc loc, Type eltTy, + ParseResult getIntAttrElements(SMLoc loc, Type eltTy, std::vector &intValues); /// Get the parsed elements for a float attribute. - ParseResult getFloatAttrElements(llvm::SMLoc loc, FloatType eltTy, + ParseResult getFloatAttrElements(SMLoc loc, FloatType eltTy, std::vector &floatValues); /// Build a Dense String attribute for the given type. - DenseElementsAttr getStringAttr(llvm::SMLoc loc, ShapedType type, Type eltTy); + DenseElementsAttr getStringAttr(SMLoc loc, ShapedType type, Type eltTy); /// Build a Dense attribute with hex data for the given type. - DenseElementsAttr getHexAttr(llvm::SMLoc loc, ShapedType type); + DenseElementsAttr getHexAttr(SMLoc loc, ShapedType type); /// Parse a single element, returning failure if it isn't a valid element /// literal. For example: @@ -505,7 +505,7 @@ /// Build a dense attribute instance with the parsed elements and the given /// shaped type. -DenseElementsAttr TensorLiteralParser::getAttr(llvm::SMLoc loc, +DenseElementsAttr TensorLiteralParser::getAttr(SMLoc loc, ShapedType type) { Type eltType = type.getElementType(); @@ -571,7 +571,7 @@ /// Build a Dense Integer attribute for the given type. ParseResult -TensorLiteralParser::getIntAttrElements(llvm::SMLoc loc, Type eltTy, +TensorLiteralParser::getIntAttrElements(SMLoc loc, Type eltTy, std::vector &intValues) { intValues.reserve(storage.size()); bool isUintType = eltTy.isUnsignedInteger(); @@ -615,7 +615,7 @@ /// Build a Dense Float attribute for the given type. ParseResult -TensorLiteralParser::getFloatAttrElements(llvm::SMLoc loc, FloatType eltTy, +TensorLiteralParser::getFloatAttrElements(SMLoc loc, FloatType eltTy, std::vector &floatValues) { floatValues.reserve(storage.size()); for (const auto &signAndToken : storage) { @@ -656,7 +656,7 @@ } /// Build a Dense String attribute for the given type. -DenseElementsAttr TensorLiteralParser::getStringAttr(llvm::SMLoc loc, +DenseElementsAttr TensorLiteralParser::getStringAttr(SMLoc loc, ShapedType type, Type eltTy) { if (hexStorage.hasValue()) { @@ -678,7 +678,7 @@ } /// Build a Dense attribute with hex data for the given type. -DenseElementsAttr TensorLiteralParser::getHexAttr(llvm::SMLoc loc, +DenseElementsAttr TensorLiteralParser::getHexAttr(SMLoc loc, ShapedType type) { Type elementType = type.getElementType(); if (!elementType.isIntOrIndexOrFloat() && !elementType.isa()) { @@ -833,7 +833,7 @@ /// Parse an opaque elements attribute. Attribute Parser::parseOpaqueElementsAttr(Type attrType) { - llvm::SMLoc loc = getToken().getLoc(); + SMLoc loc = getToken().getLoc(); consumeToken(Token::kw_opaque); if (parseToken(Token::less, "expected '<' after 'opaque'")) return nullptr; @@ -890,7 +890,7 @@ /// Parse a sparse elements attribute. Attribute Parser::parseSparseElementsAttr(Type attrType) { - llvm::SMLoc loc = getToken().getLoc(); + SMLoc loc = getToken().getLoc(); consumeToken(Token::kw_sparse); if (parseToken(Token::less, "Expected '<' after 'sparse'")) return nullptr; diff --git a/mlir/lib/Parser/DialectSymbolParser.cpp b/mlir/lib/Parser/DialectSymbolParser.cpp --- a/mlir/lib/Parser/DialectSymbolParser.cpp +++ b/mlir/lib/Parser/DialectSymbolParser.cpp @@ -20,7 +20,6 @@ using namespace mlir; using namespace mlir::detail; using llvm::MemoryBuffer; -using llvm::SMLoc; using llvm::SourceMgr; namespace { @@ -157,7 +156,7 @@ return (p.emitError("expected string literal data in dialect symbol"), nullptr); symbolData = p.getToken().getStringValue(); - loc = llvm::SMLoc::getFromPointer(p.getToken().getLoc().getPointer() + 1); + loc = SMLoc::getFromPointer(p.getToken().getLoc().getPointer() + 1); p.consumeToken(Token::string); // Consume the '>'. @@ -169,7 +168,7 @@ auto dotHalves = identifier.split('.'); dialectName = dotHalves.first; auto prettyName = dotHalves.second; - loc = llvm::SMLoc::getFromPointer(prettyName.data()); + loc = SMLoc::getFromPointer(prettyName.data()); // If the dialect's symbol is followed immediately by a <, then lex the body // of it into prettyName. @@ -183,7 +182,7 @@ } // Record the name location of the type remapped to the top level buffer. - llvm::SMLoc locInTopLevelBuffer = p.remapLocationToTopLevelBuffer(loc); + SMLoc locInTopLevelBuffer = p.remapLocationToTopLevelBuffer(loc); p.getState().symbols.nestedParserLocs.push_back(locInTopLevelBuffer); // Call into the provided symbol construction function. @@ -239,7 +238,7 @@ Attribute attr = parseExtendedSymbol( *this, Token::hash_identifier, state.symbols.attributeAliasDefinitions, [&](StringRef dialectName, StringRef symbolData, - llvm::SMLoc loc) -> Attribute { + SMLoc loc) -> Attribute { // Parse an optional trailing colon type. Type attrType = type; if (consumeIf(Token::colon) && !(attrType = parseType())) @@ -282,7 +281,7 @@ return parseExtendedSymbol( *this, Token::exclamation_identifier, state.symbols.typeAliasDefinitions, [&](StringRef dialectName, StringRef symbolData, - llvm::SMLoc loc) -> Type { + SMLoc loc) -> Type { // If we found a registered dialect, then ask it to parse the type. auto *dialect = state.context->getOrLoadDialect(dialectName); diff --git a/mlir/lib/Parser/Lexer.h b/mlir/lib/Parser/Lexer.h --- a/mlir/lib/Parser/Lexer.h +++ b/mlir/lib/Parser/Lexer.h @@ -30,7 +30,7 @@ /// Encode the specified source location information into a Location object /// for attachment to the IR or error reporting. - Location getEncodedSourceLocation(llvm::SMLoc loc); + Location getEncodedSourceLocation(SMLoc loc); /// Change the position of the lexer cursor. The next token we lex will start /// at the designated point in the input. diff --git a/mlir/lib/Parser/Lexer.cpp b/mlir/lib/Parser/Lexer.cpp --- a/mlir/lib/Parser/Lexer.cpp +++ b/mlir/lib/Parser/Lexer.cpp @@ -17,9 +17,8 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/SourceMgr.h" -using namespace mlir; -using llvm::SMLoc; +using namespace mlir; // Returns true if 'c' is an allowable punctuation character: [$._-] // Returns false otherwise. @@ -36,7 +35,7 @@ /// Encode the specified source location information into an attribute for /// attachment to the IR. -Location Lexer::getEncodedSourceLocation(llvm::SMLoc loc) { +Location Lexer::getEncodedSourceLocation(SMLoc loc) { auto &sourceMgr = getSourceMgr(); unsigned mainFileID = sourceMgr.getMainFileID(); diff --git a/mlir/lib/Parser/Parser.h b/mlir/lib/Parser/Parser.h --- a/mlir/lib/Parser/Parser.h +++ b/mlir/lib/Parser/Parser.h @@ -71,11 +71,11 @@ InFlightDiagnostic emitError(const Twine &message = {}) { return emitError(state.curToken.getLoc(), message); } - InFlightDiagnostic emitError(llvm::SMLoc loc, const Twine &message = {}); + InFlightDiagnostic emitError(SMLoc loc, const Twine &message = {}); /// Encode the specified source location information into an attribute for /// attachment to the IR. - Location getEncodedSourceLocation(llvm::SMLoc loc) { + Location getEncodedSourceLocation(SMLoc loc) { // If there are no active nested parsers, we can get the encoded source // location directly. if (state.parserDepth == 0) @@ -88,7 +88,7 @@ /// Remaps the given SMLoc to the top level lexer of the parser. This is used /// to adjust locations of potentially nested parsers to ensure that they can /// be emitted properly as diagnostics. - llvm::SMLoc remapLocationToTopLevelBuffer(llvm::SMLoc loc) { + SMLoc remapLocationToTopLevelBuffer(SMLoc loc) { // If there are no active nested parsers, we can return location directly. SymbolState &symbols = state.symbols; if (state.parserDepth == 0) @@ -101,7 +101,7 @@ size_t offset = loc.getPointer() - state.lex.getBufferBegin(); auto *rawLoc = symbols.nestedParserLocs[state.parserDepth - 1].getPointer() + offset; - return llvm::SMLoc::getFromPointer(rawLoc); + return SMLoc::getFromPointer(rawLoc); } //===--------------------------------------------------------------------===// @@ -158,7 +158,7 @@ /// unlike `OpBuilder::getType`, this method does not implicitly insert a /// context parameter. template - T getChecked(llvm::SMLoc loc, ParamsT &&...params) { + T getChecked(SMLoc loc, ParamsT &&...params) { return T::getChecked([&] { return emitError(loc); }, std::forward(params)...); } diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -29,7 +29,6 @@ using namespace mlir; using namespace mlir::detail; using llvm::MemoryBuffer; -using llvm::SMLoc; using llvm::SourceMgr; //===----------------------------------------------------------------------===// @@ -198,7 +197,7 @@ ParseResult Parser::parseFloatFromIntegerLiteral( Optional &result, const Token &tok, bool isNegative, const llvm::fltSemantics &semantics, size_t typeSizeInBits) { - llvm::SMLoc loc = tok.getLoc(); + SMLoc loc = tok.getLoc(); StringRef spelling = tok.getSpelling(); bool isHex = spelling.size() > 1 && spelling[1] == 'x'; if (!isHex) { @@ -373,7 +372,7 @@ /// Parse a region body into 'region'. ParseResult - parseRegionBody(Region ®ion, llvm::SMLoc startLoc, + parseRegionBody(Region ®ion, SMLoc startLoc, ArrayRef> entryArguments, ArrayRef argLocations, bool isIsolatedNameScope); @@ -934,7 +933,7 @@ // Add this operation to the assembly state if it was provided to populate. if (state.asmState) { unsigned resultIt = 0; - SmallVector> asmResultGroups; + SmallVector> asmResultGroups; asmResultGroups.reserve(resultIDs.size()); for (ResultRecord &record : resultIDs) { asmResultGroups.emplace_back(resultIt, std::get<2>(record)); @@ -1281,7 +1280,7 @@ } /// Emit a diagnostic at the specified location and return failure. - InFlightDiagnostic emitError(llvm::SMLoc loc, const Twine &message) override { + InFlightDiagnostic emitError(SMLoc loc, const Twine &message) override { return AsmParserImpl::emitError(loc, "custom op '" + opName + "' " + message); } @@ -1692,7 +1691,7 @@ Operation * OperationParser::parseCustomOperation(ArrayRef resultIDs) { - llvm::SMLoc opLoc = getToken().getLoc(); + SMLoc opLoc = getToken().getLoc(); FailureOr opNameInfo = parseCustomOperationName(); if (failed(opNameInfo)) @@ -1849,7 +1848,7 @@ } ParseResult OperationParser::parseRegionBody( - Region ®ion, llvm::SMLoc startLoc, + Region ®ion, SMLoc startLoc, ArrayRef> entryArguments, ArrayRef argLocations, bool isIsolatedNameScope) { assert(argLocations.empty() || argLocations.size() == entryArguments.size()); @@ -2252,7 +2251,7 @@ "could not open input file " + filename); // Load the MLIR source file. - sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc()); + sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), SMLoc()); return parseSourceFile(sourceMgr, block, context, sourceFileLoc, asmState); } diff --git a/mlir/lib/Parser/ParserState.h b/mlir/lib/Parser/ParserState.h --- a/mlir/lib/Parser/ParserState.h +++ b/mlir/lib/Parser/ParserState.h @@ -32,7 +32,7 @@ /// active nested parsers. Given that some nested parsers, i.e. custom dialect /// parsers, operate on a temporary memory buffer, this provides an anchor /// point for emitting diagnostics. - SmallVector nestedParserLocs; + SmallVector nestedParserLocs; /// The top-level lexer that contains the original memory buffer provided by /// the user. This is used by nested parsers to get a properly encoded source diff --git a/mlir/lib/Parser/Token.h b/mlir/lib/Parser/Token.h --- a/mlir/lib/Parser/Token.h +++ b/mlir/lib/Parser/Token.h @@ -102,9 +102,9 @@ std::string getSymbolReference() const; // Location processing. - llvm::SMLoc getLoc() const; - llvm::SMLoc getEndLoc() const; - llvm::SMRange getLocRange() const; + SMLoc getLoc() const; + SMLoc getEndLoc() const; + SMRange getLocRange() const; /// Given a punctuation or keyword token kind, return the spelling of the /// token as a string. Warning: This will abort on markers, identifiers and diff --git a/mlir/lib/Parser/Token.cpp b/mlir/lib/Parser/Token.cpp --- a/mlir/lib/Parser/Token.cpp +++ b/mlir/lib/Parser/Token.cpp @@ -12,9 +12,8 @@ #include "Token.h" #include "llvm/ADT/StringExtras.h" + using namespace mlir; -using llvm::SMLoc; -using llvm::SMRange; SMLoc Token::getLoc() const { return SMLoc::getFromPointer(spelling.data()); } diff --git a/mlir/lib/Parser/TypeParser.cpp b/mlir/lib/Parser/TypeParser.cpp --- a/mlir/lib/Parser/TypeParser.cpp +++ b/mlir/lib/Parser/TypeParser.cpp @@ -116,7 +116,7 @@ if (parseToken(Token::less, "expected '<' in complex type")) return nullptr; - llvm::SMLoc elementTypeLoc = getToken().getLoc(); + SMLoc elementTypeLoc = getToken().getLoc(); auto elementType = parseType(); if (!elementType || parseToken(Token::greater, "expected '>' in complex type")) @@ -190,7 +190,7 @@ /// memory-space ::= integer-literal | attribute /// Type Parser::parseMemRefType() { - llvm::SMLoc loc = getToken().getLoc(); + SMLoc loc = getToken().getLoc(); consumeToken(Token::kw_memref); if (parseToken(Token::less, "expected '<' in memref type")) diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp --- a/mlir/lib/Pass/PassRegistry.cpp +++ b/mlir/lib/Pass/PassRegistry.cpp @@ -371,9 +371,9 @@ pipelineMgr.AddNewSourceBuffer( llvm::MemoryBuffer::getMemBuffer(text, "MLIR Textual PassPipeline Parser", /*RequiresNullTerminator=*/false), - llvm::SMLoc()); + SMLoc()); auto errorHandler = [&](const char *rawLoc, Twine msg) { - pipelineMgr.PrintMessage(errorStream, llvm::SMLoc::getFromPointer(rawLoc), + pipelineMgr.PrintMessage(errorStream, SMLoc::getFromPointer(rawLoc), llvm::SourceMgr::DK_Error, msg); return failure(); }; diff --git a/mlir/lib/Support/MlirOptMain.cpp b/mlir/lib/Support/MlirOptMain.cpp --- a/mlir/lib/Support/MlirOptMain.cpp +++ b/mlir/lib/Support/MlirOptMain.cpp @@ -37,7 +37,6 @@ using namespace mlir; using namespace llvm; -using llvm::SMLoc; /// Perform the actions on the input file indicated by the command line flags /// within the specified context. diff --git a/mlir/lib/Support/ToolUtilities.cpp b/mlir/lib/Support/ToolUtilities.cpp --- a/mlir/lib/Support/ToolUtilities.cpp +++ b/mlir/lib/Support/ToolUtilities.cpp @@ -37,7 +37,7 @@ // Add the original buffer to the source manager. llvm::SourceMgr fileSourceMgr; - fileSourceMgr.AddNewSourceBuffer(std::move(originalBuffer), llvm::SMLoc()); + fileSourceMgr.AddNewSourceBuffer(std::move(originalBuffer), SMLoc()); // Flag near misses by iterating over all the sub-buffers found when splitting // with the prefix of the splitMarker. Use a sliding window where we only add @@ -60,7 +60,7 @@ prev = buffer.drop_front(checkLen); } else { // TODO: Consider making this a failure. - auto splitLoc = llvm::SMLoc::getFromPointer(buffer.data()); + auto splitLoc = SMLoc::getFromPointer(buffer.data()); fileSourceMgr.PrintMessage(llvm::errs(), splitLoc, llvm::SourceMgr::DK_Warning, "near miss with file split marker"); @@ -74,7 +74,7 @@ // Process each chunk in turn. bool hadFailure = false; for (auto &subBuffer : sourceBuffers) { - auto splitLoc = llvm::SMLoc::getFromPointer(subBuffer.data()); + auto splitLoc = SMLoc::getFromPointer(subBuffer.data()); unsigned splitLine = fileSourceMgr.getLineAndColumn(splitLoc).first; auto subMemBuffer = llvm::MemoryBuffer::getMemBufferCopy( subBuffer, Twine("within split at ") + diff --git a/mlir/lib/TableGen/AttrOrTypeDef.cpp b/mlir/lib/TableGen/AttrOrTypeDef.cpp --- a/mlir/lib/TableGen/AttrOrTypeDef.cpp +++ b/mlir/lib/TableGen/AttrOrTypeDef.cpp @@ -147,7 +147,7 @@ return value.empty() ? Optional() : value; } -ArrayRef AttrOrTypeDef::getLoc() const { return def->getLoc(); } +ArrayRef AttrOrTypeDef::getLoc() const { return def->getLoc(); } bool AttrOrTypeDef::skipDefaultBuilders() const { return def->getValueAsBit("skipDefaultBuilders"); diff --git a/mlir/lib/TableGen/Builder.cpp b/mlir/lib/TableGen/Builder.cpp --- a/mlir/lib/TableGen/Builder.cpp +++ b/mlir/lib/TableGen/Builder.cpp @@ -39,7 +39,7 @@ // Builder //===----------------------------------------------------------------------===// -Builder::Builder(const llvm::Record *record, ArrayRef loc) +Builder::Builder(const llvm::Record *record, ArrayRef loc) : def(record) { // Initialize the parameters of the builder. const llvm::DagInit *dag = def->getValueAsDag("dagParams"); diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp --- a/mlir/lib/TableGen/Operator.cpp +++ b/mlir/lib/TableGen/Operator.cpp @@ -612,7 +612,7 @@ return resultTypeMapping[index]; } -ArrayRef Operator::getLoc() const { return def.getLoc(); } +ArrayRef Operator::getLoc() const { return def.getLoc(); } bool Operator::hasDescription() const { return def.getValue("description") != nullptr; diff --git a/mlir/lib/TableGen/Predicate.cpp b/mlir/lib/TableGen/Predicate.cpp --- a/mlir/lib/TableGen/Predicate.cpp +++ b/mlir/lib/TableGen/Predicate.cpp @@ -47,7 +47,7 @@ return def && def->isSubClassOf("CombinedPred"); } -ArrayRef Pred::getLoc() const { return def->getLoc(); } +ArrayRef Pred::getLoc() const { return def->getLoc(); } CPred::CPred(const llvm::Record *record) : Pred(record) { assert(def->isSubClassOf("CPred") && diff --git a/mlir/lib/Tools/PDLL/AST/Nodes.cpp b/mlir/lib/Tools/PDLL/AST/Nodes.cpp --- a/mlir/lib/Tools/PDLL/AST/Nodes.cpp +++ b/mlir/lib/Tools/PDLL/AST/Nodes.cpp @@ -28,7 +28,7 @@ // Name //===----------------------------------------------------------------------===// -const Name &Name::create(Context &ctx, StringRef name, llvm::SMRange location) { +const Name &Name::create(Context &ctx, StringRef name, SMRange location) { return *new (ctx.getAllocator().Allocate()) Name(copyStringWithNull(ctx, name), location); } @@ -54,7 +54,7 @@ // CompoundStmt //===----------------------------------------------------------------------===// -CompoundStmt *CompoundStmt::create(Context &ctx, llvm::SMRange loc, +CompoundStmt *CompoundStmt::create(Context &ctx, SMRange loc, ArrayRef children) { unsigned allocSize = CompoundStmt::totalSizeToAlloc(children.size()); void *rawData = ctx.getAllocator().Allocate(allocSize, alignof(CompoundStmt)); @@ -69,7 +69,7 @@ // LetStmt //===----------------------------------------------------------------------===// -LetStmt *LetStmt::create(Context &ctx, llvm::SMRange loc, +LetStmt *LetStmt::create(Context &ctx, SMRange loc, VariableDecl *varDecl) { return new (ctx.getAllocator().Allocate()) LetStmt(loc, varDecl); } @@ -81,14 +81,14 @@ //===----------------------------------------------------------------------===// // EraseStmt -EraseStmt *EraseStmt::create(Context &ctx, llvm::SMRange loc, Expr *rootOp) { +EraseStmt *EraseStmt::create(Context &ctx, SMRange loc, Expr *rootOp) { return new (ctx.getAllocator().Allocate()) EraseStmt(loc, rootOp); } //===----------------------------------------------------------------------===// // ReplaceStmt -ReplaceStmt *ReplaceStmt::create(Context &ctx, llvm::SMRange loc, Expr *rootOp, +ReplaceStmt *ReplaceStmt::create(Context &ctx, SMRange loc, Expr *rootOp, ArrayRef replExprs) { unsigned allocSize = ReplaceStmt::totalSizeToAlloc(replExprs.size()); void *rawData = ctx.getAllocator().Allocate(allocSize, alignof(ReplaceStmt)); @@ -102,7 +102,7 @@ //===----------------------------------------------------------------------===// // RewriteStmt -RewriteStmt *RewriteStmt::create(Context &ctx, llvm::SMRange loc, Expr *rootOp, +RewriteStmt *RewriteStmt::create(Context &ctx, SMRange loc, Expr *rootOp, CompoundStmt *rewriteBody) { return new (ctx.getAllocator().Allocate()) RewriteStmt(loc, rootOp, rewriteBody); @@ -112,7 +112,7 @@ // AttributeExpr //===----------------------------------------------------------------------===// -AttributeExpr *AttributeExpr::create(Context &ctx, llvm::SMRange loc, +AttributeExpr *AttributeExpr::create(Context &ctx, SMRange loc, StringRef value) { return new (ctx.getAllocator().Allocate()) AttributeExpr(ctx, loc, copyStringWithNull(ctx, value)); @@ -122,7 +122,7 @@ // DeclRefExpr //===----------------------------------------------------------------------===// -DeclRefExpr *DeclRefExpr::create(Context &ctx, llvm::SMRange loc, Decl *decl, +DeclRefExpr *DeclRefExpr::create(Context &ctx, SMRange loc, Decl *decl, Type type) { return new (ctx.getAllocator().Allocate()) DeclRefExpr(loc, decl, type); @@ -132,7 +132,7 @@ // MemberAccessExpr //===----------------------------------------------------------------------===// -MemberAccessExpr *MemberAccessExpr::create(Context &ctx, llvm::SMRange loc, +MemberAccessExpr *MemberAccessExpr::create(Context &ctx, SMRange loc, const Expr *parentExpr, StringRef memberName, Type type) { return new (ctx.getAllocator().Allocate()) MemberAccessExpr( @@ -144,7 +144,7 @@ //===----------------------------------------------------------------------===// OperationExpr *OperationExpr::create( - Context &ctx, llvm::SMRange loc, const OpNameDecl *name, + Context &ctx, SMRange loc, const OpNameDecl *name, ArrayRef operands, ArrayRef resultTypes, ArrayRef attributes) { unsigned allocSize = @@ -174,7 +174,7 @@ // TupleExpr //===----------------------------------------------------------------------===// -TupleExpr *TupleExpr::create(Context &ctx, llvm::SMRange loc, +TupleExpr *TupleExpr::create(Context &ctx, SMRange loc, ArrayRef elements, ArrayRef names) { unsigned allocSize = TupleExpr::totalSizeToAlloc(elements.size()); @@ -194,7 +194,7 @@ // TypeExpr //===----------------------------------------------------------------------===// -TypeExpr *TypeExpr::create(Context &ctx, llvm::SMRange loc, StringRef value) { +TypeExpr *TypeExpr::create(Context &ctx, SMRange loc, StringRef value) { return new (ctx.getAllocator().Allocate()) TypeExpr(ctx, loc, copyStringWithNull(ctx, value)); } @@ -203,7 +203,7 @@ // AttrConstraintDecl //===----------------------------------------------------------------------===// -AttrConstraintDecl *AttrConstraintDecl::create(Context &ctx, llvm::SMRange loc, +AttrConstraintDecl *AttrConstraintDecl::create(Context &ctx, SMRange loc, Expr *typeExpr) { return new (ctx.getAllocator().Allocate()) AttrConstraintDecl(loc, typeExpr); @@ -213,10 +213,10 @@ // OpConstraintDecl //===----------------------------------------------------------------------===// -OpConstraintDecl *OpConstraintDecl::create(Context &ctx, llvm::SMRange loc, +OpConstraintDecl *OpConstraintDecl::create(Context &ctx, SMRange loc, const OpNameDecl *nameDecl) { if (!nameDecl) - nameDecl = OpNameDecl::create(ctx, llvm::SMRange()); + nameDecl = OpNameDecl::create(ctx, SMRange()); return new (ctx.getAllocator().Allocate()) OpConstraintDecl(loc, nameDecl); @@ -231,7 +231,7 @@ //===----------------------------------------------------------------------===// TypeConstraintDecl *TypeConstraintDecl::create(Context &ctx, - llvm::SMRange loc) { + SMRange loc) { return new (ctx.getAllocator().Allocate()) TypeConstraintDecl(loc); } @@ -241,7 +241,7 @@ //===----------------------------------------------------------------------===// TypeRangeConstraintDecl *TypeRangeConstraintDecl::create(Context &ctx, - llvm::SMRange loc) { + SMRange loc) { return new (ctx.getAllocator().Allocate()) TypeRangeConstraintDecl(loc); } @@ -251,7 +251,7 @@ //===----------------------------------------------------------------------===// ValueConstraintDecl * -ValueConstraintDecl::create(Context &ctx, llvm::SMRange loc, Expr *typeExpr) { +ValueConstraintDecl::create(Context &ctx, SMRange loc, Expr *typeExpr) { return new (ctx.getAllocator().Allocate()) ValueConstraintDecl(loc, typeExpr); } @@ -261,7 +261,7 @@ //===----------------------------------------------------------------------===// ValueRangeConstraintDecl *ValueRangeConstraintDecl::create(Context &ctx, - llvm::SMRange loc, + SMRange loc, Expr *typeExpr) { return new (ctx.getAllocator().Allocate()) ValueRangeConstraintDecl(loc, typeExpr); @@ -284,7 +284,7 @@ OpNameDecl *OpNameDecl::create(Context &ctx, const Name &name) { return new (ctx.getAllocator().Allocate()) OpNameDecl(name); } -OpNameDecl *OpNameDecl::create(Context &ctx, llvm::SMRange loc) { +OpNameDecl *OpNameDecl::create(Context &ctx, SMRange loc) { return new (ctx.getAllocator().Allocate()) OpNameDecl(loc); } @@ -292,7 +292,7 @@ // PatternDecl //===----------------------------------------------------------------------===// -PatternDecl *PatternDecl::create(Context &ctx, llvm::SMRange loc, +PatternDecl *PatternDecl::create(Context &ctx, SMRange loc, const Name *name, Optional benefit, bool hasBoundedRecursion, const CompoundStmt *body) { @@ -322,7 +322,7 @@ // Module //===----------------------------------------------------------------------===// -Module *Module::create(Context &ctx, llvm::SMLoc loc, +Module *Module::create(Context &ctx, SMLoc loc, ArrayRef children) { unsigned allocSize = Module::totalSizeToAlloc(children.size()); void *rawData = ctx.getAllocator().Allocate(allocSize, alignof(Module)); diff --git a/mlir/lib/Tools/PDLL/Parser/Lexer.h b/mlir/lib/Tools/PDLL/Parser/Lexer.h --- a/mlir/lib/Tools/PDLL/Parser/Lexer.h +++ b/mlir/lib/Tools/PDLL/Parser/Lexer.h @@ -133,16 +133,16 @@ bool is(Kind k) const { return kind == k; } /// Return a location for the start of this token. - llvm::SMLoc getStartLoc() const { - return llvm::SMLoc::getFromPointer(spelling.data()); + SMLoc getStartLoc() const { + return SMLoc::getFromPointer(spelling.data()); } /// Return a location at the end of this token. - llvm::SMLoc getEndLoc() const { - return llvm::SMLoc::getFromPointer(spelling.data() + spelling.size()); + SMLoc getEndLoc() const { + return SMLoc::getFromPointer(spelling.data() + spelling.size()); } /// Return a location for the range of this token. - llvm::SMRange getLoc() const { - return llvm::SMRange(getStartLoc(), getEndLoc()); + SMRange getLoc() const { + return SMRange(getStartLoc(), getEndLoc()); } private: @@ -182,10 +182,10 @@ void resetPointer(const char *newPointer) { curPtr = newPointer; } /// Emit an error to the lexer with the given location and message. - Token emitError(llvm::SMRange loc, const Twine &msg); + Token emitError(SMRange loc, const Twine &msg); Token emitError(const char *loc, const Twine &msg); - Token emitErrorAndNote(llvm::SMRange loc, const Twine &msg, - llvm::SMRange noteLoc, const Twine ¬e); + Token emitErrorAndNote(SMRange loc, const Twine &msg, + SMRange noteLoc, const Twine ¬e); private: Token formToken(Token::Kind kind, const char *tokStart) { diff --git a/mlir/lib/Tools/PDLL/Parser/Lexer.cpp b/mlir/lib/Tools/PDLL/Parser/Lexer.cpp --- a/mlir/lib/Tools/PDLL/Parser/Lexer.cpp +++ b/mlir/lib/Tools/PDLL/Parser/Lexer.cpp @@ -94,7 +94,7 @@ LogicalResult Lexer::pushInclude(StringRef filename) { std::string includedFile; int bufferID = srcMgr.AddIncludeFile( - filename.str(), llvm::SMLoc::getFromPointer(curPtr), includedFile); + filename.str(), SMLoc::getFromPointer(curPtr), includedFile); if (!bufferID) return failure(); curBufferID = bufferID; @@ -103,18 +103,18 @@ return success(); } -Token Lexer::emitError(llvm::SMRange loc, const Twine &msg) { +Token Lexer::emitError(SMRange loc, const Twine &msg) { diagEngine.emitError(loc, msg); return formToken(Token::error, loc.Start.getPointer()); } -Token Lexer::emitErrorAndNote(llvm::SMRange loc, const Twine &msg, - llvm::SMRange noteLoc, const Twine ¬e) { +Token Lexer::emitErrorAndNote(SMRange loc, const Twine &msg, + SMRange noteLoc, const Twine ¬e) { diagEngine.emitError(loc, msg)->attachNote(note, noteLoc); return formToken(Token::error, loc.Start.getPointer()); } Token Lexer::emitError(const char *loc, const Twine &msg) { - return emitError(llvm::SMRange(llvm::SMLoc::getFromPointer(loc), - llvm::SMLoc::getFromPointer(loc + 1)), + return emitError(SMRange(SMLoc::getFromPointer(loc), + SMLoc::getFromPointer(loc + 1)), msg); } @@ -161,7 +161,7 @@ Token eof = formToken(Token::eof, tokStart); // Check to see if we are in an included file. - llvm::SMLoc parentIncludeLoc = srcMgr.getParentIncludeLoc(curBufferID); + SMLoc parentIncludeLoc = srcMgr.getParentIncludeLoc(curBufferID); if (parentIncludeLoc.isValid()) { curBufferID = srcMgr.FindBufferContainingLoc(parentIncludeLoc); curBuffer = srcMgr.getMemoryBuffer(curBufferID)->getBuffer(); diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp --- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp +++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp @@ -116,11 +116,11 @@ /// Try to define a variable decl with the given components, returns the /// variable on success. FailureOr - defineVariableDecl(StringRef name, llvm::SMRange nameLoc, ast::Type type, + defineVariableDecl(StringRef name, SMRange nameLoc, ast::Type type, ast::Expr *initExpr, ArrayRef constraints); FailureOr - defineVariableDecl(StringRef name, llvm::SMRange nameLoc, ast::Type type, + defineVariableDecl(StringRef name, SMRange nameLoc, ast::Type type, ArrayRef constraints); /// Parse the constraint reference list for a variable decl. @@ -136,7 +136,7 @@ /// existing constraints that have already been parsed for the same entity /// that will be constrained by this constraint. FailureOr - parseConstraint(Optional &typeConstraint, + parseConstraint(Optional &typeConstraint, ArrayRef existingConstraints); //===--------------------------------------------------------------------===// @@ -146,7 +146,7 @@ /// Identifier expressions. FailureOr parseAttributeExpr(); - FailureOr parseDeclRefExpr(StringRef name, llvm::SMRange loc); + FailureOr parseDeclRefExpr(StringRef name, SMRange loc); FailureOr parseIdentifierExpr(); FailureOr parseMemberAccessExpr(ast::Expr *parentExpr); FailureOr parseOperationName(bool allowEmptyName = false); @@ -176,14 +176,14 @@ /// Try to create a pattern decl with the given components, returning the /// Pattern on success. FailureOr - createPatternDecl(llvm::SMRange loc, const ast::Name *name, + createPatternDecl(SMRange loc, const ast::Name *name, const ParsedPatternMetadata &metadata, ast::CompoundStmt *body); /// Try to create a variable decl with the given components, returning the /// Variable on success. FailureOr - createVariableDecl(StringRef name, llvm::SMRange loc, ast::Expr *initializer, + createVariableDecl(StringRef name, SMRange loc, ast::Expr *initializer, ArrayRef constraints); /// Validate the constraints used to constraint a variable decl. @@ -206,49 +206,49 @@ //===--------------------------------------------------------------------===// // Exprs - FailureOr createDeclRefExpr(llvm::SMRange loc, + FailureOr createDeclRefExpr(SMRange loc, ast::Decl *decl); FailureOr - createInlineVariableExpr(ast::Type type, StringRef name, llvm::SMRange loc, + createInlineVariableExpr(ast::Type type, StringRef name, SMRange loc, ArrayRef constraints); FailureOr createMemberAccessExpr(ast::Expr *parentExpr, StringRef name, - llvm::SMRange loc); + SMRange loc); /// Validate the member access `name` into the given parent expression. On /// success, this also returns the type of the member accessed. FailureOr validateMemberAccess(ast::Expr *parentExpr, - StringRef name, llvm::SMRange loc); + StringRef name, SMRange loc); FailureOr - createOperationExpr(llvm::SMRange loc, const ast::OpNameDecl *name, + createOperationExpr(SMRange loc, const ast::OpNameDecl *name, MutableArrayRef operands, MutableArrayRef attributes, MutableArrayRef results); LogicalResult - validateOperationOperands(llvm::SMRange loc, Optional name, + validateOperationOperands(SMRange loc, Optional name, MutableArrayRef operands); - LogicalResult validateOperationResults(llvm::SMRange loc, + LogicalResult validateOperationResults(SMRange loc, Optional name, MutableArrayRef results); LogicalResult - validateOperationOperandsOrResults(llvm::SMRange loc, + validateOperationOperandsOrResults(SMRange loc, Optional name, MutableArrayRef values, ast::Type singleTy, ast::Type rangeTy); - FailureOr createTupleExpr(llvm::SMRange loc, + FailureOr createTupleExpr(SMRange loc, ArrayRef elements, ArrayRef elementNames); //===--------------------------------------------------------------------===// // Stmts - FailureOr createEraseStmt(llvm::SMRange loc, + FailureOr createEraseStmt(SMRange loc, ast::Expr *rootOp); FailureOr - createReplaceStmt(llvm::SMRange loc, ast::Expr *rootOp, + createReplaceStmt(SMRange loc, ast::Expr *rootOp, MutableArrayRef replValues); FailureOr - createRewriteStmt(llvm::SMRange loc, ast::Expr *rootOp, + createRewriteStmt(SMRange loc, ast::Expr *rootOp, ast::CompoundStmt *rewriteBody); //===--------------------------------------------------------------------===// @@ -280,7 +280,7 @@ } /// Reset the lexer to the location at the given position. - void resetToken(llvm::SMRange tokLoc) { + void resetToken(SMRange tokLoc) { lexer.resetPointer(tokLoc.Start.getPointer()); curToken = lexer.lexToken(); } @@ -293,15 +293,15 @@ consumeToken(); return success(); } - LogicalResult emitError(llvm::SMRange loc, const Twine &msg) { + LogicalResult emitError(SMRange loc, const Twine &msg) { lexer.emitError(loc, msg); return failure(); } LogicalResult emitError(const Twine &msg) { return emitError(curToken.getLoc(), msg); } - LogicalResult emitErrorAndNote(llvm::SMRange loc, const Twine &msg, - llvm::SMRange noteLoc, const Twine ¬e) { + LogicalResult emitErrorAndNote(SMRange loc, const Twine &msg, + SMRange noteLoc, const Twine ¬e) { lexer.emitErrorAndNote(loc, msg, noteLoc, note); return failure(); } @@ -333,7 +333,7 @@ } // namespace FailureOr Parser::parseModule() { - llvm::SMLoc moduleLoc = curToken.getStartLoc(); + SMLoc moduleLoc = curToken.getStartLoc(); pushDeclScope(); // Parse the top-level decls of the module. @@ -464,14 +464,14 @@ } LogicalResult Parser::parseInclude(SmallVector &decls) { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); consumeToken(Token::directive); // Parse the file being included. if (!curToken.isString()) return emitError(loc, "expected string file name after `include` directive"); - llvm::SMRange fileLoc = curToken.getLoc(); + SMRange fileLoc = curToken.getLoc(); std::string filenameStr = curToken.getStringValue(); StringRef filename = filenameStr; consumeToken(); @@ -548,7 +548,7 @@ } FailureOr Parser::parsePatternDecl() { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); consumeToken(Token::kw_Pattern); llvm::SaveAndRestore saveCtx(parserContext, ParserContext::PatternMatch); @@ -598,14 +598,14 @@ LogicalResult Parser::parsePatternDeclMetadata(ParsedPatternMetadata &metadata) { - Optional benefitLoc; - Optional hasBoundedRecursionLoc; + Optional benefitLoc; + Optional hasBoundedRecursionLoc; do { if (curToken.isNot(Token::identifier)) return emitError("expected pattern metadata identifier"); StringRef metadataStr = curToken.getSpelling(); - llvm::SMRange metadataLoc = curToken.getLoc(); + SMRange metadataLoc = curToken.getLoc(); consumeToken(Token::identifier); // Parse the benefit metadata: benefit() @@ -677,7 +677,7 @@ } FailureOr -Parser::defineVariableDecl(StringRef name, llvm::SMRange nameLoc, +Parser::defineVariableDecl(StringRef name, SMRange nameLoc, ast::Type type, ast::Expr *initExpr, ArrayRef constraints) { assert(curDeclScope && "defining variable outside of decl scope"); @@ -699,7 +699,7 @@ } FailureOr -Parser::defineVariableDecl(StringRef name, llvm::SMRange nameLoc, +Parser::defineVariableDecl(StringRef name, SMRange nameLoc, ast::Type type, ArrayRef constraints) { return defineVariableDecl(name, nameLoc, type, /*initExpr=*/nullptr, @@ -708,7 +708,7 @@ LogicalResult Parser::parseVariableDeclConstraintList( SmallVectorImpl &constraints) { - Optional typeConstraint; + Optional typeConstraint; auto parseSingleConstraint = [&] { FailureOr constraint = parseConstraint(typeConstraint, constraints); @@ -730,7 +730,7 @@ } FailureOr -Parser::parseConstraint(Optional &typeConstraint, +Parser::parseConstraint(Optional &typeConstraint, ArrayRef existingConstraints) { auto parseTypeConstraint = [&](ast::Expr *&typeExpr) -> LogicalResult { if (typeConstraint) @@ -746,7 +746,7 @@ return success(); }; - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); switch (curToken.getKind()) { case Token::kw_Attr: { consumeToken(Token::kw_Attr); @@ -871,7 +871,7 @@ } FailureOr Parser::parseAttributeExpr() { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); consumeToken(Token::kw_attr); // If we aren't followed by a `<`, the `attr` keyword is treated as a normal @@ -893,7 +893,7 @@ } FailureOr Parser::parseDeclRefExpr(StringRef name, - llvm::SMRange loc) { + SMRange loc) { ast::Decl *decl = curDeclScope->lookup(name); if (!decl) return emitError(loc, "undefined reference to `" + name + "`"); @@ -903,7 +903,7 @@ FailureOr Parser::parseIdentifierExpr() { StringRef name = curToken.getSpelling(); - llvm::SMRange nameLoc = curToken.getLoc(); + SMRange nameLoc = curToken.getLoc(); consumeToken(); // Check to see if this is a decl ref expression that defines a variable @@ -922,7 +922,7 @@ } FailureOr Parser::parseMemberAccessExpr(ast::Expr *parentExpr) { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); consumeToken(Token::dot); // Parse the member name. @@ -937,12 +937,12 @@ } FailureOr Parser::parseOperationName(bool allowEmptyName) { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); // Handle the case of an no operation name. if (curToken.isNot(Token::identifier) && !curToken.isKeyword()) { if (allowEmptyName) - return ast::OpNameDecl::create(ctx, llvm::SMRange()); + return ast::OpNameDecl::create(ctx, SMRange()); return emitError("expected dialect namespace"); } StringRef name = curToken.getSpelling(); @@ -968,7 +968,7 @@ FailureOr Parser::parseWrappedOperationName(bool allowEmptyName) { if (!consumeIf(Token::less)) - return ast::OpNameDecl::create(ctx, llvm::SMRange()); + return ast::OpNameDecl::create(ctx, SMRange()); FailureOr opNameDecl = parseOperationName(allowEmptyName); if (failed(opNameDecl)) @@ -980,7 +980,7 @@ } FailureOr Parser::parseOperationExpr() { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); consumeToken(Token::kw_op); // If it isn't followed by a `<`, the `op` keyword is treated as a normal @@ -1053,10 +1053,10 @@ } FailureOr Parser::parseTupleExpr() { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); consumeToken(Token::l_paren); - DenseMap usedNames; + DenseMap usedNames; SmallVector elementNames; SmallVector elements; if (curToken.isNot(Token::r_paren)) { @@ -1105,7 +1105,7 @@ } FailureOr Parser::parseTypeExpr() { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); consumeToken(Token::kw_type); // If we aren't followed by a `<`, the `type` keyword is treated as a normal @@ -1127,7 +1127,7 @@ FailureOr Parser::parseUnderscoreExpr() { StringRef name = curToken.getSpelling(); - llvm::SMRange nameLoc = curToken.getLoc(); + SMRange nameLoc = curToken.getLoc(); consumeToken(Token::underscore); // Underscore expressions require a constraint list. @@ -1175,7 +1175,7 @@ } FailureOr Parser::parseCompoundStmt() { - llvm::SMLoc startLoc = curToken.getStartLoc(); + SMLoc startLoc = curToken.getStartLoc(); consumeToken(Token::l_brace); // Push a new block scope and parse any nested statements. @@ -1190,14 +1190,14 @@ popDeclScope(); // Consume the end brace. - llvm::SMRange location(startLoc, curToken.getEndLoc()); + SMRange location(startLoc, curToken.getEndLoc()); consumeToken(Token::r_brace); return ast::CompoundStmt::create(ctx, location, statements); } FailureOr Parser::parseEraseStmt() { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); consumeToken(Token::kw_erase); // Parse the root operation expression. @@ -1209,11 +1209,11 @@ } FailureOr Parser::parseLetStmt() { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); consumeToken(Token::kw_let); // Parse the name of the new variable. - llvm::SMRange varLoc = curToken.getLoc(); + SMRange varLoc = curToken.getLoc(); if (curToken.isNot(Token::identifier) && !curToken.isDependentKeyword()) { // `_` is a reserved variable name. if (curToken.is(Token::underscore)) { @@ -1269,7 +1269,7 @@ } FailureOr Parser::parseReplaceStmt() { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); consumeToken(Token::kw_replace); // Parse the root operation expression. @@ -1315,7 +1315,7 @@ } FailureOr Parser::parseRewriteStmt() { - llvm::SMRange loc = curToken.getLoc(); + SMRange loc = curToken.getLoc(); consumeToken(Token::kw_rewrite); // Parse the root operation. @@ -1348,7 +1348,7 @@ // Decls FailureOr -Parser::createPatternDecl(llvm::SMRange loc, const ast::Name *name, +Parser::createPatternDecl(SMRange loc, const ast::Name *name, const ParsedPatternMetadata &metadata, ast::CompoundStmt *body) { return ast::PatternDecl::create(ctx, loc, name, metadata.benefit, @@ -1356,7 +1356,7 @@ } FailureOr -Parser::createVariableDecl(StringRef name, llvm::SMRange loc, +Parser::createVariableDecl(StringRef name, SMRange loc, ast::Expr *initializer, ArrayRef constraints) { // The type of the variable, which is expected to be inferred by either a @@ -1473,7 +1473,7 @@ //===----------------------------------------------------------------------===// // Exprs -FailureOr Parser::createDeclRefExpr(llvm::SMRange loc, +FailureOr Parser::createDeclRefExpr(SMRange loc, ast::Decl *decl) { // Check the type of decl being referenced. ast::Type declType; @@ -1488,7 +1488,7 @@ FailureOr Parser::createInlineVariableExpr(ast::Type type, StringRef name, - llvm::SMRange loc, + SMRange loc, ArrayRef constraints) { FailureOr decl = defineVariableDecl(name, loc, type, constraints); @@ -1499,7 +1499,7 @@ FailureOr Parser::createMemberAccessExpr(ast::Expr *parentExpr, StringRef name, - llvm::SMRange loc) { + SMRange loc) { // Validate the member name for the given parent expression. FailureOr memberType = validateMemberAccess(parentExpr, name, loc); if (failed(memberType)) @@ -1510,7 +1510,7 @@ FailureOr Parser::validateMemberAccess(ast::Expr *parentExpr, StringRef name, - llvm::SMRange loc) { + SMRange loc) { ast::Type parentType = parentExpr->getType(); if (parentType.isa()) { if (name == ast::AllResultsMemberAccessExpr::getMemberName()) @@ -1536,7 +1536,7 @@ } FailureOr Parser::createOperationExpr( - llvm::SMRange loc, const ast::OpNameDecl *name, + SMRange loc, const ast::OpNameDecl *name, MutableArrayRef operands, MutableArrayRef attributes, MutableArrayRef results) { @@ -1566,21 +1566,21 @@ } LogicalResult -Parser::validateOperationOperands(llvm::SMRange loc, Optional name, +Parser::validateOperationOperands(SMRange loc, Optional name, MutableArrayRef operands) { return validateOperationOperandsOrResults(loc, name, operands, valueTy, valueRangeTy); } LogicalResult -Parser::validateOperationResults(llvm::SMRange loc, Optional name, +Parser::validateOperationResults(SMRange loc, Optional name, MutableArrayRef results) { return validateOperationOperandsOrResults(loc, name, results, typeTy, typeRangeTy); } LogicalResult Parser::validateOperationOperandsOrResults( - llvm::SMRange loc, Optional name, + SMRange loc, Optional name, MutableArrayRef values, ast::Type singleTy, ast::Type rangeTy) { // All operation types accept a single range parameter. @@ -1619,7 +1619,7 @@ } FailureOr -Parser::createTupleExpr(llvm::SMRange loc, ArrayRef elements, +Parser::createTupleExpr(SMRange loc, ArrayRef elements, ArrayRef elementNames) { for (const ast::Expr *element : elements) { ast::Type eleTy = element->getType(); @@ -1635,7 +1635,7 @@ //===----------------------------------------------------------------------===// // Stmts -FailureOr Parser::createEraseStmt(llvm::SMRange loc, +FailureOr Parser::createEraseStmt(SMRange loc, ast::Expr *rootOp) { // Check that root is an Operation. ast::Type rootType = rootOp->getType(); @@ -1646,7 +1646,7 @@ } FailureOr -Parser::createReplaceStmt(llvm::SMRange loc, ast::Expr *rootOp, +Parser::createReplaceStmt(SMRange loc, ast::Expr *rootOp, MutableArrayRef replValues) { // Check that root is an Operation. ast::Type rootType = rootOp->getType(); @@ -1681,7 +1681,7 @@ } FailureOr -Parser::createRewriteStmt(llvm::SMRange loc, ast::Expr *rootOp, +Parser::createRewriteStmt(SMRange loc, ast::Expr *rootOp, ast::CompoundStmt *rewriteBody) { // Check that root is an Operation. ast::Type rootType = rootOp->getType(); diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -17,7 +17,7 @@ using namespace mlir; /// Returns a language server position for the given source location. -static lsp::Position getPosFromLoc(llvm::SourceMgr &mgr, llvm::SMLoc loc) { +static lsp::Position getPosFromLoc(llvm::SourceMgr &mgr, SMLoc loc) { std::pair lineAndCol = mgr.getLineAndColumn(loc); lsp::Position pos; pos.line = lineAndCol.first - 1; @@ -26,19 +26,19 @@ } /// Returns a source location from the given language server position. -static llvm::SMLoc getPosFromLoc(llvm::SourceMgr &mgr, lsp::Position pos) { +static SMLoc getPosFromLoc(llvm::SourceMgr &mgr, lsp::Position pos) { return mgr.FindLocForLineAndColumn(mgr.getMainFileID(), pos.line + 1, pos.character); } /// Returns a language server range for the given source range. -static lsp::Range getRangeFromLoc(llvm::SourceMgr &mgr, llvm::SMRange range) { +static lsp::Range getRangeFromLoc(llvm::SourceMgr &mgr, SMRange range) { return {getPosFromLoc(mgr, range.Start), getPosFromLoc(mgr, range.End)}; } /// Returns a language server location from the given source range. static lsp::Location getLocationFromLoc(llvm::SourceMgr &mgr, - llvm::SMRange range, + SMRange range, const lsp::URIForFile &uri) { return lsp::Location{uri, getRangeFromLoc(mgr, range)}; } @@ -75,13 +75,13 @@ Optional sourceLoc = getLocationFromLoc(fileLoc); if (sourceLoc && (!uri || sourceLoc->uri == *uri)) { location = *sourceLoc; - llvm::SMLoc loc = sourceMgr.FindLocForLineAndColumn( + SMLoc loc = sourceMgr.FindLocForLineAndColumn( sourceMgr.getMainFileID(), fileLoc.getLine(), fileLoc.getColumn()); // Use range of potential identifier starting at location, else length 1 // range. location->range.end.character += 1; - if (Optional range = + if (Optional range = AsmParserState::convertIdLocToRange(loc)) { auto lineCol = sourceMgr.getLineAndColumn(range->End); location->range.end.character = @@ -115,7 +115,7 @@ /// Returns true if the given range contains the given source location. Note /// that this has slightly different behavior than SMRange because it is /// inclusive of the end location. -static bool contains(llvm::SMRange range, llvm::SMLoc loc) { +static bool contains(SMRange range, SMLoc loc) { return range.Start.getPointer() <= loc.getPointer() && loc.getPointer() <= range.End.getPointer(); } @@ -123,8 +123,8 @@ /// Returns true if the given location is contained by the definition or one of /// the uses of the given SMDefinition. If provided, `overlappedRange` is set to /// the range within `def` that the provided `loc` overlapped with. -static bool isDefOrUse(const AsmParserState::SMDefinition &def, llvm::SMLoc loc, - llvm::SMRange *overlappedRange = nullptr) { +static bool isDefOrUse(const AsmParserState::SMDefinition &def, SMLoc loc, + SMRange *overlappedRange = nullptr) { // Check the main definition. if (contains(def.loc, loc)) { if (overlappedRange) @@ -133,7 +133,7 @@ } // Check the uses. - const auto *useIt = llvm::find_if(def.uses, [&](const llvm::SMRange &range) { + const auto *useIt = llvm::find_if(def.uses, [&](const SMRange &range) { return contains(range, loc); }); if (useIt != def.uses.end()) { @@ -146,7 +146,7 @@ /// Given a location pointing to a result, return the result number it refers /// to or None if it refers to all of the results. -static Optional getResultNumberFromLoc(llvm::SMLoc loc) { +static Optional getResultNumberFromLoc(SMLoc loc) { // Skip all of the identifier characters. auto isIdentifierChar = [](char c) { return isalnum(c) || c == '%' || c == '$' || c == '.' || c == '_' || @@ -173,7 +173,7 @@ /// Given a source location range, return the text covered by the given range. /// If the range is invalid, returns None. -static Optional getTextFromRange(llvm::SMRange range) { +static Optional getTextFromRange(SMRange range) { if (!range.isValid()) return None; const char *startPtr = range.Start.getPointer(); @@ -188,7 +188,7 @@ /// Given a block and source location, print the source name of the block to the /// given output stream. static void printDefBlockName(raw_ostream &os, Block *block, - llvm::SMRange loc = {}) { + SMRange loc = {}) { // Try to extract a name from the source location. Optional text = getTextFromRange(loc); if (text && text->startswith("^")) { @@ -285,16 +285,16 @@ Optional findHover(const lsp::URIForFile &uri, const lsp::Position &hoverPos); Optional - buildHoverForOperation(llvm::SMRange hoverRange, + buildHoverForOperation(SMRange hoverRange, const AsmParserState::OperationDefinition &op); - lsp::Hover buildHoverForOperationResult(llvm::SMRange hoverRange, + lsp::Hover buildHoverForOperationResult(SMRange hoverRange, Operation *op, unsigned resultStart, unsigned resultEnd, - llvm::SMLoc posLoc); - lsp::Hover buildHoverForBlock(llvm::SMRange hoverRange, + SMLoc posLoc); + lsp::Hover buildHoverForBlock(SMRange hoverRange, const AsmParserState::BlockDefinition &block); lsp::Hover - buildHoverForBlockArgument(llvm::SMRange hoverRange, BlockArgument arg, + buildHoverForBlockArgument(SMRange hoverRange, BlockArgument arg, const AsmParserState::BlockDefinition &block); //===--------------------------------------------------------------------===// @@ -335,7 +335,7 @@ return; } - sourceMgr.AddNewSourceBuffer(std::move(memBuffer), llvm::SMLoc()); + sourceMgr.AddNewSourceBuffer(std::move(memBuffer), SMLoc()); if (failed(parseSourceFile(sourceMgr, &parsedIR, &context, nullptr, &asmState))) { // If parsing failed, clear out any of the current state. @@ -352,7 +352,7 @@ void MLIRDocument::getLocationsOf(const lsp::URIForFile &uri, const lsp::Position &defPos, std::vector &locations) { - llvm::SMLoc posLoc = getPosFromLoc(sourceMgr, defPos); + SMLoc posLoc = getPosFromLoc(sourceMgr, defPos); // Functor used to check if an SM definition contains the position. auto containsPosition = [&](const AsmParserState::SMDefinition &def) { @@ -394,11 +394,11 @@ // definition to the reference list. auto appendSMDef = [&](const AsmParserState::SMDefinition &def) { references.push_back(getLocationFromLoc(sourceMgr, def.loc, uri)); - for (const llvm::SMRange &use : def.uses) + for (const SMRange &use : def.uses) references.push_back(getLocationFromLoc(sourceMgr, use, uri)); }; - llvm::SMLoc posLoc = getPosFromLoc(sourceMgr, pos); + SMLoc posLoc = getPosFromLoc(sourceMgr, pos); // Check all definitions related to operations. for (const AsmParserState::OperationDefinition &op : asmState.getOpDefs()) { @@ -439,8 +439,8 @@ Optional MLIRDocument::findHover(const lsp::URIForFile &uri, const lsp::Position &hoverPos) { - llvm::SMLoc posLoc = getPosFromLoc(sourceMgr, hoverPos); - llvm::SMRange hoverRange; + SMLoc posLoc = getPosFromLoc(sourceMgr, hoverPos); + SMRange hoverRange; // Check for Hovers on operations and results. for (const AsmParserState::OperationDefinition &op : asmState.getOpDefs()) { @@ -485,7 +485,7 @@ } Optional MLIRDocument::buildHoverForOperation( - llvm::SMRange hoverRange, const AsmParserState::OperationDefinition &op) { + SMRange hoverRange, const AsmParserState::OperationDefinition &op) { lsp::Hover hover(getRangeFromLoc(sourceMgr, hoverRange)); llvm::raw_string_ostream os(hover.contents.value); @@ -517,11 +517,11 @@ return hover; } -lsp::Hover MLIRDocument::buildHoverForOperationResult(llvm::SMRange hoverRange, +lsp::Hover MLIRDocument::buildHoverForOperationResult(SMRange hoverRange, Operation *op, unsigned resultStart, unsigned resultEnd, - llvm::SMLoc posLoc) { + SMLoc posLoc) { lsp::Hover hover(getRangeFromLoc(sourceMgr, hoverRange)); llvm::raw_string_ostream os(hover.contents.value); @@ -553,7 +553,7 @@ } lsp::Hover -MLIRDocument::buildHoverForBlock(llvm::SMRange hoverRange, +MLIRDocument::buildHoverForBlock(SMRange hoverRange, const AsmParserState::BlockDefinition &block) { lsp::Hover hover(getRangeFromLoc(sourceMgr, hoverRange)); llvm::raw_string_ostream os(hover.contents.value); @@ -585,7 +585,7 @@ } lsp::Hover MLIRDocument::buildHoverForBlockArgument( - llvm::SMRange hoverRange, BlockArgument arg, + SMRange hoverRange, BlockArgument arg, const AsmParserState::BlockDefinition &block) { lsp::Hover hover(getRangeFromLoc(sourceMgr, hoverRange)); llvm::raw_string_ostream os(hover.contents.value); diff --git a/mlir/lib/Translation/Translation.cpp b/mlir/lib/Translation/Translation.cpp --- a/mlir/lib/Translation/Translation.cpp +++ b/mlir/lib/Translation/Translation.cpp @@ -181,7 +181,7 @@ MLIRContext context; context.printOpOnDiagnostic(!verifyDiagnostics); llvm::SourceMgr sourceMgr; - sourceMgr.AddNewSourceBuffer(std::move(ownedBuffer), llvm::SMLoc()); + sourceMgr.AddNewSourceBuffer(std::move(ownedBuffer), SMLoc()); if (!verifyDiagnostics) { SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context); diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -729,7 +729,7 @@ static ParseResult parsePrettyPrintedRegionOp(OpAsmParser &parser, OperationState &result) { - llvm::SMLoc loc = parser.getCurrentLocation(); + SMLoc loc = parser.getCurrentLocation(); Location currLocation = parser.getEncodedSourceLoc(loc); // Parse the operands. diff --git a/mlir/tools/mlir-pdll/mlir-pdll.cpp b/mlir/tools/mlir-pdll/mlir-pdll.cpp --- a/mlir/tools/mlir-pdll/mlir-pdll.cpp +++ b/mlir/tools/mlir-pdll/mlir-pdll.cpp @@ -33,7 +33,7 @@ OutputType outputType, std::vector &includeDirs) { llvm::SourceMgr sourceMgr; sourceMgr.setIncludeDirs(includeDirs); - sourceMgr.AddNewSourceBuffer(std::move(chunkBuffer), llvm::SMLoc()); + sourceMgr.AddNewSourceBuffer(std::move(chunkBuffer), SMLoc()); ast::Context astContext; FailureOr module = parsePDLAST(astContext, sourceMgr); diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp --- a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp @@ -757,7 +757,7 @@ llvm::SourceMgr mgr; mgr.AddNewSourceBuffer( llvm::MemoryBuffer::getMemBuffer(*def.getAssemblyFormat()), - llvm::SMLoc()); + SMLoc()); /// Parse the custom assembly format> FormatParser fmtParser(mgr, def); diff --git a/mlir/tools/mlir-tblgen/FormatGen.h b/mlir/tools/mlir-tblgen/FormatGen.h --- a/mlir/tools/mlir-tblgen/FormatGen.h +++ b/mlir/tools/mlir-tblgen/FormatGen.h @@ -83,7 +83,7 @@ Kind getKind() const { return kind; } /// Return a location for this token. - llvm::SMLoc getLoc() const; + SMLoc getLoc() const; /// Return if this token is a keyword. bool isKeyword() const { @@ -106,16 +106,16 @@ /// This class implements a simple lexer for operation assembly format strings. class FormatLexer { public: - FormatLexer(llvm::SourceMgr &mgr, llvm::SMLoc loc); + FormatLexer(llvm::SourceMgr &mgr, SMLoc loc); /// Lex the next token and return it. FormatToken lexToken(); /// Emit an error to the lexer with the given location and message. - FormatToken emitError(llvm::SMLoc loc, const Twine &msg); + FormatToken emitError(SMLoc loc, const Twine &msg); FormatToken emitError(const char *loc, const Twine &msg); - FormatToken emitErrorAndNote(llvm::SMLoc loc, const Twine &msg, + FormatToken emitErrorAndNote(SMLoc loc, const Twine &msg, const Twine ¬e); private: @@ -135,7 +135,7 @@ /// The source manager containing the format string. llvm::SourceMgr &mgr; /// Location of the format string. - llvm::SMLoc loc; + SMLoc loc; /// Buffer containing the format string. StringRef curBuffer; /// Current pointer in the buffer. diff --git a/mlir/tools/mlir-tblgen/FormatGen.cpp b/mlir/tools/mlir-tblgen/FormatGen.cpp --- a/mlir/tools/mlir-tblgen/FormatGen.cpp +++ b/mlir/tools/mlir-tblgen/FormatGen.cpp @@ -18,20 +18,20 @@ // FormatToken //===----------------------------------------------------------------------===// -llvm::SMLoc FormatToken::getLoc() const { - return llvm::SMLoc::getFromPointer(spelling.data()); +SMLoc FormatToken::getLoc() const { + return SMLoc::getFromPointer(spelling.data()); } //===----------------------------------------------------------------------===// // FormatLexer //===----------------------------------------------------------------------===// -FormatLexer::FormatLexer(llvm::SourceMgr &mgr, llvm::SMLoc loc) +FormatLexer::FormatLexer(llvm::SourceMgr &mgr, SMLoc loc) : mgr(mgr), loc(loc), curBuffer(mgr.getMemoryBuffer(mgr.getMainFileID())->getBuffer()), curPtr(curBuffer.begin()) {} -FormatToken FormatLexer::emitError(llvm::SMLoc loc, const Twine &msg) { +FormatToken FormatLexer::emitError(SMLoc loc, const Twine &msg) { mgr.PrintMessage(loc, llvm::SourceMgr::DK_Error, msg); llvm::SrcMgr.PrintMessage(this->loc, llvm::SourceMgr::DK_Note, "in custom assembly format for this operation"); @@ -39,10 +39,10 @@ } FormatToken FormatLexer::emitError(const char *loc, const Twine &msg) { - return emitError(llvm::SMLoc::getFromPointer(loc), msg); + return emitError(SMLoc::getFromPointer(loc), msg); } -FormatToken FormatLexer::emitErrorAndNote(llvm::SMLoc loc, const Twine &msg, +FormatToken FormatLexer::emitErrorAndNote(SMLoc loc, const Twine &msg, const Twine ¬e) { mgr.PrintMessage(loc, llvm::SourceMgr::DK_Error, msg); llvm::SrcMgr.PrintMessage(this->loc, llvm::SourceMgr::DK_Note, diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -2223,27 +2223,27 @@ std::vector>::const_iterator>; /// Verify the state of operation attributes within the format. - LogicalResult verifyAttributes(llvm::SMLoc loc); + LogicalResult verifyAttributes(SMLoc loc); /// Verify the attribute elements at the back of the given stack of iterators. LogicalResult verifyAttributes( - llvm::SMLoc loc, + SMLoc loc, SmallVectorImpl> &iteratorStack); /// Verify the state of operation operands within the format. LogicalResult - verifyOperands(llvm::SMLoc loc, + verifyOperands(SMLoc loc, llvm::StringMap &variableTyResolver); /// Verify the state of operation regions within the format. - LogicalResult verifyRegions(llvm::SMLoc loc); + LogicalResult verifyRegions(SMLoc loc); /// Verify the state of operation results within the format. LogicalResult - verifyResults(llvm::SMLoc loc, + verifyResults(SMLoc loc, llvm::StringMap &variableTyResolver); /// Verify the state of operation successors within the format. - LogicalResult verifySuccessors(llvm::SMLoc loc); + LogicalResult verifySuccessors(SMLoc loc); /// Given the values of an `AllTypesMatch` trait, check for inferable type /// resolution. @@ -2281,31 +2281,31 @@ std::vector> &childElements, Optional &anchorIdx); LogicalResult verifyOptionalChildElement(Element *element, - llvm::SMLoc childLoc, bool isAnchor); + SMLoc childLoc, bool isAnchor); /// Parse the various different directives. LogicalResult parseAttrDictDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context, + SMLoc loc, ParserContext context, bool withKeyword); LogicalResult parseCustomDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context); + SMLoc loc, ParserContext context); LogicalResult parseCustomDirectiveParameter( std::vector> ¶meters); LogicalResult parseFunctionalTypeDirective(std::unique_ptr &element, FormatToken tok, ParserContext context); LogicalResult parseOperandsDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context); + SMLoc loc, ParserContext context); LogicalResult parseQualifiedDirective(std::unique_ptr &element, FormatToken tok, ParserContext context); LogicalResult parseReferenceDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context); + SMLoc loc, ParserContext context); LogicalResult parseRegionsDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context); + SMLoc loc, ParserContext context); LogicalResult parseResultsDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context); + SMLoc loc, ParserContext context); LogicalResult parseSuccessorsDirective(std::unique_ptr &element, - llvm::SMLoc loc, + SMLoc loc, ParserContext context); LogicalResult parseTypeDirective(std::unique_ptr &element, FormatToken tok, ParserContext context); @@ -2329,11 +2329,11 @@ consumeToken(); return ::mlir::success(); } - LogicalResult emitError(llvm::SMLoc loc, const Twine &msg) { + LogicalResult emitError(SMLoc loc, const Twine &msg) { lexer.emitError(loc, msg); return ::mlir::failure(); } - LogicalResult emitErrorAndNote(llvm::SMLoc loc, const Twine &msg, + LogicalResult emitErrorAndNote(SMLoc loc, const Twine &msg, const Twine ¬e) { lexer.emitErrorAndNote(loc, msg, note); return ::mlir::failure(); @@ -2362,7 +2362,7 @@ } // namespace LogicalResult FormatParser::parse() { - llvm::SMLoc loc = curToken.getLoc(); + SMLoc loc = curToken.getLoc(); // Parse each of the format elements into the main format. while (curToken.getKind() != FormatToken::eof) { @@ -2415,7 +2415,7 @@ return ::mlir::success(); } -LogicalResult FormatParser::verifyAttributes(llvm::SMLoc loc) { +LogicalResult FormatParser::verifyAttributes(SMLoc loc) { // Check that there are no `:` literals after an attribute without a constant // type. The attribute grammar contains an optional trailing colon type, which // can lead to unexpected and generally unintended behavior. Given that, it is @@ -2441,7 +2441,7 @@ } /// Verify the attribute elements at the back of the given stack of iterators. LogicalResult FormatParser::verifyAttributes( - llvm::SMLoc loc, + SMLoc loc, SmallVectorImpl> &iteratorStack) { auto &stackIt = iteratorStack.back(); ElementsIterT &it = stackIt.first, e = stackIt.second; @@ -2497,7 +2497,7 @@ } LogicalResult FormatParser::verifyOperands( - llvm::SMLoc loc, + SMLoc loc, llvm::StringMap &variableTyResolver) { // Check that all of the operands are within the format, and their types can // be inferred. @@ -2544,7 +2544,7 @@ return ::mlir::success(); } -LogicalResult FormatParser::verifyRegions(llvm::SMLoc loc) { +LogicalResult FormatParser::verifyRegions(SMLoc loc) { // Check that all of the regions are within the format. if (hasAllRegions) return ::mlir::success(); @@ -2563,7 +2563,7 @@ } LogicalResult FormatParser::verifyResults( - llvm::SMLoc loc, + SMLoc loc, llvm::StringMap &variableTyResolver) { // If we format all of the types together, there is nothing to check. if (fmt.allResultTypes) @@ -2611,7 +2611,7 @@ return ::mlir::success(); } -LogicalResult FormatParser::verifySuccessors(llvm::SMLoc loc) { +LogicalResult FormatParser::verifySuccessors(SMLoc loc) { // Check that all of the successors are within the format. if (hasAllSuccessors) return ::mlir::success(); @@ -2715,7 +2715,7 @@ consumeToken(); StringRef name = varTok.getSpelling().drop_front(); - llvm::SMLoc loc = varTok.getLoc(); + SMLoc loc = varTok.getLoc(); // Check that the parsed argument is something actually registered on the // op. @@ -2861,7 +2861,7 @@ LogicalResult FormatParser::parseOptional(std::unique_ptr &element, ParserContext context) { - llvm::SMLoc curLoc = curToken.getLoc(); + SMLoc curLoc = curToken.getLoc(); if (context != TopLevelContext) return emitError(curLoc, "optional groups can only be used as top-level " "elements"); @@ -2884,7 +2884,7 @@ "of optional group"))) return failure(); do { - llvm::SMLoc childLoc = curToken.getLoc(); + SMLoc childLoc = curToken.getLoc(); elseElements.push_back({}); if (failed(parseElement(elseElements.back(), TopLevelContext)) || failed(verifyOptionalChildElement(elseElements.back().get(), childLoc, @@ -2924,7 +2924,7 @@ LogicalResult FormatParser::parseOptionalChildElement( std::vector> &childElements, Optional &anchorIdx) { - llvm::SMLoc childLoc = curToken.getLoc(); + SMLoc childLoc = curToken.getLoc(); childElements.push_back({}); if (failed(parseElement(childElements.back(), TopLevelContext))) return ::mlir::failure(); @@ -2944,7 +2944,7 @@ } LogicalResult FormatParser::verifyOptionalChildElement(Element *element, - llvm::SMLoc childLoc, + SMLoc childLoc, bool isAnchor) { return TypeSwitch(element) // All attributes can be within the optional group, but only optional @@ -3004,7 +3004,7 @@ LogicalResult FormatParser::parseAttrDictDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context, + SMLoc loc, ParserContext context, bool withKeyword) { if (context == TypeDirectiveContext) return emitError(loc, "'attr-dict' directive can only be used as a " @@ -3028,8 +3028,8 @@ LogicalResult FormatParser::parseCustomDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context) { - llvm::SMLoc curLoc = curToken.getLoc(); + SMLoc loc, ParserContext context) { + SMLoc curLoc = curToken.getLoc(); if (context != TopLevelContext) return emitError(loc, "'custom' is only valid as a top-level directive"); @@ -3079,7 +3079,7 @@ LogicalResult FormatParser::parseCustomDirectiveParameter( std::vector> ¶meters) { - llvm::SMLoc childLoc = curToken.getLoc(); + SMLoc childLoc = curToken.getLoc(); parameters.push_back({}); if (failed(parseElement(parameters.back(), CustomDirectiveContext))) return ::mlir::failure(); @@ -3096,7 +3096,7 @@ LogicalResult FormatParser::parseFunctionalTypeDirective( std::unique_ptr &element, FormatToken tok, ParserContext context) { - llvm::SMLoc loc = tok.getLoc(); + SMLoc loc = tok.getLoc(); if (context != TopLevelContext) return emitError( loc, "'functional-type' is only valid as a top-level directive"); @@ -3119,7 +3119,7 @@ LogicalResult FormatParser::parseOperandsDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context) { + SMLoc loc, ParserContext context) { if (context == RefDirectiveContext) { if (!fmt.allOperands) return emitError(loc, "'ref' of 'operands' is not bound by a prior " @@ -3136,7 +3136,7 @@ LogicalResult FormatParser::parseReferenceDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context) { + SMLoc loc, ParserContext context) { if (context != CustomDirectiveContext) return emitError(loc, "'ref' is only valid within a `custom` directive"); @@ -3154,7 +3154,7 @@ LogicalResult FormatParser::parseRegionsDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context) { + SMLoc loc, ParserContext context) { if (context == TypeDirectiveContext) return emitError(loc, "'regions' is only valid as a top-level directive"); if (context == RefDirectiveContext) { @@ -3174,7 +3174,7 @@ LogicalResult FormatParser::parseResultsDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context) { + SMLoc loc, ParserContext context) { if (context != TypeDirectiveContext) return emitError(loc, "'results' directive can can only be used as a child " "to a 'type' directive"); @@ -3184,7 +3184,7 @@ LogicalResult FormatParser::parseSuccessorsDirective(std::unique_ptr &element, - llvm::SMLoc loc, ParserContext context) { + SMLoc loc, ParserContext context) { if (context == TypeDirectiveContext) return emitError(loc, "'successors' is only valid as a top-level directive"); @@ -3206,7 +3206,7 @@ LogicalResult FormatParser::parseTypeDirective(std::unique_ptr &element, FormatToken tok, ParserContext context) { - llvm::SMLoc loc = tok.getLoc(); + SMLoc loc = tok.getLoc(); if (context == TypeDirectiveContext) return emitError(loc, "'type' cannot be used as a child of another `type`"); @@ -3247,7 +3247,7 @@ LogicalResult FormatParser::parseTypeDirectiveOperand(std::unique_ptr &element, bool isRefChild) { - llvm::SMLoc loc = curToken.getLoc(); + SMLoc loc = curToken.getLoc(); if (failed(parseElement(element, TypeDirectiveContext))) return ::mlir::failure(); if (isa(element.get())) @@ -3306,7 +3306,7 @@ // Parse the format description. llvm::SourceMgr mgr; mgr.AddNewSourceBuffer( - llvm::MemoryBuffer::getMemBuffer(op.getAssemblyFormat()), llvm::SMLoc()); + llvm::MemoryBuffer::getMemBuffer(op.getAssemblyFormat()), SMLoc()); OperationFormat format(op); if (failed(FormatParser(mgr, format, op).parse())) { // Exit the process if format errors are treated as fatal. diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -229,7 +229,7 @@ // Pattern instantiation location followed by the location of multiclass // prototypes used. This is intended to be used as a whole to // PrintFatalError() on errors. - ArrayRef loc; + ArrayRef loc; // Op's TableGen Record to wrapper object. RecordOperatorMap *opMap; diff --git a/mlir/unittests/Dialect/SparseTensor/MergerTest.cpp b/mlir/unittests/Dialect/SparseTensor/MergerTest.cpp --- a/mlir/unittests/Dialect/SparseTensor/MergerTest.cpp +++ b/mlir/unittests/Dialect/SparseTensor/MergerTest.cpp @@ -3,6 +3,7 @@ #include "gtest/gtest.h" #include +using namespace mlir; using namespace mlir::sparse_tensor; namespace {