- Refactor the code that resolve basic block references to a TargetJITInfo
method.
- Added synchronizeICache() to TargetJITInfo. It is called after each block
of code is emitted to flush the icache. This ensures correct execution
on targets that have separate dcache and icache.
- Added PPC / Mac OS X specific code to do icache flushing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29276 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/Alpha/AlphaJITInfo.cpp b/lib/Target/Alpha/AlphaJITInfo.cpp
index 81f5e74..8dc5a47 100644
--- a/lib/Target/Alpha/AlphaJITInfo.cpp
+++ b/lib/Target/Alpha/AlphaJITInfo.cpp
@@ -304,3 +304,19 @@
}
}
}
+
+void AlphaJITInfo::resolveBBRefs(MachineCodeEmitter &MCE) {
+ // Resolve all forward branches now...
+ for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) {
+ unsigned* Location =
+ (unsigned*)MCE.getMachineBasicBlockAddress(BBRefs[i].first);
+ unsigned* Ref = (unsigned*)BBRefs[i].second;
+ intptr_t BranchTargetDisp =
+ (((unsigned char*)Location - (unsigned char*)Ref) >> 2) - 1;
+ DEBUG(std::cerr << "Fixup @ " << (void*)Ref << " to " << (void*)Location
+ << " Disp " << BranchTargetDisp
+ << " using " << (BranchTargetDisp & ((1 << 22)-1)) << "\n");
+ *Ref |= (BranchTargetDisp & ((1 << 21)-1));
+ }
+ BBRefs.clear();
+}