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