2012-05-05 04:18:50 +08:00
|
|
|
//===-- NVPTXISelDAGToDAG.h - A dag to dag inst selector for NVPTX --------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines an instruction selector for the NVPTX target.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXISELDAGTODAG_H
|
|
|
|
#define LLVM_LIB_TARGET_NVPTX_NVPTXISELDAGTODAG_H
|
|
|
|
|
2012-05-05 04:18:50 +08:00
|
|
|
#include "NVPTX.h"
|
|
|
|
#include "NVPTXISelLowering.h"
|
|
|
|
#include "NVPTXRegisterInfo.h"
|
|
|
|
#include "NVPTXTargetMachine.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAGISel.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/Intrinsics.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2012-05-05 04:18:50 +08:00
|
|
|
|
2016-01-28 03:29:42 +08:00
|
|
|
namespace llvm {
|
2012-05-05 04:18:50 +08:00
|
|
|
|
|
|
|
class LLVM_LIBRARY_VISIBILITY NVPTXDAGToDAGISel : public SelectionDAGISel {
|
2015-02-19 08:08:27 +08:00
|
|
|
const NVPTXTargetMachine &TM;
|
2012-05-05 04:18:50 +08:00
|
|
|
|
|
|
|
// If true, generate mul.wide from sext and mul
|
|
|
|
bool doMulWide;
|
|
|
|
|
2013-07-22 20:18:04 +08:00
|
|
|
int getDivF32Level() const;
|
|
|
|
bool usePrecSqrtF32() const;
|
|
|
|
bool useF32FTZ() const;
|
2014-07-18 02:10:09 +08:00
|
|
|
bool allowFMA() const;
|
2017-01-14 02:48:13 +08:00
|
|
|
bool allowUnsafeFPMath() const;
|
2018-05-10 07:46:19 +08:00
|
|
|
bool useShortPointers() const;
|
2013-07-22 20:18:04 +08:00
|
|
|
|
2012-05-05 04:18:50 +08:00
|
|
|
public:
|
|
|
|
explicit NVPTXDAGToDAGISel(NVPTXTargetMachine &tm,
|
2013-07-22 20:18:04 +08:00
|
|
|
CodeGenOpt::Level OptLevel);
|
2012-05-05 04:18:50 +08:00
|
|
|
|
|
|
|
// Pass Name
|
2016-10-01 10:56:57 +08:00
|
|
|
StringRef getPassName() const override {
|
2012-05-05 04:18:50 +08:00
|
|
|
return "NVPTX DAG->DAG Pattern Instruction Selection";
|
|
|
|
}
|
2015-01-30 09:40:59 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
|
|
|
const NVPTXSubtarget *Subtarget;
|
2012-05-05 04:18:50 +08:00
|
|
|
|
2014-04-29 15:57:44 +08:00
|
|
|
bool SelectInlineAsmMemoryOperand(const SDValue &Op,
|
2015-03-13 20:45:09 +08:00
|
|
|
unsigned ConstraintID,
|
2014-04-29 15:57:44 +08:00
|
|
|
std::vector<SDValue> &OutOps) override;
|
2012-05-05 04:18:50 +08:00
|
|
|
private:
|
2013-03-30 22:29:21 +08:00
|
|
|
// Include the pieces autogenerated from the target description.
|
2012-05-05 04:18:50 +08:00
|
|
|
#include "NVPTXGenDAGISel.inc"
|
|
|
|
|
2016-05-14 05:12:53 +08:00
|
|
|
void Select(SDNode *N) override;
|
|
|
|
bool tryIntrinsicNoChain(SDNode *N);
|
|
|
|
bool tryIntrinsicChain(SDNode *N);
|
|
|
|
void SelectTexSurfHandle(SDNode *N);
|
|
|
|
bool tryLoad(SDNode *N);
|
|
|
|
bool tryLoadVector(SDNode *N);
|
|
|
|
bool tryLDGLDU(SDNode *N);
|
|
|
|
bool tryStore(SDNode *N);
|
|
|
|
bool tryStoreVector(SDNode *N);
|
|
|
|
bool tryLoadParam(SDNode *N);
|
|
|
|
bool tryStoreRetval(SDNode *N);
|
|
|
|
bool tryStoreParam(SDNode *N);
|
|
|
|
void SelectAddrSpaceCast(SDNode *N);
|
|
|
|
bool tryTextureIntrinsic(SDNode *N);
|
|
|
|
bool trySurfaceIntrinsic(SDNode *N);
|
|
|
|
bool tryBFE(SDNode *N);
|
2017-01-14 04:56:17 +08:00
|
|
|
bool tryConstantFP16(SDNode *N);
|
2017-02-24 06:38:24 +08:00
|
|
|
bool SelectSETP_F16X2(SDNode *N);
|
|
|
|
bool tryEXTRACT_VECTOR_ELEMENT(SDNode *N);
|
2016-05-06 07:19:08 +08:00
|
|
|
|
2016-06-12 23:39:02 +08:00
|
|
|
inline SDValue getI32Imm(unsigned Imm, const SDLoc &DL) {
|
2015-04-28 22:05:47 +08:00
|
|
|
return CurDAG->getTargetConstant(Imm, DL, MVT::i32);
|
2012-05-05 04:18:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Match direct address complex pattern.
|
|
|
|
bool SelectDirectAddr(SDValue N, SDValue &Address);
|
|
|
|
|
|
|
|
bool SelectADDRri_imp(SDNode *OpNode, SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset, MVT mvt);
|
|
|
|
bool SelectADDRri(SDNode *OpNode, SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset);
|
|
|
|
bool SelectADDRri64(SDNode *OpNode, SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset);
|
|
|
|
bool SelectADDRsi_imp(SDNode *OpNode, SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset, MVT mvt);
|
|
|
|
bool SelectADDRsi(SDNode *OpNode, SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset);
|
|
|
|
bool SelectADDRsi64(SDNode *OpNode, SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset);
|
|
|
|
|
|
|
|
bool ChkMemSDNodeAddressSpace(SDNode *N, unsigned int spN) const;
|
|
|
|
|
2016-05-03 02:12:02 +08:00
|
|
|
static unsigned GetConvertOpcode(MVT DestTy, MVT SrcTy, bool IsSigned);
|
2012-05-05 04:18:50 +08:00
|
|
|
};
|
2016-01-28 03:29:42 +08:00
|
|
|
} // end namespace llvm
|
2014-08-14 00:26:38 +08:00
|
|
|
|
|
|
|
#endif
|