]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/llvm/lib/Target/R600/AMDGPUSubtarget.cpp
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / llvm / lib / Target / R600 / 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 /// \file
11 /// \brief Implements the AMDGPU specific subclass of TargetSubtarget.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "AMDGPUSubtarget.h"
16
17 using namespace llvm;
18
19 #define GET_SUBTARGETINFO_ENUM
20 #define GET_SUBTARGETINFO_TARGET_DESC
21 #define GET_SUBTARGETINFO_CTOR
22 #include "AMDGPUGenSubtargetInfo.inc"
23
24 AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) :
25   AMDGPUGenSubtargetInfo(TT, CPU, FS), DumpCode(false) {
26     InstrItins = getInstrItineraryForCPU(CPU);
27
28   memset(CapsOverride, 0, sizeof(*CapsOverride)
29       * AMDGPUDeviceInfo::MaxNumberCapabilities);
30   // Default card
31   StringRef GPU = CPU;
32   Is64bit = false;
33   DefaultSize[0] = 64;
34   DefaultSize[1] = 1;
35   DefaultSize[2] = 1;
36   HasVertexCache = false;
37   ParseSubtargetFeatures(GPU, FS);
38   DevName = GPU;
39   Device = AMDGPUDeviceInfo::getDeviceFromName(DevName, this, Is64bit);
40 }
41
42 AMDGPUSubtarget::~AMDGPUSubtarget() {
43   delete Device;
44 }
45
46 bool
47 AMDGPUSubtarget::isOverride(AMDGPUDeviceInfo::Caps caps) const {
48   assert(caps < AMDGPUDeviceInfo::MaxNumberCapabilities &&
49       "Caps index is out of bounds!");
50   return CapsOverride[caps];
51 }
52 bool
53 AMDGPUSubtarget::is64bit() const  {
54   return Is64bit;
55 }
56 bool
57 AMDGPUSubtarget::hasVertexCache() const {
58   return HasVertexCache;
59 }
60 bool
61 AMDGPUSubtarget::isTargetELF() const {
62   return false;
63 }
64 size_t
65 AMDGPUSubtarget::getDefaultSize(uint32_t dim) const {
66   if (dim > 3) {
67     return 1;
68   } else {
69     return DefaultSize[dim];
70   }
71 }
72
73 std::string
74 AMDGPUSubtarget::getDataLayout() const {
75     if (!Device) {
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 Device->getDataLayout();
83 }
84
85 std::string
86 AMDGPUSubtarget::getDeviceName() const {
87   return DevName;
88 }
89 const AMDGPUDevice *
90 AMDGPUSubtarget::device() const {
91   return Device;
92 }