blob: 5459ddfc7ef8f2393f90c16c96b88772e6fb828f [file] [log] [blame]
Eugene Zelenkod96089b2017-02-14 00:33:36 +00001//===- AMDGPUBaseInfo.h - Top level definitions for AMDGPU ------*- C++ -*-===//
Tom Stellard347ac792015-06-26 21:15:07 +00002//
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#ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
11#define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
12
Yaxun Liu1a14bfa2017-03-27 14:04:01 +000013#include "AMDGPU.h"
Tom Stellard347ac792015-06-26 21:15:07 +000014#include "AMDKernelCodeT.h"
Matt Arsenault4bd72362016-12-10 00:39:12 +000015#include "SIDefines.h"
Eugene Zelenkod96089b2017-02-14 00:33:36 +000016#include "llvm/ADT/StringRef.h"
17#include "llvm/IR/CallingConv.h"
18#include "llvm/MC/MCInstrDesc.h"
19#include "llvm/Support/Compiler.h"
20#include "llvm/Support/ErrorHandling.h"
21#include <cstdint>
Konstantin Zhuravlyov9c05b2b2017-10-14 15:40:33 +000022#include <string>
Eugene Zelenkod96089b2017-02-14 00:33:36 +000023#include <utility>
Matt Arsenault4bd72362016-12-10 00:39:12 +000024
Tom Stellard347ac792015-06-26 21:15:07 +000025namespace llvm {
26
Matt Arsenault894e53d2017-07-26 20:39:42 +000027class Argument;
Tom Stellard347ac792015-06-26 21:15:07 +000028class FeatureBitset;
Tom Stellardac00eb52015-12-15 16:26:16 +000029class Function;
Tom Stellarde3b5aea2015-12-02 17:00:42 +000030class GlobalValue;
Tom Stellard08efb7e2017-01-27 18:41:14 +000031class MachineMemOperand;
Tom Stellarde135ffd2015-09-25 21:41:28 +000032class MCContext;
Krzysztof Parzyszekc8715502016-10-19 17:40:36 +000033class MCRegisterClass;
Sam Kolton1eeb11b2016-09-09 14:44:04 +000034class MCRegisterInfo;
Tom Stellarde135ffd2015-09-25 21:41:28 +000035class MCSection;
Tom Stellard2b65ed32015-12-21 18:44:27 +000036class MCSubtargetInfo;
Eugene Zelenkod96089b2017-02-14 00:33:36 +000037class Triple;
Tom Stellard347ac792015-06-26 21:15:07 +000038
39namespace AMDGPU {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +000040namespace IsaInfo {
Sam Koltona3ec5c12016-10-07 14:46:06 +000041
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +000042enum {
43 // The closed Vulkan driver sets 96, which limits the wave count to 8 but
44 // doesn't spill SGPRs as much as when 80 is set.
45 FIXED_NUM_SGPRS_FOR_INIT_BUG = 96
46};
47
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000048/// Instruction set architecture version.
Tom Stellard347ac792015-06-26 21:15:07 +000049struct IsaVersion {
50 unsigned Major;
51 unsigned Minor;
52 unsigned Stepping;
53};
54
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +000055/// \returns Isa version for given subtarget \p Features.
Tom Stellard347ac792015-06-26 21:15:07 +000056IsaVersion getIsaVersion(const FeatureBitset &Features);
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +000057
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000058/// Streams isa version string for given subtarget \p STI into \p Stream.
Konstantin Zhuravlyov9c05b2b2017-10-14 15:40:33 +000059void streamIsaVersion(const MCSubtargetInfo *STI, raw_ostream &Stream);
60
Konstantin Zhuravlyoveda425e2017-10-14 15:59:07 +000061/// \returns True if given subtarget \p Features support code object version 3,
62/// false otherwise.
63bool hasCodeObjectV3(const FeatureBitset &Features);
64
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +000065/// \returns Wavefront size for given subtarget \p Features.
66unsigned getWavefrontSize(const FeatureBitset &Features);
67
68/// \returns Local memory size in bytes for given subtarget \p Features.
69unsigned getLocalMemorySize(const FeatureBitset &Features);
70
71/// \returns Number of execution units per compute unit for given subtarget \p
72/// Features.
73unsigned getEUsPerCU(const FeatureBitset &Features);
74
75/// \returns Maximum number of work groups per compute unit for given subtarget
76/// \p Features and limited by given \p FlatWorkGroupSize.
77unsigned getMaxWorkGroupsPerCU(const FeatureBitset &Features,
78 unsigned FlatWorkGroupSize);
79
80/// \returns Maximum number of waves per compute unit for given subtarget \p
81/// Features without any kind of limitation.
82unsigned getMaxWavesPerCU(const FeatureBitset &Features);
83
84/// \returns Maximum number of waves per compute unit for given subtarget \p
85/// Features and limited by given \p FlatWorkGroupSize.
86unsigned getMaxWavesPerCU(const FeatureBitset &Features,
87 unsigned FlatWorkGroupSize);
88
89/// \returns Minimum number of waves per execution unit for given subtarget \p
90/// Features.
91unsigned getMinWavesPerEU(const FeatureBitset &Features);
92
93/// \returns Maximum number of waves per execution unit for given subtarget \p
94/// Features without any kind of limitation.
95unsigned getMaxWavesPerEU(const FeatureBitset &Features);
96
97/// \returns Maximum number of waves per execution unit for given subtarget \p
98/// Features and limited by given \p FlatWorkGroupSize.
99unsigned getMaxWavesPerEU(const FeatureBitset &Features,
100 unsigned FlatWorkGroupSize);
101
102/// \returns Minimum flat work group size for given subtarget \p Features.
103unsigned getMinFlatWorkGroupSize(const FeatureBitset &Features);
104
105/// \returns Maximum flat work group size for given subtarget \p Features.
106unsigned getMaxFlatWorkGroupSize(const FeatureBitset &Features);
107
108/// \returns Number of waves per work group for given subtarget \p Features and
109/// limited by given \p FlatWorkGroupSize.
110unsigned getWavesPerWorkGroup(const FeatureBitset &Features,
111 unsigned FlatWorkGroupSize);
112
113/// \returns SGPR allocation granularity for given subtarget \p Features.
114unsigned getSGPRAllocGranule(const FeatureBitset &Features);
115
116/// \returns SGPR encoding granularity for given subtarget \p Features.
117unsigned getSGPREncodingGranule(const FeatureBitset &Features);
118
119/// \returns Total number of SGPRs for given subtarget \p Features.
120unsigned getTotalNumSGPRs(const FeatureBitset &Features);
121
122/// \returns Addressable number of SGPRs for given subtarget \p Features.
123unsigned getAddressableNumSGPRs(const FeatureBitset &Features);
124
125/// \returns Minimum number of SGPRs that meets the given number of waves per
126/// execution unit requirement for given subtarget \p Features.
127unsigned getMinNumSGPRs(const FeatureBitset &Features, unsigned WavesPerEU);
128
129/// \returns Maximum number of SGPRs that meets the given number of waves per
130/// execution unit requirement for given subtarget \p Features.
131unsigned getMaxNumSGPRs(const FeatureBitset &Features, unsigned WavesPerEU,
132 bool Addressable);
133
134/// \returns VGPR allocation granularity for given subtarget \p Features.
135unsigned getVGPRAllocGranule(const FeatureBitset &Features);
136
137/// \returns VGPR encoding granularity for given subtarget \p Features.
138unsigned getVGPREncodingGranule(const FeatureBitset &Features);
139
140/// \returns Total number of VGPRs for given subtarget \p Features.
141unsigned getTotalNumVGPRs(const FeatureBitset &Features);
142
143/// \returns Addressable number of VGPRs for given subtarget \p Features.
144unsigned getAddressableNumVGPRs(const FeatureBitset &Features);
145
146/// \returns Minimum number of VGPRs that meets given number of waves per
147/// execution unit requirement for given subtarget \p Features.
148unsigned getMinNumVGPRs(const FeatureBitset &Features, unsigned WavesPerEU);
149
150/// \returns Maximum number of VGPRs that meets given number of waves per
151/// execution unit requirement for given subtarget \p Features.
152unsigned getMaxNumVGPRs(const FeatureBitset &Features, unsigned WavesPerEU);
153
Eugene Zelenkod96089b2017-02-14 00:33:36 +0000154} // end namespace IsaInfo
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000155
156LLVM_READONLY
157int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx);
158
Matt Arsenaultcad7fa82017-12-13 21:07:51 +0000159LLVM_READONLY
160int getMaskedMIMGOp(const MCInstrInfo &MII,
161 unsigned Opc, unsigned NewChannels);
Dmitry Preobrazhensky0b4eb1e2018-01-26 15:43:29 +0000162
163LLVM_READONLY
164int getMaskedMIMGAtomicOp(const MCInstrInfo &MII,
165 unsigned Opc, unsigned NewChannels);
166
Matt Arsenaultcad7fa82017-12-13 21:07:51 +0000167LLVM_READONLY
168int getMCOpcode(uint16_t Opcode, unsigned Gen);
169
Tom Stellardff7416b2015-06-26 21:58:31 +0000170void initDefaultAMDKernelCodeT(amd_kernel_code_t &Header,
171 const FeatureBitset &Features);
Tom Stellard9760f032015-12-03 03:34:32 +0000172
Konstantin Zhuravlyov435151a2017-11-01 19:12:38 +0000173bool isGroupSegment(const GlobalValue *GV);
174bool isGlobalSegment(const GlobalValue *GV);
175bool isReadOnlySegment(const GlobalValue *GV);
Tom Stellarde3b5aea2015-12-02 17:00:42 +0000176
Konstantin Zhuravlyov08326b62016-10-20 18:12:38 +0000177/// \returns True if constants should be emitted to .text section for given
178/// target triple \p TT, false otherwise.
179bool shouldEmitConstantsToTextSection(const Triple &TT);
180
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000181/// \returns Integer value requested using \p F's \p Name attribute.
182///
183/// \returns \p Default if attribute is not present.
184///
185/// \returns \p Default and emits error if requested value cannot be converted
186/// to integer.
Matt Arsenault83002722016-05-12 02:45:18 +0000187int getIntegerAttribute(const Function &F, StringRef Name, int Default);
188
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000189/// \returns A pair of integer values requested using \p F's \p Name attribute
190/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
191/// is false).
192///
193/// \returns \p Default if attribute is not present.
194///
195/// \returns \p Default and emits error if one of the requested values cannot be
196/// converted to integer, or \p OnlyFirstRequired is false and "second" value is
197/// not present.
198std::pair<int, int> getIntegerPairAttribute(const Function &F,
199 StringRef Name,
200 std::pair<int, int> Default,
201 bool OnlyFirstRequired = false);
202
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000203/// \returns Vmcnt bit mask for given isa \p Version.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000204unsigned getVmcntBitMask(const IsaInfo::IsaVersion &Version);
Konstantin Zhuravlyov836cbff2016-09-30 17:01:40 +0000205
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000206/// \returns Expcnt bit mask for given isa \p Version.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000207unsigned getExpcntBitMask(const IsaInfo::IsaVersion &Version);
Konstantin Zhuravlyov836cbff2016-09-30 17:01:40 +0000208
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000209/// \returns Lgkmcnt bit mask for given isa \p Version.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000210unsigned getLgkmcntBitMask(const IsaInfo::IsaVersion &Version);
211
212/// \returns Waitcnt bit mask for given isa \p Version.
213unsigned getWaitcntBitMask(const IsaInfo::IsaVersion &Version);
Konstantin Zhuravlyov836cbff2016-09-30 17:01:40 +0000214
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000215/// \returns Decoded Vmcnt from given \p Waitcnt for given isa \p Version.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000216unsigned decodeVmcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt);
Konstantin Zhuravlyov836cbff2016-09-30 17:01:40 +0000217
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000218/// \returns Decoded Expcnt from given \p Waitcnt for given isa \p Version.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000219unsigned decodeExpcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt);
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000220
221/// \returns Decoded Lgkmcnt from given \p Waitcnt for given isa \p Version.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000222unsigned decodeLgkmcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt);
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000223
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000224/// Decodes Vmcnt, Expcnt and Lgkmcnt from given \p Waitcnt for given isa
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000225/// \p Version, and writes decoded values into \p Vmcnt, \p Expcnt and
226/// \p Lgkmcnt respectively.
227///
228/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are decoded as follows:
Matt Arsenaulte823d922017-02-18 18:29:53 +0000229/// \p Vmcnt = \p Waitcnt[3:0] (pre-gfx9 only)
230/// \p Vmcnt = \p Waitcnt[3:0] | \p Waitcnt[15:14] (gfx9+ only)
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000231/// \p Expcnt = \p Waitcnt[6:4]
232/// \p Lgkmcnt = \p Waitcnt[11:8]
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000233void decodeWaitcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt,
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000234 unsigned &Vmcnt, unsigned &Expcnt, unsigned &Lgkmcnt);
235
236/// \returns \p Waitcnt with encoded \p Vmcnt for given isa \p Version.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000237unsigned encodeVmcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt,
238 unsigned Vmcnt);
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000239
240/// \returns \p Waitcnt with encoded \p Expcnt for given isa \p Version.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000241unsigned encodeExpcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt,
242 unsigned Expcnt);
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000243
244/// \returns \p Waitcnt with encoded \p Lgkmcnt for given isa \p Version.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000245unsigned encodeLgkmcnt(const IsaInfo::IsaVersion &Version, unsigned Waitcnt,
246 unsigned Lgkmcnt);
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000247
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000248/// Encodes \p Vmcnt, \p Expcnt and \p Lgkmcnt into Waitcnt for given isa
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000249/// \p Version.
250///
251/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are encoded as follows:
Matt Arsenaulte823d922017-02-18 18:29:53 +0000252/// Waitcnt[3:0] = \p Vmcnt (pre-gfx9 only)
253/// Waitcnt[3:0] = \p Vmcnt[3:0] (gfx9+ only)
254/// Waitcnt[6:4] = \p Expcnt
255/// Waitcnt[11:8] = \p Lgkmcnt
256/// Waitcnt[15:14] = \p Vmcnt[5:4] (gfx9+ only)
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000257///
258/// \returns Waitcnt with encoded \p Vmcnt, \p Expcnt and \p Lgkmcnt for given
259/// isa \p Version.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000260unsigned encodeWaitcnt(const IsaInfo::IsaVersion &Version,
Konstantin Zhuravlyovcdd45472016-10-11 18:58:22 +0000261 unsigned Vmcnt, unsigned Expcnt, unsigned Lgkmcnt);
Konstantin Zhuravlyov836cbff2016-09-30 17:01:40 +0000262
Marek Olsakfccabaf2016-01-13 11:45:36 +0000263unsigned getInitialPSInputAddr(const Function &F);
264
Matt Arsenaulte622dc32017-04-11 22:29:24 +0000265LLVM_READNONE
266bool isShader(CallingConv::ID CC);
267
268LLVM_READNONE
269bool isCompute(CallingConv::ID CC);
270
271LLVM_READNONE
272bool isEntryFunctionCC(CallingConv::ID CC);
273
Matt Arsenaultefa9f4b2017-04-11 22:29:28 +0000274// FIXME: Remove this when calling conventions cleaned up
275LLVM_READNONE
276inline bool isKernel(CallingConv::ID CC) {
277 switch (CC) {
Matt Arsenaultefa9f4b2017-04-11 22:29:28 +0000278 case CallingConv::AMDGPU_KERNEL:
279 case CallingConv::SPIR_KERNEL:
280 return true;
281 default:
282 return false;
283 }
284}
Tom Stellardac00eb52015-12-15 16:26:16 +0000285
Dmitry Preobrazhensky3afbd822018-01-10 14:22:19 +0000286bool hasXNACK(const MCSubtargetInfo &STI);
Dmitry Preobrazhenskye3271ae2018-02-05 12:45:43 +0000287bool hasMIMG_R128(const MCSubtargetInfo &STI);
Dmitry Preobrazhensky0a1ff462018-02-05 14:18:53 +0000288bool hasPackedD16(const MCSubtargetInfo &STI);
Dmitry Preobrazhenskye3271ae2018-02-05 12:45:43 +0000289
Tom Stellard2b65ed32015-12-21 18:44:27 +0000290bool isSI(const MCSubtargetInfo &STI);
291bool isCI(const MCSubtargetInfo &STI);
292bool isVI(const MCSubtargetInfo &STI);
Sam Koltonf7659d712017-05-23 10:08:55 +0000293bool isGFX9(const MCSubtargetInfo &STI);
294
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000295/// Is Reg - scalar register
Sam Koltonf7659d712017-05-23 10:08:55 +0000296bool isSGPR(unsigned Reg, const MCRegisterInfo* TRI);
Tom Stellard2b65ed32015-12-21 18:44:27 +0000297
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000298/// Is there any intersection between registers
Dmitry Preobrazhenskydc4ac822017-06-21 14:41:34 +0000299bool isRegIntersect(unsigned Reg0, unsigned Reg1, const MCRegisterInfo* TRI);
300
Tom Stellard2b65ed32015-12-21 18:44:27 +0000301/// If \p Reg is a pseudo reg, return the correct hardware register given
302/// \p STI otherwise return \p Reg.
303unsigned getMCReg(unsigned Reg, const MCSubtargetInfo &STI);
304
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000305/// Convert hardware register \p Reg to a pseudo register
Dmitry Preobrazhensky03880f82017-03-03 14:31:06 +0000306LLVM_READNONE
307unsigned mc2PseudoReg(unsigned Reg);
308
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000309/// Can this operand also contain immediate values?
Sam Kolton1eeb11b2016-09-09 14:44:04 +0000310bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo);
311
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000312/// Is this floating-point operand?
Sam Kolton1eeb11b2016-09-09 14:44:04 +0000313bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo);
314
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000315/// Does this opearnd support only inlinable literals?
Sam Kolton1eeb11b2016-09-09 14:44:04 +0000316bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo);
317
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000318/// Get the size in bits of a register from the register class \p RC.
Tom Stellardb133fbb2016-10-27 23:05:31 +0000319unsigned getRegBitWidth(unsigned RCID);
320
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000321/// Get the size in bits of a register from the register class \p RC.
Krzysztof Parzyszekc8715502016-10-19 17:40:36 +0000322unsigned getRegBitWidth(const MCRegisterClass &RC);
323
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000324/// Get size of register operand
Sam Kolton1eeb11b2016-09-09 14:44:04 +0000325unsigned getRegOperandSize(const MCRegisterInfo *MRI, const MCInstrDesc &Desc,
326 unsigned OpNo);
327
Matt Arsenault4bd72362016-12-10 00:39:12 +0000328LLVM_READNONE
329inline unsigned getOperandSize(const MCOperandInfo &OpInfo) {
330 switch (OpInfo.OperandType) {
331 case AMDGPU::OPERAND_REG_IMM_INT32:
332 case AMDGPU::OPERAND_REG_IMM_FP32:
333 case AMDGPU::OPERAND_REG_INLINE_C_INT32:
334 case AMDGPU::OPERAND_REG_INLINE_C_FP32:
335 return 4;
336
337 case AMDGPU::OPERAND_REG_IMM_INT64:
338 case AMDGPU::OPERAND_REG_IMM_FP64:
339 case AMDGPU::OPERAND_REG_INLINE_C_INT64:
340 case AMDGPU::OPERAND_REG_INLINE_C_FP64:
341 return 8;
342
343 case AMDGPU::OPERAND_REG_IMM_INT16:
344 case AMDGPU::OPERAND_REG_IMM_FP16:
345 case AMDGPU::OPERAND_REG_INLINE_C_INT16:
346 case AMDGPU::OPERAND_REG_INLINE_C_FP16:
Matt Arsenault9be7b0d2017-02-27 18:49:11 +0000347 case AMDGPU::OPERAND_REG_INLINE_C_V2INT16:
348 case AMDGPU::OPERAND_REG_INLINE_C_V2FP16:
Matt Arsenault4bd72362016-12-10 00:39:12 +0000349 return 2;
350
351 default:
352 llvm_unreachable("unhandled operand type");
353 }
354}
355
356LLVM_READNONE
357inline unsigned getOperandSize(const MCInstrDesc &Desc, unsigned OpNo) {
358 return getOperandSize(Desc.OpInfo[OpNo]);
359}
360
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000361/// Is this literal inlinable
Matt Arsenault26faed32016-12-05 22:26:17 +0000362LLVM_READNONE
363bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi);
364
365LLVM_READNONE
366bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi);
367
Matt Arsenault4bd72362016-12-10 00:39:12 +0000368LLVM_READNONE
369bool isInlinableLiteral16(int16_t Literal, bool HasInv2Pi);
Sam Kolton1eeb11b2016-09-09 14:44:04 +0000370
Matt Arsenault9be7b0d2017-02-27 18:49:11 +0000371LLVM_READNONE
372bool isInlinableLiteralV216(int32_t Literal, bool HasInv2Pi);
373
Matt Arsenault894e53d2017-07-26 20:39:42 +0000374bool isArgPassedInSGPR(const Argument *Arg);
Tom Stellard08efb7e2017-01-27 18:41:14 +0000375
376/// \returns The encoding that will be used for \p ByteOffset in the SMRD
377/// offset field.
378int64_t getSMRDEncodedOffset(const MCSubtargetInfo &ST, int64_t ByteOffset);
379
380/// \returns true if this offset is small enough to fit in the SMRD
381/// offset field. \p ByteOffset should be the offset in bytes and
382/// not the encoded offset.
383bool isLegalSMRDImmOffset(const MCSubtargetInfo &ST, int64_t ByteOffset);
384
Alexander Timofeev2e5eece2018-03-05 15:12:21 +0000385/// \returns true if the intrinsic is divergent
386bool isIntrinsicSourceOfDivergence(unsigned IntrID);
387
Tom Stellard347ac792015-06-26 21:15:07 +0000388} // end namespace AMDGPU
389} // end namespace llvm
390
Eugene Zelenkod96089b2017-02-14 00:33:36 +0000391#endif // LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H