mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-24 08:24:33 +00:00
Use a SparseSet in LiveRegUnits.
Some clients may add block live ins and may track liveness over a large scope. This guarantees an efficient implementation in all cases with no memory allocation/deallocation, independent of the number of target registers. It could be slightly less convenient but is fine in the expected case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192622 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -17,9 +17,9 @@
|
||||
#ifndef LLVM_CODEGEN_LIVEREGUNITS_H
|
||||
#define LLVM_CODEGEN_LIVEREGUNITS_H
|
||||
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SparseSet.h"
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace llvm {
|
||||
@ -29,17 +29,23 @@ class MachineInstr;
|
||||
/// A set of live register units with functions to track liveness when walking
|
||||
/// backward/forward through a basic block.
|
||||
class LiveRegUnits {
|
||||
SmallSet<unsigned, 32> LiveUnits;
|
||||
SparseSet<unsigned> LiveUnits;
|
||||
|
||||
LiveRegUnits(const LiveRegUnits&) LLVM_DELETED_FUNCTION;
|
||||
LiveRegUnits &operator=(const LiveRegUnits&) LLVM_DELETED_FUNCTION;
|
||||
public:
|
||||
/// \brief Constructs a new empty LiveRegUnits set.
|
||||
LiveRegUnits() {}
|
||||
|
||||
/// \brief Constructs a new LiveRegUnits set by copying @p Other.
|
||||
LiveRegUnits(const LiveRegUnits &Other)
|
||||
: LiveUnits(Other.LiveUnits) {
|
||||
void init(const TargetRegisterInfo *TRI) {
|
||||
LiveUnits.clear();
|
||||
LiveUnits.setUniverse(TRI->getNumRegs());
|
||||
}
|
||||
|
||||
void clear() { LiveUnits.clear(); }
|
||||
|
||||
bool empty() const { return LiveUnits.empty(); }
|
||||
|
||||
/// \brief Adds a register to the set.
|
||||
void addReg(unsigned Reg, const MCRegisterInfo &MCRI) {
|
||||
for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits)
|
||||
@ -73,7 +79,7 @@ public:
|
||||
/// instruction(bundle): Remove killed-uses, add defs.
|
||||
void stepForward(const MachineInstr &MI, const MCRegisterInfo &MCRI);
|
||||
|
||||
/// Adds all registers in the live-in list of block @p BB.
|
||||
/// \brief Adds all registers in the live-in list of block @p BB.
|
||||
void addLiveIns(const MachineBasicBlock &BB, const MCRegisterInfo &MCRI);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user