26 #define DEBUG_TYPE "legalizer" 32 :
MRI(MF.getRegInfo()), LI(*MF.getSubtarget().getLegalizerInfo()) {
41 switch (Step.Action) {
56 return lower(MI, Step.TypeIdx, Step.NewType);
70 void LegalizerHelper::extractParts(
unsigned Reg,
LLT Ty,
int NumParts,
72 for (
int i = 0; i < NumParts; ++i)
79 case TargetOpcode::G_SDIV:
80 assert(Size == 32 &&
"Unsupported size");
81 return RTLIB::SDIV_I32;
82 case TargetOpcode::G_UDIV:
83 assert(Size == 32 &&
"Unsupported size");
84 return RTLIB::UDIV_I32;
85 case TargetOpcode::G_SREM:
86 assert(Size == 32 &&
"Unsupported size");
87 return RTLIB::SREM_I32;
88 case TargetOpcode::G_UREM:
89 assert(Size == 32 &&
"Unsupported size");
90 return RTLIB::UREM_I32;
91 case TargetOpcode::G_FADD:
92 assert((Size == 32 || Size == 64) &&
"Unsupported size");
93 return Size == 64 ? RTLIB::ADD_F64 : RTLIB::ADD_F32;
94 case TargetOpcode::G_FSUB:
95 assert((Size == 32 || Size == 64) &&
"Unsupported size");
96 return Size == 64 ? RTLIB::SUB_F64 : RTLIB::SUB_F32;
97 case TargetOpcode::G_FMUL:
98 assert((Size == 32 || Size == 64) &&
"Unsupported size");
99 return Size == 64 ? RTLIB::MUL_F64 : RTLIB::MUL_F32;
100 case TargetOpcode::G_FDIV:
101 assert((Size == 32 || Size == 64) &&
"Unsupported size");
102 return Size == 64 ? RTLIB::DIV_F64 : RTLIB::DIV_F32;
103 case TargetOpcode::G_FREM:
104 return Size == 64 ? RTLIB::REM_F64 : RTLIB::REM_F32;
105 case TargetOpcode::G_FPOW:
106 return Size == 64 ? RTLIB::POW_F64 : RTLIB::POW_F32;
107 case TargetOpcode::G_FMA:
108 assert((Size == 32 || Size == 64) &&
"Unsupported size");
109 return Size == 64 ? RTLIB::FMA_F64 : RTLIB::FMA_F32;
120 const char *
Name = TLI.getLibcallName(Libcall);
123 if (!CLI.lowerCall(MIRBuilder, TLI.getLibcallCallingConv(Libcall),
138 Args.push_back({MI.getOperand(i).getReg(), OpType});
149 case TargetOpcode::G_FPEXT:
151 case TargetOpcode::G_FPTRUNC:
153 case TargetOpcode::G_FPTOSI:
155 case TargetOpcode::G_FPTOUI:
157 case TargetOpcode::G_SITOFP:
159 case TargetOpcode::G_UITOFP:
184 case TargetOpcode::G_SDIV:
185 case TargetOpcode::G_UDIV:
186 case TargetOpcode::G_SREM:
187 case TargetOpcode::G_UREM: {
194 case TargetOpcode::G_FADD:
195 case TargetOpcode::G_FSUB:
196 case TargetOpcode::G_FMUL:
197 case TargetOpcode::G_FDIV:
198 case TargetOpcode::G_FMA:
199 case TargetOpcode::G_FPOW:
200 case TargetOpcode::G_FREM: {
207 case TargetOpcode::G_FPEXT: {
211 if (ToSize != 64 || FromSize != 32)
219 case TargetOpcode::G_FPTRUNC: {
223 if (ToSize != 32 || FromSize != 64)
231 case TargetOpcode::G_FPTOSI:
232 case TargetOpcode::G_FPTOUI: {
236 if (ToSize != 32 || (FromSize != 32 && FromSize != 64))
245 case TargetOpcode::G_SITOFP:
246 case TargetOpcode::G_UITOFP: {
250 if (FromSize != 32 || (ToSize != 32 && ToSize != 64))
270 if (TypeIdx != 0 && MI.
getOpcode() != TargetOpcode::G_EXTRACT)
281 case TargetOpcode::G_IMPLICIT_DEF: {
284 if (SizeOp0 % NarrowSize != 0)
286 int NumParts = SizeOp0 / NarrowSize;
289 for (
int i = 0; i < NumParts; ++i)
296 case TargetOpcode::G_ADD: {
299 if (SizeOp0 % NarrowSize != 0)
311 for (
int i = 0; i < NumParts; ++i) {
316 Src2Regs[i], CarryIn);
326 case TargetOpcode::G_EXTRACT: {
333 if (SizeOp1 % NarrowSize != 0)
335 int NumParts = SizeOp1 / NarrowSize;
344 for (
int i = 0; i < NumParts; ++i) {
345 unsigned SrcStart = i * NarrowSize;
347 if (SrcStart + NarrowSize <= OpStart || SrcStart >= OpStart + OpSize) {
350 }
else if (SrcStart == OpStart && NarrowTy == MRI.
getType(OpReg)) {
358 int64_t ExtractOffset;
360 if (OpStart < SrcStart) {
362 SegSize = std::min(NarrowSize, OpStart + OpSize - SrcStart);
364 ExtractOffset = OpStart - SrcStart;
365 SegSize = std::min(SrcStart + NarrowSize - OpStart, OpSize);
368 unsigned SegReg = SrcRegs[i];
369 if (ExtractOffset != 0 || SegSize != NarrowSize) {
382 case TargetOpcode::G_INSERT: {
385 if (SizeOp0 % NarrowSize != 0)
388 int NumParts = SizeOp0 / NarrowSize;
397 for (
int i = 0; i < NumParts; ++i) {
398 unsigned DstStart = i * NarrowSize;
400 if (DstStart + NarrowSize <= OpStart || DstStart >= OpStart + OpSize) {
404 }
else if (DstStart == OpStart && NarrowTy == MRI.
getType(OpReg)) {
413 int64_t ExtractOffset, InsertOffset;
415 if (OpStart < DstStart) {
417 ExtractOffset = DstStart - OpStart;
418 SegSize = std::min(NarrowSize, OpStart + OpSize - DstStart);
420 InsertOffset = OpStart - DstStart;
423 std::min(NarrowSize - InsertOffset, OpStart + OpSize - DstStart);
426 unsigned SegReg = OpReg;
427 if (ExtractOffset != 0 || SegSize != OpSize) {
443 case TargetOpcode::G_LOAD: {
446 if (SizeOp0 % NarrowSize != 0)
456 int NumParts = SizeOp0 / NarrowSize;
461 for (
int i = 0; i < NumParts; ++i) {
464 unsigned Adjustment = i * NarrowSize / 8;
467 MMO.getPointerInfo().getWithOffset(Adjustment), MMO.getFlags(),
468 NarrowSize / 8, i == 0 ? MMO.getAlignment() : NarrowSize / 8,
469 MMO.getAAInfo(), MMO.getRanges(), MMO.getSyncScopeID(),
470 MMO.getOrdering(), MMO.getFailureOrdering());
477 DstRegs.push_back(DstReg);
484 case TargetOpcode::G_STORE: {
487 if (SizeOp0 % NarrowSize != 0)
497 int NumParts = SizeOp0 / NarrowSize;
504 for (
int i = 0; i < NumParts; ++i) {
506 unsigned Adjustment = i * NarrowSize / 8;
509 MMO.getPointerInfo().getWithOffset(Adjustment), MMO.getFlags(),
510 NarrowSize / 8, i == 0 ? MMO.getAlignment() : NarrowSize / 8,
511 MMO.getAAInfo(), MMO.getRanges(), MMO.getSyncScopeID(),
512 MMO.getOrdering(), MMO.getFailureOrdering());
522 case TargetOpcode::G_CONSTANT: {
525 if (SizeOp0 % NarrowSize != 0)
527 int NumParts = SizeOp0 / NarrowSize;
532 for (
int i = 0; i < NumParts; ++i) {
544 case TargetOpcode::G_OR: {
557 if (SizeOp0 % NarrowSize != 0)
559 int NumParts = SizeOp0 / NarrowSize;
568 for (
int i = 0; i < NumParts; ++i) {
582 for (
int i = 0; i < NumParts; ++i)
595 unsigned OpIdx,
unsigned ExtOpcode) {
598 MO.
setReg(ExtB->getOperand(0).getReg());
602 unsigned OpIdx,
unsigned TruncOpcode) {
618 case TargetOpcode::G_ADD:
619 case TargetOpcode::G_AND:
620 case TargetOpcode::G_MUL:
621 case TargetOpcode::G_OR:
622 case TargetOpcode::G_XOR:
623 case TargetOpcode::G_SUB:
627 widenScalarSrc(MI, WideTy, 1, TargetOpcode::G_ANYEXT);
628 widenScalarSrc(MI, WideTy, 2, TargetOpcode::G_ANYEXT);
629 widenScalarDst(MI, WideTy);
633 case TargetOpcode::G_SHL:
634 widenScalarSrc(MI, WideTy, 1, TargetOpcode::G_ANYEXT);
637 widenScalarSrc(MI, WideTy, 2, TargetOpcode::G_ZEXT);
638 widenScalarDst(MI, WideTy);
642 case TargetOpcode::G_SDIV:
643 case TargetOpcode::G_SREM:
644 widenScalarSrc(MI, WideTy, 1, TargetOpcode::G_SEXT);
645 widenScalarSrc(MI, WideTy, 2, TargetOpcode::G_SEXT);
646 widenScalarDst(MI, WideTy);
650 case TargetOpcode::G_ASHR:
651 widenScalarSrc(MI, WideTy, 1, TargetOpcode::G_SEXT);
654 widenScalarSrc(MI, WideTy, 2, TargetOpcode::G_ZEXT);
655 widenScalarDst(MI, WideTy);
659 case TargetOpcode::G_UDIV:
660 case TargetOpcode::G_UREM:
661 case TargetOpcode::G_LSHR:
662 widenScalarSrc(MI, WideTy, 1, TargetOpcode::G_ZEXT);
663 widenScalarSrc(MI, WideTy, 2, TargetOpcode::G_ZEXT);
664 widenScalarDst(MI, WideTy);
668 case TargetOpcode::G_SELECT:
674 widenScalarSrc(MI, WideTy, 2, TargetOpcode::G_ANYEXT);
675 widenScalarSrc(MI, WideTy, 3, TargetOpcode::G_ANYEXT);
676 widenScalarDst(MI, WideTy);
680 case TargetOpcode::G_FPTOSI:
681 case TargetOpcode::G_FPTOUI:
684 widenScalarDst(MI, WideTy);
688 case TargetOpcode::G_SITOFP:
691 widenScalarSrc(MI, WideTy, 1, TargetOpcode::G_SEXT);
695 case TargetOpcode::G_UITOFP:
698 widenScalarSrc(MI, WideTy, 1, TargetOpcode::G_ZEXT);
702 case TargetOpcode::G_INSERT:
705 widenScalarSrc(MI, WideTy, 1, TargetOpcode::G_ANYEXT);
706 widenScalarDst(MI, WideTy);
710 case TargetOpcode::G_LOAD:
718 case TargetOpcode::G_SEXTLOAD:
719 case TargetOpcode::G_ZEXTLOAD:
720 widenScalarDst(MI, WideTy);
724 case TargetOpcode::G_STORE: {
729 widenScalarSrc(MI, WideTy, 0, TargetOpcode::G_ZEXT);
733 case TargetOpcode::G_CONSTANT: {
739 widenScalarDst(MI, WideTy);
743 case TargetOpcode::G_FCONSTANT: {
760 widenScalarDst(MI, WideTy, 0, TargetOpcode::G_FPTRUNC);
764 case TargetOpcode::G_BRCOND:
765 widenScalarSrc(MI, WideTy, 0, TargetOpcode::G_ANYEXT);
769 case TargetOpcode::G_FCMP:
771 widenScalarDst(MI, WideTy);
773 widenScalarSrc(MI, WideTy, 2, TargetOpcode::G_FPEXT);
774 widenScalarSrc(MI, WideTy, 3, TargetOpcode::G_FPEXT);
779 case TargetOpcode::G_ICMP:
781 widenScalarDst(MI, WideTy);
785 ? TargetOpcode::G_SEXT
786 : TargetOpcode::G_ZEXT;
787 widenScalarSrc(MI, WideTy, 2, ExtOpcode);
788 widenScalarSrc(MI, WideTy, 3, ExtOpcode);
793 case TargetOpcode::G_GEP:
794 assert(TypeIdx == 1 &&
"unable to legalize pointer of GEP");
795 widenScalarSrc(MI, WideTy, 2, TargetOpcode::G_SEXT);
799 case TargetOpcode::G_PHI: {
800 assert(TypeIdx == 0 &&
"Expecting only Idx 0");
805 widenScalarSrc(MI, WideTy,
I, TargetOpcode::G_ANYEXT);
810 widenScalarDst(MI, WideTy);
819 using namespace TargetOpcode;
825 case TargetOpcode::G_SREM:
826 case TargetOpcode::G_UREM: {
827 unsigned QuotReg =
MRI.createGenericVirtualRegister(Ty);
833 unsigned ProdReg =
MRI.createGenericVirtualRegister(Ty);
840 case TargetOpcode::G_SMULO:
841 case TargetOpcode::G_UMULO: {
851 unsigned Opcode = MI.
getOpcode() == TargetOpcode::G_SMULO
852 ? TargetOpcode::G_SMULH
853 : TargetOpcode::G_UMULH;
855 unsigned HiPart =
MRI.createGenericVirtualRegister(Ty);
861 unsigned Zero =
MRI.createGenericVirtualRegister(Ty);
866 if (Opcode == TargetOpcode::G_SMULH) {
867 unsigned Shifted =
MRI.createGenericVirtualRegister(Ty);
868 unsigned ShiftAmt =
MRI.createGenericVirtualRegister(Ty);
881 case TargetOpcode::G_FNEG: {
910 .
addUse(Zero->getOperand(0).getReg())
915 case TargetOpcode::G_FSUB: {
919 if (LI.getAction({G_FNEG, {Ty}}).Action ==
Lower)
924 unsigned Neg =
MRI.createGenericVirtualRegister(Ty);
933 case TargetOpcode::G_ATOMIC_CMPXCHG_WITH_SUCCESS: {
945 case TargetOpcode::G_LOAD:
946 case TargetOpcode::G_SEXTLOAD:
947 case TargetOpcode::G_ZEXTLOAD: {
951 LLT DstTy =
MRI.getType(DstReg);
957 if (MI.
getOpcode() == TargetOpcode::G_LOAD)
965 unsigned TmpReg =
MRI.createGenericVirtualRegister(
971 case TargetOpcode::G_LOAD:
974 case TargetOpcode::G_SEXTLOAD:
977 case TargetOpcode::G_ZEXTLOAD:
999 case TargetOpcode::G_ADD: {
1002 unsigned Size =
MRI.getType(DstReg).getSizeInBits();
1003 int NumParts = Size / NarrowSize;
1006 if (Size % NarrowSize != 0)
1015 for (
int i = 0; i < NumParts; ++i) {
1016 unsigned DstReg =
MRI.createGenericVirtualRegister(NarrowTy);
static LegalizerHelper::LegalizeResult simpleLibcall(MachineInstr &MI, MachineIRBuilder &MIRBuilder, unsigned Size, Type *OpType)
MachineInstrBuilder buildOr(unsigned Dst, unsigned Src0, unsigned Src1)
Build and insert Res = G_OR Op0, Op1.
void push_back(const T &Elt)
MachineIRBuilder MIRBuilder
Expose MIRBuilder so clients can set their own RecordInsertInstruction functions. ...
static Type * getDoubleTy(LLVMContext &C)
APInt sext(unsigned width) const
Sign extend to a new width.
MachineBasicBlock * getMBB() const
Compute iterated dominance frontiers using a linear time algorithm.
The operation should be implemented in terms of a wider scalar base-type.
void setFPImm(const ConstantFP *CFP)
MachineInstrBuilder buildStore(unsigned Val, unsigned Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
MachineInstrBuilder buildFConstant(DstType &&Res, const ConstantFP &Val)
Build and insert Res = G_FCONSTANT Val.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
MachineInstrBuilder buildUndef(DstType &&Res)
Build and insert Res = IMPLICIT_DEF.
unsigned getReg() const
getReg - Returns the register number.
MachineInstrBuilder buildSExt(DstType &&Res, ArgType &&Arg)
Build and insert Res = G_SEXT Op.
MachineInstrBuilder buildUnmerge(ArrayRef< unsigned > Res, unsigned Op)
Build and insert Res0, ...
The (vector) operation should be implemented by splitting it into sub-vectors where the operation is ...
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
virtual const TargetLowering * getTargetLowering() const
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
static const MCPhysReg VRegs[32]
APInt trunc(unsigned width) const
Truncate to new width.
MachineInstrBuilder buildAnyExt(unsigned Res, unsigned Op)
Build and insert Res = G_ANYEXT Op0.
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Libcall getFPROUND(EVT OpVT, EVT RetVT)
getFPROUND - Return the FPROUND_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
MachineInstrBuilder buildAtomicCmpXchg(unsigned OldValRes, unsigned Addr, unsigned CmpVal, unsigned NewVal, MachineMemOperand &MMO)
Build and insert OldValRes<def> = G_ATOMIC_CMPXCHG Addr, CmpVal, NewVal, MMO.
Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
LegalizerHelper(MachineFunction &MF)
The operation should be synthesized from multiple instructions acting on a narrower scalar base-type...
LegalizeActionStep getAction(const LegalityQuery &Query) const
Determine what action should be taken to legalize the described instruction.
void recordInsertion(MachineInstr *InsertedInstr) const
A description of a memory reference used in the backend.
LegalizeResult widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy)
Legalize an instruction by performing the operation on a wider scalar type (for example a 16-bit addi...
static Type * getFloatTy(LLVMContext &C)
const ConstantFP * getFPImm() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
void setMF(MachineFunction &)
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
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.
LegalizerHelper::LegalizeResult createLibcall(MachineIRBuilder &MIRBuilder, RTLIB::Libcall Libcall, const CallLowering::ArgInfo &Result, ArrayRef< CallLowering::ArgInfo > Args)
Helper function that creates the given libcall.
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
MachineInstrBuilder buildSub(unsigned Dst, unsigned Src0, unsigned Src1)
Build and insert Res = G_SUB Op0, Op1.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const APInt & getValue() const
Return the constant as an APInt value reference.
static const fltSemantics & IEEEdouble() LLVM_READNONE
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
MachineInstrBuilder buildZExt(DstType &&Res, ArgType &&Arg)
Build and insert Res = G_ZEXT Op.
unsigned const MachineRegisterInfo * MRI
LegalizeResult legalizeInstrStep(MachineInstr &MI)
Replace MI by a sequence of legal instructions that can implement the same operation.
The instances of the Type class are immutable: once they are created, they are never changed...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This is an important class for using LLVM in a threaded context.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
ConstantFP - Floating Point Values [float, double].
Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
MachineInstrBuilder buildUAdde(unsigned Res, unsigned CarryOut, unsigned Op0, unsigned Op1, unsigned CarryIn)
Build and insert Res, CarryOut = G_UADDE Op0, Op1, CarryIn.
MachineInstrBuilder buildExtract(unsigned Res, unsigned Src, uint64_t Index)
Build and insert `Res0, ...
virtual const CallLowering * getCallLowering() const
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
static MVT getVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
void print(raw_ostream &OS, bool IsStandalone=true, bool SkipOpers=false, bool SkipDebugLoc=false, bool AddNewLine=true, const TargetInstrInfo *TII=nullptr) const
Print this MI to OS.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Some kind of error has occurred and we could not legalize this instruction.
Instruction was already legal and no change was made to the MachineFunction.
MachineBasicBlock::iterator getInsertPt()
Current insertion point for new instructions.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
static Type * getFP128Ty(LLVMContext &C)
const APFloat & getValueAPF() const
Libcall getFPEXT(EVT OpVT, EVT RetVT)
getFPEXT - Return the FPEXT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
unsigned createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
static Type * getHalfTy(LLVMContext &C)
static const fltSemantics & IEEEsingle() LLVM_READNONE
void setInsertPt(MachineBasicBlock &MBB, MachineBasicBlock::iterator II)
Set the insertion point before the specified position.
This is the shared class of boolean and integer constants.
LegalizeResult libcall(MachineInstr &MI)
Legalize an instruction by emiting a runtime library call instead.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
static RTLIB::Libcall getRTLibDesc(unsigned Opcode, unsigned Size)
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
The target wants to do something special with this combination of operand and type.
LegalizeResult lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Legalize an instruction by splitting it into simpler parts, hopefully understood by the target...
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.
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
LegalizeResult fewerElementsVector(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Legalize a vector instruction by splitting into multiple components, each acting on the same scalar t...
MachineInstrBuilder buildAdd(unsigned Dst, unsigned Src0, unsigned Src1)
Build and insert Res = G_ADD Op0, Op1.
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.
Class for arbitrary precision integers.
static RTLIB::Libcall getConvRTLibDesc(unsigned Opcode, Type *ToType, Type *FromType)
static MachineOperand CreateES(const char *SymName, unsigned char TargetFlags=0)
static LegalizerHelper::LegalizeResult conversionLibcall(MachineInstr &MI, MachineIRBuilder &MIRBuilder, Type *ToType, Type *FromType)
MachineInstrBuilder buildConstant(unsigned Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
const MachineBasicBlock * getParent() const
MachineInstrBuilder buildMerge(unsigned Res, ArrayRef< unsigned > Ops)
Build and insert Res = G_MERGE_VALUES Op0, ...
virtual bool legalizeCustom(MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &MIRBuilder) const
Representation of each machine instruction.
Instruction has been legalized and the MachineFunction changed.
Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
static IntegerType * getInt32Ty(LLVMContext &C)
void setReg(unsigned Reg)
Change the register this operand corresponds to.
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.
MachineFunction & getMF()
Getter for the function we currently build.
void setCImm(const ConstantInt *CI)
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Optional< MachineInstrBuilder > materializeGEP(unsigned &Res, unsigned Op0, const LLT &ValueTy, uint64_t Value)
Materialize and insert Res = G_GEP Op0, (G_CONSTANT Value)
Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
LegalizeResult narrowScalar(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Legalize an instruction by reducing the width of the underlying scalar type.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
This file describes how to lower LLVM calls to machine code calls.
MachineBasicBlock & getMBB()
Getter for the basic block we currently build.
MachineInstrBuilder buildInstr(unsigned Opc, DstTy &&Ty, UseArgsTy &&... Args)
DAG like Generic method for building arbitrary instructions as above.
MachineInstrBuilder buildMul(unsigned Dst, unsigned Src0, unsigned Src1)
Build and insert Res = G_MUL Op0, Op1.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
const MachineInstrBuilder & addDef(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
MachineInstrBuilder buildInsert(unsigned Res, unsigned Src, unsigned Op, unsigned Index)
const MachineOperand & getOperand(unsigned i) const
const ConstantInt * getCImm() const
The operation is expected to be selectable directly by the target, and no transformation is necessary...
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.
This file describes how to lower LLVM code to machine code.
unsigned getPredicate() const