x86.c
来自「基于4个mips核的noc设计」· C语言 代码 · 共 2,433 行 · 第 1/5 页
C
2,433 行
77,};static short _decode_mrc3[] = { 0, 78, 79,};static short _decode_con5[] = { 0, 131,};static short _decode_memf[] = { 0, 169, 170, 171,};static short _decode_flt[] = { 0, 180, 181,};static short _decode_addrj[] = { 0, 196, 197, 198,};static short _decode_cmpf[] = { 0, 223, 224,};static int _rule(void *state, int goalnt) { if (goalnt < 1 || goalnt > 21) fatal("_rule", "Bad goal nonterminal %d\n", goalnt); if (!state) return 0; switch (goalnt) { case _stmt_NT: return _decode_stmt[((struct _state *)state)->rule._stmt]; case _reg_NT: return _decode_reg[((struct _state *)state)->rule._reg]; case _con_NT: return _decode_con[((struct _state *)state)->rule._con]; case _acon_NT: return _decode_acon[((struct _state *)state)->rule._acon]; case _base_NT: return _decode_base[((struct _state *)state)->rule._base]; case _index_NT: return _decode_index[((struct _state *)state)->rule._index]; case _con1_NT: return _decode_con1[((struct _state *)state)->rule._con1]; case _con2_NT: return _decode_con2[((struct _state *)state)->rule._con2]; case _con3_NT: return _decode_con3[((struct _state *)state)->rule._con3]; case _addr_NT: return _decode_addr[((struct _state *)state)->rule._addr]; case _mem_NT: return _decode_mem[((struct _state *)state)->rule._mem]; case _rc_NT: return _decode_rc[((struct _state *)state)->rule._rc]; case _mr_NT: return _decode_mr[((struct _state *)state)->rule._mr]; case _mrc0_NT: return _decode_mrc0[((struct _state *)state)->rule._mrc0]; case _mrc1_NT: return _decode_mrc1[((struct _state *)state)->rule._mrc1]; case _mrc3_NT: return _decode_mrc3[((struct _state *)state)->rule._mrc3]; case _con5_NT: return _decode_con5[((struct _state *)state)->rule._con5]; case _memf_NT: return _decode_memf[((struct _state *)state)->rule._memf]; case _flt_NT: return _decode_flt[((struct _state *)state)->rule._flt]; case _addrj_NT: return _decode_addrj[((struct _state *)state)->rule._addrj]; case _cmpf_NT: return _decode_cmpf[((struct _state *)state)->rule._cmpf]; default: fatal("_rule", "Bad goal nonterminal %d\n", goalnt); return 0; }}static void _closure_reg(NODEPTR_TYPE, int);static void _closure_con(NODEPTR_TYPE, int);static void _closure_base(NODEPTR_TYPE, int);static void _closure_index(NODEPTR_TYPE, int);static void _closure_addr(NODEPTR_TYPE, int);static void _closure_mem(NODEPTR_TYPE, int);static void _closure_rc(NODEPTR_TYPE, int);static void _closure_mrc0(NODEPTR_TYPE, int);static void _closure_memf(NODEPTR_TYPE, int);static void _closure_reg(NODEPTR_TYPE a, int c) { struct _state *p = STATE_LABEL(a); if (c + 0 < p->cost[_cmpf_NT]) { p->cost[_cmpf_NT] = c + 0; p->rule._cmpf = 2; } if (c + 2 < p->cost[_addrj_NT]) { p->cost[_addrj_NT] = c + 2; p->rule._addrj = 2; } if (c + 0 < p->cost[_flt_NT]) { p->cost[_flt_NT] = c + 0; p->rule._flt = 2; } if (c + 0 < p->cost[_mr_NT]) { p->cost[_mr_NT] = c + 0; p->rule._mr = 1; } if (c + 0 < p->cost[_rc_NT]) { p->cost[_rc_NT] = c + 0; p->rule._rc = 1; _closure_rc(a, c + 0); } if (c + 0 < p->cost[_index_NT]) { p->cost[_index_NT] = c + 0; p->rule._index = 1; _closure_index(a, c + 0); } if (c + 0 < p->cost[_base_NT]) { p->cost[_base_NT] = c + 0; p->rule._base = 2; _closure_base(a, c + 0); } if (c + 0 < p->cost[_stmt_NT]) { p->cost[_stmt_NT] = c + 0; p->rule._stmt = 13; }}static void _closure_con(NODEPTR_TYPE a, int c) { struct _state *p = STATE_LABEL(a); if (c + 0 < p->cost[_rc_NT]) { p->cost[_rc_NT] = c + 0; p->rule._rc = 2; _closure_rc(a, c + 0); } if (c + 0 < p->cost[_acon_NT]) { p->cost[_acon_NT] = c + 0; p->rule._acon = 2; }}static void _closure_base(NODEPTR_TYPE a, int c) { struct _state *p = STATE_LABEL(a); if (c + 0 < p->cost[_addr_NT]) { p->cost[_addr_NT] = c + 0; p->rule._addr = 1; _closure_addr(a, c + 0); }}static void _closure_index(NODEPTR_TYPE a, int c) { struct _state *p = STATE_LABEL(a); if (c + 0 < p->cost[_addr_NT]) { p->cost[_addr_NT] = c + 0; p->rule._addr = 5; _closure_addr(a, c + 0); }}static void _closure_addr(NODEPTR_TYPE a, int c) { struct _state *p = STATE_LABEL(a); if (c + 1 < p->cost[_reg_NT]) { p->cost[_reg_NT] = c + 1; p->rule._reg = 13; _closure_reg(a, c + 1); }}static void _closure_mem(NODEPTR_TYPE a, int c) { struct _state *p = STATE_LABEL(a); if (c + 2 < p->cost[_addrj_NT]) { p->cost[_addrj_NT] = c + 2; p->rule._addrj = 3; } if (c + 3 < p->cost[_mrc3_NT]) { p->cost[_mrc3_NT] = c + 3; p->rule._mrc3 = 1; } if (c + 1 < p->cost[_mrc1_NT]) { p->cost[_mrc1_NT] = c + 1; p->rule._mrc1 = 1; } if (c + 0 < p->cost[_mrc0_NT]) { p->cost[_mrc0_NT] = c + 0; p->rule._mrc0 = 1; _closure_mrc0(a, c + 0); } if (c + 0 < p->cost[_mr_NT]) { p->cost[_mr_NT] = c + 0; p->rule._mr = 2; }}static void _closure_rc(NODEPTR_TYPE a, int c) { struct _state *p = STATE_LABEL(a); if (c + 0 < p->cost[_mrc3_NT]) { p->cost[_mrc3_NT] = c + 0; p->rule._mrc3 = 2; } if (c + 0 < p->cost[_mrc1_NT]) { p->cost[_mrc1_NT] = c + 0; p->rule._mrc1 = 2; } if (c + 0 < p->cost[_mrc0_NT]) { p->cost[_mrc0_NT] = c + 0; p->rule._mrc0 = 2; _closure_mrc0(a, c + 0); }}static void _closure_mrc0(NODEPTR_TYPE a, int c) { struct _state *p = STATE_LABEL(a); if (c + 1 < p->cost[_reg_NT]) { p->cost[_reg_NT] = c + 1; p->rule._reg = 14; _closure_reg(a, c + 1); }}static void _closure_memf(NODEPTR_TYPE a, int c) { struct _state *p = STATE_LABEL(a); if (c + 0 < p->cost[_cmpf_NT]) { p->cost[_cmpf_NT] = c + 0; p->rule._cmpf = 1; } if (c + 0 < p->cost[_flt_NT]) { p->cost[_flt_NT] = c + 0; p->rule._flt = 1; } if (c + 3 < p->cost[_reg_NT]) { p->cost[_reg_NT] = c + 3; p->rule._reg = 66; _closure_reg(a, c + 3); }}static void _label(NODEPTR_TYPE a) { int c; struct _state *p; if (!a) fatal("_label", "Null tree\n", 0); STATE_LABEL(a) = p = allocate(sizeof *p, FUNC); p->rule._stmt = 0; p->cost[1] = p->cost[2] = p->cost[3] = p->cost[4] = p->cost[5] = p->cost[6] = p->cost[7] = p->cost[8] = p->cost[9] = p->cost[10] = p->cost[11] = p->cost[12] = p->cost[13] = p->cost[14] = p->cost[15] = p->cost[16] = p->cost[17] = p->cost[18] = p->cost[19] = p->cost[20] = p->cost[21] = 0x7fff; switch (OP_LABEL(a)) { case 41: /* ARGB */ _label(LEFT_CHILD(a)); if ( /* stmt: ARGB(INDIRB(reg)) */ LEFT_CHILD(a)->op == 73 /* INDIRB */ ) { c = ((struct _state *)(LEFT_CHILD(LEFT_CHILD(a))->x.state))->cost[_reg_NT] + 0; if (c + 0 < p->cost[_stmt_NT]) { p->cost[_stmt_NT] = c + 0; p->rule._stmt = 48; } } break; case 57: /* ASGNB */ _label(LEFT_CHILD(a)); _label(RIGHT_CHILD(a)); if ( /* stmt: ASGNB(reg,INDIRB(reg)) */ RIGHT_CHILD(a)->op == 73 /* INDIRB */ ) { c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_reg_NT] + ((struct _state *)(LEFT_CHILD(RIGHT_CHILD(a))->x.state))->cost[_reg_NT] + 0; if (c + 0 < p->cost[_stmt_NT]) { p->cost[_stmt_NT] = c + 0; p->rule._stmt = 47; } } break; case 73: /* INDIRB */ _label(LEFT_CHILD(a)); break; case 216: /* CALLV */ _label(LEFT_CHILD(a)); /* stmt: CALLV(addrj) */ c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_addrj_NT] + 0; if (c + 0 < p->cost[_stmt_NT]) { p->cost[_stmt_NT] = c + 0; p->rule._stmt = 90; } break; case 217: /* CALLB */ break; case 233: /* LOADB */ break; case 248: /* RETV */ break; case 584: /* JUMPV */ _label(LEFT_CHILD(a)); /* stmt: JUMPV(addrj) */ c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_addrj_NT] + 3; if (c + 0 < p->cost[_stmt_NT]) { p->cost[_stmt_NT] = c + 0; p->rule._stmt = 54; } break; case 600: /* LABELV */ /* stmt: LABELV */ if (0 + 0 < p->cost[_stmt_NT]) { p->cost[_stmt_NT] = 0 + 0; p->rule._stmt = 55; } break; case 711: /* VREGP */ break; case 1045: /* CNSTI1 */ /* con: CNSTI1 */ if (0 + 0 < p->cost[_con_NT]) { p->cost[_con_NT] = 0 + 0; p->rule._con = 1; _closure_con(a, 0 + 0); } break; case 1046: /* CNSTU1 */ /* con: CNSTU1 */ if (0 + 0 < p->cost[_con_NT]) { p->cost[_con_NT] = 0 + 0; p->rule._con = 2; _closure_con(a, 0 + 0); } break; case 1077: /* ASGNI1 */ _label(LEFT_CHILD(a)); _label(RIGHT_CHILD(a)); if ( /* stmt: ASGNI1(VREGP,reg) */ LEFT_CHILD(a)->op == 711 /* VREGP */ ) { c = ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_reg_NT] + 0; if (c + 0 < p->cost[_stmt_NT]) { p->cost[_stmt_NT] = c + 0; p->rule._stmt = 1; } } /* stmt: ASGNI1(addr,rc) */ c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_addr_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_rc_NT] + 1; if (c + 0 < p->cost[_stmt_NT]) { p->cost[_stmt_NT] = c + 0; p->rule._stmt = 37; } break; case 1078: /* ASGNU1 */ _label(LEFT_CHILD(a)); _label(RIGHT_CHILD(a)); if ( /* stmt: ASGNU1(VREGP,reg) */ LEFT_CHILD(a)->op == 711 /* VREGP */ ) { c = ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_reg_NT] + 0; if (c + 0 < p->cost[_stmt_NT]) { p->cost[_stmt_NT] = c + 0; p->rule._stmt = 2; } } /* stmt: ASGNU1(addr,rc) */ c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_addr_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_rc_NT] + 1; if (c + 0 < p->cost[_stmt_NT]) { p->cost[_stmt_NT] = c + 0; p->rule._stmt = 40; } break; case 1093: /* INDIRI1 */ _label(LEFT_CHILD(a)); if ( /* reg: INDIRI1(VREGP) */ LEFT_CHILD(a)->op == 711 /* VREGP */ ) { if (mayrecalc(a)) { struct _state *q = a->syms[RX]->u.t.cse->x.state; if (q->cost[_stmt_NT] == 0) { p->cost[_stmt_NT] = 0; p->rule._stmt = q->rule._stmt; } if (q->cost[_reg_NT] == 0) { p->cost[_reg_NT] = 0; p->rule._reg = q->rule._reg; } if (q->cost[_con_NT] == 0) { p->cost[_con_NT] = 0; p->rule._con = q->rule._con; } if (q->cost[_acon_NT] == 0) { p->cost[_acon_NT] = 0; p->rule._acon = q->rule._acon; } if (q->cost[_base_NT] == 0) { p->cost[_base_NT] = 0; p->rule._base = q->rule._base; } if (q->cost[_index_NT] == 0) { p->cost[_index_NT] = 0; p->rule._index = q->rule._index; } if (q->cost[_con1_NT] == 0) { p->cost[_con1_NT] = 0; p->rule._con1 = q->rule._con1; } if (q->cost[_con2_NT] == 0) { p->cost[_con2_NT] = 0; p->rule._con2 = q->rule._con2; } if (q->cost[_con3_NT] == 0) { p->cost[_con3_NT] = 0; p->rule._con3 = q->rule._con3; } if (q->cost[_addr_NT] == 0) { p->cost[_addr_NT] = 0; p->rule._addr = q->rule._addr; } if (q->cost[_mem_NT] == 0) { p->cost[_mem_NT] = 0; p->rule._mem = q->rule._mem; } if (q->cost[_rc_NT] == 0) { p->cost[_rc_NT] = 0; p->rule._rc = q->rule._rc; } if (q->cost[_mr_NT] == 0) { p->cost[_mr_NT] = 0; p->rule._mr = q->rule._mr; } if (q->cost[_mrc0_NT] == 0) { p->cost[_mrc0_NT] = 0; p->rule._mrc0 = q->rule._mrc0; } if (q->cost[_mrc1_NT] == 0) { p->cost[_mrc1_NT] = 0; p->rule._mrc1 = q->rule._mrc1; } if (q->cost[_mrc3_NT] == 0) { p->cost[_mrc3_NT] = 0; p->rule._mrc3 = q->rule._mrc3; } if (q->cost[_con5_NT] == 0) { p->cost[_con5_NT] = 0; p->rule._con5 = q->rule._con5; } if (q->cost[_memf_NT] == 0) { p->cost[_memf_NT] = 0; p->rule._memf = q->rule._memf; } if (q->cost[_flt_NT] == 0) { p->cost[_flt_NT] = 0; p->rule._flt = q->rule._flt; } if (q->cost[_addrj_NT] == 0) { p->cost[_addrj_NT] = 0; p->rule._addrj = q->rule._addrj; } if (q->cost[_cmpf_NT] == 0) { p->cost[_cmpf_NT] = 0; p->rule._cmpf = q->rule._cmpf; } } c = 0; if (c + 0 < p->cost[_reg_NT]) { p->cost[_reg_NT] = c + 0; p->rule._reg = 1; _closure_reg(a, c + 0); } } /* mem: INDIRI1(addr) */ c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_addr_NT] + 0; if (c + 0 < p->cost[_mem_NT]) { p->cost[_mem_NT] = c + 0; p->rule._mem = 1; _closure_mem(a, c + 0); } break; case 1094: /* INDIRU1 */ _label(LEFT_CHILD(a)); if ( /* reg: INDIRU1(VREGP) */ LEFT_CHILD(a)->op == 711 /* VREGP */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?