R600/SI: Use scratch memory for large private arrays
[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 SIISELLOWERING_H
16 #define 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   SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;
31   SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
32   SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
33   SDValue LowerFastFDIV(SDValue Op, SelectionDAG &DAG) const;
34   SDValue LowerFDIV32(SDValue Op, SelectionDAG &DAG) const;
35   SDValue LowerFDIV64(SDValue Op, SelectionDAG &DAG) const;
36   SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const;
37   SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
38   SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const;
39   SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
40
41   bool foldImm(SDValue &Operand, int32_t &Immediate,
42                bool &ScalarSlotUsed) const;
43   const TargetRegisterClass *getRegClassForNode(SelectionDAG &DAG,
44                                                 const SDValue &Op) const;
45   bool fitsRegClass(SelectionDAG &DAG, const SDValue &Op,
46                     unsigned RegClass) const;
47   void ensureSRegLimit(SelectionDAG &DAG, SDValue &Operand,
48                        unsigned RegClass, bool &ScalarSlotUsed) const;
49
50   SDNode *foldOperands(MachineSDNode *N, SelectionDAG &DAG) const;
51   void adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
52   MachineSDNode *AdjustRegClass(MachineSDNode *N, SelectionDAG &DAG) const;
53
54   static SDValue performUCharToFloatCombine(SDNode *N,
55                                             DAGCombinerInfo &DCI);
56
57 public:
58   SITargetLowering(TargetMachine &tm);
59   bool allowsUnalignedMemoryAccesses(EVT VT, unsigned AS,
60                                      bool *IsFast) const override;
61
62   TargetLoweringBase::LegalizeTypeAction
63   getPreferredVectorAction(EVT VT) const override;
64
65   bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
66                                         Type *Ty) const override;
67
68   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
69                                bool isVarArg,
70                                const SmallVectorImpl<ISD::InputArg> &Ins,
71                                SDLoc DL, SelectionDAG &DAG,
72                                SmallVectorImpl<SDValue> &InVals) const override;
73
74   MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr * MI,
75                                       MachineBasicBlock * BB) const override;
76   EVT getSetCCResultType(LLVMContext &Context, EVT VT) const override;
77   MVT getScalarShiftAmountTy(EVT VT) const override;
78   bool isFMAFasterThanFMulAndFAdd(EVT VT) const override;
79   SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
80   SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
81   SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const override;
82   void AdjustInstrPostInstrSelection(MachineInstr *MI,
83                                      SDNode *Node) const override;
84
85   int32_t analyzeImmediate(const SDNode *N) const;
86   SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC,
87                                unsigned Reg, EVT VT) const override;
88 };
89
90 } // End namespace llvm
91
92 #endif //SIISELLOWERING_H