#include "RISCVISelDAGToDAG.h"
#include "MCTargetDesc/RISCVBaseInfo.h"
#include "MCTargetDesc/RISCVMCTargetDesc.h"
#include "MCTargetDesc/RISCVMatInt.h"
#include "RISCVISelLowering.h"
#include "RISCVInstrInfo.h"
#include "RISCVMachineFunctionInfo.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/IR/IntrinsicsRISCV.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
usingnamespacellvm;
#define DEBUG_TYPE …
#define PASS_NAME …
static cl::opt<bool> UsePseudoMovImm(
"riscv-use-rematerializable-movimm", cl::Hidden,
cl::desc("Use a rematerializable pseudoinstruction for 2 instruction "
"constant materialization"),
cl::init(false));
namespace llvm::RISCV {
#define GET_RISCVVSSEGTable_IMPL
#define GET_RISCVVLSEGTable_IMPL
#define GET_RISCVVLXSEGTable_IMPL
#define GET_RISCVVSXSEGTable_IMPL
#define GET_RISCVVLETable_IMPL
#define GET_RISCVVSETable_IMPL
#define GET_RISCVVLXTable_IMPL
#define GET_RISCVVSXTable_IMPL
#include "RISCVGenSearchableTables.inc"
}
void RISCVDAGToDAGISel::PreprocessISelDAG() { … }
void RISCVDAGToDAGISel::PostprocessISelDAG() { … }
static SDValue selectImmSeq(SelectionDAG *CurDAG, const SDLoc &DL, const MVT VT,
RISCVMatInt::InstSeq &Seq) { … }
static SDValue selectImm(SelectionDAG *CurDAG, const SDLoc &DL, const MVT VT,
int64_t Imm, const RISCVSubtarget &Subtarget) { … }
void RISCVDAGToDAGISel::addVectorLoadStoreOperands(
SDNode *Node, unsigned Log2SEW, const SDLoc &DL, unsigned CurOp,
bool IsMasked, bool IsStridedOrIndexed, SmallVectorImpl<SDValue> &Operands,
bool IsLoad, MVT *IndexVT) { … }
void RISCVDAGToDAGISel::selectVLSEG(SDNode *Node, unsigned NF, bool IsMasked,
bool IsStrided) { … }
void RISCVDAGToDAGISel::selectVLSEGFF(SDNode *Node, unsigned NF,
bool IsMasked) { … }
void RISCVDAGToDAGISel::selectVLXSEG(SDNode *Node, unsigned NF, bool IsMasked,
bool IsOrdered) { … }
void RISCVDAGToDAGISel::selectVSSEG(SDNode *Node, unsigned NF, bool IsMasked,
bool IsStrided) { … }
void RISCVDAGToDAGISel::selectVSXSEG(SDNode *Node, unsigned NF, bool IsMasked,
bool IsOrdered) { … }
void RISCVDAGToDAGISel::selectVSETVLI(SDNode *Node) { … }
bool RISCVDAGToDAGISel::tryShrinkShlLogicImm(SDNode *Node) { … }
bool RISCVDAGToDAGISel::trySignedBitfieldExtract(SDNode *Node) { … }
bool RISCVDAGToDAGISel::tryIndexedLoad(SDNode *Node) { … }
void RISCVDAGToDAGISel::selectSF_VC_X_SE(SDNode *Node) { … }
static unsigned getSegInstNF(unsigned Intrinsic) { … }
void RISCVDAGToDAGISel::Select(SDNode *Node) { … }
bool RISCVDAGToDAGISel::SelectInlineAsmMemoryOperand(
const SDValue &Op, InlineAsm::ConstraintCode ConstraintID,
std::vector<SDValue> &OutOps) { … }
bool RISCVDAGToDAGISel::SelectAddrFrameIndex(SDValue Addr, SDValue &Base,
SDValue &Offset) { … }
bool RISCVDAGToDAGISel::SelectFrameAddrRegImm(SDValue Addr, SDValue &Base,
SDValue &Offset) { … }
static bool selectConstantAddr(SelectionDAG *CurDAG, const SDLoc &DL,
const MVT VT, const RISCVSubtarget *Subtarget,
SDValue Addr, SDValue &Base, SDValue &Offset,
bool IsPrefetch = false,
bool IsRV32Zdinx = false) { … }
static bool isWorthFoldingAdd(SDValue Add) { … }
bool RISCVDAGToDAGISel::SelectAddrRegRegScale(SDValue Addr,
unsigned MaxShiftAmount,
SDValue &Base, SDValue &Index,
SDValue &Scale) { … }
bool RISCVDAGToDAGISel::SelectAddrRegImm(SDValue Addr, SDValue &Base,
SDValue &Offset, bool IsRV32Zdinx) { … }
bool RISCVDAGToDAGISel::SelectAddrRegImmLsb00000(SDValue Addr, SDValue &Base,
SDValue &Offset) { … }
bool RISCVDAGToDAGISel::SelectAddrRegReg(SDValue Addr, SDValue &Base,
SDValue &Offset) { … }
bool RISCVDAGToDAGISel::selectShiftMask(SDValue N, unsigned ShiftWidth,
SDValue &ShAmt) { … }
bool RISCVDAGToDAGISel::selectSETCC(SDValue N, ISD::CondCode ExpectedCCVal,
SDValue &Val) { … }
bool RISCVDAGToDAGISel::selectSExtBits(SDValue N, unsigned Bits, SDValue &Val) { … }
bool RISCVDAGToDAGISel::selectZExtBits(SDValue N, unsigned Bits, SDValue &Val) { … }
bool RISCVDAGToDAGISel::selectSHXADDOp(SDValue N, unsigned ShAmt,
SDValue &Val) { … }
bool RISCVDAGToDAGISel::selectSHXADD_UWOp(SDValue N, unsigned ShAmt,
SDValue &Val) { … }
static bool vectorPseudoHasAllNBitUsers(SDNode *User, unsigned UserOpNo,
unsigned Bits,
const TargetInstrInfo *TII) { … }
bool RISCVDAGToDAGISel::hasAllNBitUsers(SDNode *Node, unsigned Bits,
const unsigned Depth) const { … }
bool RISCVDAGToDAGISel::selectSimm5Shl2(SDValue N, SDValue &Simm5,
SDValue &Shl2) { … }
bool RISCVDAGToDAGISel::selectVLOp(SDValue N, SDValue &VL) { … }
static SDValue findVSplat(SDValue N) { … }
bool RISCVDAGToDAGISel::selectVSplat(SDValue N, SDValue &SplatVal) { … }
static bool selectVSplatImmHelper(SDValue N, SDValue &SplatVal,
SelectionDAG &DAG,
const RISCVSubtarget &Subtarget,
std::function<bool(int64_t)> ValidateImm) { … }
bool RISCVDAGToDAGISel::selectVSplatSimm5(SDValue N, SDValue &SplatVal) { … }
bool RISCVDAGToDAGISel::selectVSplatSimm5Plus1(SDValue N, SDValue &SplatVal) { … }
bool RISCVDAGToDAGISel::selectVSplatSimm5Plus1NonZero(SDValue N,
SDValue &SplatVal) { … }
bool RISCVDAGToDAGISel::selectVSplatUimm(SDValue N, unsigned Bits,
SDValue &SplatVal) { … }
bool RISCVDAGToDAGISel::selectLow8BitsVSplat(SDValue N, SDValue &SplatVal) { … }
bool RISCVDAGToDAGISel::selectScalarFPAsInt(SDValue N, SDValue &Imm) { … }
bool RISCVDAGToDAGISel::selectRVVSimm5(SDValue N, unsigned Width,
SDValue &Imm) { … }
bool RISCVDAGToDAGISel::doPeepholeSExtW(SDNode *N) { … }
static SDValue getMaskSetter(SDValue MaskOp, SDValue GlueOp) { … }
static bool usesAllOnesMask(SDValue MaskOp, SDValue GlueOp) { … }
static bool usesAllOnesMask(SDNode *N, unsigned MaskOpIdx) { … }
static bool isImplicitDef(SDValue V) { … }
bool RISCVDAGToDAGISel::doPeepholeMaskedRVV(MachineSDNode *N) { … }
static bool IsVMerge(SDNode *N) { … }
bool RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) { … }
bool RISCVDAGToDAGISel::doPeepholeMergeVVMFold() { … }
bool RISCVDAGToDAGISel::doPeepholeNoRegPassThru() { … }
FunctionPass *llvm::createRISCVISelDag(RISCVTargetMachine &TM,
CodeGenOptLevel OptLevel) { … }
char RISCVDAGToDAGISelLegacy::ID = …;
RISCVDAGToDAGISelLegacy::RISCVDAGToDAGISelLegacy(RISCVTargetMachine &TM,
CodeGenOptLevel OptLevel)
: … { … }
INITIALIZE_PASS(…)