radeon/llvm: Add some comments
[mesa.git] / src / gallium / drivers / radeon / AMDILDevice.cpp
1 //===-- AMDILDevice.cpp - Base class for AMDIL Devices --------------------===//
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 "AMDILDevice.h"
10 #include "AMDILSubtarget.h"
11
12 using namespace llvm;
13 // Default implementation for all of the classes.
14 AMDILDevice::AMDILDevice(AMDILSubtarget *ST) : mSTM(ST)
15 {
16 mHWBits.resize(AMDILDeviceInfo::MaxNumberCapabilities);
17 mSWBits.resize(AMDILDeviceInfo::MaxNumberCapabilities);
18 setCaps();
19 mDeviceFlag = OCL_DEVICE_ALL;
20 }
21
22 AMDILDevice::~AMDILDevice()
23 {
24 mHWBits.clear();
25 mSWBits.clear();
26 }
27
28 size_t AMDILDevice::getMaxGDSSize() const
29 {
30 return 0;
31 }
32
33 uint32_t
34 AMDILDevice::getDeviceFlag() const
35 {
36 return mDeviceFlag;
37 }
38
39 size_t AMDILDevice::getMaxNumCBs() const
40 {
41 if (usesHardware(AMDILDeviceInfo::ConstantMem)) {
42 return HW_MAX_NUM_CB;
43 }
44
45 return 0;
46 }
47
48 size_t AMDILDevice::getMaxCBSize() const
49 {
50 if (usesHardware(AMDILDeviceInfo::ConstantMem)) {
51 return MAX_CB_SIZE;
52 }
53
54 return 0;
55 }
56
57 size_t AMDILDevice::getMaxScratchSize() const
58 {
59 return 65536;
60 }
61
62 uint32_t AMDILDevice::getStackAlignment() const
63 {
64 return 16;
65 }
66
67 void AMDILDevice::setCaps()
68 {
69 mSWBits.set(AMDILDeviceInfo::HalfOps);
70 mSWBits.set(AMDILDeviceInfo::ByteOps);
71 mSWBits.set(AMDILDeviceInfo::ShortOps);
72 mSWBits.set(AMDILDeviceInfo::HW64BitDivMod);
73 if (mSTM->isOverride(AMDILDeviceInfo::NoInline)) {
74 mSWBits.set(AMDILDeviceInfo::NoInline);
75 }
76 if (mSTM->isOverride(AMDILDeviceInfo::MacroDB)) {
77 mSWBits.set(AMDILDeviceInfo::MacroDB);
78 }
79 if (mSTM->isOverride(AMDILDeviceInfo::Debug)) {
80 mSWBits.set(AMDILDeviceInfo::ConstantMem);
81 } else {
82 mHWBits.set(AMDILDeviceInfo::ConstantMem);
83 }
84 if (mSTM->isOverride(AMDILDeviceInfo::Debug)) {
85 mSWBits.set(AMDILDeviceInfo::PrivateMem);
86 } else {
87 mHWBits.set(AMDILDeviceInfo::PrivateMem);
88 }
89 if (mSTM->isOverride(AMDILDeviceInfo::BarrierDetect)) {
90 mSWBits.set(AMDILDeviceInfo::BarrierDetect);
91 }
92 mSWBits.set(AMDILDeviceInfo::ByteLDSOps);
93 mSWBits.set(AMDILDeviceInfo::LongOps);
94 }
95
96 AMDILDeviceInfo::ExecutionMode
97 AMDILDevice::getExecutionMode(AMDILDeviceInfo::Caps Caps) const
98 {
99 if (mHWBits[Caps]) {
100 assert(!mSWBits[Caps] && "Cannot set both SW and HW caps");
101 return AMDILDeviceInfo::Hardware;
102 }
103
104 if (mSWBits[Caps]) {
105 assert(!mHWBits[Caps] && "Cannot set both SW and HW caps");
106 return AMDILDeviceInfo::Software;
107 }
108
109 return AMDILDeviceInfo::Unsupported;
110
111 }
112
113 bool AMDILDevice::isSupported(AMDILDeviceInfo::Caps Mode) const
114 {
115 return getExecutionMode(Mode) != AMDILDeviceInfo::Unsupported;
116 }
117
118 bool AMDILDevice::usesHardware(AMDILDeviceInfo::Caps Mode) const
119 {
120 return getExecutionMode(Mode) == AMDILDeviceInfo::Hardware;
121 }
122
123 bool AMDILDevice::usesSoftware(AMDILDeviceInfo::Caps Mode) const
124 {
125 return getExecutionMode(Mode) == AMDILDeviceInfo::Software;
126 }
127
128 std::string
129 AMDILDevice::getDataLayout() const
130 {
131 return std::string("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16"
132 "-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:32:32"
133 "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64"
134 "-v96:128:128-v128:128:128-v192:256:256-v256:256:256"
135 "-v512:512:512-v1024:1024:1024-v2048:2048:2048"
136 "-n8:16:32:64");
137 }