[llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/Phase2.cpp
Joel Stanley
jstanley at cs.uiuc.edu
Tue Apr 8 22:37:01 PDT 2003
Changes in directory llvm/lib/Reoptimizer/Inst:
Phase2.cpp updated: 1.2 -> 1.3
---
Log message:
Cleanup.
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/Inst/Phase2.cpp
diff -u llvm/lib/Reoptimizer/Inst/Phase2.cpp:1.2 llvm/lib/Reoptimizer/Inst/Phase2.cpp:1.3
--- llvm/lib/Reoptimizer/Inst/Phase2.cpp:1.2 Tue Apr 8 22:35:57 2003
+++ llvm/lib/Reoptimizer/Inst/Phase2.cpp Tue Apr 8 22:37:42 2003
@@ -125,12 +125,6 @@
AddressRange range;
while(elfReader.GetNextFunction(funcName, range)) {
-#if 0
- if(funcName == "l16_floogle") {
- cerr << "Printing information about function " << funcName << endl;
- m_instManip.printRange(range);
- }
-#endif
if(funcName == "l16_fibs") {
//cerr << "Printing information about function " << funcName << endl;
//m_instManip.printRange(range);
@@ -150,96 +144,6 @@
fflush(stdout);
}
-#if 0
-static void generateLoad64(uint64_t value, vector<unsigned>& snippet)
-{
- // Use %o0 and %o1 to load the 64-bit value 'value' into %o0.
- // Place the generated instructions into instruction-vector 'snippet'.
-
- unsigned high32 = (unsigned) (value >> 32);
- unsigned low32 = (unsigned) value;
- unsigned low10 = high32 & 0x000003ff;
-
- snippet.push_back(0x11000000 | (high32 >> 10)); // sethi (upper 22b of upper wrd), %o0
- snippet.push_back(0x90122000 | low10); // or %o0, (lower 10b of upper wrd), %o0
- snippet.push_back(0x912a3020); // sllx %o0, 32, %o0
- low10 = low32 & 0x000003ff;
- snippet.push_back(0x13000000 | (low32 >> 10)); // sethi (upper 22b of lwr wrd), %o1
- snippet.push_back(0x90120009); // or %o0, %o1, %o0
- snippet.push_back(0x90022000 | low10); // add %o0, (lwr 10b of lwr wrd), %o0
-}
-
-void Phase2::transformFunction(AddressRange& range)
-{
- ////////////////
- // 1. Replace the first instruction in F with a branch to a new slot (annulling bit
- // should specify *not* to execute the branch delay slot).
- //
- // 2. At the new slot write first the replaced instruction followed by code to call
- // the phase 3 function with the address of of F as an argument.
- //
- // 3. At the new slot write a branch back to immediately after the branch-to-slot
- // instruction in the original code.
- //
-
- // Obtain address of first replacable instruction in function
- VirtualMem* vm = m_traceCache.getVM();
- uint64_t repInstAddr = m_instManip.skipFunctionHdr(range.first, vm);
-
- // Obtain new slot's base address, build unconditional-anulled branch to slot base,
- // and write over original instruction (saving it for later use).
-
- MemoryManager* mm = m_traceCache.getMemMgr();
- uint64_t slotBase = mm->getMemory(11);
-
- // 0x30480000 is branch-always-annul-high instruction (without imm offset)
- unsigned branchToSlot = getUndepJumpInstr(0x30480000, slotBase, repInstAddr);
- unsigned origInstr = vm->readInstrFrmVm(repInstAddr);
-
- if(isBranchInstr(origInstr))
- assert(0 && "Unhandled case: branch instruction first in function body");
-
- vm->writeInstToVM(repInstAddr, branchToSlot);
-
- // Build instructions into snippet vector for later insertion.
- vector<unsigned> snippet;
-
- // Pass the starting address of F as the argument to phase3
- m_instManip.generateLoad64(0xefefefefabababab, snippet);
-
- // Build call to phase3
- uint64_t phase3Addr = (uint64_t)(&phase3);
- unsigned call = getCallInstr(phase3Addr, slotBase + 4 * snippet.size());
- snippet.push_back(call); // call phase3
- snippet.push_back(0x01000000); // nop
-
- // Insert the instruction from the original code which has now
- // been replaced with a branch.
- snippet.push_back(origInstr); // Inst from orig code (now replaced with branch)
-
- // Build unconditional branch to repInstAddr + 4; this ensures execution of the code
- // is resumed after phase3 is called and performs its transformations.
- unsigned branchBack =
- getUndepJumpInstr(0x30480000, repInstAddr + 4, slotBase + 4 * snippet.size());
- snippet.push_back(branchBack); // branch to original code
- snippet.push_back(0x01000000); // nop
-
- // Copy the snippet code into the slot.
- uint64_t currAddr = slotBase;
- for(vector<unsigned>::iterator i = snippet.begin(), e = snippet.end(); i != e; ++i) {
- vm->writeInstToVM(currAddr, *i);
- currAddr += 4;
- }
-
-#if 0
- cerr << "Dumping inserted snippet..." << endl;
- m_instManip.printRange(slotBase, currAddr - 4);
- fflush(stdout);
- cerr << "Done w/ transformFunction" << endl;
-#endif
-}
-#endif
-
void Phase2::transformFunction(AddressRange& range)
{
////////////////
@@ -274,6 +178,7 @@
vector<unsigned> snippet;
// Pass the starting address of F as the argument to phase3
+ // Currently, just some 64-bit value for verification purposes...
m_instManip.generateLoad64(0xefefefefabababab, snippet);
// Build call to phase 3
More information about the llvm-commits
mailing list