diff src/cpu/ppc/vm/assembler_ppc.hpp @ 17830:56e7f5560e60

8036767: PPC64: Support for little endian execution model Reviewed-by: goetz, kvn, dholmes, simonis Contributed-by: asmundak@google.com
author kvn
date Wed, 02 Apr 2014 11:24:44 -0700
parents 31e80afe3fed
children b384ba33c9a0
line wrap: on
line diff
--- a/src/cpu/ppc/vm/assembler_ppc.hpp	Mon Mar 31 13:08:03 2014 -0700
+++ b/src/cpu/ppc/vm/assembler_ppc.hpp	Wed Apr 02 11:24:44 2014 -0700
@@ -1025,15 +1025,14 @@
   }
 
   static void set_imm(int* instr, short s) {
-    short* p = ((short *)instr) + 1;
-    *p = s;
+    // imm is always in the lower 16 bits of the instruction,
+    // so this is endian-neutral. Same for the get_imm below.
+    uint32_t w = *(uint32_t *)instr;
+    *instr = (int)((w & ~0x0000FFFF) | (s & 0x0000FFFF));
   }
 
   static int get_imm(address a, int instruction_number) {
-    short imm;
-    short *p =((short *)a)+2*instruction_number+1;
-    imm = *p;
-    return (int)imm;
+    return (short)((int *)a)[instruction_number];
   }
 
   static inline int hi16_signed(  int x) { return (int)(int16_t)(x >> 16); }