Esempio n. 1
0
File: cg-syn.c Progetto: jezze/gaz
void cgbrcond(char *i, int n)
{

    int lab = label();

    if (empty == Q_type)
    {

        cgpop2();
        gen("cmpl\t%eax,%ecx");

    }

    else
    {

        cgsynth("cmpl");

    }

    lgen("%s\t%c%d", i, lab);
    lgen("%s\t%c%d", "jmp", n);
    genlab(lab);

}
Esempio n. 2
0
File: cg-syn.c Progetto: jezze/gaz
void cgbr(char *how, int n)
{

    int lab = label();

    gen("orl\t%eax,%eax");
    lgen("%s\t%c%d", how, lab);
    lgen("%s\t%c%d", "jmp", n);
    genlab(lab);

}
Esempio n. 3
0
void
seltblgen(Node *n, int tbl, int *ends, int *ip)
{
	Node *c, *s, *l, *t;
	if(n->t==NList){
		/* chans are eval'ed from the top, so table is backwards */
		seltblgen(n->r, tbl, ends, ip);
		seltblgen(n->l, tbl, ends, ip);
		return;
	}
	if(n->t!=NCase)
		panic("seltblgen");
	if(n->l->t==NList)
		error("sorry, empty cases not implemented");
	patch(tbl+*ip, (long)(here()-tbl)*WS);
	c=n->l->l;	/* communication */
	s=n->r;		/* statement */
	l=0;
	if(c->o.t=='='){
		l=c->l;	/* lvalue */
		c=c->r;
	}
	if(c->o.t==SND){
		gen(c->r, 1);
		if(isptrtype(etypeoft(c->l)->r))
			emit(Isndptr);
		else
			emit(Isnd);
	}
	c=c->l;	/* channel expression */
	/*
	 * The value is still on the stack; save it or toss it
	 */
	if(l)
		lgen(l);
	else if(c->t==NArraycom){
		t=etypeoft(c->l)->r;
		if(t->o.t==TID)
			t=typeoftid(t);
		popgen(t->r);
	}else
		popgen(etypeoft(c)->r);
	if(c->t==NArraycom){	/* save array index */
		if(c->r)
			lgen(c->r);
		else
			emit(Ipop);
	}
	gen(s, 0);
	emit(Ijmp);
	ends[*ip]=here();
	(*ip)++;
	emitconst(0L);
}
Esempio n. 4
0
File: cg-syn.c Progetto: jezze/gaz
void cgcmp(char *inst)
{

    int lab = label();

    gen("xor\tdx,dx");

    if (empty == Q_type)
    {

        cgpop2();
        gen("cmp\tcx,ax");

    }

    else
    {

        cgsynth("cmp");

    }

    lgen("%s\t%c%d", inst, lab);
    gen("inc\tdx");
    genlab(lab);
    gen("mov\tax,dx");

}
Esempio n. 5
0
File: cg-syn.c Progetto: jezze/gaz
void cgcmp(char *inst)
{

    int lab = label();

    gen("xorl\t%edx,%edx");

    if (empty == Q_type)
    {

        cgpop2();
        gen("cmpl\t%eax,%ecx");

    }

    else
    {

        cgsynth("cmpl");

    }

    lgen("%s\t%c%d", inst, lab);
    gen("incl\t%edx");
    genlab(lab);
    gen("movl\t%edx,%eax");

}
Esempio n. 6
0
File: cg-syn.c Progetto: jezze/gaz
void cgincbstat(char *i, int a, int v)
{

    ngen("%s\tcl,%d", "mov", v);
    lgen("%s\t%c%d,cl", i, a);

}
Esempio n. 7
0
File: cg-syn.c Progetto: jezze/gaz
void cgincstat(char *i, int a, int v)
{

    ngen("%s\tcx,%d", "mov", v);
    lgen("%s\t%c%d,cx", i, a);

}
Esempio n. 8
0
void cgcmp(char *inst)	{ int lab;
			  lab = label();
			  gen("xorl\t%edx,%edx");
			  cgpop2();
			  gen("cmpl\t%eax,%ecx");
			  lgen("%s\t%c%d", inst, lab);
			  gen("incl\t%edx");
			  genlab(lab);
			  gen("movl\t%edx,%eax"); }
Esempio n. 9
0
/*
 * 386 -> videocore mapping
 * 
 * eax   r0
 * ecx   r1
 * edx   r2
 * tmp   r3
 * ebp   r23
 * esp   r25
 *
 *  g = global
 *  l = local
 *  s = static
 *
 *  b = byte
 *  w = word
 *  a = address
 *
 */

static int lab_data_skip;

void cgdeclare(int id)  { lgenraw("%s(%c%d);", "declare", id); }
void cglab(int id)      { lgenraw("%s(%c%d);", "label", id); }
void cgname(char *name) { sgenraw("%s(C%s);", "\nlabel", name); }

void cgdata(void)	{ if (lab_data_skip==0) { lab_data_skip = label(); lgen("%s(%c%d);", "b", lab_data_skip); } /*gen(".data;");*/ }
void cgtext(void)	{ if (lab_data_skip) { cglab(lab_data_skip); lab_data_skip=0; } /*gen(".text;");*/ }
void cgprelude(void)	{ }
void cgpostlude(void)	{ }
void cgpublic(char *s)	{ sgenraw("%s(%s);", "\nglobal", s); /*ngen(".globl\t%s", s, 0);*/ }
void cgstatic(char *s)	{ sgenraw("%s(%s);", "\nstatic", s); }


void cglit(int v)	{ ngen("%s(r0, %d);", "movi", v); } /* ngen("%s\t$%d,%%eax", "movl", v); } */
void cgclear(void)	{ ngen("%s(r0, %d);", "movi", 0); } /* gen("xorl\t%eax,%eax;"); } */

void cgldgb(char *s)	{ sgen("%s(r0, %s);", "ldb_rd_u", s); } /* sgen("%s\t%s,%%al", "movb", s); } */
void cgldgw(char *s)	{ sgen("%s(r0, %s);", "ld_rd_u", s); } /* sgen("%s\t%s,%%eax", "movl", s); } */
void cgldlb(int n)	{ ngen("%s(r0, %d, r23);", "ldb_rd_o_rs", n); } /* { ngen("%s\t%d(%%ebp),%%al", "movb", n); } */
void cgldlw(int n)	{ ngen("%s(r0, %d, r23);", "ld_rd_o_rs", n); } /* { ngen("%s\t%d(%%ebp),%%eax", "movl", n); } */
void cgldsb(int n)	{ lgen("%s(r0, %c%d);", "ldb_rd_u", n); } /* lgen("%s\t%c%d,%%al", "movb", n); } */
Esempio n. 10
0
void cgdefl(int v)	{ lgen("%s(%c%d);", "dc", v); /*lgen("%s\t%c%d", ".long", v);*/ }
Esempio n. 11
0
void cgdata(void)	{ if (lab_data_skip==0) { lab_data_skip = label(); lgen("%s(%c%d);", "b", lab_data_skip); } /*gen(".data;");*/ }
Esempio n. 12
0
File: cg-syn.c Progetto: jezze/gaz
void cgincsb(int a)
{

    lgen("%s\t%c%d", "incb", a);

}
Esempio n. 13
0
                                /* { int lab; lab = label(); gen("orl\t%eax,%eax;"); lgen("%s\t%c%d", how, lab); lgen("%s\t%c%d", "jmp", n); genlab(lab); } */
void cgbrtrue(int n)	{ cgbr("beq", n); } /* cgbr("jz", n); } */
void cgbrfalse(int n)	{ cgbr("bne", n); } /* cgbr("jnz", n); } */
void cgjump(int n)	{ lgen("%s(%c%d);", "b", n); } /* lgen("%s\t%c%d", "jmp", n); } */
void cgldswtch(int n)	{ lgen("%s(r2, %c%d);", "movi", n); } /* lgen("%s\t$%c%d,%%edx", "movl", n); } */
void cgcalswtch(void)	{ gen("b(switch);"); } /* gen("jmp\tswitch;"); } */
void cgcase(int v, int l)	{ lgen2("dc(%d); dc(%c%d);", v, l); } /* lgen2(".long\t%d,%c%d", v, l); } */

void cgpopptr(void)	{ gen("ld_rd_rs_inc(r2, r25);"); } /* gen("popl\t%edx;"); } */
void cgstorib(void)	{ ngen("%s(r0, r2);", "stb_rd_rs", 0); } /* ngen("%s\t%%al,(%%edx);", "movb", 0); } */
void cgstoriw(void)	{ ngen("%s(r0, r2);", "st_rd_rs", 0); } /* ngen("%s\t%%eax,(%%edx);", "movl", 0); } */
void cgstorlb(int n)	{ ngen("%s(r0, %d, r23);", "stb_rd_o_rs", n); } /* ngen("%s\t%%al,%d(%%ebp);", "movb", n); } */
void cgstorlw(int n)	{ ngen("%s(r0, %d, r23);", "st_rd_o_rs", n); } /* \t%%eax,%d(%%ebp);", "movl", n); } */
void cgstorsb(int n)	{ lgen("%s(r0, %c%d);", "stb_rd_o_rs", n); } /* lgen("%s\t%%al,%c%d", "movb", n); } */
void cgstorsw(int n)	{ lgen("%s(r0, %c%d);", "st_rd_o_rs", n); } /* lgen("\t%%eax,%c%d", "movl", n); } */
Esempio n. 14
0
void cgldlab(int id)	{ lgen("%s(r0,%c%d);", "lea_rd_u", id); } /* lgen("%s\t$%c%d,%%eax", "movl", id); } */
Esempio n. 15
0
void
gen(Node *n, int retain)
{
	int i;

	if(n==0)
		return;
	switch(n->t){
	case NArrayref:
		arygen(n->l, n->r, 0, 0L);
		if(!retain)
			popgen(n->l->o.s->val->type->r);
		return;
	case NBecome:
		didbecome=1;
		if(n->l->t==NCall && !bflag){
			callgen(n->l, Ibecome);
			return;
		}
		gen(n->l, 1);
		n=n->r;
		if(n->o.t==TID)
			n=typeoftid(n);
		switch(n->o.t){
		case TInt:
		case TChar:
			emit(Istoreauto);
			emitconst(-WS*(4+length(formals)));
			break;
		case TArray:
		case TChan:
		case TProg:
		case TStruct:
			emit(Istoreptrauto);
			emitconst(-WS*(4+length(formals)));
			break;
		case TUnit:
			break;
		default:
			panic("can't compile %t become", n);
		}
		scopedecrefgen();
		trlrgen();
		return;
	case NBegin:
		callgen(n->l, Ibegin);
		return;
	case NBreak:
		if(breakloc==-1)
			lerror(n, "break not in loop");
		if(breakloc)	/* chain previous break to here */
			patch(breakloc, (long)(here()-breakloc-1)*WS);
		emit(Ijmp);
		breakloc=here();
		emitconst(0L);
		return;
	case NCall:
		callgen(n, Icall);
		if(!retain)
			popgen(etypeoft(n->l)->r);
		return;
	case NComplete:
		gen(n->l, retain);
		return;
	case NContinue:
		if(continueloc==-1)
			lerror(n, "continue not in loop");
		if(continueloc)	/* chain previous continue to here */
			patch(continueloc, (long)(here()-continueloc-1)*WS);
		emit(Ijmp);
		continueloc=here();
		emitconst(0L);
		return;
	case NDecl:
	case NDeclsc:
		declare(n, 0, 0, 1);
		return;
	case NExpr:
		switch(n->o.i){
		case GE:
			i=Ige;
		Binop:
			gen(n->l, 1);
			gen(n->r, 1);
			if(eqtype(etypeof(n->l), &arychartype)){
				emit(Istrcmp);
				constgen(0L);
			}
			emit(i);
		Popit:
			if(!retain)
				emit(Ipop);
			return;
		case LE:
			i=Ile;
			goto Binop;
		case NE:
			i=Ine;
			goto Binop;
		case EQ:
			i=Ieq;
			goto Binop;
		case '>':
			i=Igt;
			goto Binop;
		case '<':
			i=Ilt;
			goto Binop;
		case '+':
			i=Iadd;
			goto Binop;
		case '-':
			i=Isub;
			goto Binop;
		case '*':
			i=Imul;
			goto Binop;
		case '/':
			i=Idiv;
			goto Binop;
		case '%':
			i=Imod;
			goto Binop;
		case '&':
			i=Iand;
			goto Binop;
		case '|':
			i=Ior;
			goto Binop;
		case '^':
			i=Ixor;
			goto Binop;
		case LSH:
			i=Ilsh;
			goto Binop;
		case RSH:
			i=Irsh;
			goto Binop;
		case ANDAND:
			condgen(n->l, n->r, Ijmptrue, Ijmpfalse, 0L, 1L, retain);
			return;
		case OROR:
			condgen(n->l, n->r, Ijmpfalse, Ijmptrue, 1L, 0L, retain);
			return;
		case CAT:
			gen(n->l, 1);
			gen(n->r, 1);
			emit(Icat);
			return;
		case DEL:
			gen(n->l, 1);
			gen(n->r, 1);
			emit(Idel);
			return;
		case PRINT:
			gen(n->l, 1);
			printgen(n->l);
			emit(Isprnt);
			if(!retain)
				emit(Iprint);
			return;
		case SND:
			gen(n->l, 1);
			constgen((long)Cissnd);
			emit(Icommset1);
			emit(Icommcln1);
			gen(n->r, 1);
			if(isptrtype(etypeoft(n->l)->r))
				emit(Isndptr);
			else
				emit(Isnd);
			if(!retain)
				popgen(etypeof(n));
			return;
		case RCV:
			gen(n->l, 1);
			constgen(0L);	/* not Cissnd */
			emit(Icommset1);
			emit(Icommcln1);
			if(!retain)
				popgen(etypeof(n));
			return;
		case '=':
			gen(n->r, 1);
			if(retain)
				dupgen(etypeof(n->r), 1);
			lgen(n->l);
			return;
		case LEN:
			gen(n->l, 1);
			emit(Ilen);
			goto Popit;
		case REF:
			if(isptrtype(etypeof(n->l))){
				gen(n->l, 1);
				emit(Iref);
			}else
				constgen(1L);
			goto Popit;
		case DEF:
			if(retain && n->l->t==NID && isinttype(etypeof(n->l))){
				constgen(1L);
				return;
			}
			/*
			 * don't really need to call lgen1, which will uniquify our
			 * array for us, but it does no harm, and it's easy.
			 */
			lgen1(n->l, Idefauto, Idef, Idefary);
			goto Popit;
		case UMINUS:
			gen(n->l, 1);
			emit(Ineg);
			goto Popit;
		case '~':
			gen(n->l, 1);
			emit(Inot);
			goto Popit;
		case '!':
			gen(n->l, 1);
			emit(Ilnot);
			goto Popit;
		case INC:
			lgen1(n->l, Iincauto, Iinc, Iincary);
			goto Popit;
		case DEC:
			lgen1(n->l, Idecauto, Idec, Idecary);
			goto Popit;
		default:
			panic("can't compile %e expression", n);
		}

	case NExprlist:
		/*
		 * This is an arg or element list; first is pushed last
		 */
		gen(n->r, 1);
		gen(n->l, 1);
		return;
	case NID:
		if(!retain)
			return;
		switch(type_of(n)->o.t){
		case TInt:
		case TChar:
			if(n->o.s->val->isauto){
				emit(Ipushauto);
				emitconst(n->o.s->val->store.off);
			}else{
				emit(Ipush);
				emitconst((long)&n->o.s->val->store.l);
			}
			return;
		case TProg:
		case TArray:
		case TChan:
		case TStruct:
			if(n->o.s->val->isauto){
				emit(Ipushptrauto);
				emitconst(n->o.s->val->store.off);
			}else{
				emit(Ipushptr);
				emitconst((long)&n->o.s->val->store.l);
			}
			return;
		case TUnit:
			if(retain)
				constgen(0L);
			return;
		case TType:
			lerror(n, "attempt to evaluate type variable %m", n);
		default:
			panic("can't compile type %t", n->o.s->val->type);
		}
	case NIf:
		ifgen(n);
		return;
	case NList:
		gen(n->l, 0);
		gen(n->r, 0);
		return;
	case NLoop:
		loopgen(n);
		return;
	case NMk:
		mkgen(n->l, n->r);
		return;
	case NNum:
		if(retain)
			constgen(n->o.l);
		return;
	case NProg:
		if(retain)
			proggen(n->l, n->r);
		return;
	case NResult:
		if(resultloc==0)
			lerror(n, "result not in val");
		gen(n->l, 1);
		emit(Ijmp);
		emitconst((long)(resultloc-here()-1)*WS);
		return;
	case NScope:
		pushscope();
		if(nscope==1){
			int nauto;
			autooffset=0;
			emit(Ipushfp);
			nauto=here();
			emitconst(0L);
			gen(n->l, 0);
			patch((int)nauto, autooffset);
			emit(Ipop);	/* Ipopfp() */
		}else
			gen(n->l, 0);
		scopedecrefgen();
		popscope();
		return;
	case NSelect:
		selgen(n->l);
		return;
	case NSmash:{
		Value *vl, *vr;
		vl=n->l->o.s->val;
		vr=n->r->o.s->val;
		if(vr->type->o.t==TType){
			freenode(vl->type);
			vl->type=dupnode(vr->type);
			return;
		}
		gen(n->r, 1);
		/*
		 * Free old values; tricky: push as int, pop as ptr
		 */
		if(isptrtype(vl->type)){
			if(vl->isauto){
				emit(Ipushauto);
				emitconst(vl->store.off);
			}else{
				emit(Ipush);
				emitconst((long)&vl->store.l);
			}
			emit(Ipopptr);
		}
		if(vl->isauto){
			emit(Istoreauto);
			emitconst(vl->store.l);
			return;
		}
		emit(Istore);
		emitconst((long)&vl->store.l);
		return;
	}
	case NString:
		if(retain){
			emit(Ipushdata);
			emitconst((long)n->o.st);
			emitstore(n->o.st);
			n->o.st->ref++;
		}
		return;
	case NStructref:
		arygen(n->l, n->r, 1, n->o.l);
		return;
	case NSwitch:
		switchgen(n->l, n->r);
		return;
	case NUnit:
		if(retain)
			constgen(0L);
		return;
	case NVal:
		valgen(n->l);
		if(!retain)
			popgen(n->o.n);
		return;
	}
	panic("can't compile node %n", n);
	return;
}
Esempio n. 16
0
File: cg-syn.c Progetto: jezze/gaz
void cgdecsw(int a)
{

    lgen("%s\t%c%d", "decl", a);

}
Esempio n. 17
0
void cgbr(char *how, int n)	{ int lab; lab = label(); gen("or(r0, r0);"); lgen("%s(%c%d);", how, lab); lgen("%s(%c%d);", "b", n); genlab(lab); }
Esempio n. 18
0
File: cg-syn.c Progetto: jezze/gaz
void cgstorsw(int n)
{

    lgen("%s\t%%eax,%c%d", "movl", n);

}
Esempio n. 19
0
/* increment/decrement pointer to local, static, global */
void cgincpl(int a, int v)	{ ngen("%s(r3, %d, r23);", "ld_rd_o_rs", a); ngen("%s(r3,%d);", "addi", v); ngen("%s(r3, %d, r23);", "st_rd_o_rs", a); } /* ngen2("%s\t$%d,%d(%%ebp);", "addl", v, a); } */
void cgdecpl(int a, int v)	{ ngen("%s(r3, %d, r23);", "ld_rd_o_rs", a); ngen("%s(r3,%d);", "subi", v); ngen("%s(r3, %d, r23);", "st_rd_o_rs", a); } /* ngen2("%s\t$%d,%d(%%ebp);", "subl", v, a); } */
void cgincps(int a, int v)	{ lgen("%s(r3, %c%d);", "ld_rd_u", a); ngen("%s(r3,%d);", "addi", v); lgen("%s(r3, %c%d);", "st_rd_u", a); } /* lgen2("addl\t$%d,%c%d", v, a); } */
Esempio n. 20
0
File: cg-syn.c Progetto: jezze/gaz
void cgstorsb(int n)
{

    lgen("%s\t%%al,%c%d", "movb", n);

}
Esempio n. 21
0
File: cg-syn.c Progetto: jezze/gaz
void cgldswtch(int n)
{

    lgen("%s\t$%c%d,%%edx", "movl", n);

}
Esempio n. 22
0
File: cg-syn.c Progetto: jezze/gaz
void cgjump(int n)
{

    lgen("%s\t%c%d", "jmp", n);

}
Esempio n. 23
0
/*
 * 386 -> videocore mapping
 * 
 * eax   r0
 * ecx   r1
 * edx   r2
 * tmp   r3
 * ebp   r23
 * esp   r25
 *
 *  g = global
 *  l = local
 *  s = static
 *
 *  b = byte
 *  w = word
 *  a = address
 *
 */

static int lab_data_skip;

void cgdeclare(int id)  { lgenraw("%s(%c%d);", "declare", id); }
void cglab(int id)      { lgenraw("%s(%c%d);", "label", id); }
void cgname(char *name) { sgenraw("%s(C%s);", "\nlabel", name); }

void cgdata(void)	{ if (lab_data_skip==0) { lab_data_skip = label(); lgen("%s(%c%d);", "b", lab_data_skip); } /*gen(".data;");*/ }
void cgtext(void)	{ if (lab_data_skip) { cglab(lab_data_skip); lab_data_skip=0; } /*gen(".text;");*/ }
void cgprelude(void)	{ }
void cgpostlude(void)	{ }
void cgpublic(char *s)	{ sgenraw("%s(%s);", "\nglobal", s); /*ngen(".globl\t%s", s, 0);*/ }
void cgstatic(char *s)	{ sgenraw("%s(%s);", "\nstatic", s); }


void cglit(int v)	{ ngen("%s(r0, %d);", "movi", v); } /* ngen("%s\t$%d,%%eax", "movl", v); } */
void cgclear(void)	{ ngen("%s(r0, %d);", "movi", 0); } /* gen("xorl\t%eax,%eax;"); } */

void cgldgb(char *s)	{ sgen("%s(r0, %s);", "ldb_rd_u", s); } /* sgen("%s\t%s,%%al", "movb", s); } */
void cgldgw(char *s)	{ sgen("%s(r0, %s);", "ld_rd_u", s); } /* sgen("%s\t%s,%%eax", "movl", s); } */
void cgldlb(int n)	{ ngen("%s(r0, %d, r23);", "ldb_rd_o_rs", n); } /* { ngen("%s\t%d(%%ebp),%%al", "movb", n); } */
void cgldlw(int n)	{ ngen("%s(r0, %d, r23);", "ld_rd_o_rs", n); } /* { ngen("%s\t%d(%%ebp),%%eax", "movl", n); } */
void cgldsb(int n)	{ lgen("%s(r0, %c%d);", "ldb_rd_u", n); } /* lgen("%s\t%c%d,%%al", "movb", n); } */
void cgldsw(int n)	{ lgen("%s(r0, %c%d);", "ld_rd_u", n); } /* lgen("%s\t%c%d,%%eax", "movl", n); } */
Esempio n. 24
0
                                /* { int lab; lab = label(); gen("orl\t%eax,%eax;"); lgen("%s\t%c%d", how, lab); lgen("%s\t%c%d", "jmp", n); genlab(lab); } */
void cgbrtrue(int n)	{ cgbr("beq", n); } /* cgbr("jz", n); } */
void cgbrfalse(int n)	{ cgbr("bne", n); } /* cgbr("jnz", n); } */
void cgjump(int n)	{ lgen("%s(%c%d);", "b", n); } /* lgen("%s\t%c%d", "jmp", n); } */
Esempio n. 25
0
/*
 * 386 -> videocore mapping
 * 
 * eax   r0
 * ecx   r1
 * edx   r2
 * tmp   r3
 * ebp   r23
 * esp   r25
 *
 *  g = global
 *  l = local
 *  s = static
 *
 *  b = byte
 *  w = word
 *  a = address
 *
 */

static int lab_data_skip;

void cgdeclare(int id)  { lgenraw("%s(%c%d);", "declare", id); }
void cglab(int id)      { lgenraw("%s(%c%d);", "label", id); }
void cgname(char *name) { sgenraw("%s(C%s);", "\nlabel", name); }

void cgdata(void)	{ if (lab_data_skip==0) { lab_data_skip = label(); lgen("%s(%c%d);", "b", lab_data_skip); } /*gen(".data;");*/ }
void cgtext(void)	{ if (lab_data_skip) { cglab(lab_data_skip); lab_data_skip=0; } /*gen(".text;");*/ }
void cgprelude(void)	{ }
void cgpostlude(void)	{ }
void cgpublic(char *s)	{ sgenraw("%s(%s);", "\nglobal", s); /*ngen(".globl\t%s", s, 0);*/ }
void cgstatic(char *s)	{ sgenraw("%s(%s);", "\nstatic", s); }


void cglit(int v)	{ ngen("%s(r0, %d);", "movi", v); } /* ngen("%s\t$%d,%%eax", "movl", v); } */
void cgclear(void)	{ ngen("%s(r0, %d);", "movi", 0); } /* gen("xorl\t%eax,%eax;"); } */

void cgldgb(char *s)	{ sgen("%s(r0, %s);", "ldb_rd_u", s); } /* sgen("%s\t%s,%%al", "movb", s); } */
void cgldgw(char *s)	{ sgen("%s(r0, %s);", "ld_rd_u", s); } /* sgen("%s\t%s,%%eax", "movl", s); } */
void cgldlb(int n)	{ ngen("%s(r0, %d, r23);", "ldb_rd_o_rs", n); } /* { ngen("%s\t%d(%%ebp),%%al", "movb", n); } */
void cgldlw(int n)	{ ngen("%s(r0, %d, r23);", "ld_rd_o_rs", n); } /* { ngen("%s\t%d(%%ebp),%%eax", "movl", n); } */
void cgldsb(int n)	{ lgen("%s(r0, %c%d);", "ldb_rd_u", n); } /* lgen("%s\t%c%d,%%al", "movb", n); } */
void cgldsw(int n)	{ lgen("%s(r0, %c%d);", "ld_rd_u", n); } /* lgen("%s\t%c%d,%%eax", "movl", n); } */

void cgldla(int n)	{ ngen("%s(r0, %d, r23);", "lea_rd_o_rs", n); } /* ngen("%s\t%d(%%ebp),%%eax", "leal", n); } */
void cgldsa(int n)	{ lgen("%s(r0, %c%d);", "lea_rd_u", n); } /* lgen("%s\t$%c%d,%%eax", "movl", n); } */
Esempio n. 26
0
                                /* { int lab; lab = label(); gen("orl\t%eax,%eax;"); lgen("%s\t%c%d", how, lab); lgen("%s\t%c%d", "jmp", n); genlab(lab); } */
void cgbrtrue(int n)	{ cgbr("beq", n); } /* cgbr("jz", n); } */
void cgbrfalse(int n)	{ cgbr("bne", n); } /* cgbr("jnz", n); } */
void cgjump(int n)	{ lgen("%s(%c%d);", "b", n); } /* lgen("%s\t%c%d", "jmp", n); } */
void cgldswtch(int n)	{ lgen("%s(r2, %c%d);", "movi", n); } /* lgen("%s\t$%c%d,%%edx", "movl", n); } */
Esempio n. 27
0
void cgcmp(char *inst)	{ int lab; lab = label(); gen("movi(r2, 0);"); cgpop2(); gen("cmp(r1, r0);"); lgen("%s(%c%d);", inst, lab); gen("addi(r2, 1);"); genlab(lab); gen("mov(r0, r2);"); }
Esempio n. 28
0
                                /* { int lab; lab = label(); gen("orl\t%eax,%eax;"); lgen("%s\t%c%d", how, lab); lgen("%s\t%c%d", "jmp", n); genlab(lab); } */
void cgbrtrue(int n)	{ cgbr("beq", n); } /* cgbr("jz", n); } */
void cgbrfalse(int n)	{ cgbr("bne", n); } /* cgbr("jnz", n); } */
void cgjump(int n)	{ lgen("%s(%c%d);", "b", n); } /* lgen("%s\t%c%d", "jmp", n); } */
void cgldswtch(int n)	{ lgen("%s(r2, %c%d);", "movi", n); } /* lgen("%s\t$%c%d,%%edx", "movl", n); } */
void cgcalswtch(void)	{ gen("b(switch);"); } /* gen("jmp\tswitch;"); } */
void cgcase(int v, int l)	{ lgen2("dc(%d); dc(%c%d);", v, l); } /* lgen2(".long\t%d,%c%d", v, l); } */

void cgpopptr(void)	{ gen("ld_rd_rs_inc(r2, r25);"); } /* gen("popl\t%edx;"); } */
void cgstorib(void)	{ ngen("%s(r0, r2);", "stb_rd_rs", 0); } /* ngen("%s\t%%al,(%%edx);", "movb", 0); } */
void cgstoriw(void)	{ ngen("%s(r0, r2);", "st_rd_rs", 0); } /* ngen("%s\t%%eax,(%%edx);", "movl", 0); } */
void cgstorlb(int n)	{ ngen("%s(r0, %d, r23);", "stb_rd_o_rs", n); } /* ngen("%s\t%%al,%d(%%ebp);", "movb", n); } */
void cgstorlw(int n)	{ ngen("%s(r0, %d, r23);", "st_rd_o_rs", n); } /* \t%%eax,%d(%%ebp);", "movl", n); } */
void cgstorsb(int n)	{ lgen("%s(r0, %c%d);", "stb_rd_o_rs", n); } /* lgen("%s\t%%al,%c%d", "movb", n); } */
Esempio n. 29
0
/* increment/decrement pointer to local, static, global */
void cgincpl(int a, int v)	{ ngen("%s(r3, %d, r23);", "ld_rd_o_rs", a); ngen("%s(r3,%d);", "addi", v); ngen("%s(r3, %d, r23);", "st_rd_o_rs", a); } /* ngen2("%s\t$%d,%d(%%ebp);", "addl", v, a); } */
void cgdecpl(int a, int v)	{ ngen("%s(r3, %d, r23);", "ld_rd_o_rs", a); ngen("%s(r3,%d);", "subi", v); ngen("%s(r3, %d, r23);", "st_rd_o_rs", a); } /* ngen2("%s\t$%d,%d(%%ebp);", "subl", v, a); } */
void cgincps(int a, int v)	{ lgen("%s(r3, %c%d);", "ld_rd_u", a); ngen("%s(r3,%d);", "addi", v); lgen("%s(r3, %c%d);", "st_rd_u", a); } /* lgen2("addl\t$%d,%c%d", v, a); } */
void cgdecps(int a, int v)	{ lgen("%s(r3, %c%d);", "ld_rd_u", a); ngen("%s(r3,%d);", "subi", v); lgen("%s(r3, %c%d);", "st_rd_u", a); } /* { lgen2("subl\t$%d,%c%d", v, a); } */
Esempio n. 30
0
File: cg-syn.c Progetto: jezze/gaz
void cgdecsb(int a)
{

    lgen("%s\t%c%d", "decb", a);

}