+++ /dev/null
-//===- llvm/ADT/DenseMap.h - A dense map implmentation ----------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements a dense map. A dense map template takes two
-// types. The first is the mapped type and the second is a functor
-// that maps its argument to a size_t. On instantiation a "null" value
-// can be provided to be used as a "does not exist" indicator in the
-// map. A member function grow() is provided that given the value of
-// the maximally indexed key (the argument of the functor) makes sure
-// the map has enough space for it.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_ADT_DENSEMAP_H
-#define LLVM_ADT_DENSEMAP_H
-
-#include <functional>
-#include <vector>
-#include <cassert>
-
-namespace llvm {
-
- struct IdentityFunctor : std::unary_function<unsigned, unsigned> {
- unsigned operator()(unsigned Index) const {
- return Index;
- }
- };
-
- template <typename T, typename ToIndexT = IdentityFunctor>
- class DenseMap {
- typedef typename ToIndexT::argument_type IndexT;
- typedef std::vector<T> StorageT;
- StorageT storage_;
- T nullVal_;
- ToIndexT toIndex_;
-
- public:
- DenseMap() : nullVal_(T()) { }
-
- explicit DenseMap(const T& val) : nullVal_(val) { }
-
- typename StorageT::reference operator[](IndexT n) {
- assert(toIndex_(n) < storage_.size() && "index out of bounds!");
- return storage_[toIndex_(n)];
- }
-
- typename StorageT::const_reference operator[](IndexT n) const {
- assert(toIndex_(n) < storage_.size() && "index out of bounds!");
- return storage_[toIndex_(n)];
- }
-
- void clear() {
- storage_.clear();
- }
-
- void grow(IndexT n) {
- unsigned NewSize = toIndex_(n) + 1;
- if (NewSize > storage_.size())
- storage_.resize(NewSize, nullVal_);
- }
-
- typename StorageT::size_type size() const {
- return storage_.size();
- }
- };
-
-} // End llvm namespace
-
-#endif
};
template <typename T, typename ToIndexT = IdentityFunctor>
- class IndexMap {
+ class IndexedMap {
typedef typename ToIndexT::argument_type IndexT;
typedef std::vector<T> StorageT;
StorageT storage_;
ToIndexT toIndex_;
public:
- IndexMap() : nullVal_(T()) { }
+ IndexedMap() : nullVal_(T()) { }
- explicit IndexMap(const T& val) : nullVal_(val) { }
+ explicit IndexedMap(const T& val) : nullVal_(val) { }
typename StorageT::reference operator[](IndexT n) {
assert(toIndex_(n) < storage_.size() && "index out of bounds!");
#ifndef LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
#define LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
-#include "llvm/ADT/DenseMap.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/LiveInterval.h"
+#include "llvm/ADT/IndexedMap.h"
namespace llvm {
typedef std::map<unsigned, LiveInterval> Reg2IntervalMap;
Reg2IntervalMap r2iMap_;
- typedef DenseMap<unsigned> Reg2RegMap;
+ typedef IndexedMap<unsigned> Reg2RegMap;
Reg2RegMap r2rMap_;
std::vector<bool> allocatableRegs_;
#define LLVM_CODEGEN_SSAREGMAP_H
#include "llvm/Target/MRegisterInfo.h"
-#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/IndexedMap.h"
namespace llvm {
class TargetRegisterClass;
class SSARegMap {
- DenseMap<const TargetRegisterClass*, VirtReg2IndexFunctor> RegClassMap;
+ IndexedMap<const TargetRegisterClass*, VirtReg2IndexFunctor> RegClassMap;
unsigned NextRegNum;
public:
#define LLVM_CODEGEN_SCHEDULEDAG_H
#include "llvm/CodeGen/SelectionDAG.h"
-
-#include <set>
+#include "llvm/ADT/SmallSet.h"
namespace llvm {
struct InstrStage;
// represent noop instructions.
std::map<SDNode*, SUnit*> SUnitMap; // SDNode to SUnit mapping (n -> 1).
std::vector<SUnit> SUnits; // The scheduling units.
- std::set<SDNode*> CommuteSet; // Nodes the should be commuted.
+ SmallSet<SDNode*, 16> CommuteSet; // Nodes the should be commuted.
ScheduleDAG(SelectionDAG &dag, MachineBasicBlock *bb,
const TargetMachine &tm)
virtual void getInitialFrameState(std::vector<MachineMove> &Moves) const;
};
-// This is useful when building DenseMaps keyed on virtual registers
+// This is useful when building IndexedMaps keyed on virtual registers
struct VirtReg2IndexFunctor : std::unary_function<unsigned, unsigned> {
unsigned operator()(unsigned Reg) const {
return Reg - MRegisterInfo::FirstVirtualRegister;
#include "llvm/CodeGen/SSARegMap.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
-#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Compiler.h"
-#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/IndexedMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include <algorithm>
// Virt2PhysRegMap - This map contains entries for each virtual register
// that is currently available in a physical register.
- DenseMap<unsigned, VirtReg2IndexFunctor> Virt2PhysRegMap;
+ IndexedMap<unsigned, VirtReg2IndexFunctor> Virt2PhysRegMap;
unsigned &getVirt2PhysRegMapSlot(unsigned VirtReg) {
return Virt2PhysRegMap[VirtReg];
#define LLVM_CODEGEN_VIRTREGMAP_H
#include "llvm/Target/MRegisterInfo.h"
-#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/IndexedMap.h"
#include "llvm/Support/Streams.h"
#include <map>
/// it; even spilled virtual registers (the register mapped to a
/// spilled register is the temporary used to load it from the
/// stack).
- DenseMap<unsigned, VirtReg2IndexFunctor> Virt2PhysMap;
+ IndexedMap<unsigned, VirtReg2IndexFunctor> Virt2PhysMap;
/// Virt2StackSlotMap - This is virtual register to stack slot
/// mapping. Each spilled virtual register has an entry in it
/// which corresponds to the stack slot this register is spilled
/// at.
- DenseMap<int, VirtReg2IndexFunctor> Virt2StackSlotMap;
+ IndexedMap<int, VirtReg2IndexFunctor> Virt2StackSlotMap;
/// MI2VirtMap - This is MachineInstr to virtual register
/// mapping. In the case of memory spill code being folded into
/// instructions, we need to know which virtual register was