]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / contrib / llvm / lib / Target / NVPTX / NVPTXISelDAGToDAG.h
1 //===-- NVPTXISelDAGToDAG.h - A dag to dag inst selector for NVPTX --------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines an instruction selector for the NVPTX target.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #define DEBUG_TYPE "nvptx-isel"
15
16 #include "NVPTX.h"
17 #include "NVPTXISelLowering.h"
18 #include "NVPTXRegisterInfo.h"
19 #include "NVPTXTargetMachine.h"
20 #include "llvm/CodeGen/SelectionDAGISel.h"
21 #include "llvm/IR/Intrinsics.h"
22 #include "llvm/Support/Compiler.h"
23 using namespace llvm;
24
25 namespace {
26
27 class LLVM_LIBRARY_VISIBILITY NVPTXDAGToDAGISel : public SelectionDAGISel {
28
29   // If true, generate corresponding FPCONTRACT. This is
30   // language dependent (i.e. CUDA and OpenCL works differently).
31   bool doFMADF32;
32   bool doFMAF64;
33   bool doFMAF32;
34   bool doFMAF64AGG;
35   bool doFMAF32AGG;
36   bool allowFMA;
37
38   // 0: use div.approx
39   // 1: use div.full
40   // 2: For sm_20 and later, ieee-compliant div.rnd.f32 can be generated;
41   //    Otherwise, use div.full
42   int do_DIVF32_PREC;
43
44   // If true, generate sqrt.rn, else generate sqrt.approx. If FTZ
45   // is true, then generate the corresponding FTZ version.
46   bool do_SQRTF32_PREC;
47
48   // If true, add .ftz to f32 instructions.
49   // This is only meaningful for sm_20 and later, as the default
50   // is not ftz.
51   // For sm earlier than sm_20, f32 denorms are always ftz by the
52   // hardware.
53   // We always add the .ftz modifier regardless of the sm value
54   // when Use32FTZ is true.
55   bool UseF32FTZ;
56
57   // If true, generate mul.wide from sext and mul
58   bool doMulWide;
59
60 public:
61   explicit NVPTXDAGToDAGISel(NVPTXTargetMachine &tm,
62                              CodeGenOpt::Level OptLevel);
63
64   // Pass Name
65   virtual const char *getPassName() const {
66     return "NVPTX DAG->DAG Pattern Instruction Selection";
67   }
68
69   const NVPTXSubtarget &Subtarget;
70
71   virtual bool SelectInlineAsmMemoryOperand(
72       const SDValue &Op, char ConstraintCode, std::vector<SDValue> &OutOps);
73 private:
74 // Include the pieces autogenerated from the target description.
75 #include "NVPTXGenDAGISel.inc"
76
77   SDNode *Select(SDNode *N);
78   SDNode *SelectLoad(SDNode *N);
79   SDNode *SelectLoadVector(SDNode *N);
80   SDNode *SelectLDGLDUVector(SDNode *N);
81   SDNode *SelectStore(SDNode *N);
82   SDNode *SelectStoreVector(SDNode *N);
83
84   inline SDValue getI32Imm(unsigned Imm) {
85     return CurDAG->getTargetConstant(Imm, MVT::i32);
86   }
87
88   // Match direct address complex pattern.
89   bool SelectDirectAddr(SDValue N, SDValue &Address);
90
91   bool SelectADDRri_imp(SDNode *OpNode, SDValue Addr, SDValue &Base,
92                         SDValue &Offset, MVT mvt);
93   bool SelectADDRri(SDNode *OpNode, SDValue Addr, SDValue &Base,
94                     SDValue &Offset);
95   bool SelectADDRri64(SDNode *OpNode, SDValue Addr, SDValue &Base,
96                       SDValue &Offset);
97
98   bool SelectADDRsi_imp(SDNode *OpNode, SDValue Addr, SDValue &Base,
99                         SDValue &Offset, MVT mvt);
100   bool SelectADDRsi(SDNode *OpNode, SDValue Addr, SDValue &Base,
101                     SDValue &Offset);
102   bool SelectADDRsi64(SDNode *OpNode, SDValue Addr, SDValue &Base,
103                       SDValue &Offset);
104
105   bool ChkMemSDNodeAddressSpace(SDNode *N, unsigned int spN) const;
106
107   bool UndefOrImm(SDValue Op, SDValue N, SDValue &Retval);
108
109 };
110 }