blob: 8b41245a15cb5a0954517cb9a2dae00ff339ffb5 [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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_R600_SIISELLOWERING_H
16#define LLVM_LIB_TARGET_R600_SIISELLOWERING_H
Tom Stellard75aadc22012-12-11 21:25:42 +000017
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;
Matt Arsenaulta5789bb2014-07-26 06:23:37 +000030
31 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
32 SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
Tom Stellardb02094e2014-07-21 15:45:01 +000033 SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;
Tom Stellard81d871d2013-11-13 23:36:50 +000034 SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
Tom Stellard0ec134f2014-02-04 17:18:40 +000035 SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
Matt Arsenault22ca3f82014-07-15 23:50:10 +000036 SDValue LowerFastFDIV(SDValue Op, SelectionDAG &DAG) const;
Matt Arsenaulte9fa3b82014-07-15 20:18:31 +000037 SDValue LowerFDIV32(SDValue Op, SelectionDAG &DAG) const;
38 SDValue LowerFDIV64(SDValue Op, SelectionDAG &DAG) const;
39 SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const;
Matt Arsenaultf7c95e32014-10-03 23:54:41 +000040 SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG, bool Signed) const;
Tom Stellard81d871d2013-11-13 23:36:50 +000041 SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
Matt Arsenaultad14ce82014-07-19 18:44:39 +000042 SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const;
Tom Stellardf8794352012-12-19 22:10:31 +000043 SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
Tom Stellard75aadc22012-12-11 21:25:42 +000044
Christian Konigf82901a2013-02-26 17:52:23 +000045 bool foldImm(SDValue &Operand, int32_t &Immediate,
46 bool &ScalarSlotUsed) const;
Tom Stellard4c0ffcc2013-08-06 23:08:18 +000047 const TargetRegisterClass *getRegClassForNode(SelectionDAG &DAG,
48 const SDValue &Op) const;
Tom Stellardb35efba2013-05-20 15:02:01 +000049 bool fitsRegClass(SelectionDAG &DAG, const SDValue &Op,
50 unsigned RegClass) const;
Christian Konigf82901a2013-02-26 17:52:23 +000051
Matt Arsenault253e5da2014-09-17 15:35:43 +000052 SDNode *legalizeOperands(MachineSDNode *N, SelectionDAG &DAG) const;
Christian Konig8e06e2a2013-04-10 08:39:08 +000053 void adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
Tom Stellard0518ff82013-06-03 17:39:58 +000054 MachineSDNode *AdjustRegClass(MachineSDNode *N, SelectionDAG &DAG) const;
Christian Konig8e06e2a2013-04-10 08:39:08 +000055
Matt Arsenault364a6742014-06-11 17:50:44 +000056 static SDValue performUCharToFloatCombine(SDNode *N,
57 DAGCombinerInfo &DCI);
Matt Arsenaultb2baffa2014-08-15 17:49:05 +000058 SDValue performSHLPtrCombine(SDNode *N,
59 unsigned AS,
60 DAGCombinerInfo &DCI) const;
Matt Arsenaultd0101a22015-01-06 23:00:46 +000061 SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const;
Matt Arsenaultf2290332015-01-06 23:00:39 +000062 SDValue performOrCombine(SDNode *N, DAGCombinerInfo &DCI) const;
63 SDValue performClassCombine(SDNode *N, DAGCombinerInfo &DCI) const;
Matt Arsenault364a6742014-06-11 17:50:44 +000064
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000065 SDValue performMin3Max3Combine(SDNode *N, DAGCombinerInfo &DCI) const;
Matt Arsenault6f6233d2015-01-06 23:00:41 +000066 SDValue performSetCCCombine(SDNode *N, DAGCombinerInfo &DCI) const;
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000067
Tom Stellard75aadc22012-12-11 21:25:42 +000068public:
69 SITargetLowering(TargetMachine &tm);
Matt Arsenault5015a892014-08-15 17:17:07 +000070
Matt Arsenaulte306a322014-10-21 16:25:08 +000071 bool isShuffleMaskLegal(const SmallVectorImpl<int> &/*Mask*/,
72 EVT /*VT*/) const override;
73
Matt Arsenault5015a892014-08-15 17:17:07 +000074 bool isLegalAddressingMode(const AddrMode &AM,
75 Type *Ty) const override;
76
Matt Arsenault6f2a5262014-07-27 17:46:40 +000077 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS,
78 unsigned Align,
79 bool *IsFast) const override;
Chandler Carruth9d010ff2014-07-03 00:23:43 +000080
Matt Arsenault46645fa2014-07-28 17:49:26 +000081 EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
82 unsigned SrcAlign, bool IsMemset,
83 bool ZeroMemset,
84 bool MemcpyStrSrc,
85 MachineFunction &MF) const override;
86
Chandler Carruth9d010ff2014-07-03 00:23:43 +000087 TargetLoweringBase::LegalizeTypeAction
88 getPreferredVectorAction(EVT VT) const override;
Christian Konig2c8f6d52013-03-07 09:03:52 +000089
Craig Topper5656db42014-04-29 07:57:24 +000090 bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
91 Type *Ty) const override;
Matt Arsenaultd7bdcc42014-03-31 19:54:27 +000092
Christian Konig2c8f6d52013-03-07 09:03:52 +000093 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
94 bool isVarArg,
95 const SmallVectorImpl<ISD::InputArg> &Ins,
Andrew Trickef9de2a2013-05-25 02:42:55 +000096 SDLoc DL, SelectionDAG &DAG,
Craig Topper5656db42014-04-29 07:57:24 +000097 SmallVectorImpl<SDValue> &InVals) const override;
Christian Konig2c8f6d52013-03-07 09:03:52 +000098
Craig Topper5656db42014-04-29 07:57:24 +000099 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;
Christian Konigf82901a2013-02-26 17:52:23 +0000109
110 int32_t analyzeImmediate(const SDNode *N) const;
Tom Stellard94593ee2013-06-03 17:40:18 +0000111 SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC,
Craig Topper5656db42014-04-29 07:57:24 +0000112 unsigned Reg, EVT VT) const override;
Tom Stellard3457a842014-10-09 19:06:00 +0000113 void legalizeTargetIndependentNode(SDNode *Node, SelectionDAG &DAG) const;
Matt Arsenault485defe2014-11-05 19:01:17 +0000114
115 MachineSDNode *wrapAddr64Rsrc(SelectionDAG &DAG, SDLoc DL, SDValue Ptr) const;
Matt Arsenaultf3cd4512014-11-05 19:01:19 +0000116 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;
Tom Stellard75aadc22012-12-11 21:25:42 +0000124};
125
126} // End namespace llvm
127
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000128#endif