📄 mips.c
字号:
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
77,
78,
79,
80,
81,
82,
85,
86,
87,
88,
89,
90,
91,
92,
93,
94,
95,
96,
99,
100,
101,
102,
103,
104,
105,
106,
107,
108,
109,
110,
111,
112,
113,
114,
115,
116,
117,
118,
119,
120,
121,
122,
123,
124,
125,
126,
127,
128,
129,
130,
131,
132,
133,
163,
164,
165,
166,
167,
};
static short _decode_con[] = {
0,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
};
static short _decode_acon[] = {
0,
36,
37,
};
static short _decode_addr[] = {
0,
38,
39,
40,
41,
42,
43,
44,
};
static short _decode_rc[] = {
0,
83,
84,
};
static short _decode_rc5[] = {
0,
97,
98,
};
static short _decode_ar[] = {
0,
162,
169,
170,
};
static int _rule(void *state, int goalnt) {
if (goalnt < 1 || goalnt > 8)
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 _addr_NT: return _decode_addr[((struct _state *)state)->rule._addr];
case _rc_NT: return _decode_rc[((struct _state *)state)->rule._rc];
case _rc5_NT: return _decode_rc5[((struct _state *)state)->rule._rc5];
case _ar_NT: return _decode_ar[((struct _state *)state)->rule._ar];
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_acon(NODEPTR_TYPE, int);
static void _closure_addr(NODEPTR_TYPE, int);
static void _closure_reg(NODEPTR_TYPE a, int c) {
struct _state *p = STATE_LABEL(a);
if (c + 0 < p->cost[_ar_NT]) {
p->cost[_ar_NT] = c + 0;
p->rule._ar = 2;
}
if (c + 0 < p->cost[_rc5_NT]) {
p->cost[_rc5_NT] = c + 0;
p->rule._rc5 = 2;
}
if (c + 0 < p->cost[_rc_NT]) {
p->cost[_rc_NT] = c + 0;
p->rule._rc = 2;
}
if (c + 0 < p->cost[_addr_NT]) {
p->cost[_addr_NT] = c + 0;
p->rule._addr = 5;
_closure_addr(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 = 1;
}
if (c + 0 < p->cost[_acon_NT]) {
p->cost[_acon_NT] = c + 0;
p->rule._acon = 1;
_closure_acon(a, c + 0);
}
}
static void _closure_acon(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 = 4;
_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 _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] =
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] + 1;
if (c + 0 < p->cost[_stmt_NT]) {
p->cost[_stmt_NT] = c + 0;
p->rule._stmt = 63;
}
}
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] + 1;
if (c + 0 < p->cost[_stmt_NT]) {
p->cost[_stmt_NT] = c + 0;
p->rule._stmt = 64;
}
}
break;
case 73: /* INDIRB */
_label(LEFT_CHILD(a));
break;
case 216: /* CALLV */
_label(LEFT_CHILD(a));
/* stmt: CALLV(ar) */
c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_ar_NT] + 1;
if (c + 0 < p->cost[_stmt_NT]) {
p->cost[_stmt_NT] = c + 0;
p->rule._stmt = 51;
}
break;
case 217: /* CALLB */
break;
case 233: /* LOADB */
break;
case 248: /* RETV */
_label(LEFT_CHILD(a));
/* stmt: RETV(reg) */
c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_reg_NT] + 1;
if (c + 0 < p->cost[_stmt_NT]) {
p->cost[_stmt_NT] = c + 0;
p->rule._stmt = 57;
}
break;
case 584: /* JUMPV */
_label(LEFT_CHILD(a));
/* stmt: JUMPV(acon) */
c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_acon_NT] + 1;
if (c + 0 < p->cost[_stmt_NT]) {
p->cost[_stmt_NT] = c + 0;
p->rule._stmt = 24;
}
/* stmt: JUMPV(reg) */
c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_reg_NT] + (!pic);
if (c + 0 < p->cost[_stmt_NT]) {
p->cost[_stmt_NT] = c + 0;
p->rule._stmt = 25;
}
/* stmt: JUMPV(reg) */
c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_reg_NT] + (pic);
if (c + 0 < p->cost[_stmt_NT]) {
p->cost[_stmt_NT] = c + 0;
p->rule._stmt = 26;
}
break;
case 600: /* LABELV */
/* stmt: LABELV */
if (0 + 0 < p->cost[_stmt_NT]) {
p->cost[_stmt_NT] = 0 + 0;
p->rule._stmt = 23;
}
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);
}
/* reg: CNSTI1 */
c = (range(a, 0, 0));
if (c + 0 < p->cost[_reg_NT]) {
p->cost[_reg_NT] = c + 0;
p->rule._reg = 14;
_closure_reg(a, c + 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);
}
/* reg: CNSTU1 */
c = (range(a, 0, 0));
if (c + 0 < p->cost[_reg_NT]) {
p->cost[_reg_NT] = c + 0;
p->rule._reg = 17;
_closure_reg(a, c + 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,reg) */
c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_addr_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_reg_NT] + 1;
if (c + 0 < p->cost[_stmt_NT]) {
p->cost[_stmt_NT] = c + 0;
p->rule._stmt = 14;
}
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,reg) */
c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_addr_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_reg_NT] + 1;
if (c + 0 < p->cost[_stmt_NT]) {
p->cost[_stmt_NT] = c + 0;
p->rule._stmt = 15;
}
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[_addr_NT] == 0) {
p->cost[_addr_NT] = 0;
p->rule._addr = q->rule._addr;
}
if (q->cost[_rc_NT] == 0) {
p->cost[_rc_NT] = 0;
p->rule._rc = q->rule._rc;
}
if (q->cost[_rc5_NT] == 0) {
p->cost[_rc5_NT] = 0;
p->rule._rc5 = q->rule._rc5;
}
if (q->cost[_ar_NT] == 0) {
p->cost[_ar_NT] = 0;
p->rule._ar = q->rule._ar;
}
}
c = 0;
if (c + 0 < p->cost[_reg_NT]) {
p->cost[_reg_NT] = c + 0;
p->rule._reg = 1;
_closure_reg(a, c + 0);
}
}
/* reg: INDIRI1(addr) */
c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_addr_NT] + 1;
if (c + 0 < p->cost[_reg_NT]) {
p->cost[_reg_NT] = c + 0;
p->rule._reg = 21;
_closure_reg(a, c + 0);
}
break;
case 1094: /* INDIRU1 */
_label(LEFT_CHILD(a));
if ( /* reg: INDIRU1(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[_addr_NT] == 0) {
p->cost[_addr_NT] = 0;
p->rule._addr = q->rule._addr;
}
if (q->cost[_rc_NT] == 0) {
p->cost[_rc_NT] = 0;
p->rule._rc = q->rule._rc;
}
if (q->cost[_rc5_NT] == 0) {
p->cost[_rc5_NT] = 0;
p->rule._rc5 = q->rule._rc5;
}
if (q->cost[_ar_NT] == 0) {
p->cost[_ar_NT] = 0;
p->rule._ar = q->rule._ar;
}
}
c = 0;
if (c + 0 < p->cost[_reg_NT]) {
p->cost[_reg_NT] = c + 0;
p->rule._reg = 2;
_closure_reg(a, c + 0);
}
}
/* reg: INDIRU1(addr) */
c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_addr_NT] + 1;
if (c + 0 < p->cost[_reg_NT]) {
p->cost[_reg_NT] = c + 0;
p->rule._reg = 22;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -