version 1.1.1.1, 2012/02/21 23:05:52
|
version 1.1.1.2, 2012/02/21 23:50:25
|
Line 1
|
Line 1
|
/* |
/* |
* Stack-less Just-In-Time compiler |
* Stack-less Just-In-Time compiler |
* |
* |
* Copyright 2009-2010 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved. | * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without modification, are |
* Redistribution and use in source and binary forms, with or without modification, are |
* permitted provided that the following conditions are met: |
* permitted provided that the following conditions are met: |
Line 49 static int load_immediate(struct sljit_compiler *compi
|
Line 49 static int load_immediate(struct sljit_compiler *compi
|
if (imm <= SIMM_MAX && imm >= SIMM_MIN) |
if (imm <= SIMM_MAX && imm >= SIMM_MIN) |
return push_inst(compiler, ADDI | D(reg) | A(0) | IMM(imm)); |
return push_inst(compiler, ADDI | D(reg) | A(0) | IMM(imm)); |
|
|
|
if (!(imm & ~0xffff)) |
|
return push_inst(compiler, ORI | S(ZERO_REG) | A(reg) | IMM(imm)); |
|
|
if (imm <= SLJIT_W(0x7fffffff) && imm >= SLJIT_W(-0x80000000)) { |
if (imm <= SLJIT_W(0x7fffffff) && imm >= SLJIT_W(-0x80000000)) { |
FAIL_IF(push_inst(compiler, ADDIS | D(reg) | A(0) | IMM(imm >> 16))); |
FAIL_IF(push_inst(compiler, ADDIS | D(reg) | A(0) | IMM(imm >> 16))); |
return (imm & 0xffff) ? push_inst(compiler, ORI | S(reg) | A(reg) | IMM(imm)) : SLJIT_SUCCESS; |
return (imm & 0xffff) ? push_inst(compiler, ORI | S(reg) | A(reg) | IMM(imm)) : SLJIT_SUCCESS; |
Line 146 static SLJIT_INLINE int emit_single_op(struct sljit_co
|
Line 149 static SLJIT_INLINE int emit_single_op(struct sljit_co
|
switch (op) { |
switch (op) { |
case SLJIT_ADD: |
case SLJIT_ADD: |
if (flags & ALT_FORM1) { |
if (flags & ALT_FORM1) { |
/* Flags not set: BIN_IMM_EXTS unnecessary. */ | /* Flags does not set: BIN_IMM_EXTS unnecessary. */ |
SLJIT_ASSERT(src2 == TMP_REG2); |
SLJIT_ASSERT(src2 == TMP_REG2); |
return push_inst(compiler, ADDI | D(dst) | A(src1) | compiler->imm); |
return push_inst(compiler, ADDI | D(dst) | A(src1) | compiler->imm); |
} |
} |
if (flags & ALT_FORM2) { |
if (flags & ALT_FORM2) { |
/* Flags not set: BIN_IMM_EXTS unnecessary. */ | /* Flags does not set: BIN_IMM_EXTS unnecessary. */ |
SLJIT_ASSERT(src2 == TMP_REG2); |
SLJIT_ASSERT(src2 == TMP_REG2); |
return push_inst(compiler, ADDIS | D(dst) | A(src1) | compiler->imm); |
return push_inst(compiler, ADDIS | D(dst) | A(src1) | compiler->imm); |
} |
} |
Line 160 static SLJIT_INLINE int emit_single_op(struct sljit_co
|
Line 163 static SLJIT_INLINE int emit_single_op(struct sljit_co
|
BIN_IMM_EXTS(); |
BIN_IMM_EXTS(); |
return push_inst(compiler, ADDIC | D(dst) | A(src1) | compiler->imm); |
return push_inst(compiler, ADDIC | D(dst) | A(src1) | compiler->imm); |
} |
} |
|
if (flags & ALT_FORM4) { |
|
/* Flags does not set: BIN_IMM_EXTS unnecessary. */ |
|
FAIL_IF(push_inst(compiler, ADDI | D(dst) | A(src1) | (compiler->imm & 0xffff))); |
|
return push_inst(compiler, ADDIS | D(dst) | A(dst) | (((compiler->imm >> 16) & 0xffff) + ((compiler->imm >> 15) & 0x1))); |
|
} |
if (!(flags & ALT_SET_FLAGS)) |
if (!(flags & ALT_SET_FLAGS)) |
return push_inst(compiler, ADD | D(dst) | A(src1) | B(src2)); |
return push_inst(compiler, ADD | D(dst) | A(src1) | B(src2)); |
BIN_EXTS(); |
BIN_EXTS(); |
Line 176 static SLJIT_INLINE int emit_single_op(struct sljit_co
|
Line 184 static SLJIT_INLINE int emit_single_op(struct sljit_co
|
|
|
case SLJIT_SUB: |
case SLJIT_SUB: |
if (flags & ALT_FORM1) { |
if (flags & ALT_FORM1) { |
/* Flags not set: BIN_IMM_EXTS unnecessary. */ | /* Flags does not set: BIN_IMM_EXTS unnecessary. */ |
SLJIT_ASSERT(src2 == TMP_REG2); |
SLJIT_ASSERT(src2 == TMP_REG2); |
return push_inst(compiler, SUBFIC | D(dst) | A(src1) | compiler->imm); |
return push_inst(compiler, SUBFIC | D(dst) | A(src1) | compiler->imm); |
} |
} |
if (flags & ALT_FORM2) { | if (flags & (ALT_FORM2 | ALT_FORM3)) { |
SLJIT_ASSERT(src2 == TMP_REG2); |
SLJIT_ASSERT(src2 == TMP_REG2); |
return push_inst(compiler, CMPI | CRD(0 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | compiler->imm); | if (flags & ALT_FORM2) |
| FAIL_IF(push_inst(compiler, CMPI | CRD(0 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | compiler->imm)); |
| if (flags & ALT_FORM3) |
| return push_inst(compiler, CMPLI | CRD(4 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | compiler->imm); |
| return SLJIT_SUCCESS; |
} |
} |
if (flags & ALT_FORM3) { | if (flags & (ALT_FORM4 | ALT_FORM5)) { |
SLJIT_ASSERT(src2 == TMP_REG2); | if (flags & ALT_FORM4) |
return push_inst(compiler, CMPLI | CRD(4 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | compiler->imm); | FAIL_IF(push_inst(compiler, CMPL | CRD(4 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | B(src2))); |
| if (flags & ALT_FORM5) |
| return push_inst(compiler, CMP | CRD(0 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | B(src2)); |
| return SLJIT_SUCCESS; |
} |
} |
if (flags & ALT_FORM4) |
|
return push_inst(compiler, CMPL | CRD(4 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | B(src2)); |
|
if (!(flags & ALT_SET_FLAGS)) |
if (!(flags & ALT_SET_FLAGS)) |
return push_inst(compiler, SUBF | D(dst) | A(src2) | B(src1)); |
return push_inst(compiler, SUBF | D(dst) | A(src2) | B(src1)); |
BIN_EXTS(); |
BIN_EXTS(); |
if (flags & ALT_FORM5) | if (flags & ALT_FORM6) |
FAIL_IF(push_inst(compiler, CMPL | CRD(4 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | B(src2))); |
FAIL_IF(push_inst(compiler, CMPL | CRD(4 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | B(src2))); |
return push_inst(compiler, SUBFC | OERC(ALT_SET_FLAGS) | D(dst) | A(src2) | B(src1)); |
return push_inst(compiler, SUBFC | OERC(ALT_SET_FLAGS) | D(dst) | A(src2) | B(src1)); |
|
|