R600/SI: Add combine for isinfinite pattern
[oota-llvm.git] / lib / Target / R600 / SIISelLowering.h
1 //===-- SIISelLowering.h - SI DAG Lowering Interface ------------*- C++ -*-===//
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 /// \file
11 /// \brief SI DAG Lowering interface definition
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_LIB_TARGET_R600_SIISELLOWERING_H
16 #define LLVM_LIB_TARGET_R600_SIISELLOWERING_H
17
18 #include "AMDGPUISelLowering.h"
19 #include "SIInstrInfo.h"
20
21 namespace llvm {
22
23 class SITargetLowering : public AMDGPUTargetLowering {
24   SDValue LowerParameter(SelectionDAG &DAG, EVT VT, EVT MemVT, SDLoc DL,
25                          SDValue Chain, unsigned Offset, bool Signed) const;
26   SDValue LowerSampleIntrinsic(unsigned Opcode, const SDValue &Op,
27                                SelectionDAG &DAG) const;
28   SDValue LowerGlobalAddress(AMDGPUMachineFunction *MFI, SDValue Op,
29                              SelectionDAG &DAG) const override;
30
31   SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
32   SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
33   SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;
34   SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
35   SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
36   SDValue LowerFastFDIV(SDValue Op, SelectionDAG &DAG) const;
37   SDValue LowerFDIV32(SDValue Op, SelectionDAG &DAG) const;
38   SDValue LowerFDIV64(SDValue Op, SelectionDAG &DAG) const;
39   SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const;
40   SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG, bool Signed) const;
41   SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
42   SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const;
43   SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
44
45   bool foldImm(SDValue &Operand, int32_t &Immediate,
46                bool &ScalarSlotUsed) const;
47   const TargetRegisterClass *getRegClassForNode(SelectionDAG &DAG,
48                                                 const SDValue &Op) const;
49   bool fitsRegClass(SelectionDAG &DAG, const SDValue &Op,
50                     unsigned RegClass) const;
51
52   SDNode *legalizeOperands(MachineSDNode *N, SelectionDAG &DAG) const;
53   void adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
54   MachineSDNode *AdjustRegClass(MachineSDNode *N, SelectionDAG &DAG) const;
55
56   static SDValue performUCharToFloatCombine(SDNode *N,
57                                             DAGCombinerInfo &DCI);
58   SDValue performSHLPtrCombine(SDNode *N,
59                                unsigned AS,
60                                DAGCombinerInfo &DCI) const;
61   SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const;
62   SDValue performOrCombine(SDNode *N, DAGCombinerInfo &DCI) const;
63   SDValue performClassCombine(SDNode *N, DAGCombinerInfo &DCI) const;
64
65   SDValue performMin3Max3Combine(SDNode *N, DAGCombinerInfo &DCI) const;
66   SDValue performSetCCCombine(SDNode *N, DAGCombinerInfo &DCI) const;
67
68 public:
69   SITargetLowering(TargetMachine &tm);
70
71   bool isShuffleMaskLegal(const SmallVectorImpl<int> &/*Mask*/,
72                           EVT /*VT*/) const override;
73
74   bool isLegalAddressingMode(const AddrMode &AM,
75                              Type *Ty) const override;
76
77   bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS,
78                                       unsigned Align,
79                                       bool *IsFast) const override;
80
81   EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
82                           unsigned SrcAlign, bool IsMemset,
83                           bool ZeroMemset,
84                           bool MemcpyStrSrc,
85                           MachineFunction &MF) const override;
86
87   TargetLoweringBase::LegalizeTypeAction
88   getPreferredVectorAction(EVT VT) const override;
89
90   bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
91                                         Type *Ty) const override;
92
93   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
94                                bool isVarArg,
95                                const SmallVectorImpl<ISD::InputArg> &Ins,
96                                SDLoc DL, SelectionDAG &DAG,
97                                SmallVectorImpl<SDValue> &InVals) const override;
98
99   MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr * MI,
100                                       MachineBasicBlock * BB) const override;
101   EVT getSetCCResultType(LLVMContext &Context, EVT VT) const override;
102   MVT getScalarShiftAmountTy(EVT VT) const override;
103   bool isFMAFasterThanFMulAndFAdd(EVT VT) const override;
104   SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
105   SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
106   SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const override;
107   void AdjustInstrPostInstrSelection(MachineInstr *MI,
108                                      SDNode *Node) const override;
109
110   int32_t analyzeImmediate(const SDNode *N) const;
111   SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC,
112                                unsigned Reg, EVT VT) const override;
113   void legalizeTargetIndependentNode(SDNode *Node, SelectionDAG &DAG) const;
114
115   MachineSDNode *wrapAddr64Rsrc(SelectionDAG &DAG, SDLoc DL, SDValue Ptr) const;
116   MachineSDNode *buildRSRC(SelectionDAG &DAG,
117                            SDLoc DL,
118                            SDValue Ptr,
119                            uint32_t RsrcDword1,
120                            uint64_t RsrcDword2And3) const;
121   MachineSDNode *buildScratchRSRC(SelectionDAG &DAG,
122                                   SDLoc DL,
123                                   SDValue Ptr) const;
124 };
125
126 } // End namespace llvm
127
128 #endif