1 /* Title: LiveRangeInfo.h
2 Author: Ruchira Sasanka
6 This file constructs and keeps the LiveRang map which contains all the live
7 ranges used in a method.
11 All variables (llvm Values) are defined before they are used. However, a
12 constant may not be defined in the machine instruction stream if it can be
13 used as an immediate value within a machine instruction. However, register
14 allocation does not have to worry about immediate constants since they
15 do not require registers.
17 Since an llvm Value has a list of uses associated, it is sufficient to
18 record only the defs in a Live Range.
23 #ifndef LIVE_RANGE_INFO_H
24 #define LIVE_RANGE_INFO_H
27 #include "llvm/Type.h"
28 #include "llvm/Method.h"
29 #include "llvm/CodeGen/MachineInstr.h"
31 #include "llvm/Analysis/LiveVar/LiveVarSet.h"
33 #include "llvm/CodeGen/IGNode.h"
34 #include "llvm/CodeGen/LiveRange.h"
35 #include "llvm/CodeGen/RegClass.h"
39 #define size_type (unsigned int)
44 typedef hash_map <const Value *, LiveRange *, hashFuncValue> LiveRangeMapType;
45 typedef vector <const MachineInstr *> CallRetInstrListType;
52 const Method *const Meth; // Method for which live range info is held
54 LiveRangeMapType LiveRangeMap; // A map from Value * to LiveRange *
55 // created by constructLiveRanges
57 const TargetMachine& TM; // target machine description
58 vector<RegClass *> & RegClassList;// a vector containing register classess
59 const MachineRegInfo& MRI; // machine reg info
61 CallRetInstrListType CallRetInstrList; // a list of all call/ret instrs
63 void unionAndUpdateLRs(LiveRange *L1, LiveRange *L2);
65 void addInterference(const Instruction *const Inst,
66 const LiveVarSet *const LVSet);
68 void suggestRegs4CallRets();
72 LiveRangeInfo(const Method *const M,
73 const TargetMachine& tm,
74 vector<RegClass *> & RCList);
76 void constructLiveRanges();
78 inline void addLRToMap(const Value *Val, LiveRange *LR) {
79 assert( Val && LR && "Val/LR is NULL!\n");
80 assert( (! LiveRangeMap[ Val ]) && "LR already set in map");
81 LiveRangeMap[ Val ] = LR;
85 inline const LiveRangeMapType *const getLiveRangeMap() const
86 { return &LiveRangeMap; }
88 inline LiveRange *getLiveRangeForValue( const Value *const Val)
89 { return LiveRangeMap[ Val ]; }
91 inline CallRetInstrListType &getCallRetInstrList() {
92 return CallRetInstrList;
99 void printLiveRanges();