forked from OSchip/llvm-project
Add SourceMgrDiagnosticHandler to toy
PiperOrigin-RevId: 275659433
This commit is contained in:
parent
305dafd3b1
commit
8317bd85e5
|
|
@ -79,7 +79,8 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
|||
return parser.ParseModule();
|
||||
}
|
||||
|
||||
int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
|
||||
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
mlir::OwningModuleRef &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
|
|
@ -97,7 +98,6 @@ int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
|
|||
}
|
||||
|
||||
// Parse the input mlir.
|
||||
llvm::SourceMgr sourceMgr;
|
||||
sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
|
||||
module = mlir::parseSourceFile(sourceMgr, &context);
|
||||
if (!module) {
|
||||
|
|
@ -113,7 +113,9 @@ int dumpMLIR() {
|
|||
|
||||
mlir::MLIRContext context;
|
||||
mlir::OwningModuleRef module;
|
||||
if (int error = loadMLIR(context, module))
|
||||
llvm::SourceMgr sourceMgr;
|
||||
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
|
||||
if (int error = loadMLIR(sourceMgr, context, module))
|
||||
return error;
|
||||
|
||||
if (EnableOpt) {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,8 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
|||
return parser.ParseModule();
|
||||
}
|
||||
|
||||
int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
|
||||
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
mlir::OwningModuleRef &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
|
|
@ -98,7 +99,6 @@ int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
|
|||
}
|
||||
|
||||
// Parse the input mlir.
|
||||
llvm::SourceMgr sourceMgr;
|
||||
sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
|
||||
module = mlir::parseSourceFile(sourceMgr, &context);
|
||||
if (!module) {
|
||||
|
|
@ -114,7 +114,9 @@ int dumpMLIR() {
|
|||
|
||||
mlir::MLIRContext context;
|
||||
mlir::OwningModuleRef module;
|
||||
if (int error = loadMLIR(context, module))
|
||||
llvm::SourceMgr sourceMgr;
|
||||
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
|
||||
if (int error = loadMLIR(sourceMgr, context, module))
|
||||
return error;
|
||||
|
||||
if (EnableOpt) {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
|
|||
return parser.ParseModule();
|
||||
}
|
||||
|
||||
int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
|
||||
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
||||
mlir::OwningModuleRef &module) {
|
||||
// Handle '.toy' input to the compiler.
|
||||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
|
|
@ -100,7 +101,6 @@ int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
|
|||
}
|
||||
|
||||
// Parse the input mlir.
|
||||
llvm::SourceMgr sourceMgr;
|
||||
sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
|
||||
module = mlir::parseSourceFile(sourceMgr, &context);
|
||||
if (!module) {
|
||||
|
|
@ -116,7 +116,9 @@ int dumpMLIR() {
|
|||
|
||||
mlir::MLIRContext context;
|
||||
mlir::OwningModuleRef module;
|
||||
if (int error = loadMLIR(context, module))
|
||||
llvm::SourceMgr sourceMgr;
|
||||
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
|
||||
if (int error = loadMLIR(sourceMgr, context, module))
|
||||
return error;
|
||||
|
||||
mlir::PassManager pm(&context);
|
||||
|
|
|
|||
Loading…
Reference in New Issue