Tom Stellard | 347ac79 | 2015-06-26 21:15:07 +0000 | [diff] [blame] | 1 | //===-- AMDGPUBaseInfo.h - Top level definitions for AMDGPU -----*- 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 | #ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H |
| 11 | #define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H |
| 12 | |
| 13 | #include "AMDKernelCodeT.h" |
Nicolai Haehnle | df3a20c | 2016-04-06 19:40:20 +0000 | [diff] [blame] | 14 | #include "llvm/IR/CallingConv.h" |
Tom Stellard | 347ac79 | 2015-06-26 21:15:07 +0000 | [diff] [blame] | 15 | |
Sam Kolton | a3ec5c1 | 2016-10-07 14:46:06 +0000 | [diff] [blame] | 16 | #define GET_INSTRINFO_OPERAND_ENUM |
| 17 | #include "AMDGPUGenInstrInfo.inc" |
| 18 | #undef GET_INSTRINFO_OPERAND_ENUM |
| 19 | |
Tom Stellard | 347ac79 | 2015-06-26 21:15:07 +0000 | [diff] [blame] | 20 | namespace llvm { |
| 21 | |
| 22 | class FeatureBitset; |
Tom Stellard | ac00eb5 | 2015-12-15 16:26:16 +0000 | [diff] [blame] | 23 | class Function; |
Tom Stellard | e3b5aea | 2015-12-02 17:00:42 +0000 | [diff] [blame] | 24 | class GlobalValue; |
Tom Stellard | e135ffd | 2015-09-25 21:41:28 +0000 | [diff] [blame] | 25 | class MCContext; |
Sam Kolton | 1eeb11b | 2016-09-09 14:44:04 +0000 | [diff] [blame] | 26 | class MCInstrDesc; |
| 27 | class MCRegisterInfo; |
Tom Stellard | e135ffd | 2015-09-25 21:41:28 +0000 | [diff] [blame] | 28 | class MCSection; |
Tom Stellard | 2b65ed3 | 2015-12-21 18:44:27 +0000 | [diff] [blame] | 29 | class MCSubtargetInfo; |
Tom Stellard | 347ac79 | 2015-06-26 21:15:07 +0000 | [diff] [blame] | 30 | |
| 31 | namespace AMDGPU { |
| 32 | |
Sam Kolton | a3ec5c1 | 2016-10-07 14:46:06 +0000 | [diff] [blame] | 33 | LLVM_READONLY |
| 34 | int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx); |
| 35 | |
Tom Stellard | 347ac79 | 2015-06-26 21:15:07 +0000 | [diff] [blame] | 36 | struct IsaVersion { |
| 37 | unsigned Major; |
| 38 | unsigned Minor; |
| 39 | unsigned Stepping; |
| 40 | }; |
| 41 | |
| 42 | IsaVersion getIsaVersion(const FeatureBitset &Features); |
Tom Stellard | ff7416b | 2015-06-26 21:58:31 +0000 | [diff] [blame] | 43 | void initDefaultAMDKernelCodeT(amd_kernel_code_t &Header, |
| 44 | const FeatureBitset &Features); |
Tom Stellard | e135ffd | 2015-09-25 21:41:28 +0000 | [diff] [blame] | 45 | MCSection *getHSATextSection(MCContext &Ctx); |
Tom Stellard | 347ac79 | 2015-06-26 21:15:07 +0000 | [diff] [blame] | 46 | |
Tom Stellard | 00f2f91 | 2015-12-02 19:47:57 +0000 | [diff] [blame] | 47 | MCSection *getHSADataGlobalAgentSection(MCContext &Ctx); |
| 48 | |
| 49 | MCSection *getHSADataGlobalProgramSection(MCContext &Ctx); |
| 50 | |
Tom Stellard | 9760f03 | 2015-12-03 03:34:32 +0000 | [diff] [blame] | 51 | MCSection *getHSARodataReadonlyAgentSection(MCContext &Ctx); |
| 52 | |
Tom Stellard | e3b5aea | 2015-12-02 17:00:42 +0000 | [diff] [blame] | 53 | bool isGroupSegment(const GlobalValue *GV); |
Tom Stellard | 00f2f91 | 2015-12-02 19:47:57 +0000 | [diff] [blame] | 54 | bool isGlobalSegment(const GlobalValue *GV); |
| 55 | bool isReadOnlySegment(const GlobalValue *GV); |
Tom Stellard | e3b5aea | 2015-12-02 17:00:42 +0000 | [diff] [blame] | 56 | |
Konstantin Zhuravlyov | 1d65026 | 2016-09-06 20:22:28 +0000 | [diff] [blame] | 57 | /// \returns Integer value requested using \p F's \p Name attribute. |
| 58 | /// |
| 59 | /// \returns \p Default if attribute is not present. |
| 60 | /// |
| 61 | /// \returns \p Default and emits error if requested value cannot be converted |
| 62 | /// to integer. |
Matt Arsenault | 8300272 | 2016-05-12 02:45:18 +0000 | [diff] [blame] | 63 | int getIntegerAttribute(const Function &F, StringRef Name, int Default); |
| 64 | |
Konstantin Zhuravlyov | 1d65026 | 2016-09-06 20:22:28 +0000 | [diff] [blame] | 65 | /// \returns A pair of integer values requested using \p F's \p Name attribute |
| 66 | /// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired |
| 67 | /// is false). |
| 68 | /// |
| 69 | /// \returns \p Default if attribute is not present. |
| 70 | /// |
| 71 | /// \returns \p Default and emits error if one of the requested values cannot be |
| 72 | /// converted to integer, or \p OnlyFirstRequired is false and "second" value is |
| 73 | /// not present. |
| 74 | std::pair<int, int> getIntegerPairAttribute(const Function &F, |
| 75 | StringRef Name, |
| 76 | std::pair<int, int> Default, |
| 77 | bool OnlyFirstRequired = false); |
| 78 | |
Konstantin Zhuravlyov | 836cbff | 2016-09-30 17:01:40 +0000 | [diff] [blame] | 79 | /// \returns VMCNT bit mask for given isa \p Version. |
| 80 | unsigned getVmcntMask(IsaVersion Version); |
| 81 | |
| 82 | /// \returns VMCNT bit shift for given isa \p Version. |
| 83 | unsigned getVmcntShift(IsaVersion Version); |
| 84 | |
| 85 | /// \returns EXPCNT bit mask for given isa \p Version. |
| 86 | unsigned getExpcntMask(IsaVersion Version); |
| 87 | |
| 88 | /// \returns EXPCNT bit shift for given isa \p Version. |
| 89 | unsigned getExpcntShift(IsaVersion Version); |
| 90 | |
| 91 | /// \returns LGKMCNT bit mask for given isa \p Version. |
| 92 | unsigned getLgkmcntMask(IsaVersion Version); |
| 93 | |
| 94 | /// \returns LGKMCNT bit shift for given isa \p Version. |
| 95 | unsigned getLgkmcntShift(IsaVersion Version); |
| 96 | |
Marek Olsak | fccabaf | 2016-01-13 11:45:36 +0000 | [diff] [blame] | 97 | unsigned getInitialPSInputAddr(const Function &F); |
| 98 | |
Nicolai Haehnle | df3a20c | 2016-04-06 19:40:20 +0000 | [diff] [blame] | 99 | bool isShader(CallingConv::ID cc); |
| 100 | bool isCompute(CallingConv::ID cc); |
Tom Stellard | ac00eb5 | 2015-12-15 16:26:16 +0000 | [diff] [blame] | 101 | |
Tom Stellard | 2b65ed3 | 2015-12-21 18:44:27 +0000 | [diff] [blame] | 102 | bool isSI(const MCSubtargetInfo &STI); |
| 103 | bool isCI(const MCSubtargetInfo &STI); |
| 104 | bool isVI(const MCSubtargetInfo &STI); |
| 105 | |
| 106 | /// If \p Reg is a pseudo reg, return the correct hardware register given |
| 107 | /// \p STI otherwise return \p Reg. |
| 108 | unsigned getMCReg(unsigned Reg, const MCSubtargetInfo &STI); |
| 109 | |
Sam Kolton | 1eeb11b | 2016-09-09 14:44:04 +0000 | [diff] [blame] | 110 | /// \brief Can this operand also contain immediate values? |
| 111 | bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo); |
| 112 | |
| 113 | /// \brief Is this floating-point operand? |
| 114 | bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo); |
| 115 | |
| 116 | /// \brief Does this opearnd support only inlinable literals? |
| 117 | bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo); |
| 118 | |
| 119 | /// \brief Get size of register operand |
| 120 | unsigned getRegOperandSize(const MCRegisterInfo *MRI, const MCInstrDesc &Desc, |
| 121 | unsigned OpNo); |
| 122 | |
| 123 | /// \brief Is this literal inlinable |
| 124 | bool isInlinableLiteral64(int64_t Literal, bool IsVI); |
| 125 | bool isInlinableLiteral32(int32_t Literal, bool IsVI); |
| 126 | |
Tom Stellard | 347ac79 | 2015-06-26 21:15:07 +0000 | [diff] [blame] | 127 | } // end namespace AMDGPU |
| 128 | } // end namespace llvm |
| 129 | |
| 130 | #endif |