#include "NVPTXISelDAGToDAG.h"
#include "MCTargetDesc/NVPTXBaseInfo.h"
#include "NVPTXUtilities.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicsNVPTX.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetIntrinsicInfo.h"
usingnamespacellvm;
#define DEBUG_TYPE …
#define PASS_NAME …
static cl::opt<bool>
EnableRsqrtOpt("nvptx-rsqrt-approx-opt", cl::init(true), cl::Hidden,
cl::desc("Enable reciprocal sqrt optimization"));
FunctionPass *llvm::createNVPTXISelDag(NVPTXTargetMachine &TM,
llvm::CodeGenOptLevel OptLevel) { … }
NVPTXDAGToDAGISelLegacy::NVPTXDAGToDAGISelLegacy(NVPTXTargetMachine &tm,
CodeGenOptLevel OptLevel)
: … { … }
char NVPTXDAGToDAGISelLegacy::ID = …;
INITIALIZE_PASS(…)
NVPTXDAGToDAGISel::NVPTXDAGToDAGISel(NVPTXTargetMachine &tm,
CodeGenOptLevel OptLevel)
: … { … }
bool NVPTXDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) { … }
int NVPTXDAGToDAGISel::getDivF32Level() const { … }
bool NVPTXDAGToDAGISel::usePrecSqrtF32() const { … }
bool NVPTXDAGToDAGISel::useF32FTZ() const { … }
bool NVPTXDAGToDAGISel::allowFMA() const { … }
bool NVPTXDAGToDAGISel::allowUnsafeFPMath() const { … }
bool NVPTXDAGToDAGISel::doRsqrtOpt() const { … }
void NVPTXDAGToDAGISel::Select(SDNode *N) { … }
bool NVPTXDAGToDAGISel::tryIntrinsicChain(SDNode *N) { … }
bool NVPTXDAGToDAGISel::tryConstantFP(SDNode *N) { … }
static unsigned getPTXCmpMode(const CondCodeSDNode &CondCode, bool FTZ) { … }
bool NVPTXDAGToDAGISel::SelectSETP_F16X2(SDNode *N) { … }
bool NVPTXDAGToDAGISel::SelectSETP_BF16X2(SDNode *N) { … }
bool NVPTXDAGToDAGISel::tryEXTRACT_VECTOR_ELEMENT(SDNode *N) { … }
static unsigned int getCodeAddrSpace(MemSDNode *N) { … }
namespace {
struct OperationOrderings { … };
static OperationOrderings
getOperationOrderings(MemSDNode *N, const NVPTXSubtarget *Subtarget) { … }
}
static bool canLowerToLDG(MemSDNode *N, const NVPTXSubtarget &Subtarget,
unsigned CodeAddrSpace, MachineFunction *F) { … }
NVPTX::Ordering NVPTXDAGToDAGISel::insertMemoryInstructionFence(SDLoc DL,
SDValue &Chain,
MemSDNode *N) { … }
bool NVPTXDAGToDAGISel::tryIntrinsicNoChain(SDNode *N) { … }
void NVPTXDAGToDAGISel::SelectTexSurfHandle(SDNode *N) { … }
void NVPTXDAGToDAGISel::SelectAddrSpaceCast(SDNode *N) { … }
static std::optional<unsigned>
pickOpcodeForVT(MVT::SimpleValueType VT, unsigned Opcode_i8,
unsigned Opcode_i16, unsigned Opcode_i32,
std::optional<unsigned> Opcode_i64, unsigned Opcode_f32,
std::optional<unsigned> Opcode_f64) { … }
static int getLdStRegType(EVT VT) { … }
bool NVPTXDAGToDAGISel::tryLoad(SDNode *N) { … }
bool NVPTXDAGToDAGISel::tryLoadVector(SDNode *N) { … }
bool NVPTXDAGToDAGISel::tryLDGLDU(SDNode *N) { … }
bool NVPTXDAGToDAGISel::tryStore(SDNode *N) { … }
bool NVPTXDAGToDAGISel::tryStoreVector(SDNode *N) { … }
bool NVPTXDAGToDAGISel::tryLoadParam(SDNode *Node) { … }
bool NVPTXDAGToDAGISel::tryStoreRetval(SDNode *N) { … }
#define getOpcV2H(ty, opKind0, opKind1) …
#define getOpcV2H1(ty, opKind0, isImm1) …
#define getOpcodeForVectorStParamV2(ty, isimm) …
#define getOpcV4H(ty, opKind0, opKind1, opKind2, opKind3) …
#define getOpcV4H3(ty, opKind0, opKind1, opKind2, isImm3) …
#define getOpcV4H2(ty, opKind0, opKind1, isImm2, isImm3) …
#define getOpcV4H1(ty, opKind0, isImm1, isImm2, isImm3) …
#define getOpcodeForVectorStParamV4(ty, isimm) …
#define getOpcodeForVectorStParam(n, ty, isimm) …
static unsigned pickOpcodeForVectorStParam(SmallVector<SDValue, 8> &Ops,
unsigned NumElts,
MVT::SimpleValueType MemTy,
SelectionDAG *CurDAG, SDLoc DL) { … }
bool NVPTXDAGToDAGISel::tryStoreParam(SDNode *N) { … }
bool NVPTXDAGToDAGISel::tryTextureIntrinsic(SDNode *N) { … }
bool NVPTXDAGToDAGISel::trySurfaceIntrinsic(SDNode *N) { … }
bool NVPTXDAGToDAGISel::tryBFE(SDNode *N) { … }
bool NVPTXDAGToDAGISel::SelectDirectAddr(SDValue N, SDValue &Address) { … }
bool NVPTXDAGToDAGISel::SelectADDRsi_imp(
SDNode *OpNode, SDValue Addr, SDValue &Base, SDValue &Offset, MVT mvt) { … }
bool NVPTXDAGToDAGISel::SelectADDRsi(SDNode *OpNode, SDValue Addr,
SDValue &Base, SDValue &Offset) { … }
bool NVPTXDAGToDAGISel::SelectADDRsi64(SDNode *OpNode, SDValue Addr,
SDValue &Base, SDValue &Offset) { … }
bool NVPTXDAGToDAGISel::SelectADDRri_imp(
SDNode *OpNode, SDValue Addr, SDValue &Base, SDValue &Offset, MVT mvt) { … }
bool NVPTXDAGToDAGISel::SelectADDRri(SDNode *OpNode, SDValue Addr,
SDValue &Base, SDValue &Offset) { … }
bool NVPTXDAGToDAGISel::SelectADDRri64(SDNode *OpNode, SDValue Addr,
SDValue &Base, SDValue &Offset) { … }
bool NVPTXDAGToDAGISel::ChkMemSDNodeAddressSpace(SDNode *N,
unsigned int spN) const { … }
bool NVPTXDAGToDAGISel::SelectInlineAsmMemoryOperand(
const SDValue &Op, InlineAsm::ConstraintCode ConstraintID,
std::vector<SDValue> &OutOps) { … }
void NVPTXDAGToDAGISel::SelectV2I64toI128(SDNode *N) { … }
void NVPTXDAGToDAGISel::SelectI128toV2I64(SDNode *N) { … }
unsigned NVPTXDAGToDAGISel::GetConvertOpcode(MVT DestTy, MVT SrcTy,
LoadSDNode *LdNode) { … }