void TreeNode::CodeGeneration(CodeEmitter &e) { GenProlog(jumpMain, e); GenIOFunctions(e); // Traverse the tree GenCode(e, true, 0, 0); }
static void BlockToCode( bool partly_done ) /*********************************************/ { block_num inputs; block_num targets; block_edge *input_edges; conflict_node *curr; conflict_node **owner; conflict_node *conflist; block_num id; /* try to get back some memory*/ _MemLow; /* make the block look like an entire procedure*/ HeadBlock = CurrBlock; BlockList = CurrBlock; HeadBlock->prev_block = NULL; if( HeadBlock->next_block != NULL ) { HeadBlock->next_block->prev_block = NULL; } /* Kludge - need a pointer to the next block for CALL_LABEL - puke! */ if( HeadBlock->class & CALL_LABEL ) { HeadBlock->v.next = HeadBlock->next_block; } HeadBlock->next_block = NULL; /* force anything that spans blocks to memory */ HeadBlock->u.partition = HeadBlock; ConstFold( HeadBlock ); HeadBlock->u.partition = NULL; ForceTempsMemory(); if( partly_done == FALSE ) { FixMemRefs(); HaveLiveInfo = FALSE; if( _IsntModel( NO_OPTIMIZATION | FORTRAN_ALIASING ) ) { FindReferences(); CommonSex(FALSE); PushPostOps(); } FindReferences(); DeadTemps(); if( _IsModel( NO_OPTIMIZATION ) ) { SetInOut( HeadBlock ); } else { MakeConflicts(); } MakeLiveInfo(); HaveLiveInfo = TRUE; AxeDeadCode(); FixIndex(); FixSegments(); FPRegAlloc(); RegAlloc( TRUE ); FreeConflicts(); HaveLiveInfo = FALSE; } else { conflist = NULL; owner = &ConfList; for( ;; ) { curr = *owner; if( curr == NULL ) break; if( curr->start_block == HeadBlock ) { *owner = curr->next_conflict; curr->next_conflict = conflist; conflist = curr; } else { owner = &curr->next_conflict; } } curr = ConfList; ConfList = conflist; RegAlloc( TRUE ); FreeConflicts(); ConfList = curr; } input_edges = HeadBlock->input_edges; inputs = HeadBlock->inputs; targets = HeadBlock->targets; HeadBlock->inputs = 0; HeadBlock->input_edges = NULL; HeadBlock->targets = 0; FPParms(); PostOptimize(); HeadBlock->input_edges = input_edges; HeadBlock->inputs = inputs; HeadBlock->targets = targets; /* generate a prolog that saves all registers*/ if( ( CurrProc->prolog_state & GENERATED_PROLOG ) == 0 ) { CurrProc->state.used = AllCacheRegs(); GenProlog(); } id = CurrBlock->id; AssgnMoreTemps( id ); OptSegs(); /* generate the code for the block*/ if( CurrBlock->class & RETURN ) { GenObject(); FiniStackMap(); FreeProc(); } else {