LLVM 24.0.0git
DXILDebugInfoMap.h
Go to the documentation of this file.
1//===- DXILDebugInfoMap.h - DXIL debug info serialization ------*- C++ -*-===//
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
9#ifndef LLVM_LIB_TARGET_DIRECTX_DXILWRITER_DXILDEBUGINFOMAP_H
10#define LLVM_LIB_TARGET_DIRECTX_DXILWRITER_DXILDEBUGINFOMAP_H
11
12#include "llvm/ADT/DenseMap.h"
13#include "llvm/IR/Function.h"
14#include "llvm/IR/Instruction.h"
15#include <memory>
16
17namespace llvm {
18namespace dxil {
19
21 struct InstructionDeleter {
22 void operator()(Instruction *I) { I->deleteValue(); }
23 };
24
25public:
27 using InstMap = DenseMap<const Instruction *,
28 std::unique_ptr<Instruction, InstructionDeleter>>;
30
31 DXILDebugInfoMap() = default;
34
35 /// Completely replace one function with another in ValueEnumerator.
37
38 /// Completely replace one instruction with another in ValueEnumerator.
40
41 /// Enumerate extra metadata when Key is encountered in ValueEnumerator.
43
44 /// Completely replace one metadata with another in ValueEnumerator.
46
47 const Function &getDXILFunction(const Function &F) const {
48 auto It = FuncReplace.find(&F);
49 if (It != FuncReplace.end())
50 return *It->second.get();
51 return F;
52 }
53
55 auto It = InstReplace.find(&I);
56 if (It != InstReplace.end())
57 return *It->second.get();
58 return I;
59 }
60
61 const Metadata *getDXILMetadata(const Metadata *M) const {
62 return MDReplace.lookup_or(M, M);
63 }
64};
65
66DXILDebugInfoMap collectDXILDebugInfo(Module &M);
67
68} // namespace dxil
69} // namespace llvm
70
71#endif // LLVM_LIB_TARGET_DIRECTX_DXILWRITER_DXILDEBUGINFOMAP_H
This file defines the DenseMap class.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Root of the metadata hierarchy.
Definition Metadata.h:64
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
const Instruction & getDXILInstruction(const Instruction &I) const
const Function & getDXILFunction(const Function &F) const
DXILDebugInfoMap(const DXILDebugInfoMap &)=delete
InstMap InstReplace
Completely replace one instruction with another in ValueEnumerator.
DenseMap< const Function *, std::unique_ptr< Function > > FuncMap
MDMap MDExtra
Enumerate extra metadata when Key is encountered in ValueEnumerator.
FuncMap FuncReplace
Completely replace one function with another in ValueEnumerator.
DXILDebugInfoMap(DXILDebugInfoMap &&)=default
const Metadata * getDXILMetadata(const Metadata *M) const
MDMap MDReplace
Completely replace one metadata with another in ValueEnumerator.
DenseMap< const Metadata *, const Metadata * > MDMap
DenseMap< const Instruction *, std::unique_ptr< Instruction, InstructionDeleter > > InstMap
DXILDebugInfoMap collectDXILDebugInfo(Module &M)
This is an optimization pass for GlobalISel generic memory operations.