[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / lib / Target / WebAssembly / WebAssemblyDebugValueManager.cpp
blob579377c9a5d755d8c8cb29ece7af07bfe990f646
1 //===-- WebAssemblyDebugValueManager.cpp - WebAssembly DebugValue Manager -===//
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
10 /// This file implements the manager for MachineInstr DebugValues.
11 ///
12 //===----------------------------------------------------------------------===//
14 #include "WebAssemblyDebugValueManager.h"
15 #include "WebAssemblyMachineFunctionInfo.h"
16 #include "llvm/CodeGen/MachineInstr.h"
18 using namespace llvm;
20 WebAssemblyDebugValueManager::WebAssemblyDebugValueManager(
21 MachineInstr *Instr) {
22 Instr->collectDebugValues(DbgValues);
25 void WebAssemblyDebugValueManager::move(MachineInstr *Insert) {
26 MachineBasicBlock *MBB = Insert->getParent();
27 for (MachineInstr *DBI : reverse(DbgValues))
28 MBB->splice(Insert, DBI->getParent(), DBI);
31 void WebAssemblyDebugValueManager::updateReg(unsigned Reg) {
32 for (auto *DBI : DbgValues)
33 DBI->getOperand(0).setReg(Reg);
36 void WebAssemblyDebugValueManager::clone(MachineInstr *Insert,
37 unsigned NewReg) {
38 MachineBasicBlock *MBB = Insert->getParent();
39 MachineFunction *MF = MBB->getParent();
40 for (MachineInstr *DBI : reverse(DbgValues)) {
41 MachineInstr *Clone = MF->CloneMachineInstr(DBI);
42 Clone->getOperand(0).setReg(NewReg);
43 MBB->insert(Insert, Clone);