mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 20:10:50 +08:00
Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC)
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace toy {
|
||||
@@ -44,7 +45,7 @@ public:
|
||||
};
|
||||
|
||||
ExprAST(ExprASTKind kind, Location location)
|
||||
: kind(kind), location(location) {}
|
||||
: kind(kind), location(std::move(location)) {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
ExprASTKind getKind() const { return kind; }
|
||||
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
|
||||
double Val;
|
||||
|
||||
public:
|
||||
NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
|
||||
NumberExprAST(Location loc, double val)
|
||||
: ExprAST(Expr_Num, std::move(loc)), Val(val) {}
|
||||
|
||||
double getValue() { return Val; }
|
||||
|
||||
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
|
||||
public:
|
||||
LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
|
||||
std::vector<int64_t> dims)
|
||||
: ExprAST(Expr_Literal, loc), values(std::move(values)),
|
||||
: ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
|
||||
dims(std::move(dims)) {}
|
||||
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
|
||||
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(Location loc, llvm::StringRef name)
|
||||
: ExprAST(Expr_Var, loc), name(name) {}
|
||||
: ExprAST(Expr_Var, std::move(loc)), name(name) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
|
||||
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
|
||||
public:
|
||||
VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
|
||||
std::unique_ptr<ExprAST> initVal)
|
||||
: ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
|
||||
initVal(std::move(initVal)) {}
|
||||
: ExprAST(Expr_VarDecl, std::move(loc)), name(name),
|
||||
type(std::move(type)), initVal(std::move(initVal)) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
ExprAST *getInitVal() { return initVal.get(); }
|
||||
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
if (expr.hasValue())
|
||||
@@ -154,7 +156,7 @@ public:
|
||||
|
||||
BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
|
||||
std::unique_ptr<ExprAST> rhs)
|
||||
: ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
|
||||
: ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
|
||||
rhs(std::move(rhs)) {}
|
||||
|
||||
/// LLVM style RTTI
|
||||
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
|
||||
public:
|
||||
CallExprAST(Location loc, const std::string &callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> args)
|
||||
: ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
|
||||
: ExprAST(Expr_Call, std::move(loc)), callee(callee),
|
||||
args(std::move(args)) {}
|
||||
|
||||
llvm::StringRef getCallee() { return callee; }
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
|
||||
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
|
||||
: ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
|
||||
: ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
|
||||
|
||||
ExprAST *getArg() { return arg.get(); }
|
||||
|
||||
@@ -203,7 +206,7 @@ class PrototypeAST {
|
||||
public:
|
||||
PrototypeAST(Location location, const std::string &name,
|
||||
std::vector<std::unique_ptr<VariableExprAST>> args)
|
||||
: location(location), name(name), args(std::move(args)) {}
|
||||
: location(std::move(location)), name(name), args(std::move(args)) {}
|
||||
|
||||
const Location &loc() { return location; }
|
||||
llvm::StringRef getName() const { return name; }
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace toy {
|
||||
@@ -44,7 +45,7 @@ public:
|
||||
};
|
||||
|
||||
ExprAST(ExprASTKind kind, Location location)
|
||||
: kind(kind), location(location) {}
|
||||
: kind(kind), location(std::move(location)) {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
ExprASTKind getKind() const { return kind; }
|
||||
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
|
||||
double Val;
|
||||
|
||||
public:
|
||||
NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
|
||||
NumberExprAST(Location loc, double val)
|
||||
: ExprAST(Expr_Num, std::move(loc)), Val(val) {}
|
||||
|
||||
double getValue() { return Val; }
|
||||
|
||||
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
|
||||
public:
|
||||
LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
|
||||
std::vector<int64_t> dims)
|
||||
: ExprAST(Expr_Literal, loc), values(std::move(values)),
|
||||
: ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
|
||||
dims(std::move(dims)) {}
|
||||
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
|
||||
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(Location loc, llvm::StringRef name)
|
||||
: ExprAST(Expr_Var, loc), name(name) {}
|
||||
: ExprAST(Expr_Var, std::move(loc)), name(name) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
|
||||
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
|
||||
public:
|
||||
VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
|
||||
std::unique_ptr<ExprAST> initVal)
|
||||
: ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
|
||||
initVal(std::move(initVal)) {}
|
||||
: ExprAST(Expr_VarDecl, std::move(loc)), name(name),
|
||||
type(std::move(type)), initVal(std::move(initVal)) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
ExprAST *getInitVal() { return initVal.get(); }
|
||||
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
if (expr.hasValue())
|
||||
@@ -154,7 +156,7 @@ public:
|
||||
|
||||
BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
|
||||
std::unique_ptr<ExprAST> rhs)
|
||||
: ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
|
||||
: ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
|
||||
rhs(std::move(rhs)) {}
|
||||
|
||||
/// LLVM style RTTI
|
||||
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
|
||||
public:
|
||||
CallExprAST(Location loc, const std::string &callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> args)
|
||||
: ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
|
||||
: ExprAST(Expr_Call, std::move(loc)), callee(callee),
|
||||
args(std::move(args)) {}
|
||||
|
||||
llvm::StringRef getCallee() { return callee; }
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
|
||||
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
|
||||
: ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
|
||||
: ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
|
||||
|
||||
ExprAST *getArg() { return arg.get(); }
|
||||
|
||||
@@ -203,7 +206,7 @@ class PrototypeAST {
|
||||
public:
|
||||
PrototypeAST(Location location, const std::string &name,
|
||||
std::vector<std::unique_ptr<VariableExprAST>> args)
|
||||
: location(location), name(name), args(std::move(args)) {}
|
||||
: location(std::move(location)), name(name), args(std::move(args)) {}
|
||||
|
||||
const Location &loc() { return location; }
|
||||
llvm::StringRef getName() const { return name; }
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace toy {
|
||||
@@ -44,7 +45,7 @@ public:
|
||||
};
|
||||
|
||||
ExprAST(ExprASTKind kind, Location location)
|
||||
: kind(kind), location(location) {}
|
||||
: kind(kind), location(std::move(location)) {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
ExprASTKind getKind() const { return kind; }
|
||||
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
|
||||
double Val;
|
||||
|
||||
public:
|
||||
NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
|
||||
NumberExprAST(Location loc, double val)
|
||||
: ExprAST(Expr_Num, std::move(loc)), Val(val) {}
|
||||
|
||||
double getValue() { return Val; }
|
||||
|
||||
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
|
||||
public:
|
||||
LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
|
||||
std::vector<int64_t> dims)
|
||||
: ExprAST(Expr_Literal, loc), values(std::move(values)),
|
||||
: ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
|
||||
dims(std::move(dims)) {}
|
||||
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
|
||||
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(Location loc, llvm::StringRef name)
|
||||
: ExprAST(Expr_Var, loc), name(name) {}
|
||||
: ExprAST(Expr_Var, std::move(loc)), name(name) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
|
||||
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
|
||||
public:
|
||||
VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
|
||||
std::unique_ptr<ExprAST> initVal)
|
||||
: ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
|
||||
initVal(std::move(initVal)) {}
|
||||
: ExprAST(Expr_VarDecl, std::move(loc)), name(name),
|
||||
type(std::move(type)), initVal(std::move(initVal)) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
ExprAST *getInitVal() { return initVal.get(); }
|
||||
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
if (expr.hasValue())
|
||||
@@ -154,7 +156,7 @@ public:
|
||||
|
||||
BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
|
||||
std::unique_ptr<ExprAST> rhs)
|
||||
: ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
|
||||
: ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
|
||||
rhs(std::move(rhs)) {}
|
||||
|
||||
/// LLVM style RTTI
|
||||
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
|
||||
public:
|
||||
CallExprAST(Location loc, const std::string &callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> args)
|
||||
: ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
|
||||
: ExprAST(Expr_Call, std::move(loc)), callee(callee),
|
||||
args(std::move(args)) {}
|
||||
|
||||
llvm::StringRef getCallee() { return callee; }
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
|
||||
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
|
||||
: ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
|
||||
: ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
|
||||
|
||||
ExprAST *getArg() { return arg.get(); }
|
||||
|
||||
@@ -203,7 +206,7 @@ class PrototypeAST {
|
||||
public:
|
||||
PrototypeAST(Location location, const std::string &name,
|
||||
std::vector<std::unique_ptr<VariableExprAST>> args)
|
||||
: location(location), name(name), args(std::move(args)) {}
|
||||
: location(std::move(location)), name(name), args(std::move(args)) {}
|
||||
|
||||
const Location &loc() { return location; }
|
||||
llvm::StringRef getName() const { return name; }
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace toy {
|
||||
@@ -44,7 +45,7 @@ public:
|
||||
};
|
||||
|
||||
ExprAST(ExprASTKind kind, Location location)
|
||||
: kind(kind), location(location) {}
|
||||
: kind(kind), location(std::move(location)) {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
ExprASTKind getKind() const { return kind; }
|
||||
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
|
||||
double Val;
|
||||
|
||||
public:
|
||||
NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
|
||||
NumberExprAST(Location loc, double val)
|
||||
: ExprAST(Expr_Num, std::move(loc)), Val(val) {}
|
||||
|
||||
double getValue() { return Val; }
|
||||
|
||||
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
|
||||
public:
|
||||
LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
|
||||
std::vector<int64_t> dims)
|
||||
: ExprAST(Expr_Literal, loc), values(std::move(values)),
|
||||
: ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
|
||||
dims(std::move(dims)) {}
|
||||
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
|
||||
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(Location loc, llvm::StringRef name)
|
||||
: ExprAST(Expr_Var, loc), name(name) {}
|
||||
: ExprAST(Expr_Var, std::move(loc)), name(name) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
|
||||
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
|
||||
public:
|
||||
VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
|
||||
std::unique_ptr<ExprAST> initVal)
|
||||
: ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
|
||||
initVal(std::move(initVal)) {}
|
||||
: ExprAST(Expr_VarDecl, std::move(loc)), name(name),
|
||||
type(std::move(type)), initVal(std::move(initVal)) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
ExprAST *getInitVal() { return initVal.get(); }
|
||||
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
if (expr.hasValue())
|
||||
@@ -154,7 +156,7 @@ public:
|
||||
|
||||
BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
|
||||
std::unique_ptr<ExprAST> rhs)
|
||||
: ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
|
||||
: ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
|
||||
rhs(std::move(rhs)) {}
|
||||
|
||||
/// LLVM style RTTI
|
||||
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
|
||||
public:
|
||||
CallExprAST(Location loc, const std::string &callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> args)
|
||||
: ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
|
||||
: ExprAST(Expr_Call, std::move(loc)), callee(callee),
|
||||
args(std::move(args)) {}
|
||||
|
||||
llvm::StringRef getCallee() { return callee; }
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
|
||||
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
|
||||
: ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
|
||||
: ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
|
||||
|
||||
ExprAST *getArg() { return arg.get(); }
|
||||
|
||||
@@ -203,7 +206,7 @@ class PrototypeAST {
|
||||
public:
|
||||
PrototypeAST(Location location, const std::string &name,
|
||||
std::vector<std::unique_ptr<VariableExprAST>> args)
|
||||
: location(location), name(name), args(std::move(args)) {}
|
||||
: location(std::move(location)), name(name), args(std::move(args)) {}
|
||||
|
||||
const Location &loc() { return location; }
|
||||
llvm::StringRef getName() const { return name; }
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace toy {
|
||||
@@ -44,7 +45,7 @@ public:
|
||||
};
|
||||
|
||||
ExprAST(ExprASTKind kind, Location location)
|
||||
: kind(kind), location(location) {}
|
||||
: kind(kind), location(std::move(location)) {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
ExprASTKind getKind() const { return kind; }
|
||||
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
|
||||
double Val;
|
||||
|
||||
public:
|
||||
NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
|
||||
NumberExprAST(Location loc, double val)
|
||||
: ExprAST(Expr_Num, std::move(loc)), Val(val) {}
|
||||
|
||||
double getValue() { return Val; }
|
||||
|
||||
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
|
||||
public:
|
||||
LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
|
||||
std::vector<int64_t> dims)
|
||||
: ExprAST(Expr_Literal, loc), values(std::move(values)),
|
||||
: ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
|
||||
dims(std::move(dims)) {}
|
||||
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
|
||||
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(Location loc, llvm::StringRef name)
|
||||
: ExprAST(Expr_Var, loc), name(name) {}
|
||||
: ExprAST(Expr_Var, std::move(loc)), name(name) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
|
||||
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
|
||||
public:
|
||||
VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
|
||||
std::unique_ptr<ExprAST> initVal)
|
||||
: ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
|
||||
initVal(std::move(initVal)) {}
|
||||
: ExprAST(Expr_VarDecl, std::move(loc)), name(name),
|
||||
type(std::move(type)), initVal(std::move(initVal)) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
ExprAST *getInitVal() { return initVal.get(); }
|
||||
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
if (expr.hasValue())
|
||||
@@ -154,7 +156,7 @@ public:
|
||||
|
||||
BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
|
||||
std::unique_ptr<ExprAST> rhs)
|
||||
: ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
|
||||
: ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
|
||||
rhs(std::move(rhs)) {}
|
||||
|
||||
/// LLVM style RTTI
|
||||
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
|
||||
public:
|
||||
CallExprAST(Location loc, const std::string &callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> args)
|
||||
: ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
|
||||
: ExprAST(Expr_Call, std::move(loc)), callee(callee),
|
||||
args(std::move(args)) {}
|
||||
|
||||
llvm::StringRef getCallee() { return callee; }
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
|
||||
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
|
||||
: ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
|
||||
: ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
|
||||
|
||||
ExprAST *getArg() { return arg.get(); }
|
||||
|
||||
@@ -203,7 +206,7 @@ class PrototypeAST {
|
||||
public:
|
||||
PrototypeAST(Location location, const std::string &name,
|
||||
std::vector<std::unique_ptr<VariableExprAST>> args)
|
||||
: location(location), name(name), args(std::move(args)) {}
|
||||
: location(std::move(location)), name(name), args(std::move(args)) {}
|
||||
|
||||
const Location &loc() { return location; }
|
||||
llvm::StringRef getName() const { return name; }
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace toy {
|
||||
@@ -44,7 +45,7 @@ public:
|
||||
};
|
||||
|
||||
ExprAST(ExprASTKind kind, Location location)
|
||||
: kind(kind), location(location) {}
|
||||
: kind(kind), location(std::move(location)) {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
ExprASTKind getKind() const { return kind; }
|
||||
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
|
||||
double Val;
|
||||
|
||||
public:
|
||||
NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
|
||||
NumberExprAST(Location loc, double val)
|
||||
: ExprAST(Expr_Num, std::move(loc)), Val(val) {}
|
||||
|
||||
double getValue() { return Val; }
|
||||
|
||||
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
|
||||
public:
|
||||
LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
|
||||
std::vector<int64_t> dims)
|
||||
: ExprAST(Expr_Literal, loc), values(std::move(values)),
|
||||
: ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
|
||||
dims(std::move(dims)) {}
|
||||
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
|
||||
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(Location loc, llvm::StringRef name)
|
||||
: ExprAST(Expr_Var, loc), name(name) {}
|
||||
: ExprAST(Expr_Var, std::move(loc)), name(name) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
|
||||
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
|
||||
public:
|
||||
VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
|
||||
std::unique_ptr<ExprAST> initVal)
|
||||
: ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
|
||||
initVal(std::move(initVal)) {}
|
||||
: ExprAST(Expr_VarDecl, std::move(loc)), name(name),
|
||||
type(std::move(type)), initVal(std::move(initVal)) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
ExprAST *getInitVal() { return initVal.get(); }
|
||||
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
if (expr.hasValue())
|
||||
@@ -154,7 +156,7 @@ public:
|
||||
|
||||
BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
|
||||
std::unique_ptr<ExprAST> rhs)
|
||||
: ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
|
||||
: ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
|
||||
rhs(std::move(rhs)) {}
|
||||
|
||||
/// LLVM style RTTI
|
||||
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
|
||||
public:
|
||||
CallExprAST(Location loc, const std::string &callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> args)
|
||||
: ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
|
||||
: ExprAST(Expr_Call, std::move(loc)), callee(callee),
|
||||
args(std::move(args)) {}
|
||||
|
||||
llvm::StringRef getCallee() { return callee; }
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
|
||||
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
|
||||
: ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
|
||||
: ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
|
||||
|
||||
ExprAST *getArg() { return arg.get(); }
|
||||
|
||||
@@ -203,7 +206,7 @@ class PrototypeAST {
|
||||
public:
|
||||
PrototypeAST(Location location, const std::string &name,
|
||||
std::vector<std::unique_ptr<VariableExprAST>> args)
|
||||
: location(location), name(name), args(std::move(args)) {}
|
||||
: location(std::move(location)), name(name), args(std::move(args)) {}
|
||||
|
||||
const Location &loc() { return location; }
|
||||
llvm::StringRef getName() const { return name; }
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace toy {
|
||||
@@ -46,7 +47,7 @@ public:
|
||||
};
|
||||
|
||||
ExprAST(ExprASTKind kind, Location location)
|
||||
: kind(kind), location(location) {}
|
||||
: kind(kind), location(std::move(location)) {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
ExprASTKind getKind() const { return kind; }
|
||||
@@ -66,7 +67,8 @@ class NumberExprAST : public ExprAST {
|
||||
double Val;
|
||||
|
||||
public:
|
||||
NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
|
||||
NumberExprAST(Location loc, double val)
|
||||
: ExprAST(Expr_Num, std::move(loc)), Val(val) {}
|
||||
|
||||
double getValue() { return Val; }
|
||||
|
||||
@@ -82,7 +84,7 @@ class LiteralExprAST : public ExprAST {
|
||||
public:
|
||||
LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
|
||||
std::vector<int64_t> dims)
|
||||
: ExprAST(Expr_Literal, loc), values(std::move(values)),
|
||||
: ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
|
||||
dims(std::move(dims)) {}
|
||||
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
|
||||
@@ -99,7 +101,8 @@ class StructLiteralExprAST : public ExprAST {
|
||||
public:
|
||||
StructLiteralExprAST(Location loc,
|
||||
std::vector<std::unique_ptr<ExprAST>> values)
|
||||
: ExprAST(Expr_StructLiteral, loc), values(std::move(values)) {}
|
||||
: ExprAST(Expr_StructLiteral, std::move(loc)), values(std::move(values)) {
|
||||
}
|
||||
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
|
||||
|
||||
@@ -115,7 +118,7 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(Location loc, llvm::StringRef name)
|
||||
: ExprAST(Expr_Var, loc), name(name) {}
|
||||
: ExprAST(Expr_Var, std::move(loc)), name(name) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
|
||||
@@ -132,8 +135,8 @@ class VarDeclExprAST : public ExprAST {
|
||||
public:
|
||||
VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
|
||||
std::unique_ptr<ExprAST> initVal = nullptr)
|
||||
: ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
|
||||
initVal(std::move(initVal)) {}
|
||||
: ExprAST(Expr_VarDecl, std::move(loc)), name(name),
|
||||
type(std::move(type)), initVal(std::move(initVal)) {}
|
||||
|
||||
llvm::StringRef getName() { return name; }
|
||||
ExprAST *getInitVal() { return initVal.get(); }
|
||||
@@ -149,7 +152,7 @@ class ReturnExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
|
||||
: ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
|
||||
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
|
||||
|
||||
llvm::Optional<ExprAST *> getExpr() {
|
||||
if (expr.hasValue())
|
||||
@@ -173,7 +176,7 @@ public:
|
||||
|
||||
BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
|
||||
std::unique_ptr<ExprAST> rhs)
|
||||
: ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
|
||||
: ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
|
||||
rhs(std::move(rhs)) {}
|
||||
|
||||
/// LLVM style RTTI
|
||||
@@ -188,7 +191,8 @@ class CallExprAST : public ExprAST {
|
||||
public:
|
||||
CallExprAST(Location loc, const std::string &callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> args)
|
||||
: ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
|
||||
: ExprAST(Expr_Call, std::move(loc)), callee(callee),
|
||||
args(std::move(args)) {}
|
||||
|
||||
llvm::StringRef getCallee() { return callee; }
|
||||
llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
|
||||
@@ -203,7 +207,7 @@ class PrintExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
|
||||
: ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
|
||||
: ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
|
||||
|
||||
ExprAST *getArg() { return arg.get(); }
|
||||
|
||||
@@ -222,7 +226,7 @@ class PrototypeAST {
|
||||
public:
|
||||
PrototypeAST(Location location, const std::string &name,
|
||||
std::vector<std::unique_ptr<VarDeclExprAST>> args)
|
||||
: location(location), name(name), args(std::move(args)) {}
|
||||
: location(std::move(location)), name(name), args(std::move(args)) {}
|
||||
|
||||
const Location &loc() { return location; }
|
||||
llvm::StringRef getName() const { return name; }
|
||||
@@ -274,7 +278,7 @@ class StructAST : public RecordAST {
|
||||
public:
|
||||
StructAST(Location location, const std::string &name,
|
||||
std::vector<std::unique_ptr<VarDeclExprAST>> variables)
|
||||
: RecordAST(Record_Struct), location(location), name(name),
|
||||
: RecordAST(Record_Struct), location(std::move(location)), name(name),
|
||||
variables(std::move(variables)) {}
|
||||
|
||||
const Location &loc() { return location; }
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace adaptors {
|
||||
class pure_subclass {
|
||||
public:
|
||||
pure_subclass(py::handle scope, const char *derivedClassName,
|
||||
py::object superClass) {
|
||||
const py::object &superClass) {
|
||||
py::object pyType =
|
||||
py::reinterpret_borrow<py::object>((PyObject *)&PyType_Type);
|
||||
py::object metaclass = pyType(superClass);
|
||||
@@ -335,7 +335,8 @@ public:
|
||||
/// as the mlir.ir class (otherwise, it will trigger a recursive
|
||||
/// initialization).
|
||||
mlir_attribute_subclass(py::handle scope, const char *typeClassName,
|
||||
IsAFunctionTy isaFunction, py::object superClass)
|
||||
IsAFunctionTy isaFunction,
|
||||
const py::object &superClass)
|
||||
: pure_subclass(scope, typeClassName, superClass) {
|
||||
// Casting constructor. Note that defining an __init__ method is special
|
||||
// and not yet generalized on pure_subclass (it requires a somewhat
|
||||
@@ -386,7 +387,7 @@ public:
|
||||
/// as the mlir.ir class (otherwise, it will trigger a recursive
|
||||
/// initialization).
|
||||
mlir_type_subclass(py::handle scope, const char *typeClassName,
|
||||
IsAFunctionTy isaFunction, py::object superClass)
|
||||
IsAFunctionTy isaFunction, const py::object &superClass)
|
||||
: pure_subclass(scope, typeClassName, superClass) {
|
||||
// Casting constructor. Note that defining an __init__ method is special
|
||||
// and not yet generalized on pure_subclass (it requires a somewhat
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#ifndef MLIR_CAPI_UTILS_H
|
||||
#define MLIR_CAPI_UTILS_H
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "mlir-c/Support.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
@@ -29,7 +31,7 @@ class CallbackOstream : public llvm::raw_ostream {
|
||||
public:
|
||||
CallbackOstream(std::function<void(MlirStringRef, void *)> callback,
|
||||
void *opaqueData)
|
||||
: raw_ostream(/*unbuffered=*/true), callback(callback),
|
||||
: raw_ostream(/*unbuffered=*/true), callback(std::move(callback)),
|
||||
opaqueData(opaqueData), pos(0u) {}
|
||||
|
||||
void write_impl(const char *ptr, size_t size) override {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#ifndef MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_BUFFERIZABLEOPINTERFACE_H_
|
||||
#define MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_BUFFERIZABLEOPINTERFACE_H_
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "mlir/IR/BlockAndValueMapping.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
@@ -48,7 +50,8 @@ struct AllocationCallbacks {
|
||||
|
||||
AllocationCallbacks(AllocationFn allocFn, DeallocationFn deallocFn,
|
||||
MemCpyFn copyFn)
|
||||
: allocationFn(allocFn), deallocationFn(deallocFn), memCpyFn(copyFn) {}
|
||||
: allocationFn(std::move(allocFn)), deallocationFn(std::move(deallocFn)),
|
||||
memCpyFn(std::move(copyFn)) {}
|
||||
|
||||
/// A function that allocates memory.
|
||||
AllocationFn allocationFn;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#ifndef MLIR_DIALECT_LINALG_TRANSFORMS_CODEGENSTRATEGY_H_
|
||||
#define MLIR_DIALECT_LINALG_TRANSFORMS_CODEGENSTRATEGY_H_
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
|
||||
#include "mlir/Dialect/Linalg/Passes.h"
|
||||
#include "mlir/Pass/PassManager.h"
|
||||
@@ -23,7 +25,7 @@ namespace linalg {
|
||||
/// through markers.
|
||||
struct Transformation {
|
||||
explicit Transformation(LinalgTransformationFilter::FilterFunction f)
|
||||
: filter(f) {}
|
||||
: filter(std::move(f)) {}
|
||||
virtual ~Transformation() = default;
|
||||
virtual void addToPassPipeline(OpPassManager &pm,
|
||||
LinalgTransformationFilter m) const = 0;
|
||||
@@ -34,7 +36,8 @@ struct Transformation {
|
||||
struct TileAndFuse : public Transformation {
|
||||
TileAndFuse(StringRef name, linalg::LinalgTilingAndFusionOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr)
|
||||
: Transformation(f), opName(name), options(options) {}
|
||||
: Transformation(std::move(f)), opName(name),
|
||||
options(std::move(options)) {}
|
||||
|
||||
void addToPassPipeline(OpPassManager &pm,
|
||||
LinalgTransformationFilter m) const override {
|
||||
@@ -50,7 +53,8 @@ private:
|
||||
struct Tile : public Transformation {
|
||||
Tile(StringRef name, linalg::LinalgTilingOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr)
|
||||
: Transformation(f), opName(name), options(options) {}
|
||||
: Transformation(std::move(f)), opName(name),
|
||||
options(std::move(options)) {}
|
||||
|
||||
void addToPassPipeline(OpPassManager &pm,
|
||||
LinalgTransformationFilter m) const override {
|
||||
@@ -66,7 +70,8 @@ private:
|
||||
struct Pad : public Transformation {
|
||||
Pad(StringRef name, linalg::LinalgPaddingOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr)
|
||||
: Transformation(f), opName(name), options(options) {}
|
||||
: Transformation(std::move(f)), opName(name),
|
||||
options(std::move(options)) {}
|
||||
|
||||
void addToPassPipeline(OpPassManager &pm,
|
||||
LinalgTransformationFilter m) const override {
|
||||
@@ -82,7 +87,8 @@ private:
|
||||
struct Promote : public Transformation {
|
||||
Promote(StringRef name, linalg::LinalgPromotionOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr)
|
||||
: Transformation(f), opName(name), options(options) {}
|
||||
: Transformation(std::move(f)), opName(name),
|
||||
options(std::move(options)) {}
|
||||
|
||||
void addToPassPipeline(OpPassManager &pm,
|
||||
LinalgTransformationFilter m) const override {
|
||||
@@ -98,7 +104,7 @@ private:
|
||||
struct Generalize : public Transformation {
|
||||
explicit Generalize(StringRef name,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr)
|
||||
: Transformation(f), opName(name) {}
|
||||
: Transformation(std::move(f)), opName(name) {}
|
||||
|
||||
void addToPassPipeline(OpPassManager &pm,
|
||||
LinalgTransformationFilter m) const override {
|
||||
@@ -113,8 +119,9 @@ private:
|
||||
struct Interchange : public Transformation {
|
||||
explicit Interchange(ArrayRef<int64_t> iteratorInterchange,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr)
|
||||
: Transformation(f), iteratorInterchange(iteratorInterchange.begin(),
|
||||
iteratorInterchange.end()) {}
|
||||
: Transformation(std::move(f)),
|
||||
iteratorInterchange(iteratorInterchange.begin(),
|
||||
iteratorInterchange.end()) {}
|
||||
|
||||
void addToPassPipeline(OpPassManager &pm,
|
||||
LinalgTransformationFilter m) const override {
|
||||
@@ -128,7 +135,7 @@ private:
|
||||
/// Represent one application of createLinalgStrategyDecomposePass.
|
||||
struct Decompose : public Transformation {
|
||||
explicit Decompose(LinalgTransformationFilter::FilterFunction f = nullptr)
|
||||
: Transformation(f) {}
|
||||
: Transformation(std::move(f)) {}
|
||||
|
||||
void addToPassPipeline(OpPassManager &pm,
|
||||
LinalgTransformationFilter m) const override {
|
||||
@@ -141,13 +148,13 @@ struct Vectorize : public Transformation {
|
||||
explicit Vectorize(linalg::LinalgVectorizationOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr,
|
||||
bool padVectorize = false)
|
||||
: Transformation(f), opName(), options(options),
|
||||
: Transformation(std::move(f)), opName(), options(options),
|
||||
vectorizePadding(padVectorize) {}
|
||||
|
||||
Vectorize(StringRef name, linalg::LinalgVectorizationOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr,
|
||||
bool padVectorize = false)
|
||||
: Transformation(f), opName(name), options(options),
|
||||
: Transformation(std::move(f)), opName(name), options(options),
|
||||
vectorizePadding(padVectorize) {}
|
||||
|
||||
void addToPassPipeline(OpPassManager &pm,
|
||||
@@ -167,7 +174,7 @@ struct VectorLowering : public Transformation {
|
||||
explicit VectorLowering(
|
||||
linalg::LinalgVectorLoweringOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr)
|
||||
: Transformation(f), options(options) {}
|
||||
: Transformation(std::move(f)), options(options) {}
|
||||
|
||||
void addToPassPipeline(OpPassManager &pm,
|
||||
LinalgTransformationFilter m) const override {
|
||||
@@ -183,8 +190,8 @@ struct CodegenStrategy {
|
||||
/// Append a pattern to tile the Op `opName` and fuse its producers with
|
||||
/// tiling and fusion `options`.
|
||||
CodegenStrategy &
|
||||
tileAndFuse(StringRef opName, LinalgTilingAndFusionOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
tileAndFuse(StringRef opName, const LinalgTilingAndFusionOptions &options,
|
||||
const LinalgTransformationFilter::FilterFunction &f = nullptr) {
|
||||
transformationSequence.emplace_back(
|
||||
std::make_unique<TileAndFuse>(opName, options, f));
|
||||
return *this;
|
||||
@@ -194,13 +201,13 @@ struct CodegenStrategy {
|
||||
CodegenStrategy &
|
||||
tileAndFuseIf(bool b, StringRef opName, LinalgTilingAndFusionOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
return b ? tileAndFuse(opName, options, f) : *this;
|
||||
return b ? tileAndFuse(opName, std::move(options), std::move(f)) : *this;
|
||||
}
|
||||
/// Append a pattern to add a level of tiling for Op `opName` with tiling
|
||||
/// `options`.
|
||||
CodegenStrategy &
|
||||
tile(StringRef opName, linalg::LinalgTilingOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
tile(StringRef opName, const linalg::LinalgTilingOptions &options,
|
||||
const LinalgTransformationFilter::FilterFunction &f = nullptr) {
|
||||
transformationSequence.emplace_back(
|
||||
std::make_unique<Tile>(opName, options, f));
|
||||
return *this;
|
||||
@@ -210,12 +217,13 @@ struct CodegenStrategy {
|
||||
CodegenStrategy &
|
||||
tileIf(bool b, StringRef opName, linalg::LinalgTilingOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
return b ? tile(opName, options, f) : *this;
|
||||
return b ? tile(opName, std::move(options), std::move(f)) : *this;
|
||||
}
|
||||
/// Append a pattern to pad and hoist the operands of Op `opName` with padding
|
||||
/// `options`.
|
||||
CodegenStrategy &pad(StringRef opName, linalg::LinalgPaddingOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
CodegenStrategy &
|
||||
pad(StringRef opName, const linalg::LinalgPaddingOptions &options,
|
||||
const LinalgTransformationFilter::FilterFunction &f = nullptr) {
|
||||
transformationSequence.emplace_back(
|
||||
std::make_unique<Pad>(opName, options, f));
|
||||
return *this;
|
||||
@@ -225,13 +233,13 @@ struct CodegenStrategy {
|
||||
CodegenStrategy &
|
||||
padIf(bool b, StringRef opName, linalg::LinalgPaddingOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
return b ? pad(opName, options, f) : *this;
|
||||
return b ? pad(opName, std::move(options), std::move(f)) : *this;
|
||||
}
|
||||
/// Append a pattern to add a level of promotion for `LinalgOpType` with
|
||||
/// promotion `options`.
|
||||
CodegenStrategy &
|
||||
promote(StringRef opName, linalg::LinalgPromotionOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
promote(StringRef opName, const linalg::LinalgPromotionOptions &options,
|
||||
const LinalgTransformationFilter::FilterFunction &f = nullptr) {
|
||||
transformationSequence.emplace_back(
|
||||
std::make_unique<Promote>(opName, options, f));
|
||||
return *this;
|
||||
@@ -241,12 +249,12 @@ struct CodegenStrategy {
|
||||
CodegenStrategy &
|
||||
promoteIf(bool b, StringRef opName, linalg::LinalgPromotionOptions options,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
return b ? promote(opName, options, f) : *this;
|
||||
return b ? promote(opName, std::move(options), std::move(f)) : *this;
|
||||
}
|
||||
/// Append a pattern to generalize named operations.
|
||||
CodegenStrategy &
|
||||
generalize(StringRef opName,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
const LinalgTransformationFilter::FilterFunction &f = nullptr) {
|
||||
transformationSequence.emplace_back(
|
||||
std::make_unique<Generalize>(opName, f));
|
||||
return *this;
|
||||
@@ -255,12 +263,12 @@ struct CodegenStrategy {
|
||||
CodegenStrategy &
|
||||
generalizeIf(bool b, StringRef opName,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
return b ? generalize(opName, f) : *this;
|
||||
return b ? generalize(opName, std::move(f)) : *this;
|
||||
}
|
||||
/// Append a pattern to interchange iterators.
|
||||
CodegenStrategy &
|
||||
interchange(ArrayRef<int64_t> iteratorInterchange,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
const LinalgTransformationFilter::FilterFunction &f = nullptr) {
|
||||
transformationSequence.emplace_back(
|
||||
std::make_unique<Interchange>(iteratorInterchange, f));
|
||||
return *this;
|
||||
@@ -269,23 +277,23 @@ struct CodegenStrategy {
|
||||
CodegenStrategy &
|
||||
interchangeIf(bool b, ArrayRef<int64_t> iteratorInterchange,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
return b ? interchange(iteratorInterchange, f) : *this;
|
||||
return b ? interchange(iteratorInterchange, std::move(f)) : *this;
|
||||
}
|
||||
/// Append patterns to decompose convolutions.
|
||||
CodegenStrategy &
|
||||
decompose(LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
decompose(const LinalgTransformationFilter::FilterFunction &f = nullptr) {
|
||||
transformationSequence.emplace_back(std::make_unique<Decompose>(f));
|
||||
return *this;
|
||||
}
|
||||
/// Conditionally append patterns to decompose convolutions.
|
||||
CodegenStrategy &
|
||||
decomposeIf(bool b, LinalgTransformationFilter::FilterFunction f = nullptr) {
|
||||
return b ? decompose(f) : *this;
|
||||
return b ? decompose(std::move(f)) : *this;
|
||||
}
|
||||
/// Append a pattern to rewrite `LinalgOpType` as a vector operation.
|
||||
CodegenStrategy &
|
||||
vectorize(StringRef opName,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr,
|
||||
const LinalgTransformationFilter::FilterFunction &f = nullptr,
|
||||
bool vectorizePadding = false) {
|
||||
transformationSequence.emplace_back(std::make_unique<Vectorize>(
|
||||
opName, linalg::LinalgVectorizationOptions(), f, vectorizePadding));
|
||||
@@ -297,7 +305,7 @@ struct CodegenStrategy {
|
||||
vectorizeIf(bool b, StringRef opName,
|
||||
LinalgTransformationFilter::FilterFunction f = nullptr,
|
||||
bool vectorizePadding = false) {
|
||||
return b ? vectorize(opName, f, vectorizePadding) : *this;
|
||||
return b ? vectorize(opName, std::move(f), vectorizePadding) : *this;
|
||||
}
|
||||
/// Append a pattern to lower all vector operations.
|
||||
CodegenStrategy &vectorLowering(LinalgVectorLoweringOptions options) {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#ifndef MLIR_DIALECT_LINALG_TRANSFORMS_TRANSFORMS_H
|
||||
#define MLIR_DIALECT_LINALG_TRANSFORMS_TRANSFORMS_H
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
|
||||
#include "mlir/Dialect/Linalg/Utils/Utils.h"
|
||||
#include "mlir/Dialect/MemRef/IR/MemRef.h"
|
||||
@@ -443,7 +445,7 @@ struct LinalgTransformationFilter {
|
||||
Operation *op) const;
|
||||
bool hasReplacementFilter(Operation *op) const;
|
||||
|
||||
LinalgTransformationFilter &addFilter(FilterFunction f) {
|
||||
LinalgTransformationFilter &addFilter(const FilterFunction &f) {
|
||||
if (f)
|
||||
filters.push_back(f);
|
||||
return *this;
|
||||
@@ -550,7 +552,7 @@ struct LinalgTilingOptions {
|
||||
/// Set the `tileSizeComputationFunction` to return the values `ts`. The
|
||||
/// values must not fold away when tiling. Otherwise, use a more robust
|
||||
/// `tileSizeComputationFunction`.
|
||||
LinalgTilingOptions &setTileSizes(SmallVector<Value, 4> ts) {
|
||||
LinalgTilingOptions &setTileSizes(const SmallVector<Value, 4> &ts) {
|
||||
tileSizeComputationFunction = [=](OpBuilder &, Operation *) { return ts; };
|
||||
return *this;
|
||||
}
|
||||
@@ -1160,7 +1162,7 @@ struct GeneralizePadTensorOpPattern : public OpRewritePattern<PadTensorOp> {
|
||||
OptimizeCopyFn optimizeCopyFn = nullptr,
|
||||
PatternBenefit benefit = 1)
|
||||
: OpRewritePattern<PadTensorOp>(context, benefit),
|
||||
optimizeCopyFn(optimizeCopyFn) {}
|
||||
optimizeCopyFn(std::move(optimizeCopyFn)) {}
|
||||
LogicalResult matchAndRewrite(PadTensorOp padOp,
|
||||
PatternRewriter &rewriter) const override;
|
||||
|
||||
@@ -1276,7 +1278,7 @@ class ConvOpVectorization : public OpRewritePattern<ConvOp> {
|
||||
SmallVector<bool, 4> mask;
|
||||
|
||||
public:
|
||||
ConvOpVectorization(MLIRContext *context, SmallVector<bool, 4> msk)
|
||||
ConvOpVectorization(MLIRContext *context, const SmallVector<bool, 4> &msk)
|
||||
: OpRewritePattern<ConvOp>(context) {
|
||||
assert(msk.size() == N && "Mask size does not match rank");
|
||||
this->mask = msk;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#ifndef MLIR_DIALECT_QUANT_UNIFORMSUPPORT_H_
|
||||
#define MLIR_DIALECT_QUANT_UNIFORMSUPPORT_H_
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "mlir/Dialect/Quant/QuantTypes.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Types.h"
|
||||
@@ -79,7 +81,8 @@ public:
|
||||
roundMode(APFloat::rmNearestTiesToAway) {}
|
||||
|
||||
UniformQuantizedValueConverter(double scale, double zeroPoint,
|
||||
APFloat clampMin, APFloat clampMax,
|
||||
const APFloat &clampMin,
|
||||
const APFloat &clampMax,
|
||||
uint32_t storageBitWidth, bool isSigned)
|
||||
: scale(scale), zeroPoint(zeroPoint), clampMin(clampMin),
|
||||
clampMax(clampMax), scaleDouble(scale), zeroPointDouble(zeroPoint),
|
||||
@@ -116,7 +119,7 @@ public:
|
||||
}
|
||||
|
||||
int64_t quantizeFloatToInt64(APFloat expressedValue) const {
|
||||
APInt qValue = quantizeFloatToInt(expressedValue);
|
||||
APInt qValue = quantizeFloatToInt(std::move(expressedValue));
|
||||
return isSigned ? qValue.getSExtValue() : qValue.getZExtValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#ifndef MLIR_DIALECT_VECTOR_VECTORREWRITEPATTERNS_H
|
||||
#define MLIR_DIALECT_VECTOR_VECTORREWRITEPATTERNS_H
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "mlir/Dialect/Vector/VectorOps.h"
|
||||
#include "mlir/Dialect/Vector/VectorUtils.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
@@ -101,7 +103,7 @@ struct UnrollVectorOptions {
|
||||
/// attempted on the operation.
|
||||
FilterConstraintFnType filterConstraint = nullptr;
|
||||
UnrollVectorOptions &setFilterConstraint(FilterConstraintFnType constraint) {
|
||||
filterConstraint = constraint;
|
||||
filterConstraint = std::move(constraint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -111,7 +113,7 @@ struct UnrollVectorOptions {
|
||||
/// operation. The unrolling is aborted if the function returns `llvm::None`.
|
||||
NativeShapeFnType nativeShape = nullptr;
|
||||
UnrollVectorOptions &setNativeShapeFn(NativeShapeFnType fn) {
|
||||
nativeShape = fn;
|
||||
nativeShape = std::move(fn);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -321,7 +323,7 @@ struct VectorTransferFullPartialRewriter : public RewritePattern {
|
||||
[](VectorTransferOpInterface op) { return success(); },
|
||||
PatternBenefit benefit = 1)
|
||||
: RewritePattern(MatchAnyOpTypeTag(), benefit, context), options(options),
|
||||
filter(filter) {}
|
||||
filter(std::move(filter)) {}
|
||||
|
||||
/// Performs the rewrite.
|
||||
LogicalResult matchAndRewrite(Operation *op,
|
||||
@@ -360,7 +362,8 @@ public:
|
||||
vector::VectorTransformsOptions vectorTransformOptions,
|
||||
MLIRContext *context, FilterConstraintType constraint = defaultFilter)
|
||||
: OpRewritePattern<vector::ContractionOp>(context),
|
||||
vectorTransformOptions(vectorTransformOptions), filter(constraint) {}
|
||||
vectorTransformOptions(vectorTransformOptions),
|
||||
filter(std::move(constraint)) {}
|
||||
|
||||
LogicalResult matchAndRewrite(vector::ContractionOp op,
|
||||
PatternRewriter &rewriter) const override;
|
||||
@@ -401,7 +404,8 @@ public:
|
||||
vector::VectorTransformsOptions vectorTransformOptions,
|
||||
MLIRContext *context, FilterConstraintType constraint = defaultFilter)
|
||||
: OpRewritePattern<vector::ContractionOp>(context),
|
||||
vectorTransformOptions(vectorTransformOptions), filter(constraint) {}
|
||||
vectorTransformOptions(vectorTransformOptions),
|
||||
filter(std::move(constraint)) {}
|
||||
|
||||
LogicalResult matchAndRewrite(vector::ContractionOp op,
|
||||
PatternRewriter &rewriter) const override;
|
||||
@@ -443,7 +447,8 @@ public:
|
||||
|
||||
ContractionOpToDotLowering(
|
||||
vector::VectorTransformsOptions vectorTransformOptions,
|
||||
MLIRContext *context, FilterConstraintType constraint = defaultFilter)
|
||||
MLIRContext *context,
|
||||
const FilterConstraintType &constraint = defaultFilter)
|
||||
: OpRewritePattern<vector::ContractionOp>(context),
|
||||
vectorTransformOptions(vectorTransformOptions), filter(defaultFilter) {}
|
||||
|
||||
@@ -484,7 +489,8 @@ public:
|
||||
MLIRContext *context,
|
||||
FilterConstraintType constraint = defaultFilter)
|
||||
: OpRewritePattern<vector::ContractionOp>(context),
|
||||
vectorTransformOptions(vectorTransformOptions), filter(constraint) {}
|
||||
vectorTransformOptions(vectorTransformOptions),
|
||||
filter(std::move(constraint)) {}
|
||||
|
||||
LogicalResult matchAndRewrite(vector::ContractionOp op,
|
||||
PatternRewriter &rewriter) const override;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "mlir/Pass/PassOptions.h"
|
||||
#include "mlir/Support/TypeID.h"
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
namespace mlir {
|
||||
class OpPassManager;
|
||||
@@ -76,7 +77,7 @@ protected:
|
||||
std::function<void(function_ref<void(const detail::PassOptions &)>)>
|
||||
optHandler)
|
||||
: arg(arg), description(description), builder(builder),
|
||||
optHandler(optHandler) {}
|
||||
optHandler(std::move(optHandler)) {}
|
||||
|
||||
private:
|
||||
/// The argument with which to invoke the pass via mlir-opt.
|
||||
@@ -100,7 +101,7 @@ public:
|
||||
StringRef arg, StringRef description, const PassRegistryFunction &builder,
|
||||
std::function<void(function_ref<void(const detail::PassOptions &)>)>
|
||||
optHandler)
|
||||
: PassRegistryEntry(arg, description, builder, optHandler) {}
|
||||
: PassRegistryEntry(arg, description, builder, std::move(optHandler)) {}
|
||||
};
|
||||
|
||||
/// A structure to represent the information for a derived pass class.
|
||||
@@ -182,8 +183,9 @@ struct PassPipelineRegistration {
|
||||
/// Convenience specialization of PassPipelineRegistration for EmptyPassOptions
|
||||
/// that does not pass an empty options struct to the pass builder function.
|
||||
template <> struct PassPipelineRegistration<EmptyPipelineOptions> {
|
||||
PassPipelineRegistration(StringRef arg, StringRef description,
|
||||
std::function<void(OpPassManager &)> builder) {
|
||||
PassPipelineRegistration(
|
||||
StringRef arg, StringRef description,
|
||||
const std::function<void(OpPassManager &)> &builder) {
|
||||
registerPassPipeline(
|
||||
arg, description,
|
||||
[builder](OpPassManager &pm, StringRef optionsStr,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "mlir/Support/LLVM.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
namespace llvm {
|
||||
class RecordKeeper;
|
||||
@@ -30,7 +31,7 @@ public:
|
||||
/// GenInfo constructor should not be invoked directly, instead use
|
||||
/// GenRegistration or registerGen.
|
||||
GenInfo(StringRef arg, StringRef description, GenFunction generator)
|
||||
: arg(arg), description(description), generator(generator) {}
|
||||
: arg(arg), description(description), generator(std::move(generator)) {}
|
||||
|
||||
/// Invokes the generator and returns whether the generator failed.
|
||||
bool invoke(const llvm::RecordKeeper &recordKeeper, raw_ostream &os) const {
|
||||
|
||||
@@ -774,7 +774,7 @@ public:
|
||||
/// Register the operations of the given dialects as dynamically legal, i.e.
|
||||
/// requiring custom handling by the callback.
|
||||
template <typename... Names>
|
||||
void addDynamicallyLegalDialect(DynamicLegalityCallbackFn callback,
|
||||
void addDynamicallyLegalDialect(const DynamicLegalityCallbackFn &callback,
|
||||
StringRef name, Names... names) {
|
||||
SmallVector<StringRef, 2> dialectNames({name, names...});
|
||||
setDialectAction(dialectNames, LegalizationAction::Dynamic);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#ifndef MLIR_BINDINGS_PYTHON_IRMODULES_H
|
||||
#define MLIR_BINDINGS_PYTHON_IRMODULES_H
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "PybindUtils.h"
|
||||
@@ -330,8 +331,9 @@ public:
|
||||
void detach();
|
||||
|
||||
pybind11::object contextEnter() { return pybind11::cast(this); }
|
||||
void contextExit(pybind11::object excType, pybind11::object excVal,
|
||||
pybind11::object excTb) {
|
||||
void contextExit(const pybind11::object &excType,
|
||||
const pybind11::object &excVal,
|
||||
const pybind11::object &excTb) {
|
||||
detach();
|
||||
}
|
||||
|
||||
@@ -532,7 +534,7 @@ public:
|
||||
}
|
||||
|
||||
bool isAttached() { return attached; }
|
||||
void setAttached(pybind11::object parent = pybind11::object()) {
|
||||
void setAttached(const pybind11::object &parent = pybind11::object()) {
|
||||
assert(!attached && "operation already attached");
|
||||
attached = true;
|
||||
}
|
||||
@@ -876,7 +878,7 @@ public:
|
||||
class PyValue {
|
||||
public:
|
||||
PyValue(PyOperationRef parentOperation, MlirValue value)
|
||||
: parentOperation(parentOperation), value(value) {}
|
||||
: parentOperation(std::move(parentOperation)), value(value) {}
|
||||
operator MlirValue() const { return value; }
|
||||
|
||||
MlirValue get() { return value; }
|
||||
|
||||
@@ -133,7 +133,7 @@ struct PyPrintAccumulator {
|
||||
/// or binary.
|
||||
class PyFileAccumulator {
|
||||
public:
|
||||
PyFileAccumulator(pybind11::object fileObject, bool binary)
|
||||
PyFileAccumulator(const pybind11::object &fileObject, bool binary)
|
||||
: pyWriteFunction(fileObject.attr("write")), binary(binary) {}
|
||||
|
||||
void *getUserData() { return this; }
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <bitset>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace mlir {
|
||||
@@ -566,7 +567,7 @@ bool fromJSON(const llvm::json::Value &value, DocumentSymbolParams &result,
|
||||
/// diagnostics, e.g. when duplicating a symbol in a scope.
|
||||
struct DiagnosticRelatedInformation {
|
||||
DiagnosticRelatedInformation(Location location, std::string message)
|
||||
: location(location), message(std::move(message)) {}
|
||||
: location(std::move(location)), message(std::move(message)) {}
|
||||
|
||||
/// The location of this related diagnostic information.
|
||||
Location location;
|
||||
@@ -626,7 +627,7 @@ llvm::json::Value toJSON(const Diagnostic &diag);
|
||||
|
||||
struct PublishDiagnosticsParams {
|
||||
PublishDiagnosticsParams(URIForFile uri, int64_t version)
|
||||
: uri(uri), version(version) {}
|
||||
: uri(std::move(uri)), version(version) {}
|
||||
|
||||
/// The URI for which diagnostic information is reported.
|
||||
URIForFile uri;
|
||||
|
||||
Reference in New Issue
Block a user