void efcode(void) { TWORD t; NODE *p, *q; /* code for the end of a function */ if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN) return; t = PTR+BTYPE(cftnsp->stype); /* Create struct assignment */ q = tempnode(strtemp, t, 0, cftnsp->sap); q = buildtree(UMUL, q, NIL); p = block(REG, NIL, NIL, t, 0, cftnsp->sap); regno(p) = R0; p = buildtree(UMUL, p, NIL); p = buildtree(ASSIGN, q, p); ecomp(p); /* put hidden arg in r0 on return */ q = tempnode(strtemp, INT, 0, 0); p = block(REG, NIL, NIL, INT, 0, 0); regno(p) = R0; ecomp(buildtree(ASSIGN, p, q)); }
/* * Allocate off bits on the stack. p is a tree that when evaluated * is the multiply count for off, t is a storeable node where to write * the allocated address. */ void spalloc(NODE *t, NODE *p, OFFSZ off) { NODE *sp; p = buildtree(MUL, p, bcon(off/SZCHAR)); p = buildtree(PLUS, p, bcon(30)); p = buildtree(AND, p, xbcon(-16, NULL, UNSIGNED)); p = cast(p, UNSIGNED, 0); /* sub the size from sp */ sp = block(REG, NIL, NIL, UNSIGNED+PTR, 0, 0); slval(sp, 0); sp->n_rval = STKREG; p = (buildtree(MINUSEQ, sp, p)); ecomp(p); /* save the address of sp */ sp = block(REG, NIL, NIL, PTR+UNSIGNED, t->n_df, t->n_ap); slval(sp, 0); sp->n_rval = STKREG; t->n_type = sp->n_type; p = (buildtree(ASSIGN, t, sp)); /* Emit! */ ecomp(p); }
void bfcode(struct symtab **sp, int cnt) { int i, off; NODE *p, *q; struct symtab *sym; /* Process the first six arguments. */ for (i=0; i < cnt && i < 6; i++) { sym = sp[i]; q = block(REG, NIL, NIL, sym->stype, sym->sdf, sym->sap); q->n_rval = RETREG_PRE(sym->stype) + i; p = tempnode(0, sym->stype, sym->sdf, sym->sap); sym->soffset = regno(p); sym->sflags |= STNODE; p = buildtree(ASSIGN, p, q); ecomp(p); } /* Process the remaining arguments. */ for (off = V9RESERVE; i < cnt; i++) { sym = sp[i]; p = tempnode(0, sym->stype, sym->sdf, sym->sap); off = ALIGN(off, (tlen(p) - 1)); sym->soffset = off * SZCHAR; off += tlen(p); p = buildtree(ASSIGN, p, nametree(sym)); sym->soffset = regno(p->n_left); sym->sflags |= STNODE; ecomp(p); } }
/* * Allocate off bits on the stack. p is a tree that when evaluated * is the multiply count for off, t is a NAME node where to write * the allocated address. */ void spalloc(NODE *t, NODE *p, OFFSZ off) { NODE *sp; if ((off % SZINT) == 0) p = buildtree(MUL, p, bcon(off/SZINT)); else if ((off % SZSHORT) == 0) { p = buildtree(MUL, p, bcon(off/SZSHORT)); p = buildtree(PLUS, p, bcon(1)); p = buildtree(RS, p, bcon(1)); } else if ((off % SZCHAR) == 0) { p = buildtree(MUL, p, bcon(off/SZCHAR)); p = buildtree(PLUS, p, bcon(3)); p = buildtree(RS, p, bcon(2)); } else cerror("roundsp"); /* save the address of sp */ sp = block(REG, NIL, NIL, PTR+INT, t->n_df, t->n_sue); sp->n_lval = 0; sp->n_rval = STKREG; t->n_type = sp->n_type; ecomp(buildtree(ASSIGN, t, sp)); /* Emit! */ /* add the size to sp */ sp = block(REG, NIL, NIL, p->n_type, 0, 0); sp->n_lval = 0; sp->n_rval = STKREG; ecomp(buildtree(PLUSEQ, sp, p)); }
void bfcode(struct symtab **sp, int n) { struct symtab *sp2; NODE *p, *q; int i; if (cftnsp->stype == STRTY+FTN || cftnsp->stype == UNIONTY+FTN) { /* Move return address into temporary */ p = tempnode(0, INT, 0, 0); strtemp = regno(p); q = block(REG, 0, 0, INT, 0, 0); regno(q) = R1; ecomp(buildtree(ASSIGN, p, q)); } if (xtemps == 0) return; /* put arguments in temporaries */ for (i = 0; i < n; i++) { if (sp[i]->stype == STRTY || sp[i]->stype == UNIONTY || cisreg(sp[i]->stype) == 0) continue; if (cqual(sp[i]->stype, sp[i]->squal) & VOL) continue; sp2 = sp[i]; p = tempnode(0, sp[i]->stype, sp[i]->sdf, sp[i]->sap); p = buildtree(ASSIGN, p, nametree(sp2)); sp[i]->soffset = regno(p->n_left); sp[i]->sflags |= STNODE; ecomp(p); } }
/* * code for the end of a function * deals with struct return here */ void efcode(void) { NODE *p, *q; int tempnr; int ty; if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN) return; ty = cftnsp->stype - FTN; q = block(REG, NIL, NIL, INCREF(ty), 0, cftnsp->sap); q->n_rval = V0; p = tempnode(0, INCREF(ty), 0, cftnsp->sap); tempnr = regno(p); p = buildtree(ASSIGN, p, q); ecomp(p); q = tempnode(tempnr, INCREF(ty), 0, cftnsp->sap); q = buildtree(UMUL, q, NIL); p = tempnode(rvnr, INCREF(ty), 0, cftnsp->sap); p = buildtree(UMUL, p, NIL); p = buildtree(ASSIGN, p, q); ecomp(p); q = tempnode(rvnr, INCREF(ty), 0, cftnsp->sap); p = block(REG, NIL, NIL, INCREF(ty), 0, cftnsp->sap); p->n_rval = V0; p = buildtree(ASSIGN, p, q); ecomp(p); }
/* setup a float param on the stack * used by bfcode() */ static void param_float(struct symtab *sym, int *argofsp, int dotemps) { NODE *p, *q, *t; int tmpnr; /* * we have to dump the float from the general register * into a temp, since the register allocator doesn't like * floats to be in CLASSA. This may not work for -xtemps. */ t = tempnode(0, INT, 0, 0); tmpnr = regno(t); q = block(REG, NIL, NIL, INT, 0, 0); q->n_rval = R0 + (*argofsp)++; p = buildtree(ASSIGN, t, q); ecomp(p); if (dotemps) { sym->soffset = tmpnr; sym->sflags |= STNODE; } else { q = tempnode(tmpnr, sym->stype, sym->sdf, sym->sap); p = nametree(sym); p = buildtree(ASSIGN, p, q); ecomp(p); } }
/* * code for the beginning of a function; a is an array of * indices in stab for the arguments; n is the number */ void bfcode(struct symtab **sp, int cnt) { NODE *p, *q; int i, n; if (cftnsp->stype == STRTY+FTN || cftnsp->stype == UNIONTY+FTN) { uerror("no struct return yet"); } /* recalculate the arg offset and create TEMP moves */ for (n = 1, i = 0; i < cnt; i++) { if (n < 8) { p = tempnode(0, sp[i]->stype, sp[i]->sdf, sp[i]->ssue); q = block(REG, NIL, NIL, sp[i]->stype, sp[i]->sdf, sp[i]->ssue); q->n_rval = n; p = buildtree(ASSIGN, p, q); sp[i]->soffset = regno(p->n_left); sp[i]->sflags |= STNODE; ecomp(p); } else { sp[i]->soffset += SZINT * n; if (xtemps) { /* put stack args in temps if optimizing */ p = tempnode(0, sp[i]->stype, sp[i]->sdf, sp[i]->ssue); p = buildtree(ASSIGN, p, nametree(sp[i])); sp[i]->soffset = regno(p->n_left); sp[i]->sflags |= STNODE; ecomp(p); } } n += szty(sp[i]->stype); } }
/* * code for the end of a function * deals with struct return here * The return value is in (or pointed to by) RETREG. */ void efcode(void) { struct symtab *sp; extern int gotnr; TWORD t; NODE *p, *r, *l; int typ, ssz, rno; gotnr = 0; /* new number for next fun */ sp = cftnsp; t = DECREF(sp->stype); if (t != STRTY && t != UNIONTY) return; /* XXX should have one routine for this */ ngpr = nsse = 0; if ((typ = argtyp(t, sp->sdf, sp->sap)) == STRREG || typ == STRCPX) { /* Cast to long pointer and move to the registers */ /* XXX can overrun struct size */ /* XXX check carefully for SSE members */ if ((ssz = tsize(t, sp->sdf, sp->sap)) > SZLONG*2) cerror("efcode1"); if (typ == STRCPX) { t = DOUBLE; rno = XMM0; } else { t = LONG; rno = RAX; } if (ssz > SZLONG) { p = block(REG, NIL, NIL, INCREF(t), 0, 0); regno(p) = RAX; p = buildtree(UMUL, buildtree(PLUS, p, bcon(1)), NIL); ecomp(movtoreg(p, rno+1)); } p = block(REG, NIL, NIL, INCREF(t), 0, 0); regno(p) = RAX; p = buildtree(UMUL, p, NIL); ecomp(movtoreg(p, rno)); } else if (typ == STRMEM) { r = block(REG, NIL, NIL, INCREF(t), sp->sdf, sp->sap); regno(r) = RAX; r = buildtree(UMUL, r, NIL); l = tempnode(stroffset, INCREF(t), sp->sdf, sp->sap); l = buildtree(UMUL, l, NIL); ecomp(buildtree(ASSIGN, l, r)); l = block(REG, NIL, NIL, LONG, 0, 0); regno(l) = RAX; r = tempnode(stroffset, LONG, 0, 0); ecomp(buildtree(ASSIGN, l, r)); } else cerror("efcode"); }
/* * code for the beginning of a function; a is an array of * indices in symtab for the arguments; n is the number */ void bfcode(struct symtab **sp, int cnt) { struct symtab *sp2; NODE *n; int i; if (cftnsp->stype == STRTY+FTN || cftnsp->stype == UNIONTY+FTN) { /* Function returns struct, adjust arg offset */ for (i = 0; i < cnt; i++) sp[i]->soffset += SZPOINT(INT); } if (xtemps == 0) return; /* put arguments in temporaries */ for (i = 0; i < cnt; i++) { if (sp[i]->stype == STRTY || sp[i]->stype == UNIONTY || cisreg(sp[i]->stype) == 0) continue; sp2 = sp[i]; n = tempnode(0, sp[i]->stype, sp[i]->sdf, sp[i]->sap); n = buildtree(ASSIGN, n, nametree(sp2)); sp[i]->soffset = regno(n->n_left); sp[i]->sflags |= STNODE; ecomp(n); } }
static NODE * builtin_va_arg(const struct bitable *bt, NODE *a) { NODE *p, *q, *r, *rv; int sz, nodnum; /* create a copy to a temp node of current ap */ p = ccopy(a->n_left); q = tempnode(0, p->n_type, p->n_df, p->n_ap); nodnum = regno(q); rv = buildtree(ASSIGN, q, p); r = a->n_right; sz = (int)tsize(r->n_type, r->n_df, r->n_ap)/SZCHAR; /* add one to ap */ #ifdef BACKAUTO rv = buildtree(COMOP, rv , buildtree(PLUSEQ, a->n_left, bcon(sz))); #else #error fix wrong eval order in builtin_va_arg ecomp(buildtree(MINUSEQ, a->n_left, bcon(sz))); #endif nfree(a->n_right); nfree(a); r = tempnode(nodnum, INCREF(r->n_type), r->n_df, r->n_ap); return buildtree(COMOP, rv, buildtree(UMUL, r, NIL)); }
/* setup struct parameter * push the registers out to memory * used by bfcode() */ static void param_struct(struct symtab *sym, int *regp) { int reg = *regp; NODE *p, *q; int navail; int sz; int off; int num; int i; navail = nargregs - (reg - A0); sz = tsize(sym->stype, sym->sdf, sym->sap) / SZINT; off = ARGINIT/SZINT + (reg - A0); num = sz > navail ? navail : sz; for (i = 0; i < num; i++) { q = block(REG, NIL, NIL, INT, 0, 0); q->n_rval = reg++; p = block(REG, NIL, NIL, INT, 0, 0); p->n_rval = FP; p = block(PLUS, p, bcon(4*off++), INT, 0, 0); p = block(UMUL, p, NIL, INT, 0, 0); p = buildtree(ASSIGN, p, q); ecomp(p); } *regp = reg; }
/* * code for the end of a function * deals with struct return here */ void efcode(void) { NODE *p, *q; // int sz; #if 0 /* restore ac3 */ p = block(REG, 0, 0, INT, 0, 0); regno(p) = 3; q = tempnode(ac3temp, INT, 0, 0); ecomp(buildtree(ASSIGN, p, q)); #endif if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN) return; cerror("efcode"); /* address of return struct is in eax */ /* create a call to memcpy() */ /* will get the result in eax */ p = block(REG, NIL, NIL, CHAR+PTR, 0, 0); // p->n_rval = EAX; q = block(OREG, NIL, NIL, CHAR+PTR, 0, 0); // q->n_rval = EBP; q->n_lval = 8; /* return buffer offset */ p = block(CM, q, p, INT, 0, 0); // sz = (tsize(STRTY, cftnsp->sdf, cftnsp->ssue)+SZCHAR-1)/SZCHAR; // p = block(CM, p, bcon(sz), INT, 0, 0); p->n_right->n_name = ""; p = block(CALL, bcon(0), p, CHAR+PTR, 0, 0); p->n_left->n_name = "memcpy"; p = clocal(p); send_passt(IP_NODE, p); }
/* setup struct parameter * push the registers out to memory * used by bfcode() */ static void param_struct(struct symtab *sym, int *argofsp) { int argofs = *argofsp; NODE *p, *q; int navail; int sz; int off; int num; int i; navail = NARGREGS - argofs; sz = tsize(sym->stype, sym->sdf, sym->sap) / SZINT; off = ARGINIT/SZINT + argofs; num = sz > navail ? navail : sz; for (i = 0; i < num; i++) { q = block(REG, NIL, NIL, INT, 0, 0); regno(q) = R0 + argofs++; p = block(REG, NIL, NIL, INT, 0, 0); regno(p) = SP; p = block(PLUS, p, bcon(4*off++), INT, 0, 0); p = block(UMUL, p, NIL, INT, 0, 0); p = buildtree(ASSIGN, p, q); ecomp(p); } *argofsp = argofs; }
/* called from moveargs() */ static NODE * movearg_float(NODE *p, int *regp) { NODE *q, *r; TWORD ty = INCREF(p->n_type); int tmpnr; /* * Floats are passed in the general registers for * compatibily with libraries compiled to handle soft-float. */ if (xtemps) { /* bounce on TOS */ r = block(REG, NIL, NIL, ty, p->n_df, p->n_ap); regno(r) = SP; r = block(PLUS, r, bcon(-4), ty, p->n_df, p->n_ap); r = block(UMUL, r, NIL, p->n_type, p->n_df, p->n_ap); r = buildtree(ASSIGN, r, p); ecomp(r); /* bounce into temp */ r = block(REG, NIL, NIL, PTR+INT, 0, 0); regno(r) = SP; r = block(PLUS, r, bcon(-8), PTR+INT, 0, 0); r = block(UMUL, r, NIL, INT, 0, 0); q = tempnode(0, INT, 0, 0); tmpnr = regno(q); r = buildtree(ASSIGN, q, r); ecomp(r); } else { /* copy directly into temp */ q = tempnode(0, p->n_type, p->n_df, p->n_ap); tmpnr = regno(q); r = buildtree(ASSIGN, q, p); ecomp(r); } /* copy from temp to register parameter */ r = tempnode(tmpnr, INT, 0, 0); q = block(REG, NIL, NIL, INT, 0, 0); regno(q) = (*regp)++; p = buildtree(ASSIGN, q, r); return p; }
void bfcode(struct symtab **sp, int n) { struct symtab *sp2; NODE *p, *q; int i, argbase, sz; if (cftnsp->stype == STRTY+FTN || cftnsp->stype == UNIONTY+FTN) { /* Move return address into temporary */ p = tempnode(0, INT, 0, 0); strtemp = regno(p); q = block(REG, 0, 0, INT, 0, 0); regno(q) = R1; ecomp(buildtree(ASSIGN, p, q)); } /* correct arg alignment XXX should be done somewhere else */ argbase = ARGINIT; for (i = 0; i < n; i++) { sp2 = sp[i]; sz = tsize(sp2->stype, sp2->sdf, sp2->sap); SETOFF(sz, SZINT); sp2->soffset = argbase; argbase += sz; } if (xtemps == 0) return; /* put arguments in temporaries */ for (i = 0; i < n; i++) { if (sp[i]->stype == STRTY || sp[i]->stype == UNIONTY || cisreg(sp[i]->stype) == 0) continue; if (cqual(sp[i]->stype, sp[i]->squal) & VOL) continue; sp2 = sp[i]; p = tempnode(0, sp[i]->stype, sp[i]->sdf, sp[i]->sap); p = buildtree(ASSIGN, p, nametree(sp2)); sp[i]->soffset = regno(p->n_left); sp[i]->sflags |= STNODE; ecomp(p); } }
/* called from moveargs() */ static NODE * movearg_double(NODE *p, int *regp) { NODE *q, *r; TWORD ty = INCREF(p->n_type); int tmpnr; if (xtemps) { /* bounce on TOS */ r = block(REG, NIL, NIL, ty, p->n_df, p->n_ap); regno(r) = SP; r = block(PLUS, r, bcon(-8), ty, p->n_df, p->n_ap); r = block(UMUL, r, NIL, p->n_type, p->n_df, p->n_ap); r = buildtree(ASSIGN, r, p); ecomp(r); /* bounce into temp */ r = block(REG, NIL, NIL, PTR+LONGLONG, 0, 0); regno(r) = SP; r = block(PLUS, r, bcon(-8), PTR+LONGLONG, 0, 0); r = block(UMUL, r, NIL, LONGLONG, 0, 0); q = tempnode(0, LONGLONG, 0, 0); tmpnr = regno(q); r = buildtree(ASSIGN, q, r); ecomp(r); } else { /* copy directly into temp */ q = tempnode(0, p->n_type, p->n_df, p->n_ap); tmpnr = regno(q); r = buildtree(ASSIGN, q, p); ecomp(r); } /* copy from temp to register parameter */ r = tempnode(tmpnr, LONGLONG, 0, 0); q = block(REG, NIL, NIL, LONGLONG, 0, 0); regno(q) = R0R1 - R0 + (*regp); p = buildtree(ASSIGN, q, r); (*regp) += 2; return p; }
/* Put a symbol in a temporary * used by bfcode() and its helpers */ static void putintemp(struct symtab *sym) { NODE *p; p = tempnode(0, sym->stype, sym->sdf, sym->sap); p = buildtree(ASSIGN, p, nametree(sym)); sym->soffset = regno(p->n_left); sym->sflags |= STNODE; ecomp(p); }
/* * code for the beginning of a function; 'a' is an array of * indices in symtab for the arguments; n is the number */ void bfcode(struct symtab **a, int cnt) { struct symtab *sp; NODE *p, *q; int i, n, sz; if (cftnsp->stype == STRTY+FTN || cftnsp->stype == UNIONTY+FTN) { /* Function returns struct, adjust arg offset */ for (i = 0; i < n; i++) a[i]->soffset += SZPOINT(LONG); } /* recalculate the arg offset and create TEMP moves */ for (n = 0, i = 0; i < cnt; i++) { sp = a[i]; sz = szty(sp->stype); if (n % sz) n++; /* XXX LDOUBLE */ if (n < 4) { p = tempnode(0, sp->stype, sp->sdf, sp->ssue); /* TODO p->n_left->n_lval = -(32 + n * 4); */ q = block(REG, NIL, NIL, sp->stype, sp->sdf, sp->ssue); q->n_rval = argreg(sp->stype, &n); p = buildtree(ASSIGN, p, q); sp->soffset = regno(p->n_left); sp->sflags |= STNODE; ecomp(p); } else { sp->soffset += SZINT * n; if (xtemps) { /* put stack args in temps if optimizing */ p = tempnode(0, sp->stype, sp->sdf, sp->ssue); p = buildtree(ASSIGN, p, buildtree(NAME, 0, 0)); sp->soffset = regno(p->n_left); sp->sflags |= STNODE; ecomp(p); } } } }
/* * XXX This is a hack. We cannot have (l)doubles in more than one * register class. So we bounce them in and out of temps to * move them in and out of the right registers. */ static void param_double(struct symtab *sym, int *regp, int dotemps) { int reg = *regp; NODE *p, *q, *t; int navail; int tmpnr; /* alignment */ ++reg; reg &= ~1; navail = nargregs - (reg - A0); if (navail < 2) { /* would have appeared half in registers/half * on the stack, but alignment ensures it * appears on the stack */ if (dotemps) putintemp(sym); *regp = reg; return; } t = tempnode(0, LONGLONG, 0, 0); tmpnr = regno(t); q = block(REG, NIL, NIL, LONGLONG, 0, 0); q->n_rval = A0A1 + (reg - A0); p = buildtree(ASSIGN, t, q); ecomp(p); if (dotemps) { sym->soffset = tmpnr; sym->sflags |= STNODE; } else { q = tempnode(tmpnr, sym->stype, sym->sdf, sym->sap); p = nametree(sym); p = buildtree(ASSIGN, p, q); ecomp(p); } *regp = reg + 2; }
/* setup the hidden pointer to struct return parameter * used by bfcode() */ static void param_retptr(void) { NODE *p, *q; p = tempnode(0, PTR+STRTY, 0, cftnsp->sap); rvnr = regno(p); q = block(REG, NIL, NIL, PTR+STRTY, 0, cftnsp->sap); q->n_rval = A0; p = buildtree(ASSIGN, p, q); ecomp(p); }
/* setup the hidden pointer to struct return parameter * used by bfcode() */ static void param_retstruct(void) { NODE *p, *q; p = tempnode(0, PTR-FTN+cftnsp->stype, 0, cftnsp->sap); rvnr = regno(p); q = block(REG, NIL, NIL, PTR+STRTY, 0, cftnsp->sap); regno(q) = R0; p = buildtree(ASSIGN, p, q); ecomp(p); }
/* * Allocate off bits on the stack. p is a tree that when evaluated * is the multiply count for off, t is a NAME node where to write * the allocated address. */ void spalloc(NODE *t, NODE *p, OFFSZ off) { NODE *sp; int nbytes = off / SZCHAR; p = buildtree(MUL, p, bcon(nbytes)); p = buildtree(PLUS, p, bcon(7)); p = buildtree(AND, p, bcon(~7)); /* subtract the size from sp */ sp = block(REG, NIL, NIL, p->n_type, 0, 0); sp->n_lval = 0; sp->n_rval = SP; ecomp(buildtree(MINUSEQ, sp, p)); /* save the address of sp */ sp = block(REG, NIL, NIL, PTR+INT, t->n_df, t->n_ap); sp->n_rval = SP; t->n_type = sp->n_type; ecomp(buildtree(ASSIGN, t, sp)); /* Emit! */ }
void lapack_getrf<T>::operator()( clapack::integer m, clapack::integer n, T* a_ptr, clapack::integer* ipiv_ptr) throw(ecomp) { clapack::integer info; lapack_exec(&m, &n, a_ptr, &m, ipiv_ptr, &info); if(info < 0) return; if(info > 0) throw ecomp(); }
/* * XXX This is a hack. We cannot have floats in more than one * register class. So we bounce them in and out of temps to * move them in and out of the right registers. */ static void param_float(struct symtab *sym, int *regp, int dotemps) { NODE *p, *q, *t; int tmpnr; t = tempnode(0, INT, 0, 0); tmpnr = regno(t); q = block(REG, NIL, NIL, INT, 0, 0); q->n_rval = (*regp)++; p = buildtree(ASSIGN, t, q); ecomp(p); if (dotemps) { sym->soffset = tmpnr; sym->sflags |= STNODE; } else { q = tempnode(tmpnr, sym->stype, sym->sdf, sym->sap); p = nametree(sym); p = buildtree(ASSIGN, p, q); ecomp(p); } }
/* * code for the end of a function * deals with struct return here */ void efcode(void) { extern int gotnr; NODE *p, *q; gotnr = 0; /* new number for next fun */ if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN) return; /* Create struct assignment */ q = tempnode(structrettemp, PTR+STRTY, 0, cftnsp->sap); q = buildtree(UMUL, q, NIL); p = block(REG, NIL, NIL, PTR+STRTY, 0, cftnsp->sap); p = buildtree(UMUL, p, NIL); p = buildtree(ASSIGN, q, p); ecomp(p); /* put hidden arg in ax on return */ q = tempnode(structrettemp, INT, 0, 0); p = block(REG, NIL, NIL, INT, 0, 0); regno(p) = AX; ecomp(buildtree(ASSIGN, p, q)); }
/* * End-of-Function code: */ void efcode(void) { NODE *p, *q; int tempnr; if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN) return; /* * At this point, the address of the return structure on * has been FORCEd to RETREG, which is R0. * We want to copy the contents from there to the address * we placed into the tempnode "rvnr". */ /* move the pointer out of R0 to a tempnode */ q = block(REG, NIL, NIL, PTR+STRTY, 0, cftnsp->sap); q->n_rval = R0; p = tempnode(0, PTR+STRTY, 0, cftnsp->sap); tempnr = regno(p); p = buildtree(ASSIGN, p, q); ecomp(p); /* get the address from the tempnode */ q = tempnode(tempnr, PTR+STRTY, 0, cftnsp->sap); q = buildtree(UMUL, q, NIL); /* now, get the structure destination */ p = tempnode(rvnr, PTR+STRTY, 0, cftnsp->sap); p = buildtree(UMUL, p, NIL); /* struct assignment */ p = buildtree(ASSIGN, p, q); ecomp(p); }
//==================================================================================================================== FixedChemPotSSTP::FixedChemPotSSTP(std::string Ename, doublereal val) : SingleSpeciesTP(), chemPot_(0.0) { std::string pname = Ename + "Fixed"; setID(pname); setName(pname); setNDim(3); addUniqueElement(Ename, -12345.); freezeElements(); vector_fp ecomp(nElements(), 0.0); ecomp[0] = 1.0; double chrg = 0.0; SpeciesThermo* spth = new SimpleThermo(); setSpeciesThermo(spth); addUniqueSpecies(pname, &ecomp[0], chrg, 0.0); double c[4]; c[0] = 298.15; c[1] = val; c[2] = 0.0; c[3] = 0.0; m_spthermo->install(pname, 0, SIMPLE, c, 0.0, 1.0E30, OneAtm); freezeSpecies(); initThermo(); m_p0 = OneAtm; m_tlast = 298.15; setChemicalPotential(val); // Create an XML_Node entry for this species XML_Node* s = new XML_Node("species", 0); s->addAttribute("name", pname); std::string aaS = Ename + ":1"; s->addChild("atomArray", aaS); XML_Node& tt = s->addChild("thermo"); XML_Node& ss = tt.addChild("Simple"); ss.addAttribute("Pref", "1 bar"); ss.addAttribute("Tmax", "5000."); ss.addAttribute("Tmin", "100."); ss.addChild("t0", "298.15"); ss.addChild("cp0", "0.0"); std::string sval = fp2str(val); ss.addChild("h", sval); ss.addChild("s", "0.0"); saveSpeciesData(0, s); delete s; s = 0; }
/* * code for the end of a function * deals with struct return here */ void efcode(void) { NODE *p, *q; if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN) return; /* Create struct assignment */ q = block(OREG, NIL, NIL, PTR+STRTY, 0, cftnsp->sap); q->n_rval = R5; q->n_lval = 8; /* return buffer offset */ q = buildtree(UMUL, q, NIL); p = block(REG, NIL, NIL, PTR+STRTY, 0, cftnsp->sap); p = buildtree(UMUL, p, NIL); p = buildtree(ASSIGN, q, p); ecomp(p); }
/* setup a 32-bit param on the stack * used by bfcode() */ static void param_32bit(struct symtab *sym, int *argofsp, int dotemps) { NODE *p, *q; q = block(REG, NIL, NIL, sym->stype, sym->sdf, sym->sap); regno(q) = R0 + (*argofsp)++; if (dotemps) { p = tempnode(0, sym->stype, sym->sdf, sym->sap); sym->soffset = regno(p); sym->sflags |= STNODE; } else { p = nametree(sym); } p = buildtree(ASSIGN, p, q); ecomp(p); }