Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 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" |
Eric Christopher | ac4b69e | 2014-07-25 22:22:39 +0000 | [diff] [blame] | 16 | #include "R600ISelLowering.h" |
Tom Stellard | 2e59a45 | 2014-06-13 01:32:00 +0000 | [diff] [blame] | 17 | #include "R600InstrInfo.h" |
Eric Christopher | ac4b69e | 2014-07-25 22:22:39 +0000 | [diff] [blame] | 18 | #include "R600MachineScheduler.h" |
Tom Stellard | 2e59a45 | 2014-06-13 01:32:00 +0000 | [diff] [blame] | 19 | #include "SIInstrInfo.h" |
Eric Christopher | ac4b69e | 2014-07-25 22:22:39 +0000 | [diff] [blame] | 20 | #include "SIISelLowering.h" |
Matt Arsenault | f171cf2 | 2014-07-14 23:40:49 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/SmallString.h" |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 22 | |
Matt Arsenault | d9a23ab | 2014-07-13 02:08:26 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/SmallString.h" |
| 24 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 25 | using namespace llvm; |
| 26 | |
Chandler Carruth | e96dd89 | 2014-04-21 22:55:11 +0000 | [diff] [blame] | 27 | #define DEBUG_TYPE "amdgpu-subtarget" |
| 28 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 29 | #define GET_SUBTARGETINFO_ENUM |
| 30 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 31 | #define GET_SUBTARGETINFO_CTOR |
| 32 | #include "AMDGPUGenSubtargetInfo.inc" |
| 33 | |
Eric Christopher | ac4b69e | 2014-07-25 22:22:39 +0000 | [diff] [blame] | 34 | static std::string computeDataLayout(const AMDGPUSubtarget &ST) { |
| 35 | std::string Ret = "e-p:32:32"; |
| 36 | |
| 37 | if (ST.is64bit()) { |
Matt Arsenault | 515c24b | 2014-08-06 00:44:25 +0000 | [diff] [blame] | 38 | // 32-bit private, local, and region pointers. 64-bit global and constant. |
Eric Christopher | ac4b69e | 2014-07-25 22:22:39 +0000 | [diff] [blame] | 39 | Ret += "-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p24:64:64"; |
| 40 | } |
| 41 | |
| 42 | Ret += "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256" |
| 43 | "-v512:512-v1024:1024-v2048:2048-n32:64"; |
| 44 | |
| 45 | return Ret; |
| 46 | } |
| 47 | |
| 48 | AMDGPUSubtarget & |
| 49 | AMDGPUSubtarget::initializeSubtargetDependencies(StringRef GPU, StringRef FS) { |
| 50 | // Determine default and user-specified characteristics |
Matt Arsenault | f171cf2 | 2014-07-14 23:40:49 +0000 | [diff] [blame] | 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. |
Matt Arsenault | d9a23ab | 2014-07-13 02:08:26 +0000 | [diff] [blame] | 58 | |
Matt Arsenault | f171cf2 | 2014-07-14 23:40:49 +0000 | [diff] [blame] | 59 | SmallString<256> FullFS("+promote-alloca,+fp64-denormals,"); |
Matt Arsenault | d9a23ab | 2014-07-13 02:08:26 +0000 | [diff] [blame] | 60 | FullFS += FS; |
| 61 | |
| 62 | ParseSubtargetFeatures(GPU, FullFS); |
Tom Stellard | 2e59a45 | 2014-06-13 01:32:00 +0000 | [diff] [blame] | 63 | |
Eric Christopher | ac4b69e | 2014-07-25 22:22:39 +0000 | [diff] [blame] | 64 | // FIXME: I don't think think Evergreen has any useful support for |
| 65 | // denormals, but should be checked. Should we issue a warning somewhere |
| 66 | // if someone tries to enable these? |
Tom Stellard | 2e59a45 | 2014-06-13 01:32:00 +0000 | [diff] [blame] | 67 | if (getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) { |
Matt Arsenault | f171cf2 | 2014-07-14 23:40:49 +0000 | [diff] [blame] | 68 | FP32Denormals = false; |
| 69 | FP64Denormals = false; |
Eric Christopher | ac4b69e | 2014-07-25 22:22:39 +0000 | [diff] [blame] | 70 | } |
| 71 | return *this; |
| 72 | } |
| 73 | |
| 74 | AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef GPU, StringRef FS, |
| 75 | TargetMachine &TM) |
| 76 | : AMDGPUGenSubtargetInfo(TT, GPU, FS), DevName(GPU), Is64bit(false), |
| 77 | DumpCode(false), R600ALUInst(false), HasVertexCache(false), |
| 78 | TexVTXClauseSize(0), Gen(AMDGPUSubtarget::R600), FP64(false), |
| 79 | FP64Denormals(false), FP32Denormals(false), CaymanISA(false), |
Matt Arsenault | 3f98140 | 2014-09-15 15:41:53 +0000 | [diff] [blame] | 80 | FlatAddressSpace(false), EnableIRStructurizer(true), |
| 81 | EnablePromoteAlloca(false), EnableIfCvt(true), |
Matt Arsenault | 4103328 | 2014-10-10 22:01:59 +0000 | [diff] [blame] | 82 | EnableLoadStoreOpt(false), WavefrontSize(0), CFALUBug(false), LocalMemorySize(0), |
Eric Christopher | ac4b69e | 2014-07-25 22:22:39 +0000 | [diff] [blame] | 83 | DL(computeDataLayout(initializeSubtargetDependencies(GPU, FS))), |
| 84 | FrameLowering(TargetFrameLowering::StackGrowsUp, |
| 85 | 64 * 16, // Maximum stack alignment (long16) |
| 86 | 0), |
Tom Stellard | 794c8c0 | 2014-12-02 17:05:41 +0000 | [diff] [blame] | 87 | InstrItins(getInstrItineraryForCPU(GPU)), |
| 88 | TargetTriple(TT) { |
Eric Christopher | ac4b69e | 2014-07-25 22:22:39 +0000 | [diff] [blame] | 89 | if (getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) { |
| 90 | InstrInfo.reset(new R600InstrInfo(*this)); |
| 91 | TLInfo.reset(new R600TargetLowering(TM)); |
Tom Stellard | 2e59a45 | 2014-06-13 01:32:00 +0000 | [diff] [blame] | 92 | } else { |
| 93 | InstrInfo.reset(new SIInstrInfo(*this)); |
Eric Christopher | ac4b69e | 2014-07-25 22:22:39 +0000 | [diff] [blame] | 94 | TLInfo.reset(new SITargetLowering(TM)); |
Tom Stellard | 2e59a45 | 2014-06-13 01:32:00 +0000 | [diff] [blame] | 95 | } |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 96 | } |
| 97 | |
Matt Arsenault | d782d05 | 2014-06-27 17:57:00 +0000 | [diff] [blame] | 98 | unsigned AMDGPUSubtarget::getStackEntrySize() const { |
Tom Stellard | a40f971 | 2014-01-22 21:55:43 +0000 | [diff] [blame] | 99 | assert(getGeneration() <= NORTHERN_ISLANDS); |
| 100 | switch(getWavefrontSize()) { |
| 101 | case 16: |
| 102 | return 8; |
| 103 | case 32: |
Matt Arsenault | d782d05 | 2014-06-27 17:57:00 +0000 | [diff] [blame] | 104 | return hasCaymanISA() ? 4 : 8; |
Tom Stellard | a40f971 | 2014-01-22 21:55:43 +0000 | [diff] [blame] | 105 | case 64: |
| 106 | return 4; |
| 107 | default: |
| 108 | llvm_unreachable("Illegal wavefront size."); |
| 109 | } |
| 110 | } |
Tom Stellard | b8fd6ef | 2014-12-02 22:00:07 +0000 | [diff] [blame^] | 111 | |
| 112 | unsigned AMDGPUSubtarget::getAmdKernelCodeChipID() const { |
| 113 | switch(getGeneration()) { |
| 114 | default: llvm_unreachable("ChipID unknown"); |
| 115 | case SEA_ISLANDS: return 12; |
| 116 | } |
| 117 | } |