R600: Add work-around for the CF stack entry HW bug
[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   CFALUBug = false;
43   ParseSubtargetFeatures(GPU, FS);
44   DevName = GPU;
45 }
46
47 bool
48 AMDGPUSubtarget::is64bit() const  {
49   return Is64bit;
50 }
51 bool
52 AMDGPUSubtarget::hasVertexCache() const {
53   return HasVertexCache;
54 }
55 short
56 AMDGPUSubtarget::getTexVTXClauseSize() const {
57   return TexVTXClauseSize;
58 }
59 enum AMDGPUSubtarget::Generation
60 AMDGPUSubtarget::getGeneration() const {
61   return Gen;
62 }
63 bool
64 AMDGPUSubtarget::hasHWFP64() const {
65   return FP64;
66 }
67 bool
68 AMDGPUSubtarget::hasCaymanISA() const {
69   return CaymanISA;
70 }
71 bool
72 AMDGPUSubtarget::IsIRStructurizerEnabled() const {
73   return EnableIRStructurizer;
74 }
75 bool
76 AMDGPUSubtarget::isIfCvtEnabled() const {
77   return EnableIfCvt;
78 }
79 unsigned
80 AMDGPUSubtarget::getWavefrontSize() const {
81   return WavefrontSize;
82 }
83 unsigned
84 AMDGPUSubtarget::getStackEntrySize() const {
85   assert(getGeneration() <= NORTHERN_ISLANDS);
86   switch(getWavefrontSize()) {
87   case 16:
88     return 8;
89   case 32:
90     if (hasCaymanISA())
91       return 4;
92     else
93       return 8;
94   case 64:
95     return 4;
96   default:
97     llvm_unreachable("Illegal wavefront size.");
98   }
99 }
100 bool
101 AMDGPUSubtarget::hasCFAluBug() const {
102   assert(getGeneration() <= NORTHERN_ISLANDS);
103   return CFALUBug;
104 }
105 bool
106 AMDGPUSubtarget::isTargetELF() const {
107   return false;
108 }
109 size_t
110 AMDGPUSubtarget::getDefaultSize(uint32_t dim) const {
111   if (dim > 2) {
112     return 1;
113   } else {
114     return DefaultSize[dim];
115   }
116 }
117
118 std::string
119 AMDGPUSubtarget::getDeviceName() const {
120   return DevName;
121 }