xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyDebugValueManager.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
10b57cec5SDimitry Andric // WebAssemblyDebugValueManager.h - WebAssembly DebugValue Manager -*- C++ -*-//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric ///
90b57cec5SDimitry Andric /// \file
100b57cec5SDimitry Andric /// This file contains the declaration of the WebAssembly-specific
110b57cec5SDimitry Andric /// manager for DebugValues associated with the specific MachineInstr.
12*06c3fb27SDimitry Andric /// This pass currently does not handle DBG_VALUE_LISTs; they are assumed to
13*06c3fb27SDimitry Andric /// have been set to undef in NullifyDebugValueLists pass.
14*06c3fb27SDimitry Andric /// TODO Handle DBG_VALUE_LIST
150b57cec5SDimitry Andric ///
160b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYDEBUGVALUEMANAGER_H
190b57cec5SDimitry Andric #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYDEBUGVALUEMANAGER_H
200b57cec5SDimitry Andric 
210b57cec5SDimitry Andric #include "llvm/ADT/SmallVector.h"
22*06c3fb27SDimitry Andric #include "llvm/CodeGen/Register.h"
230b57cec5SDimitry Andric 
240b57cec5SDimitry Andric namespace llvm {
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric class MachineInstr;
270b57cec5SDimitry Andric 
280b57cec5SDimitry Andric class WebAssemblyDebugValueManager {
29*06c3fb27SDimitry Andric   MachineInstr *Def;
30*06c3fb27SDimitry Andric   SmallVector<MachineInstr *, 1> DbgValues;
31*06c3fb27SDimitry Andric   Register CurrentReg;
32*06c3fb27SDimitry Andric   SmallVector<MachineInstr *, 1>
33*06c3fb27SDimitry Andric   getSinkableDebugValues(MachineInstr *Insert) const;
34*06c3fb27SDimitry Andric   bool isInsertSamePlace(MachineInstr *Insert) const;
350b57cec5SDimitry Andric 
360b57cec5SDimitry Andric public:
37*06c3fb27SDimitry Andric   WebAssemblyDebugValueManager(MachineInstr *Def);
380b57cec5SDimitry Andric 
39*06c3fb27SDimitry Andric   // Sink 'Def', and also sink its eligible DBG_VALUEs to the place before
40*06c3fb27SDimitry Andric   // 'Insert'. Convert the original DBG_VALUEs into undefs.
41*06c3fb27SDimitry Andric   void sink(MachineInstr *Insert);
42*06c3fb27SDimitry Andric   // Clone 'Def' (optionally), and also clone its eligible DBG_VALUEs to the
43*06c3fb27SDimitry Andric   // place before 'Insert'.
44*06c3fb27SDimitry Andric   void cloneSink(MachineInstr *Insert, Register NewReg = Register(),
45*06c3fb27SDimitry Andric                  bool CloneDef = true) const;
46*06c3fb27SDimitry Andric   // Update the register for Def and DBG_VALUEs.
47*06c3fb27SDimitry Andric   void updateReg(Register Reg);
48*06c3fb27SDimitry Andric   // Replace the current register in DBG_VALUEs with the given LocalId target
49*06c3fb27SDimitry Andric   // index.
50480093f4SDimitry Andric   void replaceWithLocal(unsigned LocalId);
51*06c3fb27SDimitry Andric   // Remove Def, and set its DBG_VALUEs to undef.
52*06c3fb27SDimitry Andric   void removeDef();
530b57cec5SDimitry Andric };
540b57cec5SDimitry Andric 
550b57cec5SDimitry Andric } // end namespace llvm
560b57cec5SDimitry Andric 
570b57cec5SDimitry Andric #endif
58