blob: 4fd43905b210c92845a39053659f6f5f2152dd19 [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 Stellard880a80a2014-06-17 16:53:14 +000044 LocalMemorySize = 0;
Tom Stellard75aadc22012-12-11 21:25:42 +000045 ParseSubtargetFeatures(GPU, FS);
46 DevName = GPU;
Tom Stellard2e59a452014-06-13 01:32:00 +000047
48 if (getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) {
49 InstrInfo.reset(new R600InstrInfo(*this));
50 } else {
51 InstrInfo.reset(new SIInstrInfo(*this));
52 }
Tom Stellard75aadc22012-12-11 21:25:42 +000053}
54
Tom Stellard75aadc22012-12-11 21:25:42 +000055bool
56AMDGPUSubtarget::is64bit() const {
57 return Is64bit;
58}
59bool
Vincent Lejeunec2991642013-04-30 00:13:39 +000060AMDGPUSubtarget::hasVertexCache() const {
61 return HasVertexCache;
62}
Vincent Lejeunef9f4e1e2013-05-17 16:49:55 +000063short
64AMDGPUSubtarget::getTexVTXClauseSize() const {
65 return TexVTXClauseSize;
66}
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000067enum AMDGPUSubtarget::Generation
68AMDGPUSubtarget::getGeneration() const {
69 return Gen;
70}
71bool
72AMDGPUSubtarget::hasHWFP64() const {
73 return FP64;
74}
75bool
76AMDGPUSubtarget::hasCaymanISA() const {
77 return CaymanISA;
78}
Vincent Lejeunec2991642013-04-30 00:13:39 +000079bool
Tom Stellarded0ceec2013-10-10 17:11:12 +000080AMDGPUSubtarget::IsIRStructurizerEnabled() const {
81 return EnableIRStructurizer;
82}
83bool
Tom Stellard783893a2013-11-18 19:43:33 +000084AMDGPUSubtarget::isIfCvtEnabled() const {
85 return EnableIfCvt;
86}
Tom Stellard8c347b02014-01-22 21:55:40 +000087unsigned
88AMDGPUSubtarget::getWavefrontSize() const {
89 return WavefrontSize;
90}
Tom Stellarda40f9712014-01-22 21:55:43 +000091unsigned
92AMDGPUSubtarget::getStackEntrySize() const {
93 assert(getGeneration() <= NORTHERN_ISLANDS);
94 switch(getWavefrontSize()) {
95 case 16:
96 return 8;
97 case 32:
98 if (hasCaymanISA())
99 return 4;
100 else
101 return 8;
102 case 64:
103 return 4;
104 default:
105 llvm_unreachable("Illegal wavefront size.");
106 }
107}
Tom Stellard783893a2013-11-18 19:43:33 +0000108bool
Tom Stellard348273d2014-01-23 16:18:02 +0000109AMDGPUSubtarget::hasCFAluBug() const {
110 assert(getGeneration() <= NORTHERN_ISLANDS);
111 return CFALUBug;
112}
Tom Stellard880a80a2014-06-17 16:53:14 +0000113int
114AMDGPUSubtarget::getLocalMemorySize() const {
115 return LocalMemorySize;
116}
Tom Stellard348273d2014-01-23 16:18:02 +0000117bool
Tom Stellard75aadc22012-12-11 21:25:42 +0000118AMDGPUSubtarget::isTargetELF() const {
119 return false;
120}
Tom Stellard75aadc22012-12-11 21:25:42 +0000121
122std::string
Tom Stellard75aadc22012-12-11 21:25:42 +0000123AMDGPUSubtarget::getDeviceName() const {
124 return DevName;
125}