p->reg = wid;
}
+void
+gdatacomplex(Node *nam, Mpcplx *cval)
+{
+ Prog *p;
+ int w;
+
+ w = cplxsubtype(nam->type->etype);
+ w = types[w]->width;
+
+ p = gins(ADATA, nam, N);
+ p->from.scale = w;
+ p->to.type = D_FCONST;
+ p->to.dval = mpgetflt(&cval->real);
+
+ p = gins(ADATA, nam, N);
+ p->from.scale = w;
+ p->from.offset += w;
+ p->to.type = D_FCONST;
+ p->to.dval = mpgetflt(&cval->imag);
+}
+
void
gdatastring(Node *nam, Strlit *sval)
{
p->from.scale = wid;
}
+void
+gdatacomplex(Node *nam, Mpcplx *cval)
+{
+ Prog *p;
+ int w;
+
+ w = cplxsubtype(nam->type->etype);
+ w = types[w]->width;
+
+ p = gins(ADATA, nam, N);
+ p->from.scale = w;
+ p->to.type = D_FCONST;
+ p->to.dval = mpgetflt(&cval->real);
+
+ p = gins(ADATA, nam, N);
+ p->from.scale = w;
+ p->from.offset += w;
+ p->to.type = D_FCONST;
+ p->to.dval = mpgetflt(&cval->imag);
+}
+
void
gdatastring(Node *nam, Strlit *sval)
{
p->from.offset += types[tptr]->width;
}
-
int
dstringptr(Sym *s, int off, char *str)
{
p->from.scale = wid;
}
+void
+gdatacomplex(Node *nam, Mpcplx *cval)
+{
+ Prog *p;
+ int w;
+
+ w = cplxsubtype(nam->type->etype);
+ w = types[w]->width;
+
+ p = gins(ADATA, nam, N);
+ p->from.scale = w;
+ p->to.type = D_FCONST;
+ p->to.dval = mpgetflt(&cval->real);
+
+ p = gins(ADATA, nam, N);
+ p->from.scale = w;
+ p->from.offset += w;
+ p->to.type = D_FCONST;
+ p->to.dval = mpgetflt(&cval->imag);
+}
+
void
gdatastring(Node *nam, Strlit *sval)
{
#include "gg.h"
static void subnode(Node *nr, Node *ni, Node *nc);
-static void zero(Node *n);
static void minus(Node *nl, Node *res);
void complexminus(Node*, Node*);
void complexadd(int op, Node*, Node*, Node*);
ni->xoffset += t->width;
}
-// generate code to zero addable dest nr
-static void
-zero(Node *nr)
-{
- Node nc;
- Mpflt fval;
-
- memset(&nc, 0, sizeof(nc));
- nc.op = OLITERAL;
- nc.addable = 1;
- ullmancalc(&nc);
- nc.val.u.fval = &fval;
- nc.val.ctype = CTFLT;
- nc.type = nr->type;
-
- mpmovecflt(nc.val.u.fval, 0.0);
-
- cgen(&nc, nr);
-}
-
// generate code res = -nl
static void
minus(Node *nl, Node *res)
void gused(Node*);
void gdata(Node*, Node*, int);
void gdatastring(Node*, Strlit*);
+void gdatacomplex(Node*, Mpcplx*);
void dumptypestructs(void);
void dumpfuncs(void);
void dumpdata(void);
gdata(&nam, nr, nr->type->width);
break;
+ case TCOMPLEX64:
+ case TCOMPLEX128:
+ case TCOMPLEX:
+ gused(N); // in case the data is the dest of a goto
+ gdatacomplex(&nam, nr->val.u.cval);
+ break;
+
case TSTRING:
gused(N); // in case the data is the dest of a goto
gdatastring(&nam, nr->val.u.sval);