[llvm-commits] [regalloc_linearscan] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Tue Sep 30 14:56:02 PDT 2003
Changes in directory llvm/lib/CodeGen:
RegAllocLinearScan.cpp added (r1.1.2.1)
---
Log message:
Initial commit of linear scan allocator. This is just a sceleton file; it does not really work
---
Diffs of the changes:
Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp
diff -c /dev/null llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.1.2.1
*** /dev/null Tue Sep 30 14:55:13 2003
--- llvm/lib/CodeGen/RegAllocLinearScan.cpp Tue Sep 30 14:55:02 2003
***************
*** 0 ****
--- 1,70 ----
+ //===-- RegAllocLinearScan.cpp - Linear Scan register allocator ---------===//
+ //
+ // This file implements a linear scan register allocator..
+ //
+ //===--------------------------------------------------------------------===//
+
+ #define DEBUG_TYPE "regalloc"
+
+ #include "llvm/Target/MRegisterInfo.h"
+ #include "llvm/Target/TargetMachine.h"
+
+ namespace {
+ Statistic<> NumSpilled ("ra-linearscan", "Number of registers spilled");
+ Statistic<> NumReloaded("ra-linearscan", "Number of registers reloaded");
+
+ class RA : public MachineFunctionPass {
+ private:
+ MachineFunction *MF;
+ const TargetMachine *TM;
+ const MRegisterInfo *RegInfo;
+ LiveVariables* LV;
+
+ // StackSlotForVirtReg - Maps virtual regs to the frame index where these
+ // values are spilled.
+ std::map<unsigned, int> StackSlotForVirtReg;
+
+ // Virt2PhysRegMap - This map contains entries for each virtual register
+ // that is currently available in a physical register.
+ //
+ std::map<unsigned, unsigned> Virt2PhysRegMap;
+
+ // Phys2VirtRegMap - This map contains entries for each physical register
+ // that currently maps a virtual register..
+ //
+ std::map<unsigned, unsigned> Phys2VirtRegMap;
+
+ public:
+ virtual const char* getPassName() const {
+ return "Linear Scan Register Allocator";
+ }
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.addRequired<LiveVariables>();
+ AU.addRequiredID(PHIEliminationID);
+ MachineFunctionPass::getAnalysisUsage(AU);
+ }
+
+ private:
+ /// runOnMachineFunction - Register allocate the whole function
+ bool runOnMachineFunction(MachineFunction &Fn);
+ };
+ }
+
+ /// runOnMachineFunction - Register allocate the whole function
+ ///
+ bool RA::runOnMachineFunction(MachineFunction &Fn) {
+ DEBUG(std::cerr << "Machine Function " << "\n");
+ MF = &Fn;
+ TM = &Fn.getTarget();
+ RegInfo = TM->getRegisterInfo();
+
+ LV = &getAnalysis<LiveVariables>();
+ // compute live intervals
+ // liner scan algorithm
+
+ return true;
+ }
+
+ FunctionPass *createLinearScanRegisterAllocator() {
+ return new RA();
+ }
More information about the llvm-commits
mailing list