blob: d106d4abb18798987b08d46c08c19c2ef5ab3718 [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//===-- 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
21namespace llvm {
22
23class SITargetLowering : public AMDGPUTargetLowering {
Tom Stellardaf775432013-10-23 00:44:32 +000024 SDValue LowerParameter(SelectionDAG &DAG, EVT VT, EVT MemVT, SDLoc DL,
Matt Arsenaulte1f030c2014-04-11 20:59:54 +000025 SDValue Chain, unsigned Offset, bool Signed) const;
Tom Stellard9fa17912013-08-14 23:24:45 +000026 SDValue LowerSampleIntrinsic(unsigned Opcode, const SDValue &Op,
27 SelectionDAG &DAG) const;
Tom Stellard067c8152014-07-21 14:01:14 +000028 SDValue LowerGlobalAddress(AMDGPUMachineFunction *MFI, SDValue Op,
29 SelectionDAG &DAG) const override;
Tom Stellardb02094e2014-07-21 15:45:01 +000030 SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;
Tom Stellard81d871d2013-11-13 23:36:50 +000031 SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
Tom Stellard0ec134f2014-02-04 17:18:40 +000032 SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
Matt Arsenault22ca3f82014-07-15 23:50:10 +000033 SDValue LowerFastFDIV(SDValue Op, SelectionDAG &DAG) const;
Matt Arsenaulte9fa3b82014-07-15 20:18:31 +000034 SDValue LowerFDIV32(SDValue Op, SelectionDAG &DAG) const;
35 SDValue LowerFDIV64(SDValue Op, SelectionDAG &DAG) const;
36 SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const;
Tom Stellard81d871d2013-11-13 23:36:50 +000037 SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
Matt Arsenaultad14ce82014-07-19 18:44:39 +000038 SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const;
Tom Stellardf8794352012-12-19 22:10:31 +000039 SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
Tom Stellard75aadc22012-12-11 21:25:42 +000040
Christian Konigf82901a2013-02-26 17:52:23 +000041 bool foldImm(SDValue &Operand, int32_t &Immediate,
42 bool &ScalarSlotUsed) const;
Tom Stellard4c0ffcc2013-08-06 23:08:18 +000043 const TargetRegisterClass *getRegClassForNode(SelectionDAG &DAG,
44 const SDValue &Op) const;
Tom Stellardb35efba2013-05-20 15:02:01 +000045 bool fitsRegClass(SelectionDAG &DAG, const SDValue &Op,
46 unsigned RegClass) const;
Matt Arsenault758659232013-05-18 00:21:46 +000047 void ensureSRegLimit(SelectionDAG &DAG, SDValue &Operand,
Christian Konigf82901a2013-02-26 17:52:23 +000048 unsigned RegClass, bool &ScalarSlotUsed) const;
49
Christian Konig8e06e2a2013-04-10 08:39:08 +000050 SDNode *foldOperands(MachineSDNode *N, SelectionDAG &DAG) const;
51 void adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
Tom Stellard0518ff82013-06-03 17:39:58 +000052 MachineSDNode *AdjustRegClass(MachineSDNode *N, SelectionDAG &DAG) const;
Christian Konig8e06e2a2013-04-10 08:39:08 +000053
Matt Arsenault364a6742014-06-11 17:50:44 +000054 static SDValue performUCharToFloatCombine(SDNode *N,
55 DAGCombinerInfo &DCI);
56
Tom Stellard75aadc22012-12-11 21:25:42 +000057public:
58 SITargetLowering(TargetMachine &tm);
Craig Topper5656db42014-04-29 07:57:24 +000059 bool allowsUnalignedMemoryAccesses(EVT VT, unsigned AS,
60 bool *IsFast) const override;
Chandler Carruth9d010ff2014-07-03 00:23:43 +000061
62 TargetLoweringBase::LegalizeTypeAction
63 getPreferredVectorAction(EVT VT) const override;
Christian Konig2c8f6d52013-03-07 09:03:52 +000064
Craig Topper5656db42014-04-29 07:57:24 +000065 bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
66 Type *Ty) const override;
Matt Arsenaultd7bdcc42014-03-31 19:54:27 +000067
Christian Konig2c8f6d52013-03-07 09:03:52 +000068 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
69 bool isVarArg,
70 const SmallVectorImpl<ISD::InputArg> &Ins,
Andrew Trickef9de2a2013-05-25 02:42:55 +000071 SDLoc DL, SelectionDAG &DAG,
Craig Topper5656db42014-04-29 07:57:24 +000072 SmallVectorImpl<SDValue> &InVals) const override;
Christian Konig2c8f6d52013-03-07 09:03:52 +000073
Craig Topper5656db42014-04-29 07:57:24 +000074 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;
Christian Konigf82901a2013-02-26 17:52:23 +000084
85 int32_t analyzeImmediate(const SDNode *N) const;
Tom Stellard94593ee2013-06-03 17:40:18 +000086 SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC,
Craig Topper5656db42014-04-29 07:57:24 +000087 unsigned Reg, EVT VT) const override;
Tom Stellard75aadc22012-12-11 21:25:42 +000088};
89
90} // End namespace llvm
91
92#endif //SIISELLOWERING_H