2016-03-11 16:00:27 +08:00
|
|
|
//===-- AMDGPUMachineFunctionInfo.h -------------------------------*- C++ -*-=//
|
2013-04-02 05:47:53 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-04-02 05:47:53 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-03-11 16:00:27 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEFUNCTION_H
|
|
|
|
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEFUNCTION_H
|
2013-04-02 05:47:53 +08:00
|
|
|
|
[amdgpu] Add codegen support for HIP dynamic shared memory.
Summary:
- HIP uses an unsized extern array `extern __shared__ T s[]` to declare
the dynamic shared memory, which size is not known at the
compile time.
Reviewers: arsenm, yaxunl, kpyzhov, b-sumner
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, dstuttard, tpr, t-tye, hiraditya, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82496
2020-06-25 00:13:10 +08:00
|
|
|
#include "Utils/AMDGPUBaseInfo.h"
|
2016-07-27 00:45:58 +08:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
[amdgpu] Add codegen support for HIP dynamic shared memory.
Summary:
- HIP uses an unsized extern array `extern __shared__ T s[]` to declare
the dynamic shared memory, which size is not known at the
compile time.
Reviewers: arsenm, yaxunl, kpyzhov, b-sumner
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, dstuttard, tpr, t-tye, hiraditya, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82496
2020-06-25 00:13:10 +08:00
|
|
|
#include "llvm/Support/Alignment.h"
|
2013-04-02 05:47:53 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2018-07-12 04:59:01 +08:00
|
|
|
class GCNSubtarget;
|
2018-06-28 18:18:55 +08:00
|
|
|
|
2013-04-02 05:47:53 +08:00
|
|
|
class AMDGPUMachineFunction : public MachineFunctionInfo {
|
2016-07-27 00:45:58 +08:00
|
|
|
/// A map to keep track of local memory objects and their offsets within the
|
|
|
|
/// local memory space.
|
|
|
|
SmallDenseMap<const GlobalValue *, unsigned, 4> LocalMemoryObjects;
|
|
|
|
|
2018-05-30 03:35:00 +08:00
|
|
|
protected:
|
2020-05-20 01:44:14 +08:00
|
|
|
uint64_t ExplicitKernArgSize = 0; // Cache for this.
|
2019-10-15 20:56:24 +08:00
|
|
|
Align MaxKernArgAlign; // Cache for this.
|
2016-06-18 13:15:53 +08:00
|
|
|
|
2016-07-27 00:45:58 +08:00
|
|
|
/// Number of bytes in the LDS that are being used.
|
2020-05-20 01:44:14 +08:00
|
|
|
unsigned LDSSize = 0;
|
2016-07-27 00:45:58 +08:00
|
|
|
|
[amdgpu] Add codegen support for HIP dynamic shared memory.
Summary:
- HIP uses an unsized extern array `extern __shared__ T s[]` to declare
the dynamic shared memory, which size is not known at the
compile time.
Reviewers: arsenm, yaxunl, kpyzhov, b-sumner
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, dstuttard, tpr, t-tye, hiraditya, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82496
2020-06-25 00:13:10 +08:00
|
|
|
/// Number of bytes in the LDS allocated statically. This field is only used
|
|
|
|
/// in the instruction selector and not part of the machine function info.
|
|
|
|
unsigned StaticLDSSize = 0;
|
|
|
|
|
|
|
|
/// Align for dynamic shared memory if any. Dynamic shared memory is
|
|
|
|
/// allocated directly after the static one, i.e., LDSSize. Need to pad
|
|
|
|
/// LDSSize to ensure that dynamic one is aligned accordingly.
|
|
|
|
/// The maximal alignment is updated during IR translation or lowering
|
|
|
|
/// stages.
|
|
|
|
Align DynLDSAlign;
|
|
|
|
|
2019-11-01 09:50:30 +08:00
|
|
|
// State of MODE register, assumed FP mode.
|
|
|
|
AMDGPU::SIModeRegisterDefaults Mode;
|
|
|
|
|
2018-04-14 16:59:00 +08:00
|
|
|
// Kernels + shaders. i.e. functions called by the driver and not called
|
2017-03-31 07:58:04 +08:00
|
|
|
// by other functions.
|
2020-05-20 01:44:14 +08:00
|
|
|
bool IsEntryFunction = false;
|
2017-03-31 07:58:04 +08:00
|
|
|
|
2020-05-20 01:44:14 +08:00
|
|
|
bool NoSignedZerosFPMath = false;
|
2014-07-13 11:06:39 +08:00
|
|
|
|
2018-05-26 01:25:12 +08:00
|
|
|
// Function may be memory bound.
|
2020-05-20 01:44:14 +08:00
|
|
|
bool MemoryBound = false;
|
2018-05-26 01:25:12 +08:00
|
|
|
|
|
|
|
// Kernel may need limited waves per EU for better performance.
|
2020-05-20 01:44:14 +08:00
|
|
|
bool WaveLimiter = false;
|
2018-05-26 01:25:12 +08:00
|
|
|
|
2013-04-02 05:47:53 +08:00
|
|
|
public:
|
|
|
|
AMDGPUMachineFunction(const MachineFunction &MF);
|
2016-06-18 13:15:53 +08:00
|
|
|
|
2018-06-28 18:18:55 +08:00
|
|
|
uint64_t getExplicitKernArgSize() const {
|
|
|
|
return ExplicitKernArgSize;
|
2016-07-27 00:45:58 +08:00
|
|
|
}
|
2014-07-13 11:06:39 +08:00
|
|
|
|
2019-10-15 20:56:24 +08:00
|
|
|
unsigned getMaxKernArgAlign() const { return MaxKernArgAlign.value(); }
|
2016-12-07 05:53:10 +08:00
|
|
|
|
2016-07-27 00:45:58 +08:00
|
|
|
unsigned getLDSSize() const {
|
|
|
|
return LDSSize;
|
|
|
|
}
|
2015-11-06 19:45:14 +08:00
|
|
|
|
2019-11-01 09:50:30 +08:00
|
|
|
AMDGPU::SIModeRegisterDefaults getMode() const {
|
|
|
|
return Mode;
|
|
|
|
}
|
|
|
|
|
2017-03-31 07:58:04 +08:00
|
|
|
bool isEntryFunction() const {
|
|
|
|
return IsEntryFunction;
|
2016-07-27 00:45:58 +08:00
|
|
|
}
|
|
|
|
|
2017-02-28 03:35:42 +08:00
|
|
|
bool hasNoSignedZerosFPMath() const {
|
|
|
|
return NoSignedZerosFPMath;
|
|
|
|
}
|
|
|
|
|
2018-05-26 01:25:12 +08:00
|
|
|
bool isMemoryBound() const {
|
|
|
|
return MemoryBound;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool needsWaveLimiter() const {
|
|
|
|
return WaveLimiter;
|
|
|
|
}
|
|
|
|
|
2020-05-19 11:38:13 +08:00
|
|
|
unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV);
|
[amdgpu] Add codegen support for HIP dynamic shared memory.
Summary:
- HIP uses an unsized extern array `extern __shared__ T s[]` to declare
the dynamic shared memory, which size is not known at the
compile time.
Reviewers: arsenm, yaxunl, kpyzhov, b-sumner
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, dstuttard, tpr, t-tye, hiraditya, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82496
2020-06-25 00:13:10 +08:00
|
|
|
|
|
|
|
Align getDynLDSAlign() const { return DynLDSAlign; }
|
|
|
|
|
|
|
|
void setDynLDSAlign(const DataLayout &DL, const GlobalVariable &GV);
|
2013-04-02 05:47:53 +08:00
|
|
|
};
|
|
|
|
|
2015-06-23 17:49:53 +08:00
|
|
|
}
|
2014-08-14 00:26:38 +08:00
|
|
|
#endif
|