LLVM  9.0.0svn
AMDGPUMachineFunction.cpp
Go to the documentation of this file.
1 //===-- AMDGPUMachineFunctionInfo.cpp ---------------------------------------=//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include "AMDGPUSubtarget.h"
11 #include "AMDGPUPerfHintAnalysis.h"
13 
14 using namespace llvm;
15 
18  LocalMemoryObjects(),
19  ExplicitKernArgSize(0),
20  MaxKernArgAlign(0),
21  LDSSize(0),
22  IsEntryFunction(AMDGPU::isEntryFunctionCC(MF.getFunction().getCallingConv())),
23  NoSignedZerosFPMath(MF.getTarget().Options.NoSignedZerosFPMath),
24  MemoryBound(false),
25  WaveLimiter(false) {
27 
28  // FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset,
29  // except reserved size is not correctly aligned.
30  const Function &F = MF.getFunction();
31 
32  if (auto *Resolver = MF.getMMI().getResolver()) {
33  if (AMDGPUPerfHintAnalysis *PHA = static_cast<AMDGPUPerfHintAnalysis*>(
34  Resolver->getAnalysisIfAvailable(&AMDGPUPerfHintAnalysisID, true))) {
35  MemoryBound = PHA->isMemoryBound(&F);
36  WaveLimiter = PHA->needsWaveLimiter(&F);
37  }
38  }
39 
43 }
44 
46  const GlobalValue &GV) {
47  auto Entry = LocalMemoryObjects.insert(std::make_pair(&GV, 0));
48  if (!Entry.second)
49  return Entry.first->second;
50 
51  unsigned Align = GV.getAlignment();
52  if (Align == 0)
53  Align = DL.getABITypeAlignment(GV.getValueType());
54 
55  /// TODO: We should sort these to minimize wasted space due to alignment
56  /// padding. Currently the padding is decided by the first encountered use
57  /// during lowering.
58  unsigned Offset = LDSSize = alignTo(LDSSize, Align);
59 
60  Entry.first->second = Offset;
62 
63  return Offset;
64 }
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:110
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:23
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:684
AnalysisResolver * getResolver() const
Definition: Pass.h:139
SPIR_KERNEL - Calling convention for SPIR kernel functions.
Definition: CallingConv.h:136
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
static const AMDGPUSubtarget & get(const MachineFunction &MF)
uint64_t getExplicitKernArgSize(const Function &F, unsigned &MaxAlign) const
unsigned getAlignment() const
Definition: Globals.cpp:96
static Function * getFunction(Constant *C)
Definition: Evaluator.cpp:220
Calling convention for AMDGPU code object kernels.
Definition: CallingConv.h:200
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:1854
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:212
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
Definition: DataLayout.cpp:749
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:461
Type * getValueType() const
Definition: GlobalValue.h:275
Analyzes if a function potentially memory bound and if a kernel kernel may benefit from limiting numb...