1 //===-- AMDILEvergreenDevice.cpp - Device Info for Evergreen --------------===//
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 #include "AMDILEvergreenDevice.h"
10 
11 using namespace llvm;
12 
AMDGPUEvergreenDevice(AMDGPUSubtarget * ST)13 AMDGPUEvergreenDevice::AMDGPUEvergreenDevice(AMDGPUSubtarget *ST)
14 : AMDGPUDevice(ST) {
15   setCaps();
16   std::string name = ST->getDeviceName();
17   if (name == "cedar") {
18     mDeviceFlag = OCL_DEVICE_CEDAR;
19   } else if (name == "redwood") {
20     mDeviceFlag = OCL_DEVICE_REDWOOD;
21   } else if (name == "cypress") {
22     mDeviceFlag = OCL_DEVICE_CYPRESS;
23   } else {
24     mDeviceFlag = OCL_DEVICE_JUNIPER;
25   }
26 }
27 
~AMDGPUEvergreenDevice()28 AMDGPUEvergreenDevice::~AMDGPUEvergreenDevice() {
29 }
30 
getMaxLDSSize() const31 size_t AMDGPUEvergreenDevice::getMaxLDSSize() const {
32   if (usesHardware(AMDGPUDeviceInfo::LocalMem)) {
33     return MAX_LDS_SIZE_800;
34   } else {
35     return 0;
36   }
37 }
getMaxGDSSize() const38 size_t AMDGPUEvergreenDevice::getMaxGDSSize() const {
39   if (usesHardware(AMDGPUDeviceInfo::RegionMem)) {
40     return MAX_LDS_SIZE_800;
41   } else {
42     return 0;
43   }
44 }
getMaxNumUAVs() const45 uint32_t AMDGPUEvergreenDevice::getMaxNumUAVs() const {
46   return 12;
47 }
48 
getResourceID(uint32_t id) const49 uint32_t AMDGPUEvergreenDevice::getResourceID(uint32_t id) const {
50   switch(id) {
51   default:
52     assert(0 && "ID type passed in is unknown!");
53     break;
54   case CONSTANT_ID:
55   case RAW_UAV_ID:
56     return GLOBAL_RETURN_RAW_UAV_ID;
57   case GLOBAL_ID:
58   case ARENA_UAV_ID:
59     return DEFAULT_ARENA_UAV_ID;
60   case LDS_ID:
61     if (usesHardware(AMDGPUDeviceInfo::LocalMem)) {
62       return DEFAULT_LDS_ID;
63     } else {
64       return DEFAULT_ARENA_UAV_ID;
65     }
66   case GDS_ID:
67     if (usesHardware(AMDGPUDeviceInfo::RegionMem)) {
68       return DEFAULT_GDS_ID;
69     } else {
70       return DEFAULT_ARENA_UAV_ID;
71     }
72   case SCRATCH_ID:
73     if (usesHardware(AMDGPUDeviceInfo::PrivateMem)) {
74       return DEFAULT_SCRATCH_ID;
75     } else {
76       return DEFAULT_ARENA_UAV_ID;
77     }
78   };
79   return 0;
80 }
81 
getWavefrontSize() const82 size_t AMDGPUEvergreenDevice::getWavefrontSize() const {
83   return AMDGPUDevice::WavefrontSize;
84 }
85 
getGeneration() const86 uint32_t AMDGPUEvergreenDevice::getGeneration() const {
87   return AMDGPUDeviceInfo::HD5XXX;
88 }
89 
setCaps()90 void AMDGPUEvergreenDevice::setCaps() {
91   mSWBits.set(AMDGPUDeviceInfo::ArenaSegment);
92   mHWBits.set(AMDGPUDeviceInfo::ArenaUAV);
93   mHWBits.set(AMDGPUDeviceInfo::HW64BitDivMod);
94   mSWBits.reset(AMDGPUDeviceInfo::HW64BitDivMod);
95   mSWBits.set(AMDGPUDeviceInfo::Signed24BitOps);
96   if (mSTM->isOverride(AMDGPUDeviceInfo::ByteStores)) {
97     mHWBits.set(AMDGPUDeviceInfo::ByteStores);
98   }
99   if (mSTM->isOverride(AMDGPUDeviceInfo::Debug)) {
100     mSWBits.set(AMDGPUDeviceInfo::LocalMem);
101     mSWBits.set(AMDGPUDeviceInfo::RegionMem);
102   } else {
103     mHWBits.set(AMDGPUDeviceInfo::LocalMem);
104     mHWBits.set(AMDGPUDeviceInfo::RegionMem);
105   }
106   mHWBits.set(AMDGPUDeviceInfo::Images);
107   if (mSTM->isOverride(AMDGPUDeviceInfo::NoAlias)) {
108     mHWBits.set(AMDGPUDeviceInfo::NoAlias);
109   }
110   mHWBits.set(AMDGPUDeviceInfo::CachedMem);
111   if (mSTM->isOverride(AMDGPUDeviceInfo::MultiUAV)) {
112     mHWBits.set(AMDGPUDeviceInfo::MultiUAV);
113   }
114   mHWBits.set(AMDGPUDeviceInfo::ByteLDSOps);
115   mSWBits.reset(AMDGPUDeviceInfo::ByteLDSOps);
116   mHWBits.set(AMDGPUDeviceInfo::ArenaVectors);
117   mHWBits.set(AMDGPUDeviceInfo::LongOps);
118   mSWBits.reset(AMDGPUDeviceInfo::LongOps);
119   mHWBits.set(AMDGPUDeviceInfo::TmrReg);
120 }
121 
AMDGPUCypressDevice(AMDGPUSubtarget * ST)122 AMDGPUCypressDevice::AMDGPUCypressDevice(AMDGPUSubtarget *ST)
123   : AMDGPUEvergreenDevice(ST) {
124   setCaps();
125 }
126 
~AMDGPUCypressDevice()127 AMDGPUCypressDevice::~AMDGPUCypressDevice() {
128 }
129 
setCaps()130 void AMDGPUCypressDevice::setCaps() {
131   if (mSTM->isOverride(AMDGPUDeviceInfo::DoubleOps)) {
132     mHWBits.set(AMDGPUDeviceInfo::DoubleOps);
133     mHWBits.set(AMDGPUDeviceInfo::FMA);
134   }
135 }
136 
137 
AMDGPUCedarDevice(AMDGPUSubtarget * ST)138 AMDGPUCedarDevice::AMDGPUCedarDevice(AMDGPUSubtarget *ST)
139   : AMDGPUEvergreenDevice(ST) {
140   setCaps();
141 }
142 
~AMDGPUCedarDevice()143 AMDGPUCedarDevice::~AMDGPUCedarDevice() {
144 }
145 
setCaps()146 void AMDGPUCedarDevice::setCaps() {
147   mSWBits.set(AMDGPUDeviceInfo::FMA);
148 }
149 
getWavefrontSize() const150 size_t AMDGPUCedarDevice::getWavefrontSize() const {
151   return AMDGPUDevice::QuarterWavefrontSize;
152 }
153 
AMDGPURedwoodDevice(AMDGPUSubtarget * ST)154 AMDGPURedwoodDevice::AMDGPURedwoodDevice(AMDGPUSubtarget *ST)
155   : AMDGPUEvergreenDevice(ST) {
156   setCaps();
157 }
158 
~AMDGPURedwoodDevice()159 AMDGPURedwoodDevice::~AMDGPURedwoodDevice()
160 {
161 }
162 
setCaps()163 void AMDGPURedwoodDevice::setCaps() {
164   mSWBits.set(AMDGPUDeviceInfo::FMA);
165 }
166 
getWavefrontSize() const167 size_t AMDGPURedwoodDevice::getWavefrontSize() const {
168   return AMDGPUDevice::HalfWavefrontSize;
169 }
170