LLVM 23.0.0git
DXILDebugInfo.h
Go to the documentation of this file.
1//===----- DebugInfo.h - analysis and lowering for Debug info -*- 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// \file Analyze and downgrade debug info metadata to match DXIL (LLVM 3.7).
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_DIRECTX_DXILDEBUGINFO_H
14#define LLVM_LIB_TARGET_DIRECTX_DXILDEBUGINFO_H
15
16#include "llvm/ADT/DenseMap.h"
17#include "llvm/ADT/DenseSet.h"
18#include "llvm/IR/Function.h"
19#include "llvm/IR/Instruction.h"
21#include <memory>
22
23namespace llvm {
24
25namespace dxil {
26
28 struct InstructionDeleter {
29 void operator()(Instruction *I) { I->deleteValue(); }
30 };
31
32public:
34 using InstMap = DenseMap<const Instruction *,
35 std::unique_ptr<Instruction, InstructionDeleter>>;
37
38 DXILDebugInfoMap() = default;
41
42 /// Completely replace one function with another in ValueEnumerator.
44
45 /// Completely replace one instruction with another in ValueEnumerator.
47
48 /// Enumerate extra metadata when Key is encountered in ValueEnumerator.
50
51 /// Completely replace one metadata with another in ValueEnumerator.
53
54 const Function &getDXILFunction(const Function &F) const {
55 auto It = FuncReplace.find(&F);
56 if (It != FuncReplace.end())
57 return *It->second.get();
58 return F;
59 }
60
62 auto It = InstReplace.find(&I);
63 if (It != InstReplace.end())
64 return *It->second.get();
65 return I;
66 }
67
68 const Metadata *getDXILMetadata(const Metadata *M) const {
69 return MDReplace.lookup_or(M, M);
70 }
71};
72
74
76
77} // namespace DXILDebugInfoPass
78} // namespace dxil
79} // namespace llvm
80
81#endif // LLVM_LIB_TARGET_DIRECTX_DXILDEBUGINFO_H
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
#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:67
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 run(Module &M)
This is an optimization pass for GlobalISel generic memory operations.