int litlist(ENODE *node) { struct slit *lp; ENODE *ep; lp = strtab; while (lp) { if (lp->isString) continue; ep = (ENODE *)lp->str; if (node->IsEqual(node, ep)) { return (lp->label); } lp = lp->next; } lp = (struct slit *)allocx(sizeof(struct slit)); lp->label = nextlabel++; lp->str = (char *)node; lp->nmspace = my_strdup(GetNamespace()); if (strtab == nullptr) { strtab = lp; strtab->tail = lp; } else { strtab->tail->next = lp; strtab->tail = lp; } lp->isString = false; lp->pass = pass; return (lp->label); }
ENODE *allocEnode() { ENODE *p; p = (ENODE *)allocx(sizeof(ENODE)); ZeroMemory(p, sizeof(ENODE)); p->sp = new std::string(); return (p); };
Float128 *GetFloatExpression(ENODE **pnode) /* simple integer value */ { TYP *tp; ENODE *node; Float128 *flt; flt = (Float128 *)allocx(sizeof(Float128)); tp = NonCommaExpression(&node); if (node==NULL) { error(ERR_SYNTAX); return 0; } opt_const(&node); // This should reduce to a single integer expression if (node==NULL) { fatal("Compiler Error: GetFloatExpression: node is NULL"); return 0; } if (node->nodetype != en_fcon) { if (node->nodetype==en_uminus) { if (node->p[0]->nodetype != en_fcon) { printf("\r\nnode:%d \r\n", node->nodetype); error(ERR_INT_CONST); return 0; } Float128::Assign(flt, &node->p[0]->f128); flt->sign = !flt->sign; if (pnode) *pnode = node; return (flt); } } if (pnode) *pnode = node; return &node->f128; }
Tree *Forest::MakeNewTree() { Tree *t; t = (Tree*)allocx(sizeof(Tree)); t->blocks = CSet::MakeNew(); trees[treecount] = t; treecount++; return (t); }
/* * add a compiler generated label to the peep list. */ void GenerateLabel(int labno) { struct ocode *newl; newl = (struct ocode *)allocx(sizeof(struct ocode)); newl->opcode = op_label; newl->oper1 = (struct amode *)labno; newl->oper2 = (struct amode *)my_strdup((char *)currentFn->name->c_str()); AddToPeepList(newl); }
Var *Var::MakeNew() { Var *p; p = (Var *)allocx(sizeof(Var)); p->forest = CSet::MakeNew(); p->visited = CSet::MakeNew(); nvar++; return (p); }
int caselit(struct scase *cases, int64_t num) { struct c**t *lp; lp = casetab; while (lp) { if (memcmp(lp->cases, cases, num * sizeof(struct scase)) == 0) return (lp->label); lp = lp->next; } lp = (struct c**t *)allocx(sizeof(struct c**t)); lp->label = nextlabel++; lp->nmspace = my_strdup(GetNamespace()); lp->cases = (struct scase *)allocx(sizeof(struct scase)*(int)num); lp->num = (int)num; lp->pass = pass; memcpy(lp->cases, cases, (int)num * sizeof(struct scase)); lp->next = casetab; casetab = lp; return lp->label; }
void Generate4adic(int op, int len, AMODE *ap1, AMODE *ap2, AMODE *ap3, AMODE *ap4) { struct ocode *cd; cd = (struct ocode *)allocx(sizeof(struct ocode)); cd->predop = 1; cd->pregreg = 15; cd->opcode = op; cd->length = len; cd->oper1 = copy_addr(ap1); cd->oper2 = copy_addr(ap2); cd->oper3 = copy_addr(ap3); cd->oper4 = copy_addr(ap4); AddToPeepList(cd); }
void GeneratePredicatedMonadic(int pr, int pop, int op, int len, AMODE *ap1) { struct ocode *cd; cd = (struct ocode *)allocx(sizeof(struct ocode)); cd->predop = pop; cd->pregreg = pr; cd->opcode = op; cd->length = len; cd->oper1 = copy_addr(ap1); cd->oper2 = NULL; cd->oper3 = NULL; cd->oper4 = NULL; currentFn->UsesPredicate = TRUE; AddToPeepList(cd); }
/* * make s a string literal and return it's label number. */ int stringlit(char *s) { struct slit *lp; lp = (struct slit *)allocx(sizeof(struct slit)); lp->label = nextlabel++; lp->str = my_strdup(s); lp->nmspace = my_strdup(GetNamespace()); if (strtab == nullptr) { strtab = lp; strtab->tail = lp; } else { strtab->tail->next = lp; strtab->tail = lp; } lp->isString = true; lp->pass = pass; return (lp->label); }
void GenerateMonadic(int op, int len, AMODE *ap1) { dfs.printf("Enter GenerateMonadic\r\n"); struct ocode *cd; dfs.printf("A"); cd = (struct ocode *)allocx(sizeof(struct ocode)); dfs.printf("B"); cd->predop = 1; cd->pregreg = 15; cd->opcode = op; cd->length = len; cd->oper1 = copy_addr(ap1); dfs.printf("C"); cd->oper2 = NULL; cd->oper3 = NULL; cd->oper4 = NULL; dfs.printf("D"); AddToPeepList(cd); dfs.printf("Leave GenerateMonadic\r\n"); }
int quadlit(Float128 *f128) { Float128 *lp; lp = quadtab; // First search for the same literal constant and it's label if found. while(lp) { if (Float128::IsEqual(f128,Float128::Zero())) { if (Float128::IsEqualNZ(lp,f128)) return (lp->label); } else if (Float128::IsEqual(lp,f128)) return (lp->label); lp = lp->next; } lp = (Float128 *)allocx(sizeof(Float128)); lp->label = nextlabel++; Float128::Assign(lp,f128); lp->nmspace = my_strdup(GetNamespace()); lp->next = quadtab; quadtab = lp; return (lp->label); }