[llvm-commits] CVS: llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.h BBLiveVar.cpp FunctionLiveVarInfo.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Tue Feb 24 13:47:06 PST 2004
Changes in directory llvm/lib/Target/Sparc/LiveVar:
FunctionLiveVarInfo.h added (r1.1)
BBLiveVar.cpp updated: 1.44 -> 1.45
FunctionLiveVarInfo.cpp updated: 1.53 -> 1.54
---
Log message:
FunctionLiveVarInfo.h moved: include/llvm/CodeGen -> lib/Target/Sparc/LiveVar
---
Diffs of the changes: (+113 -2)
Index: llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.h
diff -c /dev/null llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.h:1.1
*** /dev/null Tue Feb 24 13:45:55 2004
--- llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.h Tue Feb 24 13:45:45 2004
***************
*** 0 ****
--- 1,111 ----
+ //===-- CodeGen/FunctionLiveVarInfo.h - LiveVar Analysis --------*- 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 is the interface for live variable info of a function that is required
+ // by any other part of the compiler
+ //
+ // After the analysis, getInSetOfBB or getOutSetofBB can be called to get
+ // live var info of a BB.
+ //
+ // The live var set before an instruction can be obtained in 2 ways:
+ //
+ // 1. Use the method getLiveVarSetAfterInst(Instruction *) to get the LV Info
+ // just after an instruction. (also exists getLiveVarSetBeforeInst(..))
+ //
+ // This function caluclates the LV info for a BB only once and caches that
+ // info. If the cache does not contain the LV info of the instruction, it
+ // calculates the LV info for the whole BB and caches them.
+ //
+ // Getting liveVar info this way uses more memory since, LV info should be
+ // cached. However, if you need LV info of nearly all the instructions of a
+ // BB, this is the best and simplest interfrace.
+ //
+ // 2. Use the OutSet and applyTranferFuncForInst(const Instruction *const Inst)
+ // declared in LiveVarSet and traverse the instructions of a basic block in
+ // reverse (using const_reverse_iterator in the BB class).
+ //
+ //===----------------------------------------------------------------------===//
+
+ #ifndef FUNCTION_LIVE_VAR_INFO_H
+ #define FUNCTION_LIVE_VAR_INFO_H
+
+ #include "Support/hash_map"
+ #include "llvm/Pass.h"
+ #include "llvm/CodeGen/ValueSet.h"
+
+ namespace llvm {
+
+ class BBLiveVar;
+ class MachineInstr;
+
+ class FunctionLiveVarInfo : public FunctionPass {
+ // Machine Instr to LiveVarSet Map for providing LVset BEFORE each inst
+ // These sets are owned by this map and will be freed in releaseMemory().
+ hash_map<const MachineInstr *, ValueSet *> MInst2LVSetBI;
+
+ // Machine Instr to LiveVarSet Map for providing LVset AFTER each inst.
+ // These sets are just pointers to sets in MInst2LVSetBI or BBLiveVar.
+ hash_map<const MachineInstr *, ValueSet *> MInst2LVSetAI;
+
+ hash_map<const BasicBlock*, BBLiveVar*> BBLiveVarInfo;
+
+ // Stored Function that the data is computed with respect to
+ const Function *M;
+
+ // --------- private methods -----------------------------------------
+
+ // constructs BBLiveVars and init Def and In sets
+ void constructBBs(const Function *F);
+
+ // do one backward pass over the CFG
+ bool doSingleBackwardPass(const Function *F, unsigned int iter);
+
+ // calculates live var sets for instructions in a BB
+ void calcLiveVarSetsForBB(const BasicBlock *BB);
+
+ public:
+ // --------- Implement the FunctionPass interface ----------------------
+
+ // runOnFunction - Perform analysis, update internal data structures.
+ virtual bool runOnFunction(Function &F);
+
+ // releaseMemory - After LiveVariable analysis has been used, forget!
+ virtual void releaseMemory();
+
+ // getAnalysisUsage - Provide self!
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ }
+
+ // --------- Functions to access analysis results -------------------
+
+ // get OutSet of a BB
+ const ValueSet &getOutSetOfBB(const BasicBlock *BB) const;
+ ValueSet &getOutSetOfBB(const BasicBlock *BB) ;
+
+ // get InSet of a BB
+ const ValueSet &getInSetOfBB(const BasicBlock *BB) const;
+ ValueSet &getInSetOfBB(const BasicBlock *BB) ;
+
+ // gets the Live var set BEFORE an instruction.
+ // if BB is specified and the live var set has not yet been computed,
+ // it will be computed on demand.
+ const ValueSet &getLiveVarSetBeforeMInst(const MachineInstr *MI,
+ const BasicBlock *BB = 0);
+
+ // gets the Live var set AFTER an instruction
+ // if BB is specified and the live var set has not yet been computed,
+ // it will be computed on demand.
+ const ValueSet &getLiveVarSetAfterMInst(const MachineInstr *MI,
+ const BasicBlock *BB = 0);
+ };
+
+ } // End llvm namespace
+
+ #endif
Index: llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp
diff -u llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.44 llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.45
--- llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.44 Wed Feb 11 20:27:09 2004
+++ llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp Tue Feb 24 13:45:45 2004
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "BBLiveVar.h"
-#include "llvm/CodeGen/FunctionLiveVarInfo.h"
+#include "FunctionLiveVarInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/Support/CFG.h"
Index: llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp
diff -u llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp:1.53 llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp:1.54
--- llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp:1.53 Wed Feb 11 20:27:09 2004
+++ llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp Tue Feb 24 13:45:45 2004
@@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/CodeGen/FunctionLiveVarInfo.h"
+#include "FunctionLiveVarInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Target/TargetMachine.h"
More information about the llvm-commits
mailing list