R600: Add option to disable promote alloca
[oota-llvm.git] / lib / Target / R600 / AMDGPUSubtarget.cpp
1 //===-- 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 #include "R600InstrInfo.h"
17 #include "SIInstrInfo.h"
18
19 #include "llvm/ADT/SmallString.h"
20
21 using namespace llvm;
22
23 #define DEBUG_TYPE "amdgpu-subtarget"
24
25 #define GET_SUBTARGETINFO_ENUM
26 #define GET_SUBTARGETINFO_TARGET_DESC
27 #define GET_SUBTARGETINFO_CTOR
28 #include "AMDGPUGenSubtargetInfo.inc"
29
30 AMDGPUSubtarget::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),
42   EnablePromoteAlloca(false),
43   EnableIfCvt(true),
44   WavefrontSize(0),
45   CFALUBug(false),
46   LocalMemorySize(0),
47   InstrItins(getInstrItineraryForCPU(GPU)) {
48
49   SmallString<256> FullFS("+promote-alloca,");
50   FullFS += FS;
51
52   ParseSubtargetFeatures(GPU, FullFS);
53
54   if (getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) {
55     InstrInfo.reset(new R600InstrInfo(*this));
56   } else {
57     InstrInfo.reset(new SIInstrInfo(*this));
58   }
59 }
60
61 unsigned AMDGPUSubtarget::getStackEntrySize() const {
62   assert(getGeneration() <= NORTHERN_ISLANDS);
63   switch(getWavefrontSize()) {
64   case 16:
65     return 8;
66   case 32:
67     return hasCaymanISA() ? 4 : 8;
68   case 64:
69     return 4;
70   default:
71     llvm_unreachable("Illegal wavefront size.");
72   }
73 }