xref: /llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyDebugValueManager.h (revision b02db1dc78eed80c793f148913bd69a4a0ab823e)
1be24c020SYury Delendik // WebAssemblyDebugValueManager.h - WebAssembly DebugValue Manager -*- C++ -*-//
2be24c020SYury Delendik //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6be24c020SYury Delendik //
7be24c020SYury Delendik //===----------------------------------------------------------------------===//
8be24c020SYury Delendik ///
9be24c020SYury Delendik /// \file
10be24c020SYury Delendik /// This file contains the declaration of the WebAssembly-specific
11be24c020SYury Delendik /// manager for DebugValues associated with the specific MachineInstr.
12999643f1SHeejin Ahn /// This pass currently does not handle DBG_VALUE_LISTs; they are assumed to
13999643f1SHeejin Ahn /// have been set to undef in NullifyDebugValueLists pass.
14999643f1SHeejin Ahn /// TODO Handle DBG_VALUE_LIST
15be24c020SYury Delendik ///
16be24c020SYury Delendik //===----------------------------------------------------------------------===//
17be24c020SYury Delendik 
18be24c020SYury Delendik #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYDEBUGVALUEMANAGER_H
19be24c020SYury Delendik #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYDEBUGVALUEMANAGER_H
20be24c020SYury Delendik 
21be24c020SYury Delendik #include "llvm/ADT/SmallVector.h"
22999643f1SHeejin Ahn #include "llvm/CodeGen/Register.h"
23be24c020SYury Delendik 
24be24c020SYury Delendik namespace llvm {
25be24c020SYury Delendik 
26be24c020SYury Delendik class MachineInstr;
27be24c020SYury Delendik 
28be24c020SYury Delendik class WebAssemblyDebugValueManager {
295a55c950SHeejin Ahn   MachineInstr *Def;
30999643f1SHeejin Ahn   SmallVector<MachineInstr *, 1> DbgValues;
31999643f1SHeejin Ahn   Register CurrentReg;
32*b02db1dcSHeejin Ahn   SmallVector<MachineInstr *, 1>
335a55c950SHeejin Ahn   getSinkableDebugValues(MachineInstr *Insert) const;
34a4e32ae4SHeejin Ahn   bool isInsertSamePlace(MachineInstr *Insert) const;
35be24c020SYury Delendik 
36be24c020SYury Delendik public:
37999643f1SHeejin Ahn   WebAssemblyDebugValueManager(MachineInstr *Def);
38be24c020SYury Delendik 
395a55c950SHeejin Ahn   // Sink 'Def', and also sink its eligible DBG_VALUEs to the place before
405a55c950SHeejin Ahn   // 'Insert'. Convert the original DBG_VALUEs into undefs.
415a55c950SHeejin Ahn   void sink(MachineInstr *Insert);
425a55c950SHeejin Ahn   // Clone 'Def' (optionally), and also clone its eligible DBG_VALUEs to the
435a55c950SHeejin Ahn   // place before 'Insert'.
445a55c950SHeejin Ahn   void cloneSink(MachineInstr *Insert, Register NewReg = Register(),
455a55c950SHeejin Ahn                  bool CloneDef = true) const;
46999643f1SHeejin Ahn   // Update the register for Def and DBG_VALUEs.
47999643f1SHeejin Ahn   void updateReg(Register Reg);
48999643f1SHeejin Ahn   // Replace the current register in DBG_VALUEs with the given LocalId target
49999643f1SHeejin Ahn   // index.
50adf7a0a5SYury Delendik   void replaceWithLocal(unsigned LocalId);
515a55c950SHeejin Ahn   // Remove Def, and set its DBG_VALUEs to undef.
525a55c950SHeejin Ahn   void removeDef();
53be24c020SYury Delendik };
54be24c020SYury Delendik 
55be24c020SYury Delendik } // end namespace llvm
56be24c020SYury Delendik 
57be24c020SYury Delendik #endif
58