mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-05-18 21:16:31 +00:00

Following on from this RFC[0] from a while back, this is the first patch towards implementing variadic debug values. This patch specifically adds a set of functions to MachineInstr for performing operations specific to debug values, and replacing uses of the more general functions where appropriate. The most prevalent of these is replacing getOperand(0) with getDebugOperand(0) for debug-value-specific code, as the operands corresponding to values will no longer be at index 0, but index 2 and upwards: getDebugOperand(x) == getOperand(x+2). Similar replacements have been added for the other operands, along with some helper functions to replace oft-repeated code and operate on a variable number of value operands. [0] http://lists.llvm.org/pipermail/llvm-dev/2020-February/139376.html<Paste> Differential Revision: https://reviews.llvm.org/D81852
54 lines
1.8 KiB
C++
54 lines
1.8 KiB
C++
//===-- WebAssemblyDebugValueManager.cpp - WebAssembly DebugValue Manager -===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// \file
|
|
/// This file implements the manager for MachineInstr DebugValues.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "WebAssemblyDebugValueManager.h"
|
|
#include "WebAssembly.h"
|
|
#include "WebAssemblyMachineFunctionInfo.h"
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
|
|
|
using namespace llvm;
|
|
|
|
WebAssemblyDebugValueManager::WebAssemblyDebugValueManager(
|
|
MachineInstr *Instr) {
|
|
Instr->collectDebugValues(DbgValues);
|
|
}
|
|
|
|
void WebAssemblyDebugValueManager::move(MachineInstr *Insert) {
|
|
MachineBasicBlock *MBB = Insert->getParent();
|
|
for (MachineInstr *DBI : reverse(DbgValues))
|
|
MBB->splice(Insert, DBI->getParent(), DBI);
|
|
}
|
|
|
|
void WebAssemblyDebugValueManager::updateReg(unsigned Reg) {
|
|
for (auto *DBI : DbgValues)
|
|
DBI->getDebugOperand(0).setReg(Reg);
|
|
}
|
|
|
|
void WebAssemblyDebugValueManager::clone(MachineInstr *Insert,
|
|
unsigned NewReg) {
|
|
MachineBasicBlock *MBB = Insert->getParent();
|
|
MachineFunction *MF = MBB->getParent();
|
|
for (MachineInstr *DBI : reverse(DbgValues)) {
|
|
MachineInstr *Clone = MF->CloneMachineInstr(DBI);
|
|
Clone->getDebugOperand(0).setReg(NewReg);
|
|
MBB->insert(Insert, Clone);
|
|
}
|
|
}
|
|
|
|
void WebAssemblyDebugValueManager::replaceWithLocal(unsigned LocalId) {
|
|
for (auto *DBI : DbgValues) {
|
|
MachineOperand &Op = DBI->getDebugOperand(0);
|
|
Op.ChangeToTargetIndex(llvm::WebAssembly::TI_LOCAL, LocalId);
|
|
}
|
|
}
|