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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 Ice::CfgNode *NodeElse = mapBasicBlockToNode(BBElse); | 342 Ice::CfgNode *NodeElse = mapBasicBlockToNode(BBElse); |
343 return Ice::InstBr::create(Func, Src, NodeThen, NodeElse); | 343 return Ice::InstBr::create(Func, Src, NodeThen, NodeElse); |
344 } else { | 344 } else { |
345 BasicBlock *BBSucc = Inst->getSuccessor(0); | 345 BasicBlock *BBSucc = Inst->getSuccessor(0); |
346 return Ice::InstBr::create(Func, mapBasicBlockToNode(BBSucc)); | 346 return Ice::InstBr::create(Func, mapBasicBlockToNode(BBSucc)); |
347 } | 347 } |
348 } | 348 } |
349 | 349 |
350 Ice::Inst *convertIntToPtrInstruction(const IntToPtrInst *Inst) { | 350 Ice::Inst *convertIntToPtrInstruction(const IntToPtrInst *Inst) { |
351 Ice::Operand *Src = convertOperand(Inst, 0); | 351 Ice::Operand *Src = convertOperand(Inst, 0); |
352 Ice::Variable *Dest = | 352 Ice::Variable *Dest = mapValueToIceVar(Inst, Ice::getPointerType()); |
353 mapValueToIceVar(Inst, TypeConverter.getIcePointerType()); | |
354 return Ice::InstAssign::create(Func, Dest, Src); | 353 return Ice::InstAssign::create(Func, Dest, Src); |
355 } | 354 } |
356 | 355 |
357 Ice::Inst *convertPtrToIntInstruction(const PtrToIntInst *Inst) { | 356 Ice::Inst *convertPtrToIntInstruction(const PtrToIntInst *Inst) { |
358 Ice::Operand *Src = convertOperand(Inst, 0); | 357 Ice::Operand *Src = convertOperand(Inst, 0); |
359 Ice::Variable *Dest = mapValueToIceVar(Inst); | 358 Ice::Variable *Dest = mapValueToIceVar(Inst); |
360 return Ice::InstAssign::create(Func, Dest, Src); | 359 return Ice::InstAssign::create(Func, Dest, Src); |
361 } | 360 } |
362 | 361 |
363 Ice::Inst *convertRetInstruction(const ReturnInst *Inst) { | 362 Ice::Inst *convertRetInstruction(const ReturnInst *Inst) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 if (Info) { | 560 if (Info) { |
562 validateIntrinsicCall(NewInst, Info); | 561 validateIntrinsicCall(NewInst, Info); |
563 } | 562 } |
564 return NewInst; | 563 return NewInst; |
565 } | 564 } |
566 | 565 |
567 Ice::Inst *convertAllocaInstruction(const AllocaInst *Inst) { | 566 Ice::Inst *convertAllocaInstruction(const AllocaInst *Inst) { |
568 // PNaCl bitcode only contains allocas of byte-granular objects. | 567 // PNaCl bitcode only contains allocas of byte-granular objects. |
569 Ice::Operand *ByteCount = convertValue(Inst->getArraySize()); | 568 Ice::Operand *ByteCount = convertValue(Inst->getArraySize()); |
570 uint32_t Align = Inst->getAlignment(); | 569 uint32_t Align = Inst->getAlignment(); |
571 Ice::Variable *Dest = | 570 Ice::Variable *Dest = mapValueToIceVar(Inst, Ice::getPointerType()); |
572 mapValueToIceVar(Inst, TypeConverter.getIcePointerType()); | |
573 | 571 |
574 return Ice::InstAlloca::create(Func, ByteCount, Align, Dest); | 572 return Ice::InstAlloca::create(Func, ByteCount, Align, Dest); |
575 } | 573 } |
576 | 574 |
577 Ice::Inst *convertUnreachableInstruction(const UnreachableInst * /*Inst*/) { | 575 Ice::Inst *convertUnreachableInstruction(const UnreachableInst * /*Inst*/) { |
578 return Ice::InstUnreachable::create(Func); | 576 return Ice::InstUnreachable::create(Func); |
579 } | 577 } |
580 | 578 |
581 Ice::CfgNode *convertBasicBlock(const BasicBlock *BB) { | 579 Ice::CfgNode *convertBasicBlock(const BasicBlock *BB) { |
582 Ice::CfgNode *Node = mapBasicBlockToNode(BB); | 580 Ice::CfgNode *Node = mapBasicBlockToNode(BB); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 | 757 |
760 if (const auto Exp = dyn_cast<ConstantExpr>(Initializer)) { | 758 if (const auto Exp = dyn_cast<ConstantExpr>(Initializer)) { |
761 switch (Exp->getOpcode()) { | 759 switch (Exp->getOpcode()) { |
762 case Instruction::Add: | 760 case Instruction::Add: |
763 assert(!HasOffset); | 761 assert(!HasOffset); |
764 addGlobalInitializer(Global, Exp->getOperand(0), true, | 762 addGlobalInitializer(Global, Exp->getOperand(0), true, |
765 getIntegerLiteralConstant(Exp->getOperand(1))); | 763 getIntegerLiteralConstant(Exp->getOperand(1))); |
766 return; | 764 return; |
767 case Instruction::PtrToInt: { | 765 case Instruction::PtrToInt: { |
768 assert(TypeConverter.convertToIceType(Exp->getType()) == | 766 assert(TypeConverter.convertToIceType(Exp->getType()) == |
769 TypeConverter.getIcePointerType()); | 767 Ice::getPointerType()); |
770 const auto GV = dyn_cast<GlobalValue>(Exp->getOperand(0)); | 768 const auto GV = dyn_cast<GlobalValue>(Exp->getOperand(0)); |
771 assert(GV); | 769 assert(GV); |
772 const Ice::GlobalDeclaration *Addr = | 770 const Ice::GlobalDeclaration *Addr = |
773 getConverter().getGlobalDeclaration(GV); | 771 getConverter().getGlobalDeclaration(GV); |
774 Global.addInitializer( | 772 Global.addInitializer( |
775 new Ice::VariableDeclaration::RelocInitializer(Addr, Offset)); | 773 new Ice::VariableDeclaration::RelocInitializer(Addr, Offset)); |
776 return; | 774 return; |
777 } | 775 } |
778 default: | 776 default: |
779 break; | 777 break; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 Cfg *Fcn = FunctionConverter.convertFunction(&I); | 894 Cfg *Fcn = FunctionConverter.convertFunction(&I); |
897 translateFcn(Fcn); | 895 translateFcn(Fcn); |
898 if (ALLOW_DUMP && Ctx->getFlags().TimeEachFunction) | 896 if (ALLOW_DUMP && Ctx->getFlags().TimeEachFunction) |
899 Ctx->popTimer(TimerID, StackID); | 897 Ctx->popTimer(TimerID, StackID); |
900 } | 898 } |
901 | 899 |
902 emitConstants(); | 900 emitConstants(); |
903 } | 901 } |
904 | 902 |
905 } // end of namespace Ice | 903 } // end of namespace Ice |
OLD | NEW |