dagcheck.c

来自「基于4个mips核的noc设计」· C语言 代码 · 共 2,087 行 · 第 1/4 页

C
2,087
字号
			p->rule._U = 14;			_closure_U(a, c + 0);		}		break;	case 421: /* BORI */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* I: BORI(I,I) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_I_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_I_NT] + 0;		if (c + 0 < p->cost[_I_NT]) {			p->cost[_I_NT] = c + 0;			p->rule._I = 16;			_closure_I(a, c + 0);		}		break;	case 422: /* BORU */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* U: BORU(U,U) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_U_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_U_NT] + 0;		if (c + 0 < p->cost[_U_NT]) {			p->cost[_U_NT] = c + 0;			p->rule._U = 15;			_closure_U(a, c + 0);		}		break;	case 437: /* BXORI */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* I: BXORI(I,I) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_I_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_I_NT] + 0;		if (c + 0 < p->cost[_I_NT]) {			p->cost[_I_NT] = c + 0;			p->rule._I = 17;			_closure_I(a, c + 0);		}		break;	case 438: /* BXORU */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* U: BXORU(U,U) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_U_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_U_NT] + 0;		if (c + 0 < p->cost[_U_NT]) {			p->cost[_U_NT] = c + 0;			p->rule._U = 16;			_closure_U(a, c + 0);		}		break;	case 449: /* DIVF */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* F: DIVF(F,F) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_F_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_F_NT] + 0;		if (c + 0 < p->cost[_F_NT]) {			p->cost[_F_NT] = c + 0;			p->rule._F = 10;			_closure_F(a, c + 0);		}		break;	case 453: /* DIVI */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* I: DIVI(I,I) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_I_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_I_NT] + 0;		if (c + 0 < p->cost[_I_NT]) {			p->cost[_I_NT] = c + 0;			p->rule._I = 18;			_closure_I(a, c + 0);		}		break;	case 454: /* DIVU */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* U: DIVU(U,U) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_U_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_U_NT] + 0;		if (c + 0 < p->cost[_U_NT]) {			p->cost[_U_NT] = c + 0;			p->rule._U = 17;			_closure_U(a, c + 0);		}		break;	case 465: /* MULF */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* F: MULF(F,F) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_F_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_F_NT] + 0;		if (c + 0 < p->cost[_F_NT]) {			p->cost[_F_NT] = c + 0;			p->rule._F = 11;			_closure_F(a, c + 0);		}		break;	case 469: /* MULI */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* I: MULI(I,I) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_I_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_I_NT] + 0;		if (c + 0 < p->cost[_I_NT]) {			p->cost[_I_NT] = c + 0;			p->rule._I = 19;			_closure_I(a, c + 0);		}		break;	case 470: /* MULU */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* U: MULU(U,U) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_U_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_U_NT] + 0;		if (c + 0 < p->cost[_U_NT]) {			p->cost[_U_NT] = c + 0;			p->rule._U = 18;			_closure_U(a, c + 0);		}		break;	case 481: /* EQF */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: EQF(F,F) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_F_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_F_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 19;			_closure_V(a, c + 0);		}		break;	case 485: /* EQI */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: EQI(I,I) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_I_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_I_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 20;			_closure_V(a, c + 0);		}		break;	case 486: /* EQU */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: EQU(U,U) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_U_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_U_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 21;			_closure_V(a, c + 0);		}		break;	case 497: /* GEF */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: GEF(F,F) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_F_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_F_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 22;			_closure_V(a, c + 0);		}		break;	case 501: /* GEI */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: GEI(I,I) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_I_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_I_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 23;			_closure_V(a, c + 0);		}		break;	case 502: /* GEU */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: GEU(U,U) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_U_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_U_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 24;			_closure_V(a, c + 0);		}		break;	case 513: /* GTF */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: GTF(F,F) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_F_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_F_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 25;			_closure_V(a, c + 0);		}		break;	case 517: /* GTI */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: GTI(I,I) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_I_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_I_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 26;			_closure_V(a, c + 0);		}		break;	case 518: /* GTU */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: GTU(U,U) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_U_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_U_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 27;			_closure_V(a, c + 0);		}		break;	case 529: /* LEF */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: LEF(F,F) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_F_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_F_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 28;			_closure_V(a, c + 0);		}		break;	case 533: /* LEI */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: LEI(I,I) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_I_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_I_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 29;			_closure_V(a, c + 0);		}		break;	case 534: /* LEU */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: LEU(U,U) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_U_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_U_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 30;			_closure_V(a, c + 0);		}		break;	case 545: /* LTF */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: LTF(F,F) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_F_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_F_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 31;			_closure_V(a, c + 0);		}		break;	case 549: /* LTI */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: LTI(I,I) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_I_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_I_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 32;			_closure_V(a, c + 0);		}		break;	case 550: /* LTU */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: LTU(U,U) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_U_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_U_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 33;			_closure_V(a, c + 0);		}		break;	case 561: /* NEF */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: NEF(F,F) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_F_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_F_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 34;			_closure_V(a, c + 0);		}		break;	case 565: /* NEI */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: NEI(I,I) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_I_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_I_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 35;			_closure_V(a, c + 0);		}		break;	case 566: /* NEU */		_label(LEFT_CHILD(a));		_label(RIGHT_CHILD(a));		/* V: NEU(U,U) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_U_NT] + ((struct _state *)(RIGHT_CHILD(a)->x.state))->cost[_U_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 36;			_closure_V(a, c + 0);		}		break;	case 584: /* JUMPV */		_label(LEFT_CHILD(a));		/* V: JUMPV(P) */		c = ((struct _state *)(LEFT_CHILD(a)->x.state))->cost[_P_NT] + 0;		if (c + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = c + 0;			p->rule._V = 37;			_closure_V(a, c + 0);		}		break;	case 600: /* LABELV */		/* V: LABELV */		if (0 + 0 < p->cost[_V_NT]) {			p->cost[_V_NT] = 0 + 0;			p->rule._V = 38;			_closure_V(a, 0 + 0);		}		break;	default:		fatal("_label", "Bad terminal %d\n", OP_LABEL(a));	}}static void _kids(NODEPTR_TYPE p, int eruleno, NODEPTR_TYPE kids[]) {	if (!p)		fatal("_kids", "Null tree\n", 0);	if (!kids)		fatal("_kids", "Null kids\n", 0);	switch (eruleno) {	case 118: /* V: JUMPV(P) */	case 89: /* I: BCOMI(I) */	case 88: /* U: BCOMU(U) */	case 63: /* V: RETP(P) */	case 62: /* V: RETU(U) */	case 61: /* V: RETI(I) */	case 60: /* V: RETF(F) */	case 59: /* V: CALLV(P) */	case 58: /* P: CALLP(P) */	case 57: /* U: CALLU(P) */	case 56: /* I: CALLI(P) */	case 55: /* F: CALLF(P) */	case 53: /* I: NEGI(I) */	case 52: /* F: NEGF(F) */	case 51: /* P: CVPP(P) */	case 50: /* P: CVUP(U) */	case 49: /* F: CVFF(F) */	case 48: /* F: CVIF(I) */	case 47: /* U: CVPU(P) */	case 46: /* U: CVUU(U) */	case 45: /* U: CVIU(I) */	case 44: /* I: CVFI(F) */	case 43: /* I: CVUI(U) */	case 42: /* I: CVII(I) */	case 41: /* P: INDIRP(P) */	case 40: /* U: INDIRU(P) */	case 39: /* I: INDIRI(P) */	case 38: /* F: INDIRF(P) */	case 37: /* B: INDIRB(P) */	case 31: /* V: ARGP(P) */	case 30: /* V: ARGU(U) */	case 29: /* V: ARGI(I) */	case 28: /* V: ARGF(F) */	case 27: /* V: ARGB(B) */	case 9: /* stmt: CALLP(P) */	case 8: /* stmt: CALLU(P) */	case 7: /* stmt: CALLI(P) */	case 6: /* stmt: CALLF(P) */	case 5: /* stmt: INDIRP(P) */	case 4: /* stmt: INDIRU(P) */	case 3: /* stmt: INDIRI(P) */	case 2: /* stmt: INDIRF(P) */	case 1: /* stmt: INDIRB(P) */		kids[0] = LEFT_CHILD(p);		break;	case 22: /* V: bogus */	case 21: /* B: bogus */	case 20: /* F: bogus */	case 19: /* P: bogus */	case 18: /* U: bogus */	case 17: /* I: bogus */	case 16: /* bogus: V */	case 15: /* bogus: B */	case 14: /* bogus: F */	case 13: /* bogus: P */	case 12: /* bogus: U */	case 11: /* bogus: I */	case 10: /* stmt: V */		kids[0] = p;		break;	case 119: /* V: LABELV */	case 67: /* P: ADDRLP */	case 66: /* P: ADDRFP */	case 65: /* P: ADDRGP */	case 64: /* V: RETV */	case 26: /* U: CNSTU */	case 25: /* P: CNSTP */	case 24: /* I: CNSTI */	case 23: /* F: CNSTF */		break;	case 117: /* V: NEU(U,U) */	case 116: /* V: NEI(I,I) */	case 115: /* V: NEF(F,F) */	case 114: /* V: LTU(U,U) */	case 113: /* V: LTI(I,I) */	case 112: /* V: LTF(F,F) */	case 111: /* V: LEU(U,U) */	case 110: /* V: LEI(I,I) */	case 109: /* V: LEF(F,F) */	case 108: /* V: GTU(U,U) */	case 107: /* V: GTI(I,I) */	case 106: /* V: GTF(F,F) */	case 105: /* V: GEU(U,U) */	case 104: /* V: GEI(I,I) */	case 103: /* V: GEF(F,F) */	case 102: /* V: EQU(U,U) */	case 101: /* V: EQI(I,I) */	case 100: /* V: EQF(F,F) */	case 99: /* U: MULU(U,U) */	case 98: /* I: MULI(I,I) */	case 97: /* F: MULF(F,F) */	case 96: /* U: DIVU(U,U) */	case 95: /* I: DIVI(I,I) */	case 94: /* F: DIVF(F,F) */	case 93: /* I: BXORI(I,I) */	case 92: /* U: BXORU(U,U) */	case 91: /* U: BORU(U,U) */	case 90: /* I: BORI(I,I) */	case 87: /* I: BANDI(I,I) */	case 86: /* U: BANDU(U,U) */	case 85: /* U: RSHU(U,I) */	case 84: /* I: RSHI(I,I) */	case 83: /* U: MODU(U,U) */	case 82: /* I: MODI(I,I) */	case 81: /* U: LSHU(U,I) */	case 80: /* I: LSHI(I,I) */	case 79: /* U: SUBU(U,U) */	case 78: /* P: SUBP(P,U) */	case 77: /* P: SUBP(P,I) */	case 76: /* I: SUBI(I,I) */	case 75: /* F: SUBF(F,F) */	case 74: /* U: ADDU(U,U) */	case 73: /* P: ADDP(P,U) */	case 72: /* P: ADDP(U,P) */	case 71: /* P: ADDP(I,P) */	case 70: /* P: ADDP(P,I) */	case 69: /* I: ADDI(I,I) */	case 68: /* F: ADDF(F,F) */	case 54: /* V: CALLB(P,P) */	case 36: /* V: ASGNP(P,P) */	case 35: /* V: ASGNU(P,U) */	case 34: /* V: ASGNI(P,I) */	case 33: /* V: ASGNF(P,F) */	case 32: /* V: ASGNB(P,B) */		kids[0] = LEFT_CHILD(p);		kids[1] = RIGHT_CHILD(p);		break;	default:		fatal("_kids", "Bad rule number %d\n", eruleno);	}}static void reduce(NODEPTR_TYPE p, int goalnt) {	int i, sz = opsize(p->op), rulenumber = _rule(p->x.state, goalnt);	short *nts = _nts[rulenumber];	NODEPTR_TYPE kids[10];	assert(rulenumber);	_kids(p, rulenumber, kids);	for (i = 0; nts[i]; i++)		reduce(kids[i], nts[i]);	switch (optype(p->op)) {#define xx(ty) if (sz == ty->size) return	case I:	case U:		xx(chartype);		xx(shorttype);		xx(inttype);		xx(longtype);		xx(longlong);		break;	case F:		xx(floattype);		xx(doubletype);		xx(longdouble);		break;	case P:		xx(voidptype);		xx(funcptype);		break;	case V:	case B: if (sz == 0) return;#undef xx	}	printdag(p, 2);	assert(0);}void check(Node p) {	struct _state { short cost[1]; };	_label(p);	if (((struct _state *)p->x.state)->cost[1] > 0) {		printdag(p, 2);		assert(0);	}	reduce(p, 1);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?