void visit_tree(struct expr_node *expr) { if(expr) { sprintf(out_str,"%s",expr->str);fputs(out_str,fpout); if(expr->type>2) return; sprintf(out_str,"(");fputs(out_str,fpout); visit_tree(expr->left); sprintf(out_str,",");fputs(out_str,fpout); visit_tree(expr->right); sprintf(out_str,")");fputs(out_str,fpout); } }
/** * Attempt to vectorize the previously saved assignments, and clear them from * consideration. * * If the assignments are able to be combined, it modifies in-place the last * assignment seen to be an equivalent vector form of the scalar assignments. * It then removes the other now obsolete scalar assignments. */ void ir_vectorize_visitor::try_vectorize() { if (this->last_assignment && this->channels > 1) { ir_swizzle_mask mask = {0, 0, 0, 0, channels, 0}; this->last_assignment->write_mask = 0; for (unsigned i = 0, j = 0; i < 4; i++) { if (this->assignment[i]) { this->last_assignment->write_mask |= 1 << i; if (this->assignment[i] != this->last_assignment) { this->assignment[i]->remove(); } switch (j) { case 0: mask.x = i; break; case 1: mask.y = i; break; case 2: mask.z = i; break; case 3: mask.w = i; break; } j++; } } visit_tree(this->last_assignment->rhs, rewrite_swizzle, &mask); this->progress = true; } clear(); }
void visit_tree(int *A,int index,int len) { int pNode=PARENT(index); if (pNode==0) { } else { if (A[pNode]>=A[index]) { std::cout<<"yes"<<"\n"; } } int lNode=LEFT(index); int rNode=RIGHT(index); if (lNode>=len||rNode>=len) { std::cout<<" left "<<A[lNode-1]; std::cout<<"end"; return; } index++; std::cout<<" left "<<A[lNode-1]<<" right "<<A[rNode-1]<<std::endl; visit_tree(A, index, len); // visit_tree(A, index, len); }
void print_data(struct Process *proc) { struct process_construct *pc; struct instruction_node *in; struct expr_node *expr; struct var_table *vt; if(!DO_DEBUG) return; for(in=proc->pc->first;in;in=in->next) { sprintf(out_str,"{line(%d[%d]),%s",in->num_node,in->line_count,in->instr);fputs(out_str,fpout); if(in->left) { sprintf(out_str,"(%c ",*in->laddr);fputs(out_str,fpout); visit_tree(in->left); if(in->right) { sprintf(out_str,",%c ",*in->raddr);fputs(out_str,fpout); visit_tree(in->right); } sprintf(out_str,")");fputs(out_str,fpout); } sprintf(out_str,"};");fputs(out_str,fpout); } sprintf(out_str,"\n---var table---\n");fputs(out_str,fpout); for(vt=proc->pc->vt_first;vt;vt=vt->next) { sprintf(out_str,"%s %s",vt->name,vt->val_first->str);fputs(out_str,fpout); if(vt->val_first->left) { sprintf(out_str,"(");fputs(out_str,fpout); visit_tree(vt->val_first->left); if(vt->val_first->right) { sprintf(out_str,",");fputs(out_str,fpout); visit_tree(vt->val_first->right); } sprintf(out_str,")");fputs(out_str,fpout); } sprintf(out_str,"\n");fputs(out_str,fpout); } }
void visit_tree(astree node, FILE* outfile){ switch(node->symbol){ case TOK_STRUCT: handlestruct(node, outfile); return; case TOK_BLOCK: push_block(gblock_stk); break; case TOK_FUNCTION: if (handlefunction(node, outfile)){ return; } else { push_block(gblock_stk); break; } case TOK_PROTOTYPE: handleprototype(node,outfile); break; case TOK_VARDECLINIT: handlevardecl(node,outfile); break; } astree temp; for(temp = node->first; temp != NULL; temp = temp->next){ visit_tree(temp, outfile); } switch(node->symbol){ case TOK_BLOCK: case TOK_FUNCTION: pop_idents(gident_tbl,gblock_stk->top->blocknr); pop_block(gblock_stk); break; case TOK_INTCON: node->attrs = ATTR_INT | ATTR_CONST; break; case TOK_CHARCON: node->attrs = ATTR_CHAR | ATTR_CONST; break; case TOK_STRINGCON: node->attrs = ATTR_STRING | ATTR_CONST; break; case TOK_FALSE: case TOK_TRUE: case TOK_BOOL: node->attrs = ATTR_BOOL | ATTR_CONST; node->blocknr = gblock_stk->top->blocknr; break; case TOK_ARRAY: node->attrs = ATTR_ARRAY | bitlookup(node->first->symbol); node->blocknr = gblock_stk->top->blocknr; break; case TOK_INT: node->attrs = ATTR_INT; node->blocknr = gblock_stk->top->blocknr; break; case TOK_CHAR: node->attrs = ATTR_CHAR; node->blocknr = gblock_stk->top->blocknr; break; case TOK_STRING: node->attrs = ATTR_STRING; node->blocknr = gblock_stk->top->blocknr; break; case TOK_TYPEID: node->attrs = ATTR_TYPEID; node->blocknr = gblock_stk->top->blocknr; break; case TOK_VOID: node->attrs = ATTR_VOID; node->blocknr = gblock_stk->top->blocknr; break; } }