112 using namespace llvm;
115 #define DEBUG_TYPE "isel" 120 cl::desc(
"Sink local values in FastISel"));
122 STATISTIC(NumFastIselSuccessIndependent,
"Number of insts selected by " 123 "target-independent selector");
124 STATISTIC(NumFastIselSuccessTarget,
"Number of insts selected by " 125 "target-specific selector");
126 STATISTIC(NumFastIselDead,
"Number of dead insts removed on failure");
131 assert(LocalValueMap.empty() &&
132 "local values should be cleared after finishing a BB");
137 EmitStartPt =
nullptr;
138 if (!FuncInfo.MBB->empty())
139 EmitStartPt = &FuncInfo.MBB->back();
140 LastLocalValue = EmitStartPt;
147 if (!FuncInfo.CanLowerReturn)
152 if (!fastLowerArguments())
157 E = FuncInfo.Fn->arg_end();
160 assert(VI != LocalValueMap.
end() &&
"Missed an argument?");
161 FuncInfo.ValueMap[&*
I] = VI->second;
176 RegDef = MO.getReg();
185 void FastISel::flushLocalValueMap() {
195 : FuncInfo.MBB->rend();
196 MachineBasicBlock::reverse_iterator RI(LastLocalValue);
198 InstOrderMap OrderMap;
209 sinkLocalValueMaterialization(LocalMI, DefReg, OrderMap);
213 LocalValueMap.clear();
214 LastLocalValue = EmitStartPt;
216 SavedInsertPt = FuncInfo.InsertPt;
217 LastFlushPoint = FuncInfo.InsertPt;
223 if (
P.second == DefReg)
235 if (!FirstTerminator &&
236 (
I.isTerminator() || (
I.isEHLabel() && &
I != &MBB->front()))) {
237 FirstTerminator = &
I;
238 FirstTerminatorOrder = Order;
240 Orders[&
I] = Order++;
243 if (
I.getIterator() == LastFlushPoint)
248 void FastISel::sinkLocalValueMaterialization(
MachineInstr &LocalMI,
250 InstOrderMap &OrderMap) {
256 if (FuncInfo.RegsWithFixups.count(DefReg))
262 if (!UsedByPHI &&
MRI.use_nodbg_empty(DefReg)) {
263 if (EmitStartPt == &LocalMI)
264 EmitStartPt = EmitStartPt->getPrevNode();
267 OrderMap.Orders.erase(&LocalMI);
274 if (OrderMap.Orders.empty())
275 OrderMap.initialize(FuncInfo.MBB, LastFlushPoint);
281 auto I = OrderMap.Orders.find(&UseInst);
282 assert(
I != OrderMap.Orders.end() &&
283 "local value used by instruction outside local region");
284 unsigned UseOrder =
I->second;
285 if (UseOrder < FirstOrder) {
286 FirstOrder = UseOrder;
287 FirstUser = &UseInst;
295 if (UsedByPHI && OrderMap.FirstTerminatorOrder < FirstOrder) {
296 FirstOrder = OrderMap.FirstTerminatorOrder;
297 SinkPos = OrderMap.FirstTerminator->getIterator();
298 }
else if (FirstUser) {
301 assert(UsedByPHI &&
"must be users if not used by a phi");
302 SinkPos = FuncInfo.MBB->instr_end();
309 if (!DbgVal.isDebugValue())
311 unsigned UseOrder = OrderMap.Orders[&DbgVal];
312 if (UseOrder < FirstOrder)
317 LLVM_DEBUG(
dbgs() <<
"sinking local value to first use " << LocalMI);
318 FuncInfo.MBB->remove(&LocalMI);
319 FuncInfo.MBB->insert(SinkPos, &LocalMI);
320 if (SinkPos != FuncInfo.MBB->end())
325 FuncInfo.MBB->remove(DI);
326 FuncInfo.MBB->insert(SinkPos, DI);
337 if (
const auto *Cast = dyn_cast<CastInst>(I))
338 if (Cast->isNoopCast(DL) && !hasTrivialKill(Cast->getOperand(0)))
344 unsigned Reg = lookUpRegForValue(V);
345 if (Reg && !
MRI.use_empty(Reg))
349 if (
const auto *
GEP = dyn_cast<GetElementPtrInst>(I))
350 if (
GEP->hasAllZeroIndices() && !hasTrivialKill(
GEP->getOperand(0)))
356 !(I->
getOpcode() == Instruction::BitCast ||
357 I->
getOpcode() == Instruction::PtrToInt ||
358 I->
getOpcode() == Instruction::IntToPtr) &&
363 EVT RealVT = TLI.getValueType(DL, V->
getType(),
true);
372 if (!TLI.isTypeLegal(VT)) {
375 VT = TLI.getTypeToTransformTo(V->
getContext(), VT).getSimpleVT();
381 unsigned Reg = lookUpRegForValue(V);
387 if (isa<Instruction>(V) &&
388 (!isa<AllocaInst>(V) ||
389 !FuncInfo.StaticAllocaMap.count(cast<AllocaInst>(V))))
390 return FuncInfo.InitializeRegForValue(V);
392 SavePoint SaveInsertPt = enterLocalValueArea();
396 Reg = materializeRegForValue(V, VT);
398 leaveLocalValueArea(SaveInsertPt);
403 unsigned FastISel::materializeConstant(
const Value *V,
MVT VT) {
405 if (
const auto *CI = dyn_cast<ConstantInt>(V)) {
406 if (CI->getValue().getActiveBits() <= 64)
408 }
else if (isa<AllocaInst>(V))
409 Reg = fastMaterializeAlloca(cast<AllocaInst>(V));
410 else if (isa<ConstantPointerNull>(V))
415 else if (
const auto *CF = dyn_cast<ConstantFP>(V)) {
416 if (CF->isNullValue())
417 Reg = fastMaterializeFloatZero(CF);
424 const APFloat &Flt = CF->getValueAPF();
425 EVT IntVT = TLI.getPointerTy(DL);
427 APSInt SIntVal(IntBitWidth,
false);
431 unsigned IntegerReg =
438 }
else if (
const auto *
Op = dyn_cast<Operator>(V)) {
439 if (!selectOperator(
Op,
Op->getOpcode()))
440 if (!isa<Instruction>(
Op) ||
441 !fastSelectInstruction(cast<Instruction>(
Op)))
443 Reg = lookUpRegForValue(
Op);
444 }
else if (isa<UndefValue>(V)) {
445 Reg = createResultReg(TLI.getRegClassFor(VT));
446 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
447 TII.get(TargetOpcode::IMPLICIT_DEF),
Reg);
455 unsigned FastISel::materializeRegForValue(
const Value *V,
MVT VT) {
458 if (isa<Constant>(V))
459 Reg = fastMaterializeConstant(cast<Constant>(V));
464 Reg = materializeConstant(V, VT);
469 LocalValueMap[V] =
Reg;
470 LastLocalValue =
MRI.getVRegDef(Reg);
481 if (I != FuncInfo.ValueMap.
end())
483 return LocalValueMap[V];
487 if (!isa<Instruction>(I)) {
488 LocalValueMap[
I] =
Reg;
492 unsigned &AssignedReg = FuncInfo.ValueMap[
I];
493 if (AssignedReg == 0)
496 else if (Reg != AssignedReg) {
498 for (
unsigned i = 0; i < NumRegs; i++) {
499 FuncInfo.RegFixups[AssignedReg + i] = Reg + i;
500 FuncInfo.RegsWithFixups.insert(Reg + i);
508 unsigned IdxN = getRegForValue(Idx);
511 return std::pair<unsigned, bool>(0,
false);
513 bool IdxNIsKill = hasTrivialKill(Idx);
516 MVT PtrVT = TLI.getPointerTy(DL);
518 if (IdxVT.
bitsLT(PtrVT)) {
522 }
else if (IdxVT.
bitsGT(PtrVT)) {
527 return std::pair<unsigned, bool>(IdxN, IdxNIsKill);
531 if (getLastLocalValue()) {
532 FuncInfo.InsertPt = getLastLocalValue();
533 FuncInfo.MBB = FuncInfo.InsertPt->getParent();
536 FuncInfo.InsertPt = FuncInfo.MBB->getFirstNonPHI();
539 while (FuncInfo.InsertPt != FuncInfo.MBB->end() &&
547 "Invalid iterator!");
549 if (LastFlushPoint == I)
551 if (SavedInsertPt == I)
553 if (EmitStartPt == I)
554 EmitStartPt = E.
isValid() ? &*
E :
nullptr;
555 if (LastLocalValue == I)
556 LastLocalValue = E.
isValid() ? &*
E :
nullptr;
576 if (FuncInfo.InsertPt != FuncInfo.MBB->begin())
577 LastLocalValue = &*std::prev(FuncInfo.InsertPt);
580 FuncInfo.InsertPt = OldInsertPt.
InsertPt;
581 DbgLoc = OldInsertPt.
DL;
594 if (!TLI.isTypeLegal(VT)) {
599 VT = TLI.getTypeToTransformTo(I->
getContext(), VT);
606 if (
const auto *CI = dyn_cast<ConstantInt>(I->
getOperand(0)))
607 if (isa<Instruction>(I) && cast<Instruction>(
I)->
isCommutative()) {
608 unsigned Op1 = getRegForValue(I->
getOperand(1));
611 bool Op1IsKill = hasTrivialKill(I->
getOperand(1));
614 fastEmit_ri_(VT.
getSimpleVT(), ISDOpcode, Op1, Op1IsKill,
620 updateValueMap(I, ResultReg);
624 unsigned Op0 = getRegForValue(I->
getOperand(0));
627 bool Op0IsKill = hasTrivialKill(I->
getOperand(0));
630 if (
const auto *CI = dyn_cast<ConstantInt>(I->
getOperand(1))) {
631 uint64_t Imm = CI->getSExtValue();
634 if (ISDOpcode ==
ISD::SDIV && isa<BinaryOperator>(I) &&
641 if (ISDOpcode ==
ISD::UREM && isa<BinaryOperator>(I) &&
647 unsigned ResultReg = fastEmit_ri_(VT.
getSimpleVT(), ISDOpcode, Op0,
653 updateValueMap(I, ResultReg);
657 unsigned Op1 = getRegForValue(I->
getOperand(1));
660 bool Op1IsKill = hasTrivialKill(I->
getOperand(1));
664 ISDOpcode, Op0, Op0IsKill, Op1, Op1IsKill);
671 updateValueMap(I, ResultReg);
679 bool NIsKill = hasTrivialKill(I->
getOperand(0));
683 uint64_t TotalOffs = 0;
685 uint64_t MaxOffs = 2048;
686 MVT VT = TLI.getPointerTy(DL);
689 const Value *Idx = GTI.getOperand();
690 if (
StructType *StTy = GTI.getStructTypeOrNull()) {
691 uint64_t
Field = cast<ConstantInt>(Idx)->getZExtValue();
694 TotalOffs += DL.getStructLayout(StTy)->getElementOffset(Field);
695 if (TotalOffs >= MaxOffs) {
696 N = fastEmit_ri_(VT,
ISD::ADD, N, NIsKill, TotalOffs, VT);
704 Type *Ty = GTI.getIndexedType();
707 if (
const auto *CI = dyn_cast<ConstantInt>(Idx)) {
711 uint64_t IdxN = CI->getValue().sextOrTrunc(64).getSExtValue();
712 TotalOffs += DL.getTypeAllocSize(Ty) * IdxN;
713 if (TotalOffs >= MaxOffs) {
714 N = fastEmit_ri_(VT,
ISD::ADD, N, NIsKill, TotalOffs, VT);
723 N = fastEmit_ri_(VT,
ISD::ADD, N, NIsKill, TotalOffs, VT);
731 uint64_t ElementSize = DL.getTypeAllocSize(Ty);
732 std::pair<unsigned, bool> Pair = getRegForGEPIndex(Idx);
733 unsigned IdxN = Pair.first;
734 bool IdxNIsKill = Pair.second;
738 if (ElementSize != 1) {
739 IdxN = fastEmit_ri_(VT,
ISD::MUL, IdxN, IdxNIsKill, ElementSize, VT);
744 N = fastEmit_rr(VT, VT,
ISD::ADD, N, NIsKill, IdxN, IdxNIsKill);
750 N = fastEmit_ri_(VT,
ISD::ADD, N, NIsKill, TotalOffs, VT);
756 updateValueMap(I, N);
761 const CallInst *CI,
unsigned StartIdx) {
765 if (
const auto *
C = dyn_cast<ConstantInt>(Val)) {
768 }
else if (isa<ConstantPointerNull>(Val)) {
771 }
else if (
auto *AI = dyn_cast<AllocaInst>(Val)) {
775 auto SI = FuncInfo.StaticAllocaMap.find(AI);
776 if (
SI != FuncInfo.StaticAllocaMap.end())
781 unsigned Reg = getRegForValue(Val);
794 "Stackmap cannot return a value.");
810 "Expected a constant integer.");
815 "Expected a constant integer.");
816 const auto *NumBytes =
830 const MCPhysReg *ScratchRegs = TLI.getScratchRegisters(CC);
831 for (
unsigned i = 0; ScratchRegs[i]; ++i)
833 ScratchRegs[i],
true,
true,
false,
834 false,
false,
true));
837 unsigned AdjStackDown =
TII.getCallFrameSetupOpcode();
839 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(AdjStackDown));
840 const MCInstrDesc &MCID = Builder.getInstr()->getDesc();
841 for (
unsigned I = 0,
E = MCID.getNumOperands(); I <
E; ++
I)
846 TII.get(TargetOpcode::STACKMAP));
847 for (
auto const &MO : Ops)
851 unsigned AdjStackUp =
TII.getCallFrameDestroyOpcode();
852 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(AdjStackUp))
867 bool FastISel::lowerCallOperands(
const CallInst *CI,
unsigned ArgIdx,
871 Args.reserve(NumArgs);
875 for (
unsigned ArgI = ArgIdx, ArgE = ArgIdx + NumArgs; ArgI != ArgE; ++ArgI) {
883 Entry.setAttributes(&CS, ArgI);
884 Args.push_back(Entry);
891 return lowerCallTo(CLI);
900 return setCallee(CC, ResultTy, Sym, std::move(ArgsList), FixedArgs);
917 "Expected a constant integer.");
918 const auto *NumArgsVal =
920 unsigned NumArgs = NumArgsVal->getZExtValue();
926 "Not enough arguments provided to the patchpoint intrinsic");
929 unsigned NumCallArgs = IsAnyRegCC ? 0 : NumArgs;
932 if (!lowerCallOperands(I, NumMetaOpers, NumCallArgs, Callee, IsAnyRegCC, CLI))
935 assert(CLI.
Call &&
"No call instruction specified.");
940 if (IsAnyRegCC && HasDef) {
949 "Expected a constant integer.");
954 "Expected a constant integer.");
955 const auto *NumBytes =
960 if (
const auto *
C = dyn_cast<IntToPtrInst>(Callee)) {
961 uint64_t CalleeConstAddr =
962 cast<ConstantInt>(
C->
getOperand(0))->getZExtValue();
964 }
else if (
const auto *
C = dyn_cast<ConstantExpr>(Callee)) {
965 if (
C->
getOpcode() == Instruction::IntToPtr) {
966 uint64_t CalleeConstAddr =
967 cast<ConstantInt>(
C->
getOperand(0))->getZExtValue();
971 }
else if (
const auto *GV = dyn_cast<GlobalValue>(Callee)) {
973 }
else if (isa<ConstantPointerNull>(Callee))
980 unsigned NumCallRegArgs = IsAnyRegCC ? NumArgs : CLI.
OutRegs.size();
989 for (
unsigned i = NumMetaOpers,
e = NumMetaOpers + NumArgs; i !=
e; ++i) {
1007 TRI.getCallPreservedMask(*FuncInfo.MF, CC)));
1010 const MCPhysReg *ScratchRegs = TLI.getScratchRegisters(CC);
1011 for (
unsigned i = 0; ScratchRegs[i]; ++i)
1013 ScratchRegs[i],
true,
true,
false,
1014 false,
false,
true));
1023 TII.get(TargetOpcode::PATCHPOINT));
1025 for (
auto &MO : Ops)
1034 FuncInfo.MF->getFrameInfo().setHasPatchPoint();
1042 const auto &
Triple =
TM.getTargetTriple();
1051 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1052 TII.get(TargetOpcode::PATCHABLE_EVENT_CALL));
1053 for (
auto &MO : Ops)
1061 const auto &
Triple =
TM.getTargetTriple();
1072 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1073 TII.get(TargetOpcode::PATCHABLE_TYPED_EVENT_CALL));
1074 for (
auto &MO : Ops)
1102 return lowerCallTo(CI, Sym, NumArgs);
1113 Args.reserve(NumArgs);
1117 for (
unsigned ArgI = 0; ArgI != NumArgs; ++ArgI) {
1125 Entry.setAttributes(&CS, ArgI);
1126 Args.push_back(Entry);
1131 CLI.
setCallee(RetTy, FTy, Symbol, std::move(Args), CS, NumArgs);
1133 return lowerCallTo(CLI);
1145 bool CanLowerReturn = TLI.CanLowerReturn(
1149 if (!CanLowerReturn)
1152 for (
unsigned I = 0,
E = RetTys.
size();
I !=
E; ++
I) {
1156 for (
unsigned i = 0; i != NumRegs; ++i) {
1158 MyFlags.
VT = RegisterVT;
1167 CLI.
Ins.push_back(MyFlags);
1176 FinalType = cast<PointerType>(
Arg.Ty)->getElementType();
1177 bool NeedsRegBlock = TLI.functionArgumentNeedsConsecutiveRegisters(
1189 if (
Arg.IsSwiftSelf)
1191 if (
Arg.IsSwiftError)
1193 if (
Arg.IsCFGuardTarget)
1197 if (
Arg.IsInAlloca) {
1206 if (
Arg.IsByVal ||
Arg.IsInAlloca) {
1209 unsigned FrameSize =
1210 DL.getTypeAllocSize(
Arg.ByValType ?
Arg.ByValType : ElementTy);
1214 unsigned FrameAlign =
Arg.Alignment;
1216 FrameAlign = TLI.getByValTypeAlignment(ElementTy, DL);
1230 if (!fastLowerCall(CLI))
1234 assert(CLI.
Call &&
"No call instruction specified.");
1271 Args.push_back(Entry);
1279 if (IsTailCall && MF->getFunction()
1280 .getFnAttribute(
"disable-tail-calls")
1281 .getValueAsString() ==
"true")
1286 .setTailCall(IsTailCall);
1288 return lowerCallTo(CLI);
1292 const CallInst *Call = cast<CallInst>(
I);
1298 if (IA->hasSideEffects())
1299 flushLocalValueMap();
1302 if (!IA->getConstraintString().empty())
1305 unsigned ExtraInfo = 0;
1306 if (IA->hasSideEffects())
1308 if (IA->isAlignStack())
1312 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1314 .addExternalSymbol(IA->getAsmString().c_str())
1320 if (
const auto *II = dyn_cast<IntrinsicInst>(Call))
1321 return selectIntrinsicCall(II);
1330 flushLocalValueMap();
1332 return lowerCall(Call);
1340 case Intrinsic::lifetime_start:
1341 case Intrinsic::lifetime_end:
1343 case Intrinsic::donothing:
1345 case Intrinsic::sideeffect:
1347 case Intrinsic::assume:
1349 case Intrinsic::dbg_declare: {
1352 if (!FuncInfo.MF->getMMI().hasDebugInfo()) {
1358 if (!Address || isa<UndefValue>(Address)) {
1367 if (
Arg && FuncInfo.getArgumentFrameIndex(
Arg) != INT_MAX)
1371 if (
unsigned Reg = lookUpRegForValue(Address))
1385 if (!Op && !Address->
use_empty() && isa<Instruction>(Address) &&
1386 (!isa<AllocaInst>(Address) ||
1387 !FuncInfo.StaticAllocaMap.count(cast<AllocaInst>(Address))))
1393 "Expected inlined-at fields to agree");
1396 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1397 TII.get(TargetOpcode::DBG_VALUE),
true,
1406 case Intrinsic::dbg_value: {
1412 "Expected inlined-at fields to agree");
1416 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II,
false, 0U,
1418 }
else if (
const auto *CI = dyn_cast<ConstantInt>(V)) {
1419 if (CI->getBitWidth() > 64)
1420 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
1426 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
1427 .
addImm(CI->getZExtValue())
1431 }
else if (
const auto *CF = dyn_cast<ConstantFP>(V)) {
1432 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
1437 }
else if (
unsigned Reg = lookUpRegForValue(V)) {
1439 bool IsIndirect =
false;
1440 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, IsIndirect,
Reg,
1449 case Intrinsic::dbg_label: {
1452 if (!FuncInfo.MF->getMMI().hasDebugInfo()) {
1457 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1458 TII.get(TargetOpcode::DBG_LABEL)).addMetadata(DI->
getLabel());
1461 case Intrinsic::objectsize:
1464 case Intrinsic::is_constant:
1467 case Intrinsic::launder_invariant_group:
1468 case Intrinsic::strip_invariant_group:
1469 case Intrinsic::expect: {
1473 updateValueMap(II, ResultReg);
1476 case Intrinsic::experimental_stackmap:
1477 return selectStackmap(II);
1478 case Intrinsic::experimental_patchpoint_void:
1479 case Intrinsic::experimental_patchpoint_i64:
1480 return selectPatchpoint(II);
1482 case Intrinsic::xray_customevent:
1483 return selectXRayCustomEvent(II);
1484 case Intrinsic::xray_typedevent:
1485 return selectXRayTypedEvent(II);
1488 return fastLowerIntrinsicCall(II);
1493 EVT DstVT = TLI.getValueType(DL, I->
getType());
1501 if (!TLI.isTypeLegal(DstVT))
1505 if (!TLI.isTypeLegal(SrcVT))
1508 unsigned InputReg = getRegForValue(I->
getOperand(0));
1513 bool InputRegIsKill = hasTrivialKill(I->
getOperand(0));
1516 Opcode, InputReg, InputRegIsKill);
1520 updateValueMap(I, ResultReg);
1530 updateValueMap(I, Reg);
1536 EVT DstEVT = TLI.getValueType(DL, I->
getType());
1538 !TLI.isTypeLegal(SrcEVT) || !TLI.isTypeLegal(DstEVT))
1544 unsigned Op0 = getRegForValue(I->
getOperand(0));
1547 bool Op0IsKill = hasTrivialKill(I->
getOperand(0));
1550 unsigned ResultReg = 0;
1551 if (SrcVT == DstVT) {
1555 if (SrcClass == DstClass) {
1556 ResultReg = createResultReg(DstClass);
1557 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1558 TII.get(TargetOpcode::COPY), ResultReg).addReg(Op0);
1564 ResultReg = fastEmit_r(SrcVT, DstVT,
ISD::BITCAST, Op0, Op0IsKill);
1569 updateValueMap(I, ResultReg);
1575 void FastISel::removeDeadLocalValueCode(
MachineInstr *SavedLastLocalValue)
1578 if (CurLastLocalValue != SavedLastLocalValue) {
1583 if (SavedLastLocalValue)
1586 FirstDeadInst = FuncInfo.MBB->getFirstNonPHI();
1587 setLastLocalValue(SavedLastLocalValue);
1588 removeDeadCode(FirstDeadInst, FuncInfo.InsertPt);
1593 MachineInstr *SavedLastLocalValue = getLastLocalValue();
1597 if (!handlePHINodesInSuccessorBlocks(I->
getParent())) {
1602 removeDeadLocalValueCode(SavedLastLocalValue);
1609 for (
unsigned i = 0,
e = CS.getNumOperandBundles(); i !=
e; ++i)
1615 SavedInsertPt = FuncInfo.InsertPt;
1617 if (
const auto *Call = dyn_cast<CallInst>(I)) {
1618 const Function *
F = Call->getCalledFunction();
1624 LibInfo->getLibFunc(F->
getName(), Func) &&
1625 LibInfo->hasOptimizedCodeGen(Func))
1630 Call->hasFnAttr(
"trap-func-name"))
1635 if (!SkipTargetIndependentISel) {
1636 if (selectOperator(I, I->
getOpcode())) {
1637 ++NumFastIselSuccessIndependent;
1642 recomputeInsertPt();
1643 if (SavedInsertPt != FuncInfo.InsertPt)
1644 removeDeadCode(FuncInfo.InsertPt, SavedInsertPt);
1645 SavedInsertPt = FuncInfo.InsertPt;
1648 if (fastSelectInstruction(I)) {
1649 ++NumFastIselSuccessTarget;
1654 recomputeInsertPt();
1655 if (SavedInsertPt != FuncInfo.InsertPt)
1656 removeDeadCode(FuncInfo.InsertPt, SavedInsertPt);
1663 removeDeadLocalValueCode(SavedLastLocalValue);
1664 FuncInfo.PHINodesToUpdate.resize(FuncInfo.OrigNumPHINodesToUpdate);
1673 if (FuncInfo.MBB->getBasicBlock()->sizeWithoutDebug() > 1 &&
1674 FuncInfo.MBB->isLayoutSuccessor(MSucc)) {
1688 FuncInfo.MBB->addSuccessorWithoutProb(MSucc);
1697 if (TrueMBB != FalseMBB) {
1700 FuncInfo.BPI->getEdgeProbability(BranchBB, TrueMBB->
getBasicBlock());
1703 FuncInfo.MBB->addSuccessorWithoutProb(TrueMBB);
1706 fastEmitBranch(FalseMBB, DbgLoc);
1711 unsigned OpReg = getRegForValue(In);
1714 bool OpRegIsKill = hasTrivialKill(In);
1719 OpReg, OpRegIsKill);
1721 updateValueMap(I, ResultReg);
1730 if (!TLI.isTypeLegal(IntVT))
1738 unsigned IntResultReg = fastEmit_ri_(
1745 IntResultReg,
true);
1749 updateValueMap(I, ResultReg);
1760 EVT RealVT = TLI.getValueType(DL, EVI->
getType(),
true);
1764 if (!TLI.isTypeLegal(VT) && VT !=
MVT::i1)
1773 if (I != FuncInfo.ValueMap.
end())
1774 ResultReg = I->second;
1775 else if (isa<Instruction>(Op0))
1776 ResultReg = FuncInfo.InitializeRegForValue(Op0);
1786 for (
unsigned i = 0; i < VTIndex; i++)
1787 ResultReg += TLI.getNumRegisters(FuncInfo.Fn->getContext(), AggValueVTs[i]);
1789 updateValueMap(EVI, ResultReg);
1797 case Instruction::FAdd:
1799 case Instruction::Sub:
1801 case Instruction::FSub: {
1805 return selectFNeg(I, X);
1808 case Instruction::Mul:
1810 case Instruction::FMul:
1812 case Instruction::SDiv:
1814 case Instruction::UDiv:
1816 case Instruction::FDiv:
1818 case Instruction::SRem:
1820 case Instruction::URem:
1822 case Instruction::FRem:
1824 case Instruction::Shl:
1826 case Instruction::LShr:
1828 case Instruction::AShr:
1830 case Instruction::And:
1832 case Instruction::Or:
1834 case Instruction::Xor:
1837 case Instruction::FNeg:
1840 case Instruction::GetElementPtr:
1841 return selectGetElementPtr(I);
1843 case Instruction::Br: {
1858 case Instruction::Unreachable:
1859 if (
TM.Options.TrapUnreachable)
1864 case Instruction::Alloca:
1866 if (FuncInfo.StaticAllocaMap.count(cast<AllocaInst>(I)))
1878 if (
TM.getTargetTriple().isOSAIX())
1880 return selectCall(I);
1882 case Instruction::BitCast:
1883 return selectBitCast(I);
1885 case Instruction::FPToSI:
1887 case Instruction::ZExt:
1889 case Instruction::SExt:
1891 case Instruction::Trunc:
1893 case Instruction::SIToFP:
1896 case Instruction::IntToPtr:
1897 case Instruction::PtrToInt: {
1899 EVT DstVT = TLI.getValueType(DL, I->
getType());
1907 updateValueMap(I, Reg);
1911 case Instruction::ExtractValue:
1912 return selectExtractValue(I);
1914 case Instruction::PHI:
1925 bool SkipTargetIndependentISel)
1926 : FuncInfo(FuncInfo), MF(FuncInfo.MF),
MRI(FuncInfo.MF->getRegInfo()),
1927 MFI(FuncInfo.MF->getFrameInfo()), MCP(*FuncInfo.MF->getConstantPool()),
1928 TM(FuncInfo.MF->getTarget()), DL(MF->getDataLayout()),
1929 TII(*MF->getSubtarget().getInstrInfo()),
1930 TLI(*MF->getSubtarget().getTargetLowering()),
1931 TRI(*MF->getSubtarget().getRegisterInfo()), LibInfo(LibInfo),
1932 SkipTargetIndependentISel(SkipTargetIndependentISel),
1933 LastLocalValue(nullptr), EmitStartPt(nullptr) {}
1977 bool Op0IsKill, uint64_t Imm,
MVT ImmType) {
1995 unsigned ResultReg =
fastEmit_ri(VT, VT, Opcode, Op0, Op0IsKill, Imm);
1999 bool IsImmKill =
true;
2016 return fastEmit_rr(VT, VT, Opcode, Op0, Op0IsKill, MaterialReg, IsImmKill);
2033 TII.
get(TargetOpcode::COPY), NewOp).addReg(Op);
2072 bool Op0IsKill,
unsigned Op1,
2096 bool Op0IsKill,
unsigned Op1,
2097 bool Op1IsKill,
unsigned Op2,
2124 bool Op0IsKill, uint64_t Imm) {
2146 bool Op0IsKill, uint64_t Imm1,
2190 bool Op0IsKill,
unsigned Op1,
2191 bool Op1IsKill, uint64_t Imm) {
2234 "Cannot yet extract from physregs");
2254 bool FastISel::handlePHINodesInSuccessorBlocks(
const BasicBlock *LLVMBB) {
2264 if (!isa<PHINode>(SuccBB->
begin()))
2270 if (!SuccsHandled.
insert(SuccMBB).second)
2298 const Value *PHIOp = PN.getIncomingValueForBlock(LLVMBB);
2302 DbgLoc = PN.getDebugLoc();
2303 if (
const auto *Inst = dyn_cast<Instruction>(PHIOp))
2304 DbgLoc = Inst->getDebugLoc();
2321 "tryToFoldLoad expected a LoadInst with a single use");
2325 unsigned MaxUsers = 6;
2328 while (TheUser != FoldInst &&
2341 if (TheUser != FoldInst)
2377 if (!isa<AddOperator>(Add))
2384 if (isa<Instruction>(Add) &&
2388 return isa<ConstantInt>(cast<AddOperator>(
Add)->getOperand(1));
2399 if (
const auto *LI = dyn_cast<LoadInst>(I)) {
2400 Alignment = LI->getAlignment();
2401 IsVolatile = LI->isVolatile();
2403 Ptr = LI->getPointerOperand();
2404 ValTy = LI->getType();
2405 }
else if (
const auto *
SI = dyn_cast<StoreInst>(I)) {
2406 Alignment =
SI->getAlignment();
2407 IsVolatile =
SI->isVolatile();
2409 Ptr =
SI->getPointerOperand();
2410 ValTy =
SI->getValueOperand()->getType();
2414 bool IsNonTemporal = I->
hasMetadata(LLVMContext::MD_nontemporal);
2415 bool IsInvariant = I->
hasMetadata(LLVMContext::MD_invariant_load);
2416 bool IsDereferenceable = I->
hasMetadata(LLVMContext::MD_dereferenceable);
2431 if (IsDereferenceable)
2437 Alignment, AAInfo, Ranges);
2446 switch (Predicate) {
void setHasStackMap(bool s=true)
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
unsigned fastEmitInst_rrr(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill, unsigned Op2, bool Op2IsKill)
Emit a MachineInstr with three register operands and a result register in the given register class...
const MachineInstrBuilder & addMetadata(const MDNode *MD) const
const MachineInstrBuilder & add(const MachineOperand &MO) const
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
This class is the base class for the comparison instructions.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
unsigned fastEmitZExtFromI1(MVT VT, unsigned Op0, bool Op0IsKill)
Emit MachineInstrs to compute the value of Op with all but the least significant bit set to zero...
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
bool hasLocalLinkage() const
This class represents an incoming formal argument to a Function.
bool lowerCall(const CallInst *I)
This represents the llvm.dbg.label instruction.
This class represents lattice values for constants.
unsigned OrigNumPHINodesToUpdate
bool selectFNeg(const User *I, const Value *In)
Emit an FNeg operation.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
BasicBlock * getSuccessor(unsigned Idx) const
Return the specified successor. This instruction must be a terminator.
constexpr char IsVolatile[]
Key for Kernel::Arg::Metadata::mIsVolatile.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool selectXRayTypedEvent(const CallInst *II)
bool selectGetElementPtr(const User *I)
void setHeapAllocMarker(MachineFunction &MF, MDNode *MD)
Set a marker on instructions that denotes where we should create and emit heap alloc site labels...
void leaveLocalValueArea(SavePoint Old)
Reset InsertPt to the given old insert position.
void push_back(const T &Elt)
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
Describe properties that are true of each instruction in the target description file.
bool selectStackmap(const CallInst *I)
This class represents a function call, abstracting a target machine's calling convention.
virtual bool tryToFoldLoadIntoMI(MachineInstr *, unsigned, const LoadInst *)
The specified machine instr operand is a vreg, and that vreg is being provided by the specified load ...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
gep_type_iterator gep_type_end(const User *GEP)
0 1 0 0 True if ordered and less than
MachineMemOperand * createMachineMemOperandFor(const Instruction *I) const
Create a machine mem operand from the given instruction.
LLVMContext & getContext() const
All values hold a context through their type.
bool isTerminator() const
1 1 1 0 True if unordered or not equal
virtual unsigned fastEmit_(MVT VT, MVT RetVT, unsigned Opcode)
This method is called by target-independent code to request that an instruction with the given type a...
BasicBlock * getSuccessor(unsigned i) const
void setInConsecutiveRegs()
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
An instruction for reading from memory.
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
void setAttributes(const CallBase *Call, unsigned ArgIdx)
Set CallLoweringInfo attribute flags based on a call instruction and called function attributes...
virtual unsigned fastEmit_i(MVT VT, MVT RetVT, unsigned Opcode, uint64_t Imm)
This method is called by target-independent code to request that an instruction with the given type...
iterator_range< mop_iterator > operands()
FunctionType * getFunctionType() const
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
virtual bool fastLowerCall(CallLoweringInfo &CLI)
This method is called by target-independent code to do target- specific call lowering.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
iterator begin()
Instruction iterator methods.
bool selectInstruction(const Instruction *I)
Do "fast" instruction selection for the given LLVM IR instruction and append the generated machine in...
Value * getArgOperand(unsigned i) const
unsigned fastEmitInst_rii(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, uint64_t Imm1, uint64_t Imm2)
Emit a MachineInstr with one register operand and two immediate operands.
opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
1 0 0 1 True if unordered or equal
bool match(Val *V, const Pattern &P)
unsigned fastEmitInst_ri(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, uint64_t Imm)
Emit a MachineInstr with a register operand, an immediate, and a result register in the given registe...
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
unsigned fastEmitInst_rri(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill, uint64_t Imm)
Emit a MachineInstr with two register operands, an immediate, and a result register in the given regi...
CmpInst::Predicate optimizeCmpPredicate(const CmpInst *CI) const
bool isVolatile() const
Return true if this is a load from a volatile memory location.
A description of a memory reference used in the backend.
const HexagonInstrInfo * TII
TargetLoweringBase::ArgListTy ArgListTy
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset, unsigned TargetFlags=0)
Shift and rotation operations.
virtual const TargetRegisterClass * getRegClass(const MCInstrDesc &MCID, unsigned OpNum, const TargetRegisterInfo *TRI, const MachineFunction &MF) const
Given a machine instruction descriptor, returns the register class constraint for OpNum...
Class to represent struct types.
A Use represents the edge between a Value definition and its users.
DILabel * getLabel() const
bool canFoldAddIntoGEP(const User *GEP, const Value *Add)
Check if Add is an add that can be safely folded into GEP.
MachineBasicBlock iterator that automatically skips over MIs that are inside bundles (i...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
unsigned fastEmitInst_r(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill)
Emit a MachineInstr with one register operand and a result register in the given register class...
0 1 0 1 True if ordered and less than or equal
This file contains the simple types necessary to represent the attributes associated with functions a...
The memory access is dereferenceable (i.e., doesn't trap).
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
static MachineOperand CreateRegMask(const uint32_t *Mask)
CreateRegMask - Creates a register mask operand referencing Mask.
virtual const TargetRegisterClass * getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const
Returns the largest legal sub-class of RC that supports the sub-register index Idx.
void setByValSize(unsigned S)
Type * getType() const
Return the type of the instruction that generated this call site.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
INLINEASM - Represents an inline asm block.
bool selectIntrinsicCall(const IntrinsicInst *II)
bool selectCast(const User *I, unsigned Opcode)
Context object for machine code objects.
InstrTy * getInstruction() const
Class to represent function types.
SmallVector< ISD::InputArg, 4 > Ins
Type * getType() const
All values are typed, get the type of this value.
unsigned constrainOperandRegClass(const MCInstrDesc &II, unsigned Op, unsigned OpNum)
Try to constrain Op so that it is usable by argument OpNum of the provided MCInstrDesc.
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
bool selectOperator(const User *I, unsigned Opcode)
Do "fast" instruction selection for the given LLVM IR operator (Instruction or ConstantExpr), and append generated machine instructions to the current block.
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
MachineInstrBundleIterator< MachineInstr, true > reverse_iterator
bool selectExtractValue(const User *U)
unsigned getRegForValue(const Value *V)
Create a virtual register and arrange for it to be assigned the value for the given LLVM value...
Simple integer binary arithmetic operators.
unsigned fastEmitInst_(unsigned MachineInstOpcode, const TargetRegisterClass *RC)
Emit a MachineInstr with no operands and a result register in the given register class.
const MachineInstrBuilder & addFPImm(const ConstantFP *Val) const
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
bool hasTrivialKill(const Value *V)
Test whether the given value has exactly one use.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
unsigned getNumSuccessors() const
Return the number of successors that this instruction has.
Value * getOperand(unsigned i) const
Class to represent pointers.
unsigned getKillRegState(bool B)
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
unsigned lookUpRegForValue(const Value *V)
Look up the value to see if its value is already cached in a register.
void finishBasicBlock()
Flush the local value map and sink local values if possible.
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
bool isVoidTy() const
Return true if this is 'void'.
The memory access is volatile.
static unsigned selectBinaryOp(unsigned GenericOpc, unsigned RegBankID, unsigned OpSize)
Select the AArch64 opcode for the basic binary operation GenericOpc (such as G_OR or G_SDIV)...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
void getAAMetadata(AAMDNodes &N, bool Merge=false) const
Fills the AAMDNodes structure with AA metadata from this instruction.
initializer< Ty > init(const Ty &Val)
Type * getReturnType() const
Returns the type of the ret val.
SmallVector< Register, 16 > OutRegs
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
std::vector< std::pair< MachineInstr *, unsigned > > PHINodesToUpdate
PHINodesToUpdate - A list of phi instructions whose operand list will be updated after processing the...
unsigned const MachineRegisterInfo * MRI
CallLoweringInfo & setCallee(Type *ResultTy, FunctionType *FuncTy, const Value *Target, ArgListTy &&ArgsList, ImmutableCallSite &Call)
Value * getCalledValue() const
LLVM Basic Block Representation.
const MachineInstrBuilder & addCImm(const ConstantInt *Val) const
The instances of the Type class are immutable: once they are created, they are never changed...
Simple binary floating point operators.
Conditional or Unconditional Branch instruction.
Value * getAddress() const
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void removeDeadCode(MachineBasicBlock::iterator I, MachineBasicBlock::iterator E)
Remove all dead instructions between the I and E.
SmallVector< ISD::ArgFlagsTy, 16 > OutFlags
This file contains the declarations for the subclasses of Constant, which represent the different fla...
void setByValAlign(Align A)
ConstantFP - Floating Point Values [float, double].
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
const MCPhysReg * ImplicitDefs
DIExpression * getExpression() const
virtual unsigned fastEmit_r(MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0, bool Op0IsKill)
This method is called by target-independent code to request that an instruction with the given type...
bool isValidLocationForIntrinsic(const DILocation *DL) const
Check that a location is valid for this variable.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static Type * getVoidTy(LLVMContext &C)
bool tryToFoldLoad(const LoadInst *LI, const Instruction *FoldInst)
We're checking to see if we can fold LI into FoldInst.
bool lowerArguments()
Do "fast" instruction selection for function arguments and append the machine instructions to the cur...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
std::pair< unsigned, bool > getRegForGEPIndex(const Value *Idx)
This is a wrapper around getRegForValue that also takes care of truncating or sign-extending the give...
TRAP - Trapping instruction.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
bool isValid() const
Check for null.
0 1 1 1 True if ordered (no nans)
self_iterator getIterator()
The memory access is non-temporal.
Class to represent integer types.
bool selectXRayCustomEvent(const CallInst *II)
const TargetRegisterInfo & TRI
1 1 1 1 Always true (always folded)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
static unsigned findSinkableLocalRegDef(MachineInstr &MI)
Return the defined register if this instruction defines exactly one virtual register and uses no othe...
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
This class contains a discriminated union of information about pointers in memory operands...
1 1 0 1 True if unordered, less than, or equal
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
SmallVector< Value *, 16 > OutVals
static AttributeList getReturnAttrs(FastISel::CallLoweringInfo &CLI)
Returns an AttributeList representing the attributes applied to the return value of the given call...
const TargetInstrInfo & TII
MachineBasicBlock * MBB
MBB - The current block.
bool isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM)
Test if the given instruction is in a position to be optimized with a tail-call.
Triple - Helper class for working with autoconf configuration names.
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
void recomputeInsertPt()
Reset InsertPt to prepare for inserting instructions into the current block.
The memory access writes data.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
void GetReturnInfo(CallingConv::ID CC, Type *ReturnType, AttributeList attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI, const DataLayout &DL)
Given an LLVM IR type and return type attributes, compute the return value EVTs and flags...
0 0 1 0 True if ordered and greater than
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
void setOrigAlign(Align A)
virtual unsigned fastEmit_rr(MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill)
This method is called by target-independent code to request that an instruction with the given type...
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Align max(MaybeAlign Lhs, Align Rhs)
virtual unsigned fastEmit_ri(MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0, bool Op0IsKill, uint64_t Imm)
This method is called by target-independent code to request that an instruction with the given type...
MachineOperand class - Representation of each machine instruction operand.
1 1 0 0 True if unordered or less than
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool selectCall(const User *I)
Instruction * user_back()
Specialize the methods defined in Value, as we know that an instruction can only be used by other ins...
Provides information about what library functions are available for the current target.
unsigned arg_size() const
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
void finishCondBranch(const BasicBlock *BranchBB, MachineBasicBlock *TrueMBB, MachineBasicBlock *FalseMBB)
Emit an unconditional branch to FalseMBB, obtains the branch weight and adds TrueMBB and FalseMBB to ...
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
bool isOSLinux() const
Tests whether the OS is Linux.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
reg_iterator reg_begin(unsigned RegNo) const
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
Insert branch code into the end of the specified MachineBasicBlock.
unsigned fastEmitInst_rr(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill)
Emit a MachineInstr with two register operands and a result register in the given register class...
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
void updateValueMap(const Value *I, unsigned Reg, unsigned NumRegs=1)
Update the value map to include the new mapping for this instruction, or insert an extra copy to get ...
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
void startNewBlock()
Set the current block to which generated machine instructions will be appended.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool selectBitCast(const User *I)
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
Target - Wrapper for Target specific information.
virtual unsigned fastEmit_f(MVT VT, MVT RetVT, unsigned Opcode, const ConstantFP *FPImm)
This method is called by target-independent code to request that an instruction with the given type...
bool selectBinaryOp(const User *I, unsigned ISDOpcode)
Select and emit code for a binary operator instruction, which has an opcode which directly correspond...
void setDebugLoc(DebugLoc dl)
Replace current source information with new such.
amdgpu Simplify well known AMD library false FunctionCallee Callee
This file defines the FastISel class.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
ZERO_EXTEND - Used for integer types, zeroing the new bits.
Flags
Flags values. These may be or'd together.
const MachineBasicBlock * getParent() const
The memory access reads data.
SavePoint enterLocalValueArea()
Prepare InsertPt to begin inserting instructions into the local value area and return the old insert ...
Representation of each machine instruction.
Predicate getPredicate() const
Return the predicate for this instruction.
virtual bool fastLowerIntrinsicCall(const IntrinsicInst *II)
This method is called by target-independent code to do target- specific intrinsic lowering...
unsigned getOperandNo() const
getOperandNo - Return the operand # of this MachineOperand in its MachineInstr.
FNeg_match< OpTy > m_FNeg(const OpTy &X)
Match 'fneg X' as 'fsub -0.0, X'.
bool selectPatchpoint(const CallInst *I)
unsigned getNumArgOperands() const
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Bitwise operators - logical and, logical or, logical xor.
MachineRegisterInfo & MRI
bool hasOneUse(unsigned RegNo) const
hasOneUse - Return true if there is exactly one instruction using the specified register.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
unsigned greater or equal
This represents the llvm.dbg.value instruction.
CallingConv::ID getCallingConv() const
bool lowerCallTo(const CallInst *CI, MCSymbol *Symbol, unsigned NumArgs)
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
StringRef getName() const
Return a constant reference to the value's name.
Establish a view to a call site for examination.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
unsigned fastEmitInst_i(unsigned MachineInstOpcode, const TargetRegisterClass *RC, uint64_t Imm)
Emit a MachineInstr with a single immediate operand, and a result register in the given register clas...
static MachineOperand CreateImm(int64_t Val)
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
static void addStackMapLiveVars(ImmutableCallSite CS, unsigned StartIdx, const SDLoc &DL, SmallVectorImpl< SDValue > &Ops, SelectionDAGBuilder &Builder)
Add a stack map intrinsic call's live variable operands to a stackmap or patchpoint target node's ope...
The memory access always returns the same value (or traps).
static bool isRegUsedByPhiNodes(unsigned DefReg, FunctionLoweringInfo &FuncInfo)
0 1 1 0 True if ordered and operands are unequal
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
MachineBasicBlock::iterator InsertPt
MBB - The current insert position inside the current block.
SmallVector< Register, 4 > InRegs
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void setPhysRegsDeadExcept(ArrayRef< Register > UsedRegs, const TargetRegisterInfo &TRI)
Mark every physreg used by this instruction as dead except those in the UsedRegs list.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
DILocalVariable * getVariable() const
bool isUnconditional() const
1 0 1 0 True if unordered or greater than
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
const TargetLowering & TLI
unsigned createResultReg(const TargetRegisterClass *RC)
CallLoweringInfo & setIsPatchPoint(bool Value=true)
unsigned fastEmit_ri_(MVT VT, unsigned Opcode, unsigned Op0, bool Op0IsKill, uint64_t Imm, MVT ImmType)
This method is a wrapper of fastEmit_ri.
unsigned fastEmitInst_extractsubreg(MVT RetVT, unsigned Op0, bool Op0IsKill, uint32_t Idx)
Emit a MachineInstr for an extract_subreg from a specified index of a superregister to a specified ty...
MachineBasicBlock::iterator InsertPt
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
FastISel(FunctionLoweringInfo &FuncInfo, const TargetLibraryInfo *LibInfo, bool SkipTargetIndependentISel=false)
bool isSafeToMove(AAResults *AA, bool &SawStore) const
Return true if it is safe to move this instruction.
virtual bool fastLowerArguments()
This method is called by target-independent code to do target- specific argument lowering.
0 0 0 1 True if ordered and equal
LLVM Value Representation.
1 0 1 1 True if unordered, greater than, or equal
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
static const Function * getParent(const Value *V)
static bool isCommutative(Instruction *I)
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
DenseMap< const BasicBlock *, MachineBasicBlock * > MBBMap
MBBMap - A mapping from LLVM basic blocks to their machine code entry.
bool hasOneUse() const
Return true if there is exactly one user of this value.
void fastEmitBranch(MachineBasicBlock *MSucc, const DebugLoc &DbgLoc)
Emit an unconditional branch to the given block, unless it is the immediate (fall-through) successor...
StringRef - Represent a constant reference to a string, i.e.
static cl::opt< bool > SinkLocalValues("fast-isel-sink-local-values", cl::init(true), cl::Hidden, cl::desc("Sink local values in FastISel"))
unsigned fastEmitInst_f(unsigned MachineInstOpcode, const TargetRegisterClass *RC, const ConstantFP *FPImm)
Emit a MachineInstr with a floating point immediate, and a result register in the given register clas...
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty...
FunctionLoweringInfo & FuncInfo
const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
TRUNCATE - Completely drop the high bits.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
0 0 1 1 True if ordered and greater than or equal
unsigned ComputeLinearIndex(Type *Ty, const unsigned *Indices, const unsigned *IndicesEnd, unsigned CurIndex=0)
Compute the linearized index of a member in a nested aggregate/struct/array.
reg_begin/reg_end - Provide iteration support to walk over all definitions and uses of a register wit...
This represents the llvm.dbg.declare instruction.
Perform various unary floating-point operations inspired by libm.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
static MachineOperand CreateFI(int Idx)
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Type * getElementType() const
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute >> Attrs)
Create an AttributeList with the specified parameters in it.
0 0 0 0 Always false (always folded)
A wrapper class for inspecting calls to intrinsic functions.
This file describes how to lower LLVM code to machine code.
const BasicBlock * getParent() const
gep_type_iterator gep_type_begin(const User *GEP)