14 #define DEBUG_TYPE "isel"
71 cl::desc(
"Generate low-precision inline sequences "
72 "for some float libcalls"),
93 const SDValue *Parts,
unsigned NumParts,
103 unsigned NumParts,
MVT PartVT,
EVT ValueVT,
110 assert(NumParts > 0 &&
"No parts to assemble!");
121 unsigned RoundParts = NumParts & (NumParts - 1) ?
122 1 <<
Log2_32(NumParts) : NumParts;
123 unsigned RoundBits = PartBits * RoundParts;
124 EVT RoundVT = RoundBits == ValueBits ?
130 if (RoundParts > 2) {
134 RoundParts / 2, PartVT, HalfVT, V);
145 if (RoundParts < NumParts) {
147 unsigned OddParts = NumParts - RoundParts;
150 Parts + RoundParts, OddParts, PartVT, OddVT, V);
177 !PartVT.
isVector() &&
"Unexpected split");
186 if (PartEVT == ValueVT)
190 if (ValueVT.
bitsLT(PartEVT)) {
195 Val = DAG.
getNode(AssertOp, DL, PartEVT, Val,
223 const SDValue *Parts,
unsigned NumParts,
225 assert(ValueVT.
isVector() &&
"Not a vector value");
226 assert(NumParts > 0 &&
"No parts to assemble!");
234 unsigned NumIntermediates;
237 NumIntermediates, RegisterVT);
238 assert(NumRegs == NumParts &&
"Part count doesn't match vector breakdown!");
240 assert(RegisterVT == PartVT &&
"Part type doesn't match vector breakdown!");
241 assert(RegisterVT == Parts[0].getSimpleValueType() &&
242 "Part type doesn't match part!");
246 if (NumIntermediates == NumParts) {
249 for (
unsigned i = 0; i != NumParts; ++i)
251 PartVT, IntermediateVT, V);
252 }
else if (NumParts > 0) {
255 assert(NumParts % NumIntermediates == 0 &&
256 "Must expand into a divisible number of parts!");
257 unsigned Factor = NumParts / NumIntermediates;
258 for (
unsigned i = 0; i != NumIntermediates; ++i)
260 PartVT, IntermediateVT, V);
265 Val = DAG.
getNode(IntermediateVT.isVector() ?
267 ValueVT, &Ops[0], NumIntermediates);
273 if (PartEVT == ValueVT)
283 "Cannot narrow, it would be a lossy transformation");
293 "Cannot handle this kind of promotion");
295 bool Smaller = ValueVT.
bitsLE(PartEVT);
310 Twine ErrMsg(
"non-trivial scalar-to-vector conversion");
311 if (
const Instruction *
I = dyn_cast_or_null<Instruction>(V)) {
312 if (
const CallInst *CI = dyn_cast<CallInst>(
I))
313 if (isa<InlineAsm>(CI->getCalledValue()))
314 ErrMsg = ErrMsg +
", possible invalid constraint for vector type";
324 bool Smaller = ValueVT.
bitsLE(PartEVT);
351 unsigned OrigNumParts = NumParts;
352 assert(TLI.
isTypeLegal(PartVT) &&
"Copying to an illegal type!");
357 assert(!ValueVT.
isVector() &&
"Vector case handled elsewhere");
358 EVT PartEVT = PartVT;
359 if (PartEVT == ValueVT) {
360 assert(NumParts == 1 &&
"No-op copy with multiple parts!");
368 assert(NumParts == 1 &&
"Do not know what to promote to!");
373 "Unknown mismatch!");
375 Val = DAG.
getNode(ExtendKind, DL, ValueVT, Val);
381 assert(NumParts == 1 && PartEVT != ValueVT);
387 "Unknown mismatch!");
397 "Failed to tile the value with PartVT!");
400 if (PartEVT != ValueVT) {
402 Twine ErrMsg(
"scalar-to-vector conversion failed");
403 if (
const Instruction *
I = dyn_cast_or_null<Instruction>(V)) {
404 if (
const CallInst *CI = dyn_cast<CallInst>(
I))
405 if (isa<InlineAsm>(CI->getCalledValue()))
406 ErrMsg = ErrMsg +
", possible invalid constraint for vector type";
418 if (NumParts & (NumParts - 1)) {
421 "Do not know what to expand to!");
422 unsigned RoundParts = 1 <<
Log2_32(NumParts);
423 unsigned RoundBits = RoundParts * PartBits;
424 unsigned OddParts = NumParts - RoundParts;
427 getCopyToParts(DAG, DL, OddVal, Parts + RoundParts, OddParts, PartVT, V);
431 std::reverse(Parts + RoundParts, Parts + NumParts);
433 NumParts = RoundParts;
445 for (
unsigned StepSize = NumParts; StepSize > 1; StepSize /= 2) {
446 for (
unsigned i = 0; i < NumParts; i += StepSize) {
447 unsigned ThisBits = StepSize * PartBits / 2;
450 SDValue &Part1 = Parts[i+StepSize/2];
457 if (ThisBits == PartBits && ThisVT != PartVT) {
465 std::reverse(Parts, Parts + OrigNumParts);
475 assert(ValueVT.
isVector() &&
"Not a vector");
479 EVT PartEVT = PartVT;
480 if (PartEVT == ValueVT) {
495 TLI.getVectorIdxTy())));
513 bool Smaller = PartEVT.
bitsLE(ValueVT);
519 "Only trivial vector-to-scalar conversions should get here!");
521 PartVT, Val, DAG.
getConstant(0, TLI.getVectorIdxTy()));
523 bool Smaller = ValueVT.
bitsLE(PartVT);
535 unsigned NumIntermediates;
536 unsigned NumRegs = TLI.getVectorTypeBreakdown(*DAG.
getContext(), ValueVT,
538 NumIntermediates, RegisterVT);
541 assert(NumRegs == NumParts &&
"Part count doesn't match vector breakdown!");
543 assert(RegisterVT == PartVT &&
"Part type doesn't match vector breakdown!");
547 for (
unsigned i = 0; i != NumIntermediates; ++i) {
548 if (IntermediateVT.isVector())
551 DAG.
getConstant(i * (NumElements / NumIntermediates),
552 TLI.getVectorIdxTy()));
560 if (NumParts == NumIntermediates) {
563 for (
unsigned i = 0; i != NumParts; ++i)
565 }
else if (NumParts > 0) {
568 assert(NumParts % NumIntermediates == 0 &&
569 "Must expand into a divisible number of parts!");
570 unsigned Factor = NumParts / NumIntermediates;
571 for (
unsigned i = 0; i != NumIntermediates; ++i)
572 getCopyToParts(DAG, DL, Ops[i], &Parts[i*Factor], Factor, PartVT, V);
586 struct RegsForValue {
613 : ValueVTs(1, valuevt), RegVTs(1, regvt), Regs(regs) {}
623 for (
unsigned i = 0; i != NumRegs; ++i)
624 Regs.push_back(Reg + i);
625 RegVTs.push_back(RegisterVT);
641 void append(
const RegsForValue &RHS) {
642 ValueVTs.append(RHS.ValueVTs.begin(), RHS.ValueVTs.end());
643 RegVTs.append(RHS.RegVTs.begin(), RHS.RegVTs.end());
644 Regs.append(RHS.Regs.begin(), RHS.Regs.end());
654 const Value *V = 0)
const;
666 void AddInlineAsmOperands(
unsigned Kind,
667 bool HasMatching,
unsigned MatchingIdx,
669 std::vector<SDValue> &Ops)
const;
681 const Value *V)
const {
683 if (ValueVTs.empty())
691 for (
unsigned Value = 0, Part = 0, e = ValueVTs.size();
Value != e; ++
Value) {
698 for (
unsigned i = 0; i != NumRegs; ++i) {
703 P = DAG.
getCopyFromReg(Chain, dl, Regs[Part+i], RegisterVT, *Flag);
725 if (NumZeroBits == RegSize) {
737 if (NumSignBits == RegSize)
738 isSExt =
true, FromVT =
MVT::i1;
739 else if (NumZeroBits >= RegSize-1)
740 isSExt =
false, FromVT =
MVT::i1;
741 else if (NumSignBits > RegSize-8)
742 isSExt =
true, FromVT =
MVT::i8;
743 else if (NumZeroBits >= RegSize-8)
744 isSExt =
false, FromVT =
MVT::i8;
745 else if (NumSignBits > RegSize-16)
747 else if (NumZeroBits >= RegSize-16)
749 else if (NumSignBits > RegSize-32)
751 else if (NumZeroBits >= RegSize-32)
763 NumRegs, RegisterVT, ValueVT, V);
769 DAG.
getVTList(&ValueVTs[0], ValueVTs.size()),
770 &Values[0], ValueVTs.size());
779 const Value *V)
const {
783 unsigned NumRegs = Regs.size();
785 for (
unsigned Value = 0, Part = 0, e = ValueVTs.size();
Value != e; ++
Value) {
793 &Parts[Part], NumParts, RegisterVT, V, ExtendKind);
799 for (
unsigned i = 0; i != NumRegs; ++i) {
804 Part = DAG.
getCopyToReg(Chain, dl, Regs[i], Parts[i], *Flag);
811 if (NumRegs == 1 || Flag)
822 Chain = Chains[NumRegs-1];
830 void RegsForValue::AddInlineAsmOperands(
unsigned Code,
bool HasMatching,
831 unsigned MatchingIdx,
833 std::vector<SDValue> &Ops)
const {
839 else if (!Regs.empty() &&
854 for (
unsigned Value = 0, Reg = 0, e = ValueVTs.size();
Value != e; ++
Value) {
857 for (
unsigned i = 0; i != NumRegs; ++i) {
858 assert(Reg < Regs.size() &&
"Mismatch in # registers expected");
859 Ops.push_back(DAG.
getRegister(Regs[Reg++], RegisterVT));
882 UnusedArgNodeMap.clear();
884 PendingExports.clear();
896 DanglingDebugInfoMap.clear();
930 if (PendingExports.empty())
935 unsigned i = 0, e = PendingExports.size();
936 for (; i != e; ++i) {
937 assert(PendingExports[i].getNode()->getNumOperands() > 1);
938 if (PendingExports[i].getNode()->getOperand(0) == Root)
943 PendingExports.push_back(Root);
948 PendingExports.size());
949 PendingExports.clear();
956 if (isa<TerminatorInst>(&I))
957 HandlePHINodesInSuccessorBlocks(I.
getParent());
971 void SelectionDAGBuilder::visitPHI(
const PHINode &) {
981 #define HANDLE_INST(NUM, OPCODE, CLASS) \
982 case Instruction::OPCODE: visit##OPCODE((const CLASS&)I); break;
983 #include "llvm/IR/Instruction.def"
991 DanglingDebugInfo &DDI = DanglingDebugInfoMap[V];
995 unsigned DbgSDNodeOrder = DDI.getSDNodeOrder();
1000 if (!EmitFuncArgumentDbgValue(V, Variable, Offset, Val)) {
1002 Val.
getResNo(), Offset, dl, DbgSDNodeOrder);
1006 DEBUG(
dbgs() <<
"Dropping debug info for " << *DI <<
"\n");
1007 DanglingDebugInfoMap[V] = DanglingDebugInfo();
1023 unsigned InReg = It->second;
1027 N = RFV.getCopyFromRegs(DAG, FuncInfo,
getCurSDLoc(), Chain, NULL, V);
1058 if (
const Constant *
C = dyn_cast<Constant>(V)) {
1067 if (isa<ConstantPointerNull>(
C)) {
1072 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
C))
1079 visit(CE->getOpcode(), *CE);
1081 assert(N1.getNode() &&
"visit didn't populate the NodeMap!");
1085 if (isa<ConstantStruct>(
C) || isa<ConstantArray>(
C)) {
1094 for (
unsigned i = 0, e = Val->
getNumValues(); i != e; ++i)
1103 dyn_cast<ConstantDataSequential>(
C)) {
1105 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
1109 for (
unsigned i = 0, e = Val->
getNumValues(); i != e; ++i)
1113 if (isa<ArrayType>(CDS->getType()))
1116 VT, &Ops[0], Ops.
size());
1119 if (
C->getType()->isStructTy() ||
C->getType()->isArrayTy()) {
1120 assert((isa<ConstantAggregateZero>(
C) || isa<UndefValue>(
C)) &&
1121 "Unknown struct or array constant!");
1125 unsigned NumElts = ValueVTs.
size();
1129 for (
unsigned i = 0; i != NumElts; ++i) {
1130 EVT EltVT = ValueVTs[i];
1131 if (isa<UndefValue>(
C))
1132 Constants[i] = DAG.
getUNDEF(EltVT);
1153 for (
unsigned i = 0; i != NumElements; ++i)
1156 assert(isa<ConstantAggregateZero>(
C) &&
"Unknown vector constant!");
1164 Ops.
assign(NumElements, Op);
1169 VT, &Ops[0], Ops.
size());
1174 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(V)) {
1182 if (
const Instruction *Inst = dyn_cast<Instruction>(V)) {
1184 RegsForValue RFV(*DAG.
getContext(), *TLI, InReg, Inst->getType());
1186 return RFV.getCopyFromRegs(DAG, FuncInfo,
getCurSDLoc(), Chain, NULL, V);
1192 void SelectionDAGBuilder::visitRet(
const ReturnInst &
I) {
1215 unsigned NumValues = ValueVTs.size();
1218 for (
unsigned i = 0; i != NumValues; ++i) {
1234 unsigned NumValues = ValueVTs.
size();
1237 for (
unsigned j = 0, f = NumValues; j != f; ++j) {
1238 EVT VT = ValueVTs[j];
1258 &Parts[0], NumParts, PartVT, &I, ExtendKind);
1272 for (
unsigned i = 0; i < NumParts; ++i) {
1290 "LowerReturn didn't return a valid chain!");
1306 assert(!V->
use_empty() &&
"Unused value assigned virtual registers!");
1316 if (!isa<Instruction>(V) && !isa<Argument>(V))
return;
1329 if (
const Instruction *VI = dyn_cast<Instruction>(V)) {
1331 if (VI->getParent() == FromBB)
1340 if (isa<Argument>(V)) {
1363 void SelectionDAGBuilder::
1367 Weight = getEdgeWeight(Src, Dst);
1373 if (
const Instruction *I = dyn_cast<Instruction>(V))
1392 if (
const CmpInst *BOp = dyn_cast<CmpInst>(Cond)) {
1396 if (CurBB == SwitchBB ||
1400 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(Cond)) {
1402 }
else if (
const FCmpInst *
FC = dyn_cast<FCmpInst>(Cond)) {
1411 CaseBlock CB(Condition, BOp->getOperand(0),
1412 BOp->getOperand(1), NULL, TBB, FBB, CurBB);
1420 NULL, TBB, FBB, CurBB);
1433 if (!BOp || !(isa<BinaryOperator>(BOp) || isa<CmpInst>(BOp)) ||
1486 if (Cases.size() != 2)
return true;
1490 if ((Cases[0].CmpLHS == Cases[1].CmpLHS &&
1491 Cases[0].CmpRHS == Cases[1].CmpRHS) ||
1492 (Cases[0].CmpRHS == Cases[1].CmpLHS &&
1493 Cases[0].CmpLHS == Cases[1].CmpRHS)) {
1499 if (Cases[0].CmpRHS == Cases[1].CmpRHS &&
1500 Cases[0].CC == Cases[1].CC &&
1501 isa<Constant>(Cases[0].CmpRHS) &&
1502 cast<Constant>(Cases[0].CmpRHS)->isNullValue()) {
1503 if (Cases[0].CC ==
ISD::SETEQ && Cases[0].TrueBB == Cases[1].ThisBB)
1505 if (Cases[0].CC ==
ISD::SETNE && Cases[0].FalseBB == Cases[1].ThisBB)
1512 void SelectionDAGBuilder::visitBr(
const BranchInst &I) {
1521 if (++BBI != FuncInfo.
MF->
end())
1529 if (Succ0MBB != NextBlock)
1558 if (
const BinaryOperator *BOp = dyn_cast<BinaryOperator>(CondVal)) {
1568 assert(
SwitchCases[0].ThisBB == BrMBB &&
"Unexpected lowering!");
1572 for (
unsigned i = 1, e =
SwitchCases.size(); i != e; ++i) {
1585 for (
unsigned i = 1, e =
SwitchCases.size(); i != e; ++i)
1594 NULL, Succ0MBB, Succ1MBB, BrMBB);
1610 if (CB.CmpMHS == NULL) {
1623 assert(CB.CC ==
ISD::SETLE &&
"Can handle only LE ranges now");
1625 const APInt& Low = cast<ConstantInt>(CB.CmpLHS)->
getValue();
1626 const APInt& High = cast<ConstantInt>(CB.CmpRHS)->
getValue();
1631 if (cast<ConstantInt>(CB.CmpLHS)->isMinValue(
true)) {
1643 addSuccessorWithWeight(SwitchBB, CB.TrueBB, CB.TrueWeight);
1646 if (CB.TrueBB != CB.FalseBB)
1647 addSuccessorWithWeight(SwitchBB, CB.FalseBB, CB.FalseWeight);
1653 if (++BBI != FuncInfo.
MF->
end())
1658 if (CB.TrueBB == NextBlock) {
1680 assert(JT.Reg != -1U &&
"Should lower JT Header first!");
1694 JumpTableHeader &JTH,
1714 JumpTableReg, SwitchOp);
1715 JT.Reg = JumpTableReg;
1732 if (++BBI != FuncInfo.
MF->
end())
1739 if (JT.MBB != NextBlock)
1762 const Value *IRGuard = SPD.getGuard();
1770 true,
false,
false,
Align);
1775 true,
false,
false,
Align);
1813 false,
false).second;
1836 bool UsePtrType =
false;
1840 for (
unsigned i = 0, e = B.Cases.size(); i != e; ++i)
1862 if (++BBI != FuncInfo.
MF->
end())
1867 addSuccessorWithWeight(SwitchBB, B.Default);
1868 addSuccessorWithWeight(SwitchBB, MBB);
1874 if (MBB != NextBlock)
1884 uint32_t BranchWeightToNext,
1894 if (PopCount == 1) {
1902 }
else if (PopCount == BB.Range) {
1924 addSuccessorWithWeight(SwitchBB, B.TargetBB, B.ExtraWeight);
1926 addSuccessorWithWeight(SwitchBB, NextMBB, BranchWeightToNext);
1936 if (++BBI != FuncInfo.
MF->
end())
1939 if (NextMBB != NextBlock)
1946 void SelectionDAGBuilder::visitInvoke(
const InvokeInst &I) {
1955 if (isa<InlineAsm>(Callee))
1957 else if (Fn && Fn->isIntrinsic()) {
1968 addSuccessorWithWeight(InvokeMBB, Return);
1969 addSuccessorWithWeight(InvokeMBB, LandingPad);
1977 void SelectionDAGBuilder::visitResume(
const ResumeInst &RI) {
1978 llvm_unreachable(
"SelectionDAGBuilder shouldn't visit resume instructions!");
1981 void SelectionDAGBuilder::visitLandingPad(
const LandingPadInst &LP) {
1983 "Call to landingpad not in landing pad!");
1998 assert(ValueVTs.
size() == 2 &&
"Only two-valued landingpads are supported");
2021 bool SelectionDAGBuilder::handleSmallSwitchRange(CaseRec& CR,
2022 CaseRecVector& WorkList,
2027 size_t Size = CR.Range.second - CR.Range.first;
2039 if (++BBI != FuncInfo.
MF->
end())
2049 if (Size == 2 && CR.CaseBB == SwitchBB) {
2050 Case &
Small = *CR.Range.first;
2051 Case &Big = *(CR.Range.second-1);
2053 if (Small.Low == Small.High && Big.Low == Big.High && Small.BB == Big.BB) {
2054 const APInt& SmallValue = cast<ConstantInt>(Small.Low)->
getValue();
2055 const APInt& BigValue = cast<ConstantInt>(Big.Low)->
getValue();
2059 (SmallValue | BigValue) == BigValue) {
2061 APInt CommonBit = BigValue & ~SmallValue;
2062 assert((SmallValue | CommonBit) == BigValue &&
2066 EVT VT = CondLHS.getValueType();
2077 addSuccessorWithWeight(SwitchBB, Small.BB,
2078 Small.ExtraWeight + Big.ExtraWeight);
2079 addSuccessorWithWeight(SwitchBB, Default,
2099 uint32_t UnhandledWeights = 0;
2101 for (CaseItr I = CR.Range.first,
IE = CR.Range.second; I !=
IE; ++I) {
2102 uint32_t IWeight = I->ExtraWeight;
2103 UnhandledWeights += IWeight;
2104 for (CaseItr J = CR.Range.first; J < I; ++J) {
2105 uint32_t JWeight = J->ExtraWeight;
2106 if (IWeight > JWeight)
2112 Case &BackCase = *(CR.Range.second-1);
2114 NextBlock && Default != NextBlock && BackCase.BB != NextBlock) {
2118 for (Case *I = &*(CR.Range.second-2), *E = &*CR.Range.first-1; I != E; --
I)
2119 if (I->BB == NextBlock) {
2129 for (CaseItr I = CR.Range.first, E = CR.Range.second; I != E; ++I) {
2133 CurMF->
insert(BBI, FallThrough);
2142 const Value *RHS, *LHS, *MHS;
2144 if (I->High == I->Low) {
2147 LHS = SV; RHS = I->High; MHS = NULL;
2150 LHS = I->Low; MHS = SV; RHS = I->High;
2154 UnhandledWeights -= I->ExtraWeight;
2155 CaseBlock CB(CC, LHS, RHS, MHS, I->BB, FallThrough,
2164 if (CurBlock == SwitchBB)
2169 CurBlock = FallThrough;
2183 APInt LastExt = Last.
sext(BitWidth), FirstExt = First.
sext(BitWidth);
2184 return (LastExt - FirstExt + 1ULL);
2188 bool SelectionDAGBuilder::handleJTSwitchCase(CaseRec &CR,
2189 CaseRecVector &WorkList,
2193 Case& FrontCase = *CR.Range.first;
2194 Case& BackCase = *(CR.Range.second-1);
2196 const APInt &First = cast<ConstantInt>(FrontCase.Low)->
getValue();
2197 const APInt &Last = cast<ConstantInt>(BackCase.High)->
getValue();
2200 for (CaseItr I = CR.Range.first, E = CR.Range.second; I != E; ++I)
2212 uint64_t IntTSize = TSize.getLimitedValue(UINT64_MAX/10);
2213 if (IntTSize * 10 < IntRange * 4)
2217 <<
"First entry: " << First <<
". Last entry: " << Last <<
'\n'
2218 <<
"Range: " << Range <<
". Size: " << TSize <<
".\n\n");
2228 const BasicBlock *LLVMBB = CR.CaseBB->getBasicBlock();
2235 CurMF->
insert(BBI, JumpTableBB);
2237 addSuccessorWithWeight(CR.CaseBB, Default);
2238 addSuccessorWithWeight(CR.CaseBB, JumpTableBB);
2244 std::vector<MachineBasicBlock*> DestBBs;
2246 for (CaseItr I = CR.Range.first, E = CR.Range.second; I != E; ++TEI) {
2250 if (Low.
sle(TEI) && TEI.
sle(High)) {
2251 DestBBs.push_back(I->BB);
2255 DestBBs.push_back(Default);
2262 for (CaseItr I = CR.Range.first, E = CR.Range.second; I != E; ++I) {
2264 DestWeights.
find(I->BB);
2265 if (Itr != DestWeights.
end())
2266 Itr->second += I->ExtraWeight;
2268 DestWeights[I->BB] = I->ExtraWeight;
2272 BitVector SuccsHandled(CR.CaseBB->getParent()->getNumBlockIDs());
2273 for (std::vector<MachineBasicBlock*>::iterator I = DestBBs.begin(),
2274 E = DestBBs.end(); I != E; ++
I) {
2275 if (!SuccsHandled[(*I)->getNumber()]) {
2276 SuccsHandled[(*I)->getNumber()] =
true;
2278 DestWeights.
find(*I);
2279 addSuccessorWithWeight(JumpTableBB, *I,
2280 Itr != DestWeights.
end() ? Itr->second : 0);
2291 JumpTable JT(-1U, JTI, JumpTableBB, Default);
2292 JumpTableHeader JTH(First, Last, SV, CR.CaseBB, (CR.CaseBB == SwitchBB));
2293 if (CR.CaseBB == SwitchBB)
2296 JTCases.push_back(JumpTableBlock(JTH, JT));
2302 bool SelectionDAGBuilder::handleBTSplitSwitchCase(CaseRec& CR,
2303 CaseRecVector& WorkList,
2315 Case& FrontCase = *CR.Range.first;
2316 Case& BackCase = *(CR.Range.second-1);
2317 const BasicBlock *LLVMBB = CR.CaseBB->getBasicBlock();
2320 unsigned Size = CR.Range.second - CR.Range.first;
2322 const APInt &First = cast<ConstantInt>(FrontCase.Low)->
getValue();
2323 const APInt &Last = cast<ConstantInt>(BackCase.High)->
getValue();
2325 CaseItr Pivot = CR.Range.first + Size/2;
2330 for (CaseItr I = CR.Range.first, E = CR.Range.second;
2334 APInt LSize = FrontCase.size();
2335 APInt RSize = TSize-LSize;
2336 DEBUG(
dbgs() <<
"Selecting best pivot: \n"
2337 <<
"First: " << First <<
", Last: " << Last <<
'\n'
2338 <<
"LSize: " << LSize <<
", RSize: " << RSize <<
'\n');
2339 for (CaseItr I = CR.Range.first, J=I+1, E = CR.Range.second;
2342 const APInt &RBegin = cast<ConstantInt>(J->Low)->
getValue();
2344 assert((Range - 2ULL).isNonNegative() &&
2345 "Invalid case distance");
2348 volatile double LDensity =
2349 (double)LSize.roundToDouble() /
2350 (LEnd - First + 1ULL).roundToDouble();
2351 volatile double RDensity =
2353 (Last - RBegin + 1ULL).roundToDouble();
2354 double Metric = Range.
logBase2()*(LDensity+RDensity);
2357 <<
"LEnd: " << LEnd <<
", RBegin: " << RBegin <<
'\n'
2358 <<
"LDensity: " << LDensity
2359 <<
", RDensity: " << RDensity <<
'\n'
2360 <<
"Metric: " << Metric <<
'\n');
2361 if (FMetric < Metric) {
2364 DEBUG(
dbgs() <<
"Current metric set to: " << FMetric <<
'\n');
2374 assert((FMetric > 0) &&
"Should handle dense range earlier!");
2376 Pivot = CR.Range.first + Size/2;
2379 CaseRange LHSR(CR.Range.first, Pivot);
2380 CaseRange RHSR(Pivot, CR.Range.second);
2390 if ((LHSR.second - LHSR.first) == 1 &&
2391 LHSR.first->High == CR.GE &&
2392 cast<ConstantInt>(C)->getValue() ==
2393 (cast<ConstantInt>(CR.GE)->
getValue() + 1LL)) {
2394 TrueBB = LHSR.first->BB;
2397 CurMF->
insert(BBI, TrueBB);
2398 WorkList.push_back(CaseRec(TrueBB, C, CR.GE, LHSR));
2408 if ((RHSR.second - RHSR.first) == 1 && CR.LT &&
2409 cast<ConstantInt>(RHSR.first->Low)->getValue() ==
2410 (cast<ConstantInt>(CR.LT)->
getValue() - 1LL)) {
2411 FalseBB = RHSR.first->BB;
2414 CurMF->
insert(BBI, FalseBB);
2415 WorkList.push_back(CaseRec(FalseBB,CR.LT,C,RHSR));
2424 CaseBlock CB(
ISD::SETLT, SV, C, NULL, TrueBB, FalseBB, CR.CaseBB);
2426 if (CR.CaseBB == SwitchBB)
2437 bool SelectionDAGBuilder::handleBitTestsSwitchCase(CaseRec& CR,
2438 CaseRecVector& WorkList,
2446 Case& FrontCase = *CR.Range.first;
2447 Case& BackCase = *(CR.Range.second-1);
2458 for (CaseItr I = CR.Range.first, E = CR.Range.second;
2461 numCmps += (I->Low == I->High ? 1 : 2);
2466 for (CaseItr I = CR.Range.first, E = CR.Range.second; I!=E; ++I) {
2468 if (Dests.
size() > 3)
2472 DEBUG(
dbgs() <<
"Total number of unique destinations: "
2473 << Dests.
size() <<
'\n'
2474 <<
"Total number of comparisons: " << numCmps <<
'\n');
2477 const APInt& minValue = cast<ConstantInt>(FrontCase.Low)->
getValue();
2478 const APInt& maxValue = cast<ConstantInt>(BackCase.High)->
getValue();
2479 APInt cmpRange = maxValue - minValue;
2481 DEBUG(
dbgs() <<
"Compare range: " << cmpRange <<
'\n'
2482 <<
"Low bound: " << minValue <<
'\n'
2483 <<
"High bound: " << maxValue <<
'\n');
2485 if (cmpRange.
uge(IntPtrBits) ||
2486 (!(Dests.
size() == 1 && numCmps >= 3) &&
2487 !(Dests.
size() == 2 && numCmps >= 5) &&
2488 !(Dests.
size() >= 3 && numCmps >= 6)))
2491 DEBUG(
dbgs() <<
"Emitting bit tests\n");
2497 if (minValue.isNonNegative() && maxValue.
slt(IntPtrBits)) {
2498 cmpRange = maxValue;
2500 lowBound = minValue;
2503 CaseBitsVector CasesBits;
2504 unsigned i, count = 0;
2506 for (CaseItr I = CR.Range.first, E = CR.Range.second; I!=E; ++I) {
2508 for (i = 0; i < count; ++i)
2509 if (Dest == CasesBits[i].BB)
2513 assert((count < 3) &&
"Too much destinations to test!");
2514 CasesBits.push_back(CaseBits(0, Dest, 0, 0));
2518 const APInt& lowValue = cast<ConstantInt>(I->Low)->
getValue();
2519 const APInt& highValue = cast<ConstantInt>(I->High)->
getValue();
2521 uint64_t lo = (lowValue - lowBound).getZExtValue();
2522 uint64_t hi = (highValue - lowBound).getZExtValue();
2523 CasesBits[i].ExtraWeight += I->ExtraWeight;
2525 for (uint64_t j = lo; j <= hi; j++) {
2526 CasesBits[i].Mask |= 1ULL << j;
2527 CasesBits[i].Bits++;
2531 std::sort(CasesBits.begin(), CasesBits.end(), CaseBitsCmp());
2539 const BasicBlock *LLVMBB = CR.CaseBB->getBasicBlock();
2542 for (
unsigned i = 0, e = CasesBits.size(); i!=e; ++i) {
2543 DEBUG(
dbgs() <<
"Mask: " << CasesBits[i].Mask
2544 <<
", Bits: " << CasesBits[i].
Bits
2545 <<
", BB: " << CasesBits[i].BB <<
'\n');
2548 CurMF->
insert(BBI, CaseBB);
2549 BTC.push_back(BitTestCase(CasesBits[i].Mask,
2551 CasesBits[i].BB, CasesBits[i].ExtraWeight));
2557 BitTestBlock BTB(lowBound, cmpRange, SV,
2559 CR.CaseBB, Default, BTC);
2561 if (CR.CaseBB == SwitchBB)
2570 size_t SelectionDAGBuilder::Clusterify(CaseVector& Cases,
2578 const BasicBlock *SuccBB = i.getCaseSuccessor();
2581 uint32_t ExtraWeight =
2584 Cases.push_back(Case(i.getCaseValue(), i.getCaseValue(),
2585 SMBB, ExtraWeight));
2587 std::sort(Cases.begin(), Cases.end(), CaseCmp());
2590 if (Cases.size() >= 2)
2593 for (CaseItr I = Cases.begin(), J =
llvm::next(Cases.begin());
2594 J != Cases.end(); ) {
2595 const APInt& nextValue = cast<ConstantInt>(J->Low)->
getValue();
2596 const APInt& currentValue = cast<ConstantInt>(I->High)->
getValue();
2602 if ((nextValue - currentValue == 1) && (currentBB == nextBB)) {
2604 I->ExtraWeight += J->ExtraWeight;
2611 for (CaseItr I=Cases.begin(), E=Cases.end(); I!=E; ++
I, ++numCmps) {
2612 if (I->Low != I->High)
2623 for (
unsigned i = 0, e =
JTCases.size(); i != e; ++i)
2624 if (
JTCases[i].first.HeaderBB == First)
2625 JTCases[i].first.HeaderBB = Last;
2628 for (
unsigned i = 0, e =
BitTestCases.size(); i != e; ++i)
2633 void SelectionDAGBuilder::visitSwitch(
const SwitchInst &SI) {
2647 if (Default != NextBlock)
2659 size_t numCmps = Clusterify(Cases, SI);
2660 DEBUG(
dbgs() <<
"Clusterify finished. Total clusters: " << Cases.size()
2661 <<
". Total compares: " << numCmps <<
'\n');
2670 CaseRecVector WorkList;
2671 WorkList.push_back(CaseRec(SwitchMBB,0,0,
2672 CaseRange(Cases.begin(),Cases.end())));
2674 while (!WorkList.empty()) {
2676 CaseRec CR = WorkList.back();
2677 WorkList.pop_back();
2679 if (handleBitTestsSwitchCase(CR, WorkList, SV, Default, SwitchMBB))
2684 if (handleSmallSwitchRange(CR, WorkList, SV, Default, SwitchMBB))
2691 if (handleJTSwitchCase(CR, WorkList, SV, Default, SwitchMBB))
2696 handleBTSplitSwitchCase(CR, WorkList, SV, Default, SwitchMBB);
2700 void SelectionDAGBuilder::visitIndirectBr(
const IndirectBrInst &I) {
2707 bool Inserted = Done.
insert(BB);
2712 addSuccessorWithWeight(IndirectBrMBB, Succ);
2720 void SelectionDAGBuilder::visitFSub(
const User &I) {
2734 void SelectionDAGBuilder::visitBinary(
const User &I,
unsigned OpCode) {
2741 void SelectionDAGBuilder::visitShift(
const User &I,
unsigned Opcode) {
2750 unsigned Op2Size = Op2.getValueType().getSizeInBits();
2754 if (ShiftSize > Op2Size)
2761 else if (ShiftSize >=
Log2_32_Ceil(Op2.getValueType().getSizeInBits()))
2773 void SelectionDAGBuilder::visitSDiv(
const User &I) {
2780 if (isa<BinaryOperator>(&I) && cast<BinaryOperator>(&
I)->isExact() &&
2781 !isa<ConstantSDNode>(Op1) &&
2782 isa<ConstantSDNode>(Op2) && !cast<ConstantSDNode>(Op2)->isNullValue())
2790 void SelectionDAGBuilder::visitICmp(
const User &I) {
2792 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(&I))
2793 predicate = IC->getPredicate();
2794 else if (
const ConstantExpr *IC = dyn_cast<ConstantExpr>(&I))
2804 void SelectionDAGBuilder::visitFCmp(
const User &I) {
2806 if (
const FCmpInst *
FC = dyn_cast<FCmpInst>(&I))
2807 predicate =
FC->getPredicate();
2819 void SelectionDAGBuilder::visitSelect(
const User &I) {
2822 unsigned NumValues = ValueVTs.
size();
2823 if (NumValues == 0)
return;
2832 for (
unsigned i = 0; i != NumValues; ++i)
2834 TrueVal.getNode()->getValueType(TrueVal.getResNo()+i),
2837 TrueVal.getResNo() + i),
2839 FalseVal.getResNo() + i));
2843 &Values[0], NumValues));
2846 void SelectionDAGBuilder::visitTrunc(
const User &I) {
2853 void SelectionDAGBuilder::visitZExt(
const User &I) {
2861 void SelectionDAGBuilder::visitSExt(
const User &I) {
2869 void SelectionDAGBuilder::visitFPTrunc(
const User &I) {
2879 void SelectionDAGBuilder::visitFPExt(
const User &I) {
2886 void SelectionDAGBuilder::visitFPToUI(
const User &I) {
2893 void SelectionDAGBuilder::visitFPToSI(
const User &I) {
2900 void SelectionDAGBuilder::visitUIToFP(
const User &I) {
2907 void SelectionDAGBuilder::visitSIToFP(
const User &I) {
2914 void SelectionDAGBuilder::visitPtrToInt(
const User &I) {
2922 void SelectionDAGBuilder::visitIntToPtr(
const User &I) {
2930 void SelectionDAGBuilder::visitBitCast(
const User &I) {
2943 void SelectionDAGBuilder::visitAddrSpaceCast(
const User &I) {
2958 void SelectionDAGBuilder::visitInsertElement(
const User &I) {
2966 InVec, InVal, InIdx));
2969 void SelectionDAGBuilder::visitExtractElement(
const User &I) {
2983 unsigned Pos,
unsigned Size,
int Low) {
2984 for (
unsigned i = Pos, e = Pos+Size; i != e; ++i, ++Low)
2985 if (Mask[i] >= 0 && Mask[i] != Low)
2990 void SelectionDAGBuilder::visitShuffleVector(
const User &I) {
2996 unsigned MaskNumElts = Mask.size();
3003 if (SrcNumElts == MaskNumElts) {
3010 if (SrcNumElts < MaskNumElts && MaskNumElts % SrcNumElts == 0) {
3014 if (SrcNumElts*2 == MaskNumElts) {
3034 unsigned NumConcat = MaskNumElts / SrcNumElts;
3046 &MOps1[0], NumConcat);
3049 &MOps2[0], NumConcat);
3053 for (
unsigned i = 0; i != MaskNumElts; ++i) {
3055 if (Idx >= (
int)SrcNumElts)
3056 Idx -= SrcNumElts - MaskNumElts;
3065 if (SrcNumElts > MaskNumElts) {
3069 int MinRange[2] = {
static_cast<int>(SrcNumElts),
3070 static_cast<int>(SrcNumElts)};
3071 int MaxRange[2] = {-1, -1};
3073 for (
unsigned i = 0; i != MaskNumElts; ++i) {
3079 if (Idx >= (
int)SrcNumElts) {
3083 if (Idx > MaxRange[Input])
3084 MaxRange[Input] = Idx;
3085 if (Idx < MinRange[Input])
3086 MinRange[Input] = Idx;
3091 int RangeUse[2] = { -1, -1 };
3094 for (
unsigned Input = 0; Input < 2; ++Input) {
3095 if (MinRange[Input] >= (
int)SrcNumElts && MaxRange[Input] < 0) {
3096 RangeUse[Input] = 0;
3097 StartIdx[Input] = 0;
3103 StartIdx[Input] = (MinRange[Input]/MaskNumElts)*MaskNumElts;
3104 if (MaxRange[Input] - StartIdx[Input] < (
int)MaskNumElts &&
3105 StartIdx[Input] + MaskNumElts <= SrcNumElts)
3106 RangeUse[Input] = 1;
3109 if (RangeUse[0] == 0 && RangeUse[1] == 0) {
3113 if (RangeUse[0] >= 0 && RangeUse[1] >= 0) {
3115 for (
unsigned Input = 0; Input < 2; ++Input) {
3116 SDValue &Src = Input == 0 ? Src1 : Src2;
3117 if (RangeUse[Input] == 0)
3127 for (
unsigned i = 0; i != MaskNumElts; ++i) {
3130 if (Idx < (
int)SrcNumElts)
3133 Idx -= SrcNumElts + StartIdx[1] - MaskNumElts;
3150 for (
unsigned i = 0; i != MaskNumElts; ++i) {
3157 SDValue &Src = Idx < (int)SrcNumElts ? Src1 : Src2;
3158 if (Idx >= (
int)SrcNumElts) Idx -= SrcNumElts;
3168 VT, &Ops[0], Ops.
size()));
3171 void SelectionDAGBuilder::visitInsertValue(
const InsertValueInst &I) {
3176 bool IntoUndef = isa<UndefValue>(Op0);
3177 bool FromUndef = isa<UndefValue>(Op1);
3187 unsigned NumAggValues = AggValueVTs.
size();
3188 unsigned NumValValues = ValValueVTs.
size();
3194 for (; i != LinearIndex; ++i)
3195 Values[i] = IntoUndef ? DAG.
getUNDEF(AggValueVTs[i]) :
3200 for (; i != LinearIndex + NumValValues; ++i)
3201 Values[i] = FromUndef ? DAG.
getUNDEF(AggValueVTs[i]) :
3205 for (; i != NumAggValues; ++i)
3206 Values[i] = IntoUndef ? DAG.
getUNDEF(AggValueVTs[i]) :
3210 DAG.
getVTList(&AggValueVTs[0], NumAggValues),
3211 &Values[0], NumAggValues));
3218 bool OutOfUndef = isa<UndefValue>(Op0);
3226 unsigned NumValValues = ValValueVTs.
size();
3229 if (!NumValValues) {
3238 for (
unsigned i = LinearIndex; i != LinearIndex + NumValValues; ++i)
3239 Values[i - LinearIndex] =
3245 DAG.
getVTList(&ValValueVTs[0], NumValValues),
3246 &Values[0], NumValValues));
3249 void SelectionDAGBuilder::visitGetElementPtr(
const User &I) {
3259 const Value *Idx = *OI;
3260 if (
StructType *StTy = dyn_cast<StructType>(Ty)) {
3261 unsigned Field = cast<Constant>(Idx)->getUniqueInteger().getZExtValue();
3269 Ty = StTy->getElementType(Field);
3271 Ty = cast<SequentialType>(Ty)->getElementType();
3275 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(Idx)) {
3276 if (CI->isZero())
continue;
3304 if (ElementSize != 1) {
3306 unsigned Amt = ElementSize.
logBase2();
3325 void SelectionDAGBuilder::visitAlloca(
const AllocaInst &I) {
3341 if (AllocSize.getValueType() != IntPtr)
3352 if (Align <= StackAlign)
3358 AllocSize.getValueType(), AllocSize,
3363 AllocSize.getValueType(), AllocSize,
3378 void SelectionDAGBuilder::visitLoad(
const LoadInst &I) {
3380 return visitAtomicLoad(I);
3388 bool isNonTemporal = I.
getMetadata(
"nontemporal") != 0;
3389 bool isInvariant = I.
getMetadata(
"invariant.load") != 0;
3397 unsigned NumValues = ValueVTs.size();
3402 bool ConstantMemory =
false;
3410 ConstantMemory =
true;
3420 unsigned ChainI = 0;
3421 for (
unsigned i = 0; i != NumValues; ++i, ++ChainI) {
3429 assert(
PendingLoads.empty() &&
"PendingLoads must be serialized first");
3440 isNonTemporal, isInvariant, Alignment, TBAAInfo,
3447 if (!ConstantMemory) {
3458 &Values[0], NumValues));
3461 void SelectionDAGBuilder::visitStore(
const StoreInst &I) {
3463 return visitAtomicStore(I);
3471 unsigned NumValues = ValueVTs.
size();
3486 bool isNonTemporal = I.
getMetadata(
"nontemporal") != 0;
3490 unsigned ChainI = 0;
3491 for (
unsigned i = 0; i != NumValues; ++i, ++ChainI) {
3504 isVolatile, isNonTemporal, Alignment, TBAAInfo);
3505 Chains[ChainI] = St;
3515 bool Before,
SDLoc dl,
3570 void SelectionDAGBuilder::visitAtomicRMW(
const AtomicRMWInst &I) {
3617 void SelectionDAGBuilder::visitFence(
const FenceInst &I) {
3627 void SelectionDAGBuilder::visitAtomicLoad(
const LoadInst &I) {
3657 void SelectionDAGBuilder::visitAtomicStore(
const StoreInst &I) {
3693 void SelectionDAGBuilder::visitTargetIntrinsic(
const CallInst &I,
3694 unsigned Intrinsic) {
3710 TargetLowering::IntrinsicInfo Info;
3735 if (IsTgtIntrinsic) {
3738 VTs, &Ops[0], Ops.
size(),
3741 Info.align, Info.vol,
3742 Info.readMem, Info.writeMem);
3743 }
else if (!HasChain) {
3745 VTs, &Ops[0], Ops.
size());
3748 VTs, &Ops[0], Ops.
size());
3751 VTs, &Ops[0], Ops.
size());
3836 if (LimitFloatPrecision <= 6) {
3851 }
else if (LimitFloatPrecision <= 12) {
3907 t13, IntegerPartOfX));
3932 if (LimitFloatPrecision <= 6) {
3947 }
else if (LimitFloatPrecision <= 12) {
4028 if (LimitFloatPrecision <= 6) {
4041 }
else if (LimitFloatPrecision <= 12) {
4123 if (LimitFloatPrecision <= 6) {
4138 }
else if (LimitFloatPrecision <= 12) {
4209 SDValue TwoToFractionalPartOfX;
4210 if (LimitFloatPrecision <= 6) {
4225 }
else if (LimitFloatPrecision <= 12) {
4278 TwoToFractionalPartOfX);
4281 t13, IntegerPartOfX));
4292 bool IsExp10 =
false;
4297 IsExp10 = LHSC->isExactlyValue(Ten);
4319 SDValue TwoToFractionalPartOfX;
4320 if (LimitFloatPrecision <= 6) {
4335 }
else if (LimitFloatPrecision <= 12) {
4389 t13, IntegerPartOfX));
4406 unsigned Val = RHSC->getSExtValue();
4407 if ((
int)Val < 0) Val = -Val;
4434 CurSquare, CurSquare);
4439 if (RHSC->getSExtValue() < 0)
4472 SelectionDAGBuilder::EmitFuncArgumentDbgValue(
const Value *V,
MDNode *Variable,
4519 dyn_cast<FrameIndexSDNode>(LNode->getBasePtr().getNode()))
4526 bool IsIndirect = Offset != 0;
4531 Op->
getReg(), Offset, Variable));
4541 #if defined(_MSC_VER) && defined(setjmp) && \
4542 !defined(setjmp_undefined_for_msvc)
4543 # pragma push_macro("setjmp")
4545 # define setjmp_undefined_for_msvc
4552 SelectionDAGBuilder::visitIntrinsicCall(
const CallInst &I,
unsigned Intrinsic) {
4558 switch (Intrinsic) {
4561 visitTargetIntrinsic(I, Intrinsic);
4585 "Unknown address space");
4589 unsigned Align = cast<ConstantInt>(I.
getArgOperand(3))->getZExtValue();
4592 bool isVol = cast<ConstantInt>(I.
getArgOperand(4))->getZExtValue();
4603 "Unknown address space");
4607 unsigned Align = cast<ConstantInt>(I.
getArgOperand(3))->getZExtValue();
4610 bool isVol = cast<ConstantInt>(I.
getArgOperand(4))->getZExtValue();
4622 "Unknown address space");
4626 unsigned Align = cast<ConstantInt>(I.
getArgOperand(3))->getZExtValue();
4629 bool isVol = cast<ConstantInt>(I.
getArgOperand(4))->getZExtValue();
4640 assert((!DIVar || DIVar.isVariable()) &&
4641 "Variable in DbgDeclareInst should be either null or a DIVariable.");
4642 if (!Address || !DIVar) {
4643 DEBUG(
dbgs() <<
"Dropping debug info for " << DI <<
"\n");
4648 if (isa<UndefValue>(Address) ||
4649 (Address->
use_empty() && !isa<Argument>(Address))) {
4650 DEBUG(
dbgs() <<
"Dropping debug info for " << DI <<
"\n");
4654 SDValue &N = NodeMap[Address];
4655 if (!N.
getNode() && isa<Argument>(Address))
4657 N = UnusedArgNodeMap[Address];
4660 if (
const BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
4661 Address = BCI->getOperand(0);
4665 isa<Argument>(Address));
4669 if (isParameter && !AI) {
4674 0, dl, SDNodeOrder);
4678 EmitFuncArgumentDbgValue(Address, Variable, 0, N);
4683 0, dl, SDNodeOrder);
4686 DEBUG(
dbgs() <<
"Dropping debug info for " << DI <<
"\n");
4687 DEBUG(
dbgs() <<
"non-AllocaInst issue for Address: \n\t");
4695 if (!EmitFuncArgumentDbgValue(Address, Variable, 0, N)) {
4698 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(Address)) {
4704 0, dl, SDNodeOrder);
4710 DEBUG(
dbgs() <<
"Dropping debug info for " << DI <<
"\n");
4718 assert((!DIVar || DIVar.isVariable()) &&
4719 "Variable in DbgValueInst should be either null or a DIVariable.");
4730 if (isa<ConstantInt>(V) || isa<ConstantFP>(V) || isa<UndefValue>(V)) {
4731 SDV = DAG.
getDbgValue(Variable, V, Offset, dl, SDNodeOrder);
4737 if (!N.
getNode() && isa<Argument>(V))
4739 N = UnusedArgNodeMap[V];
4741 if (!EmitFuncArgumentDbgValue(V, Variable, Offset, N)) {
4743 N.
getResNo(), Offset, dl, SDNodeOrder);
4749 DanglingDebugInfo DDI(&DI, dl, SDNodeOrder);
4750 DanglingDebugInfoMap[V] = DDI;
4754 DEBUG(
dbgs() <<
"Dropping debug info for " << DI <<
"\n");
4759 if (
const BitCastInst *BCI = dyn_cast<BitCastInst>(V))
4760 V = BCI->getOperand(0);
4764 DEBUG(
dbgs() <<
"Dropping debug location info for:\n " << DI <<
"\n");
4765 DEBUG(
dbgs() <<
" Last seen at:\n " << *V <<
"\n");
4772 int FI = SI->second;
4819 assert(CI &&
"Non-constant call site value in eh.sjlj.callsite!");
4860 if (isa<ConstantSDNode>(ShAmt)) {
4861 visitTargetIntrinsic(I, Intrinsic);
4864 unsigned NewIntrinsic = 0;
4866 switch (Intrinsic) {
4916 uint64_t Idx = (cast<ConstantInt>(I.
getArgOperand(2))->getZExtValue() & 1) *
4930 uint64_t Idx = (cast<ConstantInt>(I.
getArgOperand(1))->getZExtValue() & 1) *
4948 switch (Intrinsic) {
5005 switch (Intrinsic) {
5147 assert(CI &&
"Non-constant type in __builtin_object_size?");
5216 if (TrapFuncName.
empty()) {
5231 std::pair<SDValue, SDValue> Result = TLI->
LowerCallTo(CLI);
5243 switch (Intrinsic) {
5261 unsigned rw = cast<ConstantInt>(I.
getArgOperand(1))->getZExtValue();
5289 E = Allocas.
end(); Object != E; ++Object) {
5290 AllocaInst *LifetimeObject = dyn_cast_or_null<AllocaInst>(*Object);
5293 if (!LifetimeObject)
5347 Type *RetTy = FTy->getReturnType();
5362 FTy->isVarArg(), Outs,
5366 int DemoteStackIdx = -100;
5368 if (!CanLowerReturn) {
5370 FTy->getReturnType());
5372 FTy->getReturnType());
5378 Entry.
Node = DemoteStackSlot;
5379 Entry.
Ty = StackSlotPtrType;
5388 Args.push_back(Entry);
5394 const Value *V = *i;
5405 Args.push_back(Entry);
5416 if (CallSiteIndex) {
5438 std::pair<SDValue,SDValue> Result = TLI->
LowerCallTo(CLI);
5439 assert((isTailCall || Result.second.getNode()) &&
5440 "Non-null chain expected with non-tail call!");
5441 assert((Result.second.getNode() || !Result.first.getNode()) &&
5442 "Null value expected with tail call!");
5443 if (Result.first.getNode()) {
5445 }
else if (!CanLowerReturn && Result.second.getNode()) {
5452 assert(PVTs.
size() == 1 &&
"Pointers should fit in one register");
5453 EVT PtrVT = PVTs[0];
5457 RetTy = FTy->getReturnType();
5460 unsigned NumValues = RetTys.
size();
5464 for (
unsigned i = 0; i < NumValues; ++i) {
5470 false,
false,
false, 1);
5482 &Values[0], Values.
size()));
5485 if (!Result.second.getNode()) {
5492 PendingExports.clear();
5504 MMI.
addInvoke(LandingPad, BeginLabel, EndLabel);
5513 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(*UI))
5514 if (IC->isEquality())
5515 if (
const Constant *C = dyn_cast<Constant>(IC->getOperand(1)))
5530 if (
const Constant *LoadInput = dyn_cast<Constant>(PtrVal)) {
5544 bool ConstantMemory =
false;
5549 ConstantMemory =
true;
5562 if (!ConstantMemory)
5569 void SelectionDAGBuilder::processIntegerCallValue(
const Instruction &I,
5583 bool SelectionDAGBuilder::visitMemCmpCall(
const CallInst &I) {
5603 std::pair<SDValue, SDValue> Res =
5608 if (Res.first.getNode()) {
5609 processIntegerCallValue(I, Res.first,
true);
5617 bool ActuallyDoIt =
true;
5624 ActuallyDoIt =
false;
5659 ActuallyDoIt =
false;
5668 processIntegerCallValue(I, Res,
false);
5680 bool SelectionDAGBuilder::visitMemChrCall(
const CallInst &I) {
5695 std::pair<SDValue, SDValue> Res =
5699 if (Res.first.getNode()) {
5711 bool SelectionDAGBuilder::visitStrCpyCall(
const CallInst &I,
bool isStpcpy) {
5718 !Arg1->getType()->isPointerTy() ||
5723 std::pair<SDValue, SDValue> Res =
5728 if (Res.first.getNode()) {
5740 bool SelectionDAGBuilder::visitStrCmpCall(
const CallInst &I) {
5747 !Arg1->getType()->isPointerTy() ||
5752 std::pair<SDValue, SDValue> Res =
5757 if (Res.first.getNode()) {
5758 processIntegerCallValue(I, Res.first,
true);
5769 bool SelectionDAGBuilder::visitStrLenCall(
const CallInst &I) {
5779 std::pair<SDValue, SDValue> Res =
5782 if (Res.first.getNode()) {
5783 processIntegerCallValue(I, Res.first,
false);
5794 bool SelectionDAGBuilder::visitStrNLenCall(
const CallInst &I) {
5801 !Arg1->getType()->isIntegerTy() ||
5806 std::pair<SDValue, SDValue> Res =
5810 if (Res.first.getNode()) {
5811 processIntegerCallValue(I, Res.first,
false);
5822 bool SelectionDAGBuilder::visitUnaryFloatCall(
const CallInst &I,
5836 void SelectionDAGBuilder::visitCall(
const CallInst &I) {
5846 const char *RenameFn = 0;
5850 if (
unsigned IID = II->getIntrinsicID(F)) {
5851 RenameFn = visitIntrinsicCall(I, IID);
5857 RenameFn = visitIntrinsicCall(I, IID);
5962 if (visitMemCmpCall(I))
5966 if (visitMemChrCall(I))
5970 if (visitStrCpyCall(I,
false))
5974 if (visitStrCpyCall(I,
true))
5978 if (visitStrCmpCall(I))
5982 if (visitStrLenCall(I))
5986 if (visitStrNLenCall(I))
6018 RegsForValue AssignedRegs;
6032 if (isa<BasicBlock>(CallOperandVal))
6035 llvm::Type *OpTy = CallOperandVal->getType();
6048 if (
StructType *STy = dyn_cast<StructType>(OpTy))
6049 if (STy->getNumElements() == 1)
6050 OpTy = STy->getElementType(0);
6088 SDISelAsmOperandInfo &OpInfo) {
6096 std::pair<unsigned, const TargetRegisterClass*> PhysReg =
6098 OpInfo.ConstraintVT);
6100 unsigned NumRegs = 1;
6106 PhysReg.second && !PhysReg.second->hasType(OpInfo.ConstraintVT)) {
6110 MVT RegVT = *PhysReg.second->vt_begin();
6111 if (RegVT.
getSizeInBits() == OpInfo.ConstraintVT.getSizeInBits()) {
6113 RegVT, OpInfo.CallOperand);
6114 OpInfo.ConstraintVT = RegVT;
6115 }
else if (RegVT.
isInteger() && OpInfo.ConstraintVT.isFloatingPoint()) {
6122 RegVT, OpInfo.CallOperand);
6123 OpInfo.ConstraintVT = RegVT;
6131 EVT ValueVT = OpInfo.ConstraintVT;
6135 if (
unsigned AssignedReg = PhysReg.first) {
6151 for (; *I != AssignedReg; ++
I)
6152 assert(I != RC->
end() &&
"Didn't find reg!");
6156 for (; NumRegs; --NumRegs, ++
I) {
6157 assert(I != RC->
end() &&
"Ran out of registers to allocate!");
6162 OpInfo.AssignedRegs = RegsForValue(Regs, RegVT, ValueVT);
6175 for (; NumRegs; --NumRegs)
6178 OpInfo.AssignedRegs = RegsForValue(Regs, RegVT, ValueVT);
6191 SDISelAsmOperandInfoVector ConstraintOperands;
6197 bool hasMemory =
false;
6201 for (
unsigned i = 0, e = TargetConstraints.size(); i != e; ++i) {
6202 ConstraintOperands.push_back(SDISelAsmOperandInfo(TargetConstraints[i]));
6203 SDISelAsmOperandInfo &OpInfo = ConstraintOperands.back();
6208 switch (OpInfo.Type) {
6211 if (OpInfo.isIndirect) {
6212 OpInfo.CallOperandVal =
const_cast<Value *
>(CS.
getArgument(ArgNo++));
6222 assert(ResNo == 0 &&
"Asm only has one result!");
6228 OpInfo.CallOperandVal =
const_cast<Value *
>(CS.
getArgument(ArgNo++));
6237 if (OpInfo.CallOperandVal) {
6238 if (
const BasicBlock *BB = dyn_cast<BasicBlock>(OpInfo.CallOperandVal)) {
6241 OpInfo.CallOperand =
getValue(OpInfo.CallOperandVal);
6244 OpVT = OpInfo.getCallOperandValEVT(*DAG.
getContext(), *TLI,
TD).
6248 OpInfo.ConstraintVT = OpVT;
6251 if (OpInfo.isIndirect)
6254 for (
unsigned j = 0, ee = OpInfo.Codes.size(); j != ee; ++j) {
6276 for (
unsigned i = 0, e = ConstraintOperands.size(); i != e; ++i) {
6277 SDISelAsmOperandInfo &OpInfo = ConstraintOperands[i];
6283 if (OpInfo.hasMatchingInput()) {
6284 SDISelAsmOperandInfo &Input = ConstraintOperands[OpInfo.MatchingInput];
6286 if (OpInfo.ConstraintVT != Input.ConstraintVT) {
6287 std::pair<unsigned, const TargetRegisterClass*> MatchRC =
6289 OpInfo.ConstraintVT);
6290 std::pair<unsigned, const TargetRegisterClass*> InputRC =
6292 Input.ConstraintVT);
6293 if ((OpInfo.ConstraintVT.isInteger() !=
6294 Input.ConstraintVT.isInteger()) ||
6295 (MatchRC.second != InputRC.second)) {
6297 " with a matching output constraint of"
6298 " incompatible type!");
6300 Input.ConstraintVT = OpInfo.ConstraintVT;
6314 !OpInfo.isIndirect) {
6315 assert((OpInfo.isMultipleAlternative ||
6317 "Can only indirectify direct input operands!");
6329 const Value *OpVal = OpInfo.CallOperandVal;
6330 if (isa<ConstantFP>(OpVal) || isa<ConstantInt>(OpVal) ||
6331 isa<ConstantVector>(OpVal) || isa<ConstantDataVector>(OpVal)) {
6344 OpInfo.CallOperand, StackSlot,
6347 OpInfo.CallOperand = StackSlot;
6351 OpInfo.CallOperandVal = 0;
6354 OpInfo.isIndirect =
true;
6365 for (
unsigned i = 0, e = ConstraintOperands.size(); i != e; ++i) {
6366 SDISelAsmOperandInfo &OpInfo = ConstraintOperands[i];
6375 std::vector<SDValue> AsmNodeOperands;
6376 AsmNodeOperands.push_back(
SDValue());
6377 AsmNodeOperands.push_back(
6385 AsmNodeOperands.push_back(DAG.
getMDNode(SrcLoc));
6389 unsigned ExtraInfo = 0;
6391 ExtraInfo |= InlineAsm::Extra_HasSideEffects;
6393 ExtraInfo |= InlineAsm::Extra_IsAlignStack;
6395 ExtraInfo |= IA->
getDialect() * InlineAsm::Extra_AsmDialect;
6398 for (
unsigned i = 0, e = TargetConstraints.size(); i != e; ++i) {
6411 ExtraInfo |= InlineAsm::Extra_MayLoad;
6413 ExtraInfo |= InlineAsm::Extra_MayStore;
6415 ExtraInfo |= (InlineAsm::Extra_MayLoad | InlineAsm::Extra_MayStore);
6424 RegsForValue RetValRegs;
6427 std::vector<std::pair<RegsForValue, Value*> > IndirectStoresToEmit;
6429 for (
unsigned i = 0, e = ConstraintOperands.size(); i != e; ++i) {
6430 SDISelAsmOperandInfo &OpInfo = ConstraintOperands[i];
6432 switch (OpInfo.Type) {
6437 assert(OpInfo.isIndirect &&
"Memory output must be indirect operand");
6443 AsmNodeOperands.push_back(OpInfo.CallOperand);
6451 if (OpInfo.AssignedRegs.Regs.empty()) {
6454 "couldn't allocate output register for constraint '" +
6455 Twine(OpInfo.ConstraintCode) +
"'");
6461 if (OpInfo.isIndirect) {
6462 IndirectStoresToEmit.push_back(std::make_pair(OpInfo.AssignedRegs,
6463 OpInfo.CallOperandVal));
6468 RetValRegs.append(OpInfo.AssignedRegs);
6474 .AddInlineAsmOperands(OpInfo.isEarlyClobber
6475 ? InlineAsm::Kind_RegDefEarlyClobber
6476 : InlineAsm::Kind_RegDef,
6477 false, 0, DAG, AsmNodeOperands);
6481 SDValue InOperandVal = OpInfo.CallOperand;
6483 if (OpInfo.isMatchingInputConstraint()) {
6486 unsigned OperandNo = OpInfo.getMatchedOperand();
6490 unsigned CurOp = InlineAsm::Op_FirstOperand;
6491 for (; OperandNo; --OperandNo) {
6494 cast<ConstantSDNode>(AsmNodeOperands[CurOp])->getZExtValue();
6502 cast<ConstantSDNode>(AsmNodeOperands[CurOp])->getZExtValue();
6506 if (OpInfo.isIndirect) {
6510 " don't know how to handle tied "
6511 "indirect register inputs");
6515 RegsForValue MatchedRegs;
6516 MatchedRegs.ValueVTs.push_back(InOperandVal.
getValueType());
6517 MVT RegVT = AsmNodeOperands[CurOp+1].getSimpleValueType();
6518 MatchedRegs.RegVTs.push_back(RegVT);
6527 "inline asm error: This value"
6528 " type register class is not natively supported!");
6533 MatchedRegs.getCopyToRegs(InOperandVal, DAG,
getCurSDLoc(),
6535 MatchedRegs.AddInlineAsmOperands(InlineAsm::Kind_RegUse,
6536 true, OpInfo.getMatchedOperand(),
6537 DAG, AsmNodeOperands);
6543 "Unexpected number of operands");
6547 OpInfo.getMatchedOperand());
6550 AsmNodeOperands.push_back(AsmNodeOperands[CurOp+1]);
6560 std::vector<SDValue> Ops;
6566 "invalid operand for inline asm constraint '" +
6567 Twine(OpInfo.ConstraintCode) +
"'");
6572 unsigned ResOpType =
6576 AsmNodeOperands.insert(AsmNodeOperands.end(), Ops.begin(), Ops.end());
6581 assert(OpInfo.isIndirect &&
"Operand must be indirect to be a mem!");
6583 "Memory operands expect pointer values");
6589 AsmNodeOperands.push_back(InOperandVal);
6595 "Unknown constraint type!");
6598 if (OpInfo.isIndirect) {
6601 "Don't know how to handle indirect register inputs yet "
6602 "for constraint '" +
6603 Twine(OpInfo.ConstraintCode) +
"'");
6608 if (OpInfo.AssignedRegs.Regs.empty()) {
6611 "couldn't allocate input reg for constraint '" +
6612 Twine(OpInfo.ConstraintCode) +
"'");
6616 OpInfo.AssignedRegs.getCopyToRegs(InOperandVal, DAG,
getCurSDLoc(),
6619 OpInfo.AssignedRegs.AddInlineAsmOperands(InlineAsm::Kind_RegUse,
false, 0,
6620 DAG, AsmNodeOperands);
6626 if (!OpInfo.AssignedRegs.Regs.empty())
6627 OpInfo.AssignedRegs.AddInlineAsmOperands(InlineAsm::Kind_Clobber,
6636 AsmNodeOperands[InlineAsm::Op_InputChain] = Chain;
6637 if (Flag.
getNode()) AsmNodeOperands.push_back(Flag);
6641 &AsmNodeOperands[0], AsmNodeOperands.size());
6646 if (!RetValRegs.Regs.empty()) {
6671 assert(ResultType == Val.
getValueType() &&
"Asm result value mismatch!");
6676 if (!IA->
hasSideEffects() && !hasMemory && IndirectStoresToEmit.empty())
6680 std::vector<std::pair<SDValue, const Value *> > StoresToEmit;
6684 for (
unsigned i = 0, e = IndirectStoresToEmit.size(); i != e; ++i) {
6685 RegsForValue &OutRegs = IndirectStoresToEmit[i].first;
6686 const Value *Ptr = IndirectStoresToEmit[i].second;
6689 StoresToEmit.push_back(std::make_pair(OutVal, Ptr));
6694 for (
unsigned i = 0, e = StoresToEmit.size(); i != e; ++i) {
6696 StoresToEmit[i].first,
6703 if (!OutChains.
empty())
6705 &OutChains[0], OutChains.
size());
6710 void SelectionDAGBuilder::visitVAStart(
const CallInst &I) {
6717 void SelectionDAGBuilder::visitVAArg(
const VAArgInst &I) {
6728 void SelectionDAGBuilder::visitVAEnd(
const CallInst &I) {
6735 void SelectionDAGBuilder::visitVACopy(
const CallInst &I) {
6751 std::pair<SDValue, SDValue>
6753 unsigned NumArgs,
SDValue Callee,
6756 Args.reserve(NumArgs);
6761 for (
unsigned ArgI = ArgIdx, ArgE = ArgIdx + NumArgs, AttrI = ArgIdx + 1;
6762 ArgI != ArgE; ++ArgI) {
6770 Entry.setAttributes(&CS, AttrI);
6771 Args.push_back(Entry);
6776 false,
false,
false, NumArgs,
6785 void SelectionDAGBuilder::visitStackmap(
const CallInst &CI) {
6789 assert(CI.
getType()->
isVoidTy() &&
"Stackmap cannot return a value.");
6796 SDValue Chain = Result.second;
6803 "Expected a callseq node.");
6811 for (
unsigned i = 0; i < 2; ++i) {
6814 cast<ConstantSDNode>(tmp)->getZExtValue(),
MVT::i32));
6844 void SelectionDAGBuilder::visitPatchpoint(
const CallInst &CI) {
6863 "Not enough arguments provided to the patchpoint intrinsic");
6866 unsigned NumCallArgs = isAnyRegCC ? 0 : NumArgs;
6867 std::pair<SDValue, SDValue> Result =
6871 SDValue Chain = Result.second;
6881 "Expected a callseq node.");
6883 bool hasGlue = Call->getGluedNode();
6889 for (
unsigned i = 0; i < 2; ++i) {
6892 cast<ConstantSDNode>(tmp)->getZExtValue(),
MVT::i32));
6902 unsigned NumCallRegArgs = Call->getNumOperands() - (hasGlue ? 4 : 3);
6903 NumCallRegArgs = isAnyRegCC ? NumArgs : NumCallRegArgs;
6912 for (
unsigned i = 4, e = NumArgs + 4; i != e; ++i)
6947 if (isAnyRegCC && hasDef) {
6952 assert(ValueVTs.
size() == 1 &&
"Expected only one return value type.");
6977 if (isAnyRegCC && hasDef) {
6990 std::pair<SDValue, SDValue>
6996 for (
unsigned I = 0, E = RetTys.
size(); I != E; ++
I) {
7000 for (
unsigned i = 0; i != NumRegs; ++i) {
7002 MyFlags.
VT = RegisterVT;
7019 for (
unsigned i = 0, e = Args.size(); i != e; ++i) {
7022 for (
unsigned Value = 0, NumValues = ValueVTs.
size();
7023 Value != NumValues; ++Value) {
7024 EVT VT = ValueVTs[Value];
7027 Args[i].Node.getResNo() + Value);
7029 unsigned OriginalAlignment =
7036 if (Args[i].isInReg)
7040 if (Args[i].isByVal) {
7044 Flags.setByValSize(
getDataLayout()->getTypeAllocSize(ElementTy));
7047 unsigned FrameAlign;
7048 if (Args[i].Alignment)
7049 FrameAlign = Args[i].Alignment;
7052 Flags.setByValAlign(FrameAlign);
7056 Flags.setOrigAlign(OriginalAlignment);
7065 else if (Args[i].isZExt)
7070 assert(CLI.
RetTy == Args[i].Ty && RetTys.
size() == NumValues &&
7071 "unexpected use of 'returned'");
7085 Flags.setReturned();
7091 for (
unsigned j = 0; j != NumParts; ++j) {
7095 i, j*Parts[j].getValueType().getStoreSize());
7096 if (NumParts > 1 && j == 0)
7099 MyFlags.Flags.setOrigAlign(1);
7102 CLI.
OutVals.push_back(Parts[j]);
7112 "LowerCall didn't return a valid chain!");
7114 "LowerCall emitted a return value for a tail call!");
7116 "LowerCall didn't emit the correct number of values!");
7127 DEBUG(
for (
unsigned i = 0, e = CLI.
Ins.
size(); i != e; ++i) {
7128 assert(InVals[i].getNode() &&
7129 "LowerCall emitted a null value!");
7130 assert(
EVT(CLI.
Ins[i].VT) == InVals[i].getValueType() &&
7131 "LowerCall emitted a value with the wrong type!");
7142 unsigned CurReg = 0;
7143 for (
unsigned I = 0, E = RetTys.
size(); I != E; ++
I) {
7149 NumRegs, RegisterVT, VT, NULL,
7157 if (ReturnValues.
empty())
7162 &ReturnValues[0], ReturnValues.
size());
7163 return std::make_pair(Res, CLI.
Chain);
7183 "Copy from a reg to the same reg!");
7189 RFV.getCopyToRegs(Op, DAG,
getCurSDLoc(), Chain, 0, V);
7190 PendingExports.push_back(Chain);
7207 const User *U = *UI;
7208 if (cast<Instruction>(U)->getParent() != Entry || isa<SwitchInst>(U))
7214 void SelectionDAGISel::LowerArguments(
const Function &F) {
7232 ISD::InputArg RetArg(Flags, RegisterVT, ValueVTs[0],
true, 0, 0);
7239 I != E; ++
I, ++Idx) {
7243 unsigned PartBase = 0;
7244 for (
unsigned Value = 0, NumValues = ValueVTs.
size();
7245 Value != NumValues; ++Value) {
7246 EVT VT = ValueVTs[Value];
7249 unsigned OriginalAlignment =
7267 unsigned FrameAlign;
7280 for (
unsigned i = 0; i != NumRegs; ++i) {
7281 ISD::InputArg MyFlags(Flags, RegisterVT, VT, isArgValueUsed,
7283 if (NumRegs > 1 && i == 0)
7287 MyFlags.Flags.setOrigAlign(1);
7302 "LowerFormalArguments didn't return a valid chain!");
7303 assert(InVals.
size() == Ins.
size() &&
7304 "LowerFormalArguments didn't emit the correct number of values!");
7306 for (
unsigned i = 0, e = Ins.
size(); i != e; ++i) {
7307 assert(InVals[i].getNode() &&
7308 "LowerFormalArguments emitted a null value!");
7309 assert(
EVT(Ins[i].VT) == InVals[i].getValueType() &&
7310 "LowerFormalArguments emitted a value with the wrong type!");
7315 DAG.setRoot(NewRoot);
7325 MVT VT = ValueVTs[0].getSimpleVT();
7329 RegVT, VT, NULL, AssertOp);
7337 DAG.setRoot(NewRoot);
7349 unsigned NumValues = ValueVTs.
size();
7358 dyn_cast<FrameIndexSDNode>(InVals[i].getNode()))
7362 for (
unsigned Val = 0; Val != NumValues; ++Val) {
7363 EVT VT = ValueVTs[Val];
7375 NumParts, PartVT, VT,
7383 if (ArgValues.
empty())
7388 dyn_cast<FrameIndexSDNode>(ArgValues[0].getNode()))
7391 SDValue Res = DAG.getMergeValues(&ArgValues[0], NumValues,
7399 dyn_cast<FrameIndexSDNode>(LNode->getBasePtr().getNode()))
7422 assert(i == InVals.
size() &&
"Argument register count mismatch!");
7437 SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(
const BasicBlock *LLVMBB) {
7446 if (!isa<PHINode>(SuccBB->
begin()))
continue;
7451 if (!SuccsHandled.
insert(SuccMBB))
continue;
7470 if (
const Constant *C = dyn_cast<Constant>(PHIOp)) {
7483 assert(isa<AllocaInst>(PHIOp) &&
7485 "Didn't codegen value into a register!??");
7496 for (
unsigned vti = 0, vte = ValueVTs.
size(); vti != vte; ++vti) {
7497 EVT VT = ValueVTs[vti];
7499 for (
unsigned i = 0, e = NumRegisters; i != e; ++i)
7501 Reg += NumRegisters;
7506 ConstantsOut.clear();
7512 SelectionDAGBuilder::StackProtectorDescriptor::
7521 MF->
insert(++BBI, SuccMBB);
virtual SDValue LowerReturn(SDValue, CallingConv::ID, bool, const SmallVectorImpl< ISD::OutputArg > &, const SmallVectorImpl< SDValue > &, SDLoc, SelectionDAG &) const
static unsigned getTruncatedArgReg(const SDValue &N)
unsigned getStackAlignment() const
int strcmp(const char *s1, const char *s2);
BasicBlock * getSuccessor(unsigned i) const
Value * getValueOperand()
const Value * getCalledValue() const
std::vector< BitTestBlock > BitTestCases
const MachineInstrBuilder & addMetadata(const MDNode *MD) const
static MVT getIntegerVT(unsigned BitWidth)
void setByValAlign(unsigned A)
void push_back(const T &Elt)
unsigned Log2_32_Ceil(uint32_t Value)
const MachineFunction * getParent() const
SelectionDAGBuilder * SDB
SDValue getConstant(uint64_t Val, EVT VT, bool isTarget=false)
AsmDialect getDialect() const
static ConstantInt * getFalse(LLVMContext &Context)
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrcpy(SelectionDAG &DAG, SDLoc DL, SDValue Chain, SDValue Dest, SDValue Src, MachinePointerInfo DestPtrInfo, MachinePointerInfo SrcPtrInfo, bool isStpcpy) const
ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred)
SDValue getValue(unsigned R) const
virtual const TargetLowering * getTargetLowering() const
Abstract base class of comparison instructions.
void ComputeValueVTs(const TargetLowering &TLI, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=0, uint64_t StartingOffset=0)
AtomicOrdering getOrdering() const
Returns the ordering constraint on this cmpxchg.
virtual bool pointsToConstantMemory(const Location &Loc, bool OrLocal=false)
*p = old <signed v ? old : v
const AttributeSet & getAttributes() const
LLVMContext * getContext() const
LLVM Argument representation.
SDValue getCopyToReg(SDValue Chain, SDLoc dl, unsigned Reg, SDValue N)
void LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool IsTailCall, MachineBasicBlock *LandingPad=NULL)
void addStackRoot(int Num, const Constant *Metadata)
void GetUnderlyingObjects(Value *V, SmallVectorImpl< Value * > &Objects, const DataLayout *TD=0, unsigned MaxLookup=6)
GlobalVariable * ExtractTypeInfo(Value *V)
ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
void ExportFromCurrentBlock(const Value *V)
SynchronizationScope getSynchScope() const
const TargetLibraryInfo * LibInfo
ArrayRef< unsigned > getIndices() const
Sign extended before/after call.
unsigned getNumRegisters(LLVMContext &Context, EVT VT) const
Force argument to be passed in register.
SDValue getVAArg(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr, SDValue SV, unsigned Align)
virtual void ComputeConstraintToUse(AsmOperandInfo &OpInfo, SDValue Op, SelectionDAG *DAG=0) const
void CopyValueToVirtualRegister(const Value *V, unsigned Reg)
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
unsigned arg_size() const
static unsigned LimitFloatPrecision
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
long double copysignl(long double x, long double y);
unsigned getNumOperands() const
Nested function static chain.
const TargetMachine & getTarget() const
long double rintl(long double x);
unsigned getPrefTypeAlignment(Type *Ty) const
static unsigned getFlagWord(unsigned Kind, unsigned NumOps)
SDNode * getGluedNode() const
long double truncl(long double x);
virtual ConstraintType getConstraintType(const std::string &Constraint) const
Given a constraint, return the type of constraint it is for this target.
static bool isVirtualRegister(unsigned Reg)
bool usesUnderscoreSetJmp() const
Determine if we should use _setjmp or setjmp to implement llvm.setjmp.
const std::string & getAsmString() const
long double sinl(long double x);
SDValue getBasicBlock(MachineBasicBlock *MBB)
unsigned getOpcode() const
*p = old <unsigned v ? old : v
const TargetSelectionDAGInfo & getSelectionDAGInfo() const
void setValue(const Value *V, SDValue NewN)
void visitJumpTableHeader(JumpTable &JT, JumpTableHeader &JTH, MachineBasicBlock *SwitchBB)
*p = old >unsigned v ? old : v
Type * getTypeForEVT(LLVMContext &Context) const
unsigned getSizeInBits() const
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
Type * getReturnType() const
const Function * getParent() const
Return the enclosing method, or null if none.
Value * getNewValOperand()
double nearbyint(double x);
virtual bool isZExtFree(Type *, Type *) const
MDNode - a tuple of other values.
const SDValue & getOperand(unsigned Num) const
bool supportJumpTables() const
Return whether the target can generate code for jump tables.
const Function * getFunction() const
size_t strnlen(const char *s, size_t maxlen);
static IntegerType * getInt64Ty(LLVMContext &C)
double roundToDouble(bool isSigned) const
Converts this APInt to a double value.
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned char TargetFlags=0)
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
const SDValue & setRoot(SDValue N)
double __sqrt_finite(double x);
static IntegerType * getInt16Ty(LLVMContext &C)
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
const MCPhysReg * iterator
void DeleteNode(SDNode *N)
SDValue getValueImpl(const Value *V)
SDValue getConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offs=0, bool isT=false, unsigned char TargetFlags=0)
*p = old >signed v ? old : v
DebugLoc getCurDebugLoc() const
uint64_t getOffset() const
EntryToken - This is the marker used to indicate the start of a region.
void AddDbgValue(SDDbgValue *DB, SDNode *SD, bool isParameter)
float __sqrt_finite(float x);
unsigned getResNo() const
get the index which selects a specific result in the SDNode
void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, unsigned Num)
bool bitsLT(EVT VT) const
bitsLT - Return true if this has less bits than VT.
ValTy * getArgument(unsigned ArgNo) const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
long double nearbyintl(long double x);
SDValue getExternalSymbol(const char *Sym, EVT VT)
CallingConv::ID getCallingConv() const
EVT getValueType(Type *Ty, bool AllowUnknown=false) const
static MachinePointerInfo getFixedStack(int FI, int64_t offset=0)
void setCurrentCallSite(unsigned Site)
setCurrentCallSite - Set the call site currently being processed.
StringRef getName() const
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
SDValue getValue(const Value *V)
getValue - Return an SDValue for the given Value.
unsigned getPointerSizeInBits(uint32_t AS=0) const
bool isSingleValueType() const
long double roundl(long double x);
StackProtectorDescriptor SPDescriptor
SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, bool isVolatile, bool isNonTemporal, bool isInvariant, unsigned Alignment, const MDNode *TBAAInfo=0, const MDNode *Ranges=0)
bool isVector() const
isVector - Return true if this is a vector value type.
EVT getShiftAmountTy(EVT LHSTy) const
void visitSPDescriptorParent(StackProtectorDescriptor &SPD, MachineBasicBlock *ParentBB)
long double __sqrt_finite(long double x);
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
long double fabsl(long double x);
bool isUnknown() const
isUnknown - Return true if this is an unknown location.
void setAttributes(ImmutableCallSite *CS, unsigned AttrIdx)
Set CallLoweringInfo attribute flags based on a call instruction and called function attributes...
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
bool isUnconditional() const
void dump() const
dump - Support for debugging, callable in GDB: V->dump()
unsigned CountTrailingOnes_64(uint64_t Value)
static unsigned getFlagWordForRegClass(unsigned InputFlag, unsigned RC)
SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, bool isVolatile, bool isNonTemporal, unsigned Alignment, const MDNode *TBAAInfo=0)
long double cosl(long double x);
PCMARKER - This corresponds to the pcmarker intrinsic.
MCSymbol * CreateTempSymbol()
void visitSwitchCase(CaseBlock &CB, MachineBasicBlock *SwitchBB)
const HexagonInstrInfo * TII
const StructLayout * getStructLayout(StructType *Ty) const
static SDValue GetExponent(SelectionDAG &DAG, SDValue Op, const TargetLowering &TLI, SDLoc dl)
bool getLibFunc(StringRef funcName, LibFunc::Func &F) const
static MachineOperand CreateReg(unsigned 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)
#define llvm_unreachable(msg)
EVT getValueType(unsigned ResNo) const
bool hasOptimizedCodeGen(LibFunc::Func F) const
MachineFunction & getMachineFunction() const
void visitJumpTable(JumpTable &JT)
visitJumpTable - Emit JumpTable node in the current MBB
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, const SDValue *Ops, unsigned NumOps, bool isSigned, SDLoc dl, bool doesNotReturn=false, bool isReturnValueUsed=true) const
Returns a pair of (return value, chain).
TargetLowering::ConstraintType ConstraintType
virtual EVT getSetCCResultType(LLVMContext &Context, EVT VT) const
double copysign(double x, double y);
bool isReg() const
isReg - Tests if this is a MO_Register operand.
unsigned getNumArgOperands() const
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
const TargetLowering * getTargetLowering() const
const TargetRegisterClass * getRegClass(unsigned Reg) const
const Value * getCalledValue() const
void assign(unsigned NumElts, const T &Elt)
bool getInsertFencesForAtomic() const
StringRef getTrapFunctionName() const
EVT getScalarType() const
Abstract Stack Frame Information.
static bool isRegDefEarlyClobberKind(unsigned Flag)
std::pair< SDValue, SDValue > LowerCallOperands(const CallInst &CI, unsigned ArgIdx, unsigned NumArgs, SDValue Callee, bool useVoidTy=false)
Lower an argument list according to the target calling convention.
bool bitsGE(EVT VT) const
bitsGE - Return true if this has no less bits than VT.
static SDValue expandExp(SDLoc dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
Type * getAllocatedType() const
void setByValSize(unsigned S)
bool hasDebugInfo() const
SDVTList getVTList(EVT VT)
unsigned getStoreSize() const
virtual MVT getPointerTy(uint32_t=0) const
void setFunctionContextIndex(int I)
ID
LLVM Calling Convention Representation.
static SDValue expandLog10(SDLoc dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
const MachineInstrBuilder & addImm(int64_t Val) const
Hidden pointer to structure to return.
bool isInteger() const
isInteger - Return true if this is an integer, or a vector integer type.
SDDbgValue * getDbgValue(MDNode *MDPtr, SDNode *N, unsigned R, uint64_t Off, DebugLoc DL, unsigned O)
SynchronizationScope getSynchScope() const
SDValue getConstantFP(double Val, EVT VT, bool isTarget=false)
SmallVector< ISD::InputArg, 32 > Ins
uint64_t getZExtValue() const
Return the zero extended value.
EVT getVectorElementType() const
MVT getSimpleValueType(Type *Ty, bool AllowUnknown=false) const
Return the MVT corresponding to this LLVM type. See getValueType.
int getArgumentFrameIndex(const Argument *A)
getArgumentFrameIndex - Get frame index for the byval argument.
void emitError(unsigned LocCookie, const Twine &ErrorStr)
SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp, MachinePointerInfo PtrInfo, unsigned Alignment, AtomicOrdering Ordering, SynchronizationScope SynchScope)
Value * getPointerOperand()
AtomicOrdering getOrdering() const
Returns the ordering constraint on this RMW.
bool usesUnderscoreLongJmp() const
Determine if we should use _longjmp or longjmp to implement llvm.longjmp.
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
unsigned createJumpTableIndex(const std::vector< MachineBasicBlock * > &DestBBs)
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
const LiveOutInfo * GetLiveOutRegInfo(unsigned Reg)
unsigned getNumValues() const
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
void setCallSiteBeginLabel(MCSymbol *BeginLabel, unsigned Site)
setCallSiteBeginLabel - Map the begin label for a call site.
const char * data() const
enable_if_c< std::numeric_limits< T >::is_integer &&!std::numeric_limits< T >::is_signed, std::size_t >::type countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1...
This contains information for each constraint that we are lowering.
Simple integer binary arithmetic operators.
SDValue getVectorShuffle(EVT VT, SDLoc dl, SDValue N1, SDValue N2, const int *MaskElts)
static SDValue ExpandPowI(SDLoc DL, SDValue LHS, SDValue RHS, SelectionDAG &DAG)
ExpandPowI - Expand a llvm.powi intrinsic.
CallingConv::ID getCallingConv() const
SDValue getNonRegisterValue(const Value *V)
Represents a floating point comparison operator.
BasicBlock * getSuccessor(unsigned i) const
SmallVector< ISD::OutputArg, 32 > Outs
This class represents a no-op cast from one type to another.
unsigned getCurrentCallSite()
uint64_t getTypeStoreSize(Type *Ty)
bool isFloatingPointTy() const
bool ShouldEmitAsBranches(const std::vector< CaseBlock > &Cases)
SDValue getUNDEF(EVT VT)
getUNDEF - Return an UNDEF node. UNDEF does not have a useful SDLoc.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const
ValTy * getCalledValue() const
static SDValue expandLog2(SDLoc dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
int getMinimumJumpTableEntries() const
static void getCopyToPartsVector(SelectionDAG &DAG, SDLoc dl, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, const Value *V)
virtual SDValue LowerCall(CallLoweringInfo &, SmallVectorImpl< SDValue > &) const
CodeGenOpt::Level getOptLevel() const
ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred)
unsigned getNumElements() const
Return the number of elements in the Vector type.
static bool isRegDefKind(unsigned Flag)
void setStackProtectorIndex(int I)
MDNode * getVariable() const
void setOrigAlign(unsigned A)
Type * getElementType() const
virtual MVT getVectorIdxTy() const
bool bitsLE(EVT VT) const
bitsLE - Return true if this has no more bits than VT.
void AddLandingPadInfo(const LandingPadInst &I, MachineModuleInfo &MMI, MachineBasicBlock *MBB)
const BasicBlock * getBasicBlock() const
UNDEF - An undefined node.
SDValue getAddrSpaceCast(SDLoc dl, EVT VT, SDValue Ptr, unsigned SrcAS, unsigned DestAS)
getAddrSpaceCast - Return an AddrSpaceCastSDNode.
uint64_t getElementOffset(unsigned Idx) const
unsigned getNumSuccessors() const
SDNode * getNode() const
get the SDNode which holds the desired result
void GetReturnInfo(Type *ReturnType, AttributeSet attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI)
bundle_iterator< MachineInstr, instr_iterator > iterator
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
int memcmp(const void *s1, const void *s2, size_t n);
unsigned getStoreSize() const
SDValue getMDNode(const MDNode *MD)
getMDNode - Return an MDNodeSDNode which holds an MDNode.
bool isTypeLegal(EVT VT) const
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain, SDValue Src, MachinePointerInfo SrcPtrInfo) const
initializer< Ty > init(const Ty &Val)
FPOpFusion::FPOpFusionMode AllowFPOpFusion
bool isInteger() const
isInteger - Return true if this is an integer, or a vector integer type.
Control flow instructions. These all have token chains.
unsigned getAlignment() const
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=0)
std::vector< std::pair< MachineInstr *, unsigned > > PHINodesToUpdate
void setCallsEHReturn(bool b)
unsigned getVectorNumElements() const
bool hasSideEffects() const
SynchronizationScope getSynchScope() const
LLVM Basic Block Representation.
long double floorl(long double x);
void EmitBranchForMergedCondition(const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB)
const SDValue & getOperand(unsigned i) const
InstrTy * getInstruction() const
BasicBlock * getSuccessor(unsigned idx) const
const Function * getParent() const
Simple binary floating point operators.
bool isOperationLegalOrCustom(unsigned Op, EVT VT) const
unsigned getIntrinsicID() const LLVM_READONLY
LLVM Constant Representation.
static APInt ComputeRange(const APInt &First, const APInt &Last)
bool isVector() const
isVector - Return true if this is a vector value type.
Value * getCompareOperand()
static SDValue InsertFenceForAtomic(SDValue Chain, AtomicOrdering Order, SynchronizationScope Scope, bool Before, SDLoc dl, SelectionDAG &DAG, const TargetLowering &TLI)
bool isFloatingPoint() const
isFloatingPoint - Return true if this is a FP, or a vector FP type.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
unsigned getAlignment() const
virtual std::pair< SDValue, SDValue > EmitTargetCodeForMemchr(SelectionDAG &DAG, SDLoc dl, SDValue Chain, SDValue Src, SDValue Char, SDValue Length, MachinePointerInfo SrcPtrInfo) const
bool isInTailCallPosition(ImmutableCallSite CS, const TargetLowering &TLI)
const DebugLoc & getDebugLoc() const
getDebugLoc - Return the debug location for this node as a DebugLoc.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sext(unsigned width) const
Sign extend to a new width.
static unsigned getNumOperandRegisters(unsigned Flag)
bool sle(const APInt &RHS) const
Signed less or equal comparison.
static Type * getVoidTy(LLVMContext &C)
static cl::opt< unsigned, true > LimitFPPrecision("limit-float-precision", cl::desc("Generate low-precision inline sequences ""for some float libcalls"), cl::location(LimitFloatPrecision), cl::init(0))
ItTy next(ItTy it, Dist n)
SDValue getCopyFromReg(SDValue Chain, SDLoc dl, unsigned Reg, EVT VT)
void visitBitTestCase(BitTestBlock &BB, MachineBasicBlock *NextMBB, uint32_t BranchWeightToNext, unsigned Reg, BitTestCase &B, MachineBasicBlock *SwitchBB)
visitBitTestCase - this function produces one "bit test"
SDValue getSExtOrTrunc(SDValue Op, SDLoc DL, EVT VT)
const DataLayout * getDataLayout() const
virtual bool isFMAFasterThanFMulAndFAdd(EVT) const
virtual void EmitFunctionEntryCode()
Represent an integer comparison operator.
unsigned getBitWidth() const
Return the number of bits in the APInt.
static SDValue getMemCmpLoad(const Value *PtrVal, MVT LoadVT, Type *LoadTy, SelectionDAGBuilder &Builder)
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
unsigned getOpcode() const
TRAP - Trapping instruction.
bool doesNotAccessMemory() const
Determine if the call does not access memory.
void *memchr(const void *s, int c, size_t n);
Value * getOperand(unsigned i) const
Zero extended before/after call.
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
static SDValue expandExp2(SDLoc dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
Value * getPointerOperand()
DEBUGTRAP - Trap intended to get the attention of a debugger.
float nearbyintf(float x);
void addInvoke(MachineBasicBlock *LandingPad, MCSymbol *BeginLabel, MCSymbol *EndLabel)
unsigned getTypeIDFor(const GlobalVariable *TI)
unsigned countPopulation() const
Count the number of bits set.
SDLoc getCurSDLoc() const
static SDValue getF32Constant(SelectionDAG &DAG, unsigned Flt)
getF32Constant - Get 32-bit floating point constant.
virtual unsigned getByValTypeAlignment(Type *Ty) const
Constant * ConstantFoldLoadFromConstPtr(Constant *C, const DataLayout *TD=0)
unsigned getVectorTypeBreakdown(LLVMContext &Context, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const
Location - A description of a memory location.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrnlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain, SDValue Src, SDValue MaxLength, MachinePointerInfo SrcPtrInfo) const
Bit counting operators with an undefined result for zero inputs.
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
unsigned ExceptionPointerVirtReg
unsigned CountPopulation_64(uint64_t Value)
static bool isMemKind(unsigned Flag)
virtual const TargetFrameLowering * getFrameLowering() const
std::vector< ArgListEntry > ArgListTy
unsigned getExceptionPointerRegister() const
SDValue getGlobalAddress(const GlobalValue *GV, SDLoc DL, EVT VT, int64_t offset=0, bool isTargetGA=false, unsigned char TargetFlags=0)
LLVMContext & getContext() const
All values hold a context through their type.
MDNode * getVariable() const
virtual SDValue LowerFormalArguments(SDValue, CallingConv::ID, bool, const SmallVectorImpl< ISD::InputArg > &, SDLoc, SelectionDAG &, SmallVectorImpl< SDValue > &) const
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
const SDValue & getRoot() const
const MCInstrDesc & get(unsigned Opcode) const
MachineBasicBlock * MBB
MBB - The current block.
unsigned getNumSuccessors() const
BasicBlock * getSuccessor(unsigned i) const
SDValue getMemcpy(SDValue Chain, SDLoc dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
void CopyToExportRegsIfNeeded(const Value *V)
std::vector< AsmOperandInfo > AsmOperandInfoVector
virtual const TargetInstrInfo * getInstrInfo() const
unsigned getABITypeAlignment(Type *Ty) const
void visitSPDescriptorFailure(StackProtectorDescriptor &SPD)
static IntegerType * get(LLVMContext &C, unsigned NumBits)
Get or create an IntegerType instance.
SDValue getConvertRndSat(EVT VT, SDLoc dl, SDValue Val, SDValue DTy, SDValue STy, SDValue Rnd, SDValue Sat, ISD::CvtCode Code)
static Constant * getBitCast(Constant *C, Type *Ty)
virtual MVT getTypeForExtArgOrReturn(MVT VT, ISD::NodeType) const
AtomicOrdering getOrdering() const
Returns the ordering effect of this store.
unsigned CountPopulation_32(uint32_t Value)
virtual unsigned getJumpTableEncoding() const
static PointerType * getUnqual(Type *ElementType)
Class for constant integers.
bool slt(const APInt &RHS) const
Signed less than comparison.
uint64_t getTypeAllocSize(Type *Ty) const
const MCContext & getContext() const
unsigned logBase2() const
SmallVector< MachineInstr *, 8 > ArgDbgValues
Instr is a return instruction.
void setCallsUnwindInit(bool b)
MDNode * getMetadata(unsigned KindID) const
SDValue getIntPtrConstant(uint64_t Val, bool isTarget=false)
virtual std::pair< SDValue, SDValue > EmitTargetCodeForMemcmp(SelectionDAG &DAG, SDLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, MachinePointerInfo Op1PtrInfo, MachinePointerInfo Op2PtrInfo) const
Byte Swap and Counting operators.
SDValue getMemmove(SDValue Chain, SDLoc dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
void visit(const Instruction &I)
static bool isOnlyUsedInEntryBlock(const Argument *A, bool FastISel)
Value * stripPointerCasts()
Strips off any unneeded pointer casts, all-zero GEPs and aliases from the specified value...
static bool isSequentialInRange(const SmallVectorImpl< int > &Mask, unsigned Pos, unsigned Size, int Low)
Function * getCalledFunction() const
AtomicOrdering getOrdering() const
Returns the ordering effect of this fence.
MachineFrameInfo * getFrameInfo()
const BasicBlock & getEntryBlock() const
size_t strlen(const char *s);
void UpdateSplitBlock(MachineBasicBlock *First, MachineBasicBlock *Last)
char *stpcpy(char *s1, const char *s2);
static void getCopyToParts(SelectionDAG &DAG, SDLoc DL, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, const Value *V, ISD::NodeType ExtendKind=ISD::ANY_EXTEND)
static ConstantInt * getTrue(LLVMContext &Context)
BinOp getOperation() const
ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC)
unsigned CreateRegs(Type *Ty)
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
static SDValue GetSignificand(SelectionDAG &DAG, SDValue Op, SDLoc dl)
double long double log2l(long double x);
static bool areJTsAllowed(const TargetLowering &TLI)
unsigned Log2_32(uint32_t Value)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
AttributeSet getAttributes() const
Return the attribute list for this Function.
GCFunctionInfo * GFI
GFI - Garbage collection metadata for the function.
SynchronizationScope getSynchScope() const
Value * getArgOperand(unsigned i) const
static const unsigned MaxParallelChains
Class for arbitrary precision integers.
SDValue getMemIntrinsicNode(unsigned Opcode, SDLoc dl, const EVT *VTs, unsigned NumVTs, const SDValue *Ops, unsigned NumOps, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, bool Vol=false, bool ReadMem=true, bool WriteMem=true)
BranchProbabilityInfo * BPI
Value * getIncomingValueForBlock(const BasicBlock *BB) const
virtual const TargetRegisterClass * getRegClassFor(MVT VT) const
ZERO_EXTEND - Used for integer types, zeroing the new bits.
int CreateVariableSizedObject(unsigned Alignment)
static SDValue getCopyFromParts(SelectionDAG &DAG, SDLoc DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, const Value *V, ISD::NodeType AssertOp=ISD::DELETED_NODE)
std::vector< JumpTableBlock > JTCases
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT)
ANY_EXTEND - Used for integer types. The high bits are undefined.
static bool IsOnlyUsedInZeroEqualityComparison(const Value *V)
static void GetRegistersForValue(SelectionDAG &DAG, const TargetLowering &TLI, SDLoc DL, SDISelAsmOperandInfo &OpInfo)
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
Value * getCondition() const
int getStackProtectorIndex() const
SDValue getBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, bool isTarget=false, unsigned char TargetFlags=0)
virtual bool CanLowerReturn(CallingConv::ID, MachineFunction &, bool, const SmallVectorImpl< ISD::OutputArg > &, LLVMContext &) const
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
SmallVector< SDValue, 8 > PendingLoads
long double ceill(long double x);
unsigned countLeadingOnes() const
Count the number of leading one bits.
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, bool MayNeedSP=false, const AllocaInst *Alloca=0)
static bool isPhysicalRegister(unsigned Reg)
cl::opt< std::string > TrapFuncName("trap-func", cl::Hidden, cl::desc("Emit a call to trap function rather than a trap instruction"), cl::init(""))
unsigned ExceptionSelectorVirtReg
SmallVector< SDValue, 32 > OutVals
bool isLandingPad() const
static const fltSemantics IEEEsingle
Value * getCondition() const
Analysis pass providing branch probability information.
BasicBlock * getDefaultDest() const
Bitwise operators - logical and, logical or, logical xor.
SDValue BuildExactSDIV(SDValue Op1, SDValue Op2, SDLoc dl, SelectionDAG &DAG) const
Given an exact SDIV by a constant, create a multiplication with the multiplicative inverse of the con...
pointer data()
data - Return a pointer to the vector's buffer, even if empty().
bool isAggregateType() const
MachineRegisterInfo & getRegInfo()
static IntegerType * getInt32Ty(LLVMContext &C)
AtomicOrdering getOrdering() const
Returns the ordering effect of this fence.
virtual void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
bool isDeclaration() const
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
unsigned getAlignment() const
Value * getPointerOperand()
ImmutableCallSite - establish a view to a call site for examination.
unsigned getSizeInBits() const
getSizeInBits - Return the size of the specified value type in bits.
void FindMergedConditions(const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB, unsigned Opc)
FindMergedConditions - If Cond is an expression like.
void ReplaceAllUsesWith(SDValue From, SDValue Op)
virtual const DataLayout * getDataLayout() const
DBG_VALUE - a mapping of the llvm.dbg.value intrinsic.
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
static Constant * getZeroValueForNegation(Type *Ty)
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
const Type * getScalarType() const
MachineSDNode * getMachineNode(unsigned Opcode, SDLoc dl, EVT VT)
SDValue getMemset(SDValue Chain, SDLoc dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, MachinePointerInfo DstPtrInfo)
unsigned CreateReg(MVT VT)
CreateReg - Allocate a single virtual register for the given type.
DenseMap< const AllocaInst *, int > StaticAllocaMap
unsigned getNumCases() const
void setVariableDbgInfo(MDNode *N, unsigned Slot, DebugLoc Loc)
bool hasLocalLinkage() const
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrcmp(SelectionDAG &DAG, SDLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, MachinePointerInfo Op1PtrInfo, MachinePointerInfo Op2PtrInfo) const
virtual AsmOperandInfoVector ParseConstraints(ImmutableCallSite CS) const
unsigned getReg() const
getReg - Returns the register number.
bool isFloatingPoint() const
isFloatingPoint - Return true if this is a FP, or a vector FP type.
void erase(iterator MBBI)
virtual bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &, unsigned) const
SDValue getJumpTable(int JTI, EVT VT, bool isTarget=false, unsigned char TargetFlags=0)
void insert(iterator MBBI, MachineBasicBlock *MBB)
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
void setUnusedArgValue(const Value *V, SDValue NewN)
unsigned getParamAlignment(unsigned i) const
Extract the alignment for a call or parameter (0=unknown).
virtual bool allowsUnalignedMemoryAccesses(EVT, bool *=0) const
Determine if the target supports unaligned memory accesses.
SDValue getZExtOrTrunc(SDValue Op, SDLoc DL, EVT VT)
LLVM Value Representation.
SDValue getRegister(unsigned Reg, EVT VT)
void init(GCFunctionInfo *gfi, AliasAnalysis &aa, const TargetLibraryInfo *li)
SDValue getEHLabel(SDLoc dl, SDValue Root, MCSymbol *Label)
unsigned getOpcode() const
getOpcode() returns a member of one of the enums like Instruction::Add.
Value * getAddress() const
SDValue getValueType(EVT)
const Value * getArraySize() const
long double exp2l(long double x);
uint64_t getTypeSizeInBits(Type *Ty) const
BasicBlockListType::iterator iterator
const TargetLowering & getTargetLoweringInfo() const
const Value * getValue() const
std::vector< CaseBlock > SwitchCases
uint32_t getEdgeWeight(const BasicBlock *Src, unsigned IndexInSuccessors) const
Get the raw edge weight calculated for the edge.
char *strcpy(char *s1, const char *s2);
SDValue getSrcValue(const Value *v)
getSrcValue - Construct a node to track a Value* through the backend.
DenseMap< const BasicBlock *, MachineBasicBlock * > MBBMap
MBBMap - A mapping from LLVM basic blocks to their machine code entry.
vt_iterator vt_begin() const
MachineModuleInfo & getMMI() const
void clearDanglingDebugInfo()
SDValue getMergeValues(const SDValue *Ops, unsigned NumOps, SDLoc dl)
getMergeValues - Create a MERGE_VALUES node from the given operands.
CallingConv::ID getCallingConv() const
static SDValue getCopyFromPartsVector(SelectionDAG &DAG, SDLoc DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, const Value *V)
const MCRegisterInfo & MRI
static SDValue expandPow(SDLoc dl, SDValue LHS, SDValue RHS, SelectionDAG &DAG, const TargetLowering &TLI)
SDValue getTargetConstant(uint64_t Val, EVT VT)
DenseMap< MachineBasicBlock *, SmallVector< unsigned, 4 > > LPadToCallSiteMap
LPadToCallSiteMap - Map a landing pad to the call site indexes.
unsigned getExceptionSelectorRegister() const
SDValue getSetCC(SDLoc DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond)
MVT getVectorElementType() const
static APInt getNullValue(unsigned numBits)
Get the '0' value.
SDValue getEntryNode() const
TRUNCATE - Completely drop the high bits.
bool isUIntN(unsigned N, uint64_t x)
void setArgumentFrameIndex(const Argument *A, int FI)
DenseMap< const Constant *, unsigned > ConstantsOut
bool isAlignStack() const
iterator find(const KeyT &Val)
void ComputeUsesVAFloatArgument(const CallInst &I, MachineModuleInfo *MMI)
unsigned ComputeLinearIndex(Type *Ty, const unsigned *Indices, const unsigned *IndicesEnd, unsigned CurIndex=0)
bool isExportableFromCurrentBlock(const Value *V, const BasicBlock *FromBB)
SynchronizationScope getSynchScope() const
float copysignf(float x, float y);
DenseMap< const Value *, unsigned > ValueMap
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
bool isJumpExpensive() const
Value * getPointerOperand()
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const
void addSuccessor(MachineBasicBlock *succ, uint32_t weight=0)
static MachineOperand CreateFI(int Idx)
void visitBitTestHeader(BitTestBlock &B, MachineBasicBlock *SwitchBB)
static RegisterPass< NVPTXAllocaHoisting > X("alloca-hoisting","Hoisting alloca instructions in non-entry ""blocks to the entry block")
LocationClass< Ty > location(Ty &L)
const BasicBlock * getParent() const
bool isExportedInst(const Value *V)
INITIALIZE_PASS(GlobalMerge,"global-merge","Global Merge", false, false) bool GlobalMerge const DataLayout * TD
virtual void LowerOperationWrapper(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const
SmallVector< int, 16 > getShuffleMask() const
void resolveDanglingDebugInfo(const Value *V, SDValue Val)
static SDValue expandLog(SDLoc dl, SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI)
static unsigned getFlagWordForMatchingOp(unsigned InputFlag, unsigned MatchedOperandNo)
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
unsigned getLiveInPhysReg(unsigned VReg) const
long double sqrtl(long double x);
unsigned InitializeRegForValue(const Value *V)
bool empty() const
empty - Check if the string is empty.
unsigned getVectorNumElements() const
static bool InBlock(const Value *V, const BasicBlock *BB)
const Use * const_op_iterator