| 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 // model. | |
| 61 SubzeroPointerType = Ice::IceType_i32; | |
| 62 } | |
| 63 | 60 |
| 64 // Caller is expected to delete the returned Ice::Cfg object. | 61 // Caller is expected to delete the returned Ice::Cfg object. |
| 65 Ice::Cfg *convertFunction(const Function *F) { | 62 Ice::Cfg *convertFunction(const Function *F) { |
| 66 VarMap.clear(); | 63 VarMap.clear(); |
| 67 NodeMap.clear(); | 64 NodeMap.clear(); |
| 68 Func = new Ice::Cfg(Ctx); | 65 Func = new Ice::Cfg(Ctx); |
| 69 Func->setFunctionName(F->getName()); | 66 Func->setFunctionName(F->getName()); |
| 70 Func->setReturnType(convertType(F->getReturnType())); | 67 Func->setReturnType(convertToIceType(F->getReturnType())); |
| 71 Func->setInternal(F->hasInternalLinkage()); | 68 Func->setInternal(F->hasInternalLinkage()); |
| 72 | 69 |
| 73 // The initial definition/use of each arg is the entry node. | 70 // The initial definition/use of each arg is the entry node. |
| 74 CurrentNode = mapBasicBlockToNode(&F->getEntryBlock()); | 71 CurrentNode = mapBasicBlockToNode(&F->getEntryBlock()); |
| 75 for (Function::const_arg_iterator ArgI = F->arg_begin(), | 72 for (Function::const_arg_iterator ArgI = F->arg_begin(), |
| 76 ArgE = F->arg_end(); | 73 ArgE = F->arg_end(); |
| 77 ArgI != ArgE; ++ArgI) { | 74 ArgI != ArgE; ++ArgI) { |
| 78 Func->addArg(mapValueToIceVar(ArgI)); | 75 Func->addArg(mapValueToIceVar(ArgI)); |
| 79 } | 76 } |
| 80 | 77 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 95 Func->computePredecessors(); | 92 Func->computePredecessors(); |
| 96 | 93 |
| 97 return Func; | 94 return Func; |
| 98 } | 95 } |
| 99 | 96 |
| 100 // convertConstant() does not use Func or require it to be a valid | 97 // 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 | 98 // Ice::Cfg pointer. As such, it's suitable for e.g. constructing |
| 102 // global initializers. | 99 // global initializers. |
| 103 Ice::Constant *convertConstant(const Constant *Const) { | 100 Ice::Constant *convertConstant(const Constant *Const) { |
| 104 if (const GlobalValue *GV = dyn_cast<GlobalValue>(Const)) { | 101 if (const GlobalValue *GV = dyn_cast<GlobalValue>(Const)) { |
| 105 return Ctx->getConstantSym(convertType(GV->getType()), 0, GV->getName()); | 102 return Ctx->getConstantSym(convertToIceType(GV->getType()), |
| 103 0, GV->getName()); |
| 106 } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(Const)) { | 104 } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(Const)) { |
| 107 return Ctx->getConstantInt(convertIntegerType(CI->getType()), | 105 return Ctx->getConstantInt(convertToIceType(CI->getType()), |
| 108 CI->getZExtValue()); | 106 CI->getZExtValue()); |
| 109 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(Const)) { | 107 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(Const)) { |
| 110 Ice::Type Type = convertType(CFP->getType()); | 108 Ice::Type Type = convertToIceType(CFP->getType()); |
| 111 if (Type == Ice::IceType_f32) | 109 if (Type == Ice::IceType_f32) |
| 112 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); | 110 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); |
| 113 else if (Type == Ice::IceType_f64) | 111 else if (Type == Ice::IceType_f64) |
| 114 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); | 112 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); |
| 115 llvm_unreachable("Unexpected floating point type"); | 113 llvm_unreachable("Unexpected floating point type"); |
| 116 return NULL; | 114 return NULL; |
| 117 } else if (const UndefValue *CU = dyn_cast<UndefValue>(Const)) { | 115 } else if (const UndefValue *CU = dyn_cast<UndefValue>(Const)) { |
| 118 return Ctx->getConstantUndef(convertType(CU->getType())); | 116 return Ctx->getConstantUndef(convertToIceType(CU->getType())); |
| 119 } else { | 117 } else { |
| 120 llvm_unreachable("Unhandled constant type"); | 118 llvm_unreachable("Unhandled constant type"); |
| 121 return NULL; | 119 return NULL; |
| 122 } | 120 } |
| 123 } | 121 } |
| 124 | 122 |
| 125 private: | 123 private: |
| 126 // LLVM values (instructions, etc.) are mapped directly to ICE variables. | 124 // LLVM values (instructions, etc.) are mapped directly to ICE variables. |
| 127 // mapValueToIceVar has a version that forces an ICE type on the variable, | 125 // mapValueToIceVar has a version that forces an ICE type on the variable, |
| 128 // and a version that just uses convertType on V. | 126 // and a version that just uses convertToIceType on V. |
| 129 Ice::Variable *mapValueToIceVar(const Value *V, Ice::Type IceTy) { | 127 Ice::Variable *mapValueToIceVar(const Value *V, Ice::Type IceTy) { |
| 130 if (IceTy == Ice::IceType_void) | 128 if (IceTy == Ice::IceType_void) |
| 131 return NULL; | 129 return NULL; |
| 132 if (VarMap.find(V) == VarMap.end()) { | 130 if (VarMap.find(V) == VarMap.end()) { |
| 133 assert(CurrentNode); | 131 assert(CurrentNode); |
| 134 VarMap[V] = Func->makeVariable(IceTy, CurrentNode, V->getName()); | 132 VarMap[V] = Func->makeVariable(IceTy, CurrentNode, V->getName()); |
| 135 } | 133 } |
| 136 return VarMap[V]; | 134 return VarMap[V]; |
| 137 } | 135 } |
| 138 | 136 |
| 139 Ice::Variable *mapValueToIceVar(const Value *V) { | 137 Ice::Variable *mapValueToIceVar(const Value *V) { |
| 140 return mapValueToIceVar(V, convertType(V->getType())); | 138 return mapValueToIceVar(V, convertToIceType(V->getType())); |
| 141 } | 139 } |
| 142 | 140 |
| 143 Ice::CfgNode *mapBasicBlockToNode(const BasicBlock *BB) { | 141 Ice::CfgNode *mapBasicBlockToNode(const BasicBlock *BB) { |
| 144 if (NodeMap.find(BB) == NodeMap.end()) { | 142 if (NodeMap.find(BB) == NodeMap.end()) { |
| 145 NodeMap[BB] = Func->makeNode(BB->getName()); | 143 NodeMap[BB] = Func->makeNode(BB->getName()); |
| 146 } | 144 } |
| 147 return NodeMap[BB]; | 145 return NodeMap[BB]; |
| 148 } | 146 } |
| 149 | 147 |
| 150 Ice::Type convertIntegerType(const IntegerType *IntTy) const { | 148 Ice::Type convertToIceType(Type *LLVMTy) const { |
| 151 switch (IntTy->getBitWidth()) { | 149 Ice::Type IceTy = TypeConverter.convertToIceType(LLVMTy); |
| 152 case 1: | 150 if (IceTy == Ice::IceType_NUM) |
| 153 return Ice::IceType_i1; | 151 llvm::report_fatal_error(std::string("Invalid PNaCl type ") + |
| 154 case 8: | 152 LLVMObjectAsString(LLVMTy)); |
| 155 return Ice::IceType_i8; | 153 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 } | 154 } |
| 230 | 155 |
| 231 // Given an LLVM instruction and an operand number, produce the | 156 // Given an LLVM instruction and an operand number, produce the |
| 232 // Ice::Operand this refers to. If there's no such operand, return | 157 // Ice::Operand this refers to. If there's no such operand, return |
| 233 // NULL. | 158 // NULL. |
| 234 Ice::Operand *convertOperand(const Instruction *Inst, unsigned OpNum) { | 159 Ice::Operand *convertOperand(const Instruction *Inst, unsigned OpNum) { |
| 235 if (OpNum >= Inst->getNumOperands()) { | 160 if (OpNum >= Inst->getNumOperands()) { |
| 236 return NULL; | 161 return NULL; |
| 237 } | 162 } |
| 238 const Value *Op = Inst->getOperand(OpNum); | 163 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); | 322 Ice::CfgNode *NodeElse = mapBasicBlockToNode(BBElse); |
| 398 return Ice::InstBr::create(Func, Src, NodeThen, NodeElse); | 323 return Ice::InstBr::create(Func, Src, NodeThen, NodeElse); |
| 399 } else { | 324 } else { |
| 400 BasicBlock *BBSucc = Inst->getSuccessor(0); | 325 BasicBlock *BBSucc = Inst->getSuccessor(0); |
| 401 return Ice::InstBr::create(Func, mapBasicBlockToNode(BBSucc)); | 326 return Ice::InstBr::create(Func, mapBasicBlockToNode(BBSucc)); |
| 402 } | 327 } |
| 403 } | 328 } |
| 404 | 329 |
| 405 Ice::Inst *convertIntToPtrInstruction(const IntToPtrInst *Inst) { | 330 Ice::Inst *convertIntToPtrInstruction(const IntToPtrInst *Inst) { |
| 406 Ice::Operand *Src = convertOperand(Inst, 0); | 331 Ice::Operand *Src = convertOperand(Inst, 0); |
| 407 Ice::Variable *Dest = mapValueToIceVar(Inst, SubzeroPointerType); | 332 Ice::Variable *Dest = |
| 333 mapValueToIceVar(Inst, TypeConverter.getIcePointerType()); |
| 408 return Ice::InstAssign::create(Func, Dest, Src); | 334 return Ice::InstAssign::create(Func, Dest, Src); |
| 409 } | 335 } |
| 410 | 336 |
| 411 Ice::Inst *convertPtrToIntInstruction(const PtrToIntInst *Inst) { | 337 Ice::Inst *convertPtrToIntInstruction(const PtrToIntInst *Inst) { |
| 412 Ice::Operand *Src = convertOperand(Inst, 0); | 338 Ice::Operand *Src = convertOperand(Inst, 0); |
| 413 Ice::Variable *Dest = mapValueToIceVar(Inst); | 339 Ice::Variable *Dest = mapValueToIceVar(Inst); |
| 414 return Ice::InstAssign::create(Func, Dest, Src); | 340 return Ice::InstAssign::create(Func, Dest, Src); |
| 415 } | 341 } |
| 416 | 342 |
| 417 Ice::Inst *convertRetInstruction(const ReturnInst *Inst) { | 343 Ice::Inst *convertRetInstruction(const ReturnInst *Inst) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 if (Info) { | 541 if (Info) { |
| 616 validateIntrinsicCall(NewInst, Info); | 542 validateIntrinsicCall(NewInst, Info); |
| 617 } | 543 } |
| 618 return NewInst; | 544 return NewInst; |
| 619 } | 545 } |
| 620 | 546 |
| 621 Ice::Inst *convertAllocaInstruction(const AllocaInst *Inst) { | 547 Ice::Inst *convertAllocaInstruction(const AllocaInst *Inst) { |
| 622 // PNaCl bitcode only contains allocas of byte-granular objects. | 548 // PNaCl bitcode only contains allocas of byte-granular objects. |
| 623 Ice::Operand *ByteCount = convertValue(Inst->getArraySize()); | 549 Ice::Operand *ByteCount = convertValue(Inst->getArraySize()); |
| 624 uint32_t Align = Inst->getAlignment(); | 550 uint32_t Align = Inst->getAlignment(); |
| 625 Ice::Variable *Dest = mapValueToIceVar(Inst, SubzeroPointerType); | 551 Ice::Variable *Dest = |
| 552 mapValueToIceVar(Inst, TypeConverter.getIcePointerType()); |
| 626 | 553 |
| 627 return Ice::InstAlloca::create(Func, ByteCount, Align, Dest); | 554 return Ice::InstAlloca::create(Func, ByteCount, Align, Dest); |
| 628 } | 555 } |
| 629 | 556 |
| 630 Ice::Inst *convertUnreachableInstruction(const UnreachableInst * /*Inst*/) { | 557 Ice::Inst *convertUnreachableInstruction(const UnreachableInst * /*Inst*/) { |
| 631 return Ice::InstUnreachable::create(Func); | 558 return Ice::InstUnreachable::create(Func); |
| 632 } | 559 } |
| 633 | 560 |
| 634 Ice::CfgNode *convertBasicBlock(const BasicBlock *BB) { | 561 Ice::CfgNode *convertBasicBlock(const BasicBlock *BB) { |
| 635 Ice::CfgNode *Node = mapBasicBlockToNode(BB); | 562 Ice::CfgNode *Node = mapBasicBlockToNode(BB); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 664 report_fatal_error("Mismatched argument type."); | 591 report_fatal_error("Mismatched argument type."); |
| 665 } | 592 } |
| 666 } | 593 } |
| 667 } | 594 } |
| 668 | 595 |
| 669 private: | 596 private: |
| 670 // Data | 597 // Data |
| 671 Ice::GlobalContext *Ctx; | 598 Ice::GlobalContext *Ctx; |
| 672 Ice::Cfg *Func; | 599 Ice::Cfg *Func; |
| 673 Ice::CfgNode *CurrentNode; | 600 Ice::CfgNode *CurrentNode; |
| 674 Ice::Type SubzeroPointerType; | |
| 675 std::map<const Value *, Ice::Variable *> VarMap; | 601 std::map<const Value *, Ice::Variable *> VarMap; |
| 676 std::map<const BasicBlock *, Ice::CfgNode *> NodeMap; | 602 std::map<const BasicBlock *, Ice::CfgNode *> NodeMap; |
| 603 Ice::TypeConverter TypeConverter; |
| 677 }; | 604 }; |
| 678 | 605 |
| 679 } // end of anonymous namespace. | 606 } // end of anonymous namespace. |
| 680 | 607 |
| 681 namespace Ice { | 608 namespace Ice { |
| 682 | 609 |
| 683 void Converter::convertToIce(Module *Mod) { | 610 void Converter::convertToIce() { |
| 684 convertGlobals(Mod); | 611 convertGlobals(); |
| 685 convertFunctions(Mod); | 612 convertFunctions(); |
| 686 } | 613 } |
| 687 | 614 |
| 688 void Converter::convertGlobals(Module *Mod) { | 615 void Converter::convertGlobals() { |
| 689 OwningPtr<TargetGlobalInitLowering> GlobalLowering( | 616 OwningPtr<TargetGlobalInitLowering> GlobalLowering( |
| 690 TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); | 617 TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); |
| 691 for (Module::const_global_iterator I = Mod->global_begin(), | 618 for (Module::const_global_iterator I = Mod->global_begin(), |
| 692 E = Mod->global_end(); | 619 E = Mod->global_end(); |
| 693 I != E; ++I) { | 620 I != E; ++I) { |
| 694 if (!I->hasInitializer()) | 621 if (!I->hasInitializer()) |
| 695 continue; | 622 continue; |
| 696 const llvm::Constant *Initializer = I->getInitializer(); | 623 const llvm::Constant *Initializer = I->getInitializer(); |
| 697 IceString Name = I->getName(); | 624 IceString Name = I->getName(); |
| 698 unsigned Align = I->getAlignment(); | 625 unsigned Align = I->getAlignment(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 720 } else { | 647 } else { |
| 721 llvm_unreachable("Unhandled global initializer"); | 648 llvm_unreachable("Unhandled global initializer"); |
| 722 } | 649 } |
| 723 | 650 |
| 724 GlobalLowering->lower(Name, Align, IsInternal, IsConst, IsZeroInitializer, | 651 GlobalLowering->lower(Name, Align, IsInternal, IsConst, IsZeroInitializer, |
| 725 NumElements, Data, Flags.DisableTranslation); | 652 NumElements, Data, Flags.DisableTranslation); |
| 726 } | 653 } |
| 727 GlobalLowering.reset(); | 654 GlobalLowering.reset(); |
| 728 } | 655 } |
| 729 | 656 |
| 730 void Converter::convertFunctions(Module *Mod) { | 657 void Converter::convertFunctions() { |
| 731 for (Module::const_iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) { | 658 for (Module::const_iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) { |
| 732 if (I->empty()) | 659 if (I->empty()) |
| 733 continue; | 660 continue; |
| 734 LLVM2ICEConverter FunctionConverter(Ctx); | 661 LLVM2ICEConverter FunctionConverter(Ctx, Mod->getContext()); |
| 735 | 662 |
| 736 Timer TConvert; | 663 Timer TConvert; |
| 737 Cfg *Fcn = FunctionConverter.convertFunction(I); | 664 Cfg *Fcn = FunctionConverter.convertFunction(I); |
| 738 if (Flags.SubzeroTimingEnabled) { | 665 if (Flags.SubzeroTimingEnabled) { |
| 739 std::cerr << "[Subzero timing] Convert function " | 666 std::cerr << "[Subzero timing] Convert function " |
| 740 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec() | 667 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec() |
| 741 << " sec\n"; | 668 << " sec\n"; |
| 742 } | 669 } |
| 743 translateFcn(Fcn); | 670 translateFcn(Fcn); |
| 744 } | 671 } |
| 745 | 672 |
| 746 emitConstants(); | 673 emitConstants(); |
| 747 } | 674 } |
| 748 | 675 |
| 749 } // end of Ice namespace. | 676 } // end of Ice namespace. |
| OLD | NEW |