R600: Refactor stack size calculation
[oota-llvm.git] / 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   // Default card
29   StringRef GPU = CPU;
30   Is64bit = false;
31   DefaultSize[0] = 64;
32   DefaultSize[1] = 1;
33   DefaultSize[2] = 1;
34   HasVertexCache = false;
35   TexVTXClauseSize = 0;
36   Gen = AMDGPUSubtarget::R600;
37   FP64 = false;
38   CaymanISA = false;
39   EnableIRStructurizer = true;
40   EnableIfCvt = true;
41   WavefrontSize = 0;
42   ParseSubtargetFeatures(GPU, FS);
43   DevName = GPU;
44 }
45
46 bool
47 AMDGPUSubtarget::is64bit() const  {
48   return Is64bit;
49 }
50 bool
51 AMDGPUSubtarget::hasVertexCache() const {
52   return HasVertexCache;
53 }
54 short
55 AMDGPUSubtarget::getTexVTXClauseSize() const {
56   return TexVTXClauseSize;
57 }
58 enum AMDGPUSubtarget::Generation
59 AMDGPUSubtarget::getGeneration() const {
60   return Gen;
61 }
62 bool
63 AMDGPUSubtarget::hasHWFP64() const {
64   return FP64;
65 }
66 bool
67 AMDGPUSubtarget::hasCaymanISA() const {
68   return CaymanISA;
69 }
70 bool
71 AMDGPUSubtarget::IsIRStructurizerEnabled() const {
72   return EnableIRStructurizer;
73 }
74 bool
75 AMDGPUSubtarget::isIfCvtEnabled() const {
76   return EnableIfCvt;
77 }
78 unsigned
79 AMDGPUSubtarget::getWavefrontSize() const {
80   return WavefrontSize;
81 }
82 unsigned
83 AMDGPUSubtarget::getStackEntrySize() const {
84   assert(getGeneration() <= NORTHERN_ISLANDS);
85   switch(getWavefrontSize()) {
86   case 16:
87     return 8;
88   case 32:
89     if (hasCaymanISA())
90       return 4;
91     else
92       return 8;
93   case 64:
94     return 4;
95   default:
96     llvm_unreachable("Illegal wavefront size.");
97   }
98 }
99 bool
100 AMDGPUSubtarget::isTargetELF() const {
101   return false;
102 }
103 size_t
104 AMDGPUSubtarget::getDefaultSize(uint32_t dim) const {
105   if (dim > 2) {
106     return 1;
107   } else {
108     return DefaultSize[dim];
109   }
110 }
111
112 std::string
113 AMDGPUSubtarget::getDeviceName() const {
114   return DevName;
115 }