diff options
author | Misha Brukman <brukman+llvm@gmail.com> | 2003-11-21 23:48:54 +0000 |
---|---|---|
committer | Misha Brukman <brukman+llvm@gmail.com> | 2003-11-21 23:48:54 +0000 |
commit | a59f41fc6c7eb9422e609e25442224302cba9fd0 (patch) | |
tree | 24540da26f328ee73c00ecf0cfc3e134a2192956 /lib/Target/SparcV9/SparcV9CodeEmitter.cpp | |
parent | c282f5a380b0b1f46d270a608dc513a51792f552 (diff) | |
download | external_llvm-a59f41fc6c7eb9422e609e25442224302cba9fd0.zip external_llvm-a59f41fc6c7eb9422e609e25442224302cba9fd0.tar.gz external_llvm-a59f41fc6c7eb9422e609e25442224302cba9fd0.tar.bz2 |
* Add code to flush the ICache, which any self-respecting SMC must do
* Restore registers *after* everything else to avoid any possible side effects
This fixes McCat-imp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10147 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/SparcV9/SparcV9CodeEmitter.cpp')
-rw-r--r-- | lib/Target/SparcV9/SparcV9CodeEmitter.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp index f56e7f3..be677e0 100644 --- a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp +++ b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp @@ -380,18 +380,21 @@ void JITResolver::CompilationCallback() { // Overwrite it TheJITResolver->insertJumpAtAddr(Target, CodeBegin); - RestoreRegisters(DoubleFP, FSR, FPRS, CCR); + // Flush the I-Cache: FLUSH clears out a doubleword at a given address + // Self-modifying code MUST clear out the I-Cache to be portable +#if defined(sparc) || defined(__sparc__) || defined(__sparcv9) + for (int i = -Offset, e = 32-((int64_t)Offset); i < e; i += 8) + __asm__ __volatile__ ("flush %%i7 + %0" : : "r" (i)); +#endif // Change the return address to re-execute the restore, then the jump. - // However, we can't just modify %i7 here, because we return to the function - // that will restore the floating-point registers for us. Thus, we just return - // the value we want it to be, and the parent will take care of setting %i7 - // correctly. DEBUG(std::cerr << "Callback returning to: 0x" << std::hex << (CameFrom-Offset-12) << "\n"); #if defined(sparc) || defined(__sparc__) || defined(__sparcv9) __asm__ __volatile__ ("sub %%i7, %0, %%i7" : : "r" (Offset+12)); #endif + + RestoreRegisters(DoubleFP, FSR, FPRS, CCR); } /// emitStubForFunction - This method is used by the JIT when it needs to emit |