radeon/llvm: improve cube map handling
[mesa.git] / src / gallium / drivers / radeon / AMDGPUSubtarget.cpp
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 // This file implements the AMDGPU specific subclass of TargetSubtarget.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "AMDGPUSubtarget.h"
15
16 using namespace llvm;
17
18 #define GET_SUBTARGETINFO_ENUM
19 #define GET_SUBTARGETINFO_TARGET_DESC
20 #define GET_SUBTARGETINFO_CTOR
21 #include "AMDGPUGenSubtargetInfo.inc"
22
23 AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) :
24 AMDGPUGenSubtargetInfo(TT, CPU, FS), mDumpCode(false) {
25 InstrItins = getInstrItineraryForCPU(CPU);
26
27 memset(CapsOverride, 0, sizeof(*CapsOverride)
28 * AMDGPUDeviceInfo::MaxNumberCapabilities);
29 // Default card
30 StringRef GPU = CPU;
31 mIs64bit = false;
32 mDefaultSize[0] = 64;
33 mDefaultSize[1] = 1;
34 mDefaultSize[2] = 1;
35 ParseSubtargetFeatures(GPU, FS);
36 mDevName = GPU;
37 mDevice = AMDGPUDeviceInfo::getDeviceFromName(mDevName, this, mIs64bit);
38 }
39
40 AMDGPUSubtarget::~AMDGPUSubtarget()
41 {
42 delete mDevice;
43 }
44
45 bool
46 AMDGPUSubtarget::isOverride(AMDGPUDeviceInfo::Caps caps) const
47 {
48 assert(caps < AMDGPUDeviceInfo::MaxNumberCapabilities &&
49 "Caps index is out of bounds!");
50 return CapsOverride[caps];
51 }
52 bool
53 AMDGPUSubtarget::is64bit() const
54 {
55 return mIs64bit;
56 }
57 bool
58 AMDGPUSubtarget::isTargetELF() const
59 {
60 return false;
61 }
62 size_t
63 AMDGPUSubtarget::getDefaultSize(uint32_t dim) const
64 {
65 if (dim > 3) {
66 return 1;
67 } else {
68 return mDefaultSize[dim];
69 }
70 }
71
72 std::string
73 AMDGPUSubtarget::getDataLayout() const
74 {
75 if (!mDevice) {
76 return std::string("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16"
77 "-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:32:32"
78 "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64"
79 "-v96:128:128-v128:128:128-v192:256:256-v256:256:256"
80 "-v512:512:512-v1024:1024:1024-v2048:2048:2048-a0:0:64");
81 }
82 return mDevice->getDataLayout();
83 }
84
85 std::string
86 AMDGPUSubtarget::getDeviceName() const
87 {
88 return mDevName;
89 }
90 const AMDGPUDevice *
91 AMDGPUSubtarget::device() const
92 {
93 return mDevice;
94 }