| Yury Delendik | be24c02 | 2019-01-15 18:14:12 +0000 | [diff] [blame] | 1 | //===-- WebAssemblyDebugValueManager.cpp - WebAssembly DebugValue Manager -===// | 
|  | 2 | // | 
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 | 
| Yury Delendik | be24c02 | 2019-01-15 18:14:12 +0000 | [diff] [blame] | 6 | // | 
|  | 7 | //===----------------------------------------------------------------------===// | 
|  | 8 | /// | 
|  | 9 | /// \file | 
|  | 10 | /// This file implements the manager for MachineInstr DebugValues. | 
|  | 11 | /// | 
|  | 12 | //===----------------------------------------------------------------------===// | 
|  | 13 |  | 
|  | 14 | #include "WebAssemblyDebugValueManager.h" | 
|  | 15 | #include "WebAssemblyMachineFunctionInfo.h" | 
|  | 16 | #include "llvm/CodeGen/MachineInstr.h" | 
|  | 17 |  | 
|  | 18 | using namespace llvm; | 
|  | 19 |  | 
|  | 20 | WebAssemblyDebugValueManager::WebAssemblyDebugValueManager( | 
|  | 21 | MachineInstr *Instr) { | 
|  | 22 | Instr->collectDebugValues(DbgValues); | 
|  | 23 | } | 
|  | 24 |  | 
|  | 25 | void WebAssemblyDebugValueManager::move(MachineInstr *Insert) { | 
|  | 26 | MachineBasicBlock *MBB = Insert->getParent(); | 
|  | 27 | for (MachineInstr *DBI : reverse(DbgValues)) | 
|  | 28 | MBB->splice(Insert, DBI->getParent(), DBI); | 
|  | 29 | } | 
|  | 30 |  | 
|  | 31 | void WebAssemblyDebugValueManager::updateReg(unsigned Reg) { | 
|  | 32 | for (auto *DBI : DbgValues) | 
|  | 33 | DBI->getOperand(0).setReg(Reg); | 
|  | 34 | } | 
|  | 35 |  | 
|  | 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); | 
|  | 44 | } | 
|  | 45 | } |