blob: fc34eef7fd28a85c78638a88c363d7c4f0cac9e8 [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//===-- 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
17using namespace llvm;
18
Chandler Carruthe96dd892014-04-21 22:55:11 +000019#define DEBUG_TYPE "amdgpu-subtarget"
20
Tom Stellard75aadc22012-12-11 21:25:42 +000021#define GET_SUBTARGETINFO_ENUM
22#define GET_SUBTARGETINFO_TARGET_DESC
23#define GET_SUBTARGETINFO_CTOR
24#include "AMDGPUGenSubtargetInfo.inc"
25
26AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) :
27 AMDGPUGenSubtargetInfo(TT, CPU, FS), DumpCode(false) {
28 InstrItins = getInstrItineraryForCPU(CPU);
29
Tom Stellard75aadc22012-12-11 21:25:42 +000030 // Default card
31 StringRef GPU = CPU;
32 Is64bit = false;
33 DefaultSize[0] = 64;
34 DefaultSize[1] = 1;
35 DefaultSize[2] = 1;
Vincent Lejeunec2991642013-04-30 00:13:39 +000036 HasVertexCache = false;
Tom Stellard3498e4f2013-06-07 20:28:55 +000037 TexVTXClauseSize = 0;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000038 Gen = AMDGPUSubtarget::R600;
39 FP64 = false;
40 CaymanISA = false;
Tom Stellard66df8a22013-11-18 19:43:44 +000041 EnableIRStructurizer = true;
Tom Stellard783893a2013-11-18 19:43:33 +000042 EnableIfCvt = true;
Tom Stellard8c347b02014-01-22 21:55:40 +000043 WavefrontSize = 0;
Tom Stellard348273d2014-01-23 16:18:02 +000044 CFALUBug = false;
Tom Stellard75aadc22012-12-11 21:25:42 +000045 ParseSubtargetFeatures(GPU, FS);
46 DevName = GPU;
Tom Stellard75aadc22012-12-11 21:25:42 +000047}
48
Tom Stellard75aadc22012-12-11 21:25:42 +000049bool
50AMDGPUSubtarget::is64bit() const {
51 return Is64bit;
52}
53bool
Vincent Lejeunec2991642013-04-30 00:13:39 +000054AMDGPUSubtarget::hasVertexCache() const {
55 return HasVertexCache;
56}
Vincent Lejeunef9f4e1e2013-05-17 16:49:55 +000057short
58AMDGPUSubtarget::getTexVTXClauseSize() const {
59 return TexVTXClauseSize;
60}
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000061enum AMDGPUSubtarget::Generation
62AMDGPUSubtarget::getGeneration() const {
63 return Gen;
64}
65bool
66AMDGPUSubtarget::hasHWFP64() const {
67 return FP64;
68}
69bool
70AMDGPUSubtarget::hasCaymanISA() const {
71 return CaymanISA;
72}
Vincent Lejeunec2991642013-04-30 00:13:39 +000073bool
Tom Stellarded0ceec2013-10-10 17:11:12 +000074AMDGPUSubtarget::IsIRStructurizerEnabled() const {
75 return EnableIRStructurizer;
76}
77bool
Tom Stellard783893a2013-11-18 19:43:33 +000078AMDGPUSubtarget::isIfCvtEnabled() const {
79 return EnableIfCvt;
80}
Tom Stellard8c347b02014-01-22 21:55:40 +000081unsigned
82AMDGPUSubtarget::getWavefrontSize() const {
83 return WavefrontSize;
84}
Tom Stellarda40f9712014-01-22 21:55:43 +000085unsigned
86AMDGPUSubtarget::getStackEntrySize() const {
87 assert(getGeneration() <= NORTHERN_ISLANDS);
88 switch(getWavefrontSize()) {
89 case 16:
90 return 8;
91 case 32:
92 if (hasCaymanISA())
93 return 4;
94 else
95 return 8;
96 case 64:
97 return 4;
98 default:
99 llvm_unreachable("Illegal wavefront size.");
100 }
101}
Tom Stellard783893a2013-11-18 19:43:33 +0000102bool
Tom Stellard348273d2014-01-23 16:18:02 +0000103AMDGPUSubtarget::hasCFAluBug() const {
104 assert(getGeneration() <= NORTHERN_ISLANDS);
105 return CFALUBug;
106}
107bool
Tom Stellard75aadc22012-12-11 21:25:42 +0000108AMDGPUSubtarget::isTargetELF() const {
109 return false;
110}
111size_t
112AMDGPUSubtarget::getDefaultSize(uint32_t dim) const {
Eric Christopher99952a02013-12-06 02:45:24 +0000113 if (dim > 2) {
Tom Stellard75aadc22012-12-11 21:25:42 +0000114 return 1;
115 } else {
116 return DefaultSize[dim];
117 }
118}
119
120std::string
Tom Stellard75aadc22012-12-11 21:25:42 +0000121AMDGPUSubtarget::getDeviceName() const {
122 return DevName;
123}