void myp2tree(NODE *p) { struct symtab *sp; if (p->n_op != FCON) return; /* Write float constants to memory */ sp = IALLOC(sizeof(struct symtab)); sp->sclass = STATIC; sp->sap = 0; sp->slevel = 1; /* fake numeric label */ sp->soffset = getlab(); sp->sflags = 0; sp->stype = p->n_type; sp->squal = (CON >> TSHIFT); defloc(sp); ninval(0, tsize(sp->stype, sp->sdf, sp->sap), p); p->n_op = NAME; p->n_lval = 0; p->n_sp = sp; }
void myp2tree(NODE *p) { struct symtab *sp; int o = p->n_op; if (o != FCON) return; sp = inlalloc(sizeof(struct symtab)); sp->sclass = STATIC; sp->ssue = 0; sp->slevel = 1; /* fake numeric label */ sp->soffset = getlab(); sp->sflags = 0; sp->stype = p->n_type; sp->squal = (CON >> TSHIFT); defloc(sp); ninval(0, sp->ssue->suesize, p); p->n_op = NAME; p->n_lval = 0; p->n_sp = sp; }
void myp2tree(NODE *p) { struct symtab *sp, sps; static int dblxor, fltxor; if (p->n_op == UMINUS && (p->n_type == FLOAT || p->n_type == DOUBLE)) { /* Store xor code for sign change */ if (dblxor == 0) { dblxor = getlab(); fltxor = getlab(); sps.stype = LDOUBLE; sps.squal = CON >> TSHIFT; sps.sflags = sps.sclass = 0; sps.sname = sps.soname = ""; sps.slevel = 1; sps.sap = NULL; sps.soffset = dblxor; locctr(DATA, &sps); defloc(&sps); printf("\t.long 0,0x80000000,0,0\n"); printf(LABFMT ":\n", fltxor); printf("\t.long 0x80000000,0,0,0\n"); } p->n_label = p->n_type == FLOAT ? fltxor : dblxor; return; }
void myp2tree(NODE *p) { struct symtab *sp; NODE *l, *r; int o = p->n_op; switch (o) { case NAME: /* reading from a name must be done with a subroutine */ if (p->n_type != CHAR && p->n_type != UCHAR) break; l = buildtree(ADDROF, ccopy(p), NIL); r = block(NAME, NIL, NIL, INT, 0, 0); r->n_sp = lookup(addname("__nova_rbyte"), SNORMAL); if (r->n_sp->sclass == SNULL) { r->n_sp->sclass = EXTERN; r->n_sp->stype = INCREF(p->n_type)+(FTN-PTR); } r->n_type = r->n_sp->stype; r = clocal(r); r = optim(buildtree(CALL, r, l)); *p = *r; nfree(r); break; case FCON: sp = tmpalloc(sizeof(struct symtab)); sp->sclass = STATIC; sp->sap = 0; sp->slevel = 1; /* fake numeric label */ sp->soffset = getlab(); sp->sflags = 0; sp->stype = p->n_type; sp->squal = (CON >> TSHIFT); defloc(sp); ninval(0, tsize(sp->stype, sp->sdf, sp->sap), p); p->n_op = NAME; p->n_lval = 0; p->n_sp = sp; } }
void myp2tree(NODE *p) { struct symtab *sp; NODE *l; if (cdope(p->n_op) & CALLFLG) { if (p->n_left->n_op == ADDROF && p->n_left->n_left->n_op == NAME) { p->n_left = nfree(p->n_left); l = p->n_left; l->n_op = ICON; if (l->n_sp->sclass != STATIC && l->n_sp->sclass != USTATIC) l->n_sp = picsymtab(l->n_sp->sname, "@PLTPC", ""); } } if (p->n_op != FCON) return; sp = IALLOC(sizeof(struct symtab)); sp->sclass = STATIC; sp->sap = 0; sp->slevel = 1; /* fake numeric label */ sp->soffset = getlab(); sp->sflags = 0; sp->stype = p->n_type; sp->squal = (CON >> TSHIFT); sp->sname = NULL; locctr(DATA, sp); defloc(sp); ninval(0, tsize(sp->stype, sp->sdf, sp->sap), p); p->n_op = NAME; slval(p, 0); p->n_sp = sp; }
void myp2tree(NODE *p) { struct attr *ap; struct symtab *sp, sps; static int dblxor, fltxor; int codeatyp(NODE *); if (p->n_op == STCALL || p->n_op == USTCALL) { /* save struct encoding */ p->n_ap = attr_add(p->n_ap, ap = attr_new(ATTR_AMD64_CMPLRET, 1)); ap->iarg(0) = codeatyp(p); } if (p->n_op == UMINUS && (p->n_type == FLOAT || p->n_type == DOUBLE)) { /* Store xor code for sign change */ if (dblxor == 0) { dblxor = getlab(); fltxor = getlab(); sps.stype = LDOUBLE; sps.squal = CON >> TSHIFT; sps.sflags = sps.sclass = 0; sps.sname = ""; sps.slevel = 1; sps.sap = NULL; sps.soffset = dblxor; locctr(DATA, &sps); defloc(&sps); printf("\t.long 0,0x80000000,0,0\n"); printf(LABFMT ":\n", fltxor); printf("\t.long 0x80000000,0,0,0\n"); } p->n_ap = attr_add(p->n_ap, ap = attr_new(ATTR_AMD64_XORLBL, 1)); ap->iarg(0) = p->n_type == FLOAT ? fltxor : dblxor; return; }
/* * Print out a string of characters. * Assume that the assembler understands C-style escape * sequences. */ void instring(struct symtab *sp) { char *s, *str; defloc(sp); str = sp->sname; /* be kind to assemblers and avoid long strings */ printf("\t.ascii \""); for (s = str; *s != 0; ) { if (*s++ == '\\') { (void)esccon(&s); } if (s - str > 60) { fwrite(str, 1, s - str, stdout); printf("\"\n\t.ascii \""); str = s; } } fwrite(str, 1, s - str, stdout); printf("\\0\"\n"); }
/* * special handling before tree is written out. */ void myp2tree(NODE *p) { struct symtab *sp; union dimfun *df; union arglist *al; NODE *q; int i; switch (p->n_op) { case MOD: case DIV: if (p->n_type == LONG || p->n_type == ULONG) { /* Swap arguments for hardops() later */ q = p->n_left; p->n_left = p->n_right; p->n_right = q; } break; case CALL: case STCALL: /* * inform pass2 about varargs. * store first variadic argument number in n_stalign * in the CM node. */ if (p->n_right->n_op != CM) break; /* nothing to care about */ df = p->n_left->n_df; if (df && (al = df->dfun)) { for (i = 0; i < 6; i++, al++) { if (al->type == TELLIPSIS || al->type == TNULL) break; } p->n_right->n_stalign = al->type == TELLIPSIS ? i : 0; } else p->n_right->n_stalign = 0; break; case FCON: /* Write float constants to memory */ sp = inlalloc(sizeof(struct symtab)); sp->sclass = STATIC; sp->ssue = 0; sp->slevel = 1; /* fake numeric label */ sp->soffset = getlab(); sp->sflags = 0; sp->stype = p->n_type; sp->squal = (CON >> TSHIFT); defloc(sp); ninval(0, sp->ssue->suesize, p); p->n_op = NAME; p->n_lval = 0; p->n_sp = sp; break; } }