blob: d5203611756ff710181f04469972ed4985c57a8d [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
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +000019#include "llvm/ADT/SmallString.h"
20
Tom Stellard75aadc22012-12-11 21:25:42 +000021using namespace llvm;
22
Chandler Carruthe96dd892014-04-21 22:55:11 +000023#define DEBUG_TYPE "amdgpu-subtarget"
24
Tom Stellard75aadc22012-12-11 21:25:42 +000025#define GET_SUBTARGETINFO_ENUM
26#define GET_SUBTARGETINFO_TARGET_DESC
27#define GET_SUBTARGETINFO_CTOR
28#include "AMDGPUGenSubtargetInfo.inc"
29
Matt Arsenaultd782d052014-06-27 17:57:00 +000030AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef GPU, StringRef FS) :
31 AMDGPUGenSubtargetInfo(TT, GPU, FS),
32 DevName(GPU),
33 Is64bit(false),
34 DumpCode(false),
35 R600ALUInst(false),
36 HasVertexCache(false),
37 TexVTXClauseSize(0),
38 Gen(AMDGPUSubtarget::R600),
39 FP64(false),
40 CaymanISA(false),
41 EnableIRStructurizer(true),
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +000042 EnablePromoteAlloca(false),
Matt Arsenaultd782d052014-06-27 17:57:00 +000043 EnableIfCvt(true),
44 WavefrontSize(0),
45 CFALUBug(false),
46 LocalMemorySize(0),
47 InstrItins(getInstrItineraryForCPU(GPU)) {
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +000048
49 SmallString<256> FullFS("+promote-alloca,");
50 FullFS += FS;
51
52 ParseSubtargetFeatures(GPU, FullFS);
Tom Stellard2e59a452014-06-13 01:32:00 +000053
54 if (getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) {
55 InstrInfo.reset(new R600InstrInfo(*this));
56 } else {
57 InstrInfo.reset(new SIInstrInfo(*this));
58 }
Tom Stellard75aadc22012-12-11 21:25:42 +000059}
60
Matt Arsenaultd782d052014-06-27 17:57:00 +000061unsigned AMDGPUSubtarget::getStackEntrySize() const {
Tom Stellarda40f9712014-01-22 21:55:43 +000062 assert(getGeneration() <= NORTHERN_ISLANDS);
63 switch(getWavefrontSize()) {
64 case 16:
65 return 8;
66 case 32:
Matt Arsenaultd782d052014-06-27 17:57:00 +000067 return hasCaymanISA() ? 4 : 8;
Tom Stellarda40f9712014-01-22 21:55:43 +000068 case 64:
69 return 4;
70 default:
71 llvm_unreachable("Illegal wavefront size.");
72 }
73}