31 #include "llvm/IR/IntrinsicsWebAssembly.h" 38 #define DEBUG_TYPE "wasm-lower" 53 Subtarget->
hasAddr64() ? WebAssembly::SP64 : WebAssembly::SP32);
254 if (
MVT(
T) != MemT) {
291 setLibcallName(RTLIB::RETURN_ADDRESS,
"emscripten_return_address");
300 WebAssemblyTargetLowering::shouldExpandAtomicRMWInIR(
AtomicRMWInst *AI)
const {
316 FastISel *WebAssemblyTargetLowering::createFastISel(
321 MVT WebAssemblyTargetLowering::getScalarShiftAmountTy(
const DataLayout & ,
324 if (BitWidth > 1 && BitWidth < 8)
332 "32-bit shift counts ought to be enough for anyone");
337 "Unable to represent scalar shift amount type");
347 bool IsUnsigned,
bool Int64,
348 bool Float64,
unsigned LoweredOpcode) {
354 unsigned Abs = Float64 ? WebAssembly::ABS_F64 : WebAssembly::ABS_F32;
355 unsigned FConst = Float64 ? WebAssembly::CONST_F64 : WebAssembly::CONST_F32;
356 unsigned LT = Float64 ? WebAssembly::LT_F64 : WebAssembly::LT_F32;
357 unsigned GE = Float64 ? WebAssembly::GE_F64 : WebAssembly::GE_F32;
358 unsigned IConst = Int64 ? WebAssembly::CONST_I64 : WebAssembly::CONST_I32;
359 unsigned Eqz = WebAssembly::EQZ_I32;
360 unsigned And = WebAssembly::AND_I32;
361 int64_t Limit = Int64 ?
INT64_MIN : INT32_MIN;
362 int64_t Substitute = IsUnsigned ? 0 : Limit;
363 double CmpVal = IsUnsigned ? -(double)Limit * 2.0 : -(
double)Limit;
387 unsigned Tmp0, Tmp1, CmpReg, EqzReg, FalseReg, TrueReg;
401 BuildMI(BB, DL, TII.
get(Abs), Tmp0).addReg(InReg);
420 BuildMI(BB, DL, TII.
get(Eqz), EqzReg).addReg(CmpReg);
424 BuildMI(BB, DL, TII.
get(WebAssembly::BR_IF)).addMBB(TrueMBB).
addReg(EqzReg);
425 BuildMI(FalseMBB, DL, TII.
get(LoweredOpcode), FalseReg).addReg(InReg);
427 BuildMI(TrueMBB, DL, TII.
get(IConst), TrueReg).addImm(Substitute);
428 BuildMI(*DoneMBB, DoneMBB->
begin(), DL, TII.
get(TargetOpcode::PHI), OutReg)
445 case WebAssembly::FP_TO_SINT_I32_F32:
446 return LowerFPToInt(MI, DL, BB, TII,
false,
false,
false,
447 WebAssembly::I32_TRUNC_S_F32);
448 case WebAssembly::FP_TO_UINT_I32_F32:
449 return LowerFPToInt(MI, DL, BB, TII,
true,
false,
false,
450 WebAssembly::I32_TRUNC_U_F32);
451 case WebAssembly::FP_TO_SINT_I64_F32:
452 return LowerFPToInt(MI, DL, BB, TII,
false,
true,
false,
453 WebAssembly::I64_TRUNC_S_F32);
454 case WebAssembly::FP_TO_UINT_I64_F32:
456 WebAssembly::I64_TRUNC_U_F32);
457 case WebAssembly::FP_TO_SINT_I32_F64:
458 return LowerFPToInt(MI, DL, BB, TII,
false,
false,
true,
459 WebAssembly::I32_TRUNC_S_F64);
460 case WebAssembly::FP_TO_UINT_I32_F64:
462 WebAssembly::I32_TRUNC_U_F64);
463 case WebAssembly::FP_TO_SINT_I64_F64:
465 WebAssembly::I64_TRUNC_S_F64);
466 case WebAssembly::FP_TO_UINT_I64_F64:
468 WebAssembly::I64_TRUNC_U_F64);
474 WebAssemblyTargetLowering::getTargetNodeName(
unsigned Opcode)
const {
475 switch (static_cast<WebAssemblyISD::NodeType>(Opcode)) {
479 #define HANDLE_NODETYPE(NODE) \ 480 case WebAssemblyISD::NODE: \ 481 return "WebAssemblyISD::" #NODE; 482 #define HANDLE_MEM_NODETYPE(NODE) HANDLE_NODETYPE(NODE) 483 #include "WebAssemblyISD.def" 484 #undef HANDLE_MEM_NODETYPE 485 #undef HANDLE_NODETYPE 490 std::pair<unsigned, const TargetRegisterClass *>
491 WebAssemblyTargetLowering::getRegForInlineAsmConstraint(
495 if (Constraint.
size() == 1) {
496 switch (Constraint[0]) {
501 return std::make_pair(0U, &WebAssembly::V128RegClass);
505 return std::make_pair(0U, &WebAssembly::I32RegClass);
507 return std::make_pair(0U, &WebAssembly::I64RegClass);
518 bool WebAssemblyTargetLowering::isCheapToSpeculateCttz()
const {
523 bool WebAssemblyTargetLowering::isCheapToSpeculateCtlz()
const {
528 bool WebAssemblyTargetLowering::isLegalAddressingMode(
const DataLayout &DL,
530 Type *Ty,
unsigned AS,
546 bool WebAssemblyTargetLowering::allowsMisalignedMemoryAccesses(
547 EVT ,
unsigned ,
unsigned ,
560 bool WebAssemblyTargetLowering::isIntDivCheap(
EVT VT,
567 bool WebAssemblyTargetLowering::isVectorLoadExtDesirable(
SDValue ExtVal)
const {
577 EVT WebAssemblyTargetLowering::getSetCCResultType(
const DataLayout &DL,
586 bool WebAssemblyTargetLowering::getTgtMemIntrinsic(IntrinsicInfo &
Info,
589 unsigned Intrinsic)
const {
591 case Intrinsic::wasm_atomic_notify:
605 case Intrinsic::wasm_atomic_wait_i32:
613 case Intrinsic::wasm_atomic_wait_i64:
655 WebAssemblyTargetLowering::LowerCall(CallLoweringInfo &CLI,
667 "WebAssembly doesn't support language-specific or target-specific " 668 "calling conventions yet");
669 if (CLI.IsPatchPoint)
670 fail(DL, DAG,
"WebAssembly doesn't support patch point yet");
672 if (CLI.IsTailCall) {
673 bool MustTail = CLI.CS && CLI.CS.isMustTailCall();
683 bool TypesMatch = CallerRetTys.
size() == CalleeRetTys.
size() &&
685 CalleeRetTys.
begin());
689 CLI.IsTailCall =
false;
692 CLI.IsTailCall =
false;
696 fail(DL, DAG,
"WebAssembly does not support varargs tail calls");
698 fail(DL, DAG,
"WebAssembly 'tail-call' feature not enabled");
706 fail(DL, DAG,
"WebAssembly doesn't support more than 1 returned value yet");
715 Outs[0].Flags.isSRet()) {
721 for (
unsigned I = 0; I < Outs.
size(); ++
I) {
725 fail(DL, DAG,
"WebAssembly hasn't implemented nest arguments");
727 fail(DL, DAG,
"WebAssembly hasn't implemented inalloca arguments");
729 fail(DL, DAG,
"WebAssembly hasn't implemented cons regs arguments");
731 fail(DL, DAG,
"WebAssembly hasn't implemented cons regs last arguments");
750 bool IsVarArg = CLI.IsVarArg;
760 for (
unsigned I = NumFixedArgs; I < Outs.
size(); ++
I) {
767 Layout.getABITypeAlignment(Ty));
768 unsigned Offset = CCInfo.AllocateStack(Layout.getTypeAllocSize(Ty),
776 unsigned NumBytes = CCInfo.getAlignedCallFrameSize();
779 if (IsVarArg && NumBytes) {
783 Layout.getStackAlignment(),
789 assert(ArgLocs[ValNo].getValNo() == ValNo &&
790 "ArgLocs should remain in order and only hold varargs args");
791 unsigned Offset = ArgLocs[ValNo++].getLocMemOffset();
801 }
else if (IsVarArg) {
831 for (
const auto &
In : Ins) {
832 assert(!
In.Flags.isByVal() &&
"byval is not valid for return values");
833 assert(!
In.Flags.isNest() &&
"nest is not valid for return values");
834 if (
In.Flags.isInAlloca())
835 fail(DL, DAG,
"WebAssembly hasn't implemented inalloca return values");
836 if (
In.Flags.isInConsecutiveRegs())
837 fail(DL, DAG,
"WebAssembly hasn't implemented cons regs return values");
838 if (
In.Flags.isInConsecutiveRegsLast())
840 "WebAssembly hasn't implemented cons regs last return values");
846 if (CLI.IsTailCall) {
849 return DAG.
getNode(WebAssemblyISD::RET_CALL, DL, NodeTys, Ops);
855 DAG.
getNode(Ins.empty() ? WebAssemblyISD::CALL0 : WebAssemblyISD::CALL1,
867 bool WebAssemblyTargetLowering::CanLowerReturn(
875 SDValue WebAssemblyTargetLowering::LowerReturn(
881 "MVP WebAssembly can only return up to one value");
883 fail(DL, DAG,
"WebAssembly doesn't support non-C calling conventions");
891 assert(!Out.Flags.isByVal() &&
"byval is not valid for return values");
892 assert(!Out.Flags.isNest() &&
"nest is not valid for return values");
893 assert(Out.IsFixed &&
"non-fixed return value is not valid");
894 if (Out.Flags.isInAlloca())
895 fail(DL, DAG,
"WebAssembly hasn't implemented inalloca results");
896 if (Out.Flags.isInConsecutiveRegs())
897 fail(DL, DAG,
"WebAssembly hasn't implemented cons regs results");
898 if (Out.Flags.isInConsecutiveRegsLast())
899 fail(DL, DAG,
"WebAssembly hasn't implemented cons regs last results");
905 SDValue WebAssemblyTargetLowering::LowerFormalArguments(
910 fail(DL, DAG,
"WebAssembly doesn't support non-C calling conventions");
920 if (
In.Flags.isInAlloca())
921 fail(DL, DAG,
"WebAssembly hasn't implemented inalloca arguments");
922 if (
In.Flags.isNest())
923 fail(DL, DAG,
"WebAssembly hasn't implemented nest arguments");
924 if (
In.Flags.isInConsecutiveRegs())
925 fail(DL, DAG,
"WebAssembly hasn't implemented cons regs arguments");
926 if (
In.Flags.isInConsecutiveRegsLast())
927 fail(DL, DAG,
"WebAssembly hasn't implemented cons regs last arguments");
936 MFI->addParam(
In.VT);
945 MFI->setVarargBufferVreg(VarargVreg);
947 Chain, DL, VarargVreg,
948 DAG.
getNode(WebAssemblyISD::ARGUMENT, DL, PtrVT,
950 MFI->addParam(PtrVT);
958 for (
MVT VT : Results)
962 assert(MFI->getParams().size() == Params.
size() &&
963 std::equal(MFI->getParams().begin(), MFI->getParams().end(),
969 void WebAssemblyTargetLowering::ReplaceNodeResults(
980 "ReplaceNodeResults not implemented for this op for WebAssembly!");
996 return LowerFrameIndex(Op, DAG);
998 return LowerGlobalAddress(Op, DAG);
1000 return LowerExternalSymbol(Op, DAG);
1002 return LowerJumpTable(Op, DAG);
1004 return LowerBR_JT(Op, DAG);
1006 return LowerVASTART(Op, DAG);
1009 fail(DL, DAG,
"WebAssembly hasn't implemented computed gotos");
1012 return LowerRETURNADDR(Op, DAG);
1014 return LowerFRAMEADDR(Op, DAG);
1016 return LowerCopyToReg(Op, DAG);
1019 return LowerAccessVectorElement(Op, DAG);
1023 return LowerIntrinsic(Op, DAG);
1025 return LowerSIGN_EXTEND_INREG(Op, DAG);
1027 return LowerBUILD_VECTOR(Op, DAG);
1029 return LowerVECTOR_SHUFFLE(Op, DAG);
1031 return LowerSETCC(Op, DAG);
1035 return LowerShift(Op, DAG);
1042 if (isa<FrameIndexSDNode>(Src.
getNode())) {
1053 : WebAssembly::COPY_I64,
1067 int FI = cast<FrameIndexSDNode>(
Op)->getIndex();
1077 "Non-Emscripten WebAssembly hasn't implemented " 1078 "__builtin_return_address");
1085 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
1086 MakeLibCallOptions CallOptions;
1107 SDValue WebAssemblyTargetLowering::LowerGlobalAddress(
SDValue Op,
1110 const auto *GA = cast<GlobalAddressSDNode>(
Op);
1112 assert(GA->getTargetFlags() == 0 &&
1113 "Unexpected target flags on generic GlobalAddressSDNode");
1114 if (GA->getAddressSpace() != 0)
1115 fail(DL, DAG,
"WebAssembly only expects the 0 address space");
1123 const char *BaseName;
1153 WebAssemblyTargetLowering::LowerExternalSymbol(
SDValue Op,
1156 const auto *ES = cast<ExternalSymbolSDNode>(
Op);
1158 assert(ES->getTargetFlags() == 0 &&
1159 "Unexpected target flags on generic ExternalSymbolSDNode");
1178 const auto *
JT = cast<JumpTableSDNode>(Op.
getOperand(1));
1180 assert(
JT->getTargetFlags() == 0 &&
"WebAssembly doesn't set target flags");
1184 Ops.push_back(Index);
1190 for (
auto MBB : MBBs)
1210 MFI->getVarargBufferVreg(), PtrVT);
1222 IntNo = cast<ConstantSDNode>(Op.
getOperand(1))->getZExtValue();
1225 IntNo = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
1236 case Intrinsic::wasm_lsda: {
1247 case Intrinsic::wasm_throw: {
1257 return DAG.
getNode(WebAssemblyISD::THROW, DL,
1269 WebAssemblyTargetLowering::LowerSIGN_EXTEND_INREG(
SDValue Op,
1287 if (ExtractedVecT == VecT)
1326 auto IsConstant = [](
const SDValue &V) {
1335 auto GetSwizzleSrcs = [](
size_t I,
const SDValue &Lane) {
1352 return std::make_pair(SwizzleSrc, SwizzleIndices);
1355 using ValueEntry = std::pair<SDValue, size_t>;
1358 using SwizzleEntry = std::pair<std::pair<SDValue, SDValue>,
size_t>;
1361 auto AddCount = [](
auto &Counts,
const auto &Val) {
1362 auto CountIt =
std::find_if(Counts.begin(), Counts.end(),
1363 [&Val](
auto E) {
return E.first == Val; });
1364 if (CountIt == Counts.end()) {
1365 Counts.emplace_back(Val, 1);
1371 auto GetMostCommon = [](
auto &Counts) {
1373 std::max_element(Counts.begin(), Counts.end(),
1374 [](
auto A,
auto B) {
return A.second <
B.second; });
1375 assert(CommonIt != Counts.end() &&
"Unexpected all-undef build_vector");
1379 size_t NumConstantLanes = 0;
1382 for (
size_t I = 0; I < Lanes; ++
I) {
1387 AddCount(SplatValueCounts, Lane);
1389 if (IsConstant(Lane)) {
1391 }
else if (CanSwizzle) {
1392 auto SwizzleSrcs = GetSwizzleSrcs(I, Lane);
1393 if (SwizzleSrcs.first)
1394 AddCount(SwizzleCounts, SwizzleSrcs);
1399 size_t NumSplatLanes;
1400 std::tie(SplatValue, NumSplatLanes) = GetMostCommon(SplatValueCounts);
1404 size_t NumSwizzleLanes = 0;
1405 if (SwizzleCounts.
size())
1406 std::forward_as_tuple(std::tie(SwizzleSrc, SwizzleIndices),
1407 NumSwizzleLanes) = GetMostCommon(SwizzleCounts);
1411 std::function<bool(size_t, const SDValue &)> IsLaneConstructed;
1415 if (NumSwizzleLanes >= NumSplatLanes &&
1416 NumSwizzleLanes >= NumConstantLanes) {
1417 Result = DAG.
getNode(WebAssemblyISD::SWIZZLE, DL, VecT, SwizzleSrc,
1419 auto Swizzled = std::make_pair(SwizzleSrc, SwizzleIndices);
1420 IsLaneConstructed = [&, Swizzled](
size_t I,
const SDValue &Lane) {
1421 return Swizzled == GetSwizzleSrcs(I, Lane);
1423 }
else if (NumConstantLanes >= NumSplatLanes) {
1426 if (IsConstant(Lane)) {
1435 IsLaneConstructed = [&](
size_t _,
const SDValue &Lane) {
1436 return IsConstant(Lane);
1447 WebAssemblyISD::LOAD_SPLAT, DL, DAG.
getVTList(VecT),
1454 IsLaneConstructed = [&](
size_t _,
const SDValue &Lane) {
1455 return Lane == SplatValue;
1460 for (
size_t I = 0; I < Lanes; ++
I) {
1462 if (!Lane.
isUndef() && !IsLaneConstructed(I, Lane))
1471 WebAssemblyTargetLowering::LowerVECTOR_SHUFFLE(
SDValue Op,
1486 for (
int M : Mask) {
1487 for (
size_t J = 0; J < LaneBytes; ++J) {
1489 uint64_t ByteIndex = M == -1 ? 0 : (uint64_t)M * LaneBytes + J;
1511 auto MakeLane = [&](
unsigned I) {
1517 {MakeLane(0), MakeLane(1)});
1521 WebAssemblyTargetLowering::LowerAccessVectorElement(
SDValue Op,
1525 if (isa<ConstantSDNode>(IdxNode) || IdxNode->
isUndef())
1568 !(SplatVal = ShiftVec->getSplatValue()))
1580 Opcode = WebAssemblyISD::VEC_SHL;
1583 Opcode = WebAssemblyISD::VEC_SHR_S;
1586 Opcode = WebAssemblyISD::VEC_SHR_U;
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
void setFrameAddressIsTaken(bool T)
static MVT getIntegerVT(unsigned BitWidth)
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
This file defines the interfaces that WebAssembly uses to lower LLVM code into a selection DAG...
bool isOSEmscripten() const
Tests whether the OS is Emscripten.
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
EVT getValueType() const
Return the ValueType of the referenced return value.
bool isInteger() const
Return true if this is an integer or a vector integer type.
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...
const SDValue & getOffset() const
static Type * getDoubleTy(LLVMContext &C)
const std::vector< MachineJumpTableEntry > & getJumpTables() const
const GlobalValue * getGlobal() const
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
Diagnostic information for unsupported feature in backend.
SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
Utility function used by legalize and lowering to "unroll" a vector operation by splitting out the sc...
void setMinimumJumpTableEntries(unsigned Val)
Indicate the minimum number of blocks to generate jump tables.
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
BR_CC - Conditional branch.
This class represents lattice values for constants.
static MVT getVectorVT(MVT VT, unsigned NumElements)
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0...
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool isVector() const
Return true if this is a vector value type.
void addLiveIn(unsigned Reg, unsigned vreg=0)
addLiveIn - Add the specified register as a live-in.
const SDValue & getBasePtr() const
Carry-setting nodes for multiple precision addition and subtraction.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain...
This class represents a function call, abstracting a target machine's calling convention.
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
SDValue getBasicBlock(MachineBasicBlock *MBB)
unsigned getVectorNumElements() const
const SDValue & getChain() const
Function Alias Analysis Results
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
void setBooleanVectorContents(BooleanContent Ty)
Specify how the target extends the result of a vector boolean value from a vector of i1 to a wider ty...
C - The default llvm calling convention, compatible with C.
unsigned const TargetRegisterInfo * TRI
MVT getSimpleValueType(unsigned ResNo) const
Return the type of a specified result as a simple type.
MachineModuleInfo & getMMI() const
[US]{MIN/MAX} - Binary minimum or maximum or signed or unsigned integers.
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
void computeSignatureVTs(const FunctionType *Ty, const Function &F, const TargetMachine &TM, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results)
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
SDValue getMCSymbol(MCSymbol *Sym, EVT VT)
Register getFrameRegister(const MachineFunction &MF) const override
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
Value * getArgOperand(unsigned i) const
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations...
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
FastISel * createFastISel(FunctionLoweringInfo &funcInfo, const TargetLibraryInfo *libInfo)
amdgpu aa AMDGPU Address space based Alias Analysis Wrapper
void setMaxAtomicSizeInBitsSupported(unsigned SizeInBits)
Set the maximum atomic operation size supported by the backend.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
static Type * getFloatTy(LLVMContext &C)
Shift and rotation operations.
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
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), MachineInstr opcode, and operands.
BinOp getOperation() const
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
CopyToReg - This node has three operands: a chain, a register number to set to this value...
uint64_t getConstantOperandVal(unsigned i) const
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags=0)
void setCondCodeAction(ISD::CondCode CC, MVT VT, LegalizeAction Action)
Indicate that the specified condition code is or isn't supported on the target and indicate what to d...
bool isInConsecutiveRegs() const
bool hasUnimplementedSIMD128() const
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
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...
const DataLayout & getDataLayout() const
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
This class is used to represent EVT's, which are used to parameterize some operations.
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
static mvt_range integer_fixedlen_vector_valuetypes()
OutputArg - This struct carries flags and a value for a single outgoing (actual) argument or outgoing...
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
STACKSAVE - STACKSAVE has one operand, an input chain.
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
This file declares the WebAssembly-specific subclass of TargetMachine.
MachineFunction & getMachineFunction() const
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose...
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
SDValue getTargetFrameIndex(int FI, EVT VT)
const TargetMachine & getTarget() const
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
const MCContext & getContext() const
Simple integer binary arithmetic operators.
LLVM_NODISCARD size_t size() const
size - Get the string size.
unsigned getTargetFlags() const
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements. ...
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
MVT getVectorElementType() const
Analysis containing CSE Info
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
unsigned getByValSize() const
bool IsFixed
IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
bool hasMultivalue() const
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
TargetInstrInfo - Interface to description of machine instruction set.
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
static SDValue unrollVectorShift(SDValue Op, SelectionDAG &DAG)
bool is128BitVector() const
Return true if this is a 128-bit vector type.
The memory access is volatile.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
Type * getReturnType() const
Returns the type of the ret val.
int64_t getOffset() const
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
MVT getSimpleValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the MVT corresponding to this LLVM type. See getValueType.
Control flow instructions. These all have token chains.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const MachineRegisterInfo * MRI
LLVM Basic Block Representation.
unsigned getOrigAlign() const
The instances of the Type class are immutable: once they are created, they are never changed...
const Triple & getTargetTriple() const
This is an important class for using LLVM in a threaded context.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type...
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE...
iterator_range< value_op_iterator > op_values() const
const SDValue & getOperand(unsigned Num) const
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL...
Carry-using nodes for multiple precision addition and subtraction.
OperandFlags
These are flags set on operands, but should be considered private, all access should go through the M...
This file provides WebAssembly-specific target descriptions.
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
TRAP - Trapping instruction.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
self_iterator getIterator()
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
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...
static unsigned NumFixedArgs
uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isPositionIndependent() const
const TargetMachine & getTargetMachine() const
This class contains a discriminated union of information about pointers in memory operands...
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This struct is a compact representation of a valid (non-zero power of two) alignment.
WebAssemblyTargetLowering(const TargetMachine &TM, const WebAssemblySubtarget &STI)
SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
TokenFactor - This node takes multiple tokens as input and produces a single token result...
static MachineBasicBlock * LowerFPToInt(MachineInstr &MI, DebugLoc DL, MachineBasicBlock *BB, const TargetInstrInfo &TII, bool IsUnsigned, bool Int64, bool Float64, unsigned LoweredOpcode)
This file declares the WebAssembly-specific subclass of TargetSubtarget.
const TargetLowering & getTargetLoweringInfo() const
Iterator for intrusive lists based on ilist_node.
CCState - This class holds information needed while lowering arguments and return values...
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
Align max(MaybeAlign Lhs, Align Rhs)
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
EVT getVectorElementType() const
Given a vector type, return the type of each element.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
Provides information about what library functions are available for the current target.
const DebugLoc & getDebugLoc() const
SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
Byte Swap and Counting operators.
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
void ExtractVectorElements(SDValue Op, SmallVectorImpl< SDValue > &Args, unsigned Start=0, unsigned Count=0)
Append the extracted elements from Start to Count out of the vector Op in Args.
Represents one node in the SelectionDAG.
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...
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
static mvt_range integer_valuetypes()
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Calling convention for emscripten __invoke_* functions.
EVT getMemoryVT() const
Return the type of the in-memory value.
Class for arbitrary precision integers.
unsigned getByValAlign() const
SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
amdgpu Simplify well known AMD library false FunctionCallee Callee
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
A "pseudo-class" with methods for operating on BUILD_VECTORs.
Select(COND, TRUEVAL, FALSEVAL).
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
const WebAssemblyRegisterInfo * getRegisterInfo() const override
Flags
Flags values. These may be or'd together.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
BR_JT - Jumptable branch.
Representation of each machine instruction.
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the source.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
bool isVector() const
Return true if this is a vector value type.
bool isFunctionTy() const
True if this is an instance of FunctionType.
Bitwise operators - logical and, logical or, logical xor.
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 '...
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
static bool callingConvSupported(CallingConv::ID CallConv)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
LLVM_NODISCARD bool empty() const
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
bool isInConsecutiveRegsLast() const
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
This file declares WebAssembly-specific per-machine-function information.
void setStackPointerRegisterToSaveRestore(unsigned R)
If set to a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save and restore.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
void setLibcallName(RTLIB::Libcall Call, const char *Name)
Rename the default libcall routine name for the specified libcall.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Type * getValueType() const
static CCValAssign getMem(unsigned ValNo, MVT ValVT, unsigned Offset, MVT LocVT, LocInfo HTP)
unsigned getOpcode() const
FSINCOS - Compute both fsin and fcos as a single operation.
SDValue getValue(unsigned R) const
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, uint64_t Size=0, const AAMDNodes &AAInfo=AAMDNodes())
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void insert(iterator MBBI, MachineBasicBlock *MBB)
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
int CreateStackObject(uint64_t Size, Align 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...
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
void computeLegalValueVTs(const Function &F, const TargetMachine &TM, Type *Ty, SmallVectorImpl< MVT > &ValueVTs)
uint64_t getConstantOperandVal(unsigned Num) const
Helper method returns the integer value of a ConstantSDNode operand.
FMA - Perform a * b + c with no intermediate rounding step.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, ArrayRef< SDValue > Ops, MakeLibCallOptions CallOptions, const SDLoc &dl, SDValue Chain=SDValue()) const
Returns a pair of (return value, chain).
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
bool isUndef() const
Return true if the type of the node type undefined.
Primary interface to the complete machine description for the target machine.
static mvt_range fixedlen_vector_valuetypes()
StringRef - Represent a constant reference to a string, i.e.
SetCC operator - This evaluates to a true value iff the condition is true.
const WebAssemblyInstrInfo * getInstrInfo() const override
unsigned getNumOperands() const
Register getReg() const
getReg - Returns the register number.
const SDValue & getOperand(unsigned i) const
bool verifyReturnAddressArgumentIsConstant(SDValue Op, SelectionDAG &DAG) const
static void fail(const SDLoc &DL, SelectionDAG &DAG, const char *Msg)
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const MachineOperand & getOperand(unsigned i) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
LLVMContext * getContext() const
Wrapper class representing virtual and physical registers.
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
This class is used to represent ISD::LOAD nodes.
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary...