@@ -47,14 +47,15 @@ static void printModuleBody(mlir::ModuleOp mod, raw_ostream &output) {
47
47
}
48
48
49
49
// compile a .fir file
50
- static int compileFIR () {
50
+ static mlir::LogicalResult
51
+ compileFIR (const mlir::PassPipelineCLParser &passPipeline) {
51
52
// check that there is a file to load
52
53
ErrorOr<std::unique_ptr<MemoryBuffer>> fileOrErr =
53
54
MemoryBuffer::getFileOrSTDIN (inputFilename);
54
55
55
56
if (std::error_code EC = fileOrErr.getError ()) {
56
57
errs () << " Could not open file: " << EC.message () << ' \n ' ;
57
- return 1 ;
58
+ return mlir::failure () ;
58
59
}
59
60
60
61
// load the file into a module
@@ -66,11 +67,11 @@ static int compileFIR() {
66
67
67
68
if (!owningRef) {
68
69
errs () << " Error can't load file " << inputFilename << ' \n ' ;
69
- return 2 ;
70
+ return mlir::failure () ;
70
71
}
71
72
if (mlir::failed (owningRef->verify ())) {
72
73
errs () << " Error verifying FIR module\n " ;
73
- return 4 ;
74
+ return mlir::failure () ;
74
75
}
75
76
76
77
std::error_code ec;
@@ -94,13 +95,13 @@ static int compileFIR() {
94
95
if (emitFir)
95
96
printModuleBody (*owningRef, out.os ());
96
97
out.keep ();
97
- return 0 ;
98
+ return mlir::success () ;
98
99
}
99
100
100
101
// pass manager failed
101
102
printModuleBody (*owningRef, errs ());
102
103
errs () << " \n\n FAILED: " << inputFilename << ' \n ' ;
103
- return 8 ;
104
+ return mlir::failure () ;
104
105
}
105
106
106
107
int main (int argc, char **argv) {
@@ -109,5 +110,5 @@ int main(int argc, char **argv) {
109
110
mlir::registerPassManagerCLOptions ();
110
111
mlir::PassPipelineCLParser passPipe (" " , " Compiler passes to run" );
111
112
cl::ParseCommandLineOptions (argc, argv, " Tilikum Crossing Optimizer\n " );
112
- return compileFIR ();
113
+ return mlir::failed ( compileFIR (passPipe) );
113
114
}
0 commit comments