예제 #1
0
파일: gen.c 프로젝트: minux/subc
static void genincptr(int *lv, int inc, int pre) {
	int	y, size;

	size = objsize(deref(lv[LVPRIM]), TVARIABLE, 1);
	gentext();
	y = lv[LVSYM];
	commit();
	if (!y && !pre) cgldinc();
	if (!pre) {
		genrval(lv);
		commit();
	}
	if (!y) {
		if (pre)
			if (inc)
				cginc1pi(size);
			else
				cgdec1pi(size);
		else
			if (inc)
				cginc2pi(size);
			else
				cgdec2pi(size);
	}
	else if (CAUTO == Stcls[y]) {
		if (inc)
			cgincpl(Vals[y], size);
		else
			cgdecpl(Vals[y], size);
	}
	else if (CLSTATC == Stcls[y]) {
		if (inc)
			cgincps(Vals[y], size);
		else
			cgdecps(Vals[y], size);
	}
	else {
		if (inc)
			cgincpg(gsym(Names[y]), size);
		else
			cgdecpg(gsym(Names[y]), size);
	}
	if (pre) genrval(lv);
}
예제 #2
0
파일: gen-syn.c 프로젝트: jezze/gaz
static void genincptr(int *lv, int inc, int pre)
{

    int y;
    int size = objsize(deref(lv[LVPRIM]), TVARIABLE, 1);

    gentext();

    y = lv[LVSYM];

    commit();

    if (!y && !pre)
        cgldinc();

    if (!pre)
    {

        rvalue(lv);
        commit();

    }

    if (!y)
    {

        if (pre)
        {

            if (inc)
                cginc1pi(size);
            else
                cgdec1pi(size);

        }

        else
        {

            if (inc)
                cginc2pi(size);
            else
                cgdec2pi(size);

        }

    }

    else if (CAUTO == symbols[y].stcl)
    {

        if (inc)
            cgincpl(symbols[y].value, size);
        else
            cgdecpl(symbols[y].value, size);

    }

    else if (CLSTATC == symbols[y].stcl)
    {

        if (inc)
            cgincps(symbols[y].value, size);
        else
            cgdecps(symbols[y].value, size);

    }

    else
    {

        if (inc)
            cgincpg(gsym(symbols[y].name), size);
        else
            cgdecpg(gsym(symbols[y].name), size);

    }

    if (pre)
        rvalue(lv);

}
예제 #3
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); } */
void cgincpg(char *s, int v)	{ sgen("%s(r3, %s);", "ld_rd_u", s); ngen("%s(r3,%d);", "addi", v); sgen("%s(r3, %s);", "st_rd_u", s); } /* sgen2("%s\t$%d,%s", "addl", v, s); } */
void cgdecpg(char *s, int v)	{ sgen("%s(r3, %s);", "ld_rd_u", s); ngen("%s(r3,%d);", "subi", v); sgen("%s(r3, %s);", "st_rd_u", s); } /* sgen2("%s\t$%d,%s", "subl", v, s); } */

void cginc1iw(void)	{ cginc1pi(1); } /* ngen("%s\t(%%eax);", "incl", 0); } */
void cgdec1iw(void)	{ cgdec1pi(1); } /* ngen("%s\t(%%eax);", "decl", 0); } */
void cginc2iw(void)	{ cginc2pi(1); } /* ngen("%s\t(%%edx);", "incl", 0); } */
void cgdec2iw(void)	{ cgdec2pi(1); } /* ngen("%s\t(%%edx);", "decl", 0); } */
void cginclw(int a)	{ cgincpl(a, 1); } /* ngen("%s\t%d(%%ebp);", "incl", a); } */
void cgdeclw(int a)	{ cgdecpl(a, 1); } /* ngen("%s\t%d(%%ebp);", "decl", a); } */