blob: 348d50f93f420dc2456965a92e26ed72dd71d227 [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"
Tom Stellard2e59a452014-06-13 01:32:00 +000016#include "R600InstrInfo.h"
17#include "SIInstrInfo.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000018
19using namespace llvm;
20
Chandler Carruthe96dd892014-04-21 22:55:11 +000021#define DEBUG_TYPE "amdgpu-subtarget"
22
Tom Stellard75aadc22012-12-11 21:25:42 +000023#define GET_SUBTARGETINFO_ENUM
24#define GET_SUBTARGETINFO_TARGET_DESC
25#define GET_SUBTARGETINFO_CTOR
26#include "AMDGPUGenSubtargetInfo.inc"
27
28AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) :
29 AMDGPUGenSubtargetInfo(TT, CPU, FS), DumpCode(false) {
30 InstrItins = getInstrItineraryForCPU(CPU);
31
Tom Stellard75aadc22012-12-11 21:25:42 +000032 // Default card
33 StringRef GPU = CPU;
34 Is64bit = false;
Vincent Lejeunec2991642013-04-30 00:13:39 +000035 HasVertexCache = false;
Tom Stellard3498e4f2013-06-07 20:28:55 +000036 TexVTXClauseSize = 0;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000037 Gen = AMDGPUSubtarget::R600;
38 FP64 = false;
39 CaymanISA = false;
Tom Stellard66df8a22013-11-18 19:43:44 +000040 EnableIRStructurizer = true;
Tom Stellard783893a2013-11-18 19:43:33 +000041 EnableIfCvt = true;
Tom Stellard8c347b02014-01-22 21:55:40 +000042 WavefrontSize = 0;
Tom Stellard348273d2014-01-23 16:18:02 +000043 CFALUBug = false;
Tom Stellard75aadc22012-12-11 21:25:42 +000044 ParseSubtargetFeatures(GPU, FS);
45 DevName = GPU;
Tom Stellard2e59a452014-06-13 01:32:00 +000046
47 if (getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) {
48 InstrInfo.reset(new R600InstrInfo(*this));
49 } else {
50 InstrInfo.reset(new SIInstrInfo(*this));
51 }
Tom Stellard75aadc22012-12-11 21:25:42 +000052}
53
Tom Stellard75aadc22012-12-11 21:25:42 +000054bool
55AMDGPUSubtarget::is64bit() const {
56 return Is64bit;
57}
58bool
Vincent Lejeunec2991642013-04-30 00:13:39 +000059AMDGPUSubtarget::hasVertexCache() const {
60 return HasVertexCache;
61}
Vincent Lejeunef9f4e1e2013-05-17 16:49:55 +000062short
63AMDGPUSubtarget::getTexVTXClauseSize() const {
64 return TexVTXClauseSize;
65}
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000066enum AMDGPUSubtarget::Generation
67AMDGPUSubtarget::getGeneration() const {
68 return Gen;
69}
70bool
71AMDGPUSubtarget::hasHWFP64() const {
72 return FP64;
73}
74bool
75AMDGPUSubtarget::hasCaymanISA() const {
76 return CaymanISA;
77}
Vincent Lejeunec2991642013-04-30 00:13:39 +000078bool
Tom Stellarded0ceec2013-10-10 17:11:12 +000079AMDGPUSubtarget::IsIRStructurizerEnabled() const {
80 return EnableIRStructurizer;
81}
82bool
Tom Stellard783893a2013-11-18 19:43:33 +000083AMDGPUSubtarget::isIfCvtEnabled() const {
84 return EnableIfCvt;
85}
Tom Stellard8c347b02014-01-22 21:55:40 +000086unsigned
87AMDGPUSubtarget::getWavefrontSize() const {
88 return WavefrontSize;
89}
Tom Stellarda40f9712014-01-22 21:55:43 +000090unsigned
91AMDGPUSubtarget::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}
Tom Stellard783893a2013-11-18 19:43:33 +0000107bool
Tom Stellard348273d2014-01-23 16:18:02 +0000108AMDGPUSubtarget::hasCFAluBug() const {
109 assert(getGeneration() <= NORTHERN_ISLANDS);
110 return CFALUBug;
111}
112bool
Tom Stellard75aadc22012-12-11 21:25:42 +0000113AMDGPUSubtarget::isTargetELF() const {
114 return false;
115}
Tom Stellard75aadc22012-12-11 21:25:42 +0000116
117std::string
Tom Stellard75aadc22012-12-11 21:25:42 +0000118AMDGPUSubtarget::getDeviceName() const {
119 return DevName;
120}