36#define DEBUG_TYPE "bpf-lower"
40 cl::desc(
"Expand memcpy into load/store pairs in order"));
44 cl::desc(
"Set minimum number of entries to use a jump table on BPF"));
48 cl::desc(
"Allow libcalls instead of rejecting unsupported built-in "
98 for (
auto VT : {MVT::i8, MVT::i16, MVT::i32}) {
113 for (
auto VT : {MVT::i32, MVT::i64}) {
120 for (
auto VT : { MVT::i32, MVT::i64 }) {
130 if (VT == MVT::i32 || !STI.
hasHmul()) {
208 unsigned CommonMaxStores =
229 unsigned *
Fast)
const {
231 if (!AllowsMisalignedMemAccess)
249bool BPFTargetLowering::isTruncateFree(
Type *Ty1,
Type *Ty2)
const {
254 return NumBits1 > NumBits2;
257bool BPFTargetLowering::isTruncateFree(
EVT VT1,
EVT VT2)
const {
262 return NumBits1 > NumBits2;
265bool BPFTargetLowering::isZExtFree(
Type *Ty1,
Type *Ty2)
const {
270 return NumBits1 == 32 && NumBits2 == 64;
273bool BPFTargetLowering::isZExtFree(
EVT VT1,
EVT VT2)
const {
278 return NumBits1 == 32 && NumBits2 == 64;
281bool BPFTargetLowering::isZExtFree(
SDValue Val,
EVT VT2)
const {
286 if ((MT1 == MVT::i8 || MT1 == MVT::i16 || MT1 == MVT::i32) &&
287 (MT2 == MVT::i32 || MT2 == MVT::i64))
299 if (Constraint.
size() == 1) {
300 switch (Constraint[0]) {
311std::pair<unsigned, const TargetRegisterClass *>
315 if (Constraint.
size() == 1) {
317 switch (Constraint[0]) {
319 return std::make_pair(0U, &BPF::GPRRegClass);
322 return std::make_pair(0U, &BPF::GPR32RegClass);
332void BPFTargetLowering::ReplaceNodeResults(
346 Msg =
"unsupported atomic operation, please use 32/64 bit version";
348 Msg =
"unsupported atomic operation, please use 64 bit version";
362 switch (
Op.getOpcode()) {
366 return LowerBR_CC(
Op, DAG);
368 return LowerJumpTable(
Op, DAG);
370 return LowerBR_JT(
Op, DAG);
372 return LowerGlobalAddress(
Op, DAG);
374 return LowerConstantPool(
Op, DAG);
376 return LowerBlockAddress(
Op, DAG);
378 return LowerSELECT_CC(
Op, DAG);
381 return LowerSDIVSREM(
Op, DAG);
385 return LowerShiftParts(
Op, DAG);
387 return LowerDYNAMIC_STACKALLOC(
Op, DAG);
390 return LowerATOMIC_LOAD_STORE(
Op, DAG);
392 return LowerATOMIC_FENCE(
Op, DAG);
394 return LowerTRAP(
Op, DAG);
399#define GET_CALLING_CONV_IMPL
400#include "BPFGenCallingConv.inc"
417SDValue BPFTargetLowering::LowerFormalArguments(
430 MachineRegisterInfo &RegInfo = MF.
getRegInfo();
434 CCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.
getContext());
435 CCInfo.AnalyzeFormalArguments(Ins,
getHasAlu32() ? CC_BPF32 : CC_BPF64);
437 for (
size_t I = 0;
I < ArgLocs.
size(); ++
I) {
438 auto &VA = ArgLocs[
I];
439 EVT RegVT = VA.getLocVT();
448 raw_string_ostream OS(Str);
456 SimpleTy == MVT::i64 ? &BPF::GPRRegClass : &BPF::GPR32RegClass);
469 int Off = VA.getLocMemOffset() + 8;
470 if (
Off > INT16_MAX) {
471 fail(
DL, DAG,
"extra parameter stack depth exceeded limit");
476 SDValue StackVal = DAG.
getNode(BPFISD::LOAD_STACK_ARG,
DL,
477 DAG.
getVTList(MVT::i64, MVT::Other), Chain,
479 SDValue ArgValue = StackVal.
getValue(0);
487 fail(
DL, DAG,
"variadic functions are not supported");
494 RegMask[SubReg / 32] &= ~(1u << (SubReg % 32));
502 memcpy(RegMask, BaseRegMask,
sizeof(RegMask[0]) * RegMaskSize);
508 SelectionDAG &DAG = CLI.
DAG;
509 auto &Outs = CLI.
Outs;
512 SDValue Chain = CLI.
Chain;
532 CCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.
getContext());
534 CCInfo.AnalyzeCallOperands(Outs,
getHasAlu32() ? CC_BPF32 : CC_BPF64);
536 unsigned NumBytes = CCInfo.getStackSize();
538 for (
auto &Arg : Outs) {
539 ISD::ArgFlagsTy
Flags = Arg.Flags;
540 if (!
Flags.isByVal())
542 fail(CLI.
DL, DAG,
"pass by value not supported", Callee);
552 for (
size_t i = 0; i < OutVals.size(); ++i) {
553 CCValAssign &VA = ArgLocs[i];
554 SDValue &Arg = OutVals[i];
581 if (
Off < INT16_MIN) {
582 fail(CLI.
DL, DAG,
"extra parameter stack depth exceeded limit");
592 Chain = DAG.
getNode(BPFISD::STORE_STACK_ARG, CLI.
DL, MVT::Other, Chain,
605 for (
auto &
Reg : RegsToPass) {
618 StringRef Sym =
E->getSymbol();
620 Sym !=
"__divti3" && Sym !=
"__modti3" && Sym !=
"__udivti3" &&
621 Sym !=
"__umodti3" && Sym !=
"memcpy" && Sym !=
"memset" &&
625 Twine(
"A call to built-in function '" + Sym +
"' is not supported."));
629 SDVTList NodeTys = DAG.
getVTList(MVT::Other, MVT::Glue);
631 Ops.push_back(Chain);
632 Ops.push_back(Callee);
636 for (
auto &
Reg : RegsToPass)
645 for (
auto const &RegPair : RegsToPass)
656 Ops.push_back(InGlue);
658 Chain = DAG.
getNode(BPFISD::CALL, CLI.
DL, NodeTys,
Ops);
669 return LowerCallResult(Chain, InGlue, CallConv, IsVarArg, Ins, CLI.
DL, DAG,
679 unsigned Opc = BPFISD::RET_GLUE;
686 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, *DAG.
getContext());
689 CCInfo.AnalyzeReturn(Outs,
getHasAlu32() ? RetCC_BPF32 : RetCC_BPF64);
695 for (
size_t i = 0; i != RVLocs.
size(); ++i) {
696 CCValAssign &VA = RVLocs[i];
712 RetOps.push_back(Glue);
717SDValue BPFTargetLowering::LowerCallResult(
725 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, *DAG.
getContext());
727 CCInfo.AnalyzeCallResult(Ins,
getHasAlu32() ? RetCC_BPF32 : RetCC_BPF64);
730 for (
auto &Val : RVLocs) {
732 Val.getValVT(), InGlue).
getValue(1);
757 "unsupported signed division, please convert to unsigned div/mod.");
771 fail(
DL, DAG,
"unsupported dynamic stack allocation");
777 SDValue Chain =
Op.getOperand(0);
779 SDValue
LHS =
Op.getOperand(2);
780 SDValue
RHS =
Op.getOperand(3);
781 SDValue Dest =
Op.getOperand(4);
792 SDValue
LHS =
Op.getOperand(0);
793 SDValue
RHS =
Op.getOperand(1);
794 SDValue TrueV =
Op.getOperand(2);
795 SDValue FalseV =
Op.getOperand(3);
803 SDValue
Ops[] = {
LHS,
RHS, TargetCC, TrueV, FalseV};
805 return DAG.
getNode(BPFISD::SELECT_CC,
DL,
Op.getValueType(),
Ops);
810 SDNode *
N =
Op.getNode();
819 "sequentially consistent (seq_cst) "
820 "atomic load/store is not supported");
827 if (!HasLoadAcqStoreRel)
849 if (HasLoadAcqStoreRel &&
887 if (
auto *Fn = M->getFunction(
BPF_TRAP))
897 if (M->debug_compile_units().empty())
901 DITypeArray ParamTypes =
907 DINode::FlagZero, DISubprogram::SPFlagZero);
914 TargetLowering::CallLoweringInfo CLI(DAG);
916 SDNode *
N =
Op.getNode();
926 CLI.
DL = std::move(
DL);
929 return LowerCall(CLI, InVals);
939 SDValue Chain =
Op.getOperand(0);
941 SDValue
Index =
Op.getOperand(2);
944 std::vector<MachineBasicBlock *> MBBs = MJTI->
getJumpTables()[JTI].MBBs;
947 if (
Size != MBBs.size()) {
949 MBBs.resize(
Size, MBBs.back());
967 return getAddr(
N, DAG);
973 N->getOffset(), Flags);
981template <
class NodeTy>
983 unsigned Flags)
const {
988 return DAG.
getNode(BPFISD::Wrapper,
DL, MVT::i64, GA);
994 if (
N->getOffset() != 0)
996 Twine(
N->getOffset()));
998 const GlobalValue *GVal =
N->getGlobal();
1012 return getAddr(
N, DAG);
1032 int RShiftOp =
isSigned ? BPF::SRA_ri : BPF::SRL_ri;
1036 MachineRegisterInfo &RegInfo =
F->getRegInfo();
1041 return PromotedReg0;
1056 return PromotedReg2;
1060BPFTargetLowering::EmitInstrWithCustomInserterMemcpy(
MachineInstr &
MI,
1065 MachineInstrBuilder MIB(*MF,
MI);
1066 unsigned ScratchReg;
1084 MIB.addReg(ScratchReg,
1093 const BPFInstrInfo *
TII = MF->
getSubtarget<BPFSubtarget>().getInstrInfo();
1095 MachineRegisterInfo &RegInfo = MF->
getRegInfo();
1099 DenseMap<const BasicBlock *, MachineBasicBlock *> AddressTakenBBs;
1100 for (MachineBasicBlock &
MBB : *MF) {
1103 AddressTakenBBs[BB] = &
MBB;
1106 MachineOperand &MO =
MI.getOperand(1);
1109 Register ResultReg =
MI.getOperand(0).getReg();
1112 std::vector<MachineBasicBlock *> Targets;
1117 MachineBasicBlock *TgtMBB = AddressTakenBBs[BA->
getBasicBlock()];
1120 Targets.push_back(TgtMBB);
1122 ->createJumpTableIndex(Targets);
1129 MI.eraseFromParent();
1134 auto emitLDImm64 = [&](
const GlobalValue *GV =
nullptr,
unsigned JTI = -1) {
1135 auto MIB =
BuildMI(*BB,
MI,
DL,
TII->get(BPF::LD_imm64), ResultReg);
1137 MIB.addGlobalAddress(GV);
1139 MIB.addJumpTableIndex(JTI);
1140 MI.eraseFromParent();
1145 const GlobalValue *GVal = MO.
getGlobal();
1149 !GV->isConstant() || !GV->hasInitializer())
1150 return emitLDImm64(GVal);
1154 return emitLDImm64(GVal);
1156 for (
const Use &
Op : CA->operands()) {
1158 return emitLDImm64(GVal);
1160 MachineBasicBlock *TgtMBB = AddressTakenBBs[BA->
getBasicBlock()];
1162 Targets.push_back(TgtMBB);
1166 ->createJumpTableIndex(Targets);
1167 return emitLDImm64(
nullptr, JTI);
1175 unsigned Opc =
MI.getOpcode();
1176 bool isSelectRROp = (
Opc == BPF::Select ||
1177 Opc == BPF::Select_64_32 ||
1178 Opc == BPF::Select_32 ||
1179 Opc == BPF::Select_32_64);
1181 bool isMemcpyOp =
Opc == BPF::MEMCPY;
1182 bool isLDimm64Op =
Opc == BPF::LDIMM64;
1185 bool isSelectRIOp = (
Opc == BPF::Select_Ri ||
1186 Opc == BPF::Select_Ri_64_32 ||
1187 Opc == BPF::Select_Ri_32 ||
1188 Opc == BPF::Select_Ri_32_64);
1190 if (!(isSelectRROp || isSelectRIOp || isMemcpyOp || isLDimm64Op))
1195 return EmitInstrWithCustomInserterMemcpy(
MI, BB);
1198 return EmitInstrWithCustomInserterLDimm64(
MI, BB);
1200 bool is32BitCmp = (
Opc == BPF::Select_32 ||
1201 Opc == BPF::Select_32_64 ||
1202 Opc == BPF::Select_Ri_32 ||
1203 Opc == BPF::Select_Ri_32_64);
1222 F->insert(
I, Copy0MBB);
1223 F->insert(
I, Copy1MBB);
1226 unsigned CallFrameSize =
TII.getCallFrameSizeAt(
MI);
1240 int CC =
MI.getOperand(3).getImm();
1243#define SET_NEWCC(X, Y) \
1245 if (is32BitCmp && HasJmp32) \
1246 NewCC = isSelectRROp ? BPF::Y##_rr_32 : BPF::Y##_ri_32; \
1248 NewCC = isSelectRROp ? BPF::Y##_rr : BPF::Y##_ri; \
1277 if (is32BitCmp && !HasJmp32)
1278 LHS = EmitSubregExt(
MI, BB, LHS, isSignedCmp);
1283 if (is32BitCmp && !HasJmp32)
1284 RHS = EmitSubregExt(
MI, BB, RHS, isSignedCmp);
1288 int64_t imm32 =
MI.getOperand(2).getImm();
1314 MI.eraseFromParent();
1325 return (
getHasAlu32() && VT == MVT::i32) ? MVT::i32 : MVT::i64;
1328bool BPFTargetLowering::isLegalAddressingMode(
const DataLayout &
DL,
1350bool BPFTargetLowering::CanLowerReturn(
1353 const Type *RetTy)
const {
1355 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs,
Context);
1356 return CCInfo.CheckReturn(Outs,
getHasAlu32() ? RetCC_BPF32 : RetCC_BPF64);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
static uint32_t * regMaskFromTemplate(const TargetRegisterInfo *TRI, MachineFunction &MF, const uint32_t *BaseRegMask)
static Function * createBPFUnreachable(Module *M)
static cl::opt< bool > BPFAllowsLibcalls("bpf-allows-libcalls", cl::Hidden, cl::init(false), cl::desc("Allow libcalls instead of rejecting unsupported built-in " "functions"))
static SDValue getTargetNode(ConstantPoolSDNode *N, const SDLoc &DL, EVT Ty, SelectionDAG &DAG, unsigned Flags)
static cl::opt< bool > BPFExpandMemcpyInOrder("bpf-expand-memcpy-in-order", cl::Hidden, cl::init(false), cl::desc("Expand memcpy into load/store pairs in order"))
static SDValue convertLocValType(SelectionDAG &DAG, const SDLoc &DL, const CCValAssign &VA, EVT RegVT, SDValue ArgValue)
static void fail(const SDLoc &DL, SelectionDAG &DAG, const Twine &Msg, SDValue Val={})
static cl::opt< unsigned > BPFMinimumJumpTableEntries("bpf-min-jump-table-entries", cl::init(13), cl::Hidden, cl::desc("Set minimum number of entries to use a jump table on BPF"))
static void resetRegMaskBit(const TargetRegisterInfo *TRI, uint32_t *RegMask, MCRegister Reg)
static void NegateCC(SDValue &LHS, SDValue &RHS, ISD::CondCode &CC)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool isSigned(unsigned Opcode)
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Register const TargetRegisterInfo * TRI
Promote Memory to Register
MachineRegisterInfo & MRI
an instruction that atomically reads a memory location, combines it with another value,...
BinOp getOperation() const
unsigned getCommonMaxStoresPerMemFunc() const
bool hasLoadAcqStoreRel() const
bool getAllowsMisalignedMemAccess() const
bool getHasJmpExt() const
const BPFSelectionDAGInfo * getSelectionDAGInfo() const override
const BPFRegisterInfo * getRegisterInfo() const override
BPFTargetLowering::ConstraintType getConstraintType(StringRef Constraint) const override
Given a constraint, return the type of constraint it is for this target.
unsigned getJumpTableEncoding() const override
Return the entry encoding for a jump table in the current function.
bool getHasJmpExt() const
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
AtomicExpansionKind shouldExpandAtomicRMWInIR(const AtomicRMWInst *AI) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned, Align, MachineMemOperand::Flags, unsigned *) const override
Determine if the target supports unaligned memory accesses.
AtomicExpansionKind shouldExpandAtomicStoreInIR(StoreInst *SI) const override
Returns how the given (atomic) store should be expanded by the IR-level AtomicExpand pass into.
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override
Return the ValueType of the result of SETCC operations.
BPFTargetLowering(const TargetMachine &TM, const BPFSubtarget &STI)
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override
Return the type to use for a scalar shift opcode, given the shifted amount type.
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
LLVM Basic Block Representation.
BasicBlock * getBasicBlock() const
CCValAssign - Represent assignment of one arg/retval to a location.
Register getLocReg() const
LocInfo getLocInfo() const
int64_t getLocMemOffset() const
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
LLVM_ABI DISubroutineType * createSubroutineType(DITypeArray ParameterTypes, DINode::DIFlags Flags=DINode::FlagZero, unsigned CC=0)
Create subroutine type.
LLVM_ABI DISubprogram * createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine, DINode::DIFlags Flags=DINode::FlagZero, DISubprogram::DISPFlags SPFlags=DISubprogram::SPFlagZero, DITemplateParameterArray TParams=nullptr, DISubprogram *Decl=nullptr, DITypeArray ThrownTypes=nullptr, DINodeArray Annotations=nullptr, StringRef TargetFuncName="", bool UseKeyInstructions=false)
Create a new descriptor for the specified subprogram.
LLVM_ABI DITypeArray getOrCreateTypeArray(ArrayRef< Metadata * > Elements)
Get a DITypeArray, create one if required.
Subprogram description. Uses SubclassData1.
Type array for a subprogram.
A parsed version of the target data layout string in and methods for querying it.
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
Diagnostic information for unsupported feature in backend.
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
void setSubprogram(DISubprogram *SP)
Set the attached subprogram.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
void setCallingConv(CallingConv::ID CC)
LLVM_ABI void setSection(StringRef S)
Change the section for this global.
LinkageTypes getLinkage() const
Module * getParent()
Get the module that this global value is contained inside of...
void setDSOLocal(bool Local)
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ ExternalWeakLinkage
ExternalWeak linkage description.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this instruction belongs to.
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
This is an important class for using LLVM in a threaded context.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Wrapper class representing physical registers. Should be passed by value.
static auto integer_valuetypes()
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
void setCallFrameSize(unsigned N)
Set the call frame size on entry to this basic block.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
bool hasAddressTaken() const
Test whether this block is used as something other than the target of a terminator,...
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstrBundleIterator< MachineInstr > iterator
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Function & getFunction()
Return the LLVM function that this machine code represents.
BasicBlockListType::iterator iterator
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addJumpTableIndex(unsigned Idx, unsigned TargetFlags=0) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
Representation of each machine instruction.
void RemoveJumpTable(unsigned Idx)
RemoveJumpTable - Mark the specific index as being dead.
LLVM_ABI unsigned createJumpTableIndex(const std::vector< MachineBasicBlock * > &DestBBs)
createJumpTableIndex - Create a new jump table.
@ EK_BlockAddress
EK_BlockAddress - Each entry is a plain address of block, e.g.: .word LBB123.
const std::vector< MachineJumpTableEntry > & getJumpTables() const
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
const GlobalValue * getGlobal() const
const BlockAddress * getBlockAddress() const
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
bool isBlockAddress() const
isBlockAddress - Tests if this is a MO_BlockAddress operand.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
A Module instance is used to store all the information related to an LLVM module.
Wrapper class representing virtual and physical registers.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
const SDValue & getOperand(unsigned Num) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
unsigned getOpcode() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N)
LLVM_ABI SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
LLVM_ABI SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s),...
LLVM_ABI SDValue getRegister(Register Reg, EVT VT)
LLVM_ABI SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Val, MachineMemOperand *MMO)
Gets a node for an atomic op, produces result (if relevant) and chain and takes 2 operands.
void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge)
Set NoMergeSiteInfo to be associated with Node if NoMerge is true.
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags=0)
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, const SDLoc &DL)
Return a new CALLSEQ_END node, which always must have a glue result (to ensure it's not CSE'd).
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, Register Reg, EVT VT)
LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Helper function to build ISD::STORE nodes.
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize, const SDLoc &DL)
Return a new CALLSEQ_START node, that starts new call frame, in which InSize bytes are set up inside ...
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Loads are not normal binary operators: their result type is not determined by their operands,...
LLVM_ABI SDValue getValueType(EVT)
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
LLVM_ABI SDValue getJumpTable(int JTI, EVT VT, bool isTarget=false, unsigned TargetFlags=0)
MachineFunction & getMachineFunction() const
LLVM_ABI SDValue getRegisterMask(const uint32_t *RegMask)
LLVMContext * getContext() const
LLVM_ABI SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
LLVM_ABI SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment)
Create a stack temporary based on the size in bytes and the alignment.
SDValue getTargetConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offset=0, unsigned TargetFlags=0)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
constexpr size_t size() const
Get the string size.
TargetInstrInfo - Interface to description of machine instruction set.
void setOperationAction(unsigned Op, MVT VT, LegalizeAction Action)
Indicate that the specified operation does not work with the specified type and indicate what to do a...
unsigned MaxStoresPerMemcpyOptSize
Likewise for functions with the OptSize attribute.
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
virtual AtomicExpansionKind shouldExpandAtomicRMWInIR(const AtomicRMWInst *RMW) const
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
unsigned MaxLoadsPerMemcmp
Specify maximum number of load instructions per memcmp call.
virtual bool isZExtFree(Type *FromTy, Type *ToTy) const
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
void setMaxAtomicSizeInBitsSupported(unsigned SizeInBits)
Set the maximum atomic operation size supported by the backend.
void setMinFunctionAlignment(Align Alignment)
Set the target's minimum function alignment.
unsigned MaxStoresPerMemsetOptSize
Likewise for functions with the OptSize attribute.
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
unsigned MaxStoresPerMemmove
Specify maximum number of store instructions per memmove call.
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose.
unsigned MaxStoresPerMemmoveOptSize
Likewise for functions with the OptSize attribute.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type.
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
void setPrefFunctionAlignment(Align Alignment)
Set the target's preferred function alignment.
unsigned MaxStoresPerMemset
Specify maximum number of store instructions per memset call.
void setMinimumJumpTableEntries(unsigned Val)
Indicate the minimum number of blocks to generate jump tables.
@ ZeroOrOneBooleanContent
unsigned MaxLoadsPerMemcmpOptSize
Likewise for functions with the OptSize attribute.
void setMinCmpXchgSizeInBits(unsigned SizeInBits)
Sets the minimum cmpxchg or ll/sc size supported by the backend.
void setStackPointerRegisterToSaveRestore(Register R)
If set to a physical register, this specifies the register that llvm.savestack/llvm....
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified load with extension does not work with the specified type and indicate wh...
unsigned MaxStoresPerMemcpy
Specify maximum number of store instructions per memcpy call.
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
TargetLowering(const TargetLowering &)=delete
void expandShiftParts(SDNode *N, SDValue &Lo, SDValue &Hi, SelectionDAG &DAG) const
Expand shift-by-parts.
Primary interface to the complete machine description for the target machine.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
bool isVoidTy() const
Return true if this is 'void'.
Type * getType() const
All values are typed, get the type of this value.
self_iterator getIterator()
A raw_ostream that writes to an std::string.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ PreserveAll
Used for runtime calls that preserves (almost) all registers.
@ Fast
Attempts to make calls as fast as possible (e.g.
@ C
The default llvm calling convention, compatible with C.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ STACKRESTORE
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain.
@ STACKSAVE
STACKSAVE - STACKSAVE has one operand, an input chain.
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ BSWAP
Byte Swap and Counting operators.
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ MEMBARRIER
MEMBARRIER - Compiler barrier only; generate a no-op.
@ ATOMIC_FENCE
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ SIGN_EXTEND
Conversion operators.
@ BR_CC
BR_CC - Conditional branch.
@ BRIND
BRIND - Indirect branch.
@ BR_JT
BR_JT - Jumptable branch.
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ SHL
Shift and rotation operations.
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ DYNAMIC_STACKALLOC
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary.
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ TRAP
TRAP - Trapping instruction.
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ BRCOND
BRCOND - Conditional branch.
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
LLVM_ABI CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y).
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
@ SingleThread
Synchronized with respect to signal handlers executing in the same thread.
@ System
Synchronized with respect to all concurrently executing threads.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
@ EarlyClobber
Register definition happens before uses.
@ Define
Register definition.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
@ Load
The value being inserted comes from a load (InsertElement only).
detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&...Ranges)
Returns a concatenated range across two or more ranges.
uint64_t PowerOf2Ceil(uint64_t A)
Returns the power of two which is greater than or equal to the given value.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
@ Fast
Assign the register banks as fast as possible (default).
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
MCRegisterClass TargetRegisterClass
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
LLVM_ABI void print(raw_ostream &OS) const
Implement operator<<.
bool isInteger() const
Return true if this is an integer or a vector integer type.
This class contains a discriminated union of information about pointers in memory operands,...
static LLVM_ABI MachinePointerInfo getJumpTable(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a jump table entry.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
This structure contains all information that is necessary for lowering calls.
SmallVector< ISD::InputArg, 32 > Ins
SmallVector< ISD::OutputArg, 32 > Outs
SmallVector< SDValue, 32 > OutVals