Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 1 | //===-- AMDGPUSubtarget.cpp - AMDGPU Subtarget Information ----------------===// |
| 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 Implements the AMDGPU specific subclass of TargetSubtarget. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "AMDGPUSubtarget.h" |
| 16 | |
| 17 | using namespace llvm; |
| 18 | |
| 19 | #define GET_SUBTARGETINFO_ENUM |
| 20 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 21 | #define GET_SUBTARGETINFO_CTOR |
| 22 | #include "AMDGPUGenSubtargetInfo.inc" |
| 23 | |
| 24 | AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) : |
| 25 | AMDGPUGenSubtargetInfo(TT, CPU, FS), DumpCode(false) { |
| 26 | InstrItins = getInstrItineraryForCPU(CPU); |
| 27 | |
| 28 | memset(CapsOverride, 0, sizeof(*CapsOverride) |
| 29 | * AMDGPUDeviceInfo::MaxNumberCapabilities); |
| 30 | // Default card |
| 31 | StringRef GPU = CPU; |
| 32 | Is64bit = false; |
| 33 | DefaultSize[0] = 64; |
| 34 | DefaultSize[1] = 1; |
| 35 | DefaultSize[2] = 1; |
Vincent Lejeune | 631591e | 2013-04-30 00:13:39 +0000 | [diff] [blame] | 36 | HasVertexCache = false; |
Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 37 | ParseSubtargetFeatures(GPU, FS); |
| 38 | DevName = GPU; |
| 39 | Device = AMDGPUDeviceInfo::getDeviceFromName(DevName, this, Is64bit); |
Patrik Hagglund | 92b4f20 | 2013-05-29 07:32:08 +0000 | [diff] [blame] | 40 | |
| 41 | // FIXME: The code in the comment below was the original code. But the |
| 42 | // condition is always true, generating a warning when compiled with |
| 43 | // gcc. Vincent Lejeune indicated in a mail to llvm-commits 2013-05-23 that he |
| 44 | // will look into this. The code 'TexVTXClauseSize = 16' is just a temporary |
| 45 | // equivalent replacement, to get rid of the compiler warning. |
| 46 | |
| 47 | // TexVTXClauseSize = (Device->getGeneration() >= AMDGPUDeviceInfo::HD4XXX)?16:8; |
| 48 | |
| 49 | TexVTXClauseSize = 16; |
Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | AMDGPUSubtarget::~AMDGPUSubtarget() { |
| 53 | delete Device; |
| 54 | } |
| 55 | |
| 56 | bool |
| 57 | AMDGPUSubtarget::isOverride(AMDGPUDeviceInfo::Caps caps) const { |
| 58 | assert(caps < AMDGPUDeviceInfo::MaxNumberCapabilities && |
| 59 | "Caps index is out of bounds!"); |
| 60 | return CapsOverride[caps]; |
| 61 | } |
| 62 | bool |
| 63 | AMDGPUSubtarget::is64bit() const { |
| 64 | return Is64bit; |
| 65 | } |
| 66 | bool |
Vincent Lejeune | 631591e | 2013-04-30 00:13:39 +0000 | [diff] [blame] | 67 | AMDGPUSubtarget::hasVertexCache() const { |
| 68 | return HasVertexCache; |
| 69 | } |
Vincent Lejeune | dcfcf1d | 2013-05-17 16:49:55 +0000 | [diff] [blame] | 70 | short |
| 71 | AMDGPUSubtarget::getTexVTXClauseSize() const { |
| 72 | return TexVTXClauseSize; |
| 73 | } |
Vincent Lejeune | 631591e | 2013-04-30 00:13:39 +0000 | [diff] [blame] | 74 | bool |
Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 75 | AMDGPUSubtarget::isTargetELF() const { |
| 76 | return false; |
| 77 | } |
| 78 | size_t |
| 79 | AMDGPUSubtarget::getDefaultSize(uint32_t dim) const { |
| 80 | if (dim > 3) { |
| 81 | return 1; |
| 82 | } else { |
| 83 | return DefaultSize[dim]; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | std::string |
| 88 | AMDGPUSubtarget::getDataLayout() const { |
| 89 | if (!Device) { |
| 90 | return std::string("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" |
| 91 | "-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:32:32" |
| 92 | "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64" |
| 93 | "-v96:128:128-v128:128:128-v192:256:256-v256:256:256" |
| 94 | "-v512:512:512-v1024:1024:1024-v2048:2048:2048-a0:0:64"); |
| 95 | } |
| 96 | return Device->getDataLayout(); |
| 97 | } |
| 98 | |
| 99 | std::string |
| 100 | AMDGPUSubtarget::getDeviceName() const { |
| 101 | return DevName; |
| 102 | } |
| 103 | const AMDGPUDevice * |
| 104 | AMDGPUSubtarget::device() const { |
| 105 | return Device; |
| 106 | } |