Chromium Code Reviews| 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. |
| 11 // | 11 // |
| 12 //===----------------------------------------------------------------------===// | 12 //===----------------------------------------------------------------------===// |
| 13 | 13 |
| 14 #include "IceConverter.h" | 14 #include "IceConverter.h" |
| 15 | 15 |
| 16 #include "IceCfg.h" | 16 #include "IceCfg.h" |
| 17 #include "IceCfgNode.h" | 17 #include "IceCfgNode.h" |
| 18 #include "IceClFlags.h" | 18 #include "IceClFlags.h" |
| 19 #include "IceDefs.h" | 19 #include "IceDefs.h" |
| 20 #include "IceGlobalContext.h" | 20 #include "IceGlobalContext.h" |
| 21 #include "IceInst.h" | 21 #include "IceInst.h" |
| 22 #include "IceOperand.h" | 22 #include "IceOperand.h" |
| 23 #include "IceTargetLowering.h" | 23 #include "IceTargetLowering.h" |
| 24 #include "IceTypes.h" | 24 #include "IceTypes.h" |
| 25 #include "IceTypeConverter.h" | |
| 25 | 26 |
| 26 #include "llvm/IR/Constant.h" | 27 #include "llvm/IR/Constant.h" |
| 27 #include "llvm/IR/Constants.h" | 28 #include "llvm/IR/Constants.h" |
| 28 #include "llvm/IR/DataLayout.h" | 29 #include "llvm/IR/DataLayout.h" |
| 29 #include "llvm/IR/Instruction.h" | 30 #include "llvm/IR/Instruction.h" |
| 30 #include "llvm/IR/Instructions.h" | 31 #include "llvm/IR/Instructions.h" |
| 31 #include "llvm/IR/LLVMContext.h" | 32 #include "llvm/IR/LLVMContext.h" |
| 32 #include "llvm/IR/Module.h" | 33 #include "llvm/IR/Module.h" |
| 33 | 34 |
| 34 #include <iostream> | 35 #include <iostream> |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 47 | 48 |
| 48 // Converter from LLVM to ICE. The entry point is the convertFunction method. | 49 // Converter from LLVM to ICE. The entry point is the convertFunction method. |
| 49 // | 50 // |
| 50 // Note: this currently assumes that the given IR was verified to be valid PNaCl | 51 // Note: this currently assumes that the given IR was verified to be valid PNaCl |
| 51 // bitcode: | 52 // bitcode: |
| 52 // https://developers.google.com/native-client/dev/reference/pnacl-bitcode-abi | 53 // https://developers.google.com/native-client/dev/reference/pnacl-bitcode-abi |
| 53 // If not, all kinds of assertions may fire. | 54 // If not, all kinds of assertions may fire. |
| 54 // | 55 // |
| 55 class LLVM2ICEConverter { | 56 class LLVM2ICEConverter { |
| 56 public: | 57 public: |
| 57 LLVM2ICEConverter(Ice::GlobalContext *Ctx) | 58 LLVM2ICEConverter(Ice::GlobalContext *Ctx, LLVMContext& LLVMContext) |
| 58 : Ctx(Ctx), Func(NULL), CurrentNode(NULL) { | 59 : Ctx(Ctx), Func(NULL), CurrentNode(NULL), TypeConverter(LLVMContext) { |
| 59 // All PNaCl pointer widths are 32 bits because of the sandbox | 60 // All PNaCl pointer widths are 32 bits because of the sandbox |
| 60 // model. | 61 // model. |
|
jvoung (off chromium)
2014/07/22 18:40:18
leftover comment
Karl
2014/07/23 20:22:20
Done.
| |
| 61 SubzeroPointerType = Ice::IceType_i32; | |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Caller is expected to delete the returned Ice::Cfg object. | 64 // Caller is expected to delete the returned Ice::Cfg object. |
| 65 Ice::Cfg *convertFunction(const Function *F) { | 65 Ice::Cfg *convertFunction(const Function *F) { |
| 66 VarMap.clear(); | 66 VarMap.clear(); |
| 67 NodeMap.clear(); | 67 NodeMap.clear(); |
| 68 Func = new Ice::Cfg(Ctx); | 68 Func = new Ice::Cfg(Ctx); |
| 69 Func->setFunctionName(F->getName()); | 69 Func->setFunctionName(F->getName()); |
| 70 Func->setReturnType(convertType(F->getReturnType())); | 70 Func->setReturnType(convertToIceType(F->getReturnType())); |
| 71 Func->setInternal(F->hasInternalLinkage()); | 71 Func->setInternal(F->hasInternalLinkage()); |
| 72 | 72 |
| 73 // The initial definition/use of each arg is the entry node. | 73 // The initial definition/use of each arg is the entry node. |
| 74 CurrentNode = mapBasicBlockToNode(&F->getEntryBlock()); | 74 CurrentNode = mapBasicBlockToNode(&F->getEntryBlock()); |
| 75 for (Function::const_arg_iterator ArgI = F->arg_begin(), | 75 for (Function::const_arg_iterator ArgI = F->arg_begin(), |
| 76 ArgE = F->arg_end(); | 76 ArgE = F->arg_end(); |
| 77 ArgI != ArgE; ++ArgI) { | 77 ArgI != ArgE; ++ArgI) { |
| 78 Func->addArg(mapValueToIceVar(ArgI)); | 78 Func->addArg(mapValueToIceVar(ArgI)); |
| 79 } | 79 } |
| 80 | 80 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 95 Func->computePredecessors(); | 95 Func->computePredecessors(); |
| 96 | 96 |
| 97 return Func; | 97 return Func; |
| 98 } | 98 } |
| 99 | 99 |
| 100 // convertConstant() does not use Func or require it to be a valid | 100 // convertConstant() does not use Func or require it to be a valid |
| 101 // Ice::Cfg pointer. As such, it's suitable for e.g. constructing | 101 // Ice::Cfg pointer. As such, it's suitable for e.g. constructing |
| 102 // global initializers. | 102 // global initializers. |
| 103 Ice::Constant *convertConstant(const Constant *Const) { | 103 Ice::Constant *convertConstant(const Constant *Const) { |
| 104 if (const GlobalValue *GV = dyn_cast<GlobalValue>(Const)) { | 104 if (const GlobalValue *GV = dyn_cast<GlobalValue>(Const)) { |
| 105 return Ctx->getConstantSym(convertType(GV->getType()), 0, GV->getName()); | 105 return Ctx->getConstantSym(convertToIceType(GV->getType()), |
| 106 0, GV->getName()); | |
| 106 } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(Const)) { | 107 } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(Const)) { |
| 107 return Ctx->getConstantInt(convertIntegerType(CI->getType()), | 108 return Ctx->getConstantInt(convertToIceType(CI->getType()), |
| 108 CI->getZExtValue()); | 109 CI->getZExtValue()); |
| 109 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(Const)) { | 110 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(Const)) { |
| 110 Ice::Type Type = convertType(CFP->getType()); | 111 Ice::Type Type = convertToIceType(CFP->getType()); |
| 111 if (Type == Ice::IceType_f32) | 112 if (Type == Ice::IceType_f32) |
| 112 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); | 113 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); |
| 113 else if (Type == Ice::IceType_f64) | 114 else if (Type == Ice::IceType_f64) |
| 114 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); | 115 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); |
| 115 llvm_unreachable("Unexpected floating point type"); | 116 llvm_unreachable("Unexpected floating point type"); |
| 116 return NULL; | 117 return NULL; |
| 117 } else if (const UndefValue *CU = dyn_cast<UndefValue>(Const)) { | 118 } else if (const UndefValue *CU = dyn_cast<UndefValue>(Const)) { |
| 118 return Ctx->getConstantUndef(convertType(CU->getType())); | 119 return Ctx->getConstantUndef(convertToIceType(CU->getType())); |
| 119 } else { | 120 } else { |
| 120 llvm_unreachable("Unhandled constant type"); | 121 llvm_unreachable("Unhandled constant type"); |
| 121 return NULL; | 122 return NULL; |
| 122 } | 123 } |
| 123 } | 124 } |
| 124 | 125 |
| 125 private: | 126 private: |
| 126 // LLVM values (instructions, etc.) are mapped directly to ICE variables. | 127 // LLVM values (instructions, etc.) are mapped directly to ICE variables. |
| 127 // mapValueToIceVar has a version that forces an ICE type on the variable, | 128 // mapValueToIceVar has a version that forces an ICE type on the variable, |
| 128 // and a version that just uses convertType on V. | 129 // and a version that just uses convertToIceType on V. |
| 129 Ice::Variable *mapValueToIceVar(const Value *V, Ice::Type IceTy) { | 130 Ice::Variable *mapValueToIceVar(const Value *V, Ice::Type IceTy) { |
| 130 if (IceTy == Ice::IceType_void) | 131 if (IceTy == Ice::IceType_void) |
| 131 return NULL; | 132 return NULL; |
| 132 if (VarMap.find(V) == VarMap.end()) { | 133 if (VarMap.find(V) == VarMap.end()) { |
| 133 assert(CurrentNode); | 134 assert(CurrentNode); |
| 134 VarMap[V] = Func->makeVariable(IceTy, CurrentNode, V->getName()); | 135 VarMap[V] = Func->makeVariable(IceTy, CurrentNode, V->getName()); |
| 135 } | 136 } |
| 136 return VarMap[V]; | 137 return VarMap[V]; |
| 137 } | 138 } |
| 138 | 139 |
| 139 Ice::Variable *mapValueToIceVar(const Value *V) { | 140 Ice::Variable *mapValueToIceVar(const Value *V) { |
| 140 return mapValueToIceVar(V, convertType(V->getType())); | 141 return mapValueToIceVar(V, convertToIceType(V->getType())); |
| 141 } | 142 } |
| 142 | 143 |
| 143 Ice::CfgNode *mapBasicBlockToNode(const BasicBlock *BB) { | 144 Ice::CfgNode *mapBasicBlockToNode(const BasicBlock *BB) { |
| 144 if (NodeMap.find(BB) == NodeMap.end()) { | 145 if (NodeMap.find(BB) == NodeMap.end()) { |
| 145 NodeMap[BB] = Func->makeNode(BB->getName()); | 146 NodeMap[BB] = Func->makeNode(BB->getName()); |
| 146 } | 147 } |
| 147 return NodeMap[BB]; | 148 return NodeMap[BB]; |
| 148 } | 149 } |
| 149 | 150 |
| 150 Ice::Type convertIntegerType(const IntegerType *IntTy) const { | 151 Ice::Type convertToIceType(Type *LLVMTy) const { |
| 151 switch (IntTy->getBitWidth()) { | 152 Ice::Type IceTy = TypeConverter.convertToIceType(LLVMTy); |
| 152 case 1: | 153 if (IceTy == Ice::IceType_NUM) |
| 153 return Ice::IceType_i1; | 154 llvm::report_fatal_error(std::string("Invalid PNaCl type ") + |
| 154 case 8: | 155 LLVMObjectAsString(LLVMTy)); |
| 155 return Ice::IceType_i8; | 156 return IceTy; |
| 156 case 16: | |
| 157 return Ice::IceType_i16; | |
| 158 case 32: | |
| 159 return Ice::IceType_i32; | |
| 160 case 64: | |
| 161 return Ice::IceType_i64; | |
| 162 default: | |
| 163 report_fatal_error(std::string("Invalid PNaCl int type: ") + | |
| 164 LLVMObjectAsString(IntTy)); | |
| 165 return Ice::IceType_void; | |
| 166 } | |
| 167 } | |
| 168 | |
| 169 Ice::Type convertVectorType(const VectorType *VecTy) const { | |
| 170 unsigned NumElements = VecTy->getNumElements(); | |
| 171 const Type *ElementType = VecTy->getElementType(); | |
| 172 | |
| 173 if (ElementType->isFloatTy()) { | |
| 174 if (NumElements == 4) | |
| 175 return Ice::IceType_v4f32; | |
| 176 } else if (ElementType->isIntegerTy()) { | |
| 177 switch (cast<IntegerType>(ElementType)->getBitWidth()) { | |
| 178 case 1: | |
| 179 if (NumElements == 4) | |
| 180 return Ice::IceType_v4i1; | |
| 181 if (NumElements == 8) | |
| 182 return Ice::IceType_v8i1; | |
| 183 if (NumElements == 16) | |
| 184 return Ice::IceType_v16i1; | |
| 185 break; | |
| 186 case 8: | |
| 187 if (NumElements == 16) | |
| 188 return Ice::IceType_v16i8; | |
| 189 break; | |
| 190 case 16: | |
| 191 if (NumElements == 8) | |
| 192 return Ice::IceType_v8i16; | |
| 193 break; | |
| 194 case 32: | |
| 195 if (NumElements == 4) | |
| 196 return Ice::IceType_v4i32; | |
| 197 break; | |
| 198 } | |
| 199 } | |
| 200 | |
| 201 report_fatal_error(std::string("Unhandled vector type: ") + | |
| 202 LLVMObjectAsString(VecTy)); | |
| 203 return Ice::IceType_void; | |
| 204 } | |
| 205 | |
| 206 Ice::Type convertType(const Type *Ty) const { | |
| 207 switch (Ty->getTypeID()) { | |
| 208 case Type::VoidTyID: | |
| 209 return Ice::IceType_void; | |
| 210 case Type::IntegerTyID: | |
| 211 return convertIntegerType(cast<IntegerType>(Ty)); | |
| 212 case Type::FloatTyID: | |
| 213 return Ice::IceType_f32; | |
| 214 case Type::DoubleTyID: | |
| 215 return Ice::IceType_f64; | |
| 216 case Type::PointerTyID: | |
| 217 return SubzeroPointerType; | |
| 218 case Type::FunctionTyID: | |
| 219 return SubzeroPointerType; | |
| 220 case Type::VectorTyID: | |
| 221 return convertVectorType(cast<VectorType>(Ty)); | |
| 222 default: | |
| 223 report_fatal_error(std::string("Invalid PNaCl type: ") + | |
| 224 LLVMObjectAsString(Ty)); | |
| 225 } | |
| 226 | |
| 227 llvm_unreachable("convertType"); | |
| 228 return Ice::IceType_void; | |
| 229 } | 157 } |
| 230 | 158 |
| 231 // Given an LLVM instruction and an operand number, produce the | 159 // Given an LLVM instruction and an operand number, produce the |
| 232 // Ice::Operand this refers to. If there's no such operand, return | 160 // Ice::Operand this refers to. If there's no such operand, return |
| 233 // NULL. | 161 // NULL. |
| 234 Ice::Operand *convertOperand(const Instruction *Inst, unsigned OpNum) { | 162 Ice::Operand *convertOperand(const Instruction *Inst, unsigned OpNum) { |
| 235 if (OpNum >= Inst->getNumOperands()) { | 163 if (OpNum >= Inst->getNumOperands()) { |
| 236 return NULL; | 164 return NULL; |
| 237 } | 165 } |
| 238 const Value *Op = Inst->getOperand(OpNum); | 166 const Value *Op = Inst->getOperand(OpNum); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 Ice::CfgNode *NodeElse = mapBasicBlockToNode(BBElse); | 325 Ice::CfgNode *NodeElse = mapBasicBlockToNode(BBElse); |
| 398 return Ice::InstBr::create(Func, Src, NodeThen, NodeElse); | 326 return Ice::InstBr::create(Func, Src, NodeThen, NodeElse); |
| 399 } else { | 327 } else { |
| 400 BasicBlock *BBSucc = Inst->getSuccessor(0); | 328 BasicBlock *BBSucc = Inst->getSuccessor(0); |
| 401 return Ice::InstBr::create(Func, mapBasicBlockToNode(BBSucc)); | 329 return Ice::InstBr::create(Func, mapBasicBlockToNode(BBSucc)); |
| 402 } | 330 } |
| 403 } | 331 } |
| 404 | 332 |
| 405 Ice::Inst *convertIntToPtrInstruction(const IntToPtrInst *Inst) { | 333 Ice::Inst *convertIntToPtrInstruction(const IntToPtrInst *Inst) { |
| 406 Ice::Operand *Src = convertOperand(Inst, 0); | 334 Ice::Operand *Src = convertOperand(Inst, 0); |
| 407 Ice::Variable *Dest = mapValueToIceVar(Inst, SubzeroPointerType); | 335 Ice::Variable *Dest = |
| 336 mapValueToIceVar(Inst, TypeConverter.getIcePointerType()); | |
| 408 return Ice::InstAssign::create(Func, Dest, Src); | 337 return Ice::InstAssign::create(Func, Dest, Src); |
| 409 } | 338 } |
| 410 | 339 |
| 411 Ice::Inst *convertPtrToIntInstruction(const PtrToIntInst *Inst) { | 340 Ice::Inst *convertPtrToIntInstruction(const PtrToIntInst *Inst) { |
| 412 Ice::Operand *Src = convertOperand(Inst, 0); | 341 Ice::Operand *Src = convertOperand(Inst, 0); |
| 413 Ice::Variable *Dest = mapValueToIceVar(Inst); | 342 Ice::Variable *Dest = mapValueToIceVar(Inst); |
| 414 return Ice::InstAssign::create(Func, Dest, Src); | 343 return Ice::InstAssign::create(Func, Dest, Src); |
| 415 } | 344 } |
| 416 | 345 |
| 417 Ice::Inst *convertRetInstruction(const ReturnInst *Inst) { | 346 Ice::Inst *convertRetInstruction(const ReturnInst *Inst) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 if (Info) { | 544 if (Info) { |
| 616 validateIntrinsicCall(NewInst, Info); | 545 validateIntrinsicCall(NewInst, Info); |
| 617 } | 546 } |
| 618 return NewInst; | 547 return NewInst; |
| 619 } | 548 } |
| 620 | 549 |
| 621 Ice::Inst *convertAllocaInstruction(const AllocaInst *Inst) { | 550 Ice::Inst *convertAllocaInstruction(const AllocaInst *Inst) { |
| 622 // PNaCl bitcode only contains allocas of byte-granular objects. | 551 // PNaCl bitcode only contains allocas of byte-granular objects. |
| 623 Ice::Operand *ByteCount = convertValue(Inst->getArraySize()); | 552 Ice::Operand *ByteCount = convertValue(Inst->getArraySize()); |
| 624 uint32_t Align = Inst->getAlignment(); | 553 uint32_t Align = Inst->getAlignment(); |
| 625 Ice::Variable *Dest = mapValueToIceVar(Inst, SubzeroPointerType); | 554 Ice::Variable *Dest = |
| 555 mapValueToIceVar(Inst, TypeConverter.getIcePointerType()); | |
| 626 | 556 |
| 627 return Ice::InstAlloca::create(Func, ByteCount, Align, Dest); | 557 return Ice::InstAlloca::create(Func, ByteCount, Align, Dest); |
| 628 } | 558 } |
| 629 | 559 |
| 630 Ice::Inst *convertUnreachableInstruction(const UnreachableInst * /*Inst*/) { | 560 Ice::Inst *convertUnreachableInstruction(const UnreachableInst * /*Inst*/) { |
| 631 return Ice::InstUnreachable::create(Func); | 561 return Ice::InstUnreachable::create(Func); |
| 632 } | 562 } |
| 633 | 563 |
| 634 Ice::CfgNode *convertBasicBlock(const BasicBlock *BB) { | 564 Ice::CfgNode *convertBasicBlock(const BasicBlock *BB) { |
| 635 Ice::CfgNode *Node = mapBasicBlockToNode(BB); | 565 Ice::CfgNode *Node = mapBasicBlockToNode(BB); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 664 report_fatal_error("Mismatched argument type."); | 594 report_fatal_error("Mismatched argument type."); |
| 665 } | 595 } |
| 666 } | 596 } |
| 667 } | 597 } |
| 668 | 598 |
| 669 private: | 599 private: |
| 670 // Data | 600 // Data |
| 671 Ice::GlobalContext *Ctx; | 601 Ice::GlobalContext *Ctx; |
| 672 Ice::Cfg *Func; | 602 Ice::Cfg *Func; |
| 673 Ice::CfgNode *CurrentNode; | 603 Ice::CfgNode *CurrentNode; |
| 674 Ice::Type SubzeroPointerType; | |
| 675 std::map<const Value *, Ice::Variable *> VarMap; | 604 std::map<const Value *, Ice::Variable *> VarMap; |
| 676 std::map<const BasicBlock *, Ice::CfgNode *> NodeMap; | 605 std::map<const BasicBlock *, Ice::CfgNode *> NodeMap; |
| 606 Ice::TypeConverter TypeConverter; | |
| 677 }; | 607 }; |
| 678 | 608 |
| 679 } // end of anonymous namespace. | 609 } // end of anonymous namespace. |
| 680 | 610 |
| 681 namespace Ice { | 611 namespace Ice { |
| 682 | 612 |
| 683 void Converter::convertToIce(Module *Mod) { | 613 void Converter::convertToIce() { |
| 684 convertGlobals(Mod); | 614 convertGlobals(); |
| 685 convertFunctions(Mod); | 615 convertFunctions(); |
| 686 } | 616 } |
| 687 | 617 |
| 688 void Converter::convertGlobals(Module *Mod) { | 618 void Converter::convertGlobals() { |
| 689 OwningPtr<TargetGlobalInitLowering> GlobalLowering( | 619 OwningPtr<TargetGlobalInitLowering> GlobalLowering( |
| 690 TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); | 620 TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); |
| 691 for (Module::const_global_iterator I = Mod->global_begin(), | 621 for (Module::const_global_iterator I = Mod->global_begin(), |
| 692 E = Mod->global_end(); | 622 E = Mod->global_end(); |
| 693 I != E; ++I) { | 623 I != E; ++I) { |
| 694 if (!I->hasInitializer()) | 624 if (!I->hasInitializer()) |
| 695 continue; | 625 continue; |
| 696 const llvm::Constant *Initializer = I->getInitializer(); | 626 const llvm::Constant *Initializer = I->getInitializer(); |
| 697 IceString Name = I->getName(); | 627 IceString Name = I->getName(); |
| 698 unsigned Align = I->getAlignment(); | 628 unsigned Align = I->getAlignment(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 720 } else { | 650 } else { |
| 721 llvm_unreachable("Unhandled global initializer"); | 651 llvm_unreachable("Unhandled global initializer"); |
| 722 } | 652 } |
| 723 | 653 |
| 724 GlobalLowering->lower(Name, Align, IsInternal, IsConst, IsZeroInitializer, | 654 GlobalLowering->lower(Name, Align, IsInternal, IsConst, IsZeroInitializer, |
| 725 NumElements, Data, Flags.DisableTranslation); | 655 NumElements, Data, Flags.DisableTranslation); |
| 726 } | 656 } |
| 727 GlobalLowering.reset(); | 657 GlobalLowering.reset(); |
| 728 } | 658 } |
| 729 | 659 |
| 730 void Converter::convertFunctions(Module *Mod) { | 660 void Converter::convertFunctions() { |
| 731 for (Module::const_iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) { | 661 for (Module::const_iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) { |
| 732 if (I->empty()) | 662 if (I->empty()) |
| 733 continue; | 663 continue; |
| 734 LLVM2ICEConverter FunctionConverter(Ctx); | 664 LLVM2ICEConverter FunctionConverter(Ctx, Mod->getContext()); |
| 735 | 665 |
| 736 Timer TConvert; | 666 Timer TConvert; |
| 737 Cfg *Fcn = FunctionConverter.convertFunction(I); | 667 Cfg *Fcn = FunctionConverter.convertFunction(I); |
| 738 if (Flags.SubzeroTimingEnabled) { | 668 if (Flags.SubzeroTimingEnabled) { |
| 739 std::cerr << "[Subzero timing] Convert function " | 669 std::cerr << "[Subzero timing] Convert function " |
| 740 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec() | 670 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec() |
| 741 << " sec\n"; | 671 << " sec\n"; |
| 742 } | 672 } |
| 743 translateFcn(Fcn); | 673 translateFcn(Fcn); |
| 744 } | 674 } |
| 745 | 675 |
| 746 emitConstants(); | 676 emitConstants(); |
| 747 } | 677 } |
| 748 | 678 |
| 749 } // end of Ice namespace. | 679 } // end of Ice namespace. |
| OLD | NEW |