| OLD | NEW |
| 1 //===- subzero/src/IceConverter.cpp - Converts LLVM to Ice ---------------===// | 1 //===- subzero/src/IceConverter.cpp - Converts LLVM to Ice ---------------===// |
| 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 implements the LLVM to ICE converter. | 10 // This file implements the LLVM to ICE converter. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // | 54 // |
| 55 class LLVM2ICEConverter { | 55 class LLVM2ICEConverter { |
| 56 public: | 56 public: |
| 57 LLVM2ICEConverter(Ice::GlobalContext *Ctx, LLVMContext &LLVMContext) | 57 LLVM2ICEConverter(Ice::GlobalContext *Ctx, LLVMContext &LLVMContext) |
| 58 : Ctx(Ctx), Func(NULL), TypeConverter(LLVMContext) {} | 58 : Ctx(Ctx), Func(NULL), TypeConverter(LLVMContext) {} |
| 59 | 59 |
| 60 // Caller is expected to delete the returned Ice::Cfg object. | 60 // Caller is expected to delete the returned Ice::Cfg object. |
| 61 Ice::Cfg *convertFunction(const Function *F) { | 61 Ice::Cfg *convertFunction(const Function *F) { |
| 62 static Ice::TimerIdT IDllvmConvert = | 62 static Ice::TimerIdT IDllvmConvert = |
| 63 Ice::GlobalContext::getTimerID("llvmConvert"); | 63 Ice::GlobalContext::getTimerID("llvmConvert"); |
| 64 Ice::TimerMarker T(IDllvmConvert, Ctx); | |
| 65 VarMap.clear(); | 64 VarMap.clear(); |
| 66 NodeMap.clear(); | 65 NodeMap.clear(); |
| 67 Func = new Ice::Cfg(Ctx); | 66 Func = new Ice::Cfg(Ctx); |
| 68 Func->setFunctionName(F->getName()); | 67 Func->setFunctionName(F->getName()); |
| 69 Func->setReturnType(convertToIceType(F->getReturnType())); | 68 Func->setReturnType(convertToIceType(F->getReturnType())); |
| 70 Func->setInternal(F->hasInternalLinkage()); | 69 Func->setInternal(F->hasInternalLinkage()); |
| 70 Ice::TimerMarker T(IDllvmConvert, Func); |
| 71 | 71 |
| 72 // The initial definition/use of each arg is the entry node. | 72 // The initial definition/use of each arg is the entry node. |
| 73 for (auto ArgI = F->arg_begin(), ArgE = F->arg_end(); ArgI != ArgE; | 73 for (auto ArgI = F->arg_begin(), ArgE = F->arg_end(); ArgI != ArgE; |
| 74 ++ArgI) { | 74 ++ArgI) { |
| 75 Func->addArg(mapValueToIceVar(ArgI)); | 75 Func->addArg(mapValueToIceVar(ArgI)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Make an initial pass through the block list just to resolve the | 78 // Make an initial pass through the block list just to resolve the |
| 79 // blocks in the original linearized order. Otherwise the ICE | 79 // blocks in the original linearized order. Otherwise the ICE |
| 80 // linearized order will be affected by branch targets in | 80 // linearized order will be affected by branch targets in |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 void Converter::convertToIce() { | 619 void Converter::convertToIce() { |
| 620 static TimerIdT IDconvertToIce = GlobalContext::getTimerID("convertToIce"); | 620 static TimerIdT IDconvertToIce = GlobalContext::getTimerID("convertToIce"); |
| 621 TimerMarker T(IDconvertToIce, Ctx); | 621 TimerMarker T(IDconvertToIce, Ctx); |
| 622 nameUnnamedGlobalAddresses(Mod); | 622 nameUnnamedGlobalAddresses(Mod); |
| 623 if (!Ctx->getFlags().DisableGlobals) | 623 if (!Ctx->getFlags().DisableGlobals) |
| 624 convertGlobals(Mod); | 624 convertGlobals(Mod); |
| 625 convertFunctions(); | 625 convertFunctions(); |
| 626 } | 626 } |
| 627 | 627 |
| 628 void Converter::convertFunctions() { | 628 void Converter::convertFunctions() { |
| 629 TimerStackIdT StackID = GlobalContext::TSK_Funcs; |
| 629 for (const Function &I : *Mod) { | 630 for (const Function &I : *Mod) { |
| 630 if (I.empty()) | 631 if (I.empty()) |
| 631 continue; | 632 continue; |
| 633 if (Ctx->getFlags().TimeEachFunction) |
| 634 Ctx->pushTimer(GlobalContext::getTimerID(I.getName()), StackID); |
| 632 LLVM2ICEConverter FunctionConverter(Ctx, Mod->getContext()); | 635 LLVM2ICEConverter FunctionConverter(Ctx, Mod->getContext()); |
| 633 | 636 |
| 634 Cfg *Fcn = FunctionConverter.convertFunction(&I); | 637 Cfg *Fcn = FunctionConverter.convertFunction(&I); |
| 635 translateFcn(Fcn); | 638 translateFcn(Fcn); |
| 639 if (Ctx->getFlags().TimeEachFunction) |
| 640 Ctx->popTimer(GlobalContext::getTimerID(I.getName()), StackID); |
| 636 } | 641 } |
| 637 | 642 |
| 638 emitConstants(); | 643 emitConstants(); |
| 639 } | 644 } |
| 640 | 645 |
| 641 } // end of namespace Ice | 646 } // end of namespace Ice |
| OLD | NEW |