74 #define DEBUG_TYPE "irtranslator" 94 if (!R.getLocation().isValid() || TPC.isGlobalISelAbortEnabled())
95 R << (
" (in function: " + MF.getName() +
")").str();
97 if (TPC.isGlobalISelAbortEnabled())
117 uint64_t StartingOffset = 0) {
119 if (
StructType *STy = dyn_cast<StructType>(&Ty)) {
121 for (
unsigned I = 0,
E = STy->getNumElements();
I !=
E; ++
I)
127 if (
ArrayType *ATy = dyn_cast<ArrayType>(&Ty)) {
128 Type *EltTy = ATy->getElementType();
130 for (
unsigned i = 0, e = ATy->getNumElements(); i != e; ++i)
132 StartingOffset + i * EltSize);
141 Offsets->push_back(StartingOffset * 8);
145 IRTranslator::allocateVRegs(
const Value &Val) {
146 assert(!VMap.contains(Val) &&
"Value already allocated in VMap");
147 auto *
Regs = VMap.getVRegs(Val);
148 auto *
Offsets = VMap.getOffsets(Val);
152 for (
unsigned i = 0; i < SplitTys.
size(); ++i)
158 auto VRegsIt = VMap.findVRegs(Val);
159 if (VRegsIt != VMap.vregs_end())
160 return *VRegsIt->second;
163 return *VMap.getVRegs(Val);
166 auto *
VRegs = VMap.getVRegs(Val);
167 auto *
Offsets = VMap.getOffsets(Val);
170 "Don't know how to create an empty vreg");
176 if (!isa<Constant>(Val)) {
177 for (
auto Ty : SplitTys)
184 auto &
C = cast<Constant>(Val);
186 while (
auto Elt =
C.getAggregateElement(Idx++)) {
187 auto EltRegs = getOrCreateVRegs(*Elt);
188 std::copy(EltRegs.begin(), EltRegs.end(), std::back_inserter(*
VRegs));
191 assert(SplitTys.size() == 1 &&
"unexpectedly split LLT");
193 bool Success = translate(cast<Constant>(Val),
VRegs->front());
198 R <<
"unable to translate constant: " <<
ore::NV(
"Type", Val.
getType());
207 int IRTranslator::getOrCreateFrameIndex(
const AllocaInst &AI) {
208 if (FrameIndices.find(&AI) != FrameIndices.end())
209 return FrameIndices[&AI];
213 ElementSize * cast<ConstantInt>(AI.
getArraySize())->getZExtValue();
222 int &FI = FrameIndices[&AI];
227 unsigned IRTranslator::getMemOpAlignment(
const Instruction &
I) {
228 unsigned Alignment = 0;
229 Type *ValTy =
nullptr;
230 if (
const StoreInst *
SI = dyn_cast<StoreInst>(&I)) {
231 Alignment =
SI->getAlignment();
232 ValTy =
SI->getValueOperand()->getType();
233 }
else if (
const LoadInst *LI = dyn_cast<LoadInst>(&I)) {
234 Alignment = LI->getAlignment();
235 ValTy = LI->getType();
242 ValTy = AI->getCompareOperand()->
getType();
243 }
else if (
const AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(&I)) {
252 R <<
"unable to translate memop: " <<
ore::NV(
"Opcode", &I);
262 assert(MBB &&
"BasicBlock was not encountered before");
267 assert(NewPred &&
"new predecessor must be a real MachineBasicBlock");
268 MachinePreds[Edge].push_back(NewPred);
271 bool IRTranslator::translateBinaryOp(
unsigned Opcode,
const User &U,
279 unsigned Op0 = getOrCreateVReg(*U.
getOperand(0));
280 unsigned Op1 = getOrCreateVReg(*U.
getOperand(1));
281 unsigned Res = getOrCreateVReg(U);
291 .
addDef(getOrCreateVReg(U))
295 return translateBinaryOp(TargetOpcode::G_FSUB, U, MIRBuilder);
298 bool IRTranslator::translateCompare(
const User &U,
301 unsigned Op0 = getOrCreateVReg(*U.
getOperand(0));
302 unsigned Op1 = getOrCreateVReg(*U.
getOperand(1));
303 unsigned Res = getOrCreateVReg(U);
308 MIRBuilder.
buildICmp(Pred, Res, Op0, Op1);
316 MIRBuilder.
buildFCmp(Pred, Res, Op0, Op1);
332 unsigned VReg = Ret ? packRegs(*Ret, MIRBuilder) : 0;
337 const BranchInst &BrInst = cast<BranchInst>(U);
361 bool IRTranslator::translateSwitch(
const User &U,
370 const SwitchInst &SwInst = cast<SwitchInst>(U);
371 const unsigned SwCondValue = getOrCreateVReg(*SwInst.
getCondition());
375 for (
auto &CaseIt : SwInst.
cases()) {
376 const unsigned CaseValueReg = getOrCreateVReg(*CaseIt.getCaseValue());
380 const BasicBlock *TrueBB = CaseIt.getCaseSuccessor();
385 addMachineCFGPred({OrigBB, TrueBB}, &CurMBB);
394 MIRBuilder.
setMBB(*FalseMBB);
399 MIRBuilder.
buildBr(DefaultMBB);
402 addMachineCFGPred({OrigBB, DefaultBB}, &CurMBB);
407 bool IRTranslator::translateIndirectBr(
const User &U,
411 const unsigned Tgt = getOrCreateVReg(*BrInst.
getAddress());
423 const LoadInst &LI = cast<LoadInst>(U);
436 for (
unsigned i = 0; i < Regs.
size(); ++i) {
441 unsigned BaseAlign = getMemOpAlignment(LI);
446 MIRBuilder.
buildLoad(Regs[i], Addr, *MMO);
465 for (
unsigned i = 0; i < Vals.
size(); ++i) {
470 unsigned BaseAlign = getMemOpAlignment(SI);
490 for (
auto Idx : EVI->indices())
492 }
else if (
const InsertValueInst *IVI = dyn_cast<InsertValueInst>(&U)) {
493 for (
auto Idx : IVI->indices())
500 return 8 *
static_cast<uint64_t
>(
504 bool IRTranslator::translateExtractValue(
const User &U,
512 auto &DstRegs = allocateVRegs(U);
514 for (
unsigned i = 0; i < DstRegs.size(); ++i)
515 DstRegs[i] = SrcRegs[Idx++];
520 bool IRTranslator::translateInsertValue(
const User &U,
524 auto &DstRegs = allocateVRegs(U);
528 auto InsertedIt = InsertedRegs.
begin();
530 for (
unsigned i = 0; i < DstRegs.size(); ++i) {
531 if (DstOffsets[i] >= Offset && InsertedIt != InsertedRegs.
end())
532 DstRegs[i] = *InsertedIt++;
534 DstRegs[i] = SrcRegs[i];
540 bool IRTranslator::translateSelect(
const User &U,
542 unsigned Tst = getOrCreateVReg(*U.
getOperand(0));
547 for (
unsigned i = 0; i < ResRegs.size(); ++i)
548 MIRBuilder.
buildSelect(ResRegs[i], Tst, Op0Regs[i], Op1Regs[i]);
553 bool IRTranslator::translateBitCast(
const User &U,
558 unsigned SrcReg = getOrCreateVReg(*U.
getOperand(0));
559 auto &
Regs = *VMap.getVRegs(U);
565 Regs.push_back(SrcReg);
566 VMap.getOffsets(U)->push_back(0);
570 return translateCast(TargetOpcode::G_BITCAST, U, MIRBuilder);
573 bool IRTranslator::translateCast(
unsigned Opcode,
const User &U,
576 unsigned Res = getOrCreateVReg(U);
581 bool IRTranslator::translateGetElementPtr(
const User &U,
588 unsigned BaseReg = getOrCreateVReg(Op0);
597 const Value *Idx = GTI.getOperand();
598 if (
StructType *StTy = GTI.getStructTypeOrNull()) {
599 unsigned Field = cast<Constant>(Idx)->getUniqueInteger().getZExtValue();
607 if (
const auto *CI = dyn_cast<ConstantInt>(Idx)) {
608 Offset += ElementSize * CI->getSExtValue();
616 MIRBuilder.
buildGEP(NewBaseReg, BaseReg, OffsetReg);
618 BaseReg = NewBaseReg;
622 unsigned IdxReg = getOrCreateVReg(*Idx);
623 if (MRI->
getType(IdxReg) != OffsetTy) {
631 unsigned GepOffsetReg;
632 if (ElementSize != 1) {
633 unsigned ElementSizeReg =
637 MIRBuilder.
buildMul(GepOffsetReg, ElementSizeReg, IdxReg);
639 GepOffsetReg = IdxReg;
642 MIRBuilder.
buildGEP(NewBaseReg, BaseReg, GepOffsetReg);
643 BaseReg = NewBaseReg;
648 unsigned OffsetReg = getOrCreateVReg(*
ConstantInt::get(OffsetIRTy, Offset));
649 MIRBuilder.
buildGEP(getOrCreateVReg(U), BaseReg, OffsetReg);
653 MIRBuilder.
buildCopy(getOrCreateVReg(U), BaseReg);
657 bool IRTranslator::translateMemfunc(
const CallInst &CI,
662 if (cast<PointerType>(DstTy)->getAddressSpace() != 0 ||
667 for (
int i = 0; i < 3; ++i) {
674 case Intrinsic::memmove:
675 case Intrinsic::memcpy: {
677 if(cast<PointerType>(SrcTy)->getAddressSpace() != 0)
679 Callee = ID == Intrinsic::memcpy ?
"memcpy" :
"memmove";
682 case Intrinsic::memset:
694 void IRTranslator::getStackGuard(
unsigned DstReg,
698 auto MIB = MIRBuilder.
buildInstr(TargetOpcode::LOAD_STACK_GUARD);
713 MIB.setMemRefs(MemRefs, MemRefs + 1);
716 bool IRTranslator::translateOverflowIntrinsic(
const CallInst &CI,
unsigned Op,
725 if (Op == TargetOpcode::G_UADDE || Op == TargetOpcode::G_USUBE) {
726 unsigned Zero = getOrCreateVReg(
739 case Intrinsic::lifetime_start:
740 case Intrinsic::lifetime_end:
747 case Intrinsic::dbg_declare: {
752 if (!Address || isa<UndefValue>(Address)) {
759 "Expected inlined-at fields to agree");
771 case Intrinsic::vaend:
775 case Intrinsic::vastart: {
778 unsigned ListSize = TLI.getVaListSizeInBits(*DL) / 8;
780 MIRBuilder.
buildInstr(TargetOpcode::G_VASTART)
781 .
addUse(getOrCreateVReg(*Ptr))
786 case Intrinsic::dbg_value: {
792 "Expected inlined-at fields to agree");
797 }
else if (
const auto *CI = dyn_cast<Constant>(V)) {
800 unsigned Reg = getOrCreateVReg(*V);
809 case Intrinsic::uadd_with_overflow:
810 return translateOverflowIntrinsic(CI, TargetOpcode::G_UADDE, MIRBuilder);
811 case Intrinsic::sadd_with_overflow:
812 return translateOverflowIntrinsic(CI, TargetOpcode::G_SADDO, MIRBuilder);
813 case Intrinsic::usub_with_overflow:
814 return translateOverflowIntrinsic(CI, TargetOpcode::G_USUBE, MIRBuilder);
815 case Intrinsic::ssub_with_overflow:
816 return translateOverflowIntrinsic(CI, TargetOpcode::G_SSUBO, MIRBuilder);
817 case Intrinsic::umul_with_overflow:
818 return translateOverflowIntrinsic(CI, TargetOpcode::G_UMULO, MIRBuilder);
819 case Intrinsic::smul_with_overflow:
820 return translateOverflowIntrinsic(CI, TargetOpcode::G_SMULO, MIRBuilder);
823 .
addDef(getOrCreateVReg(CI))
829 .
addDef(getOrCreateVReg(CI))
832 case Intrinsic::exp2:
834 .
addDef(getOrCreateVReg(CI))
839 .
addDef(getOrCreateVReg(CI))
844 .
addDef(getOrCreateVReg(CI))
847 case Intrinsic::fabs:
849 .
addDef(getOrCreateVReg(CI))
854 .
addDef(getOrCreateVReg(CI))
859 case Intrinsic::fmuladd: {
862 unsigned Dst = getOrCreateVReg(CI);
870 MIRBuilder.
buildInstr(TargetOpcode::G_FMA, Dst, Op0, Op1, Op2);
873 auto FMul = MIRBuilder.
buildInstr(TargetOpcode::G_FMUL, Ty, Op0, Op1);
874 MIRBuilder.
buildInstr(TargetOpcode::G_FADD, Dst, FMul, Op2);
878 case Intrinsic::memcpy:
879 case Intrinsic::memmove:
880 case Intrinsic::memset:
881 return translateMemfunc(CI, MIRBuilder, ID);
882 case Intrinsic::eh_typeid_for: {
884 unsigned Reg = getOrCreateVReg(CI);
889 case Intrinsic::objectsize: {
896 case Intrinsic::stackguard:
897 getStackGuard(getOrCreateVReg(CI), MIRBuilder);
899 case Intrinsic::stackprotector: {
902 getStackGuard(GuardVal, MIRBuilder);
906 GuardVal, getOrCreateVReg(*Slot),
909 getOrCreateFrameIndex(*Slot)),
918 bool IRTranslator::translateInlineAsm(
const CallInst &CI,
924 unsigned ExtraInfo = 0;
937 unsigned IRTranslator::packRegs(
const Value &V,
943 if (Regs.
size() == 1)
948 for (
unsigned i = 0; i < Regs.
size(); ++i) {
950 MIRBuilder.
buildInsert(NewDst, Dst, Regs[i], Offsets[i]);
956 void IRTranslator::unpackRegs(
const Value &V,
unsigned Src,
961 for (
unsigned i = 0; i < Regs.
size(); ++i)
966 const CallInst &CI = cast<CallInst>(U);
975 return translateInlineAsm(CI, MIRBuilder);
984 bool IsSplitType = valueIsSplit(CI);
988 : getOrCreateVReg(CI);
1000 unpackRegs(CI, Res, MIRBuilder);
1006 if (translateKnownIntrinsic(CI, ID, MIRBuilder))
1015 Res = getOrCreateVReg(CI);
1022 if (isa<MetadataAsValue>(
Arg))
1028 unpackRegs(CI, Res, MIRBuilder);
1032 TargetLowering::IntrinsicInfo Info;
1035 uint64_t
Size = Info.memVT.getStoreSize();
1037 Info.flags, Size, Info.align));
1043 bool IRTranslator::translateInvoke(
const User &U,
1053 if (isa<InlineAsm>(Callee))
1065 if (!isa<LandingPadInst>(EHPadBB->
front()))
1070 MCSymbol *BeginSymbol = Context.createTempSymbol();
1079 if (!CLI->
lowerCall(MIRBuilder, &I, Res, Args,
1080 [&]() { return getOrCreateVReg(*I.getCalledValue()); }))
1083 unpackRegs(I, Res, MIRBuilder);
1085 MCSymbol *EndSymbol = Context.createTempSymbol();
1090 &ReturnMBB = getMBB(*ReturnBB);
1091 MF->
addInvoke(&EHPadMBB, BeginSymbol, EndSymbol);
1094 MIRBuilder.
buildBr(ReturnMBB);
1099 bool IRTranslator::translateLandingPad(
const User &U,
1112 if (TLI.getExceptionPointerRegister(PersonalityFn) == 0 &&
1113 TLI.getExceptionSelectorRegister(PersonalityFn) == 0)
1133 for (
Type *Ty : cast<StructType>(LP.
getType())->elements())
1135 assert(Tys.
size() == 2 &&
"Only two-valued landingpads are supported");
1138 unsigned ExceptionReg = TLI.getExceptionPointerRegister(PersonalityFn);
1142 MBB.addLiveIn(ExceptionReg);
1144 MIRBuilder.
buildCopy(ResRegs[0], ExceptionReg);
1146 unsigned SelectorReg = TLI.getExceptionSelectorRegister(PersonalityFn);
1150 MBB.addLiveIn(SelectorReg);
1152 MIRBuilder.
buildCopy(PtrVReg, SelectorReg);
1153 MIRBuilder.
buildCast(ResRegs[1], PtrVReg);
1158 bool IRTranslator::translateAlloca(
const User &U,
1160 auto &AI = cast<AllocaInst>(U);
1166 unsigned Res = getOrCreateVReg(AI);
1167 int FI = getOrCreateFrameIndex(AI);
1181 unsigned NumElts = getOrCreateVReg(*AI.
getArraySize());
1185 if (MRI->
getType(NumElts) != IntPtrTy) {
1194 MIRBuilder.
buildMul(AllocSize, NumElts, TySize);
1204 MIRBuilder.
buildGEP(AllocTmp, SPTmp, AllocSize);
1209 unsigned StackAlign =
1211 Align =
std::max(Align, StackAlign);
1218 AllocTmp = AlignedAlloc;
1222 MIRBuilder.
buildCopy(getOrCreateVReg(AI), AllocTmp);
1235 .
addDef(getOrCreateVReg(U))
1241 bool IRTranslator::translateInsertElement(
const User &U,
1246 unsigned Elt = getOrCreateVReg(*U.
getOperand(1));
1247 auto &
Regs = *VMap.getVRegs(U);
1249 Regs.push_back(Elt);
1250 VMap.getOffsets(U)->push_back(0);
1257 unsigned Res = getOrCreateVReg(U);
1258 unsigned Val = getOrCreateVReg(*U.
getOperand(0));
1259 unsigned Elt = getOrCreateVReg(*U.
getOperand(1));
1260 unsigned Idx = getOrCreateVReg(*U.
getOperand(2));
1265 bool IRTranslator::translateExtractElement(
const User &U,
1270 unsigned Elt = getOrCreateVReg(*U.
getOperand(0));
1271 auto &
Regs = *VMap.getVRegs(U);
1273 Regs.push_back(Elt);
1274 VMap.getOffsets(U)->push_back(0);
1280 unsigned Res = getOrCreateVReg(U);
1281 unsigned Val = getOrCreateVReg(*U.
getOperand(0));
1282 unsigned Idx = getOrCreateVReg(*U.
getOperand(1));
1287 bool IRTranslator::translateShuffleVector(
const User &U,
1289 MIRBuilder.
buildInstr(TargetOpcode::G_SHUFFLE_VECTOR)
1290 .
addDef(getOrCreateVReg(U))
1298 const PHINode &PI = cast<PHINode>(U);
1301 for (
auto Reg : getOrCreateVRegs(PI)) {
1303 Insts.push_back(MIB.getInstr());
1306 PendingPHIs.emplace_back(&PI, std::move(Insts));
1310 bool IRTranslator::translateAtomicCmpXchg(
const User &U,
1322 Type *
ValType = ResType->Type::getStructElementType(0);
1324 auto Res = getOrCreateVRegs(I);
1325 unsigned OldValRes = Res[0];
1326 unsigned SuccessRes = Res[1];
1332 OldValRes, SuccessRes, Addr, Cmp, NewVal,
1335 getMemOpAlignment(I),
AAMDNodes(),
nullptr,
1341 bool IRTranslator::translateAtomicRMW(
const User &U,
1351 unsigned Res = getOrCreateVReg(I);
1355 unsigned Opcode = 0;
1361 Opcode = TargetOpcode::G_ATOMICRMW_XCHG;
1364 Opcode = TargetOpcode::G_ATOMICRMW_ADD;
1367 Opcode = TargetOpcode::G_ATOMICRMW_SUB;
1370 Opcode = TargetOpcode::G_ATOMICRMW_AND;
1373 Opcode = TargetOpcode::G_ATOMICRMW_NAND;
1376 Opcode = TargetOpcode::G_ATOMICRMW_OR;
1379 Opcode = TargetOpcode::G_ATOMICRMW_XOR;
1382 Opcode = TargetOpcode::G_ATOMICRMW_MAX;
1385 Opcode = TargetOpcode::G_ATOMICRMW_MIN;
1388 Opcode = TargetOpcode::G_ATOMICRMW_UMAX;
1391 Opcode = TargetOpcode::G_ATOMICRMW_UMIN;
1396 Opcode, Res, Addr, Val,
1399 getMemOpAlignment(I),
AAMDNodes(),
nullptr,
1404 void IRTranslator::finishPendingPhis() {
1405 for (
auto &Phi : PendingPHIs) {
1406 const PHINode *PI = Phi.first;
1417 if (HandledPreds.
count(IRPred))
1420 HandledPreds.
insert(IRPred);
1422 for (
auto Pred : getMachinePredBBs({IRPred, PI->
getParent()})) {
1423 assert(Pred->isSuccessor(ComponentPHIs[0]->getParent()) &&
1424 "incorrect CFG at MachineBasicBlock level");
1425 for (
unsigned j = 0; j < ValRegs.
size(); ++j) {
1435 bool IRTranslator::valueIsSplit(
const Value &V,
1438 if (Offsets && !Offsets->
empty())
1441 return SplitTys.
size() > 1;
1444 bool IRTranslator::translate(
const Instruction &Inst) {
1447 #define HANDLE_INST(NUM, OPCODE, CLASS) \ 1448 case Instruction::OPCODE: return translate##OPCODE(Inst, CurBuilder); 1449 #include "llvm/IR/Instruction.def" 1455 bool IRTranslator::translate(
const Constant &
C,
unsigned Reg) {
1456 if (
auto CI = dyn_cast<ConstantInt>(&C))
1458 else if (
auto CF = dyn_cast<ConstantFP>(&C))
1460 else if (isa<UndefValue>(C))
1462 else if (isa<ConstantPointerNull>(C)) {
1468 unsigned ZeroReg = getOrCreateVReg(*ZeroVal);
1470 }
else if (
auto GV = dyn_cast<GlobalValue>(&C))
1472 else if (
auto CAZ = dyn_cast<ConstantAggregateZero>(&C)) {
1473 if (!CAZ->getType()->isVectorTy())
1476 if (CAZ->getNumElements() == 1)
1477 return translate(*CAZ->getElementValue(0u),
Reg);
1478 std::vector<unsigned> Ops;
1479 for (
unsigned i = 0; i < CAZ->getNumElements(); ++i) {
1480 Constant &Elt = *CAZ->getElementValue(i);
1481 Ops.push_back(getOrCreateVReg(Elt));
1484 }
else if (
auto CV = dyn_cast<ConstantDataVector>(&C)) {
1486 if (CV->getNumElements() == 1)
1487 return translate(*CV->getElementAsConstant(0),
Reg);
1488 std::vector<unsigned> Ops;
1489 for (
unsigned i = 0; i < CV->getNumElements(); ++i) {
1490 Constant &Elt = *CV->getElementAsConstant(i);
1491 Ops.push_back(getOrCreateVReg(Elt));
1494 }
else if (
auto CE = dyn_cast<ConstantExpr>(&C)) {
1495 switch(CE->getOpcode()) {
1496 #define HANDLE_INST(NUM, OPCODE, CLASS) \ 1497 case Instruction::OPCODE: return translate##OPCODE(*CE, EntryBuilder); 1498 #include "llvm/IR/Instruction.def" 1502 }
else if (
auto CV = dyn_cast<ConstantVector>(&C)) {
1503 if (CV->getNumOperands() == 1)
1504 return translate(*CV->getOperand(0),
Reg);
1506 for (
unsigned i = 0; i < CV->getNumOperands(); ++i) {
1507 Ops.
push_back(getOrCreateVReg(*CV->getOperand(i)));
1510 }
else if (
auto *BA = dyn_cast<BlockAddress>(&C)) {
1518 void IRTranslator::finalizeFunction() {
1521 PendingPHIs.clear();
1523 FrameIndices.clear();
1524 MachinePreds.clear();
1538 CurBuilder.
setMF(*MF);
1539 EntryBuilder.
setMF(*MF);
1542 TPC = &getAnalysis<TargetPassConfig>();
1543 ORE = llvm::make_unique<OptimizationRemarkEmitter>(&
F);
1545 assert(PendingPHIs.empty() &&
"stale PHIs");
1551 R <<
"unable to translate in big endian mode";
1556 auto FinalizeOnReturn =
make_scope_exit([
this]() { finalizeFunction(); });
1561 EntryBuilder.
setMBB(*EntryBB);
1565 auto *&MBB = BBToMBB[&BB];
1571 MBB->setHasAddressTaken();
1575 EntryBB->addSuccessor(&getMBB(F.front()));
1587 for (
auto &
Arg : F.args()) {
1588 if (
Arg.hasSwiftErrorAttr() ||
Arg.hasSwiftSelfAttr()) {
1590 F.getSubprogram(), &F.getEntryBlock());
1591 R <<
"unable to lower arguments due to swifterror/swiftself: " 1592 <<
ore::NV(
"Prototype", F.getType());
1600 F.getSubprogram(), &F.getEntryBlock());
1601 R <<
"unable to lower arguments: " <<
ore::NV(
"Prototype", F.getType());
1606 auto ArgIt = F.arg_begin();
1607 for (
auto &VArg : VRegArgs) {
1610 if (!valueIsSplit(*ArgIt, VMap.getOffsets(*ArgIt))) {
1611 auto &
VRegs = *VMap.getVRegs(cast<Value>(*ArgIt));
1612 assert(
VRegs.empty() &&
"VRegs already populated?");
1613 VRegs.push_back(VArg);
1615 unpackRegs(*ArgIt, VArg, EntryBuilder);
1629 if (translate(Inst))
1634 R <<
"unable to translate instruction: " <<
ore::NV(
"Opcode", &Inst);
1636 if (ORE->allowExtraAnalysis(
"gisel-irtranslator")) {
1637 std::string InstStrStorage;
1641 R <<
": '" << InstStr.
str() <<
"'";
1649 finishPendingPhis();
1654 assert(EntryBB->succ_size() == 1 &&
1655 "Custom BB used for lowering should have only one successor");
1658 assert(NewEntryBB.pred_size() == 1 &&
1659 "LLVM-IR entry block has a predecessor!?");
1662 NewEntryBB.splice(NewEntryBB.begin(), EntryBB, EntryBB->begin(),
1667 NewEntryBB.addLiveIn(LiveIn);
1668 NewEntryBB.sortUniqueLiveIns();
1671 EntryBB->removeSuccessor(&NewEntryBB);
1676 "New entry wasn't next in the list of basic block!");
MachineInstrBuilder buildCopy(unsigned Res, unsigned Op)
Build and insert Res = COPY Op.
void initializeIRTranslatorPass(PassRegistry &)
Return a value (possibly void), from a function.
Value * getValueOperand()
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
This class is the base class for the comparison instructions.
MachineInstrBuilder buildIndirectDbgValue(unsigned Reg, const MDNode *Variable, const MDNode *Expr)
Build and insert a DBG_VALUE instruction expressing the fact that the associated Variable lives in me...
static IntegerType * getInt1Ty(LLVMContext &C)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
*p = old <signed v ? old : v
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents an incoming formal argument to a Function.
DiagnosticInfoOptimizationBase::Argument NV
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Compute iterated dominance frontiers using a linear time algorithm.
MachineInstrBuilder buildGEP(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res = G_GEP Op0, Op1.
unsigned countOperandBundlesOfType(StringRef Name) const
Return the number of operand bundles with the tag Name attached to this instruction.
void getSelectionDAGFallbackAnalysisUsage(AnalysisUsage &AU)
Modify analysis usage so it preserves passes required for the SelectionDAG fallback.
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad. Returns the label ID for the landing pad entry.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
MachineInstrBuilder buildInsertVectorElement(unsigned Res, unsigned Val, unsigned Elt, unsigned Idx)
Build and insert Res = G_INSERT_VECTOR_ELT Val, Elt, Idx.
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
MachineInstrBuilder buildStore(unsigned Val, unsigned Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
void addLandingPadInfo(const LandingPadInst &I, MachineBasicBlock &MBB)
Extract the exception handling information from the landingpad instruction and add them to the specif...
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
MachineInstrBuilder buildFConstant(DstType &&Res, const ConstantFP &Val)
Build and insert Res = G_FCONSTANT Val.
MachineInstrBuilder buildUndef(DstType &&Res)
Build and insert Res = IMPLICIT_DEF.
IRTranslator LLVM IR static false void reportTranslationError(MachineFunction &MF, const TargetPassConfig &TPC, OptimizationRemarkEmitter &ORE, OptimizationRemarkMissed &R)
This class represents a function call, abstracting a target machine's calling convention.
Value * getCondition() const
virtual const TargetLowering * getTargetLowering() const
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this store instruction.
gep_type_iterator gep_type_end(const User *GEP)
const std::string & getAsmString() const
*p = old <unsigned v ? old : v
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
*p = old >unsigned v ? old : v
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
LLVM_NODISCARD detail::scope_exit< typename std::decay< Callable >::type > make_scope_exit(Callable &&F)
static const MCPhysReg VRegs[32]
LLVMContext & getContext() const
All values hold a context through their type.
bool hasDLLImportStorageClass() const
BasicBlock * getSuccessor(unsigned i) const
Value * getNewValOperand()
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
unsigned const TargetRegisterInfo * TRI
An instruction for reading from memory.
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
Value * getCondition() const
bool isVectorTy() const
True if this is an instance of VectorType.
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - Get or set the calling convention of this function call...
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
MachineInstrBuilder buildBrCond(unsigned Tst, MachineBasicBlock &Dest)
Build and insert G_BRCOND Tst, Dest.
GlobalValue * ExtractTypeInfo(Value *V)
ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
*p = old >signed v ? old : v
void DeleteMachineBasicBlock(MachineBasicBlock *MBB)
DeleteMachineBasicBlock - Delete the given MachineBasicBlock.
unsigned getPointerABIAlignment(unsigned AS) const
Layout pointer alignment.
virtual bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &, MachineFunction &, unsigned) const
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
bool hasSideEffects() const
AnalysisUsage & addRequired()
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
#define INITIALIZE_PASS_DEPENDENCY(depName)
bool isVolatile() const
Return true if this is a load from a volatile memory location.
A description of a memory reference used in the backend.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
virtual bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef< unsigned > VRegs) const
This hook must be implemented to lower the incoming (formal) arguments, described by Args...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
PointerType * getType() const
Overload to return most specific pointer type.
Class to represent struct types.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
void setMF(MachineFunction &)
BinOp getOperation() const
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
bool isWeak() const
Return true if this cmpxchg may spuriously fail.
MachineInstrBuilder buildBrIndirect(unsigned Tgt)
Build and insert G_BRINDIRECT Tgt.
The memory access is dereferenceable (i.e., doesn't trap).
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Target-Independent Code Generator Pass Configuration Options.
INLINEASM - Represents an inline asm block.
MachineInstrBuilder buildConstDbgValue(const Constant &C, const MDNode *Variable, const MDNode *Expr)
Build and insert a DBG_VALUE instructions specifying that Variable is given by C (suitably modified b...
Context object for machine code objects.
Value * getPointerOperand()
Type * getType() const
All values are typed, get the type of this value.
MachineInstrBuilder buildPtrMask(unsigned Res, unsigned Op0, uint32_t NumBits)
Build and insert Res = G_PTR_MASK Op0, NumBits.
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
Class to represent array types.
bool isLittleEndian() const
Layout endianness...
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
An instruction for storing to memory.
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
MachineInstrBuilder buildGlobalValue(unsigned Res, const GlobalValue *GV)
Build and insert Res = G_GLOBAL_VALUE GV.
amdgpu Simplify well known AMD library false Value * Callee
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
Value * getOperand(unsigned i) const
bool doesNotAccessMemory() const
Determine if the call does not access memory.
Value * getOperand(unsigned i_nocapture) const
MCContext & getContext() const
bool isOSWindows() const
Tests whether the OS is Windows.
bool isVoidTy() const
Return true if this is 'void'.
The memory access is volatile.
const BasicBlock & getEntryBlock() const
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
MachineInstrBuilder buildIntrinsic(Intrinsic::ID ID, unsigned Res, bool HasSideEffects)
Build and insert either a G_INTRINSIC (if HasSideEffects is false) or G_INTRINSIC_W_SIDE_EFFECTS inst...
FPOpFusion::FPOpFusionMode AllowFPOpFusion
AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
MachineInstrBuilder buildZExtOrTrunc(DstTy &&Dst, UseArgTy &&Use)
Build and insert Res = G_ZEXT Op, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes...
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this rmw instruction.
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
LLVM Basic Block Representation.
void addInvoke(MachineBasicBlock *LandingPad, MCSymbol *BeginLabel, MCSymbol *EndLabel)
Provide the begin and end labels of an invoke style call and associate it with a try landing pad bloc...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool lowerCall(MachineIRBuilder &MIRBuilder, CallingConv::ID CallConv, const MachineOperand &Callee, const ArgInfo &OrigRet, ArrayRef< ArgInfo > OrigArgs) const
This hook must be implemented to lower the given call instruction, including argument and return valu...
DISubprogram * getSubprogram() const
Get the attached subprogram.
Conditional or Unconditional Branch instruction.
Value * getAddress() const
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
MachineInstrBuilder buildBr(MachineBasicBlock &Dest)
Build and insert G_BR Dest.
Value * getCompareOperand()
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const Instruction & front() const
Indirect Branch Instruction.
BasicBlock * getDefaultDest() const
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
MachineInstrBuilder buildExtract(unsigned Res, unsigned Src, uint64_t Index)
Build and insert `Res0, ...
bool isValidLocationForIntrinsic(const DILocation *DL) const
Check that a location is valid for this variable.
Represent the analysis usage information of a pass.
DILocalVariable * getVariable() const
MachineInstrBuilder buildDirectDbgValue(unsigned Reg, const MDNode *Variable, const MDNode *Expr)
Build and insert a DBG_VALUE instruction expressing the fact that the associated Variable lives in Re...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
virtual const CallLowering * getCallLowering() const
const Triple & getTargetTriple() const
DIExpression * getExpression() const
Value * getPointerOperand()
MachineInstrBuilder buildExtractVectorElement(unsigned Res, unsigned Val, unsigned Idx)
Build and insert Res = G_EXTRACT_VECTOR_ELT Val, Idx.
void remove(iterator MBBI)
self_iterator getIterator()
DebugLoc getDebugLoc()
Get the current instruction's debug location.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
static double log2(double V)
static Constant * getAllOnesValue(Type *Ty)
1 1 1 1 Always true (always folded)
succ_iterator succ_begin()
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this cmpxchg instruction.
iterator_range< User::op_iterator > arg_operands()
Iteration adapter for range-for loops.
BasicBlock * getSuccessor(unsigned i) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MachineBasicBlock & front() const
const Value * getArraySize() const
Get the number of elements allocated.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
This class contains a discriminated union of information about pointers in memory operands...
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
const std::string & getConstraintString() const
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
LLT getLLTForType(Type &Ty, const DataLayout &DL)
Construct a low-level type based on an LLVM type.
The memory access writes data.
unsigned createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
MachineInstrBuilder buildSExtOrTrunc(DstTy &&Dst, UseArgTy &&Use)
Build and insert Res = G_SEXT Op, Res = G_TRUNC Op, or Res = COPY Op depending on the differing sizes...
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
unsigned getNumOperands() const
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
This is the shared class of boolean and integer constants.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
bool isAggregateType() const
Return true if the type is an aggregate type.
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
static uint64_t getOffsetFromIndices(const User &U, const DataLayout &DL)
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
MachineInstrBuilder buildFrameIndex(unsigned Res, int Idx)
Build and insert Res = G_FRAME_INDEX Idx.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
MachineInstrBuilder buildSelect(unsigned Res, unsigned Tst, unsigned Op0, unsigned Op1)
Build and insert a Res = G_SELECT Tst, Op0, Op1.
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
unsigned getVectorNumElements() const
bool isIntPredicate() const
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
static MachineOperand CreateES(const char *SymName, unsigned char TargetFlags=0)
virtual bool isFMAFasterThanFMulAndFAdd(EVT) const
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
MachineInstrBuilder buildConstant(unsigned Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
amdgpu Simplify well known AMD library false Value Value * Arg
MachineInstrBuilder buildAtomicRMW(unsigned Opcode, unsigned OldValRes, unsigned Addr, unsigned Val, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMICRMW_<Opcode> Addr, Val, MMO.
The memory access reads data.
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
MachineInstrBuilder buildMerge(unsigned Res, ArrayRef< unsigned > Ops)
Build and insert Res = G_MERGE_VALUES Op0, ...
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Predicate getPredicate() const
Return the predicate for this instruction.
bool isVolatile() const
Return true if this is a store to a volatile memory location.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
bool isInlineAsm() const
Check if this call is an inline asm statement.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
uint64_t getElementOffset(unsigned Idx) const
void emplace_back(ArgTypes &&... Args)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM_NODISCARD bool empty() const
AtomicOrdering getOrdering() const
Returns the ordering constraint of this store instruction.
This represents the llvm.dbg.value instruction.
bool isTokenTy() const
Return true if this is 'token'.
Value * getPointerOperand()
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
If intrinsic information is available, return it. If not, return null.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this load instruction.
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned char TargetFlags=0) const
MachineInstrBuilder buildLoad(unsigned Res, unsigned Addr, MachineMemOperand &MMO)
Build and insert Res = G_LOAD Addr, MMO.
static Constant * getZeroValueForNegation(Type *Ty)
Floating point negation must be implemented with f(x) = -0.0 - x.
Pair of physical register and lane mask.
virtual const TargetFrameLowering * getFrameLowering() const
The memory access always returns the same value (or traps).
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void setDebugLoc(const DebugLoc &DL)
Set the debug location to DL for all the next build instructions.
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Optional< MachineInstrBuilder > materializeGEP(unsigned &Res, unsigned Op0, const LLT &ValueTy, uint64_t Value)
Materialize and insert Res = G_GEP Op0, (G_CONSTANT Value)
bool isUnconditional() const
MachineInstrBuilder buildCast(DstType &&Res, ArgType &&Arg)
Build and insert an appropriate cast between two registers of equal size.
static void computeValueLLTs(const DataLayout &DL, Type &Ty, SmallVectorImpl< LLT > &ValueTys, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
AsmDialect getDialect() const
MachineInstrBuilder buildAtomicCmpXchgWithSuccess(unsigned OldValRes, unsigned SuccessRes, unsigned Addr, unsigned CmpVal, unsigned NewVal, MachineMemOperand &MMO)
Build and insert OldValRes<def>, SuccessRes<def> = G_ATOMIC_CMPXCHG_WITH_SUCCESS Addr, CmpVal, NewVal, MMO.
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
This file declares the IRTranslator pass.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void insert(iterator MBBI, MachineBasicBlock *MBB)
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
A raw_ostream that writes to an std::string.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
This file describes how to lower LLVM calls to machine code calls.
void push_back(MachineBasicBlock *MBB)
unsigned getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
INITIALIZE_PASS_BEGIN(IRTranslator, DEBUG_TYPE, "IRTranslator LLVM IR -> MI", false, false) INITIALIZE_PASS_END(IRTranslator
MachineBasicBlock & getMBB()
Getter for the basic block we currently build.
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
Primary interface to the complete machine description for the target machine.
MachineInstrBuilder buildInstr(unsigned Opc, DstTy &&Ty, UseArgsTy &&... Args)
DAG like Generic method for building arbitrary instructions as above.
MachineInstrBuilder buildFCmp(CmpInst::Predicate Pred, unsigned Res, unsigned Op0, unsigned Op1)
Build and insert a Res = G_FCMP PredOp0, Op1.
MachineInstrBuilder buildMul(unsigned Dst, unsigned Src0, unsigned Src1)
Build and insert Res = G_MUL Op0, Op1.
void setRegClass(unsigned Reg, const TargetRegisterClass *RC)
setRegClass - Set the register class of the specified virtual register.
const MachineInstrBuilder & addDef(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size...
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
MachineInstrBuilder buildInsert(unsigned Res, unsigned Src, unsigned Op, unsigned Index)
MachineInstrBuilder buildBlockAddress(unsigned Res, const BlockAddress *BA)
Build and insert Res = G_BLOCK_ADDR BA.
virtual bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, unsigned VReg) const
This hook must be implemented to lower outgoing return values, described by Val, into the specified v...
OutputIt copy(R &&Range, OutputIt Out)
void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, int Slot, const DILocation *Loc)
Collect information used to emit debugging information of a variable.
int CreateVariableSizedObject(unsigned Alignment, const AllocaInst *Alloca)
Notify the MachineFrameInfo object that a variable sized object has been created. ...
This represents the llvm.dbg.declare instruction.
Value * getPointerOperand()
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
Statically lint checks LLVM IR
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
MachineInstrBuilder buildICmp(CmpInst::Predicate Pred, unsigned Res, unsigned Op0, unsigned Op1)
Build and insert a Res = G_ICMP Pred, Op0, Op1.
int64_t getIndexedOffsetInType(Type *ElemTy, ArrayRef< Value *> Indices) const
Returns the offset from the beginning of the type for the specified indices.
bool isVolatile() const
Return true if this is a RMW on a volatile memory location.
0 0 0 0 Always false (always folded)
This file describes how to lower LLVM code to machine code.
const BasicBlock * getParent() const
virtual const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const
Returns a TargetRegisterClass used for pointer values.
an instruction to allocate memory on the stack
This instruction inserts a struct field of array element value into an aggregate value.
gep_type_iterator gep_type_begin(const User *GEP)
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.