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 31 static int load_immediate(struct sljit_compiler *compi
|
Line 31 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)); |
|
|
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 44 static SLJIT_INLINE int emit_single_op(struct sljit_co
|
Line 47 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 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 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 55 static SLJIT_INLINE int emit_single_op(struct sljit_co
|
Line 60 static SLJIT_INLINE int emit_single_op(struct sljit_co
|
SLJIT_ASSERT(src2 == TMP_REG2); |
SLJIT_ASSERT(src2 == TMP_REG2); |
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)); |
return push_inst(compiler, ADDC | OERC(ALT_SET_FLAGS) | D(dst) | A(src1) | B(src2)); |
return push_inst(compiler, ADDC | OERC(ALT_SET_FLAGS) | D(dst) | A(src1) | B(src2)); |
Line 69 static SLJIT_INLINE int emit_single_op(struct sljit_co
|
Line 79 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 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) | A(src1) | compiler->imm); | if (flags & ALT_FORM2) |
| FAIL_IF(push_inst(compiler, CMPI | CRD(0) | A(src1) | compiler->imm)); |
| if (flags & ALT_FORM3) |
| return push_inst(compiler, CMPLI | CRD(4) | 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) | A(src1) | compiler->imm); | FAIL_IF(push_inst(compiler, CMPL | CRD(4) | A(src1) | B(src2))); |
| if (flags & ALT_FORM5) |
| FAIL_IF(push_inst(compiler, CMP | CRD(0) | A(src1) | B(src2))); |
| return SLJIT_SUCCESS; |
} |
} |
if (flags & ALT_FORM4) |
|
return push_inst(compiler, CMPL | CRD(4) | 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)); |
if (flags & ALT_FORM5) | if (flags & ALT_FORM6) |
FAIL_IF(push_inst(compiler, CMPL | CRD(4) | A(src1) | B(src2))); |
FAIL_IF(push_inst(compiler, CMPL | CRD(4) | 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)); |
|
|