c7cd0d1c1306b2cfd847d3010dfb468acfe2371c
[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) const;
26   SDValue LowerSampleIntrinsic(unsigned Opcode, const SDValue &Op,
27                                SelectionDAG &DAG) const;
28   SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
29   SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
30   SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
31   SDValue LowerSIGN_EXTEND(SDValue Op, SelectionDAG &DAG) const;
32   SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
33   SDValue LowerZERO_EXTEND(SDValue Op, SelectionDAG &DAG) const;
34   SDValue LowerADD(SDValue Op, SelectionDAG &DAG) const;
35   SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
36
37   SDValue ResourceDescriptorToi128(SDValue Op, SelectionDAG &DAG) const;
38   bool foldImm(SDValue &Operand, int32_t &Immediate,
39                bool &ScalarSlotUsed) const;
40   const TargetRegisterClass *getRegClassForNode(SelectionDAG &DAG,
41                                                 const SDValue &Op) const;
42   bool fitsRegClass(SelectionDAG &DAG, const SDValue &Op,
43                     unsigned RegClass) const;
44   void ensureSRegLimit(SelectionDAG &DAG, SDValue &Operand,
45                        unsigned RegClass, bool &ScalarSlotUsed) const;
46
47   SDNode *foldOperands(MachineSDNode *N, SelectionDAG &DAG) const;
48   void adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
49   MachineSDNode *AdjustRegClass(MachineSDNode *N, SelectionDAG &DAG) const;
50
51 public:
52   SITargetLowering(TargetMachine &tm);
53   bool allowsUnalignedMemoryAccesses(EVT VT, unsigned AS, bool *IsFast) const;
54   virtual bool shouldSplitVectorElementType(EVT VT) const;
55
56   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
57                                bool isVarArg,
58                                const SmallVectorImpl<ISD::InputArg> &Ins,
59                                SDLoc DL, SelectionDAG &DAG,
60                                SmallVectorImpl<SDValue> &InVals) const;
61
62   virtual MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr * MI,
63                                               MachineBasicBlock * BB) const;
64   virtual EVT getSetCCResultType(LLVMContext &Context, EVT VT) const;
65   virtual MVT getScalarShiftAmountTy(EVT VT) const;
66   virtual bool isFMAFasterThanFMulAndFAdd(EVT VT) const;
67   virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
68   virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
69   virtual SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const;
70   virtual void AdjustInstrPostInstrSelection(MachineInstr *MI,
71                                              SDNode *Node) const;
72
73   int32_t analyzeImmediate(const SDNode *N) const;
74   SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC,
75                                unsigned Reg, EVT VT) const;
76 };
77
78 } // End namespace llvm
79
80 #endif //SIISELLOWERING_H