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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 report_fatal_error(std::string("Invalid PNaCl intrinsic call: ") + | 530 report_fatal_error(std::string("Invalid PNaCl intrinsic call: ") + |
531 LLVMObjectAsString(Inst)); | 531 LLVMObjectAsString(Inst)); |
532 } | 532 } |
533 NewInst = Ice::InstIntrinsicCall::create(Func, NumArgs, Dest, | 533 NewInst = Ice::InstIntrinsicCall::create(Func, NumArgs, Dest, |
534 CallTarget, Info->Info); | 534 CallTarget, Info->Info); |
535 } | 535 } |
536 } | 536 } |
537 | 537 |
538 // Not an intrinsic call. | 538 // Not an intrinsic call. |
539 if (NewInst == NULL) { | 539 if (NewInst == NULL) { |
540 NewInst = Ice::InstCall::create(Func, NumArgs, Dest, CallTarget); | 540 NewInst = Ice::InstCall::create(Func, NumArgs, Dest, CallTarget, |
541 Inst->isTailCall()); | |
541 } | 542 } |
542 for (unsigned i = 0; i < NumArgs; ++i) { | 543 for (unsigned i = 0; i < NumArgs; ++i) { |
543 NewInst->addArg(convertOperand(Inst, i)); | 544 NewInst->addArg(convertOperand(Inst, i)); |
544 } | 545 } |
545 if (Info) { | 546 if (Info) { |
546 validateIntrinsicCall(NewInst, Info); | 547 validateIntrinsicCall(NewInst, Info); |
547 } | 548 } |
548 return NewInst; | 549 return NewInst; |
549 } | 550 } |
550 | 551 |
(...skipping 16 matching lines...) Expand all Loading... | |
567 for (BasicBlock::const_iterator II = BB->begin(), II_e = BB->end(); | 568 for (BasicBlock::const_iterator II = BB->begin(), II_e = BB->end(); |
568 II != II_e; ++II) { | 569 II != II_e; ++II) { |
569 Ice::Inst *Inst = convertInstruction(II); | 570 Ice::Inst *Inst = convertInstruction(II); |
570 Node->appendInst(Inst); | 571 Node->appendInst(Inst); |
571 } | 572 } |
572 return Node; | 573 return Node; |
573 } | 574 } |
574 | 575 |
575 void validateIntrinsicCall(const Ice::InstCall *Call, | 576 void validateIntrinsicCall(const Ice::InstCall *Call, |
576 const Ice::Intrinsics::FullIntrinsicInfo *I) { | 577 const Ice::Intrinsics::FullIntrinsicInfo *I) { |
577 assert(I->NumTypes >= 1); | 578 switch (I->validateCall(Call)) { |
jvoung (off chromium)
2014/09/18 23:43:53
It would be okay to have the index outparam versio
Karl
2014/09/19 20:29:52
Done.
| |
578 if (I->Signature[0] == Ice::IceType_void) { | 579 default: |
579 if (Call->getDest() != NULL) { | 580 report_fatal_error("Unknown validation error for intrinsic call"); |
580 report_fatal_error( | 581 break; |
581 "Return value for intrinsic func w/ void return type."); | 582 case Ice::Intrinsics::IsValidCall: |
582 } | 583 break; |
583 } else { | 584 case Ice::Intrinsics::BadReturnType: { |
584 if (I->Signature[0] != Call->getDest()->getType()) { | 585 std::string Buffer; |
585 report_fatal_error("Mismatched return types."); | 586 raw_string_ostream StrBuf(Buffer); |
586 } | 587 StrBuf << "Intrinsic call expects return type " << I->getReturnType() |
588 << ". Found: " << Call->getReturnType(); | |
589 report_fatal_error(StrBuf.str()); | |
590 break; | |
587 } | 591 } |
588 if (Call->getNumArgs() + 1 != I->NumTypes) { | 592 case Ice::Intrinsics::WrongNumOfArgs: |
589 std::cerr << "Call->getNumArgs() " << (int)Call->getNumArgs() | |
590 << " I->NumTypes " << (int)I->NumTypes << "\n"; | |
591 report_fatal_error("Mismatched # of args."); | 593 report_fatal_error("Mismatched # of args."); |
592 } | 594 break; |
593 for (size_t i = 1; i < I->NumTypes; ++i) { | 595 case Ice::Intrinsics::WrongCallArgType: |
594 if (Call->getArg(i - 1)->getType() != I->Signature[i]) { | 596 report_fatal_error("Mismatched argument type."); |
595 report_fatal_error("Mismatched argument type."); | 597 break; |
596 } | |
597 } | 598 } |
598 } | 599 } |
599 | 600 |
600 private: | 601 private: |
601 // Data | 602 // Data |
602 Ice::GlobalContext *Ctx; | 603 Ice::GlobalContext *Ctx; |
603 Ice::Cfg *Func; | 604 Ice::Cfg *Func; |
604 Ice::CfgNode *CurrentNode; | 605 Ice::CfgNode *CurrentNode; |
605 std::map<const Value *, Ice::Variable *> VarMap; | 606 std::map<const Value *, Ice::Variable *> VarMap; |
606 std::map<const BasicBlock *, Ice::CfgNode *> NodeMap; | 607 std::map<const BasicBlock *, Ice::CfgNode *> NodeMap; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec() | 675 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec() |
675 << " sec\n"; | 676 << " sec\n"; |
676 } | 677 } |
677 translateFcn(Fcn); | 678 translateFcn(Fcn); |
678 } | 679 } |
679 | 680 |
680 emitConstants(); | 681 emitConstants(); |
681 } | 682 } |
682 | 683 |
683 } // end of namespace Ice | 684 } // end of namespace Ice |
OLD | NEW |