LLVM  8.0.1
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  ExplicitKernArgSize(0),
21  MaxKernArgAlign(0),
22  LDSSize(0),
23  IsEntryFunction(AMDGPU::isEntryFunctionCC(MF.getFunction().getCallingConv())),
24  NoSignedZerosFPMath(MF.getTarget().Options.NoSignedZerosFPMath),
25  MemoryBound(false),
26  WaveLimiter(false) {
28 
29  // FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset,
30  // except reserved size is not correctly aligned.
31  const Function &F = MF.getFunction();
32 
33  if (auto *Resolver = MF.getMMI().getResolver()) {
34  if (AMDGPUPerfHintAnalysis *PHA = static_cast<AMDGPUPerfHintAnalysis*>(
35  Resolver->getAnalysisIfAvailable(&AMDGPUPerfHintAnalysisID, true))) {
36  MemoryBound = PHA->isMemoryBound(&F);
37  WaveLimiter = PHA->needsWaveLimiter(&F);
38  }
39  }
40 
44 }
45 
47  const GlobalValue &GV) {
48  auto Entry = LocalMemoryObjects.insert(std::make_pair(&GV, 0));
49  if (!Entry.second)
50  return Entry.first->second;
51 
52  unsigned Align = GV.getAlignment();
53  if (Align == 0)
54  Align = DL.getABITypeAlignment(GV.getValueType());
55 
56  /// TODO: We should sort these to minimize wasted space due to alignment
57  /// padding. Currently the padding is decided by the first encountered use
58  /// during lowering.
59  unsigned Offset = LDSSize = alignTo(LDSSize, Align);
60 
61  Entry.first->second = Offset;
63 
64  return Offset;
65 }
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.
This class represents lattice values for constants.
Definition: AllocatorList.h:24
AMDGPUMachineFunction(const MachineFunction &MF)
F(f)
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...
static const AMDGPUSubtarget & get(const MachineFunction &MF)
SPIR_KERNEL - Calling convention for SPIR kernel functions.
Definition: CallingConv.h:137
uint64_t getExplicitKernArgSize(const Function &F, unsigned &MaxAlign) const
unsigned getAlignment() const
Definition: Globals.cpp:97
static Function * getFunction(Constant *C)
Definition: Evaluator.cpp:221
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.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:213
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
Definition: DataLayout.cpp:730
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:436
Type * getValueType() const
Definition: GlobalValue.h:276
Analyzes if a function potentially memory bound and if a kernel kernel may benefit from limiting numb...
Calling convention for AMDGPU code object kernels.
Definition: CallingConv.h:201