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

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

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

revision 884 by zherczeg, Tue Jan 17 11:52:43 2012 UTC revision 955 by zherczeg, Tue Apr 3 15:32:36 2012 UTC
# Line 39  typedef sljit_ui sljit_ins; Line 39  typedef sljit_ui sljit_ins;
39  #define TMP_REG1        (SLJIT_NO_REGISTERS + 1)  #define TMP_REG1        (SLJIT_NO_REGISTERS + 1)
40  #define TMP_REG2        (SLJIT_NO_REGISTERS + 2)  #define TMP_REG2        (SLJIT_NO_REGISTERS + 2)
41  #define TMP_REG3        (SLJIT_NO_REGISTERS + 3)  #define TMP_REG3        (SLJIT_NO_REGISTERS + 3)
 #define REAL_STACK_PTR  (SLJIT_NO_REGISTERS + 4)  
42    
43  /* For position independent code, t9 must contain the function address. */  /* For position independent code, t9 must contain the function address. */
44  #define PIC_ADDR_REG            TMP_REG2  #define PIC_ADDR_REG            TMP_REG2
# Line 174  typedef sljit_ui sljit_ins; Line 173  typedef sljit_ui sljit_ins;
173  #define UIMM_MAX        (0xffff)  #define UIMM_MAX        (0xffff)
174    
175  static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 6] = {  static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 6] = {
176    0, 2, 5, 6, 3, 8, 17, 18, 19, 20, 21, 16, 4, 25, 9, 29    0, 2, 5, 6, 3, 8, 16, 17, 18, 19, 20, 29, 4, 25, 9
177  };  };
178    
179  /* dest_reg is the absolute name of the register  /* dest_reg is the absolute name of the register
# Line 464  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 463  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
463    
464          compiler->temporaries = temporaries;          compiler->temporaries = temporaries;
465          compiler->saveds = saveds;          compiler->saveds = saveds;
466    #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
467            compiler->logical_local_size = local_size;
468    #endif
469    
470          compiler->has_locals = local_size > 0;          local_size += (saveds + 1 + 4) * sizeof(sljit_w);
         local_size += (saveds + 2 + 4) * sizeof(sljit_w);  
471          local_size = (local_size + 15) & ~0xf;          local_size = (local_size + 15) & ~0xf;
472          compiler->local_size = local_size;          compiler->local_size = local_size;
473    
474          if (local_size <= SIMM_MAX) {          if (local_size <= SIMM_MAX) {
475                  /* Frequent case. */                  /* Frequent case. */
476                  FAIL_IF(push_inst(compiler, ADDIU_W | S(REAL_STACK_PTR) | T(REAL_STACK_PTR) | IMM(-local_size), DR(REAL_STACK_PTR)));                  FAIL_IF(push_inst(compiler, ADDIU_W | S(SLJIT_LOCALS_REG) | T(SLJIT_LOCALS_REG) | IMM(-local_size), DR(SLJIT_LOCALS_REG)));
477                  base = S(REAL_STACK_PTR);                  base = S(SLJIT_LOCALS_REG);
478          }          }
479          else {          else {
480                  FAIL_IF(load_immediate(compiler, DR(TMP_REG1), local_size));                  FAIL_IF(load_immediate(compiler, DR(TMP_REG1), local_size));
481                  FAIL_IF(push_inst(compiler, ADDU_W | S(REAL_STACK_PTR) | TA(0) | D(TMP_REG2), DR(TMP_REG2)));                  FAIL_IF(push_inst(compiler, ADDU_W | S(SLJIT_LOCALS_REG) | TA(0) | D(TMP_REG2), DR(TMP_REG2)));
482                  FAIL_IF(push_inst(compiler, SUBU_W | S(REAL_STACK_PTR) | T(TMP_REG1) | D(REAL_STACK_PTR), DR(REAL_STACK_PTR)));                  FAIL_IF(push_inst(compiler, SUBU_W | S(SLJIT_LOCALS_REG) | T(TMP_REG1) | D(SLJIT_LOCALS_REG), DR(SLJIT_LOCALS_REG)));
483                  base = S(TMP_REG2);                  base = S(TMP_REG2);
484                  local_size = 0;                  local_size = 0;
485          }          }
486    
487          FAIL_IF(push_inst(compiler, STACK_STORE | base | TA(RETURN_ADDR_REG) | IMM(local_size - 1 * (int)sizeof(sljit_w)), MOVABLE_INS));          FAIL_IF(push_inst(compiler, STACK_STORE | base | TA(RETURN_ADDR_REG) | IMM(local_size - 1 * (int)sizeof(sljit_w)), MOVABLE_INS));
         if (compiler->has_locals)  
                 FAIL_IF(push_inst(compiler, STACK_STORE | base | T(SLJIT_LOCALS_REG) | IMM(local_size - 2 * (int)sizeof(sljit_w)), MOVABLE_INS));  
488          if (saveds >= 1)          if (saveds >= 1)
489                  FAIL_IF(push_inst(compiler, STACK_STORE | base | T(SLJIT_SAVED_REG1) | IMM(local_size - 3 * (int)sizeof(sljit_w)), MOVABLE_INS));                  FAIL_IF(push_inst(compiler, STACK_STORE | base | T(SLJIT_SAVED_REG1) | IMM(local_size - 2 * (int)sizeof(sljit_w)), MOVABLE_INS));
490          if (saveds >= 2)          if (saveds >= 2)
491                  FAIL_IF(push_inst(compiler, STACK_STORE | base | T(SLJIT_SAVED_REG2) | IMM(local_size - 4 * (int)sizeof(sljit_w)), MOVABLE_INS));                  FAIL_IF(push_inst(compiler, STACK_STORE | base | T(SLJIT_SAVED_REG2) | IMM(local_size - 3 * (int)sizeof(sljit_w)), MOVABLE_INS));
492          if (saveds >= 3)          if (saveds >= 3)
493                  FAIL_IF(push_inst(compiler, STACK_STORE | base | T(SLJIT_SAVED_REG3) | IMM(local_size - 5 * (int)sizeof(sljit_w)), MOVABLE_INS));                  FAIL_IF(push_inst(compiler, STACK_STORE | base | T(SLJIT_SAVED_REG3) | IMM(local_size - 4 * (int)sizeof(sljit_w)), MOVABLE_INS));
494          if (saveds >= 4)          if (saveds >= 4)
495                  FAIL_IF(push_inst(compiler, STACK_STORE | base | T(SLJIT_SAVED_EREG1) | IMM(local_size - 6 * (int)sizeof(sljit_w)), MOVABLE_INS));                  FAIL_IF(push_inst(compiler, STACK_STORE | base | T(SLJIT_SAVED_EREG1) | IMM(local_size - 5 * (int)sizeof(sljit_w)), MOVABLE_INS));
496          if (saveds >= 5)          if (saveds >= 5)
497                  FAIL_IF(push_inst(compiler, STACK_STORE | base | T(SLJIT_SAVED_EREG2) | IMM(local_size - 7 * (int)sizeof(sljit_w)), MOVABLE_INS));                  FAIL_IF(push_inst(compiler, STACK_STORE | base | T(SLJIT_SAVED_EREG2) | IMM(local_size - 6 * (int)sizeof(sljit_w)), MOVABLE_INS));
   
         if (compiler->has_locals)  
                 FAIL_IF(push_inst(compiler, ADDIU_W | S(REAL_STACK_PTR) | T(SLJIT_LOCALS_REG) | IMM(4 * sizeof(sljit_w)), DR(SLJIT_LOCALS_REG)));  
498    
499          if (args >= 1)          if (args >= 1)
500                  FAIL_IF(push_inst(compiler, ADDU_W | SA(4) | TA(0) | D(SLJIT_SAVED_REG1), DR(SLJIT_SAVED_REG1)));                  FAIL_IF(push_inst(compiler, ADDU_W | SA(4) | TA(0) | D(SLJIT_SAVED_REG1), DR(SLJIT_SAVED_REG1)));
# Line 517  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_ Line 513  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_
513    
514          compiler->temporaries = temporaries;          compiler->temporaries = temporaries;
515          compiler->saveds = saveds;          compiler->saveds = saveds;
516    #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
517            compiler->logical_local_size = local_size;
518    #endif
519    
520          compiler->has_locals = local_size > 0;          local_size += (saveds + 1 + 4) * sizeof(sljit_w);
         local_size += (saveds + 2 + 4) * sizeof(sljit_w);  
521          compiler->local_size = (local_size + 15) & ~0xf;          compiler->local_size = (local_size + 15) & ~0xf;
522  }  }
523    
# Line 530  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 528  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
528    
529          CHECK_ERROR();          CHECK_ERROR();
530          check_sljit_emit_return(compiler, op, src, srcw);          check_sljit_emit_return(compiler, op, src, srcw);
531            ADJUST_LOCAL_OFFSET(src, srcw);
532    
533          FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));          FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
534    
535          local_size = compiler->local_size;          local_size = compiler->local_size;
536          if (local_size <= SIMM_MAX)          if (local_size <= SIMM_MAX)
537                  base = S(REAL_STACK_PTR);                  base = S(SLJIT_LOCALS_REG);
538          else {          else {
539                  FAIL_IF(load_immediate(compiler, DR(TMP_REG1), local_size));                  FAIL_IF(load_immediate(compiler, DR(TMP_REG1), local_size));
540                  FAIL_IF(push_inst(compiler, ADDU_W | S(REAL_STACK_PTR) | T(TMP_REG1) | D(TMP_REG1), DR(TMP_REG1)));                  FAIL_IF(push_inst(compiler, ADDU_W | S(SLJIT_LOCALS_REG) | T(TMP_REG1) | D(TMP_REG1), DR(TMP_REG1)));
541                  base = S(TMP_REG1);                  base = S(TMP_REG1);
542                  local_size = 0;                  local_size = 0;
543          }          }
544    
545          FAIL_IF(push_inst(compiler, STACK_LOAD | base | TA(RETURN_ADDR_REG) | IMM(local_size - 1 * (int)sizeof(sljit_w)), RETURN_ADDR_REG));          FAIL_IF(push_inst(compiler, STACK_LOAD | base | TA(RETURN_ADDR_REG) | IMM(local_size - 1 * (int)sizeof(sljit_w)), RETURN_ADDR_REG));
546          if (compiler->saveds >= 5)          if (compiler->saveds >= 5)
547                  FAIL_IF(push_inst(compiler, STACK_LOAD | base | T(SLJIT_SAVED_EREG2) | IMM(local_size - 7 * (int)sizeof(sljit_w)), DR(SLJIT_SAVED_EREG2)));                  FAIL_IF(push_inst(compiler, STACK_LOAD | base | T(SLJIT_SAVED_EREG2) | IMM(local_size - 6 * (int)sizeof(sljit_w)), DR(SLJIT_SAVED_EREG2)));
548          if (compiler->saveds >= 4)          if (compiler->saveds >= 4)
549                  FAIL_IF(push_inst(compiler, STACK_LOAD | base | T(SLJIT_SAVED_EREG1) | IMM(local_size - 6 * (int)sizeof(sljit_w)), DR(SLJIT_SAVED_EREG1)));                  FAIL_IF(push_inst(compiler, STACK_LOAD | base | T(SLJIT_SAVED_EREG1) | IMM(local_size - 5 * (int)sizeof(sljit_w)), DR(SLJIT_SAVED_EREG1)));
550          if (compiler->saveds >= 3)          if (compiler->saveds >= 3)
551                  FAIL_IF(push_inst(compiler, STACK_LOAD | base | T(SLJIT_SAVED_REG3) | IMM(local_size - 5 * (int)sizeof(sljit_w)), DR(SLJIT_SAVED_REG3)));                  FAIL_IF(push_inst(compiler, STACK_LOAD | base | T(SLJIT_SAVED_REG3) | IMM(local_size - 4 * (int)sizeof(sljit_w)), DR(SLJIT_SAVED_REG3)));
552          if (compiler->saveds >= 2)          if (compiler->saveds >= 2)
553                  FAIL_IF(push_inst(compiler, STACK_LOAD | base | T(SLJIT_SAVED_REG2) | IMM(local_size - 4 * (int)sizeof(sljit_w)), DR(SLJIT_SAVED_REG2)));                  FAIL_IF(push_inst(compiler, STACK_LOAD | base | T(SLJIT_SAVED_REG2) | IMM(local_size - 3 * (int)sizeof(sljit_w)), DR(SLJIT_SAVED_REG2)));
554          if (compiler->saveds >= 1)          if (compiler->saveds >= 1)
555                  FAIL_IF(push_inst(compiler, STACK_LOAD | base | T(SLJIT_SAVED_REG1) | IMM(local_size - 3 * (int)sizeof(sljit_w)), DR(SLJIT_SAVED_REG1)));                  FAIL_IF(push_inst(compiler, STACK_LOAD | base | T(SLJIT_SAVED_REG1) | IMM(local_size - 2 * (int)sizeof(sljit_w)), DR(SLJIT_SAVED_REG1)));
         if (compiler->has_locals)  
                 FAIL_IF(push_inst(compiler, STACK_LOAD | base | T(SLJIT_LOCALS_REG) | IMM(local_size - 2 * (int)sizeof(sljit_w)), DR(SLJIT_LOCALS_REG)));  
556    
557          FAIL_IF(push_inst(compiler, JR | SA(RETURN_ADDR_REG), UNMOVABLE_INS));          FAIL_IF(push_inst(compiler, JR | SA(RETURN_ADDR_REG), UNMOVABLE_INS));
558          if (compiler->local_size <= SIMM_MAX)          if (compiler->local_size <= SIMM_MAX)
559                  return push_inst(compiler, ADDIU_W | S(REAL_STACK_PTR) | T(REAL_STACK_PTR) | IMM(compiler->local_size), UNMOVABLE_INS);                  return push_inst(compiler, ADDIU_W | S(SLJIT_LOCALS_REG) | T(SLJIT_LOCALS_REG) | IMM(compiler->local_size), UNMOVABLE_INS);
560          else          else
561                  return push_inst(compiler, ADDU_W | S(TMP_REG1) | TA(0) | D(REAL_STACK_PTR), UNMOVABLE_INS);                  return push_inst(compiler, ADDU_W | S(TMP_REG1) | TA(0) | D(SLJIT_LOCALS_REG), UNMOVABLE_INS);
562  }  }
563    
564  #undef STACK_STORE  #undef STACK_STORE
# Line 956  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 953  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
953    
954          CHECK_ERROR();          CHECK_ERROR();
955          check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);          check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
956            ADJUST_LOCAL_OFFSET(dst, dstw);
957            ADJUST_LOCAL_OFFSET(src, srcw);
958    
959          SLJIT_COMPILE_ASSERT(SLJIT_MOV + 7 == SLJIT_MOVU, movu_offset);          SLJIT_COMPILE_ASSERT(SLJIT_MOV + 7 == SLJIT_MOVU, movu_offset);
960    
# Line 1029  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 1028  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
1028    
1029          CHECK_ERROR();          CHECK_ERROR();
1030          check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);          check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
1031            ADJUST_LOCAL_OFFSET(dst, dstw);
1032            ADJUST_LOCAL_OFFSET(src1, src1w);
1033            ADJUST_LOCAL_OFFSET(src2, src2w);
1034    
1035          switch (GET_OPCODE(op)) {          switch (GET_OPCODE(op)) {
1036          case SLJIT_ADD:          case SLJIT_ADD:
# Line 1260  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 1262  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
1262  /*  Other instructions                                                   */  /*  Other instructions                                                   */
1263  /* --------------------------------------------------------------------- */  /* --------------------------------------------------------------------- */
1264    
1265  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)  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw)
1266  {  {
1267          CHECK_ERROR();          CHECK_ERROR();
1268          check_sljit_emit_fast_enter(compiler, dst, dstw, args, temporaries, saveds, local_size);          check_sljit_emit_fast_enter(compiler, dst, dstw);
1269            ADJUST_LOCAL_OFFSET(dst, dstw);
         compiler->temporaries = temporaries;  
         compiler->saveds = saveds;  
   
         compiler->has_locals = local_size > 0;  
         local_size += (saveds + 2 + 4) * sizeof(sljit_w);  
         compiler->local_size = (local_size + 15) & ~0xf;  
1270    
1271          if (dst >= SLJIT_TEMPORARY_REG1 && dst <= SLJIT_NO_REGISTERS)          if (dst >= SLJIT_TEMPORARY_REG1 && dst <= SLJIT_NO_REGISTERS)
1272                  return push_inst(compiler, ADDU_W | SA(RETURN_ADDR_REG) | TA(0) | D(dst), DR(dst));                  return push_inst(compiler, ADDU_W | SA(RETURN_ADDR_REG) | TA(0) | D(dst), DR(dst));
# Line 1283  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 1279  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
1279  {  {
1280          CHECK_ERROR();          CHECK_ERROR();
1281          check_sljit_emit_fast_return(compiler, src, srcw);          check_sljit_emit_fast_return(compiler, src, srcw);
1282            ADJUST_LOCAL_OFFSET(src, srcw);
1283    
1284          if (src >= SLJIT_TEMPORARY_REG1 && src <= SLJIT_NO_REGISTERS)          if (src >= SLJIT_TEMPORARY_REG1 && src <= SLJIT_NO_REGISTERS)
1285                  FAIL_IF(push_inst(compiler, ADDU_W | S(src) | TA(0) | DA(RETURN_ADDR_REG), RETURN_ADDR_REG));                  FAIL_IF(push_inst(compiler, ADDU_W | S(src) | TA(0) | DA(RETURN_ADDR_REG), RETURN_ADDR_REG));
# Line 1468  SLJIT_API_FUNC_ATTRIBUTE struct sljit_ju Line 1465  SLJIT_API_FUNC_ATTRIBUTE struct sljit_ju
1465    
1466          CHECK_ERROR_PTR();          CHECK_ERROR_PTR();
1467          check_sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w);          check_sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w);
1468            ADJUST_LOCAL_OFFSET(src1, src1w);
1469            ADJUST_LOCAL_OFFSET(src2, src2w);
1470    
1471          compiler->cache_arg = 0;          compiler->cache_arg = 0;
1472          compiler->cache_argw = 0;          compiler->cache_argw = 0;
# Line 1671  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 1670  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
1670    
1671          CHECK_ERROR();          CHECK_ERROR();
1672          check_sljit_emit_ijump(compiler, type, src, srcw);          check_sljit_emit_ijump(compiler, type, src, srcw);
1673            ADJUST_LOCAL_OFFSET(src, srcw);
1674    
1675          if (src >= SLJIT_TEMPORARY_REG1 && src <= SLJIT_NO_REGISTERS) {          if (src >= SLJIT_TEMPORARY_REG1 && src <= SLJIT_NO_REGISTERS) {
1676                  if (DR(src) != 4)                  if (DR(src) != 4)
# Line 1727  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 1727  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
1727    
1728          CHECK_ERROR();          CHECK_ERROR();
1729          check_sljit_emit_cond_value(compiler, op, dst, dstw, type);          check_sljit_emit_cond_value(compiler, op, dst, dstw, type);
1730            ADJUST_LOCAL_OFFSET(dst, dstw);
1731    
1732          if (dst == SLJIT_UNUSED)          if (dst == SLJIT_UNUSED)
1733                  return SLJIT_SUCCESS;                  return SLJIT_SUCCESS;
# Line 1814  SLJIT_API_FUNC_ATTRIBUTE struct sljit_co Line 1815  SLJIT_API_FUNC_ATTRIBUTE struct sljit_co
1815    
1816          CHECK_ERROR_PTR();          CHECK_ERROR_PTR();
1817          check_sljit_emit_const(compiler, dst, dstw, init_value);          check_sljit_emit_const(compiler, dst, dstw, init_value);
1818            ADJUST_LOCAL_OFFSET(dst, dstw);
1819    
1820          const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));          const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
1821          PTR_FAIL_IF(!const_);          PTR_FAIL_IF(!const_);

Legend:
Removed from v.884  
changed lines
  Added in v.955

  ViewVC Help
Powered by ViewVC 1.1.5