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