[llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Tue Nov 4 12:27:01 PST 2003
Changes in directory reopt/lib/LightWtProfiling:
UnpackTraceFunction.cpp updated: 1.9 -> 1.10
---
Log message:
Add comments.
Flesh out insertCopyMachineInstrs() a little bit.
Rename OperandAllocStateTuple to OperandAllocState, to match the others.
Implement getValueAllocStateFromModule in terms of three new stub functions.
---
Diffs of the changes: (+36 -20)
Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.9 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.10
--- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.9 Mon Nov 3 01:03:30 2003
+++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Tue Nov 4 12:26:06 2003
@@ -21,22 +21,21 @@
/// copies the value in Source to the location specified by Target, at
/// the beginning of B.
///
+/// FIXME: Not yet finished
+///
void insertCopyMachineInstrs (AllocInfo &Source, AllocInfo &Target,
MachineBasicBlock &B) {
- // FIXME: not yet implemented
-#if 0
- if (Source is memory && Target is register) {
- Insert load instruction from stack loc. Source into register Target
- } else if (Source is register && Target is register) {
- Insert move instruction from register Source to register Target
- } else if (Source is register && Target is memory) {
- Insert store instruction from register Source to stack loc. Target
- } else if (Source is memory && Target is memory) {
- Get a temporary register somehow
- Insert load instruction from stack loc. Source into register Temp
- Insert store instruction from register Temp to stack loc. Target
+ if (Source.AllocState == Spilled && Target.AllocState == Allocated) {
+ //Insert load instruction from stack loc. Source into register Target
+ } else if (Source.AllocState == Allocated && Target.AllocState == Allocated) {
+ //Insert move instruction from register Source to register Target
+ } else if (Source.AllocState == Allocated && Target.AllocState == Spilled) {
+ //Insert store instruction from register Source to stack loc. Target
+ } else if (Source.AllocState == Spilled && Target.AllocState == Spilled) {
+ //Get a temporary register Temp somehow
+ //Insert load instruction from stack loc. Source into register Temp
+ //Insert store instruction from register Temp to stack loc. Target
}
-#endif
}
/// Emit the same sequence of MachineInstrs that
@@ -103,7 +102,7 @@
}
extern "C" {
- struct OperandAllocStateTuple {
+ struct OperandAllocState {
unsigned Instruction;
unsigned Operand;
unsigned AllocState;
@@ -112,12 +111,12 @@
struct FunctionAllocState {
unsigned numTuples;
- struct OperandAllocStateTuple tuples[0];
+ struct OperandAllocState tuples[0];
};
struct ModuleAllocState {
unsigned numFunctions;
- struct FunctionAllocStateTuple *functions[0];
+ struct FunctionAllocState *functions[0];
};
/// This global is filled in by PhyRegAlloc's -save-ra-state option:
@@ -127,15 +126,32 @@
extern PhyRegAlloc::SavedStateMapTy ExportedFnAllocState;
+unsigned getSavedStateIndexOfFunction (Function *F) {
+}
+
+unsigned getSavedStateIndexOfInstruction (Function *F, Value *V) {
+}
+
+unsigned getSavedStateIndexOfOperandInInstruction (Function *F, Value *V,
+ unsigned VI) {
+}
+
/// Get the register number or stack position where V can be found in the
/// machine code for the function F.
///
AllocInfo getValueAllocStateFromModule (Function *F, Value *V) {
-
- // figure out the index I of F in _llvm_regAllocState
-
- // reconstruct the AllocInfo for V by looking at F's state, which is
+ // Figure out the indices of the in _llvm_regAllocState
+ unsigned FI = getSavedStateIndexOfFunction (F);
+ unsigned VI = getSavedStateIndexOfInstruction (F, V);
+ unsigned VO = getSavedStateIndexOfOperandInInstruction (F, V, VI);
+ // Reconstruct the AllocInfo for V by looking at F's state, which is
// in _llvm_regAllocState.functions[I]
+ FunctionAllocState &FAllocState = _llvm_regAllocState.functions[FI];
+ for (unsigned i = 0; i < FAllocState.numTuples; ++i) {
+ OperandAllocState &T = FAllocState.tuples[VI];
+ if (T.Instruction == VI && T.Operand == VO)
+ return AllocInfo (T.Instruction, T.Operand, T.AllocState, T.Placement);
+ }
}
/// Get the register number or stack position where V can be found in the
More information about the llvm-commits
mailing list