blob: bc85a0e6a37ce6eff3c74ca5371af514ee1989d6 [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
Matt Arsenault6b6a2c32016-03-11 08:00:27 +000015#ifndef LLVM_LIB_TARGET_AMDGPU_SIISELLOWERING_H
16#define LLVM_LIB_TARGET_AMDGPU_SIISELLOWERING_H
Tom Stellard75aadc22012-12-11 21:25:42 +000017
18#include "AMDGPUISelLowering.h"
19#include "SIInstrInfo.h"
20
21namespace llvm {
22
Matt Arsenault6b6a2c32016-03-11 08:00:27 +000023class SITargetLowering final : public AMDGPUTargetLowering {
Benjamin Kramerbdc49562016-06-12 15:39:02 +000024 SDValue LowerParameter(SelectionDAG &DAG, EVT VT, EVT MemVT, const SDLoc &DL,
Matt Arsenaulte1f030c2014-04-11 20:59:54 +000025 SDValue Chain, unsigned Offset, bool Signed) const;
Matt Arsenaulta5789bb2014-07-26 06:23:37 +000026
Matt Arsenaultff6da2f2015-11-30 21:15:45 +000027 SDValue lowerImplicitZextParam(SelectionDAG &DAG, SDValue Op,
28 MVT VT, unsigned Offset) const;
29
Matt Arsenaulta5789bb2014-07-26 06:23:37 +000030 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
Matt Arsenaulta9dbdca2016-04-12 14:05:04 +000031 SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
Matt Arsenaulta5789bb2014-07-26 06:23:37 +000032 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 Stellard354a43c2016-04-01 18:27:37 +000043 SDValue LowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
Tom Stellardf8794352012-12-19 22:10:31 +000044 SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
Tom Stellard75aadc22012-12-11 21:25:42 +000045
Matt Arsenault99c14522016-04-25 19:27:24 +000046 SDValue getSegmentAperture(unsigned AS, SelectionDAG &DAG) const;
47 SDValue lowerADDRSPACECAST(SDValue Op, SelectionDAG &DAG) const;
48
Christian Konig8e06e2a2013-04-10 08:39:08 +000049 void adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
50
Matt Arsenaulte6986632015-01-14 01:35:22 +000051 SDValue performUCharToFloatCombine(SDNode *N,
52 DAGCombinerInfo &DCI) const;
Matt Arsenaultb2baffa2014-08-15 17:49:05 +000053 SDValue performSHLPtrCombine(SDNode *N,
54 unsigned AS,
55 DAGCombinerInfo &DCI) const;
Matt Arsenaultd0101a22015-01-06 23:00:46 +000056 SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const;
Matt Arsenaultf2290332015-01-06 23:00:39 +000057 SDValue performOrCombine(SDNode *N, DAGCombinerInfo &DCI) const;
58 SDValue performClassCombine(SDNode *N, DAGCombinerInfo &DCI) const;
Matt Arsenault9cd90712016-04-14 01:42:16 +000059 SDValue performFCanonicalizeCombine(SDNode *N, DAGCombinerInfo &DCI) const;
Matt Arsenault364a6742014-06-11 17:50:44 +000060
Matt Arsenaultf639c322016-01-28 20:53:42 +000061 SDValue performMinMaxCombine(SDNode *N, DAGCombinerInfo &DCI) const;
62
Matt Arsenault6f6233d2015-01-06 23:00:41 +000063 SDValue performSetCCCombine(SDNode *N, DAGCombinerInfo &DCI) const;
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000064
Tom Stellard70580f82015-07-20 14:28:41 +000065 bool isLegalFlatAddressingMode(const AddrMode &AM) const;
Matt Arsenault711b3902015-08-07 20:18:34 +000066 bool isLegalMUBUFAddressingMode(const AddrMode &AM) const;
Tom Stellardbc4497b2016-02-12 23:45:29 +000067
68 bool isCFIntrinsic(const SDNode *Intr) const;
Tom Stellard75aadc22012-12-11 21:25:42 +000069public:
Eric Christopher7792e322015-01-30 23:24:40 +000070 SITargetLowering(TargetMachine &tm, const AMDGPUSubtarget &STI);
Matt Arsenault5015a892014-08-15 17:17:07 +000071
Matt Arsenaulta9dbdca2016-04-12 14:05:04 +000072 bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &,
73 unsigned IntrinsicID) const override;
74
Matt Arsenaulte306a322014-10-21 16:25:08 +000075 bool isShuffleMaskLegal(const SmallVectorImpl<int> &/*Mask*/,
76 EVT /*VT*/) const override;
77
Mehdi Amini0cdec1e2015-07-09 02:09:40 +000078 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
79 unsigned AS) const override;
Matt Arsenault5015a892014-08-15 17:17:07 +000080
Matt Arsenault6f2a5262014-07-27 17:46:40 +000081 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS,
82 unsigned Align,
83 bool *IsFast) const override;
Chandler Carruth9d010ff2014-07-03 00:23:43 +000084
Matt Arsenault46645fa2014-07-28 17:49:26 +000085 EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
86 unsigned SrcAlign, bool IsMemset,
87 bool ZeroMemset,
88 bool MemcpyStrSrc,
89 MachineFunction &MF) const override;
90
Tom Stellarda6f24c62015-12-15 20:55:55 +000091 bool isMemOpUniform(const SDNode *N) const;
Matt Arsenaultf9bfeaf2015-12-01 23:04:00 +000092 bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
93
Chandler Carruth9d010ff2014-07-03 00:23:43 +000094 TargetLoweringBase::LegalizeTypeAction
95 getPreferredVectorAction(EVT VT) const override;
Christian Konig2c8f6d52013-03-07 09:03:52 +000096
Craig Topper5656db42014-04-29 07:57:24 +000097 bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
98 Type *Ty) const override;
Matt Arsenaultd7bdcc42014-03-31 19:54:27 +000099
Tom Stellard2e045bb2016-01-20 00:13:22 +0000100 bool isTypeDesirableForOp(unsigned Op, EVT VT) const override;
101
Christian Konig2c8f6d52013-03-07 09:03:52 +0000102 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
103 bool isVarArg,
104 const SmallVectorImpl<ISD::InputArg> &Ins,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000105 const SDLoc &DL, SelectionDAG &DAG,
Craig Topper5656db42014-04-29 07:57:24 +0000106 SmallVectorImpl<SDValue> &InVals) const override;
Christian Konig2c8f6d52013-03-07 09:03:52 +0000107
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000108 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
Marek Olsak8a0f3352016-01-13 17:23:04 +0000109 const SmallVectorImpl<ISD::OutputArg> &Outs,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000110 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
111 SelectionDAG &DAG) const override;
Marek Olsak8a0f3352016-01-13 17:23:04 +0000112
Matt Arsenault9a10cea2016-01-26 04:29:24 +0000113 unsigned getRegisterByName(const char* RegName, EVT VT,
114 SelectionDAG &DAG) const override;
115
Craig Topper5656db42014-04-29 07:57:24 +0000116 MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr * MI,
117 MachineBasicBlock * BB) const override;
Matt Arsenault423bf3f2015-01-29 19:34:32 +0000118 bool enableAggressiveFMAFusion(EVT VT) const override;
Mehdi Amini44ede332015-07-09 02:09:04 +0000119 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
120 EVT VT) const override;
Mehdi Aminieaabc512015-07-09 15:12:23 +0000121 MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override;
Craig Topper5656db42014-04-29 07:57:24 +0000122 bool isFMAFasterThanFMulAndFAdd(EVT VT) const override;
123 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
124 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
125 SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const override;
126 void AdjustInstrPostInstrSelection(MachineInstr *MI,
127 SDNode *Node) const override;
Christian Konigf82901a2013-02-26 17:52:23 +0000128
129 int32_t analyzeImmediate(const SDNode *N) const;
Tom Stellard94593ee2013-06-03 17:40:18 +0000130 SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC,
Craig Topper5656db42014-04-29 07:57:24 +0000131 unsigned Reg, EVT VT) const override;
Tom Stellard3457a842014-10-09 19:06:00 +0000132 void legalizeTargetIndependentNode(SDNode *Node, SelectionDAG &DAG) const;
Matt Arsenault485defe2014-11-05 19:01:17 +0000133
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000134 MachineSDNode *wrapAddr64Rsrc(SelectionDAG &DAG, const SDLoc &DL,
135 SDValue Ptr) const;
136 MachineSDNode *buildRSRC(SelectionDAG &DAG, const SDLoc &DL, SDValue Ptr,
137 uint32_t RsrcDword1, uint64_t RsrcDword2And3) const;
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000138 std::pair<unsigned, const TargetRegisterClass *>
139 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
140 StringRef Constraint, MVT VT) const override;
Tom Stellardb3c3bda2015-12-10 02:12:53 +0000141 ConstraintType getConstraintType(StringRef Constraint) const override;
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000142 SDValue copyToM0(SelectionDAG &DAG, SDValue Chain, const SDLoc &DL,
143 SDValue V) const;
Tom Stellard75aadc22012-12-11 21:25:42 +0000144};
145
146} // End namespace llvm
147
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000148#endif