jit_pointer_t _emit_code(jit_state_t *_jit) { jit_node_t *node; jit_node_t *temp; jit_word_t word; jit_int32_t value; jit_int32_t offset; struct { jit_node_t *node; jit_word_t word; jit_int32_t patch_offset; } undo; _jitc->function = NULL; jit_reglive_setup(); undo.word = 0; undo.node = NULL; undo.patch_offset = 0; #define case_rr(name, type) \ case jit_code_##name##r##type: \ name##r##type(rn(node->u.w), rn(node->v.w)); \ break #define case_rw(name, type) \ case jit_code_##name##i##type: \ name##i##type(rn(node->u.w), node->v.w); \ break #define case_wr(name, type) \ case jit_code_##name##i##type: \ name##i##type(node->u.w, rn(node->v.w)); \ break #define case_rf(name) \ case jit_code_##name##i##type: \ assert(node->flag & jit_flag_data); \ name##_f(rn(node->u.w), \ (jit_float32_t *)node->v.n->u.w); \ break #define case_rd(name) \ case jit_code_##name##i_d: \ assert(node->flag & jit_flag_data); \ name##_d(rn(node->u.w), \ (jit_float64_t *)node->v.n->u.w); \ break #define case_rrr(name, type) \ case jit_code_##name##r##type: \ name##r##type(rn(node->u.w), \ rn(node->v.w), rn(node->w.w)); \ break #define case_rrrr(name, type) \ case jit_code_##name##r##type: \ name##r##type(rn(node->u.q.l), rn(node->u.q.h), \ rn(node->v.w), rn(node->w.w)); \ break #define case_rrw(name, type) \ case jit_code_##name##i##type: \ name##i##type(rn(node->u.w), \ rn(node->v.w), node->w.w); \ break #define case_rrrw(name, type) \ case jit_code_##name##i##type: \ name##i##type(rn(node->u.q.l), rn(node->u.q.h), \ rn(node->v.w), node->w.w); \ break #define case_rrf(name, type, size) \ case jit_code_##name##i##type: \ assert(node->flag & jit_flag_data); \ name##i##type(rn(node->u.w), rn(node->v.w), \ (jit_float##size##_t *)node->w.n->u.w); \ break #define case_wrr(name, type) \ case jit_code_##name##i##type: \ name##i##type(node->u.w, rn(node->v.w), rn(node->w.w)); \ break #define case_brr(name, type) \ case jit_code_##name##r##type: \ temp = node->u.n; \ assert(temp->code == jit_code_label || \ temp->code == jit_code_epilog); \ if (temp->flag & jit_flag_patch) \ name##r##type(temp->u.w, rn(node->v.w), \ rn(node->w.w)); \ else { \ word = name##r##type(_jit->pc.w, \ rn(node->v.w), rn(node->w.w)); \ patch(word, node); \ } \ break #define case_brw(name, type) \ case jit_code_##name##i##type: \ temp = node->u.n; \ assert(temp->code == jit_code_label || \ temp->code == jit_code_epilog); \ if (temp->flag & jit_flag_patch) \ name##i##type(temp->u.w, \ rn(node->v.w), node->w.w); \ else { \ word = name##i##type(_jit->pc.w, \ rn(node->v.w), node->w.w); \ patch(word, node); \ } \ break #define case_brf(name, type, size) \ case jit_code_##name##i##type: \ temp = node->u.n; \ assert(temp->code == jit_code_label || \ temp->code == jit_code_epilog); \ if (temp->flag & jit_flag_patch) \ name##i##type(temp->u.w, rn(node->v.w), \ (jit_float##size##_t *)node->w.n->u.w); \ else { \ word = name##i##type(_jit->pc.w, rn(node->v.w), \ (jit_float##size##_t *)node->w.n->u.w); \ patch(word, node); \ } \ break for (node = _jitc->head; node; node = node->next) { if (_jit->pc.uc >= _jitc->code.end) return (NULL); value = jit_classify(node->code); jit_regarg_set(node, value); switch (node->code) { case jit_code_align: assert(!(node->u.w & (node->u.w - 1)) && node->u.w <= sizeof(jit_word_t)); if (node->u.w == sizeof(jit_word_t) && (word = _jit->pc.w & (sizeof(jit_word_t) - 1))) nop(sizeof(jit_word_t) - word); break; case jit_code_note: case jit_code_name: node->u.w = _jit->pc.w; break; case jit_code_label: if ((node->link || (node->flag & jit_flag_use)) && (word = _jit->pc.w & (sizeof(jit_word_t) - 1))) nop(sizeof(jit_word_t) - word); /* remember label is defined */ node->flag |= jit_flag_patch; node->u.w = _jit->pc.w; break; case_rrr(add,); case_rrw(add,); case_rrr(addc,); case_rrw(addc,); case_rrr(addx,); case_rrw(addx,); case_rrr(sub,); case_rrw(sub,); case_rrr(subc,); case_rrw(subc,); case_rrr(subx,); case_rrw(subx,); case_rrw(rsb,); case_rrr(mul,); case_rrw(mul,); case_rrrr(qmul,); case_rrrw(qmul,); case_rrrr(qmul, _u); case_rrrw(qmul, _u); case_rrr(div,); case_rrw(div,); case_rrr(div, _u); case_rrw(div, _u); case_rrrr(qdiv,); case_rrrw(qdiv,); case_rrrr(qdiv, _u); case_rrrw(qdiv, _u); case_rrr(rem,); case_rrw(rem,); case_rrr(rem, _u); case_rrw(rem, _u); case_rrr(and,); case_rrw(and,); case_rrr(or,); case_rrw(or,); case_rrr(xor,); case_rrw(xor,); case_rrr(lsh,); case_rrw(lsh,); case_rrr(rsh,); case_rrw(rsh,); case_rrr(rsh, _u); case_rrw(rsh, _u); case_rr(trunc, _f_i); case_rr(trunc, _d_i); case_rrr(lt,); case_rrw(lt,); case_rrr(lt, _u); case_rrw(lt, _u); case_rrr(le,); case_rrw(le,); case_rrr(le, _u); case_rrw(le, _u); case_rrr(eq,); case_rrw(eq,); case_rrr(ge,); case_rrw(ge,); case_rrr(ge, _u); case_rrw(ge, _u); case_rrr(gt,); case_rrw(gt,); case_rrr(gt, _u); case_rrw(gt, _u); case_rrr(ne,); case_rrw(ne,); case_rr(ld, _c); case_rw(ld, _c); case_rr(ld, _uc); case_rw(ld, _uc); case_rr(ld, _s); case_rw(ld, _s); case_rr(ld, _us); case_rw(ld, _us); case_rr(ld, _i); case_rw(ld, _i); case_rrr(ldx, _c); case_rrw(ldx, _c); case_rrr(ldx, _uc); case_rrw(ldx, _uc); case_rrr(ldx, _s); case_rrw(ldx, _s); case_rrr(ldx, _us); case_rrw(ldx, _us); case_rrr(ldx, _i); case_rrw(ldx, _i); case_rr(st, _c); case_wr(st, _c); case_rr(st, _s); case_wr(st, _s); case_rr(st, _i); case_wr(st, _i); case_rrr(stx, _c); case_wrr(stx, _c); case_rrr(stx, _s); case_wrr(stx, _s); case_rrr(stx, _i); case_wrr(stx, _i); case_rr(hton, _us); case_rr(hton, _ui); case_rr(ext, _c); case_rr(ext, _uc); case_rr(ext, _s); case_rr(ext, _us); case_rr(mov,); case jit_code_movi: if (node->flag & jit_flag_node) { temp = node->v.n; if (temp->code == jit_code_data || (temp->code == jit_code_label && (temp->flag & jit_flag_patch))) movi(rn(node->u.w), temp->u.w); else { assert(temp->code == jit_code_label || temp->code == jit_code_epilog); word = movi_p(rn(node->u.w), node->v.w); patch(word, node); } } else movi(rn(node->u.w), node->v.w); break; case_rr(neg,); case_rr(com,); case_brr(blt,); case_brw(blt,); case_brr(blt, _u); case_brw(blt, _u); case_brr(ble,); case_brw(ble,); case_brr(ble, _u); case_brw(ble, _u); case_brr(beq,); case_brw(beq,); case_brr(bge,); case_brw(bge,); case_brr(bge, _u); case_brw(bge, _u); case_brr(bgt,); case_brw(bgt,); case_brr(bgt, _u); case_brw(bgt, _u); case_brr(bne,); case_brw(bne,); case_brr(boadd,); case_brw(boadd,); case_brr(boadd, _u); case_brw(boadd, _u); case_brr(bxadd,); case_brw(bxadd,); case_brr(bxadd, _u); case_brw(bxadd, _u); case_brr(bosub,); case_brw(bosub,); case_brr(bosub, _u); case_brw(bosub, _u); case_brr(bxsub,); case_brw(bxsub,); case_brr(bxsub, _u); case_brw(bxsub, _u); case_brr(bms,); case_brw(bms,); case_brr(bmc,); case_brw(bmc,); case_rrr(add, _f); case_rrf(add, _f, 32); case_rrr(sub, _f); case_rrf(sub, _f, 32); case_rrf(rsb, _f, 32); case_rrr(mul, _f); case_rrf(mul, _f, 32); case_rrr(div, _f); case_rrf(div, _f, 32); case_rr(abs, _f); case_rr(neg, _f); case_rr(sqrt, _f); case_rr(ext, _f); case_rr(ext, _d_f); case_rrr(lt, _f); case_rrf(lt, _f, 32); case_rrr(le, _f); case_rrf(le, _f, 32); case_rrr(eq, _f); case_rrf(eq, _f, 32); case_rrr(ge, _f); case_rrf(ge, _f, 32); case_rrr(gt, _f); case_rrf(gt, _f, 32); case_rrr(ne, _f); case_rrf(ne, _f, 32); case_rrr(unlt, _f); case_rrf(unlt, _f, 32); case_rrr(unle, _f); case_rrf(unle, _f, 32); case_rrr(uneq, _f); case_rrf(uneq, _f, 32); case_rrr(unge, _f); case_rrf(unge, _f, 32); case_rrr(ungt, _f); case_rrf(ungt, _f, 32); case_rrr(ltgt, _f); case_rrf(ltgt, _f, 32); case_rrr(ord, _f); case_rrf(ord, _f, 32); case_rrr(unord, _f); case_rrf(unord, _f, 32); case_rr(ld, _f); case_rw(ld, _f); case_rrr(ldx, _f); case_rrw(ldx, _f); case_rr(st, _f); case_wr(st, _f); case_rrr(stx, _f); case_wrr(stx, _f); case_rr(mov, _f); case jit_code_movi_f: assert(node->flag & jit_flag_data); movi_f(rn(node->u.w), (jit_float32_t *)node->v.n->u.w); break; case_brr(blt, _f); case_brf(blt, _f, 32); case_brr(ble, _f); case_brf(ble, _f, 32); case_brr(beq, _f); case_brf(beq, _f, 32); case_brr(bge, _f); case_brf(bge, _f, 32); case_brr(bgt, _f); case_brf(bgt, _f, 32); case_brr(bne, _f); case_brf(bne, _f, 32); case_brr(bunlt, _f); case_brf(bunlt, _f, 32); case_brr(bunle, _f); case_brf(bunle, _f, 32); case_brr(buneq, _f); case_brf(buneq, _f, 32); case_brr(bunge, _f); case_brf(bunge, _f, 32); case_brr(bungt, _f); case_brf(bungt, _f, 32); case_brr(bltgt, _f); case_brf(bltgt, _f, 32); case_brr(bord, _f); case_brf(bord, _f, 32); case_brr(bunord, _f); case_brf(bunord, _f, 32); case_rrr(add, _d); case_rrf(add, _d, 64); case_rrr(sub, _d); case_rrf(sub, _d, 64); case_rrf(rsb, _d, 64); case_rrr(mul, _d); case_rrf(mul, _d, 64); case_rrr(div, _d); case_rrf(div, _d, 64); case_rr(abs, _d); case_rr(neg, _d); case_rr(sqrt, _d); case_rr(ext, _d); case_rr(ext, _f_d); case_rrr(lt, _d); case_rrf(lt, _d, 64); case_rrr(le, _d); case_rrf(le, _d, 64); case_rrr(eq, _d); case_rrf(eq, _d, 64); case_rrr(ge, _d); case_rrf(ge, _d, 64); case_rrr(gt, _d); case_rrf(gt, _d, 64); case_rrr(ne, _d); case_rrf(ne, _d, 64); case_rrr(unlt, _d); case_rrf(unlt, _d, 64); case_rrr(unle, _d); case_rrf(unle, _d, 64); case_rrr(uneq, _d); case_rrf(uneq, _d, 64); case_rrr(unge, _d); case_rrf(unge, _d, 64); case_rrr(ungt, _d); case_rrf(ungt, _d, 64); case_rrr(ltgt, _d); case_rrf(ltgt, _d, 64); case_rrr(ord, _d); case_rrf(ord, _d, 64); case_rrr(unord, _d); case_rrf(unord, _d, 64); case_rr(ld, _d); case_rw(ld, _d); case_rrr(ldx, _d); case_rrw(ldx, _d); case_rr(st, _d); case_wr(st, _d); case_rrr(stx, _d); case_wrr(stx, _d); case_rr(mov, _d); case jit_code_movi_d: assert(node->flag & jit_flag_data); movi_d(rn(node->u.w), (jit_float64_t *)node->v.n->u.w); break; case_brr(blt, _d); case_brf(blt, _d, 64); case_brr(ble, _d); case_brf(ble, _d, 64); case_brr(beq, _d); case_brf(beq, _d, 64); case_brr(bge, _d); case_brf(bge, _d, 64); case_brr(bgt, _d); case_brf(bgt, _d, 64); case_brr(bne, _d); case_brf(bne, _d, 64); case_brr(bunlt, _d); case_brf(bunlt, _d, 64); case_brr(bunle, _d); case_brf(bunle, _d, 64); case_brr(buneq, _d); case_brf(buneq, _d, 64); case_brr(bunge, _d); case_brf(bunge, _d, 64); case_brr(bungt, _d); case_brf(bungt, _d, 64); case_brr(bltgt, _d); case_brf(bltgt, _d, 64); case_brr(bord, _d); case_brf(bord, _d, 64); case_brr(bunord, _d); case_brf(bunord, _d, 64); case jit_code_jmpr: jmpr(rn(node->u.w)); break; case jit_code_jmpi: if (node->flag & jit_flag_node) { temp = node->u.n; assert(temp->code == jit_code_label || temp->code == jit_code_epilog); if (temp->flag & jit_flag_patch) jmpi(temp->u.w); else { word = jmpi_p(_jit->pc.w); patch(word, node); } } else jmpi(node->u.w); break; case jit_code_callr: callr(rn(node->u.w)); break; case jit_code_calli: if (node->flag & jit_flag_node) { temp = node->u.n; assert(temp->code == jit_code_label || temp->code == jit_code_epilog); word = calli_p(temp->u.w); if (!(temp->flag & jit_flag_patch)) patch(word, node); } else calli(node->u.w); break; case jit_code_prolog: _jitc->function = _jitc->functions.ptr + node->w.w; undo.node = node; undo.word = _jit->pc.w; undo.patch_offset = _jitc->patches.offset; restart_function: _jitc->again = 0; prolog(node); break; case jit_code_epilog: assert(_jitc->function == _jitc->functions.ptr + node->w.w); if (_jitc->again) { for (temp = undo.node->next; temp != node; temp = temp->next) { if (temp->code == jit_code_label || temp->code == jit_code_epilog) temp->flag &= ~jit_flag_patch; } temp->flag &= ~jit_flag_patch; node = undo.node; _jit->pc.w = undo.word; _jitc->patches.offset = undo.patch_offset; goto restart_function; } /* remember label is defined */ node->flag |= jit_flag_patch; node->u.w = _jit->pc.w; epilog(node); _jitc->function = NULL; break; case jit_code_live: case jit_code_arg: case jit_code_arg_f: case jit_code_arg_d: break; default: abort(); } jit_regarg_clr(node, value); assert(_jitc->regarg == 0); /* update register live state */ jit_reglive(node); } #undef case_brf #undef case_brw #undef case_brr #undef case_wrr #undef case_rrf #undef case_rrrw #undef case_rrw #undef case_rrrr #undef case_rrr #undef case_rf #undef case_wr #undef case_rw #undef case_rr for (offset = 0; offset < _jitc->patches.offset; offset++) { node = _jitc->patches.ptr[offset].node; word = node->code == jit_code_movi ? node->v.n->u.w : node->u.n->u.w; patch_at(_jitc->patches.ptr[offset].inst, word); } jit_flush(_jit->code.ptr, _jit->pc.uc); return (_jit->code.ptr); }
int encode_op(char *opcode, char *op_data) { int rd,rs,rt,imm,funct,shaft,target; char tmp[256]; const char *fi = "%s %d"; const char *fg = "%s %%g%d"; const char *ff = "%s %%f%d"; const char *fl = "%s %s"; const char *fgi = "%s %%g%d, %d"; const char *fgl = "%s %%g%d, %s"; const char *fgg = "%s %%g%d, %%g%d"; const char *fggl = "%s %%g%d, %%g%d, %s"; const char *fggi = "%s %%g%d, %%g%d, %d"; const char *fggg = "%s %%g%d, %%g%d, %%g%d"; const char *fff = "%s %%f%d, %%f%d"; const char *fgf = "%s %%g%d, %%f%d"; const char *ffg = "%s %%f%d, %%g%d"; const char *fffl = "%s %%f%d, %%f%d, %s"; const char *ffff = "%s %%f%d, %%f%d, %%f%d"; const char *ffgi = "%s %%f%d, %%g%d, %d"; const char *ffgg = "%s %%f%d, %%g%d, %%g%d"; char lname[256]; shaft = funct = target = 0; if(strcmp(opcode, "mvhi") == 0){ if(sscanf(op_data, fgi, tmp, &rs, &imm) == 3) return mvhi(rs,0,imm); } if(strcmp(opcode, "mvlo") == 0){ if(sscanf(op_data, fgi, tmp, &rs, &imm) == 3) return mvlo(rs,0,imm); } if(strcmp(opcode, "add") == 0){ if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4) return add(rs,rt,rd,0); } if(strcmp(opcode, "nor") == 0){ if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4) return nor(rs,rt,rd,0); } if(strcmp(opcode, "sub") == 0){ if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4) return sub(rs,rt,rd,0); } if(strcmp(opcode, "mul") == 0){ if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4) return mul(rs,rt,rd,0); } if(strcmp(opcode, "addi") == 0){ if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4) return addi(rs,rt,imm); } if(strcmp(opcode, "subi") == 0){ if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4) return subi(rs,rt,imm); } if(strcmp(opcode, "muli") == 0){ if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4) return muli(rs,rt,imm); } if(strcmp(opcode, "input") == 0){ if(sscanf(op_data, fg, tmp, &rd) == 2) return input(0,0,rd,0); } if(strcmp(opcode, "inputw") == 0){ if(sscanf(op_data, fg, tmp, &rd) == 2) return inputw(0,0,rd,0); } if(strcmp(opcode, "inputf") == 0){ if(sscanf(op_data, ff, tmp, &rd) == 2) return inputf(0,0,rd,0); } if(strcmp(opcode, "output") == 0){ if(sscanf(op_data, fg, tmp, &rs) == 2) return output(rs,0,0,0); } if(strcmp(opcode, "outputw") == 0){ if(sscanf(op_data, fg, tmp, &rs) == 2) return outputw(rs,0,0,0); } if(strcmp(opcode, "outputf") == 0){ if(sscanf(op_data, ff, tmp, &rs) == 2) return outputf(rs,0,0,0); } if(strcmp(opcode, "and") == 0){ if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4) return _and(rs,rt,rd,0); } if(strcmp(opcode, "or") == 0){ if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4) return _or(rs,rt,rd,0); } if(strcmp(opcode, "sll") == 0){ if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4) return sll(rs,rt,rd,0); } if(strcmp(opcode, "srl") == 0){ if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4) return srl(rs,rt,rd,0); } if(strcmp(opcode, "slli") == 0){ if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4) return slli(rs,rt,imm); } if(strcmp(opcode, "srli") == 0){ if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4) return srli(rs,rt,imm); } if(strcmp(opcode, "b") == 0){ if(sscanf(op_data, fg, tmp, &rs) == 2) return b(rs,0,0,0); } if(strcmp(opcode, "jmp") == 0){ if(sscanf(op_data, fl, tmp, lname) == 2) { strcpy(label_name[label_cnt],lname); return jmp(label_cnt++); } } if(strcmp(opcode, "jeq") == 0){ if(sscanf(op_data, fggl, tmp, &rs, &rt, lname) == 4) { strcpy(label_name[label_cnt],lname); return jeq(rs,rt,label_cnt++); } } if(strcmp(opcode, "jne") == 0){ if(sscanf(op_data, fggl, tmp, &rs, &rt, lname) == 4) { strcpy(label_name[label_cnt],lname); return jne(rs,rt,label_cnt++); } } if(strcmp(opcode, "jlt") == 0){ if(sscanf(op_data, fggl, tmp, &rs, &rt, lname) == 4) { strcpy(label_name[label_cnt],lname); return jlt(rs,rt,label_cnt++); } } if(strcmp(opcode, "jle") == 0){ if(sscanf(op_data, fggl, tmp, &rs, &rt, lname) == 4) { strcpy(label_name[label_cnt],lname); return jle(rs,rt,label_cnt++); } } if(strcmp(opcode, "call") == 0){ if(sscanf(op_data, fl, tmp, lname) == 2) { strcpy(label_name[label_cnt],lname); return call(label_cnt++); } } if(strcmp(opcode, "callR") == 0){ if(sscanf(op_data, fg, tmp, &rs) == 2) return callr(rs,0,0,0); } if(strcmp(opcode, "return") == 0){ return _return(0); } if(strcmp(opcode, "ld") == 0){ if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4) return ld(rs,rt,rd,0); } if(strcmp(opcode, "ldi") == 0){ if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4) return ldi(rs,rt,imm); } if(strcmp(opcode, "ldlr") == 0){ if(sscanf(op_data, fgi, tmp, &rs, &imm) == 3) return ldlr(rs,0,imm); } if(strcmp(opcode, "fld") == 0){ if(sscanf(op_data, ffgg, tmp, &rd, &rs,&rt) == 4) return fld(rs,rt,rd,0); } if(strcmp(opcode, "st") == 0){ if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4) return st(rs,rt,rd,0); } if(strcmp(opcode, "sti") == 0){ if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4) return sti(rs,rt,imm); } if(strcmp(opcode, "stlr") == 0){ if(sscanf(op_data, fgi, tmp, &rs, &imm) == 3) return stlr(rs,0,imm); } if(strcmp(opcode, "fst") == 0){ if(sscanf(op_data, ffgg, tmp, &rd, &rs,&rt) == 4) return fst(rs,rt,rd,0); } if(strcmp(opcode, "fadd") == 0){ if(sscanf(op_data, ffff, tmp, &rd, &rs, &rt) == 4) return fadd(rs,rt,rd,0); } if(strcmp(opcode, "fsub") == 0){ if(sscanf(op_data, ffff, tmp, &rd, &rs, &rt) == 4) return fsub(rs,rt,rd,0); } if(strcmp(opcode, "fmul") == 0){ if(sscanf(op_data, ffff, tmp, &rd, &rs, &rt) == 4) return fmul(rs,rt,rd,0); } if(strcmp(opcode, "fdiv") == 0){ if(sscanf(op_data, ffff, tmp, &rd, &rs, &rt) == 4) return fdiv(rs,rt,rd,0); } if(strcmp(opcode, "fsqrt") == 0){ if(sscanf(op_data, fff, tmp, &rd, &rs) == 3) return fsqrt(rs,0,rd,0); } if(strcmp(opcode, "fabs") == 0){ if(sscanf(op_data, fff, tmp, &rd, &rs) == 3) return _fabs(rs,0,rd,0); } if(strcmp(opcode, "fmov") == 0){ if(sscanf(op_data, fff, tmp, &rd, &rs) == 3) return fmov(rs,0,rd,0); } if(strcmp(opcode, "fneg") == 0){ if(sscanf(op_data, fff, tmp, &rd, &rs) == 3) return fneg(rs,0,rd,0); } if(strcmp(opcode, "fldi") == 0){ if(sscanf(op_data, ffgi, tmp, &rt, &rs, &imm) == 4) return fldi(rs,rt,imm); } if(strcmp(opcode, "fsti") == 0){ if(sscanf(op_data, ffgi, tmp, &rt, &rs, &imm) == 4) return fsti(rs,rt,imm); } if(strcmp(opcode, "fjeq") == 0){ if(sscanf(op_data, fffl, tmp, &rs, &rt, lname) == 4) { strcpy(label_name[label_cnt],lname); return fjeq(rs,rt,label_cnt++); } } if(strcmp(opcode, "fjlt") == 0){ if(sscanf(op_data, fffl, tmp, &rs, &rt, lname) == 4) { strcpy(label_name[label_cnt],lname); return fjlt(rs,rt,label_cnt++); } } if(strcmp(opcode, "halt") == 0){ return halt(0,0,0,0); } if(strcmp(opcode, "setL") == 0){ if(sscanf(op_data, fgl, tmp, &rd, lname) == 3) { strcpy(label_name[label_cnt],lname); return setl(0,rd,label_cnt++); } } if(strcmp(opcode, "padd") == 0){ if(sscanf(op_data, fgi, tmp, &rt, &imm) == 3) { return padd(0,rt,imm); } } if(strcmp(opcode, "link") == 0){ if(sscanf(op_data, fi, tmp, &imm) == 2) { return link(0,0,imm); } } if(strcmp(opcode, "movlr") == 0){ return movlr(0,0,0,0); } if(strcmp(opcode, "btmplr") == 0){ return btmplr(0,0,0,0); } /* if(strcmp(opcode, "padd") == 0){ if(sscanf(op_data, fgg, tmp, &rd, &rt) == 3) { return padd(0,rt,d,0); } } */ return -1; }