LLVM  7.0.0svn
AMDGPUMachineFunction.cpp
Go to the documentation of this file.
1 //===-- AMDGPUMachineFunctionInfo.cpp ---------------------------------------=//
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 #include "AMDGPUMachineFunction.h"
11 #include "AMDGPUSubtarget.h"
12 #include "AMDGPUPerfHintAnalysis.h"
14 
15 using namespace llvm;
16 
19  LocalMemoryObjects(),
20  KernArgSize(0),
21  MaxKernArgAlign(0),
22  LDSSize(0),
23  ABIArgOffset(0),
24  IsEntryFunction(AMDGPU::isEntryFunctionCC(MF.getFunction().getCallingConv())),
25  NoSignedZerosFPMath(MF.getTarget().Options.NoSignedZerosFPMath),
26  MemoryBound(false),
27  WaveLimiter(false) {
28  // FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset,
29  // except reserved size is not correctly aligned.
30 
31  if (auto *Resolver = MF.getMMI().getResolver()) {
32  if (AMDGPUPerfHintAnalysis *PHA = static_cast<AMDGPUPerfHintAnalysis*>(
33  Resolver->getAnalysisIfAvailable(&AMDGPUPerfHintAnalysisID, true))) {
34  MemoryBound = PHA->isMemoryBound(&MF.getFunction());
35  WaveLimiter = PHA->needsWaveLimiter(&MF.getFunction());
36  }
37  }
38 }
39 
41  const GlobalValue &GV) {
42  auto Entry = LocalMemoryObjects.insert(std::make_pair(&GV, 0));
43  if (!Entry.second)
44  return Entry.first->second;
45 
46  unsigned Align = GV.getAlignment();
47  if (Align == 0)
48  Align = DL.getABITypeAlignment(GV.getValueType());
49 
50  /// TODO: We should sort these to minimize wasted space due to alignment
51  /// padding. Currently the padding is decided by the first encountered use
52  /// during lowering.
53  unsigned Offset = LDSSize = alignTo(LDSSize, Align);
54 
55  Entry.first->second = Offset;
57 
58  return Offset;
59 }
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalValue &GV)
AMDGPU specific subclass of TargetSubtarget.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
AMDGPUMachineFunction(const MachineFunction &MF)
MachineModuleInfo & getMMI() const
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Definition: MathExtras.h:685
AnalysisResolver * getResolver() const
Definition: Pass.h:140
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
unsigned getAlignment() const
Definition: Globals.cpp:97
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:1774
bool isEntryFunctionCC(CallingConv::ID CC)
char & AMDGPUPerfHintAnalysisID
unsigned LDSSize
Number of bytes in the LDS that are being used.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
Definition: DataLayout.cpp:722
const Function & getFunction() const
Return the LLVM function that this machine code represents.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Definition: DataLayout.h:428
Type * getValueType() const
Definition: GlobalValue.h:275
Analyzes if a function potentially memory bound and if a kernel kernel may benefit from limiting numb...