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

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

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

revision 847 by zherczeg, Tue Jan 3 17:49:03 2012 UTC revision 860 by zherczeg, Mon Jan 9 20:12:58 2012 UTC
# Line 1836  static int emit_shift(struct sljit_compi Line 1836  static int emit_shift(struct sljit_compi
1836                  EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REGISTER, 0);                  EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REGISTER, 0);
1837          }          }
1838          else {          else {
1839                  /* This case is really difficult, since ecx can be used for                  /* This case is really difficult, since ecx itself may used for
1840                     addressing as well, and we must ensure to work even in that case. */                     addressing, and we must ensure to work even in that case. */
1841                    EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w);
1842  #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)  #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
1843                  EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_PREF_SHIFT_REG, 0);                  EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_PREF_SHIFT_REG, 0);
1844  #else  #else
1845                  /* [esp - 4] is reserved for eflags. */                  /* [esp - 4] is reserved for eflags. */
1846                  EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), -(int)(2 * sizeof(sljit_w)), SLJIT_PREF_SHIFT_REG, 0);                  EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), -(int)(2 * sizeof(sljit_w)), SLJIT_PREF_SHIFT_REG, 0);
1847  #endif  #endif
   
                 EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w);  
1848                  EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);                  EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
1849                  code = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REGISTER, 0);                  code = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REGISTER, 0);
1850                  FAIL_IF(!code);                  FAIL_IF(!code);
1851                  *code |= mode;                  *code |= mode;
   
1852  #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)  #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
1853                  EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG2, 0);                  EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG2, 0);
1854  #else  #else
# Line 1863  static int emit_shift(struct sljit_compi Line 1861  static int emit_shift(struct sljit_compi
1861          return SLJIT_SUCCESS;          return SLJIT_SUCCESS;
1862  }  }
1863    
1864    static int emit_shift_with_flags(struct sljit_compiler *compiler,
1865            sljit_ub mode, int set_flags,
1866            int dst, sljit_w dstw,
1867            int src1, sljit_w src1w,
1868            int src2, sljit_w src2w)
1869    {
1870            /* The CPU does not set flags if the shift count is 0. */
1871            if (src2 & SLJIT_IMM) {
1872    #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
1873                    if ((src2w & 0x3f) != 0 || (compiler->mode32 && (src2w & 0x1f) != 0))
1874                            return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
1875    #else
1876                    if ((src2w & 0x1f) != 0)
1877                            return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
1878    #endif
1879                    if (!set_flags)
1880                            return emit_mov(compiler, dst, dstw, src1, src1w);
1881                    /* OR dst, src, 0 */
1882                    return emit_cum_binary(compiler, 0x0b, 0x09, 0x1 << 3, 0x0d,
1883                            dst, dstw, src1, src1w, SLJIT_IMM, 0);
1884            }
1885    
1886            if (!set_flags)
1887                    return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
1888    
1889            if (!(dst >= SLJIT_TEMPORARY_REG1 && dst <= SLJIT_NO_REGISTERS))
1890                    FAIL_IF(emit_cmp_binary(compiler, src1, src1w, SLJIT_IMM, 0));
1891    
1892            FAIL_IF(emit_shift(compiler,mode, dst, dstw, src1, src1w, src2, src2w));
1893    
1894            if (dst >= SLJIT_TEMPORARY_REG1 && dst <= SLJIT_NO_REGISTERS)
1895                    return emit_cmp_binary(compiler, dst, dstw, SLJIT_IMM, 0);
1896            return SLJIT_SUCCESS;
1897    }
1898    
1899  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int op,  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int op,
1900          int dst, sljit_w dstw,          int dst, sljit_w dstw,
1901          int src1, sljit_w src1w,          int src1, sljit_w src1w,
# Line 1942  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 1975  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
1975                  return emit_cum_binary(compiler, 0x33, 0x31, 0x6 << 3, 0x35,                  return emit_cum_binary(compiler, 0x33, 0x31, 0x6 << 3, 0x35,
1976                          dst, dstw, src1, src1w, src2, src2w);                          dst, dstw, src1, src1w, src2, src2w);
1977          case SLJIT_SHL:          case SLJIT_SHL:
1978                  return emit_shift(compiler, 0x4 << 3,                  return emit_shift_with_flags(compiler, 0x4 << 3, GET_FLAGS(op),
1979                          dst, dstw, src1, src1w, src2, src2w);                          dst, dstw, src1, src1w, src2, src2w);
1980          case SLJIT_LSHR:          case SLJIT_LSHR:
1981                  return emit_shift(compiler, 0x5 << 3,                  return emit_shift_with_flags(compiler, 0x5 << 3, GET_FLAGS(op),
1982                          dst, dstw, src1, src1w, src2, src2w);                          dst, dstw, src1, src1w, src2, src2w);
1983          case SLJIT_ASHR:          case SLJIT_ASHR:
1984                  return emit_shift(compiler, 0x7 << 3,                  return emit_shift_with_flags(compiler, 0x7 << 3, GET_FLAGS(op),
1985                          dst, dstw, src1, src1w, src2, src2w);                          dst, dstw, src1, src1w, src2, src2w);
1986          }          }
1987    

Legend:
Removed from v.847  
changed lines
  Added in v.860

  ViewVC Help
Powered by ViewVC 1.1.5