/[pcre]/code/trunk/sljit/sljitLir.c
ViewVC logotype

Diff of /code/trunk/sljit/sljitLir.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 875 by zherczeg, Sat Jan 14 17:05:53 2012 UTC revision 1182 by zherczeg, Sun Oct 28 05:22:32 2012 UTC
# Line 122  Line 122 
122  #endif  #endif
123    
124  #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)  #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
125          #define IS_CONDITIONAL  0x04          #define IS_COND         0x04
126          #define IS_BL           0x08          #define IS_BL           0x08
127          /* cannot be encoded as branch */          /* cannot be encoded as branch */
128          #define B_TYPE0         0x00          #define B_TYPE0         0x00
# Line 159  Line 159 
159          #define PATCH_J         0x80          #define PATCH_J         0x80
160    
161          /* instruction types */          /* instruction types */
162          #define UNMOVABLE_INS   0          #define MOVABLE_INS     0
163          /* 1 - 31 last destination register */          /* 1 - 31 last destination register */
         #define FCSR_FCC        32  
164          /* no destination (i.e: store) */          /* no destination (i.e: store) */
165          #define MOVABLE_INS     33          #define UNMOVABLE_INS   32
166            /* FPU status register */
167            #define FCSR_FCC        33
168    #endif
169    
170    #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
171            #define IS_MOVABLE      0x04
172            #define IS_COND         0x08
173            #define IS_CALL         0x10
174    
175            #define PATCH_B         0x20
176            #define PATCH_CALL      0x40
177    
178            /* instruction types */
179            #define MOVABLE_INS     0
180            /* 1 - 31 last destination register */
181            /* no destination (i.e: store) */
182            #define UNMOVABLE_INS   32
183    
184            #define DST_INS_MASK    0xff
185    
186            /* ICC_SET is the same as SET_FLAGS. */
187            #define ICC_IS_SET      (1 << 23)
188            #define FCC_IS_SET      (1 << 24)
189    #endif
190    
191    #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
192    #define SLJIT_HAS_VARIABLE_LOCALS_OFFSET 1
193    #endif
194    
195    #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
196    #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
197    #ifdef _WIN64
198    #define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_w))
199    #else
200    #define FIXED_LOCALS_OFFSET (sizeof(sljit_w))
201    #endif
202    #endif
203    
204    #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
205    #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
206    #if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
207    #define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_w))
208    #else
209    #define FIXED_LOCALS_OFFSET (2 * sizeof(sljit_w))
210    #endif
211    #endif
212    
213    #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
214    #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
215    #define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_w))
216    #endif
217    
218    #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
219    #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
220    #define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_w))
221    #endif
222    
223    #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
224    #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
225    #define FIXED_LOCALS_OFFSET (23 * sizeof(sljit_w))
226    #endif
227    
228    #if (defined SLJIT_HAS_VARIABLE_LOCALS_OFFSET && SLJIT_HAS_VARIABLE_LOCALS_OFFSET)
229    
230    #define ADJUST_LOCAL_OFFSET(p, i) \
231            if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
232                    (i) += compiler->locals_offset;
233    
234    #elif (defined SLJIT_HAS_FIXED_LOCALS_OFFSET && SLJIT_HAS_FIXED_LOCALS_OFFSET)
235    
236    #define ADJUST_LOCAL_OFFSET(p, i) \
237            if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
238                    (i) += FIXED_LOCALS_OFFSET;
239    
240    #else
241    
242    #define ADJUST_LOCAL_OFFSET(p, i)
243    
244  #endif  #endif
245    
246  #endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */  #endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
# Line 192  static int compiler_initialized = 0; Line 269  static int compiler_initialized = 0;
269  static void init_compiler(void);  static void init_compiler(void);
270  #endif  #endif
271    
   
272  SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)  SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
273  {  {
274          struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler));          struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler));
# Line 204  SLJIT_API_FUNC_ATTRIBUTE struct sljit_co Line 280  SLJIT_API_FUNC_ATTRIBUTE struct sljit_co
280                  sizeof(sljit_b) == 1 && sizeof(sljit_ub) == 1                  sizeof(sljit_b) == 1 && sizeof(sljit_ub) == 1
281                  && sizeof(sljit_h) == 2 && sizeof(sljit_uh) == 2                  && sizeof(sljit_h) == 2 && sizeof(sljit_uh) == 2
282                  && sizeof(sljit_i) == 4 && sizeof(sljit_ui) == 4                  && sizeof(sljit_i) == 4 && sizeof(sljit_ui) == 4
283                  && ((sizeof(sljit_w) == 4 && sizeof(sljit_uw) == 4) || (sizeof(sljit_w) == 8 && sizeof(sljit_uw) == 8)),                  && (sizeof(sljit_p) == 4 || sizeof(sljit_p) == 8)
284                    && (sizeof(sljit_w) == 4 || sizeof(sljit_w) == 8)
285                    && (sizeof(sljit_uw) == 4 || sizeof(sljit_uw) == 8),
286                  invalid_integer_types);                  invalid_integer_types);
287    
288          /* Only the non-zero members must be set. */          /* Only the non-zero members must be set. */
# Line 228  SLJIT_API_FUNC_ATTRIBUTE struct sljit_co Line 306  SLJIT_API_FUNC_ATTRIBUTE struct sljit_co
306          compiler->abuf->used_size = 0;          compiler->abuf->used_size = 0;
307    
308          compiler->temporaries = -1;          compiler->temporaries = -1;
309          compiler->generals = -1;          compiler->saveds = -1;
310    
311  #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)  #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
312          compiler->args = -1;          compiler->args = -1;
# Line 250  SLJIT_API_FUNC_ATTRIBUTE struct sljit_co Line 328  SLJIT_API_FUNC_ATTRIBUTE struct sljit_co
328          compiler->delay_slot = UNMOVABLE_INS;          compiler->delay_slot = UNMOVABLE_INS;
329  #endif  #endif
330    
331    #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
332            compiler->delay_slot = UNMOVABLE_INS;
333    #endif
334    
335  #if (defined SLJIT_NEEDS_COMPILER_INIT && SLJIT_NEEDS_COMPILER_INIT)  #if (defined SLJIT_NEEDS_COMPILER_INIT && SLJIT_NEEDS_COMPILER_INIT)
336          if (!compiler_initialized) {          if (!compiler_initialized) {
337                  init_compiler();                  init_compiler();
# Line 291  SLJIT_API_FUNC_ATTRIBUTE void sljit_free Line 373  SLJIT_API_FUNC_ATTRIBUTE void sljit_free
373          /* Remove thumb mode flag. */          /* Remove thumb mode flag. */
374          SLJIT_FREE_EXEC((void*)((sljit_uw)code & ~0x1));          SLJIT_FREE_EXEC((void*)((sljit_uw)code & ~0x1));
375  }  }
376  #elif (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)  #elif (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
377  SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)  SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
378  {  {
379          /* Resolve indirection. */          /* Resolve indirection. */
# Line 473  static SLJIT_INLINE void set_const(struc Line 555  static SLJIT_INLINE void set_const(struc
555          }          }
556    
557  #define FUNCTION_CHECK_IS_REG(r) \  #define FUNCTION_CHECK_IS_REG(r) \
558          ((r) == SLJIT_UNUSED || (r) == SLJIT_LOCALS_REG || \          ((r) == SLJIT_UNUSED || \
559          ((r) >= SLJIT_TEMPORARY_REG1 && (r) <= SLJIT_TEMPORARY_REG3 && (r) <= SLJIT_TEMPORARY_REG1 - 1 + compiler->temporaries) || \          ((r) >= SLJIT_TEMPORARY_REG1 && (r) <= SLJIT_TEMPORARY_REG1 - 1 + compiler->temporaries) || \
560          ((r) >= SLJIT_GENERAL_REG1 && (r) <= SLJIT_GENERAL_REG3 && (r) <= SLJIT_GENERAL_REG1 - 1 + compiler->generals)) \          ((r) >= SLJIT_SAVED_REG1 && (r) <= SLJIT_SAVED_REG1 - 1 + compiler->saveds))
561    
562  #define FUNCTION_CHECK_SRC(p, i) \  #define FUNCTION_CHECK_SRC(p, i) \
563          SLJIT_ASSERT(compiler->temporaries != -1 && compiler->generals != -1); \          SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \
564          if (((p) >= SLJIT_TEMPORARY_REG1 && (p) <= SLJIT_TEMPORARY_REG1 - 1 + compiler->temporaries) || \          if (FUNCTION_CHECK_IS_REG(p)) \
565                          ((p) >= SLJIT_GENERAL_REG1 && (p) <= SLJIT_GENERAL_REG1 - 1 + compiler->generals) || \                  SLJIT_ASSERT((i) == 0 && (p) != SLJIT_UNUSED); \
                         (p) == SLJIT_LOCALS_REG) \  
                 SLJIT_ASSERT(i == 0); \  
566          else if ((p) == SLJIT_IMM) \          else if ((p) == SLJIT_IMM) \
567                  ; \                  ; \
568            else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
569                    SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \
570          else if ((p) & SLJIT_MEM) { \          else if ((p) & SLJIT_MEM) { \
571                  SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \                  SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \
572                  if ((p) & 0xf0) { \                  if ((p) & 0xf0) { \
573                          SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \                          SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \
574                          SLJIT_ASSERT(((p) & 0xf0) != (SLJIT_LOCALS_REG << 4) && !(i & ~0x3)); \                          SLJIT_ASSERT(!((i) & ~0x3)); \
575                  } else \                  } \
                         SLJIT_ASSERT((((p) >> 4) & 0xf) == 0); \  
576                  SLJIT_ASSERT(((p) >> 9) == 0); \                  SLJIT_ASSERT(((p) >> 9) == 0); \
577          } \          } \
578          else \          else \
579                  SLJIT_ASSERT_STOP();                  SLJIT_ASSERT_STOP();
580    
581  #define FUNCTION_CHECK_DST(p, i) \  #define FUNCTION_CHECK_DST(p, i) \
582          SLJIT_ASSERT(compiler->temporaries != -1 && compiler->generals != -1); \          SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \
583          if (((p) >= SLJIT_TEMPORARY_REG1 && (p) <= SLJIT_TEMPORARY_REG1 - 1 + compiler->temporaries) || \          if (FUNCTION_CHECK_IS_REG(p)) \
584                          ((p) >= SLJIT_GENERAL_REG1 && (p) <= SLJIT_GENERAL_REG1 - 1 + compiler->generals) || \                  SLJIT_ASSERT((i) == 0); \
585                          (p) == SLJIT_UNUSED) \          else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
586                  SLJIT_ASSERT(i == 0); \                  SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \
587          else if ((p) & SLJIT_MEM) { \          else if ((p) & SLJIT_MEM) { \
588                  SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \                  SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \
589                  if ((p) & 0xf0) { \                  if ((p) & 0xf0) { \
590                          SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \                          SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \
591                          SLJIT_ASSERT(((p) & 0xf0) != (SLJIT_LOCALS_REG << 4) && !(i & ~0x3)); \                          SLJIT_ASSERT(!((i) & ~0x3)); \
592                  } else \                  } \
                         SLJIT_ASSERT((((p) >> 4) & 0xf) == 0); \  
593                  SLJIT_ASSERT(((p) >> 9) == 0); \                  SLJIT_ASSERT(((p) >> 9) == 0); \
594          } \          } \
595          else \          else \
# Line 531  static SLJIT_INLINE void set_const(struc Line 611  static SLJIT_INLINE void set_const(struc
611                  SLJIT_ASSERT_STOP();                  SLJIT_ASSERT_STOP();
612    
613  #define FUNCTION_CHECK_OP1() \  #define FUNCTION_CHECK_OP1() \
614          if (GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_MOVU_SI) { \          if (GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_MOVU_P) { \
615                  SLJIT_ASSERT(!GET_ALL_FLAGS(op)); \                  SLJIT_ASSERT(!GET_ALL_FLAGS(op)); \
616          } \          } \
617          if (GET_OPCODE(op) >= SLJIT_MOVU && GET_OPCODE(op) <= SLJIT_MOVU_SI) { \          if (GET_OPCODE(op) >= SLJIT_MOVU && GET_OPCODE(op) <= SLJIT_MOVU_P) { \
618                  SLJIT_ASSERT(!(src & SLJIT_MEM) || (src & 0xf) != SLJIT_LOCALS_REG); \                  SLJIT_ASSERT(!(src & SLJIT_MEM) || (src & 0xf) != SLJIT_LOCALS_REG); \
619                  SLJIT_ASSERT(!(dst & SLJIT_MEM) || (dst & 0xf) != SLJIT_LOCALS_REG); \                  SLJIT_ASSERT(!(dst & SLJIT_MEM) || (dst & 0xf) != SLJIT_LOCALS_REG); \
620                  if ((src & SLJIT_MEM) && (src & 0xf)) \                  if ((src & SLJIT_MEM) && (src & 0xf)) \
# Line 551  SLJIT_API_FUNC_ATTRIBUTE void sljit_comp Line 631  SLJIT_API_FUNC_ATTRIBUTE void sljit_comp
631  }  }
632    
633  static char* reg_names[] = {  static char* reg_names[] = {
634          (char*)"<noreg>", (char*)"tmp_r1", (char*)"tmp_r2", (char*)"tmp_r3",          (char*)"<noreg>", (char*)"t1", (char*)"t2", (char*)"t3",
635          (char*)"tmp_er1", (char*)"tmp_er2", (char*)"gen_r1", (char*)"gen_r2",          (char*)"te1", (char*)"te2", (char*)"s1", (char*)"s2",
636          (char*)"gen_r3", (char*)"gen_er1", (char*)"gen_er2", (char*)"stack_r"          (char*)"s3", (char*)"se1", (char*)"se2", (char*)"lcr"
637  };  };
638    
639  static char* freg_names[] = {  static char* freg_names[] = {
# Line 572  static char* freg_names[] = { Line 652  static char* freg_names[] = {
652    
653  #define sljit_verbose_param(p, i) \  #define sljit_verbose_param(p, i) \
654          if ((p) & SLJIT_IMM) \          if ((p) & SLJIT_IMM) \
655                  fprintf(compiler->verbose, "#%"SLJIT_PRINT_D"d", (i)); \                  fprintf(compiler->verbose, "#%" SLJIT_PRINT_D "d", (i)); \
656          else if ((p) & SLJIT_MEM) { \          else if ((p) & SLJIT_MEM) { \
657                  if ((p) & 0xf) { \                  if ((p) & 0xf) { \
658                          if (i) { \                          if (i) { \
659                                  if (((p) >> 4) & 0xf) \                                  if (((p) >> 4) & 0xf) \
660                                          fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \                                          fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \
661                                  else \                                  else \
662                                          fprintf(compiler->verbose, "[%s + #%"SLJIT_PRINT_D"d]", reg_names[(p) & 0xF], (i)); \                                          fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \
663                          } \                          } \
664                          else { \                          else { \
665                                  if (((p) >> 4) & 0xf) \                                  if (((p) >> 4) & 0xf) \
# Line 589  static char* freg_names[] = { Line 669  static char* freg_names[] = {
669                          } \                          } \
670                  } \                  } \
671                  else \                  else \
672                          fprintf(compiler->verbose, "[#%"SLJIT_PRINT_D"d]", (i)); \                          fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \
673          } else \          } else \
674                  fprintf(compiler->verbose, "%s", reg_names[p]);                  fprintf(compiler->verbose, "%s", reg_names[p]);
675  #define sljit_verbose_fparam(p, i) \  #define sljit_verbose_fparam(p, i) \
# Line 599  static char* freg_names[] = { Line 679  static char* freg_names[] = {
679                                  if (((p) >> 4) & 0xf) \                                  if (((p) >> 4) & 0xf) \
680                                          fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \                                          fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \
681                                  else \                                  else \
682                                          fprintf(compiler->verbose, "[%s + #%"SLJIT_PRINT_D"d]", reg_names[(p) & 0xF], (i)); \                                          fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \
683                          } \                          } \
684                          else { \                          else { \
685                                  if (((p) >> 4) & 0xF) \                                  if (((p) >> 4) & 0xF) \
# Line 609  static char* freg_names[] = { Line 689  static char* freg_names[] = {
689                          } \                          } \
690                  } \                  } \
691                  else \                  else \
692                          fprintf(compiler->verbose, "[#%"SLJIT_PRINT_D"d]", (i)); \                          fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \
693          } else \          } else \
694                  fprintf(compiler->verbose, "%s", freg_names[p]);                  fprintf(compiler->verbose, "%s", freg_names[p]);
695    
# Line 619  static SLJIT_CONST char* op_names[] = { Line 699  static SLJIT_CONST char* op_names[] = {
699          (char*)"umul", (char*)"smul", (char*)"udiv", (char*)"sdiv",          (char*)"umul", (char*)"smul", (char*)"udiv", (char*)"sdiv",
700          /* op1 */          /* op1 */
701          (char*)"mov", (char*)"mov.ub", (char*)"mov.sb", (char*)"mov.uh",          (char*)"mov", (char*)"mov.ub", (char*)"mov.sb", (char*)"mov.uh",
702          (char*)"mov.sh", (char*)"mov.ui", (char*)"mov.si", (char*)"movu",          (char*)"mov.sh", (char*)"mov.ui", (char*)"mov.si", (char*)"mov.p",
703          (char*)"movu.ub", (char*)"movu.sb", (char*)"movu.uh", (char*)"movu.sh",          (char*)"movu", (char*)"movu.ub", (char*)"movu.sb", (char*)"movu.uh",
704          (char*)"movu.ui", (char*)"movu.si", (char*)"not", (char*)"neg",          (char*)"movu.sh", (char*)"movu.ui", (char*)"movu.si", (char*)"movu.p",
705          (char*)"clz",          (char*)"not", (char*)"neg", (char*)"clz",
706          /* op2 */          /* op2 */
707          (char*)"add", (char*)"addc", (char*)"sub", (char*)"subc",          (char*)"add", (char*)"addc", (char*)"sub", (char*)"subc",
708          (char*)"mul", (char*)"and", (char*)"or", (char*)"xor",          (char*)"mul", (char*)"and", (char*)"or", (char*)"xor",
# Line 674  static SLJIT_INLINE void check_sljit_gen Line 754  static SLJIT_INLINE void check_sljit_gen
754  #endif  #endif
755  }  }
756    
757  static SLJIT_INLINE void check_sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size)  static SLJIT_INLINE void check_sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
758  {  {
759          /* If debug and verbose are disabled, all arguments are unused. */          /* If debug and verbose are disabled, all arguments are unused. */
760          SLJIT_UNUSED_ARG(compiler);          SLJIT_UNUSED_ARG(compiler);
761          SLJIT_UNUSED_ARG(args);          SLJIT_UNUSED_ARG(args);
762          SLJIT_UNUSED_ARG(temporaries);          SLJIT_UNUSED_ARG(temporaries);
763          SLJIT_UNUSED_ARG(generals);          SLJIT_UNUSED_ARG(saveds);
764          SLJIT_UNUSED_ARG(local_size);          SLJIT_UNUSED_ARG(local_size);
765    
766          SLJIT_ASSERT(args >= 0 && args <= 3);          SLJIT_ASSERT(args >= 0 && args <= 3);
767          SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS);          SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS);
768          SLJIT_ASSERT(generals >= 0 && generals <= SLJIT_NO_GEN_REGISTERS);          SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NO_GEN_REGISTERS);
769          SLJIT_ASSERT(args <= generals);          SLJIT_ASSERT(args <= saveds);
770          SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);          SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
771  #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)  #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
772          if (SLJIT_UNLIKELY(!!compiler->verbose))          if (SLJIT_UNLIKELY(!!compiler->verbose))
773                  fprintf(compiler->verbose, "  enter args=%d temporaries=%d generals=%d local_size=%d\n", args, temporaries, generals, local_size);                  fprintf(compiler->verbose, "  enter args=%d temporaries=%d saveds=%d local_size=%d\n", args, temporaries, saveds, local_size);
774  #endif  #endif
775  }  }
776    
777  static SLJIT_INLINE void check_sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size)  static SLJIT_INLINE void check_sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
778  {  {
779          /* If debug and verbose are disabled, all arguments are unused. */          /* If debug and verbose are disabled, all arguments are unused. */
780          SLJIT_UNUSED_ARG(compiler);          SLJIT_UNUSED_ARG(compiler);
781          SLJIT_UNUSED_ARG(args);          SLJIT_UNUSED_ARG(args);
782          SLJIT_UNUSED_ARG(temporaries);          SLJIT_UNUSED_ARG(temporaries);
783          SLJIT_UNUSED_ARG(generals);          SLJIT_UNUSED_ARG(saveds);
784          SLJIT_UNUSED_ARG(local_size);          SLJIT_UNUSED_ARG(local_size);
785    
786    #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
787            if (SLJIT_UNLIKELY(compiler->skip_checks)) {
788                    compiler->skip_checks = 0;
789                    return;
790            }
791    #endif
792    
793          SLJIT_ASSERT(args >= 0 && args <= 3);          SLJIT_ASSERT(args >= 0 && args <= 3);
794          SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS);          SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS);
795          SLJIT_ASSERT(generals >= 0 && generals <= SLJIT_NO_GEN_REGISTERS);          SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NO_GEN_REGISTERS);
796          SLJIT_ASSERT(args <= generals);          SLJIT_ASSERT(args <= saveds);
797          SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);          SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
798  #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)  #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
799          if (SLJIT_UNLIKELY(!!compiler->verbose))          if (SLJIT_UNLIKELY(!!compiler->verbose))
800                  fprintf(compiler->verbose, "  fake_enter args=%d temporaries=%d generals=%d local_size=%d\n", args, temporaries, generals, local_size);                  fprintf(compiler->verbose, "  set_context args=%d temporaries=%d saveds=%d local_size=%d\n", args, temporaries, saveds, local_size);
801  #endif  #endif
802  }  }
803    
# Line 724  static SLJIT_INLINE void check_sljit_emi Line 811  static SLJIT_INLINE void check_sljit_emi
811    
812  #if (defined SLJIT_DEBUG && SLJIT_DEBUG)  #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
813          if (op != SLJIT_UNUSED) {          if (op != SLJIT_UNUSED) {
814                  SLJIT_ASSERT(op >= SLJIT_MOV && op <= SLJIT_MOV_SI);                  SLJIT_ASSERT(op >= SLJIT_MOV && op <= SLJIT_MOV_P);
815                  FUNCTION_CHECK_SRC(src, srcw);                  FUNCTION_CHECK_SRC(src, srcw);
816          }          }
817          else          else
# Line 743  static SLJIT_INLINE void check_sljit_emi Line 830  static SLJIT_INLINE void check_sljit_emi
830  #endif  #endif
831  }  }
832    
833  static SLJIT_INLINE void check_sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int generals, int local_size)  static SLJIT_INLINE void check_sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw)
834  {  {
835          /* If debug and verbose are disabled, all arguments are unused. */          /* If debug and verbose are disabled, all arguments are unused. */
836          SLJIT_UNUSED_ARG(compiler);          SLJIT_UNUSED_ARG(compiler);
837          SLJIT_UNUSED_ARG(dst);          SLJIT_UNUSED_ARG(dst);
838          SLJIT_UNUSED_ARG(dstw);          SLJIT_UNUSED_ARG(dstw);
         SLJIT_UNUSED_ARG(args);  
         SLJIT_UNUSED_ARG(temporaries);  
         SLJIT_UNUSED_ARG(generals);  
         SLJIT_UNUSED_ARG(local_size);  
839    
         SLJIT_ASSERT(args >= 0 && args <= 3);  
         SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS);  
         SLJIT_ASSERT(generals >= 0 && generals <= SLJIT_NO_GEN_REGISTERS);  
         SLJIT_ASSERT(args <= generals);  
         SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);  
840  #if (defined SLJIT_DEBUG && SLJIT_DEBUG)  #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
         compiler->temporaries = temporaries;  
         compiler->generals = generals;  
841          FUNCTION_CHECK_DST(dst, dstw);          FUNCTION_CHECK_DST(dst, dstw);
         compiler->temporaries = -1;  
         compiler->generals = -1;  
842  #endif  #endif
843  #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)  #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
844          if (SLJIT_UNLIKELY(!!compiler->verbose)) {          if (SLJIT_UNLIKELY(!!compiler->verbose)) {
845                  fprintf(compiler->verbose, "  fast_enter ");                  fprintf(compiler->verbose, "  fast_enter ");
846                  sljit_verbose_param(dst, dstw);                  sljit_verbose_param(dst, dstw);
847                  fprintf(compiler->verbose, " args=%d temporaries=%d generals=%d local_size=%d\n", args, temporaries, generals, local_size);                  fprintf(compiler->verbose, "\n");
848          }          }
849  #endif  #endif
850  }  }
# Line 1051  static SLJIT_INLINE void check_sljit_emi Line 1125  static SLJIT_INLINE void check_sljit_emi
1125    
1126          SLJIT_ASSERT(sljit_is_fpu_available());          SLJIT_ASSERT(sljit_is_fpu_available());
1127          SLJIT_ASSERT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP)));          SLJIT_ASSERT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP)));
1128          SLJIT_ASSERT((type & 0xff) >= SLJIT_C_FLOAT_EQUAL && (type & 0xff) <= SLJIT_C_FLOAT_NOT_NAN);          SLJIT_ASSERT((type & 0xff) >= SLJIT_C_FLOAT_EQUAL && (type & 0xff) <= SLJIT_C_FLOAT_ORDERED);
1129  #if (defined SLJIT_DEBUG && SLJIT_DEBUG)  #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
1130          FUNCTION_FCHECK(src1, src1w);          FUNCTION_FCHECK(src1, src1w);
1131          FUNCTION_FCHECK(src2, src2w);          FUNCTION_FCHECK(src2, src2w);
# Line 1113  static SLJIT_INLINE void check_sljit_emi Line 1187  static SLJIT_INLINE void check_sljit_emi
1187  #endif  #endif
1188  }  }
1189    
1190    static SLJIT_INLINE void check_sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset)
1191    {
1192            SLJIT_UNUSED_ARG(compiler);
1193            SLJIT_UNUSED_ARG(dst);
1194            SLJIT_UNUSED_ARG(dstw);
1195            SLJIT_UNUSED_ARG(offset);
1196    
1197    #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
1198            FUNCTION_CHECK_DST(dst, dstw);
1199    #endif
1200    #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
1201            if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1202                    fprintf(compiler->verbose, "  local_base ");
1203                    sljit_verbose_param(dst, dstw);
1204                    fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", offset);
1205            }
1206    #endif
1207    }
1208    
1209  static SLJIT_INLINE void check_sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value)  static SLJIT_INLINE void check_sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value)
1210  {  {
1211          /* If debug and verbose are disabled, all arguments are unused. */          /* If debug and verbose are disabled, all arguments are unused. */
# Line 1128  static SLJIT_INLINE void check_sljit_emi Line 1221  static SLJIT_INLINE void check_sljit_emi
1221          if (SLJIT_UNLIKELY(!!compiler->verbose)) {          if (SLJIT_UNLIKELY(!!compiler->verbose)) {
1222                  fprintf(compiler->verbose, "  const ");                  fprintf(compiler->verbose, "  const ");
1223                  sljit_verbose_param(dst, dstw);                  sljit_verbose_param(dst, dstw);
1224                  fprintf(compiler->verbose, ", #%"SLJIT_PRINT_D"d\n", init_value);                  fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", init_value);
1225          }          }
1226  #endif  #endif
1227  }  }
# Line 1140  static SLJIT_INLINE int emit_mov_before_ Line 1233  static SLJIT_INLINE int emit_mov_before_
1233                  return SLJIT_SUCCESS;                  return SLJIT_SUCCESS;
1234    
1235  #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)  #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1236          if (src == SLJIT_RETURN_REG && op == SLJIT_MOV)          /* At the moment the pointer size is always equal to sljit_w. May be changed in the future. */
1237            if (src == SLJIT_RETURN_REG && (op == SLJIT_MOV || op == SLJIT_MOV_P))
1238                  return SLJIT_SUCCESS;                  return SLJIT_SUCCESS;
1239  #else  #else
1240          if (src == SLJIT_RETURN_REG && (op == SLJIT_MOV || op == SLJIT_MOV_UI || op == SLJIT_MOV_SI))          if (src == SLJIT_RETURN_REG && (op == SLJIT_MOV || op == SLJIT_MOV_UI || op == SLJIT_MOV_SI || op == SLJIT_MOV_P))
1241                  return SLJIT_SUCCESS;                  return SLJIT_SUCCESS;
1242  #endif  #endif
1243    
# Line 1153  static SLJIT_INLINE int emit_mov_before_ Line 1247  static SLJIT_INLINE int emit_mov_before_
1247          return sljit_emit_op1(compiler, op, SLJIT_RETURN_REG, 0, src, srcw);          return sljit_emit_op1(compiler, op, SLJIT_RETURN_REG, 0, src, srcw);
1248  }  }
1249    
1250    /* CPU description section */
1251    
1252    #if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
1253    #define SLJIT_CPUINFO_PART1 " 32bit ("
1254    #elif (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1255    #define SLJIT_CPUINFO_PART1 " 64bit ("
1256    #else
1257    #error "Internal error: CPU type info missing"
1258    #endif
1259    
1260    #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1261    #define SLJIT_CPUINFO_PART2 "little endian + "
1262    #elif (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
1263    #define SLJIT_CPUINFO_PART2 "big endian + "
1264    #else
1265    #error "Internal error: CPU type info missing"
1266    #endif
1267    
1268    #if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED)
1269    #define SLJIT_CPUINFO_PART3 "unaligned)"
1270    #else
1271    #define SLJIT_CPUINFO_PART3 "aligned)"
1272    #endif
1273    
1274    #define SLJIT_CPUINFO SLJIT_CPUINFO_PART1 SLJIT_CPUINFO_PART2 SLJIT_CPUINFO_PART3
1275    
1276  #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)  #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
1277          #include "sljitNativeX86_common.c"          #include "sljitNativeX86_common.c"
1278  #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)  #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
# Line 1169  static SLJIT_INLINE int emit_mov_before_ Line 1289  static SLJIT_INLINE int emit_mov_before_
1289          #include "sljitNativePPC_common.c"          #include "sljitNativePPC_common.c"
1290  #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)  #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
1291          #include "sljitNativeMIPS_common.c"          #include "sljitNativeMIPS_common.c"
1292    #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
1293            #include "sljitNativeSPARC_common.c"
1294  #endif  #endif
1295    
1296  #if !(defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)  #if !(defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
# Line 1267  SLJIT_API_FUNC_ATTRIBUTE struct sljit_ju Line 1389  SLJIT_API_FUNC_ATTRIBUTE struct sljit_ju
1389    
1390  #endif  #endif
1391    
1392    #if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) && !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
1393    
1394    SLJIT_API_FUNC_ATTRIBUTE int sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset)
1395    {
1396            CHECK_ERROR();
1397            check_sljit_get_local_base(compiler, dst, dstw, offset);
1398    
1399            ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_LOCALS_REG), offset);
1400    #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
1401            compiler->skip_checks = 1;
1402    #endif
1403            if (offset != 0)
1404                    return sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_LOCALS_REG, 0, SLJIT_IMM, offset);
1405            return sljit_emit_op1(compiler, SLJIT_MOV, dst, dstw, SLJIT_LOCALS_REG, 0);
1406    }
1407    
1408    #endif
1409    
1410  #else /* SLJIT_CONFIG_UNSUPPORTED */  #else /* SLJIT_CONFIG_UNSUPPORTED */
1411    
1412  /* Empty function bodies for those machines, which are not (yet) supported. */  /* Empty function bodies for those machines, which are not (yet) supported. */
1413    
1414  SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name()  SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void)
1415  {  {
1416          return "unsupported";          return "unsupported";
1417  }  }
# Line 1318  SLJIT_API_FUNC_ATTRIBUTE void sljit_free Line 1458  SLJIT_API_FUNC_ATTRIBUTE void sljit_free
1458          SLJIT_ASSERT_STOP();          SLJIT_ASSERT_STOP();
1459  }  }
1460    
1461  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size)  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
1462  {  {
1463          SLJIT_UNUSED_ARG(compiler);          SLJIT_UNUSED_ARG(compiler);
1464          SLJIT_UNUSED_ARG(args);          SLJIT_UNUSED_ARG(args);
1465          SLJIT_UNUSED_ARG(temporaries);          SLJIT_UNUSED_ARG(temporaries);
1466          SLJIT_UNUSED_ARG(generals);          SLJIT_UNUSED_ARG(saveds);
1467          SLJIT_UNUSED_ARG(local_size);          SLJIT_UNUSED_ARG(local_size);
1468          SLJIT_ASSERT_STOP();          SLJIT_ASSERT_STOP();
1469          return SLJIT_ERR_UNSUPPORTED;          return SLJIT_ERR_UNSUPPORTED;
1470  }  }
1471    
1472  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size)  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
1473  {  {
1474          SLJIT_UNUSED_ARG(compiler);          SLJIT_UNUSED_ARG(compiler);
1475          SLJIT_UNUSED_ARG(args);          SLJIT_UNUSED_ARG(args);
1476          SLJIT_UNUSED_ARG(temporaries);          SLJIT_UNUSED_ARG(temporaries);
1477          SLJIT_UNUSED_ARG(generals);          SLJIT_UNUSED_ARG(saveds);
1478          SLJIT_UNUSED_ARG(local_size);          SLJIT_UNUSED_ARG(local_size);
1479          SLJIT_ASSERT_STOP();          SLJIT_ASSERT_STOP();
1480  }  }
# Line 1349  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 1489  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
1489          return SLJIT_ERR_UNSUPPORTED;          return SLJIT_ERR_UNSUPPORTED;
1490  }  }
1491    
1492  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int generals, int local_size)  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int saveds, int local_size)
1493  {  {
1494          SLJIT_UNUSED_ARG(compiler);          SLJIT_UNUSED_ARG(compiler);
1495          SLJIT_UNUSED_ARG(dst);          SLJIT_UNUSED_ARG(dst);
1496          SLJIT_UNUSED_ARG(dstw);          SLJIT_UNUSED_ARG(dstw);
1497          SLJIT_UNUSED_ARG(args);          SLJIT_UNUSED_ARG(args);
1498          SLJIT_UNUSED_ARG(temporaries);          SLJIT_UNUSED_ARG(temporaries);
1499          SLJIT_UNUSED_ARG(generals);          SLJIT_UNUSED_ARG(saveds);
1500          SLJIT_UNUSED_ARG(local_size);          SLJIT_UNUSED_ARG(local_size);
1501          SLJIT_ASSERT_STOP();          SLJIT_ASSERT_STOP();
1502          return SLJIT_ERR_UNSUPPORTED;          return SLJIT_ERR_UNSUPPORTED;
# Line 1540  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 1680  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
1680          SLJIT_ASSERT_STOP();          SLJIT_ASSERT_STOP();
1681          return SLJIT_ERR_UNSUPPORTED;          return SLJIT_ERR_UNSUPPORTED;
1682  }  }
1683    
1684    SLJIT_API_FUNC_ATTRIBUTE int sljit_get_local_base(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w offset)
1685    {
1686            SLJIT_UNUSED_ARG(compiler);
1687            SLJIT_UNUSED_ARG(dst);
1688            SLJIT_UNUSED_ARG(dstw);
1689            SLJIT_UNUSED_ARG(offset);
1690            SLJIT_ASSERT_STOP();
1691            return SLJIT_ERR_UNSUPPORTED;
1692    }
1693    
1694  SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w initval)  SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w initval)
1695  {  {

Legend:
Removed from v.875  
changed lines
  Added in v.1182

  ViewVC Help
Powered by ViewVC 1.1.5