diff options
author | Andrew Trick <atrick@apple.com> | 2013-10-14 20:45:17 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2013-10-14 20:45:17 +0000 |
commit | 7c489ab36564ddde3fa672aff52cfcae06517dfc (patch) | |
tree | 9a67916fa3df168bef810e2e66c21e2dcb14b41c /include | |
parent | eb3b9f8ed979c34b7c11d749efb85df7fe1cfc9a (diff) | |
download | external_llvm-7c489ab36564ddde3fa672aff52cfcae06517dfc.zip external_llvm-7c489ab36564ddde3fa672aff52cfcae06517dfc.tar.gz external_llvm-7c489ab36564ddde3fa672aff52cfcae06517dfc.tar.bz2 |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/CodeGen/LiveRegUnits.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/include/llvm/CodeGen/LiveRegUnits.h b/include/llvm/CodeGen/LiveRegUnits.h index 0c6df88..1e24e69 100644 --- a/include/llvm/CodeGen/LiveRegUnits.h +++ b/include/llvm/CodeGen/LiveRegUnits.h @@ -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); }; |