113#define DEBUG_TYPE "isel"
115STATISTIC(NumFastIselSuccessIndependent,
"Number of insts selected by "
116 "target-independent selector");
117STATISTIC(NumFastIselSuccessTarget,
"Number of insts selected by "
118 "target-specific selector");
119STATISTIC(NumFastIselDead,
"Number of dead insts removed on failure");
125 "local values should be cleared after finishing a BB");
169 RegDef = MO.getReg();
170 }
else if (MO.getReg().isVirtual()) {
181 if (
P.second == DefReg)
186void FastISel::flushLocalValueMap() {
198 for (MachineInstr &LocalMI :
203 if (
FuncInfo.RegsWithFixups.count(DefReg))
206 if (!UsedByPHI &&
MRI.use_nodbg_empty(DefReg)) {
211 LocalMI.eraseFromParent();
227 if (FirstLocalValue != FirstNonValue && !FirstLocalValue->getDebugLoc()) {
228 if (FirstNonValue != FuncInfo.MBB->end()) {
229 FirstLocalValue->setDebugLoc(FirstNonValue->getDebugLoc());
230 }
else if (
const BasicBlock *BB =
FuncInfo.MBB->getBasicBlock()) {
233 FirstLocalValue->setDebugLoc(BB->getTerminator()->getDebugLoc());
238 LocalValueMap.clear();
239 LastLocalValue = EmitStartPt;
241 SavedInsertPt = FuncInfo.InsertPt;
245 EVT RealVT =
TLI.getValueType(
DL, V->getType(),
true);
254 if (!
TLI.isTypeLegal(VT)) {
256 if (VT == MVT::i1 || VT == MVT::i8 || VT == MVT::i16)
257 VT =
TLI.getTypeToTransformTo(V->getContext(), VT).getSimpleVT();
272 return FuncInfo.InitializeRegForValue(V);
278 Reg = materializeRegForValue(V, VT);
288 if (CI->getValue().getActiveBits() <= 64)
298 if (CF->isNullValue())
306 const APFloat &Flt = CF->getValueAPF();
309 APSInt SIntVal(IntBitWidth,
false);
329 TII.get(TargetOpcode::IMPLICIT_DEF),
Reg);
346 Reg = materializeConstant(
V, VT);
378 else if (Reg != AssignedReg) {
380 for (
unsigned i = 0; i < NumRegs; i++) {
381 FuncInfo.RegFixups[AssignedReg + i] = Reg + i;
382 FuncInfo.RegsWithFixups.insert(Reg + i);
397 if (IdxVT.
bitsLT(PtrVT)) {
399 }
else if (IdxVT.
bitsGT(PtrVT)) {
417 assert(
I.isValid() && E.isValid() && std::distance(
I, E) > 0 &&
418 "Invalid iterator!");
420 if (SavedInsertPt ==
I)
429 Dead->eraseFromParent();
451 if (VT == MVT::Other || !VT.
isSimple())
459 if (!
TLI.isTypeLegal(VT)) {
463 VT =
TLI.getTypeToTransformTo(
I->getContext(), VT);
493 uint64_t
Imm = CI->getSExtValue();
525 ISDOpcode, Op0, Op1);
548 uint64_t TotalOffs = 0;
550 uint64_t MaxOffs = 2048;
551 MVT VT =
TLI.getValueType(
DL,
I->getType()).getSimpleVT();
555 const Value *Idx = GTI.getOperand();
556 if (
StructType *StTy = GTI.getStructTypeOrNull()) {
560 TotalOffs +=
DL.getStructLayout(StTy)->getElementOffset(
Field);
561 if (TotalOffs >= MaxOffs) {
574 uint64_t IdxN = CI->getValue().sextOrTrunc(64).getSExtValue();
575 TotalOffs += GTI.getSequentialElementStride(
DL) * IdxN;
576 if (TotalOffs >= MaxOffs) {
592 uint64_t ElementSize = GTI.getSequentialElementStride(
DL);
597 if (ElementSize != 1) {
619 const CallInst *CI,
unsigned StartIdx) {
620 for (
unsigned i = StartIdx, e = CI->
arg_size(); i != e; ++i) {
634 if (SI !=
FuncInfo.StaticAllocaMap.end())
651 assert(
I->getCalledFunction()->getReturnType()->isVoidTy() &&
652 "Stackmap cannot return a value.");
668 "Expected a constant integer.");
673 "Expected a constant integer.");
674 const auto *NumBytes =
680 if (!addStackMapLiveVars(
Ops,
I, 2))
689 for (
unsigned i = 0; ScratchRegs[i]; ++i)
691 ScratchRegs[i],
true,
true,
false,
692 false,
false,
true));
695 unsigned AdjStackDown =
TII.getCallFrameSetupOpcode();
699 for (
unsigned I = 0, E =
MCID.getNumOperands();
I < E; ++
I)
704 TII.get(TargetOpcode::STACKMAP));
705 for (
auto const &MO :
Ops)
709 unsigned AdjStackUp =
TII.getCallFrameDestroyOpcode();
715 FuncInfo.MF->getFrameInfo().setHasStackMap();
725bool FastISel::lowerCallOperands(
const CallInst *CI,
unsigned ArgIdx,
726 unsigned NumArgs,
const Value *Callee,
727 bool ForceRetVoidTy, CallLoweringInfo &CLI) {
729 Args.reserve(NumArgs);
732 for (
unsigned ArgI = ArgIdx, ArgE = ArgIdx + NumArgs; ArgI != ArgE; ++ArgI) {
735 assert(!V->getType()->isEmptyTy() &&
"Empty type passed to intrinsic.");
738 Entry.setAttributes(CI, ArgI);
739 Args.push_back(Entry);
744 CLI.setCallee(CI->
getCallingConv(), RetTy, Callee, std::move(Args), NumArgs);
754 MCSymbol *Sym = Ctx.getOrCreateSymbol(MangledName);
755 return setCallee(
CC, ResultTy, Sym, std::move(ArgsList), FixedArgs);
767 bool HasDef = !
I->getType()->isVoidTy();
772 if (IsAnyRegCC && HasDef) {
780 "Expected a constant integer.");
781 const auto *NumArgsVal =
783 unsigned NumArgs = NumArgsVal->getZExtValue();
788 assert(
I->arg_size() >= NumMetaOpers + NumArgs &&
789 "Not enough arguments provided to the patchpoint intrinsic");
792 unsigned NumCallArgs = IsAnyRegCC ? 0 : NumArgs;
795 if (!lowerCallOperands(
I, NumMetaOpers, NumCallArgs, Callee, IsAnyRegCC, CLI))
798 assert(CLI.
Call &&
"No call instruction specified.");
803 if (IsAnyRegCC && HasDef) {
813 "Expected a constant integer.");
818 "Expected a constant integer.");
819 const auto *NumBytes =
825 uint64_t CalleeConstAddr =
829 if (
C->getOpcode() == Instruction::IntToPtr) {
830 uint64_t CalleeConstAddr =
844 unsigned NumCallRegArgs = IsAnyRegCC ? NumArgs : CLI.
OutRegs.
size();
853 for (
unsigned i = NumMetaOpers, e = NumMetaOpers + NumArgs; i != e; ++i) {
866 if (!addStackMapLiveVars(
Ops,
I, NumMetaOpers + NumArgs))
875 for (
unsigned i = 0; ScratchRegs[i]; ++i)
877 ScratchRegs[i],
true,
true,
false,
878 false,
false,
true));
881 for (
auto Reg : CLI.
InRegs)
887 TII.get(TargetOpcode::PATCHPOINT));
898 FuncInfo.MF->getFrameInfo().setHasPatchPoint();
906 const auto &
Triple =
TM.getTargetTriple();
916 TII.get(TargetOpcode::PATCHABLE_EVENT_CALL));
925 const auto &
Triple =
TM.getTargetTriple();
937 TII.get(TargetOpcode::PATCHABLE_TYPED_EVENT_CALL));
950 Attrs.push_back(Attribute::SExt);
952 Attrs.push_back(Attribute::ZExt);
954 Attrs.push_back(Attribute::InReg);
956 return AttributeList::get(CLI.
RetTy->
getContext(), AttributeList::ReturnIndex,
965 MCSymbol *Sym = Ctx.getOrCreateSymbol(MangledName);
975 Args.reserve(NumArgs);
979 for (
unsigned ArgI = 0; ArgI != NumArgs; ++ArgI) {
982 assert(!V->getType()->isEmptyTy() &&
"Empty type passed to intrinsic.");
985 Entry.setAttributes(CI, ArgI);
986 Args.push_back(Entry);
991 CLI.
setCallee(RetTy, FTy, Symbol, std::move(Args), *CI, NumArgs);
1005 bool CanLowerReturn =
TLI.CanLowerReturn(
1009 if (!CanLowerReturn)
1012 for (
EVT VT : RetTys) {
1015 for (
unsigned i = 0; i != NumRegs; ++i) {
1025 CLI.
Ins.push_back(Ret);
1031 for (
auto &Arg : CLI.
getArgs()) {
1032 Type *FinalType = Arg.Ty;
1034 FinalType = Arg.IndirectType;
1035 bool NeedsRegBlock =
TLI.functionArgumentNeedsConsecutiveRegisters(
1047 if (Arg.IsSwiftSelf)
1048 Flags.setSwiftSelf();
1049 if (Arg.IsSwiftAsync)
1050 Flags.setSwiftAsync();
1051 if (Arg.IsSwiftError)
1052 Flags.setSwiftError();
1053 if (Arg.IsCFGuardTarget)
1054 Flags.setCFGuardTarget();
1057 if (Arg.IsInAlloca) {
1058 Flags.setInAlloca();
1066 if (Arg.IsPreallocated) {
1067 Flags.setPreallocated();
1076 if (Arg.IsByVal || Arg.IsInAlloca || Arg.IsPreallocated) {
1077 unsigned FrameSize =
DL.getTypeAllocSize(Arg.IndirectType);
1082 MemAlign =
TLI.getByValTypeAlignment(Arg.IndirectType,
DL);
1083 Flags.setByValSize(FrameSize);
1084 }
else if (!MemAlign) {
1085 MemAlign =
DL.getABITypeAlign(Arg.Ty);
1087 Flags.setMemAlign(*MemAlign);
1091 Flags.setInConsecutiveRegs();
1092 Flags.setOrigAlign(
DL.getABITypeAlign(Arg.Ty));
1101 assert(CLI.
Call &&
"No call instruction specified.");
1126 if (V->getType()->isEmptyTy())
1131 Entry.setAttributes(CI, i - CI->
arg_begin());
1132 Args.push_back(Entry);
1141 MF->getFunction().getFnAttribute(
"disable-tail-calls").getValueAsBool())
1162 if (!IA->getConstraintString().empty())
1165 unsigned ExtraInfo = 0;
1166 if (IA->hasSideEffects())
1168 if (IA->isAlignStack())
1172 if (
Call->isConvergent())
1177 TII.get(TargetOpcode::INLINEASM));
1181 const MDNode *SrcLoc =
Call->getMetadata(
"srcloc");
1196 if (!
II->hasDbgRecords())
1204 flushLocalValueMap();
1208 assert(DLR->getLabel() &&
"Missing label");
1210 TII.get(TargetOpcode::DBG_LABEL))
1228 if (
FuncInfo.PreprocessedDVRDeclares.contains(&DVR))
1250 CE && CE->getOpcode() == Instruction::IntToPtr)
1253 FuncInfo.MF->getDataLayout().getPointerTypeSizeInBits(CE->getType());
1254 V = ConstantInt::get(CE->getContext(),
1255 Int->getValue().zextOrTrunc(PtrSize));
1261 if (CI->getBitWidth() > 64)
1269 .
addImm(CI->getZExtValue())
1294 assert(Arg->hasAttribute(Attribute::AttrKind::SwiftAsync));
1297 for (
auto [PhysReg, VirtReg] :
FuncInfo.RegInfo->liveins())
1298 if (Reg == VirtReg || Reg == PhysReg) {
1300 PhysReg, Var, Expr);
1304 LLVM_DEBUG(
dbgs() <<
"Dropping dbg.value: expression is entry_value but "
1305 "couldn't find a physical register\n");
1311 bool IsIndirect =
false;
1318 if (!
FuncInfo.MF->useDebugInstrRef()) {
1319 bool IsIndirect =
false;
1334 TII.get(TargetOpcode::DBG_INSTR_REF),
false, MOs,
1344 LLVM_DEBUG(
dbgs() <<
"Dropping debug info (bad/undef address)\n");
1348 std::optional<MachineOperand>
Op;
1371 "Expected inlined-at fields to agree");
1372 if (
FuncInfo.MF->useDebugInstrRef() &&
Op->isReg()) {
1380 TII.get(TargetOpcode::DBG_INSTR_REF),
false, *
Op,
1388 TII.get(TargetOpcode::DBG_VALUE),
true, *
Op, Var,
1396 dbgs() <<
"Dropping debug info (no materialized reg for address)\n");
1401 switch (
II->getIntrinsicID()) {
1405 case Intrinsic::lifetime_start:
1406 case Intrinsic::lifetime_end:
1408 case Intrinsic::donothing:
1410 case Intrinsic::sideeffect:
1412 case Intrinsic::assume:
1414 case Intrinsic::experimental_noalias_scope_decl:
1416 case Intrinsic::objectsize:
1419 case Intrinsic::is_constant:
1422 case Intrinsic::allow_runtime_check:
1423 case Intrinsic::allow_ubsan_check: {
1431 case Intrinsic::launder_invariant_group:
1432 case Intrinsic::expect:
1433 case Intrinsic::expect_with_probability: {
1440 case Intrinsic::fake_use: {
1441 const Value *V =
II->getArgOperand(0);
1444 TII.get(TargetOpcode::FAKE_USE))
1448 case Intrinsic::experimental_stackmap:
1450 case Intrinsic::experimental_patchpoint_void:
1451 case Intrinsic::experimental_patchpoint:
1454 case Intrinsic::xray_customevent:
1456 case Intrinsic::xray_typedevent:
1464 EVT SrcVT =
TLI.getValueType(
DL,
I->getOperand(0)->getType());
1465 EVT DstVT =
TLI.getValueType(
DL,
I->getType());
1467 if (SrcVT == MVT::Other || !SrcVT.
isSimple() || DstVT == MVT::Other ||
1473 if (!
TLI.isTypeLegal(DstVT))
1477 if (!
TLI.isTypeLegal(SrcVT))
1495 EVT SrcEVT =
TLI.getValueType(
DL,
I->getOperand(0)->getType());
1496 EVT DstEVT =
TLI.getValueType(
DL,
I->getType());
1497 if (SrcEVT == MVT::Other || DstEVT == MVT::Other ||
1498 !
TLI.isTypeLegal(SrcEVT) || !
TLI.isTypeLegal(DstEVT))
1509 if (SrcVT == DstVT) {
1529 EVT ETy =
TLI.getValueType(
DL,
I->getOperand(0)->getType());
1530 if (ETy == MVT::Other || !
TLI.isTypeLegal(ETy))
1538 TII.get(TargetOpcode::COPY), ResultReg).
addReg(Reg);
1546void FastISel::removeDeadLocalValueCode(
MachineInstr *SavedLastLocalValue)
1549 if (CurLastLocalValue != SavedLastLocalValue) {
1554 if (SavedLastLocalValue)
1567 flushLocalValueMap();
1572 if (
I->isTerminator()) {
1573 if (!handlePHINodesInSuccessorBlocks(
I->getParent())) {
1578 removeDeadLocalValueCode(SavedLastLocalValue);
1585 for (
unsigned i = 0, e =
Call->getNumOperandBundles(); i != e; ++i)
1597 if (
F &&
F->getIntrinsicID() == Intrinsic::trap &&
1598 Call->hasFnAttr(
"trap-func-name"))
1605 ++NumFastIselSuccessIndependent;
1611 if (SavedInsertPt !=
FuncInfo.InsertPt)
1617 ++NumFastIselSuccessTarget;
1623 if (SavedInsertPt !=
FuncInfo.InsertPt)
1628 if (
I->isTerminator()) {
1631 removeDeadLocalValueCode(SavedLastLocalValue);
1642 bool BlockHasMultipleInstrs = &BB->
front() != &BB->
back();
1643 if (BlockHasMultipleInstrs &&
FuncInfo.MBB->isLayoutSuccessor(MSucc)) {
1657 FuncInfo.MBB->addSuccessorWithoutProb(MSucc);
1666 if (TrueMBB != FalseMBB) {
1672 FuncInfo.MBB->addSuccessorWithoutProb(TrueMBB);
1685 EVT VT =
TLI.getValueType(
DL,
I->getType());
1698 if (!
TLI.isTypeLegal(IntVT))
1732 if (!
TLI.isTypeLegal(VT) && VT != MVT::i1)
1742 ResultReg =
I->second;
1744 ResultReg =
FuncInfo.InitializeRegForValue(Op0);
1754 for (
unsigned i = 0; i < VTIndex; i++)
1755 ResultReg = ResultReg.
id() +
1756 TLI.getNumRegisters(
FuncInfo.Fn->getContext(), AggValueVTs[i]);
1764 case Instruction::Add:
1766 case Instruction::FAdd:
1768 case Instruction::Sub:
1770 case Instruction::FSub:
1772 case Instruction::Mul:
1774 case Instruction::FMul:
1776 case Instruction::SDiv:
1778 case Instruction::UDiv:
1780 case Instruction::FDiv:
1782 case Instruction::SRem:
1784 case Instruction::URem:
1786 case Instruction::FRem:
1788 case Instruction::Shl:
1790 case Instruction::LShr:
1792 case Instruction::AShr:
1794 case Instruction::And:
1796 case Instruction::Or:
1798 case Instruction::Xor:
1801 case Instruction::FNeg:
1804 case Instruction::GetElementPtr:
1807 case Instruction::UncondBr: {
1815 case Instruction::Unreachable: {
1817 if (!UI->shouldLowerToTrap(
TM.Options.TrapUnreachable,
1818 TM.Options.NoTrapAfterNoreturn))
1824 case Instruction::Alloca:
1832 case Instruction::Call:
1843 case Instruction::BitCast:
1846 case Instruction::FPToSI:
1848 case Instruction::ZExt:
1850 case Instruction::SExt:
1852 case Instruction::Trunc:
1854 case Instruction::SIToFP:
1857 case Instruction::IntToPtr:
1858 case Instruction::PtrToInt:
1859 case Instruction::PtrToAddr: {
1860 EVT SrcVT =
TLI.getValueType(
DL,
I->getOperand(0)->getType());
1861 EVT DstVT =
TLI.getValueType(
DL,
I->getType());
1873 case Instruction::ExtractValue:
1876 case Instruction::Freeze:
1879 case Instruction::PHI:
1895 TII(*
MF->getSubtarget().getInstrInfo()),
1896 TLI(*
MF->getSubtarget().getTargetLowering()),
1941 uint64_t
Imm,
MVT ImmType) {
1971 ConstantInt::get(ITy,
Imm,
false,
true));
1975 return fastEmit_rr(VT, VT, Opcode, Op0, MaterialReg);
1979 return MRI.createVirtualRegister(RC);
1984 if (
Op.isVirtual()) {
1986 if (!
MRI.constrainRegClass(
Op, RegClass)) {
2015 assert(
II.getNumDefs() >= 1 &&
"instruction must define the result");
2032 assert(
II.getNumDefs() >= 1 &&
"instruction must define the result");
2050 assert(
II.getNumDefs() >= 1 &&
"instruction must define the result");
2067 assert(
II.getNumDefs() >= 1 &&
"instruction must define the result");
2077 uint64_t Imm1, uint64_t Imm2) {
2083 assert(
II.getNumDefs() >= 1 &&
"instruction must define the result");
2099 assert(
II.getNumDefs() >= 1 &&
"instruction must define the result");
2115 assert(
II.getNumDefs() >= 1 &&
"instruction must define the result");
2129 assert(
II.getNumDefs() >= 1 &&
"instruction must define the result");
2141 MRI.constrainRegClass(Op0,
TRI.getSubClassWithSubReg(RC, Idx));
2160bool FastISel::handlePHINodesInSuccessorBlocks(
const BasicBlock *LLVMBB) {
2173 if (!SuccsHandled.
insert(SuccMBB).second)
2181 for (
const PHINode &PN : SuccBB->phis()) {
2192 EVT VT =
TLI.getValueType(
DL, PN.getType(),
true);
2193 if (VT == MVT::Other || !
TLI.isTypeLegal(VT)) {
2195 if (!(VT == MVT::i1 || VT == MVT::i8 || VT == MVT::i16)) {
2201 const Value *PHIOp = PN.getIncomingValueForBlock(LLVMBB);
2207 MIMD = MIMetadata(*Inst);
2224 "tryToFoldLoad expected a LoadInst with a single use");
2228 unsigned MaxUsers = 6;
2231 while (TheUser != FoldInst &&
2244 if (TheUser != FoldInst)
2267 if (!
MRI.hasOneNonDBGUse(LoadReg))
2272 if (
FuncInfo.RegsWithFixups.contains(LoadReg))
2289 MRI.markUsesInDebugValueAsUndef(LoadReg);
2298 if (
DL.getTypeSizeInBits(
GEP->getType()) !=
2299 DL.getTypeSizeInBits(
Add->getType()))
2318 Alignment = LI->getAlign();
2319 IsVolatile = LI->isVolatile();
2321 Ptr = LI->getPointerOperand();
2322 ValTy = LI->getType();
2324 Alignment =
SI->getAlign();
2325 IsVolatile =
SI->isVolatile();
2327 Ptr =
SI->getPointerOperand();
2328 ValTy =
SI->getValueOperand()->getType();
2332 bool IsNonTemporal =
I->hasMetadata(LLVMContext::MD_nontemporal);
2333 bool IsInvariant =
I->hasMetadata(LLVMContext::MD_invariant_load);
2334 const MDNode *Ranges =
I->getMetadata(LLVMContext::MD_range);
2339 Alignment =
DL.getABITypeAlign(ValTy);
2341 unsigned Size =
DL.getTypeStoreSize(ValTy);
2361 switch (Predicate) {
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
static Register findLocalRegDef(MachineInstr &MI)
Return the defined register if this instruction defines exactly one virtual register and uses no othe...
static bool isRegUsedByPhiNodes(Register DefReg, FunctionLoweringInfo &FuncInfo)
static AttributeList getReturnAttrs(FastISel::CallLoweringInfo &CLI)
Returns an AttributeList representing the attributes applied to the return value of the given call.
This file defines the FastISel class.
Module.h This file contains the declarations for the Module class.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Promote Memory to Register
uint64_t IntrinsicInst * II
OptimizedStructLayoutField Field
This file defines the SmallPtrSet class.
This file defines the SmallString class.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static SymbolRef::Type getType(const Symbol *Sym)
This file describes how to lower LLVM code to machine code.
static constexpr roundingMode rmTowardZero
opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
An arbitrary precision integer that knows its signedness.
LLVM Basic Block Representation.
const Instruction & back() const
const Instruction & front() const
CallingConv::ID getCallingConv() const
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
Value * getCalledOperand() const
Value * getArgOperand(unsigned i) const
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
FunctionType * getFunctionType() const
unsigned arg_size() const
This class represents a function call, abstracting a target machine's calling convention.
bool isMustTailCall() const
This class is the base class for the comparison instructions.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_UGE
unsigned greater or equal
@ ICMP_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ ICMP_ULT
unsigned less than
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ ICMP_SGE
signed greater or equal
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Predicate getPredicate() const
Return the predicate for this instruction.
ConstantFP - Floating Point Values [float, double].
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
LLVM_ABI bool isEntryValue() const
Check if the expression consists of exactly one entry value operand.
LLVM_ABI std::pair< DIExpression *, const ConstantInt * > constantFold(const ConstantInt *CI)
Try to shorten an expression with an initial constant operand.
static LLVM_ABI DIExpression * prependOpcodes(const DIExpression *Expr, SmallVectorImpl< uint64_t > &Ops, bool StackValue=false, bool EntryValue=false)
Prepend DIExpr with the given opcodes and optionally turn it into a stack value.
bool isValidLocationForIntrinsic(const DILocation *DL) const
Check that a location is valid for this variable.
A parsed version of the target data layout string in and methods for querying it.
Records a position in IR for a source label (DILabel).
Base class for non-instruction debug metadata records that have positions within IR.
DebugLoc getDebugLoc() const
Record of a variable value-assignment, aka a non instruction representation of the dbg....
LocationType getType() const
LLVM_ABI Value * getVariableLocationOp(unsigned OpIdx) const
DIExpression * getExpression() const
DILocalVariable * getVariable() const
MachineRegisterInfo & MRI
const TargetLibraryInfo * LibInfo
bool selectGetElementPtr(const User *I)
void setLastLocalValue(MachineInstr *I)
Update the position of the last instruction emitted for materializing constants for use in the curren...
bool selectStackmap(const CallInst *I)
Register fastEmitInst_ri(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, uint64_t Imm)
Emit a MachineInstr with a register operand, an immediate, and a result register in the given registe...
bool selectExtractValue(const User *U)
DenseMap< const Value *, Register > LocalValueMap
void fastEmitBranch(MachineBasicBlock *MSucc, const DebugLoc &DbgLoc)
Emit an unconditional branch to the given block, unless it is the immediate (fall-through) successor,...
FastISel(FunctionLoweringInfo &FuncInfo, const TargetLibraryInfo *LibInfo, const LibcallLoweringInfo *LibcallLowering, bool SkipTargetIndependentISel=false)
MachineInstr * EmitStartPt
The top most instruction in the current block that is allowed for emitting local variables.
bool selectXRayCustomEvent(const CallInst *II)
virtual Register fastEmit_r(MVT VT, MVT RetVT, unsigned Opcode, Register Op0)
This method is called by target-independent code to request that an instruction with the given type,...
Register fastEmitInst_(unsigned MachineInstOpcode, const TargetRegisterClass *RC)
Emit a MachineInstr with no operands and a result register in the given register class.
Register fastEmitInst_rr(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, Register Op1)
Emit a MachineInstr with two register operands and a result register in the given register class.
virtual Register fastEmit_rr(MVT VT, MVT RetVT, unsigned Opcode, Register Op0, Register Op1)
This method is called by target-independent code to request that an instruction with the given type,...
const LibcallLoweringInfo * LibcallLowering
virtual bool fastLowerIntrinsicCall(const IntrinsicInst *II)
This method is called by target-independent code to do target- specific intrinsic lowering.
virtual bool lowerDbgDeclare(const Value *V, DIExpression *Expr, DILocalVariable *Var, const DebugLoc &DL)
Target-independent lowering of debug information.
MachineInstr * getLastLocalValue()
Return the position of the last instruction emitted for materializing constants for use in the curren...
bool lowerCall(const CallInst *I)
void leaveLocalValueArea(SavePoint Old)
Reset InsertPt to the given old insert position.
virtual Register fastMaterializeConstant(const Constant *C)
Emit a constant in a register using target-specific logic, such as constant pool loads.
Register fastEmitInst_rrr(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, Register Op1, Register Op2)
Emit a MachineInstr with three register operands and a result register in the given register class.
bool lowerCallTo(const CallInst *CI, MCSymbol *Symbol, unsigned NumArgs)
virtual Register 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,...
virtual Register 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,...
void handleDbgInfo(const Instruction *II)
Target-independent lowering of non-instruction debug info associated with this instruction.
bool selectFreeze(const User *I)
bool selectIntrinsicCall(const IntrinsicInst *II)
Register getRegForGEPIndex(MVT PtrVT, const Value *Idx)
This is a wrapper around getRegForValue that also takes care of truncating or sign-extending the give...
bool selectCast(const User *I, unsigned Opcode)
bool tryToFoldLoad(const LoadInst *LI, const Instruction *FoldInst)
We're checking to see if we can fold LI into FoldInst.
Register getRegForValue(const Value *V)
Create a virtual register and arrange for it to be assigned the value for the given LLVM value.
void removeDeadCode(MachineBasicBlock::iterator I, MachineBasicBlock::iterator E)
Remove all dead instructions between the I and E.
virtual Register fastMaterializeFloatZero(const ConstantFP *CF)
Emit the floating-point constant +0.0 in a register using target- specific logic.
void startNewBlock()
Set the current block to which generated machine instructions will be appended.
MachineMemOperand * createMachineMemOperandFor(const Instruction *I) const
Create a machine mem operand from the given instruction.
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 ...
Register 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...
Register fastEmitInst_rii(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, uint64_t Imm1, uint64_t Imm2)
Emit a MachineInstr with one register operand and two immediate operands.
bool canFoldAddIntoGEP(const User *GEP, const Value *Add)
Check if Add is an add that can be safely folded into GEP.
virtual bool lowerDbgValue(const Value *V, DIExpression *Expr, DILocalVariable *Var, const DebugLoc &DL)
Target-independent lowering of debug information.
TargetLoweringBase::ArgListTy ArgListTy
bool selectInstruction(const Instruction *I)
Do "fast" instruction selection for the given LLVM IR instruction and append the generated machine in...
virtual bool fastLowerCall(CallLoweringInfo &CLI)
This method is called by target-independent code to do target- specific call lowering.
bool selectXRayTypedEvent(const CallInst *II)
virtual Register fastMaterializeAlloca(const AllocaInst *C)
Emit an alloca address in a register using target-specific logic.
Register fastEmitZExtFromI1(MVT VT, Register Op0)
Emit MachineInstrs to compute the value of Op with all but the least significant bit set to zero.
Register createResultReg(const TargetRegisterClass *RC)
virtual bool fastLowerArguments()
This method is called by target-independent code to do target- specific argument lowering.
bool selectFNeg(const User *I, const Value *In)
Emit an FNeg operation.
const TargetInstrInfo & TII
bool selectCall(const User *I)
Register lookUpRegForValue(const Value *V)
Look up the value to see if its value is already cached in a register.
CmpInst::Predicate optimizeCmpPredicate(const CmpInst *CI) const
virtual Register 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...
void finishBasicBlock()
Flush the local value map.
Register fastEmitInst_r(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0)
Emit a MachineInstr with one register operand and a result register in the given register class.
Register fastEmitInst_rri(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, Register Op1, uint64_t Imm)
Emit a MachineInstr with two register operands, an immediate, and a result register in the given regi...
FunctionLoweringInfo & FuncInfo
MachineConstantPool & MCP
bool selectOperator(const User *I, unsigned Opcode)
Do "fast" instruction selection for the given LLVM IR operator (Instruction or ConstantExpr),...
bool SkipTargetIndependentISel
Register 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...
Register constrainOperandRegClass(const MCInstrDesc &II, Register Op, unsigned OpNum)
Try to constrain Op so that it is usable by argument OpNum of the provided MCInstrDesc.
MachineBasicBlock::iterator SavePoint
Register fastEmitInst_extractsubreg(MVT RetVT, Register Op0, uint32_t Idx)
Emit a MachineInstr for an extract_subreg from a specified index of a superregister to a specified ty...
void updateValueMap(const Value *I, Register Reg, unsigned NumRegs=1)
Update the value map to include the new mapping for this instruction, or insert an extra copy to get ...
bool selectBinaryOp(const User *I, unsigned ISDOpcode)
Select and emit code for a binary operator instruction, which has an opcode which directly correspond...
bool selectPatchpoint(const CallInst *I)
void recomputeInsertPt()
Reset InsertPt to prepare for inserting instructions into the current block.
virtual bool fastSelectInstruction(const Instruction *I)=0
This method is called by target-independent code when the normal FastISel process fails to select an ...
const TargetLowering & TLI
virtual Register fastEmit_ri(MVT VT, MVT RetVT, unsigned Opcode, Register Op0, uint64_t Imm)
This method is called by target-independent code to request that an instruction with the given type,...
MachineInstr * LastLocalValue
The position of the last instruction for materializing constants for use in the current block.
bool lowerArguments()
Do "fast" instruction selection for function arguments and append the machine instructions to the cur...
SavePoint enterLocalValueArea()
Prepare InsertPt to begin inserting instructions into the local value area and return the old insert ...
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 ...
bool selectBitCast(const User *I)
Register fastEmit_ri_(MVT VT, unsigned Opcode, Register Op0, uint64_t Imm, MVT ImmType)
This method is a wrapper of fastEmit_ri.
const TargetRegisterInfo & TRI
TargetLoweringBase::ArgListEntry ArgListEntry
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
MachineBasicBlock * getMBB(const BasicBlock *BB) const
unsigned OrigNumPHINodesToUpdate
MachineBasicBlock::iterator InsertPt
MBB - The current insert position inside the current block.
MachineBasicBlock * MBB
MBB - The current block.
std::vector< std::pair< MachineInstr *, Register > > PHINodesToUpdate
PHINodesToUpdate - A list of phi instructions whose operand list will be updated after processing the...
Class to represent function types.
const Argument * const_arg_iterator
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Instruction * user_back()
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Class to represent integer types.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
A wrapper class for inspecting calls to intrinsic functions.
Tracks which library functions to use for a particular subtarget or function.
An instruction for reading from memory.
Value * getPointerOperand()
Context object for machine code objects.
Describe properties that are true of each instruction in the target description file.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
LLVM_ABI iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
MachineInstrBundleIterator< MachineInstr, true > reverse_iterator
MachineInstrBundleIterator< MachineInstr > iterator
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
const MachineInstrBuilder & addCImm(const ConstantInt *Val) const
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addMetadata(const MDNode *MD) const
const MachineInstrBuilder & addFPImm(const ConstantFP *Val) const
Representation of each machine instruction.
LLVM_ABI void setHeapAllocMarker(MachineFunction &MF, MDNode *MD)
Set a marker on instructions that denotes where we should create and emit heap alloc site labels.
void setImplicitPhysRegDefsDead()
Mark the implicit physreg defs named by the instruction description as dead.
LLVM_ABI void setPhysRegsDeadExcept(ArrayRef< Register > UsedRegs, const TargetRegisterInfo &TRI)
Mark every physreg used by this instruction as dead except those in the UsedRegs list.
LLVM_ABI MachineInstrBundleIterator< MachineInstr > eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
@ MOVolatile
The memory access is volatile.
@ MOLoad
The memory access reads data.
@ MONonTemporal
The memory access is non-temporal.
@ MOInvariant
The memory access always returns the same value (or traps).
@ MOStore
The memory access writes data.
MachineOperand class - Representation of each machine instruction operand.
static MachineOperand CreateRegMask(const uint32_t *Mask)
CreateRegMask - Creates a register mask operand referencing Mask.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
static MachineOperand CreateImm(int64_t Val)
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset, unsigned TargetFlags=0)
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 MachineOperand CreateFI(int Idx)
unsigned getOperandNo() const
getOperandNo - Return the operand # of this MachineOperand in its MachineInstr.
defusechain_iterator< true, false, true, true, false > use_nodbg_iterator
use_nodbg_iterator/use_nodbg_begin/use_nodbg_end - Walk all uses of the specified register,...
LLVM_ABI void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
constexpr unsigned id() const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Class to represent struct types.
Provides information about what library functions are available for the current target.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
ArchType getArch() const
Get the parsed architecture type of this triple.
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Unconditional Branch instruction.
BasicBlock * getSuccessor(unsigned i=0) const
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
bool hasOneUse() const
Return true if there is exactly one use of this value.
LLVM_ABI bool isSwiftError() const
Return true if this value is a swifterror value.
const ParentTy * getParent() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ AnyReg
OBSOLETED - Used for stack based JavaScript calls.
@ ADD
Simple integer binary arithmetic operators.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ FADD
Simple binary floating point operators.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ SIGN_EXTEND
Conversion operators.
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ SHL
Shift and rotation operations.
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ TRAP
TRAP - Trapping instruction.
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
bool isBitwiseLogicOp(unsigned Opcode)
Whether this is bitwise logic opcode.
@ DW_OP_LLVM_arg
Only used in LLVM metadata.
std::reverse_iterator< iterator > rend() const
LLVM_ABI iterator begin() const
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI 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,...
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
LLVM_ABI void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< EVT > *MemVTs=nullptr, SmallVectorImpl< TypeSize > *Offsets=nullptr, TypeSize StartingOffset=TypeSize::getZero())
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI void diagnoseDontCall(const CallInst &CI)
auto successors(const MachineBasicBlock *BB)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
gep_type_iterator gep_type_end(const User *GEP)
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
generic_gep_type_iterator<> gep_type_iterator
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
LLVM_ABI bool isInTailCallPosition(const CallBase &Call, const TargetMachine &TM, bool ReturnsFirstArg=false)
Test if the given instruction is in a position to be optimized with a tail-call.
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
gep_type_iterator gep_type_begin(const User *GEP)
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
LLVM_ABI 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.
MCRegisterClass TargetRegisterClass
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
SmallVector< ISD::ArgFlagsTy, 16 > OutFlags
SmallVector< Value *, 16 > OutVals
SmallVector< Register, 16 > OutRegs
CallLoweringInfo & setTailCall(bool Value=true)
SmallVector< Register, 4 > InRegs
CallLoweringInfo & setIsPatchPoint(bool Value=true)
CallLoweringInfo & setCallee(Type *ResultTy, FunctionType *FuncTy, const Value *Target, ArgListTy &&ArgsList, const CallBase &Call)
SmallVector< ISD::InputArg, 4 > Ins
This class contains a discriminated union of information about pointers in memory operands,...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.