aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/radeon/AMDILEvergreenDevice.cpp
blob: 779b2d3df2f9571927adb61f233c8471f185c4ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
//===-- AMDILEvergreenDevice.cpp - Device Info for Evergreen --------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//==-----------------------------------------------------------------------===//
#include "AMDILEvergreenDevice.h"
#ifdef UPSTREAM_LLVM
#include "AMDILEGAsmPrinter.h"
#endif

using namespace llvm;

AMDILEvergreenDevice::AMDILEvergreenDevice(AMDILSubtarget *ST)
: AMDILDevice(ST) {
  setCaps();
  std::string name = ST->getDeviceName();
  if (name == "cedar") {
    mDeviceFlag = OCL_DEVICE_CEDAR;
  } else if (name == "redwood") {
    mDeviceFlag = OCL_DEVICE_REDWOOD;
  } else if (name == "cypress") {
    mDeviceFlag = OCL_DEVICE_CYPRESS;
  } else {
    mDeviceFlag = OCL_DEVICE_JUNIPER;
  }
}

AMDILEvergreenDevice::~AMDILEvergreenDevice() {
}

size_t AMDILEvergreenDevice::getMaxLDSSize() const {
  if (usesHardware(AMDILDeviceInfo::LocalMem)) {
    return MAX_LDS_SIZE_800;
  } else {
    return 0;
  }
}
size_t AMDILEvergreenDevice::getMaxGDSSize() const {
  if (usesHardware(AMDILDeviceInfo::RegionMem)) {
    return MAX_LDS_SIZE_800;
  } else {
    return 0;
  }
}
uint32_t AMDILEvergreenDevice::getMaxNumUAVs() const {
  return 12;
}

uint32_t AMDILEvergreenDevice::getResourceID(uint32_t id) const {
  switch(id) {
  default:
    assert(0 && "ID type passed in is unknown!");
    break;
  case CONSTANT_ID:
  case RAW_UAV_ID:
    if (mSTM->calVersion() >= CAL_VERSION_GLOBAL_RETURN_BUFFER) {
      return GLOBAL_RETURN_RAW_UAV_ID;
    } else {
      return DEFAULT_RAW_UAV_ID;
    }
  case GLOBAL_ID:
  case ARENA_UAV_ID:
    return DEFAULT_ARENA_UAV_ID;
  case LDS_ID:
    if (usesHardware(AMDILDeviceInfo::LocalMem)) {
      return DEFAULT_LDS_ID;
    } else {
      return DEFAULT_ARENA_UAV_ID;
    }
  case GDS_ID:
    if (usesHardware(AMDILDeviceInfo::RegionMem)) {
      return DEFAULT_GDS_ID;
    } else {
      return DEFAULT_ARENA_UAV_ID;
    }
  case SCRATCH_ID:
    if (usesHardware(AMDILDeviceInfo::PrivateMem)) {
      return DEFAULT_SCRATCH_ID;
    } else {
      return DEFAULT_ARENA_UAV_ID;
    }
  };
  return 0;
}

size_t AMDILEvergreenDevice::getWavefrontSize() const {
  return AMDILDevice::WavefrontSize;
}

uint32_t AMDILEvergreenDevice::getGeneration() const {
  return AMDILDeviceInfo::HD5XXX;
}

void AMDILEvergreenDevice::setCaps() {
  mSWBits.set(AMDILDeviceInfo::ArenaSegment);
  mHWBits.set(AMDILDeviceInfo::ArenaUAV);
  if (mSTM->calVersion() >= CAL_VERSION_SC_140) {
    mHWBits.set(AMDILDeviceInfo::HW64BitDivMod);
    mSWBits.reset(AMDILDeviceInfo::HW64BitDivMod);
  } 
  mSWBits.set(AMDILDeviceInfo::Signed24BitOps);
  if (mSTM->isOverride(AMDILDeviceInfo::ByteStores)) {
    mHWBits.set(AMDILDeviceInfo::ByteStores);
  }
  if (mSTM->isOverride(AMDILDeviceInfo::Debug)) {
    mSWBits.set(AMDILDeviceInfo::LocalMem);
    mSWBits.set(AMDILDeviceInfo::RegionMem);
  } else {
    mHWBits.set(AMDILDeviceInfo::LocalMem);
    mHWBits.set(AMDILDeviceInfo::RegionMem);
  }
  mHWBits.set(AMDILDeviceInfo::Images);
  if (mSTM->isOverride(AMDILDeviceInfo::NoAlias)) {
    mHWBits.set(AMDILDeviceInfo::NoAlias);
  }
  if (mSTM->calVersion() > CAL_VERSION_GLOBAL_RETURN_BUFFER) {
    mHWBits.set(AMDILDeviceInfo::CachedMem);
  }
  if (mSTM->isOverride(AMDILDeviceInfo::MultiUAV)) {
    mHWBits.set(AMDILDeviceInfo::MultiUAV);
  }
  if (mSTM->calVersion() > CAL_VERSION_SC_136) {
    mHWBits.set(AMDILDeviceInfo::ByteLDSOps);
    mSWBits.reset(AMDILDeviceInfo::ByteLDSOps);
    mHWBits.set(AMDILDeviceInfo::ArenaVectors);
  } else {
    mSWBits.set(AMDILDeviceInfo::ArenaVectors);
  }
  if (mSTM->calVersion() > CAL_VERSION_SC_137) {
    mHWBits.set(AMDILDeviceInfo::LongOps);
    mSWBits.reset(AMDILDeviceInfo::LongOps);
  }
  mHWBits.set(AMDILDeviceInfo::TmrReg);
}

AsmPrinter*
AMDILEvergreenDevice::getAsmPrinter(TargetMachine& TM, MCStreamer &Streamer) const
{
#ifdef UPSTREAM_LLVM
  return new AMDILEGAsmPrinter(TM, Streamer);
#else
  return NULL;
#endif
}

AMDILCypressDevice::AMDILCypressDevice(AMDILSubtarget *ST)
  : AMDILEvergreenDevice(ST) {
  setCaps();
}

AMDILCypressDevice::~AMDILCypressDevice() {
}

void AMDILCypressDevice::setCaps() {
  if (mSTM->isOverride(AMDILDeviceInfo::DoubleOps)) {
    mHWBits.set(AMDILDeviceInfo::DoubleOps);
    mHWBits.set(AMDILDeviceInfo::FMA);
  }
}


AMDILCedarDevice::AMDILCedarDevice(AMDILSubtarget *ST)
  : AMDILEvergreenDevice(ST) {
  setCaps();
}

AMDILCedarDevice::~AMDILCedarDevice() {
}

void AMDILCedarDevice::setCaps() {
  mSWBits.set(AMDILDeviceInfo::FMA);
}

size_t AMDILCedarDevice::getWavefrontSize() const {
  return AMDILDevice::QuarterWavefrontSize;
}

AMDILRedwoodDevice::AMDILRedwoodDevice(AMDILSubtarget *ST)
  : AMDILEvergreenDevice(ST) {
  setCaps();
}

AMDILRedwoodDevice::~AMDILRedwoodDevice()
{
}

void AMDILRedwoodDevice::setCaps() {
  mSWBits.set(AMDILDeviceInfo::FMA);
}

size_t AMDILRedwoodDevice::getWavefrontSize() const {
  return AMDILDevice::HalfWavefrontSize;
}