Compare commits
1 Commits
llvm-test-
...
target_ent
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0571385e85 |
@@ -1224,6 +1224,15 @@ public:
|
|||||||
///
|
///
|
||||||
///{
|
///{
|
||||||
|
|
||||||
|
/// Create a kernel entry function.
|
||||||
|
///
|
||||||
|
/// \param Ty The type of the kernel entry function.
|
||||||
|
/// \param EntryName The name of the kernel entry function.
|
||||||
|
/// \param IsSPMD Flag to indicate if the kernel is an SPMD kernel or not.
|
||||||
|
Function *createTargetEntry(FunctionType *Ty, StringRef EntryName);
|
||||||
|
Function *createTargetEntry(FunctionType *Ty, StringRef EntryName,
|
||||||
|
bool IsSPMD);
|
||||||
|
|
||||||
/// Create a runtime call for kmpc_target_init
|
/// Create a runtime call for kmpc_target_init
|
||||||
///
|
///
|
||||||
/// \param Loc The insert and source location description.
|
/// \param Loc The insert and source location description.
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include "llvm/Transforms/Utils/Cloning.h"
|
#include "llvm/Transforms/Utils/Cloning.h"
|
||||||
#include "llvm/Transforms/Utils/CodeExtractor.h"
|
#include "llvm/Transforms/Utils/CodeExtractor.h"
|
||||||
#include "llvm/Transforms/Utils/LoopPeel.h"
|
#include "llvm/Transforms/Utils/LoopPeel.h"
|
||||||
|
#include "llvm/Transforms/Utils/ModuleUtils.h"
|
||||||
#include "llvm/Transforms/Utils/UnrollLoop.h"
|
#include "llvm/Transforms/Utils/UnrollLoop.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@@ -3764,6 +3765,56 @@ CallInst *OpenMPIRBuilder::createCachedThreadPrivate(
|
|||||||
return Builder.CreateCall(Fn, Args);
|
return Builder.CreateCall(Fn, Args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function *OpenMPIRBuilder::createTargetEntry(FunctionType *Ty,
|
||||||
|
StringRef EntryName) {
|
||||||
|
assert(M.getFunction(EntryName) == nullptr && "kernel entry already exists");
|
||||||
|
|
||||||
|
LLVMContext &Ctx = M.getContext();
|
||||||
|
|
||||||
|
Function *F =
|
||||||
|
Function::Create(Ty, llvm::GlobalValue::WeakODRLinkage, EntryName, M);
|
||||||
|
|
||||||
|
F->setVisibility(GlobalValue::DefaultVisibility);
|
||||||
|
F->setDSOLocal(false);
|
||||||
|
{
|
||||||
|
Triple T(M.getTargetTriple());
|
||||||
|
if (T.isAMDGCN())
|
||||||
|
F->setCallingConv(CallingConv::AMDGPU_KERNEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get "nvvm.annotations" metadata node.
|
||||||
|
NamedMDNode *MD = M.getOrInsertNamedMetadata("nvvm.annotations");
|
||||||
|
|
||||||
|
Metadata *MDVals[] = {
|
||||||
|
ConstantAsMetadata::get(F), MDString::get(Ctx, "kernel"),
|
||||||
|
ConstantAsMetadata::get(ConstantInt::get(Type::getInt32Ty(Ctx), 1))};
|
||||||
|
// Append metadata to nvvm.annotations.
|
||||||
|
MD->addOperand(MDNode::get(Ctx, MDVals));
|
||||||
|
|
||||||
|
// Add a function attribute for the kernel.
|
||||||
|
F->addFnAttr(Attribute::get(Ctx, "kernel"));
|
||||||
|
|
||||||
|
return F;
|
||||||
|
}
|
||||||
|
|
||||||
|
Function *OpenMPIRBuilder::createTargetEntry(FunctionType *Ty,
|
||||||
|
StringRef EntryName, bool IsSPMD) {
|
||||||
|
LLVMContext &Ctx = M.getContext();
|
||||||
|
|
||||||
|
Function *F = createTargetEntry(Ty, EntryName);
|
||||||
|
|
||||||
|
// exec mode global variable
|
||||||
|
GlobalVariable *ModeGV = new GlobalVariable(
|
||||||
|
M, Type::getInt8Ty(Ctx), /*isConstant=*/true, GlobalValue::WeakAnyLinkage,
|
||||||
|
ConstantInt::get(Type::getInt8Ty(Ctx), IsSPMD
|
||||||
|
? OMP_TGT_EXEC_MODE_SPMD
|
||||||
|
: OMP_TGT_EXEC_MODE_GENERIC),
|
||||||
|
EntryName + "_exec_mode");
|
||||||
|
appendToCompilerUsed(M, {ModeGV});
|
||||||
|
|
||||||
|
return F;
|
||||||
|
}
|
||||||
|
|
||||||
OpenMPIRBuilder::InsertPointTy
|
OpenMPIRBuilder::InsertPointTy
|
||||||
OpenMPIRBuilder::createTargetInit(const LocationDescription &Loc, bool IsSPMD,
|
OpenMPIRBuilder::createTargetInit(const LocationDescription &Loc, bool IsSPMD,
|
||||||
bool RequiresFullRuntime) {
|
bool RequiresFullRuntime) {
|
||||||
|
|||||||
Reference in New Issue
Block a user