mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
eb66b33867
I did this a long time ago with a janky python script, but now clang-format has built-in support for this. I fed clang-format every line with a #include and let it re-sort things according to the precise LLVM rules for include ordering baked into clang-format these days. I've reverted a number of files where the results of sorting includes isn't healthy. Either places where we have legacy code relying on particular include ordering (where possible, I'll fix these separately) or where we have particular formatting around #include lines that I didn't want to disturb in this patch. This patch is *entirely* mechanical. If you get merge conflicts or anything, just ignore the changes in this patch and run clang-format over your #include lines in the files. Sorry for any noise here, but it is important to keep these things stable. I was seeing an increasing number of patches with irrelevant re-ordering of #include lines because clang-format was used. This patch at least isolates that churn, makes it easy to skip when resolving conflicts, and gets us to a clean baseline (again). llvm-svn: 304787
129 lines
4.0 KiB
C++
129 lines
4.0 KiB
C++
//===- llvm/CodeGen/LiveRegUnits.h - Register Unit Set ----------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
/// \file
|
|
/// A set of register units. It is intended for register liveness tracking.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CODEGEN_LIVEREGUNITS_H
|
|
#define LLVM_CODEGEN_LIVEREGUNITS_H
|
|
|
|
#include "llvm/ADT/BitVector.h"
|
|
#include "llvm/MC/LaneBitmask.h"
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
|
#include <cstdint>
|
|
|
|
namespace llvm {
|
|
|
|
class MachineInstr;
|
|
class MachineBasicBlock;
|
|
|
|
/// A set of register units used to track register liveness.
|
|
class LiveRegUnits {
|
|
const TargetRegisterInfo *TRI = nullptr;
|
|
BitVector Units;
|
|
|
|
public:
|
|
/// Constructs a new empty LiveRegUnits set.
|
|
LiveRegUnits() = default;
|
|
|
|
/// Constructs and initialize an empty LiveRegUnits set.
|
|
LiveRegUnits(const TargetRegisterInfo &TRI) {
|
|
init(TRI);
|
|
}
|
|
|
|
/// Initialize and clear the set.
|
|
void init(const TargetRegisterInfo &TRI) {
|
|
this->TRI = &TRI;
|
|
Units.reset();
|
|
Units.resize(TRI.getNumRegUnits());
|
|
}
|
|
|
|
/// Clears the set.
|
|
void clear() { Units.reset(); }
|
|
|
|
/// Returns true if the set is empty.
|
|
bool empty() const { return Units.empty(); }
|
|
|
|
/// Adds register units covered by physical register \p Reg.
|
|
void addReg(unsigned Reg) {
|
|
for (MCRegUnitIterator Unit(Reg, TRI); Unit.isValid(); ++Unit)
|
|
Units.set(*Unit);
|
|
}
|
|
|
|
/// \brief Adds register units covered by physical register \p Reg that are
|
|
/// part of the lanemask \p Mask.
|
|
void addRegMasked(unsigned Reg, LaneBitmask Mask) {
|
|
for (MCRegUnitMaskIterator Unit(Reg, TRI); Unit.isValid(); ++Unit) {
|
|
LaneBitmask UnitMask = (*Unit).second;
|
|
if (UnitMask.none() || (UnitMask & Mask).any())
|
|
Units.set((*Unit).first);
|
|
}
|
|
}
|
|
|
|
/// Removes all register units covered by physical register \p Reg.
|
|
void removeReg(unsigned Reg) {
|
|
for (MCRegUnitIterator Unit(Reg, TRI); Unit.isValid(); ++Unit)
|
|
Units.reset(*Unit);
|
|
}
|
|
|
|
/// Removes register units not preserved by the regmask \p RegMask.
|
|
/// The regmask has the same format as the one in the RegMask machine operand.
|
|
void removeRegsNotPreserved(const uint32_t *RegMask);
|
|
|
|
/// Adds register units not preserved by the regmask \p RegMask.
|
|
/// The regmask has the same format as the one in the RegMask machine operand.
|
|
void addRegsInMask(const uint32_t *RegMask);
|
|
|
|
/// Returns true if no part of physical register \p Reg is live.
|
|
bool available(unsigned Reg) const {
|
|
for (MCRegUnitIterator Unit(Reg, TRI); Unit.isValid(); ++Unit) {
|
|
if (Units.test(*Unit))
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/// Updates liveness when stepping backwards over the instruction \p MI.
|
|
void stepBackward(const MachineInstr &MI);
|
|
|
|
/// Mark all register units live during instruction \p MI.
|
|
/// This can be used to accumulate live/unoccupied registers over a range of
|
|
/// instructions.
|
|
void accumulateBackward(const MachineInstr &MI);
|
|
|
|
/// Adds registers living out of block \p MBB.
|
|
/// Live out registers are the union of the live-in registers of the successor
|
|
/// blocks and pristine registers. Live out registers of the end block are the
|
|
/// callee saved registers.
|
|
void addLiveOuts(const MachineBasicBlock &MBB);
|
|
|
|
/// Adds registers living into block \p MBB.
|
|
void addLiveIns(const MachineBasicBlock &MBB);
|
|
|
|
/// Adds all register units marked in the bitvector \p RegUnits.
|
|
void addUnits(const BitVector &RegUnits) {
|
|
Units |= RegUnits;
|
|
}
|
|
/// Removes all register units marked in the bitvector \p RegUnits.
|
|
void removeUnits(const BitVector &RegUnits) {
|
|
Units.reset(RegUnits);
|
|
}
|
|
/// Return the internal bitvector representation of the set.
|
|
const BitVector &getBitVector() const {
|
|
return Units;
|
|
}
|
|
};
|
|
|
|
} // end namespace llvm
|
|
|
|
#endif // LLVM_CODEGEN_LIVEREGUNITS_H
|