[svn:parrot] r41345 - branches/kill_jit/src
darbelo at svn.parrot.org
darbelo at svn.parrot.org
Fri Sep 18 22:47:59 UTC 2009
Author: darbelo
Date: Fri Sep 18 22:47:56 2009
New Revision: 41345
URL: https://trac.parrot.org/parrot/changeset/41345
Log:
Kill some leftover JIT functions, they are not used in the frame builder.
Modified:
branches/kill_jit/src/frame_builder.c
Modified: branches/kill_jit/src/frame_builder.c
==============================================================================
--- branches/kill_jit/src/frame_builder.c Fri Sep 18 22:22:07 2009 (r41344)
+++ branches/kill_jit/src/frame_builder.c Fri Sep 18 22:47:56 2009 (r41345)
@@ -350,157 +350,12 @@
}
char *
-emit_shift_i_m(PARROT_INTERP, char *pc, int opcode, int imm,
- int base, int i, int scale, long disp)
-{
- if (imm == 0) {
- /* noop */
- }
- else if (imm == 1) {
- *(pc++) = (char) 0xd1;
- pc = emit_r_X(interp, pc, opcode, base, i, scale, disp);
- }
- else if (imm > 1 && imm < 33) {
- *(pc++) = (char) 0xc1;
- pc = emit_r_X(interp, pc, opcode, base, i, scale, disp);
- *(pc++) = (char)imm;
- }
- else {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_JIT_ERROR,
- "emit_shift_i_m passed invalid shift\n");
- }
-
- return pc;
-}
-
-char *
-emit_shift_r_r(PARROT_INTERP, char *pc, int opcode, int reg1, int reg2)
-{
- if (reg1 != emit_ECX)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_JIT_ERROR,
- "emit_shift_r_r passed invalid register\n");
-
- *(pc++) = (char) 0xd3;
- *(pc++) = (char) emit_alu_X_r(opcode, reg2);
-
- return pc;
-}
-
-char *
-emit_shift_r_m(PARROT_INTERP, char *pc, int opcode, int reg,
- int base, int i, int scale, long disp)
-{
- if (reg != emit_ECX)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_JIT_ERROR,
- "emit_shift_r_m passed invalid register\n");
-
- *(pc++) = (char) 0xd3;
- pc = emit_r_X(interp, pc, opcode, base, i, scale, disp);
-
- return pc;
-}
-
-char *
-emit_pushl_m(PARROT_INTERP, char *pc, int base, int i, int scale, long disp)
-{
- *(pc++) = (char) 0xff;
- return emit_r_X(interp, pc, emit_reg(emit_b110), base, i, scale, disp);
-}
-
-char *
emit_popl_r(char *pc, int reg)
{
*(pc++) = (char)(0x58 | (reg - 1));
return pc;
}
-char *
-emit_popl_m(PARROT_INTERP, char *pc, int base, int i, int scale, long disp)
-{
- *(pc++) = (char) 0x8f;
- return emit_r_X(interp, pc, emit_reg(emit_b000), base, i, scale, disp);
-}
-
-char *
-emit_movb_r_r(char *pc, int reg1, int reg2)
-{
- *(pc++) = (char) 0x88;
- *(pc++) = (char) emit_alu_r_r(reg1, reg2);
- return pc;
-}
-
-char *
-emit_movb_i_r(char *pc, char imm, int reg)
-{
- *(pc++) = (char)(0xb0 | (reg - 1));
- *(pc++) = imm;
- return pc;
-}
-
-char *
-emit_movb_i_m(PARROT_INTERP, char *pc, char imm, int base, int i, int scale, long disp)
-{
- *(pc++) = (char) 0xc6;
- pc = emit_r_X(interp, pc, emit_reg(emit_b000), base, i, scale, disp);
- *(pc++) = imm;
- return pc;
-}
-
-char *
-opt_mul(PARROT_INTERP, char *pc, int dest, INTVAL imm, int src)
-{
- UINTVAL ld2 = ld((UINTVAL) imm);
-
- if (imm == 0) {
- jit_emit_mov_ri_i(interp, pc, dest, 0);
- }
- else if (imm > 0 && !(imm & (imm - 1))) {
- /* positive power of 2 - do a shift */
- jit_emit_mov_rr_i(pc, dest, src);
- pc = emit_shift_i_r(interp, pc, emit_b100, ld2, dest);
- }
- else {
- /* special small numbers */
- switch (imm) {
- case 3:
- /* LEA dest, base, index, scale, displace
- * note: src may be dest, so can't be reused
- *
- * dest = src + src*2 */
- emitm_lea_m_r(interp, pc, dest, src, src, 2, 0);
- break;
- case 5: /* dest = src + src*4 */
- emitm_lea_m_r(interp, pc, dest, src, src, 4, 0);
- break;
- case 6: /* dest = src*3; dest += dest */
- emitm_lea_m_r(interp, pc, dest, src, src, 2, 0);
- jit_emit_add_rr_i(interp, pc, dest, dest);
- break;
- case 9: /* dest = src + src*8 */
- emitm_lea_m_r(interp, pc, dest, src, src, 8, 0);
- break;
- case 10: /* dest = src + src*4 ; dest+= dest */
- emitm_lea_m_r(interp, pc, dest, src, src, 4, 0);
- jit_emit_add_rr_i(interp, pc, dest, dest);
- break;
- case 12: /* dest= src*3; dest <<= 2 */
- emitm_lea_m_r(interp, pc, dest, src, src, 2, 0);
- pc = emit_shift_i_r(interp, pc, emit_b100, 2, dest);
- break;
- case 100: /* dest = src + src*4 ; dest <<= 2; dest = 5*dest*/
- emitm_lea_m_r(interp, pc, dest, src, src, 4, 0);
- pc = emit_shift_i_r(interp, pc, emit_b100, 2, dest);
- emitm_lea_m_r(interp, pc, dest, dest, dest, 4, 0);
- break;
- default:
- emitm_alul_r_r(pc, 0x69, dest, src);
- *(long *)(pc) = (long)imm;
- pc += 4;
- }
- }
- return pc;
-}
-
int
intreg_is_used(Parrot_jit_info_t *jit_info, char reg)
{
@@ -518,71 +373,6 @@
return 0;
}
-char *
-opt_shift_rr(PARROT_INTERP, Parrot_jit_info_t *jit_info, int dest, int count, int op)
-{
- char *pc = jit_info->native_ptr;
- if (count == emit_ECX) {
- pc = emit_shift_r_r(interp, pc, op, count, dest);
- }
- else {
- int saved = 0;
- PARROT_ASSERT(count != emit_EAX);
- if (dest == emit_EAX) {
- if (intreg_is_used(jit_info, emit_ECX)) {
- emitm_pushl_r(pc, emit_ECX);
- saved = 1;
- }
- jit_emit_mov_rr_i(pc, emit_ECX, count);
- pc = emit_shift_r_r(interp, pc, op, emit_ECX, dest);
- if (saved) {
- emitm_popl_r(pc, emit_ECX);
- }
-
- }
- else if (dest == emit_ECX) {
- jit_emit_xchg_rr_i(interp, pc, dest, count);
- pc = emit_shift_r_r(interp, pc, op, dest, count);
- jit_emit_xchg_rr_i(interp, pc, dest, count);
- }
- else {
- jit_emit_mov_rr_i(pc, emit_EAX, emit_ECX);
- jit_emit_mov_rr_i(pc, emit_ECX, count);
- pc = emit_shift_r_r(interp, pc, op, emit_ECX, dest);
- jit_emit_mov_rr_i(pc, emit_ECX, emit_EAX);
- }
- }
- return pc;
-}
-
-char *
-opt_shift_rm(PARROT_INTERP, Parrot_jit_info_t *jit_info, int dest, int offs, int op)
-{
- char *pc = jit_info->native_ptr;
- int saved = 0;
- /* if ECX is mapped, save it */
- if (dest != emit_ECX && intreg_is_used(jit_info, emit_ECX)) {
- emitm_pushl_r(pc, emit_ECX);
- saved = 1;
- }
- if (dest == emit_ECX) {
- /* jit_emit_mov_RM_i(pc, emit_EAX, count); */
- emitm_movl_m_r(interp, pc, emit_EAX, emit_EBX, emit_None, 1, offs);
- jit_emit_xchg_rr_i(interp, pc, dest, emit_EAX);
- pc = emit_shift_r_r(interp, pc, op, emit_ECX, emit_EAX);
- jit_emit_xchg_rr_i(interp, pc, dest, emit_EAX);
- }
- else {
- /* jit_emit_mov_RM_i(pc, emit_ECX, count); */
- emitm_movl_m_r(interp, pc, emit_ECX, emit_EBX, emit_None, 1, offs);
- pc = emit_shift_r_r(interp, pc, op, emit_ECX, dest);
- }
- if (saved) {
- emitm_popl_r(pc, emit_ECX);
- }
- return pc;
-}
-
void call_func(Parrot_jit_info_t *jit_info, void (*addr) (void))
{
Parrot_jit_newfixup(jit_info);
@@ -598,258 +388,6 @@
unsigned char *lastpc;
-/* ST(r1) /= ST(r2) */
-char *
-div_rr_n(PARROT_INTERP, Parrot_jit_info_t *jit_info, int r1)
-{
- char *L1;
- static const char div_by_zero[] = "Divide by zero";
- char *pc = jit_info->native_ptr;
-
- jit_emit_test_r_n(pc, (char)0); /* TOS */
- L1 = pc;
- emitm_jxs(pc, emitm_jnz, 0);
- emitm_pushl_i(pc, div_by_zero);
- emitm_pushl_i(pc, EXCEPTION_DIV_BY_ZERO);
- emitm_pushl_i(pc, 0); /* NULL */
- Parrot_jit_emit_get_INTERP(interp, pc, emit_ECX);
- emitm_pushl_r(pc, emit_ECX);
- jit_info->native_ptr = pc;
- jit_emit_real_exception(jit_info);
- pc = jit_info->native_ptr;
- /* L1: */
- L1[1] = (char)(pc - L1 - 2);
- emitm_fdivp(pc, (r1+1));
- return pc;
-}
-
-char *
-mod_rr_n(PARROT_INTERP, Parrot_jit_info_t *jit_info, int r)
-{
- char *L1;
- static const char div_by_zero[] = "Divide by zero";
- char *pc = jit_info->native_ptr;
-
- jit_emit_test_r_n(pc, (char)0); /* TOS */
- L1 = pc;
- emitm_jxs(pc, emitm_jnz, 0);
- emitm_pushl_i(pc, div_by_zero);
- emitm_pushl_i(pc, EXCEPTION_DIV_BY_ZERO);
- emitm_pushl_i(pc, 0); /* NULL */
- Parrot_jit_emit_get_INTERP(interp, pc, emit_ECX);
- emitm_pushl_r(pc, emit_ECX);
- jit_info->native_ptr = pc;
- jit_emit_real_exception(jit_info);
- pc = jit_info->native_ptr;
- /* L1: */
- L1[1] = (char)(pc - L1 - 2);
- /* L2: */
- emitm_fxch(pc, (char)1);
- emitm_fprem(pc);
- emitm_fstw(pc);
- emitm_sahf(pc);
- emitm_jxs(pc, emitm_jp, -7); /* jo L2 */
- emitm_fstp(pc, (r+1));
- return pc;
-}
-
-/* dest /= src
- * edx:eax /= src, quotient => eax, rem => edx
- */
-char *
-opt_div_rr(PARROT_INTERP, Parrot_jit_info_t *jit_info, int dest, int src, int is_div)
-{
- char *pc = jit_info->native_ptr;
- int saved = 0;
- int div_ecx = 0;
- char *L1, *L2, *L3;
- static const char div_by_zero[] = "Divide by zero";
-
- PARROT_ASSERT(src != emit_EAX);
-
- if (dest != emit_EAX) {
- jit_emit_mov_rr_i(pc, emit_EAX, dest);
- }
- if (dest == emit_EDX) {
- /* all ok, we can globber it */
- }
- else {
- /* if ECX is not mapped use it */
- if (!intreg_is_used(jit_info, emit_ECX) && src == emit_EDX) {
- jit_emit_mov_rr_i(pc, emit_ECX, emit_EDX);
- div_ecx = 1;
- }
- else
- /* if EDX is mapped, preserve EDX on stack */
- if (intreg_is_used(jit_info, emit_EDX)) {
- emitm_pushl_r(pc, emit_EDX);
- saved = 1;
- /* if EDX is the src, we need another temp register: ECX */
- if (src == emit_EDX) {
- /* if ECX is mapped save it, but not if it's dest */
- if (intreg_is_used(jit_info, emit_ECX) &&
- dest != emit_ECX) {
- emitm_pushl_r(pc, emit_ECX);
- saved = 2;
- }
- /* else just use it */
- jit_emit_mov_rr_i(pc, emit_ECX, emit_EDX);
- div_ecx = 1;
- }
- }
- }
- /* this sequence allows 2 other instructions to run parallel */
- if (dest != emit_EDX) {
- jit_emit_mov_rr_i(pc, emit_EDX, emit_EAX);
- }
- pc = emit_shift_i_r(interp, pc, emit_b111, 31, emit_EDX); /* SAR 31 */
- if (div_ecx) {
- jit_emit_test_r_i(pc, emit_ECX);
- L1 = pc;
- emitm_jxs(pc, emitm_jz, 0);
- emitm_sdivl_r(pc, emit_ECX);
- L3 = pc;
- emitm_jumps(pc, 0);
- /* L1: */
- L1[1] = (char)(pc - L1 - 2);
- }
- else {
- jit_emit_test_r_i(pc, src);
- L2 = pc;
- emitm_jxs(pc, emitm_jz, 0);
- emitm_sdivl_r(pc, src);
- L3 = pc;
- emitm_jumps(pc, 0);
- /* L2: */
- L2[1] = (char)(pc - L2 - 2);
- }
- /* TODO Parrot_ex_throw_from_c_args */
- emitm_pushl_i(pc, div_by_zero);
- emitm_pushl_i(pc, EXCEPTION_DIV_BY_ZERO);
- emitm_pushl_i(pc, 0); /* NULL */
- Parrot_jit_emit_get_INTERP(interp, pc, emit_ECX);
- emitm_pushl_r(pc, emit_ECX);
- jit_info->native_ptr = pc;
- jit_emit_real_exception(jit_info);
- pc = jit_info->native_ptr;
- /* L3: */
- L3[1] = (char)(pc - L3 - 2);
- if (saved == 2) {
- emitm_popl_r(pc, emit_ECX);
- }
- if (is_div) {
- /* result = quotient in EAX */
- if (saved) {
- emitm_popl_r(pc, emit_EDX);
- }
- if (dest != emit_EAX) {
- jit_emit_mov_rr_i(pc, dest, emit_EAX);
- }
- }
- else {
- /* result = remainder in EDX */
- if (saved) {
- emitm_popl_r(pc, emit_EAX);
- jit_emit_mov_rr_i(pc, dest, emit_EDX);
- jit_emit_mov_rr_i(pc, emit_EDX, emit_EAX);
- }
- else {
- if (dest != emit_EDX)
- jit_emit_mov_rr_i(pc, dest, emit_EDX);
- }
- }
- if (!saved && div_ecx) {
- /* restore EDX */
- jit_emit_mov_rr_i(pc, emit_EDX, emit_ECX);
- }
- return pc;
-}
-
-char *
-opt_div_ri(PARROT_INTERP, Parrot_jit_info_t *jit_info, int dest, INTVAL imm, int is_div)
-{
- char *pc = jit_info->native_ptr;
-
- UINTVAL ld2 = ld((UINTVAL) imm);
- if (is_div && imm > 1 && !(imm & (imm - 1))) {
- /* positive power of 2 - do a shift */
- pc = emit_shift_i_r(interp, pc, emit_b101, ld2, dest);
- }
- else {
- if (dest != emit_EBX) {
- emitm_pushl_r(pc, emit_EBX);
- jit_emit_mov_ri_i(interp, pc, emit_EBX, imm);
- jit_info->native_ptr = pc;
- pc = opt_div_rr(interp, jit_info, dest, emit_EBX, is_div);
- pc = emit_popl_r(pc, emit_EBX);
- }
- else {
- emitm_pushl_r(pc, emit_EDI);
- jit_emit_mov_ri_i(interp, pc, emit_EDI, imm);
- jit_info->native_ptr = pc;
- pc = opt_div_rr(interp, jit_info, dest, emit_EDI, is_div);
- pc = emit_popl_r(pc, emit_EDI);
- }
- }
- return pc;
-}
-
-char *
-opt_div_RM(PARROT_INTERP, Parrot_jit_info_t *jit_info, int dest, int offs, int is_div)
-{
- char *pc = jit_info->native_ptr;
- int saved = 0;
-
- if (dest != emit_EAX) {
- jit_emit_mov_rr_i(pc, emit_EAX, dest);
- }
- if (dest == emit_EDX) {
- /* all ok, we can globber it */
- }
- else {
- /* if ECX is mapped, push EDX on stack */
- if (intreg_is_used(jit_info, emit_ECX)) {
- emitm_pushl_r(pc, emit_EDX);
- saved = 2;
- }
- /* if EDX is mapped, save it in ECX */
- else if (intreg_is_used(jit_info, emit_EDX)) {
- saved = 1;
- jit_emit_mov_rr_i(pc, emit_ECX, emit_EDX);
- }
- }
- /* this sequence allows 2 other instructions to run parallel */
- jit_emit_mov_rr_i(pc, emit_EDX, emit_EAX);
- pc = emit_shift_i_r(interp, pc, emit_b111, 31, emit_EDX); /* SAR 31 */
-
- emitm_sdivl_m(pc, emit_EBX, 0, 1, offs);
-
- if (is_div) {
- /* result = quotient in EAX */
- if (saved == 1) {
- jit_emit_mov_rr_i(pc, emit_EDX, emit_ECX);
- }
- if (dest != emit_EAX) {
- jit_emit_mov_rr_i(pc, dest, emit_EAX);
- }
- if (saved == 2) {
- emitm_popl_r(pc, emit_EDX);
- }
- }
- else {
- /* result = remainder in EDX */
- if (dest != emit_EDX) {
- jit_emit_mov_rr_i(pc, dest, emit_EDX);
- if (saved == 1) {
- jit_emit_mov_rr_i(pc, emit_EDX, emit_ECX);
- }
- else if (saved == 2)
- emitm_popl_r(pc, emit_EDX);
- }
- }
- return pc;
-}
-
void
jit_emit_jcc(Parrot_jit_info_t *jit_info, int code, opcode_t disp)
{
More information about the parrot-commits
mailing list