| OLD | NEW |
| 1 //===- subzero/src/llvm2ice.cpp - Driver for testing ----------------------===// | 1 //===- subzero/src/llvm2ice.cpp - Driver for testing ----------------------===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This file defines a driver that uses LLVM capabilities to parse a | 10 // This file defines a driver that uses LLVM capabilities to parse a |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 cl::values( | 52 cl::values( |
| 53 clEnumValN(Ice::Target_X8632, "x8632", "x86-32"), | 53 clEnumValN(Ice::Target_X8632, "x8632", "x86-32"), |
| 54 clEnumValN(Ice::Target_X8632, "x86-32", "x86-32 (same as x8632)"), | 54 clEnumValN(Ice::Target_X8632, "x86-32", "x86-32 (same as x8632)"), |
| 55 clEnumValN(Ice::Target_X8632, "x86_32", "x86-32 (same as x8632)"), | 55 clEnumValN(Ice::Target_X8632, "x86_32", "x86-32 (same as x8632)"), |
| 56 clEnumValN(Ice::Target_X8664, "x8664", "x86-64"), | 56 clEnumValN(Ice::Target_X8664, "x8664", "x86-64"), |
| 57 clEnumValN(Ice::Target_X8664, "x86-64", "x86-64 (same as x8664)"), | 57 clEnumValN(Ice::Target_X8664, "x86-64", "x86-64 (same as x8664)"), |
| 58 clEnumValN(Ice::Target_X8664, "x86_64", "x86-64 (same as x8664)"), | 58 clEnumValN(Ice::Target_X8664, "x86_64", "x86-64 (same as x8664)"), |
| 59 clEnumValN(Ice::Target_ARM32, "arm", "arm32"), | 59 clEnumValN(Ice::Target_ARM32, "arm", "arm32"), |
| 60 clEnumValN(Ice::Target_ARM32, "arm32", "arm32 (same as arm)"), | 60 clEnumValN(Ice::Target_ARM32, "arm32", "arm32 (same as arm)"), |
| 61 clEnumValN(Ice::Target_ARM64, "arm64", "arm64"), clEnumValEnd)); | 61 clEnumValN(Ice::Target_ARM64, "arm64", "arm64"), clEnumValEnd)); |
| 62 static cl::opt<bool> |
| 63 FunctionSections("ffunction-sections", |
| 64 cl::desc("Emit functions into separate sections")); |
| 62 static cl::opt<Ice::OptLevel> | 65 static cl::opt<Ice::OptLevel> |
| 63 OptLevel(cl::desc("Optimization level"), cl::init(Ice::Opt_m1), | 66 OptLevel(cl::desc("Optimization level"), cl::init(Ice::Opt_m1), |
| 64 cl::value_desc("level"), | 67 cl::value_desc("level"), |
| 65 cl::values(clEnumValN(Ice::Opt_m1, "Om1", "-1"), | 68 cl::values(clEnumValN(Ice::Opt_m1, "Om1", "-1"), |
| 66 clEnumValN(Ice::Opt_m1, "O-1", "-1"), | 69 clEnumValN(Ice::Opt_m1, "O-1", "-1"), |
| 67 clEnumValN(Ice::Opt_0, "O0", "0"), | 70 clEnumValN(Ice::Opt_0, "O0", "0"), |
| 68 clEnumValN(Ice::Opt_1, "O1", "1"), | 71 clEnumValN(Ice::Opt_1, "O1", "1"), |
| 69 clEnumValN(Ice::Opt_2, "O2", "2"), clEnumValEnd)); | 72 clEnumValN(Ice::Opt_2, "O2", "2"), clEnumValEnd)); |
| 70 static cl::opt<std::string> IRFilename(cl::Positional, cl::desc("<IR file>"), | 73 static cl::opt<std::string> IRFilename(cl::Positional, cl::desc("<IR file>"), |
| 71 cl::init("-")); | 74 cl::init("-")); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 raw_os_ostream *Os = | 122 raw_os_ostream *Os = |
| 120 new raw_os_ostream(OutputFilename == "-" ? std::cout : Ofs); | 123 new raw_os_ostream(OutputFilename == "-" ? std::cout : Ofs); |
| 121 Os->SetUnbuffered(); | 124 Os->SetUnbuffered(); |
| 122 std::ofstream Lfs; | 125 std::ofstream Lfs; |
| 123 if (LogFilename != "-") { | 126 if (LogFilename != "-") { |
| 124 Lfs.open(LogFilename.c_str(), std::ofstream::out); | 127 Lfs.open(LogFilename.c_str(), std::ofstream::out); |
| 125 } | 128 } |
| 126 raw_os_ostream *Ls = new raw_os_ostream(LogFilename == "-" ? std::cout : Lfs); | 129 raw_os_ostream *Ls = new raw_os_ostream(LogFilename == "-" ? std::cout : Lfs); |
| 127 Ls->SetUnbuffered(); | 130 Ls->SetUnbuffered(); |
| 128 | 131 |
| 129 Ice::GlobalContext Ctx(Ls, Os, VMask, TargetArch, OptLevel, TestPrefix); | |
| 130 | |
| 131 Ice::ClFlags Flags; | 132 Ice::ClFlags Flags; |
| 132 Flags.DisableInternal = DisableInternal; | 133 Flags.DisableInternal = DisableInternal; |
| 133 Flags.SubzeroTimingEnabled = SubzeroTimingEnabled; | 134 Flags.SubzeroTimingEnabled = SubzeroTimingEnabled; |
| 134 Flags.DisableTranslation = DisableTranslation; | 135 Flags.DisableTranslation = DisableTranslation; |
| 135 Flags.DisableGlobals = DisableGlobals; | 136 Flags.DisableGlobals = DisableGlobals; |
| 137 Flags.FunctionSections = FunctionSections; |
| 138 |
| 139 Ice::GlobalContext Ctx(Ls, Os, VMask, TargetArch, OptLevel, TestPrefix, |
| 140 Flags); |
| 136 | 141 |
| 137 if (BuildOnRead) { | 142 if (BuildOnRead) { |
| 138 Ice::PNaClTranslator Translator(&Ctx, Flags); | 143 Ice::PNaClTranslator Translator(&Ctx); |
| 139 Translator.translate(IRFilename); | 144 Translator.translate(IRFilename); |
| 140 return Translator.getErrorStatus(); | 145 return Translator.getErrorStatus(); |
| 141 } else { | 146 } else { |
| 142 // Parse the input LLVM IR file into a module. | 147 // Parse the input LLVM IR file into a module. |
| 143 SMDiagnostic Err; | 148 SMDiagnostic Err; |
| 144 Ice::Timer T; | 149 Ice::Timer T; |
| 145 Module *Mod = | 150 Module *Mod = |
| 146 NaClParseIRFile(IRFilename, InputFileFormat, Err, getGlobalContext()); | 151 NaClParseIRFile(IRFilename, InputFileFormat, Err, getGlobalContext()); |
| 147 | 152 |
| 148 if (SubzeroTimingEnabled) { | 153 if (SubzeroTimingEnabled) { |
| 149 std::cerr << "[Subzero timing] IR Parsing: " << T.getElapsedSec() | 154 std::cerr << "[Subzero timing] IR Parsing: " << T.getElapsedSec() |
| 150 << " sec\n"; | 155 << " sec\n"; |
| 151 } | 156 } |
| 152 | 157 |
| 153 if (!Mod) { | 158 if (!Mod) { |
| 154 Err.print(argv[0], errs()); | 159 Err.print(argv[0], errs()); |
| 155 return 1; | 160 return 1; |
| 156 } | 161 } |
| 157 | 162 |
| 158 Ice::Converter Converter(&Ctx, Flags); | 163 Ice::Converter Converter(&Ctx); |
| 159 Converter.convertToIce(Mod); | 164 Converter.convertToIce(Mod); |
| 160 return Converter.getErrorStatus(); | 165 return Converter.getErrorStatus(); |
| 161 } | 166 } |
| 162 } | 167 } |
| OLD | NEW |