[llvm-commits] [PATCH] MipsJITInfo.cpp on OpenBSD

Brian Callahan bcallah at devio.us
Fri Dec 28 11:48:45 PST 2012


Hi list --

A few days ago I submitted a patch to the LLVM Bugzilla 
(http://llvm.org/bugs/show_bug.cgi?id=14721) regarding an LLVM build 
failure on OpenBSD/mips64el. I was asked to send the patch here.

Here is a summary of the bug report:
Mips register patch

binutils on OpenBSD is quite old, which causes the build on mips64el to 
fail on MipsJITInfo.cpp - it complains of illegal operands. The 
attachment patches it so that it will build. All the patch does is 
replace the register aliases with the actual register (i.e. changing $t8 
to $24). The registers are identical to both mips and mips64, so it 
should not disrupt 32-bit Mips builds.

The patch attached to this email is slightly different from the one 
submitted to Bugzilla, this patch supersedes the Bugzilla one.

I am not subscribed to this list; please CC me on any replies.

Thanks.

~Brian
-------------- next part --------------
$OpenBSD$
--- lib/Target/Mips/MipsJITInfo.cpp.orig	Tue Dec  4 15:23:05 2012
+++ lib/Target/Mips/MipsJITInfo.cpp	Thu Dec 27 23:21:18 2012
@@ -104,7 +104,7 @@ void MipsCompilationCallback();
     ".ent " ASMPREFIX "MipsCompilationCallback\n"
     ".frame  $sp, 32, $ra\n"
     ".set  noreorder\n"
-    ".cpload $t9\n"
+    ".cpload $25\n"
 
     "addiu $sp, $sp, -64\n"
     ".cprestore 16\n"
@@ -115,35 +115,35 @@ void MipsCompilationCallback();
     // concerned. We also need to save the ra register since it contains the
     // original return address, and t8 register since it contains the address
     // of the end of function stub.
-    "sw $a0, 20($sp)\n"
-    "sw $a1, 24($sp)\n"
-    "sw $a2, 28($sp)\n"
-    "sw $a3, 32($sp)\n"
+    "sw $4, 20($sp)\n"
+    "sw $5, 24($sp)\n"
+    "sw $6, 28($sp)\n"
+    "sw $7, 32($sp)\n"
     "sw $ra, 36($sp)\n"
-    "sw $t8, 40($sp)\n"
+    "sw $24, 40($sp)\n"
     "sdc1 $f12, 48($sp)\n"
     "sdc1 $f14, 56($sp)\n"
 
     // t8 points at the end of function stub. Pass the beginning of the stub
     // to the MipsCompilationCallbackC.
-    "addiu $a0, $t8, -16\n"
+    "addiu $4, $24, -16\n"
     "jal " ASMPREFIX "MipsCompilationCallbackC\n"
     "nop\n"
 
     // Restore registers.
-    "lw $a0, 20($sp)\n"
-    "lw $a1, 24($sp)\n"
-    "lw $a2, 28($sp)\n"
-    "lw $a3, 32($sp)\n"
+    "lw $4, 20($sp)\n"
+    "lw $5, 24($sp)\n"
+    "lw $6, 28($sp)\n"
+    "lw $7, 32($sp)\n"
     "lw $ra, 36($sp)\n"
-    "lw $t8, 40($sp)\n"
+    "lw $24, 40($sp)\n"
     "ldc1 $f12, 48($sp)\n"
     "ldc1 $f14, 56($sp)\n"
     "addiu $sp, $sp, 64\n"
 
     // Jump to the (newly modified) stub to invoke the real function.
-    "addiu $t8, $t8, -16\n"
-    "jr $t8\n"
+    "addiu $24, $24, -16\n"
+    "jr $24\n"
     "nop\n"
 
     ".set  reorder\n"
@@ -168,9 +168,9 @@ extern "C" void MipsCompilationCallbackC(intptr_t Stub
   // Rewrite the function stub so that we don't end up here every time we
   // execute the call. We're replacing the first four instructions of the
   // stub with code that jumps to the compiled function:
-  //   lui $t9, %hi(NewVal)
-  //   addiu $t9, $t9, %lo(NewVal)
-  //   jr $t9
+  //   lui $25, %hi(NewVal)
+  //   addiu $25, $25, %lo(NewVal)
+  //   jr $25
   //   nop
 
   int Hi = ((unsigned)NewVal & 0xffff0000) >> 16;


More information about the llvm-commits mailing list