blob: 0584d39682421b501a79748f9fb61db5462d747d [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//===-- AMDGPUISelLowering.h - AMDGPU 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 Interface definition of the TargetLowering class that is common
12/// to all AMD GPUs.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef AMDGPUISELLOWERING_H
17#define AMDGPUISELLOWERING_H
18
19#include "llvm/Target/TargetLowering.h"
20
21namespace llvm {
22
23class MachineRegisterInfo;
24
25class AMDGPUTargetLowering : public TargetLowering {
26private:
27 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
28 SDValue LowerUDIVREM(SDValue Op, SelectionDAG &DAG) const;
29
30protected:
31
32 /// \brief Helper function that adds Reg to the LiveIn list of the DAG's
33 /// MachineFunction.
34 ///
35 /// \returns a RegisterSDNode representing Reg.
36 SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC,
37 unsigned Reg, EVT VT) const;
38
39 bool isHWTrueValue(SDValue Op) const;
40 bool isHWFalseValue(SDValue Op) const;
41
42public:
43 AMDGPUTargetLowering(TargetMachine &TM);
44
45 virtual SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
46 bool isVarArg,
47 const SmallVectorImpl<ISD::InputArg> &Ins,
48 DebugLoc DL, SelectionDAG &DAG,
49 SmallVectorImpl<SDValue> &InVals) const;
50
51 virtual SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv,
52 bool isVarArg,
53 const SmallVectorImpl<ISD::OutputArg> &Outs,
54 const SmallVectorImpl<SDValue> &OutVals,
55 DebugLoc DL, SelectionDAG &DAG) const;
56
57 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
58 SDValue LowerIntrinsicIABS(SDValue Op, SelectionDAG &DAG) const;
59 SDValue LowerIntrinsicLRP(SDValue Op, SelectionDAG &DAG) const;
60 SDValue LowerMinMax(SDValue Op, SelectionDAG &DAG) const;
61 virtual const char* getTargetNodeName(unsigned Opcode) const;
62
63// Functions defined in AMDILISelLowering.cpp
64public:
65
66 /// \brief Determine which of the bits specified in \p Mask are known to be
67 /// either zero or one and return them in the \p KnownZero and \p KnownOne
68 /// bitsets.
69 virtual void computeMaskedBitsForTargetNode(const SDValue Op,
70 APInt &KnownZero,
71 APInt &KnownOne,
72 const SelectionDAG &DAG,
73 unsigned Depth = 0) const;
74
75 virtual bool getTgtMemIntrinsic(IntrinsicInfo &Info,
76 const CallInst &I, unsigned Intrinsic) const;
77
78 /// We want to mark f32/f64 floating point values as legal.
79 bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
80
81 /// We don't want to shrink f64/f32 constants.
82 bool ShouldShrinkFPConstant(EVT VT) const;
83
84private:
85 void InitAMDILLowering();
86 SDValue LowerSREM(SDValue Op, SelectionDAG &DAG) const;
87 SDValue LowerSREM8(SDValue Op, SelectionDAG &DAG) const;
88 SDValue LowerSREM16(SDValue Op, SelectionDAG &DAG) const;
89 SDValue LowerSREM32(SDValue Op, SelectionDAG &DAG) const;
90 SDValue LowerSREM64(SDValue Op, SelectionDAG &DAG) const;
91 SDValue LowerSDIV(SDValue Op, SelectionDAG &DAG) const;
92 SDValue LowerSDIV24(SDValue Op, SelectionDAG &DAG) const;
93 SDValue LowerSDIV32(SDValue Op, SelectionDAG &DAG) const;
94 SDValue LowerSDIV64(SDValue Op, SelectionDAG &DAG) const;
95 SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const;
96 EVT genIntType(uint32_t size = 32, uint32_t numEle = 1) const;
97 SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
98 SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
99};
100
101namespace AMDGPUISD {
102
103enum {
104 // AMDIL ISD Opcodes
105 FIRST_NUMBER = ISD::BUILTIN_OP_END,
106 MAD, // 32bit Fused Multiply Add instruction
107 CALL, // Function call based on a single integer
108 UMUL, // 32bit unsigned multiplication
109 DIV_INF, // Divide with infinity returned on zero divisor
110 RET_FLAG,
111 BRANCH_COND,
112 // End AMDIL ISD Opcodes
113 BITALIGN,
114 DWORDADDR,
115 FRACT,
116 FMAX,
117 SMAX,
118 UMAX,
119 FMIN,
120 SMIN,
121 UMIN,
122 URECIP,
Tom Stellard75aadc22012-12-11 21:25:42 +0000123 EXPORT,
Tom Stellardff62c352013-01-23 02:09:03 +0000124 CONST_ADDRESS,
Tom Stellard75aadc22012-12-11 21:25:42 +0000125 LAST_AMDGPU_ISD_NUMBER
126};
127
128
129} // End namespace AMDGPUISD
130
131namespace SIISD {
132
133enum {
134 SI_FIRST = AMDGPUISD::LAST_AMDGPU_ISD_NUMBER,
135 VCC_AND,
136 VCC_BITCAST
137};
138
139} // End namespace SIISD
140
141} // End namespace llvm
142
143#endif // AMDGPUISELLOWERING_H