diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2024-01-24 19:17:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-06 20:13:49 +0000 |
commit | 7a6dacaca14b62ca4b74406814becb87a3fefac0 (patch) | |
tree | 273a870ac27484bb1f5ee55e7ef0dc0d061f63e7 /contrib/llvm-project/llvm/lib/Frontend/Offloading/Utility.cpp | |
parent | 46c59ea9b61755455ff6bf9f3e7b834e1af634ea (diff) | |
parent | 4df029cc74e5ec124f14a5682e44999ce4f086df (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Frontend/Offloading/Utility.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Frontend/Offloading/Utility.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/contrib/llvm-project/llvm/lib/Frontend/Offloading/Utility.cpp b/contrib/llvm-project/llvm/lib/Frontend/Offloading/Utility.cpp index 25f609517ebe..531919bccb94 100644 --- a/contrib/llvm-project/llvm/lib/Frontend/Offloading/Utility.cpp +++ b/contrib/llvm-project/llvm/lib/Frontend/Offloading/Utility.cpp @@ -1,4 +1,4 @@ -//===- Utility.cpp ------ Collection of geneirc offloading utilities ------===// +//===- Utility.cpp ------ Collection of generic offloading utilities ------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -28,11 +28,10 @@ StructType *offloading::getEntryTy(Module &M) { } // TODO: Rework this interface to be more generic. -void offloading::emitOffloadingEntry(Module &M, Constant *Addr, StringRef Name, - uint64_t Size, int32_t Flags, int32_t Data, - StringRef SectionName) { - llvm::Triple Triple(M.getTargetTriple()); - +std::pair<Constant *, GlobalVariable *> +offloading::getOffloadingEntryInitializer(Module &M, Constant *Addr, + StringRef Name, uint64_t Size, + int32_t Flags, int32_t Data) { Type *Int8PtrTy = PointerType::getUnqual(M.getContext()); Type *Int32Ty = Type::getInt32Ty(M.getContext()); Type *SizeTy = M.getDataLayout().getIntPtrType(M.getContext()); @@ -54,6 +53,16 @@ void offloading::emitOffloadingEntry(Module &M, Constant *Addr, StringRef Name, ConstantInt::get(Int32Ty, Data), }; Constant *EntryInitializer = ConstantStruct::get(getEntryTy(M), EntryData); + return {EntryInitializer, Str}; +} + +void offloading::emitOffloadingEntry(Module &M, Constant *Addr, StringRef Name, + uint64_t Size, int32_t Flags, int32_t Data, + StringRef SectionName) { + llvm::Triple Triple(M.getTargetTriple()); + + auto [EntryInitializer, NameGV] = + getOffloadingEntryInitializer(M, Addr, Name, Size, Flags, Data); auto *Entry = new GlobalVariable( M, getEntryTy(M), |