| OLD | NEW |
| 1 //===- subzero/src/IceTranslator.cpp - ICE to machine code ------*- C++ -*-===// | 1 //===- subzero/src/IceTranslator.cpp - ICE to machine code ------*- C++ -*-===// |
| 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 the general driver class for translating ICE to | 10 // This file defines the general driver class for translating ICE to |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 #include "IceCfg.h" | 22 #include "IceCfg.h" |
| 23 #include "IceClFlags.h" | 23 #include "IceClFlags.h" |
| 24 #include "IceDefs.h" | 24 #include "IceDefs.h" |
| 25 #include "IceGlobalInits.h" | 25 #include "IceGlobalInits.h" |
| 26 #include "IceTargetLowering.h" | 26 #include "IceTargetLowering.h" |
| 27 #include "IceTranslator.h" | 27 #include "IceTranslator.h" |
| 28 | 28 |
| 29 using namespace Ice; | 29 using namespace Ice; |
| 30 | 30 |
| 31 namespace { |
| 32 |
| 33 // Match a symbol name against a match string. An empty match string |
| 34 // means match everything. Returns true if there is a match. |
| 35 bool matchSymbolName(const IceString &SymbolName, const IceString &Match) { |
| 36 return Match.empty() || Match == SymbolName; |
| 37 } |
| 38 |
| 39 } // end of anonymous namespace |
| 40 |
| 31 Translator::~Translator() {} | 41 Translator::~Translator() {} |
| 32 | 42 |
| 33 IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) { | 43 IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) { |
| 34 if (Index == 0) | 44 if (Index == 0) |
| 35 return Prefix; | 45 return Prefix; |
| 36 std::string Buffer; | 46 std::string Buffer; |
| 37 llvm::raw_string_ostream StrBuf(Buffer); | 47 llvm::raw_string_ostream StrBuf(Buffer); |
| 38 StrBuf << Prefix << Index; | 48 StrBuf << Prefix << Index; |
| 39 return StrBuf.str(); | 49 return StrBuf.str(); |
| 40 } | 50 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 51 Stream << "Warning : Default " << Kind << " prefix '" << Prefix | 61 Stream << "Warning : Default " << Kind << " prefix '" << Prefix |
| 52 << "' potentially conflicts with name '" << Name << "'.\n"; | 62 << "' potentially conflicts with name '" << Name << "'.\n"; |
| 53 return true; | 63 return true; |
| 54 } | 64 } |
| 55 return false; | 65 return false; |
| 56 } | 66 } |
| 57 | 67 |
| 58 void Translator::translateFcn(Cfg *Fcn) { | 68 void Translator::translateFcn(Cfg *Fcn) { |
| 59 Ctx->resetStats(); | 69 Ctx->resetStats(); |
| 60 Func.reset(Fcn); | 70 Func.reset(Fcn); |
| 61 if (Ctx->getFlags().DisableInternal) | 71 VerboseMask OldVerboseMask = Ctx->getVerbose(); |
| 62 Func->setInternal(false); | 72 if (!matchSymbolName(Func->getFunctionName(), Ctx->getFlags().VerboseFocusOn)) |
| 63 if (Ctx->getFlags().DisableTranslation) { | 73 Ctx->setVerbose(IceV_None); |
| 74 |
| 75 if (Ctx->getFlags().DisableTranslation || |
| 76 !matchSymbolName(Func->getFunctionName(), |
| 77 Ctx->getFlags().TranslateOnly)) { |
| 64 Func->dump(); | 78 Func->dump(); |
| 65 } else { | 79 } else { |
| 66 Func->translate(); | 80 Func->translate(); |
| 67 if (Func->hasError()) { | 81 if (Func->hasError()) { |
| 68 std::cerr << "ICE translation error: " << Func->getError() << "\n"; | 82 std::cerr << "ICE translation error: " << Func->getError() << "\n"; |
| 69 ErrorStatus = true; | 83 ErrorStatus = true; |
| 70 } | 84 } |
| 71 | 85 |
| 72 Func->emit(); | 86 Func->emit(); |
| 73 Ctx->dumpStats(Func->getFunctionName()); | 87 Ctx->dumpStats(Func->getFunctionName()); |
| 74 } | 88 } |
| 89 |
| 90 Ctx->setVerbose(OldVerboseMask); |
| 75 } | 91 } |
| 76 | 92 |
| 77 void Translator::emitConstants() { | 93 void Translator::emitConstants() { |
| 78 if (!Ctx->getFlags().DisableTranslation && Func) | 94 if (!Ctx->getFlags().DisableTranslation && Func) |
| 79 Func->getTarget()->emitConstants(); | 95 Func->getTarget()->emitConstants(); |
| 80 } | 96 } |
| 81 | 97 |
| 82 void Translator::lowerGlobals( | 98 void Translator::lowerGlobals( |
| 83 const VariableDeclarationListType &VariableDeclarations) { | 99 const VariableDeclarationListType &VariableDeclarations) { |
| 84 llvm::OwningPtr<TargetGlobalInitLowering> GlobalLowering( | 100 llvm::OwningPtr<TargetGlobalInitLowering> GlobalLowering( |
| 85 TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); | 101 TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); |
| 86 bool DisableTranslation = Ctx->getFlags().DisableTranslation; | 102 bool DisableTranslation = Ctx->getFlags().DisableTranslation; |
| 87 bool DumpGlobalVariables = Ctx->isVerbose(); | 103 bool DumpGlobalVariables = |
| 104 Ctx->isVerbose() && Ctx->getFlags().VerboseFocusOn.empty(); |
| 88 Ostream &Stream = Ctx->getStrDump(); | 105 Ostream &Stream = Ctx->getStrDump(); |
| 106 const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly; |
| 89 for (const Ice::VariableDeclaration *Global : VariableDeclarations) { | 107 for (const Ice::VariableDeclaration *Global : VariableDeclarations) { |
| 90 if (DumpGlobalVariables) | 108 if (DumpGlobalVariables) |
| 91 Global->dump(getContext(), Stream); | 109 Global->dump(getContext(), Stream); |
| 92 if(!DisableTranslation) | 110 if (!DisableTranslation && |
| 111 matchSymbolName(Global->getName(), TranslateOnly)) |
| 93 GlobalLowering->lower(*Global); | 112 GlobalLowering->lower(*Global); |
| 94 } | 113 } |
| 95 GlobalLowering.reset(); | 114 GlobalLowering.reset(); |
| 96 } | 115 } |
| OLD | NEW |