R600: Add denormal handling subtarget features.
[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 #include "llvm/ADT/SmallString.h"
19
20 #include "llvm/ADT/SmallString.h"
21
22 using namespace llvm;
23
24 #define DEBUG_TYPE "amdgpu-subtarget"
25
26 #define GET_SUBTARGETINFO_ENUM
27 #define GET_SUBTARGETINFO_TARGET_DESC
28 #define GET_SUBTARGETINFO_CTOR
29 #include "AMDGPUGenSubtargetInfo.inc"
30
31 AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef GPU, StringRef FS) :
32   AMDGPUGenSubtargetInfo(TT, GPU, FS),
33   DevName(GPU),
34   Is64bit(false),
35   DumpCode(false),
36   R600ALUInst(false),
37   HasVertexCache(false),
38   TexVTXClauseSize(0),
39   Gen(AMDGPUSubtarget::R600),
40   FP64(false),
41   FP64Denormals(false),
42   FP32Denormals(false),
43   CaymanISA(false),
44   EnableIRStructurizer(true),
45   EnablePromoteAlloca(false),
46   EnableIfCvt(true),
47   WavefrontSize(0),
48   CFALUBug(false),
49   LocalMemorySize(0),
50   InstrItins(getInstrItineraryForCPU(GPU)) {
51   // On SI+, we want FP64 denormals to be on by default. FP32 denormals can be
52   // enabled, but some instructions do not respect them and they run at the
53   // double precision rate, so don't enable by default.
54   //
55   // We want to be able to turn these off, but making this a subtarget feature
56   // for SI has the unhelpful behavior that it unsets everything else if you
57   // disable it.
58
59   SmallString<256> FullFS("+promote-alloca,+fp64-denormals,");
60   FullFS += FS;
61
62   ParseSubtargetFeatures(GPU, FullFS);
63
64   if (getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) {
65     InstrInfo.reset(new R600InstrInfo(*this));
66
67     // FIXME: I don't think think Evergreen has any useful support for
68     // denormals, but should be checked. Should we issue a warning somewhere if
69     // someone tries to enable these?
70     FP32Denormals = false;
71     FP64Denormals = false;
72   } else {
73     InstrInfo.reset(new SIInstrInfo(*this));
74   }
75 }
76
77 unsigned AMDGPUSubtarget::getStackEntrySize() const {
78   assert(getGeneration() <= NORTHERN_ISLANDS);
79   switch(getWavefrontSize()) {
80   case 16:
81     return 8;
82   case 32:
83     return hasCaymanISA() ? 4 : 8;
84   case 64:
85     return 4;
86   default:
87     llvm_unreachable("Illegal wavefront size.");
88   }
89 }