blob: 9c78f35df3e246f0f537b26a8d29aea6e7c13863 [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//=====-- AMDGPUSubtarget.h - Define Subtarget for the AMDIL ---*- C++ -*-====//
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 AMDGPU specific subclass of TargetSubtarget.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef AMDGPUSUBTARGET_H
16#define AMDGPUSUBTARGET_H
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000017#include "AMDGPU.h"
Tom Stellard2e59a452014-06-13 01:32:00 +000018#include "AMDGPUInstrInfo.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000019#include "llvm/ADT/StringExtras.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/Target/TargetSubtargetInfo.h"
22
23#define GET_SUBTARGETINFO_HEADER
24#include "AMDGPUGenSubtargetInfo.inc"
25
26#define MAX_CB_SIZE (1 << 16)
27
28namespace llvm {
29
30class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
Tom Stellard2e59a452014-06-13 01:32:00 +000031
32 std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
33
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000034public:
35 enum Generation {
36 R600 = 0,
37 R700,
38 EVERGREEN,
39 NORTHERN_ISLANDS,
Tom Stellard6e1ee472013-10-29 16:37:28 +000040 SOUTHERN_ISLANDS,
41 SEA_ISLANDS
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000042 };
43
Tom Stellard75aadc22012-12-11 21:25:42 +000044private:
Tom Stellard75aadc22012-12-11 21:25:42 +000045 std::string DevName;
46 bool Is64bit;
47 bool Is32on64bit;
48 bool DumpCode;
49 bool R600ALUInst;
Vincent Lejeunec2991642013-04-30 00:13:39 +000050 bool HasVertexCache;
Vincent Lejeunef9f4e1e2013-05-17 16:49:55 +000051 short TexVTXClauseSize;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000052 enum Generation Gen;
53 bool FP64;
54 bool CaymanISA;
Tom Stellarded0ceec2013-10-10 17:11:12 +000055 bool EnableIRStructurizer;
Tom Stellard783893a2013-11-18 19:43:33 +000056 bool EnableIfCvt;
Tom Stellard8c347b02014-01-22 21:55:40 +000057 unsigned WavefrontSize;
Tom Stellard348273d2014-01-23 16:18:02 +000058 bool CFALUBug;
Tom Stellard880a80a2014-06-17 16:53:14 +000059 int LocalMemorySize;
Tom Stellard75aadc22012-12-11 21:25:42 +000060
61 InstrItineraryData InstrItins;
62
63public:
64 AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +000065
Tom Stellard2e59a452014-06-13 01:32:00 +000066 const AMDGPUInstrInfo *getInstrInfo() const {
67 return InstrInfo.get();
68 }
Tom Stellard75aadc22012-12-11 21:25:42 +000069 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
Craig Topperee7b0f32014-04-30 05:53:27 +000070 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +000071
Tom Stellard75aadc22012-12-11 21:25:42 +000072 bool is64bit() const;
Vincent Lejeunec2991642013-04-30 00:13:39 +000073 bool hasVertexCache() const;
Vincent Lejeunef9f4e1e2013-05-17 16:49:55 +000074 short getTexVTXClauseSize() const;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000075 enum Generation getGeneration() const;
76 bool hasHWFP64() const;
77 bool hasCaymanISA() const;
Matt Arsenaultfae02982014-03-17 18:58:11 +000078
79 bool hasBFE() const {
80 return (getGeneration() >= EVERGREEN);
81 }
82
Matt Arsenault6e439652014-06-10 19:00:20 +000083 bool hasBFI() const {
84 return (getGeneration() >= EVERGREEN);
85 }
86
Matt Arsenaultfae02982014-03-17 18:58:11 +000087 bool hasBFM() const {
88 return hasBFE();
89 }
90
Matt Arsenault60425062014-06-10 19:18:28 +000091 bool hasBCNT(unsigned Size) const {
92 if (Size == 32)
93 return (getGeneration() >= EVERGREEN);
94
95 assert(Size == 64);
96 return (getGeneration() >= SOUTHERN_ISLANDS);
97 }
98
Tom Stellard50122a52014-04-07 19:45:41 +000099 bool hasMulU24() const {
100 return (getGeneration() >= EVERGREEN);
101 }
102
103 bool hasMulI24() const {
104 return (getGeneration() >= SOUTHERN_ISLANDS ||
105 hasCaymanISA());
106 }
107
Tom Stellarded0ceec2013-10-10 17:11:12 +0000108 bool IsIRStructurizerEnabled() const;
Tom Stellard783893a2013-11-18 19:43:33 +0000109 bool isIfCvtEnabled() const;
Tom Stellard8c347b02014-01-22 21:55:40 +0000110 unsigned getWavefrontSize() const;
Tom Stellarda40f9712014-01-22 21:55:43 +0000111 unsigned getStackEntrySize() const;
Tom Stellard348273d2014-01-23 16:18:02 +0000112 bool hasCFAluBug() const;
Tom Stellard880a80a2014-06-17 16:53:14 +0000113 int getLocalMemorySize() const;
Tom Stellard75aadc22012-12-11 21:25:42 +0000114
Craig Topper5656db42014-04-29 07:57:24 +0000115 bool enableMachineScheduler() const override {
Andrew Trick978674b2013-09-20 05:14:41 +0000116 return getGeneration() <= NORTHERN_ISLANDS;
117 }
118
Tom Stellard75aadc22012-12-11 21:25:42 +0000119 // Helper functions to simplify if statements
120 bool isTargetELF() const;
Tom Stellard75aadc22012-12-11 21:25:42 +0000121 std::string getDeviceName() const;
Tom Stellard75aadc22012-12-11 21:25:42 +0000122 bool dumpCode() const { return DumpCode; }
123 bool r600ALUEncoding() const { return R600ALUInst; }
124
125};
126
127} // End namespace llvm
128
129#endif // AMDGPUSUBTARGET_H