From 94c002a190cd2e3a52b1510bc997e53d63af0b3b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 1 Feb 2007 05:32:05 +0000 Subject: [PATCH] rename DenseMap to IndexedMap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33749 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/DenseMap.h | 75 --------------------- include/llvm/ADT/IndexedMap.h | 6 +- include/llvm/CodeGen/LiveIntervalAnalysis.h | 4 +- include/llvm/CodeGen/SSARegMap.h | 4 +- include/llvm/CodeGen/ScheduleDAG.h | 5 +- include/llvm/Target/MRegisterInfo.h | 2 +- lib/CodeGen/PHIElimination.cpp | 1 - lib/CodeGen/RegAllocLocal.cpp | 4 +- lib/CodeGen/VirtRegMap.h | 6 +- 9 files changed, 15 insertions(+), 92 deletions(-) delete mode 100644 include/llvm/ADT/DenseMap.h diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h deleted file mode 100644 index 740ecd38c3a..00000000000 --- a/include/llvm/ADT/DenseMap.h +++ /dev/null @@ -1,75 +0,0 @@ -//===- 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 -#include -#include - -namespace llvm { - - struct IdentityFunctor : std::unary_function { - unsigned operator()(unsigned Index) const { - return Index; - } - }; - - template - class DenseMap { - typedef typename ToIndexT::argument_type IndexT; - typedef std::vector 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 diff --git a/include/llvm/ADT/IndexedMap.h b/include/llvm/ADT/IndexedMap.h index 7e0fbbb07eb..bc38fddc619 100644 --- a/include/llvm/ADT/IndexedMap.h +++ b/include/llvm/ADT/IndexedMap.h @@ -33,7 +33,7 @@ namespace llvm { }; template - class IndexMap { + class IndexedMap { typedef typename ToIndexT::argument_type IndexT; typedef std::vector StorageT; StorageT storage_; @@ -41,9 +41,9 @@ namespace llvm { 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!"); diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index e0f60452e39..70c189df780 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -20,9 +20,9 @@ #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 { @@ -51,7 +51,7 @@ namespace llvm { typedef std::map Reg2IntervalMap; Reg2IntervalMap r2iMap_; - typedef DenseMap Reg2RegMap; + typedef IndexedMap Reg2RegMap; Reg2RegMap r2rMap_; std::vector allocatableRegs_; diff --git a/include/llvm/CodeGen/SSARegMap.h b/include/llvm/CodeGen/SSARegMap.h index 43eee10c5c5..97d8d6988c4 100644 --- a/include/llvm/CodeGen/SSARegMap.h +++ b/include/llvm/CodeGen/SSARegMap.h @@ -18,14 +18,14 @@ #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 RegClassMap; + IndexedMap RegClassMap; unsigned NextRegNum; public: diff --git a/include/llvm/CodeGen/ScheduleDAG.h b/include/llvm/CodeGen/ScheduleDAG.h index 55b0d9f04a2..86e08fe9d9e 100644 --- a/include/llvm/CodeGen/ScheduleDAG.h +++ b/include/llvm/CodeGen/ScheduleDAG.h @@ -16,8 +16,7 @@ #define LLVM_CODEGEN_SCHEDULEDAG_H #include "llvm/CodeGen/SelectionDAG.h" - -#include +#include "llvm/ADT/SmallSet.h" namespace llvm { struct InstrStage; @@ -183,7 +182,7 @@ namespace llvm { // represent noop instructions. std::map SUnitMap; // SDNode to SUnit mapping (n -> 1). std::vector SUnits; // The scheduling units. - std::set CommuteSet; // Nodes the should be commuted. + SmallSet CommuteSet; // Nodes the should be commuted. ScheduleDAG(SelectionDAG &dag, MachineBasicBlock *bb, const TargetMachine &tm) diff --git a/include/llvm/Target/MRegisterInfo.h b/include/llvm/Target/MRegisterInfo.h index aac932e0a20..46a2cc34f17 100644 --- a/include/llvm/Target/MRegisterInfo.h +++ b/include/llvm/Target/MRegisterInfo.h @@ -465,7 +465,7 @@ public: virtual void getInitialFrameState(std::vector &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 operator()(unsigned Reg) const { return Reg - MRegisterInfo::FirstVirtualRegister; diff --git a/lib/CodeGen/PHIElimination.cpp b/lib/CodeGen/PHIElimination.cpp index a5d17c2e4b0..6a9f4282080 100644 --- a/lib/CodeGen/PHIElimination.cpp +++ b/lib/CodeGen/PHIElimination.cpp @@ -21,7 +21,6 @@ #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" diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp index 644e221212a..74d76c14fc4 100644 --- a/lib/CodeGen/RegAllocLocal.cpp +++ b/lib/CodeGen/RegAllocLocal.cpp @@ -26,7 +26,7 @@ #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 @@ -55,7 +55,7 @@ namespace { // Virt2PhysRegMap - This map contains entries for each virtual register // that is currently available in a physical register. - DenseMap Virt2PhysRegMap; + IndexedMap Virt2PhysRegMap; unsigned &getVirt2PhysRegMapSlot(unsigned VirtReg) { return Virt2PhysRegMap[VirtReg]; diff --git a/lib/CodeGen/VirtRegMap.h b/lib/CodeGen/VirtRegMap.h index 84cf2380350..5b06c01bfdf 100644 --- a/lib/CodeGen/VirtRegMap.h +++ b/lib/CodeGen/VirtRegMap.h @@ -18,7 +18,7 @@ #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 @@ -41,12 +41,12 @@ namespace llvm { /// it; even spilled virtual registers (the register mapped to a /// spilled register is the temporary used to load it from the /// stack). - DenseMap Virt2PhysMap; + IndexedMap 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 Virt2StackSlotMap; + IndexedMap 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 -- 2.34.1