Browse Source

PPC: Clean up masked shift/rotate target settings.

Mike Pall 15 years ago
parent
commit
844e40d700
3 changed files with 14 additions and 17 deletions
  1. 10 11
      src/lj_arch.h
  2. 2 3
      src/lj_opt_fold.c
  3. 2 3
      src/lj_record.c

+ 10 - 11
src/lj_arch.h

@@ -52,7 +52,8 @@
 #define LJ_TARGET_X86		1
 #define LJ_TARGET_X86ORX64	1
 #define LJ_PAGESIZE		4096
-#define LJ_TARGET_MASKEDSHIFT	1
+#define LJ_TARGET_MASKSHIFT	1
+#define LJ_TARGET_MASKROT	1
 
 #elif LUAJIT_TARGET == LUAJIT_ARCH_X64
 
@@ -62,7 +63,8 @@
 #define LJ_TARGET_X64		1
 #define LJ_TARGET_X86ORX64	1
 #define LJ_PAGESIZE		4096
-#define LJ_TARGET_MASKEDSHIFT	1
+#define LJ_TARGET_MASKSHIFT	1
+#define LJ_TARGET_MASKROT	1
 
 #elif LUAJIT_TARGET == LUAJIT_ARCH_PPC
 
@@ -76,7 +78,8 @@
 #define LJ_TARGET_PPC		1
 #define LJ_TARGET_PPCSPE	1
 #define LJ_PAGESIZE		4096
-#define LJ_TARGET_MASKEDSHIFT	1
+#define LJ_TARGET_MASKSHIFT	0
+#define LJ_TARGET_MASKROT	1
 #define LJ_ARCH_NOJIT		1
 
 #else
@@ -92,6 +95,9 @@
 #if defined(_LITTLE_ENDIAN)
 #error "No support for little-endian PowerPC"
 #endif
+#if defined(_LP64)
+#error "No support for PowerPC 64 bit mode"
+#endif
 #endif
 #endif
 
@@ -113,16 +119,9 @@
 #if LJ_ARCH_BITS == 32
 #define LJ_32			1
 #define LJ_64			0
-#elif LJ_ARCH_BITS == 64
+#else
 #define LJ_32			0
 #define LJ_64			1
-#else
-#error "Bad LJ_ARCH_BITS setting"
-#endif
-
-/* Whether target CPU masks the shift count by the operand length or not. */
-#ifndef LJ_TARGET_MASKEDSHIFT
-#define LJ_TARGET_MASKEDSHIFT	0
 #endif
 
 #endif

+ 2 - 3
src/lj_opt_fold.c

@@ -811,17 +811,16 @@ LJFOLD(BROL any BAND)
 LJFOLD(BROR any BAND)
 LJFOLDF(simplify_shift_andk)
 {
-#if LJ_TARGET_MASKEDSHIFT
   IRIns *irk = IR(fright->op2);
   PHIBARRIER(fright);
-  if (irk->o == IR_KINT) {  /* i o (j & 31) ==> i o j */
+  if ((fins->o < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) &&
+      irk->o == IR_KINT) {  /* i o (j & 31) ==> i o j */
     int32_t k = irk->i & 31;
     if (k == 31) {
       fins->op2 = fright->op1;
       return RETRYFOLD;
     }
   }
-#endif
   return NEXTFOLD;
 }
 

+ 2 - 3
src/lj_record.c

@@ -1552,10 +1552,9 @@ static void LJ_FASTCALL recff_bit_shift(jit_State *J, RecordFFData *rd)
 {
   TRef tr = lj_ir_tobit(J, J->base[0]);
   TRef tsh = lj_ir_tobit(J, J->base[1]);
-#if !LJ_TARGET_MASKEDSHIFT
-  if (!tref_isk(tsh))
+  if (!(rd->data < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) &&
+      !tref_isk(tsh))
     tsh = emitir(IRTI(IR_BAND), tsh, lj_ir_kint(J, 31));
-#endif
   J->base[0] = emitir(IRTI(rd->data), tr, tsh);
 }