[MLIR] Apply clang-tidy fixes for misc-use-internal-linkage in toy Tutorial (NFC)
This commit is contained in:
parent
d2dee948a4
commit
a8aacb1b66
@ -120,7 +120,7 @@ void ASTDumper::dump(NumberExprAST *num) {
|
||||
/// [ [ 1, 2 ], [ 3, 4 ] ]
|
||||
/// We print out such array with the dimensions spelled out at every level:
|
||||
/// <2,2>[<2>[ 1, 2 ], <2>[ 3, 4 ] ]
|
||||
void printLitHelper(ExprAST *litOrNum) {
|
||||
static void printLitHelper(ExprAST *litOrNum) {
|
||||
// Inside a literal expression we can have either a number or another literal
|
||||
if (auto *num = llvm::dyn_cast<NumberExprAST>(litOrNum)) {
|
||||
llvm::errs() << num->getValue();
|
||||
|
@ -39,7 +39,8 @@ static cl::opt<enum Action>
|
||||
cl::values(clEnumValN(DumpAST, "ast", "output the AST dump")));
|
||||
|
||||
/// Returns a Toy AST resulting from parsing the file or a nullptr on error.
|
||||
std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
static std::unique_ptr<toy::ModuleAST>
|
||||
parseInputFile(llvm::StringRef filename) {
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileOrErr =
|
||||
llvm::MemoryBuffer::getFileOrSTDIN(filename);
|
||||
if (std::error_code ec = fileOrErr.getError()) {
|
||||
|
@ -120,7 +120,7 @@ void ASTDumper::dump(NumberExprAST *num) {
|
||||
/// [ [ 1, 2 ], [ 3, 4 ] ]
|
||||
/// We print out such array with the dimensions spelled out at every level:
|
||||
/// <2,2>[<2>[ 1, 2 ], <2>[ 3, 4 ] ]
|
||||
void printLitHelper(ExprAST *litOrNum) {
|
||||
static void printLitHelper(ExprAST *litOrNum) {
|
||||
// Inside a literal expression we can have either a number or another literal
|
||||
if (auto *num = llvm::dyn_cast<NumberExprAST>(litOrNum)) {
|
||||
llvm::errs() << num->getValue();
|
||||
|
@ -58,7 +58,8 @@ static cl::opt<enum Action> emitAction(
|
||||
cl::values(clEnumValN(DumpMLIR, "mlir", "output the MLIR dump")));
|
||||
|
||||
/// Returns a Toy AST resulting from parsing the file or a nullptr on error.
|
||||
std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
static std::unique_ptr<toy::ModuleAST>
|
||||
parseInputFile(llvm::StringRef filename) {
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileOrErr =
|
||||
llvm::MemoryBuffer::getFileOrSTDIN(filename);
|
||||
if (std::error_code ec = fileOrErr.getError()) {
|
||||
@ -71,7 +72,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
return parser.parseModule();
|
||||
}
|
||||
|
||||
int dumpMLIR() {
|
||||
static int dumpMLIR() {
|
||||
mlir::MLIRContext context;
|
||||
// Load our Dialect in this MLIR Context.
|
||||
context.getOrLoadDialect<mlir::toy::ToyDialect>();
|
||||
@ -112,7 +113,7 @@ int dumpMLIR() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dumpAST() {
|
||||
static int dumpAST() {
|
||||
if (inputType == InputType::MLIR) {
|
||||
llvm::errs() << "Can't dump a Toy AST when the input is MLIR\n";
|
||||
return 5;
|
||||
|
@ -120,7 +120,7 @@ void ASTDumper::dump(NumberExprAST *num) {
|
||||
/// [ [ 1, 2 ], [ 3, 4 ] ]
|
||||
/// We print out such array with the dimensions spelled out at every level:
|
||||
/// <2,2>[<2>[ 1, 2 ], <2>[ 3, 4 ] ]
|
||||
void printLitHelper(ExprAST *litOrNum) {
|
||||
static void printLitHelper(ExprAST *litOrNum) {
|
||||
// Inside a literal expression we can have either a number or another literal
|
||||
if (auto *num = llvm::dyn_cast<NumberExprAST>(litOrNum)) {
|
||||
llvm::errs() << num->getValue();
|
||||
|
@ -64,7 +64,8 @@ static cl::opt<enum Action> emitAction(
|
||||
static cl::opt<bool> enableOpt("opt", cl::desc("Enable optimizations"));
|
||||
|
||||
/// Returns a Toy AST resulting from parsing the file or a nullptr on error.
|
||||
std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
static std::unique_ptr<toy::ModuleAST>
|
||||
parseInputFile(llvm::StringRef filename) {
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileOrErr =
|
||||
llvm::MemoryBuffer::getFileOrSTDIN(filename);
|
||||
if (std::error_code ec = fileOrErr.getError()) {
|
||||
@ -77,7 +78,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
return parser.parseModule();
|
||||
}
|
||||
|
||||
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
static int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
@ -107,7 +108,7 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dumpMLIR() {
|
||||
static int dumpMLIR() {
|
||||
mlir::MLIRContext context;
|
||||
// Load our Dialect in this MLIR Context.
|
||||
context.getOrLoadDialect<mlir::toy::ToyDialect>();
|
||||
@ -134,7 +135,7 @@ int dumpMLIR() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dumpAST() {
|
||||
static int dumpAST() {
|
||||
if (inputType == InputType::MLIR) {
|
||||
llvm::errs() << "Can't dump a Toy AST when the input is MLIR\n";
|
||||
return 5;
|
||||
|
@ -120,7 +120,7 @@ void ASTDumper::dump(NumberExprAST *num) {
|
||||
/// [ [ 1, 2 ], [ 3, 4 ] ]
|
||||
/// We print out such array with the dimensions spelled out at every level:
|
||||
/// <2,2>[<2>[ 1, 2 ], <2>[ 3, 4 ] ]
|
||||
void printLitHelper(ExprAST *litOrNum) {
|
||||
static void printLitHelper(ExprAST *litOrNum) {
|
||||
// Inside a literal expression we can have either a number or another literal
|
||||
if (auto *num = llvm::dyn_cast<NumberExprAST>(litOrNum)) {
|
||||
llvm::errs() << num->getValue();
|
||||
|
@ -65,7 +65,8 @@ static cl::opt<enum Action> emitAction(
|
||||
static cl::opt<bool> enableOpt("opt", cl::desc("Enable optimizations"));
|
||||
|
||||
/// Returns a Toy AST resulting from parsing the file or a nullptr on error.
|
||||
std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
static std::unique_ptr<toy::ModuleAST>
|
||||
parseInputFile(llvm::StringRef filename) {
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileOrErr =
|
||||
llvm::MemoryBuffer::getFileOrSTDIN(filename);
|
||||
if (std::error_code ec = fileOrErr.getError()) {
|
||||
@ -78,7 +79,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
return parser.parseModule();
|
||||
}
|
||||
|
||||
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
static int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
@ -108,7 +109,7 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dumpMLIR() {
|
||||
static int dumpMLIR() {
|
||||
mlir::MLIRContext context;
|
||||
// Load our Dialect in this MLIR Context.
|
||||
context.getOrLoadDialect<mlir::toy::ToyDialect>();
|
||||
@ -143,7 +144,7 @@ int dumpMLIR() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dumpAST() {
|
||||
static int dumpAST() {
|
||||
if (inputType == InputType::MLIR) {
|
||||
llvm::errs() << "Can't dump a Toy AST when the input is MLIR\n";
|
||||
return 5;
|
||||
|
@ -120,7 +120,7 @@ void ASTDumper::dump(NumberExprAST *num) {
|
||||
/// [ [ 1, 2 ], [ 3, 4 ] ]
|
||||
/// We print out such array with the dimensions spelled out at every level:
|
||||
/// <2,2>[<2>[ 1, 2 ], <2>[ 3, 4 ] ]
|
||||
void printLitHelper(ExprAST *litOrNum) {
|
||||
static void printLitHelper(ExprAST *litOrNum) {
|
||||
// Inside a literal expression we can have either a number or another literal
|
||||
if (auto *num = llvm::dyn_cast<NumberExprAST>(litOrNum)) {
|
||||
llvm::errs() << num->getValue();
|
||||
|
@ -71,7 +71,8 @@ static cl::opt<enum Action> emitAction(
|
||||
static cl::opt<bool> enableOpt("opt", cl::desc("Enable optimizations"));
|
||||
|
||||
/// Returns a Toy AST resulting from parsing the file or a nullptr on error.
|
||||
std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
static std::unique_ptr<toy::ModuleAST>
|
||||
parseInputFile(llvm::StringRef filename) {
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileOrErr =
|
||||
llvm::MemoryBuffer::getFileOrSTDIN(filename);
|
||||
if (std::error_code ec = fileOrErr.getError()) {
|
||||
@ -84,7 +85,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
return parser.parseModule();
|
||||
}
|
||||
|
||||
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
static int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
@ -114,7 +115,7 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dumpMLIR() {
|
||||
static int dumpMLIR() {
|
||||
mlir::DialectRegistry registry;
|
||||
mlir::func::registerAllExtensions(registry);
|
||||
|
||||
@ -171,7 +172,7 @@ int dumpMLIR() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dumpAST() {
|
||||
static int dumpAST() {
|
||||
if (inputType == InputType::MLIR) {
|
||||
llvm::errs() << "Can't dump a Toy AST when the input is MLIR\n";
|
||||
return 5;
|
||||
|
@ -120,7 +120,7 @@ void ASTDumper::dump(NumberExprAST *num) {
|
||||
/// [ [ 1, 2 ], [ 3, 4 ] ]
|
||||
/// We print out such array with the dimensions spelled out at every level:
|
||||
/// <2,2>[<2>[ 1, 2 ], <2>[ 3, 4 ] ]
|
||||
void printLitHelper(ExprAST *litOrNum) {
|
||||
static void printLitHelper(ExprAST *litOrNum) {
|
||||
// Inside a literal expression we can have either a number or another literal
|
||||
if (auto *num = llvm::dyn_cast<NumberExprAST>(litOrNum)) {
|
||||
llvm::errs() << num->getValue();
|
||||
|
@ -96,7 +96,8 @@ static cl::opt<enum Action> emitAction(
|
||||
static cl::opt<bool> enableOpt("opt", cl::desc("Enable optimizations"));
|
||||
|
||||
/// Returns a Toy AST resulting from parsing the file or a nullptr on error.
|
||||
std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
static std::unique_ptr<toy::ModuleAST>
|
||||
parseInputFile(llvm::StringRef filename) {
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileOrErr =
|
||||
llvm::MemoryBuffer::getFileOrSTDIN(filename);
|
||||
if (std::error_code ec = fileOrErr.getError()) {
|
||||
@ -109,7 +110,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
return parser.parseModule();
|
||||
}
|
||||
|
||||
int loadMLIR(mlir::MLIRContext &context,
|
||||
static int loadMLIR(mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
@ -140,7 +141,7 @@ int loadMLIR(mlir::MLIRContext &context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int loadAndProcessMLIR(mlir::MLIRContext &context,
|
||||
static int loadAndProcessMLIR(mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
if (int error = loadMLIR(context, module))
|
||||
return error;
|
||||
@ -196,7 +197,7 @@ int loadAndProcessMLIR(mlir::MLIRContext &context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dumpAST() {
|
||||
static int dumpAST() {
|
||||
if (inputType == InputType::MLIR) {
|
||||
llvm::errs() << "Can't dump a Toy AST when the input is MLIR\n";
|
||||
return 5;
|
||||
@ -210,7 +211,7 @@ int dumpAST() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dumpLLVMIR(mlir::ModuleOp module) {
|
||||
static int dumpLLVMIR(mlir::ModuleOp module) {
|
||||
// Register the translation to LLVM IR with the MLIR context.
|
||||
mlir::registerBuiltinDialectTranslation(*module->getContext());
|
||||
mlir::registerLLVMDialectTranslation(*module->getContext());
|
||||
@ -254,7 +255,7 @@ int dumpLLVMIR(mlir::ModuleOp module) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runJit(mlir::ModuleOp module) {
|
||||
static int runJit(mlir::ModuleOp module) {
|
||||
// Initialize LLVM targets.
|
||||
llvm::InitializeNativeTarget();
|
||||
llvm::InitializeNativeTargetAsmPrinter();
|
||||
|
@ -123,7 +123,7 @@ void ASTDumper::dump(NumberExprAST *num) {
|
||||
/// [ [ 1, 2 ], [ 3, 4 ] ]
|
||||
/// We print out such array with the dimensions spelled out at every level:
|
||||
/// <2,2>[<2>[ 1, 2 ], <2>[ 3, 4 ] ]
|
||||
void printLitHelper(ExprAST *litOrNum) {
|
||||
static void printLitHelper(ExprAST *litOrNum) {
|
||||
// Inside a literal expression we can have either a number or another literal
|
||||
if (auto *num = llvm::dyn_cast<NumberExprAST>(litOrNum)) {
|
||||
llvm::errs() << num->getValue();
|
||||
|
@ -96,7 +96,8 @@ static cl::opt<enum Action> emitAction(
|
||||
static cl::opt<bool> enableOpt("opt", cl::desc("Enable optimizations"));
|
||||
|
||||
/// Returns a Toy AST resulting from parsing the file or a nullptr on error.
|
||||
std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
static std::unique_ptr<toy::ModuleAST>
|
||||
parseInputFile(llvm::StringRef filename) {
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileOrErr =
|
||||
llvm::MemoryBuffer::getFileOrSTDIN(filename);
|
||||
if (std::error_code ec = fileOrErr.getError()) {
|
||||
@ -109,7 +110,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
||||
return parser.parseModule();
|
||||
}
|
||||
|
||||
int loadMLIR(mlir::MLIRContext &context,
|
||||
static int loadMLIR(mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
@ -140,7 +141,7 @@ int loadMLIR(mlir::MLIRContext &context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int loadAndProcessMLIR(mlir::MLIRContext &context,
|
||||
static int loadAndProcessMLIR(mlir::MLIRContext &context,
|
||||
mlir::OwningOpRef<mlir::ModuleOp> &module) {
|
||||
if (int error = loadMLIR(context, module))
|
||||
return error;
|
||||
@ -197,7 +198,7 @@ int loadAndProcessMLIR(mlir::MLIRContext &context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dumpAST() {
|
||||
static int dumpAST() {
|
||||
if (inputType == InputType::MLIR) {
|
||||
llvm::errs() << "Can't dump a Toy AST when the input is MLIR\n";
|
||||
return 5;
|
||||
@ -211,7 +212,7 @@ int dumpAST() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dumpLLVMIR(mlir::ModuleOp module) {
|
||||
static int dumpLLVMIR(mlir::ModuleOp module) {
|
||||
// Register the translation to LLVM IR with the MLIR context.
|
||||
mlir::registerBuiltinDialectTranslation(*module->getContext());
|
||||
mlir::registerLLVMDialectTranslation(*module->getContext());
|
||||
@ -255,7 +256,7 @@ int dumpLLVMIR(mlir::ModuleOp module) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runJit(mlir::ModuleOp module) {
|
||||
static int runJit(mlir::ModuleOp module) {
|
||||
// Initialize LLVM targets.
|
||||
llvm::InitializeNativeTarget();
|
||||
llvm::InitializeNativeTargetAsmPrinter();
|
||||
|
Loading…
x
Reference in New Issue
Block a user