Chromium Code Reviews| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 cl::desc("Use integrated assembler (default yes)"), | 154 cl::desc("Use integrated assembler (default yes)"), |
| 155 cl::init(true)); | 155 cl::init(true)); |
| 156 | 156 |
| 157 static cl::alias UseIas("ias", cl::desc("Alias for -integrated-as"), | 157 static cl::alias UseIas("ias", cl::desc("Alias for -integrated-as"), |
| 158 cl::NotHidden, cl::aliasopt(UseIntegratedAssembler)); | 158 cl::NotHidden, cl::aliasopt(UseIntegratedAssembler)); |
| 159 | 159 |
| 160 static cl::opt<bool> AlwaysExitSuccess( | 160 static cl::opt<bool> AlwaysExitSuccess( |
| 161 "exit-success", cl::desc("Exit with success status, even if errors found"), | 161 "exit-success", cl::desc("Exit with success status, even if errors found"), |
| 162 cl::init(false)); | 162 cl::init(false)); |
| 163 | 163 |
| 164 static cl::opt<bool> GenerateBuildAtts( | |
| 165 "build-atts", cl::desc("Generate list of build attributes associated with " | |
| 166 "this executable."), | |
| 167 cl::init(false)); | |
| 168 | |
| 164 static int GetReturnValue(int Val) { | 169 static int GetReturnValue(int Val) { |
| 165 if (AlwaysExitSuccess) | 170 if (AlwaysExitSuccess) |
| 166 return 0; | 171 return 0; |
| 167 return Val; | 172 return Val; |
| 168 } | 173 } |
| 169 | 174 |
| 175 static bool GenerateBuildAttributes(raw_os_ostream &Stream) { | |
| 176 if (!GenerateBuildAtts) | |
| 177 return false; | |
| 178 | |
| 179 // TODO(kschimpf): Conditionalize this once we have multiple targets. | |
| 180 Stream << "x86-32\n"; | |
| 181 | |
| 182 #if defined NO_TEXT_ASM && !defined ALLOW_TEXT_ASM | |
| 183 Stream << "no_text_asm\n"; | |
| 184 #elif !defined NO_DUMP && defined ALLOW_TEXT_ASM | |
|
jvoung (off chromium)
2014/10/21 19:12:00
NO_TEXT_ASM instead of NO_DUMP?
Maybe there can b
Karl
2014/10/21 21:14:18
After simplifying the define flags (see Makefile.s
| |
| 185 Stream << "allow_text_asm\n"; | |
| 186 #elif defined NO_TEXT_ASM | |
| 187 #error Can't define both NO_TEXT_ASM and ALLOW_TEXT_ASM | |
| 188 #else | |
| 189 #error Must define either NO_TEXT_ASM or ALLOW_TEXT_ASM | |
| 190 #endif | |
| 191 | |
| 192 #if defined NO_DUMP && !defined ALLOW_DUMP | |
| 193 Stream << "no_dump\n"; | |
| 194 #elif !defined NO_DUMP && defined ALLOW_DUMP | |
| 195 Stream << "allow_dump\n"; | |
| 196 #elif defined DO_DUMP | |
|
jvoung (off chromium)
2014/10/21 19:12:00
DO_DUMP -> NO_DUMP?
Karl
2014/10/21 21:14:18
Done.
| |
| 197 #error Can't define both NO_DUMP and ALLOW_DUMP | |
| 198 #else | |
| 199 #error Must define either NO_DUMP or ALLOW_DUMP | |
| 200 #endif | |
| 201 | |
| 202 #if defined NO_LLVM_CL && !defined ALLOW_LLVM_CL | |
| 203 Stream << "no_llvm_cl\n"; | |
| 204 #elif !defined NO_LLVM_CL && defined ALLOW_LLVM_CL | |
| 205 Stream << "allow_llvm_cl\n"; | |
| 206 #elif defined NO_LLVM_CL | |
| 207 #error Can't define both NO_LLVM_CL and ALLOW_LLVM_CL | |
| 208 #else | |
| 209 #error Must define either NO_LLVM_CL or ALLOW_LLVM_CL | |
| 210 #endif | |
| 211 | |
| 212 #if defined NO_LLVM_IR && !defined ALLOW_LLVM_IR | |
| 213 Stream << "no_llvm_ir\n"; | |
| 214 #elif !defined NO_LLMV_IR && defined ALLOW_LLVM_IR | |
| 215 Stream << "allow_llvm_ir\n"; | |
| 216 #elif defined NO_LLVM_IR | |
| 217 #error Can't define both NO_LLVM_IR and ALLOW_LLVM_IR | |
| 218 #else | |
| 219 #error Must define either NO_LLVM_IR or ALLOW_LLVM_IR | |
| 220 #endif | |
| 221 | |
| 222 | |
| 223 #if defined NO_LLVM_IR_AS_INPUT && !defined ALLOW_LLVM_IR_AS_INPUT | |
| 224 Stream << "no_llvm_ir_as_input\n"; | |
| 225 #elif !defined NO_LLMV_IR_AS_INPUT && defined ALLOW_LLVM_IR_AS_INPUT | |
| 226 Stream << "allow_llvm_ir_as_input\n"; | |
| 227 #elif defined NO_LLVM_IR_AS_INPUT | |
| 228 #error Can't define both NO_LLVM_IR_AS_INPUT and ALLOW_LLVM_IR_AS_INPUT | |
| 229 #else | |
| 230 #error Must define either NO_LLVM_IR_AS_INPUT or ALLOW_LLVM_IR_AS_INPUT | |
| 231 #endif | |
| 232 | |
| 233 return true; | |
| 234 } | |
| 235 | |
| 170 int main(int argc, char **argv) { | 236 int main(int argc, char **argv) { |
| 171 | 237 |
| 172 cl::ParseCommandLineOptions(argc, argv); | 238 cl::ParseCommandLineOptions(argc, argv); |
| 173 | 239 |
| 174 Ice::VerboseMask VMask = Ice::IceV_None; | 240 Ice::VerboseMask VMask = Ice::IceV_None; |
| 175 for (unsigned i = 0; i != VerboseList.size(); ++i) | 241 for (unsigned i = 0; i != VerboseList.size(); ++i) |
| 176 VMask |= VerboseList[i]; | 242 VMask |= VerboseList[i]; |
| 177 | 243 |
| 178 std::ofstream Ofs; | 244 std::ofstream Ofs; |
| 179 if (OutputFilename != "-") { | 245 if (OutputFilename != "-") { |
| 180 Ofs.open(OutputFilename.c_str(), std::ofstream::out); | 246 Ofs.open(OutputFilename.c_str(), std::ofstream::out); |
| 181 } | 247 } |
| 182 raw_os_ostream *Os = | 248 raw_os_ostream *Os = |
| 183 new raw_os_ostream(OutputFilename == "-" ? std::cout : Ofs); | 249 new raw_os_ostream(OutputFilename == "-" ? std::cout : Ofs); |
| 184 Os->SetUnbuffered(); | 250 Os->SetUnbuffered(); |
| 251 | |
| 252 | |
|
jvoung (off chromium)
2014/10/21 19:12:00
could squash it to one newline instead of two
Karl
2014/10/21 21:14:18
Done.
| |
| 253 if (GenerateBuildAttributes(*Os)) | |
| 254 return GetReturnValue(0); | |
| 255 | |
| 185 std::ofstream Lfs; | 256 std::ofstream Lfs; |
| 186 if (LogFilename != "-") { | 257 if (LogFilename != "-") { |
| 187 Lfs.open(LogFilename.c_str(), std::ofstream::out); | 258 Lfs.open(LogFilename.c_str(), std::ofstream::out); |
| 188 } | 259 } |
| 189 raw_os_ostream *Ls = new raw_os_ostream(LogFilename == "-" ? std::cout : Lfs); | 260 raw_os_ostream *Ls = new raw_os_ostream(LogFilename == "-" ? std::cout : Lfs); |
| 190 Ls->SetUnbuffered(); | 261 Ls->SetUnbuffered(); |
| 191 | 262 |
| 192 Ice::ClFlags Flags; | 263 Ice::ClFlags Flags; |
| 193 Flags.DisableInternal = DisableInternal; | 264 Flags.DisableInternal = DisableInternal; |
| 194 Flags.SubzeroTimingEnabled = SubzeroTimingEnabled; | 265 Flags.SubzeroTimingEnabled = SubzeroTimingEnabled; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 if (TimeEachFunction) { | 304 if (TimeEachFunction) { |
| 234 const bool DumpCumulative = false; | 305 const bool DumpCumulative = false; |
| 235 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); | 306 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); |
| 236 } | 307 } |
| 237 if (SubzeroTimingEnabled) | 308 if (SubzeroTimingEnabled) |
| 238 Ctx.dumpTimers(); | 309 Ctx.dumpTimers(); |
| 239 const bool FinalStats = true; | 310 const bool FinalStats = true; |
| 240 Ctx.dumpStats("_FINAL_", FinalStats); | 311 Ctx.dumpStats("_FINAL_", FinalStats); |
| 241 return GetReturnValue(ErrorStatus); | 312 return GetReturnValue(ErrorStatus); |
| 242 } | 313 } |
| OLD | NEW |