[Orc] Include <system_error> in OrcTargetClient.
[oota-llvm.git] / include / llvm / CodeGen / LiveStackAnalysis.h
index 7cb4151e87053c3f53595bcea18b5de9d27afea9..3ffbe3d775b42ebbb6828d3383c64fcf1c101d91 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CODEGEN_LIVESTACK_ANALYSIS_H
-#define LLVM_CODEGEN_LIVESTACK_ANALYSIS_H
+#ifndef LLVM_CODEGEN_LIVESTACKANALYSIS_H
+#define LLVM_CODEGEN_LIVESTACKANALYSIS_H
 
-#include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/LiveInterval.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/Support/Allocator.h"
+#include "llvm/Target/TargetRegisterInfo.h"
 #include <map>
+#include <unordered_map>
 
 namespace llvm {
 
-  class LiveStacks : public MachineFunctionPass {
-    /// Special pool allocator for VNInfo's (LiveInterval val#).
-    ///
-    BumpPtrAllocator VNInfoAllocator;
-
-    /// s2iMap - Stack slot indices to live interval mapping.
-    ///
-    typedef std::map<int, LiveInterval> SS2IntervalMap;
-    SS2IntervalMap s2iMap;
-
-  public:
-    static char ID; // Pass identification, replacement for typeid
-    LiveStacks() : MachineFunctionPass(&ID) {}
-
-    typedef SS2IntervalMap::iterator iterator;
-    typedef SS2IntervalMap::const_iterator const_iterator;
-    const_iterator begin() const { return s2iMap.begin(); }
-    const_iterator end() const { return s2iMap.end(); }
-    iterator begin() { return s2iMap.begin(); }
-    iterator end() { return s2iMap.end(); }
-    unsigned getNumIntervals() const { return (unsigned)s2iMap.size(); }
-
-    LiveInterval &getOrCreateInterval(int Slot) {
-      SS2IntervalMap::iterator I = s2iMap.find(Slot);
-      if (I == s2iMap.end())
-        I = s2iMap.insert(I,std::make_pair(Slot,LiveInterval(Slot,0.0F,true)));
-      return I->second;
-    }
-
-    LiveInterval &getInterval(int Slot) {
-      SS2IntervalMap::iterator I = s2iMap.find(Slot);
-      assert(I != s2iMap.end() && "Interval does not exist for stack slot");
-      return I->second;
-    }
-
-    const LiveInterval &getInterval(int Slot) const {
-      SS2IntervalMap::const_iterator I = s2iMap.find(Slot);
-      assert(I != s2iMap.end() && "Interval does not exist for stack slot");
-      return I->second;
-    }
-
-    bool hasInterval(unsigned Slot) const {
-      return s2iMap.count(Slot);
-    }
-
-    BumpPtrAllocator& getVNInfoAllocator() { return VNInfoAllocator; }
-
-    virtual void getAnalysisUsage(AnalysisUsage &AU) const;
-    virtual void releaseMemory();
-
-    /// runOnMachineFunction - pass entry point
-    virtual bool runOnMachineFunction(MachineFunction&);
-
-    /// print - Implement the dump method.
-    virtual void print(std::ostream &O, const Module* = 0) const;
-    void print(std::ostream *O, const Module* M = 0) const {
-      if (O) print(*O, M);
-    }
-  };
+class LiveStacks : public MachineFunctionPass {
+  const TargetRegisterInfo *TRI;
+
+  /// Special pool allocator for VNInfo's (LiveInterval val#).
+  ///
+  VNInfo::Allocator VNInfoAllocator;
+
+  /// S2IMap - Stack slot indices to live interval mapping.
+  ///
+  typedef std::unordered_map<int, LiveInterval> SS2IntervalMap;
+  SS2IntervalMap S2IMap;
+
+  /// S2RCMap - Stack slot indices to register class mapping.
+  std::map<int, const TargetRegisterClass *> S2RCMap;
+
+public:
+  static char ID; // Pass identification, replacement for typeid
+  LiveStacks() : MachineFunctionPass(ID) {
+    initializeLiveStacksPass(*PassRegistry::getPassRegistry());
+  }
+
+  typedef SS2IntervalMap::iterator iterator;
+  typedef SS2IntervalMap::const_iterator const_iterator;
+  const_iterator begin() const { return S2IMap.begin(); }
+  const_iterator end() const { return S2IMap.end(); }
+  iterator begin() { return S2IMap.begin(); }
+  iterator end() { return S2IMap.end(); }
+
+  unsigned getNumIntervals() const { return (unsigned)S2IMap.size(); }
+
+  LiveInterval &getOrCreateInterval(int Slot, const TargetRegisterClass *RC);
+
+  LiveInterval &getInterval(int Slot) {
+    assert(Slot >= 0 && "Spill slot indice must be >= 0");
+    SS2IntervalMap::iterator I = S2IMap.find(Slot);
+    assert(I != S2IMap.end() && "Interval does not exist for stack slot");
+    return I->second;
+  }
+
+  const LiveInterval &getInterval(int Slot) const {
+    assert(Slot >= 0 && "Spill slot indice must be >= 0");
+    SS2IntervalMap::const_iterator I = S2IMap.find(Slot);
+    assert(I != S2IMap.end() && "Interval does not exist for stack slot");
+    return I->second;
+  }
+
+  bool hasInterval(int Slot) const { return S2IMap.count(Slot); }
+
+  const TargetRegisterClass *getIntervalRegClass(int Slot) const {
+    assert(Slot >= 0 && "Spill slot indice must be >= 0");
+    std::map<int, const TargetRegisterClass *>::const_iterator I =
+        S2RCMap.find(Slot);
+    assert(I != S2RCMap.end() &&
+           "Register class info does not exist for stack slot");
+    return I->second;
+  }
+
+  VNInfo::Allocator &getVNInfoAllocator() { return VNInfoAllocator; }
+
+  void getAnalysisUsage(AnalysisUsage &AU) const override;
+  void releaseMemory() override;
+
+  /// runOnMachineFunction - pass entry point
+  bool runOnMachineFunction(MachineFunction &) override;
+
+  /// print - Implement the dump method.
+  void print(raw_ostream &O, const Module * = nullptr) const override;
+};
 }
 
 #endif /* LLVM_CODEGEN_LIVESTACK_ANALYSIS_H */