R600: Move AMDGPUInstrInfo from AMDGPUTargetMachine into AMDGPUSubtarget
[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 #include "R600InstrInfo.h"
17 #include "SIInstrInfo.h"
18
19 using namespace llvm;
20
21 #define DEBUG_TYPE "amdgpu-subtarget"
22
23 #define GET_SUBTARGETINFO_ENUM
24 #define GET_SUBTARGETINFO_TARGET_DESC
25 #define GET_SUBTARGETINFO_CTOR
26 #include "AMDGPUGenSubtargetInfo.inc"
27
28 AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) :
29   AMDGPUGenSubtargetInfo(TT, CPU, FS), DumpCode(false) {
30     InstrItins = getInstrItineraryForCPU(CPU);
31
32   // Default card
33   StringRef GPU = CPU;
34   Is64bit = false;
35   HasVertexCache = false;
36   TexVTXClauseSize = 0;
37   Gen = AMDGPUSubtarget::R600;
38   FP64 = false;
39   CaymanISA = false;
40   EnableIRStructurizer = true;
41   EnableIfCvt = true;
42   WavefrontSize = 0;
43   CFALUBug = false;
44   ParseSubtargetFeatures(GPU, FS);
45   DevName = GPU;
46
47   if (getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) {
48     InstrInfo.reset(new R600InstrInfo(*this));
49   } else {
50     InstrInfo.reset(new SIInstrInfo(*this));
51   }
52 }
53
54 bool
55 AMDGPUSubtarget::is64bit() const  {
56   return Is64bit;
57 }
58 bool
59 AMDGPUSubtarget::hasVertexCache() const {
60   return HasVertexCache;
61 }
62 short
63 AMDGPUSubtarget::getTexVTXClauseSize() const {
64   return TexVTXClauseSize;
65 }
66 enum AMDGPUSubtarget::Generation
67 AMDGPUSubtarget::getGeneration() const {
68   return Gen;
69 }
70 bool
71 AMDGPUSubtarget::hasHWFP64() const {
72   return FP64;
73 }
74 bool
75 AMDGPUSubtarget::hasCaymanISA() const {
76   return CaymanISA;
77 }
78 bool
79 AMDGPUSubtarget::IsIRStructurizerEnabled() const {
80   return EnableIRStructurizer;
81 }
82 bool
83 AMDGPUSubtarget::isIfCvtEnabled() const {
84   return EnableIfCvt;
85 }
86 unsigned
87 AMDGPUSubtarget::getWavefrontSize() const {
88   return WavefrontSize;
89 }
90 unsigned
91 AMDGPUSubtarget::getStackEntrySize() const {
92   assert(getGeneration() <= NORTHERN_ISLANDS);
93   switch(getWavefrontSize()) {
94   case 16:
95     return 8;
96   case 32:
97     if (hasCaymanISA())
98       return 4;
99     else
100       return 8;
101   case 64:
102     return 4;
103   default:
104     llvm_unreachable("Illegal wavefront size.");
105   }
106 }
107 bool
108 AMDGPUSubtarget::hasCFAluBug() const {
109   assert(getGeneration() <= NORTHERN_ISLANDS);
110   return CFALUBug;
111 }
112 bool
113 AMDGPUSubtarget::isTargetELF() const {
114   return false;
115 }
116
117 std::string
118 AMDGPUSubtarget::getDeviceName() const {
119   return DevName;
120 }