| 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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 Ice::Variable *Dest = mapValueToIceVar(Inst); | 548 Ice::Variable *Dest = mapValueToIceVar(Inst); |
| 549 Ice::Operand *CallTarget = convertValue(Inst->getCalledValue()); | 549 Ice::Operand *CallTarget = convertValue(Inst->getCalledValue()); |
| 550 unsigned NumArgs = Inst->getNumArgOperands(); | 550 unsigned NumArgs = Inst->getNumArgOperands(); |
| 551 // Note: Subzero doesn't (yet) do anything special with the Tail | 551 // Note: Subzero doesn't (yet) do anything special with the Tail |
| 552 // flag in the bitcode, i.e. CallInst::isTailCall(). | 552 // flag in the bitcode, i.e. CallInst::isTailCall(). |
| 553 Ice::InstCall *NewInst = nullptr; | 553 Ice::InstCall *NewInst = nullptr; |
| 554 const Ice::Intrinsics::FullIntrinsicInfo *Info = nullptr; | 554 const Ice::Intrinsics::FullIntrinsicInfo *Info = nullptr; |
| 555 | 555 |
| 556 if (const auto Target = dyn_cast<Ice::ConstantRelocatable>(CallTarget)) { | 556 if (const auto Target = dyn_cast<Ice::ConstantRelocatable>(CallTarget)) { |
| 557 // Check if this direct call is to an Intrinsic (starts with "llvm.") | 557 // Check if this direct call is to an Intrinsic (starts with "llvm.") |
| 558 static const char LLVMPrefix[] = "llvm."; | 558 bool BadIntrinsic; |
| 559 const size_t LLVMPrefixLen = strlen(LLVMPrefix); | 559 Info = Ctx->getIntrinsicsInfo().find(Target->getName(), BadIntrinsic); |
| 560 Ice::IceString Name = Target->getName(); | 560 if (BadIntrinsic) { |
| 561 if (Name.substr(0, LLVMPrefixLen) == LLVMPrefix) { | 561 report_fatal_error(std::string("Invalid PNaCl intrinsic call: ") + |
| 562 Ice::IceString NameSuffix = Name.substr(LLVMPrefixLen); | 562 LLVMObjectAsString(Inst)); |
| 563 Info = Ctx->getIntrinsicsInfo().find(NameSuffix); | 563 } |
| 564 if (!Info) { | 564 if (Info) |
| 565 report_fatal_error(std::string("Invalid PNaCl intrinsic call: ") + | |
| 566 LLVMObjectAsString(Inst)); | |
| 567 } | |
| 568 NewInst = Ice::InstIntrinsicCall::create(Func.get(), NumArgs, Dest, | 565 NewInst = Ice::InstIntrinsicCall::create(Func.get(), NumArgs, Dest, |
| 569 CallTarget, Info->Info); | 566 CallTarget, Info->Info); |
| 570 } | |
| 571 } | 567 } |
| 572 | 568 |
| 573 // Not an intrinsic call. | 569 // Not an intrinsic call. |
| 574 if (NewInst == nullptr) { | 570 if (NewInst == nullptr) { |
| 575 NewInst = Ice::InstCall::create(Func.get(), NumArgs, Dest, CallTarget, | 571 NewInst = Ice::InstCall::create(Func.get(), NumArgs, Dest, CallTarget, |
| 576 Inst->isTailCall()); | 572 Inst->isTailCall()); |
| 577 } | 573 } |
| 578 for (unsigned i = 0; i < NumArgs; ++i) { | 574 for (unsigned i = 0; i < NumArgs; ++i) { |
| 579 NewInst->addArg(convertOperand(Inst, i)); | 575 NewInst->addArg(convertOperand(Inst, i)); |
| 580 } | 576 } |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 Ctx->pushTimer(TimerID, StackID); | 902 Ctx->pushTimer(TimerID, StackID); |
| 907 } | 903 } |
| 908 LLVM2ICEFunctionConverter FunctionConverter(*this); | 904 LLVM2ICEFunctionConverter FunctionConverter(*this); |
| 909 FunctionConverter.convertFunction(&I); | 905 FunctionConverter.convertFunction(&I); |
| 910 if (TimeThisFunction) | 906 if (TimeThisFunction) |
| 911 Ctx->popTimer(TimerID, StackID); | 907 Ctx->popTimer(TimerID, StackID); |
| 912 } | 908 } |
| 913 } | 909 } |
| 914 | 910 |
| 915 } // end of namespace Ice | 911 } // end of namespace Ice |
| OLD | NEW |