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