Skip to content

Commit d3cef33

Browse files
committed
Fix lack of includes in GenXMetadata.h
GetOldStyleKernelMD implementation was moved out of the header. Proper forward declarations were added.
1 parent 381535d commit d3cef33

File tree

3 files changed

+39
-16
lines changed

3 files changed

+39
-16
lines changed

GenXIntrinsics/include/llvm/GenXIntrinsics/GenXMetadata.h

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ SPDX-License-Identifier: MIT
1717
#define GENX_METADATA_H
1818

1919
namespace llvm {
20+
21+
class MDNode;
22+
class Function;
23+
2024
namespace genx {
2125

2226
namespace FunctionMD {
@@ -68,22 +72,7 @@ enum KernelMDOp {
6872
BarrierCnt // Barrier count
6973
};
7074

71-
inline MDNode *GetOldStyleKernelMD(Function const &F) {
72-
auto *KernelMD = static_cast<MDNode *>(nullptr);
73-
auto *KernelMDs = F.getParent()->getNamedMetadata(FunctionMD::GenXKernels);
74-
if (!KernelMDs)
75-
return KernelMD;
76-
77-
for (unsigned I = 0, E = KernelMDs->getNumOperands(); I < E; ++I) {
78-
auto *Kernel = mdconst::dyn_extract<Function>(
79-
KernelMDs->getOperand(I)->getOperand(KernelMDOp::FunctionRef));
80-
if (Kernel == &F) {
81-
KernelMD = KernelMDs->getOperand(I);
82-
break;
83-
}
84-
}
85-
return KernelMD;
86-
}
75+
MDNode *GetOldStyleKernelMD(const Function &F);
8776

8877
} // namespace genx
8978
} // namespace llvm

GenXIntrinsics/lib/GenXIntrinsics/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if(BUILD_EXTERNAL)
2323
GenXSPIRVWriterAdaptor.cpp
2424
GenXVersion.cpp
2525
AdaptorsCommon.cpp
26+
GenXMetadata.cpp
2627
)
2728
llvm_update_compile_flags(LLVMGenXIntrinsics)
2829
add_dependencies(LLVMGenXIntrinsics GenXIntrinsicsGen)
@@ -50,6 +51,7 @@ else()
5051
GenXSPIRVWriterAdaptor.cpp
5152
GenXVersion.cpp
5253
AdaptorsCommon.cpp
54+
GenXMetadata.cpp
5355
ADDITIONAL_HEADER_DIRS
5456
${GENX_INTRINSICS_MAIN_INCLUDE_DIR}/llvm/GenXIntrinsics
5557

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*========================== begin_copyright_notice ============================
2+
3+
Copyright (C) 2021 Intel Corporation
4+
5+
SPDX-License-Identifier: MIT
6+
7+
============================= end_copyright_notice ===========================*/
8+
9+
#include "llvm/GenXIntrinsics/GenXMetadata.h"
10+
11+
#include <llvm/IR/Function.h>
12+
#include <llvm/IR/Metadata.h>
13+
#include <llvm/IR/Module.h>
14+
15+
using namespace llvm;
16+
17+
MDNode *llvm::genx::GetOldStyleKernelMD(Function const &F) {
18+
auto *KernelMD = static_cast<MDNode *>(nullptr);
19+
auto *KernelMDs = F.getParent()->getNamedMetadata(FunctionMD::GenXKernels);
20+
if (!KernelMDs)
21+
return KernelMD;
22+
23+
for (unsigned I = 0, E = KernelMDs->getNumOperands(); I < E; ++I) {
24+
auto *Kernel = mdconst::dyn_extract<Function>(
25+
KernelMDs->getOperand(I)->getOperand(KernelMDOp::FunctionRef));
26+
if (Kernel == &F) {
27+
KernelMD = KernelMDs->getOperand(I);
28+
break;
29+
}
30+
}
31+
return KernelMD;
32+
}

0 commit comments

Comments
 (0)