1 /*-------------------------------------------------------------------------
2 SDCCopt.c - calls all the optimizations routines and does some of the
3 hackier transformations, these include translating iCodes
4 to function calls and replacing local variables with their
5 register equivalents etc. Also contains the driver routine
6 for dead code elimination
8 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998)
10 This program is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by the
12 Free Software Foundation; either version 2, or (at your option) any
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 In other words, you are welcome to use, share and improve this program.
25 You are forbidden to forbid anyone else to use, share and improve
26 what you give them. Help stamp out software-hoarding!
27 -------------------------------------------------------------------------*/
31 /*-----------------------------------------------------------------*/
32 /* global variables */
38 /*-----------------------------------------------------------------*/
39 /* printSymName - prints the symbol names */
40 /*-----------------------------------------------------------------*/
42 printSymName (void *vsym)
45 fprintf (stdout, " %s ", sym->name);
49 /*-----------------------------------------------------------------*/
50 /* cnvToFcall - does the actual conversion to function call */
51 /*-----------------------------------------------------------------*/
53 cnvToFcall (iCode * ic, eBBlock * ebp)
60 int lineno = ic->lineno;
63 ip = ic->next; /* insertion point */
64 /* remove it from the iCode */
65 remiCodeFromeBBlock (ebp, ic);
68 right = IC_RIGHT (ic);
104 /* if float support routines NOT compiled as reentrant */
105 if (!options.float_rent)
109 if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
111 newic = newiCode (SEND, IC_LEFT (ic), NULL);
112 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
116 newic = newiCode ('=', NULL, IC_LEFT (ic));
117 IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
120 addiCodeToeBBlock (ebp, newic, ip);
121 newic->lineno = lineno;
124 if (IS_REGPARM (FUNC_ARGS(func->type)->next->etype))
126 newic = newiCode (SEND, IC_RIGHT (ic), NULL);
127 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->next->etype);
131 newic = newiCode ('=', NULL, IC_RIGHT (ic));
132 IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type)->next);
134 addiCodeToeBBlock (ebp, newic, ip);
135 newic->lineno = lineno;
142 if (IS_REGPARM (FUNC_ARGS(func->type)->next->etype))
144 newic = newiCode (SEND, right, NULL);
145 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->next->etype);
149 newic = newiCode (IPUSH, right, NULL);
152 bytesPushed += getSize(operandType(right));
155 addiCodeToeBBlock (ebp, newic, ip);
156 newic->lineno = lineno;
158 /* insert push left */
159 if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
161 newic = newiCode (SEND, left, NULL);
162 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
166 newic = newiCode (IPUSH, left, NULL);
169 bytesPushed += getSize(operandType(left));
171 addiCodeToeBBlock (ebp, newic, ip);
172 newic->lineno = lineno;
174 /* insert the call */
175 newic = newiCode (CALL, operandFromSymbol (func), NULL);
176 IC_RESULT (newic) = IC_RESULT (ic);
177 newic->lineno = lineno;
178 newic->parmBytes+=bytesPushed;
179 addiCodeToeBBlock (ebp, newic, ip);
182 /*-----------------------------------------------------------------*/
183 /* cnvToFloatCast - converts casts to floats to function calls */
184 /*-----------------------------------------------------------------*/
186 cnvToFloatCast (iCode * ic, eBBlock * ebp)
190 sym_link *type = operandType (IC_RIGHT (ic));
191 int linenno = ic->lineno;
196 /* remove it from the iCode */
197 remiCodeFromeBBlock (ebp, ic);
198 /* depending on the type */
199 for (bwd = 0; bwd < 3; bwd++)
201 for (su = 0; su < 2; su++)
203 if (compareType (type, __multypes[bwd][su]) == 1)
205 func = __conv[0][bwd][su];
213 /* if float support routines NOT compiled as reentrant */
214 if (!options.float_rent)
217 if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
219 newic = newiCode (SEND, IC_RIGHT (ic), NULL);
220 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
224 newic = newiCode ('=', NULL, IC_RIGHT (ic));
225 IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
227 addiCodeToeBBlock (ebp, newic, ip);
228 newic->lineno = linenno;
234 if (IS_REGPARM (FUNC_ARGS(func->type)->etype)) {
235 newic = newiCode (SEND, IC_RIGHT (ic), NULL);
236 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
240 newic = newiCode (IPUSH, IC_RIGHT (ic), NULL);
242 bytesPushed += getSize(operandType(IC_RIGHT(ic)));
244 addiCodeToeBBlock (ebp, newic, ip);
245 newic->lineno = linenno;
250 newic = newiCode (CALL, operandFromSymbol (func), NULL);
251 IC_RESULT (newic) = IC_RESULT (ic);
252 newic->parmBytes+=bytesPushed;
253 addiCodeToeBBlock (ebp, newic, ip);
254 newic->lineno = linenno;
258 /*-----------------------------------------------------------------*/
259 /* cnvFromFloatCast - converts casts From floats to function calls */
260 /*-----------------------------------------------------------------*/
262 cnvFromFloatCast (iCode * ic, eBBlock * ebp)
266 sym_link *type = operandType (IC_LEFT (ic));
267 int lineno = ic->lineno;
272 /* remove it from the iCode */
273 remiCodeFromeBBlock (ebp, ic);
275 /* depending on the type */
276 for (bwd = 0; bwd < 3; bwd++)
278 for (su = 0; su < 2; su++)
280 if (compareType (type, __multypes[bwd][su]) == 1)
282 func = __conv[1][bwd][su];
290 /* if float support routines NOT compiled as reentrant */
291 if (!options.float_rent)
294 if (IS_REGPARM (FUNC_ARGS(func->type)->etype)) {
295 newic = newiCode (SEND, IC_RIGHT (ic), NULL);
296 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
300 newic = newiCode ('=', NULL, IC_RIGHT (ic));
301 IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
303 addiCodeToeBBlock (ebp, newic, ip);
304 newic->lineno = lineno;
311 if (IS_REGPARM (FUNC_ARGS(func->type)->etype)) {
312 newic = newiCode (SEND, IC_RIGHT (ic), NULL);
313 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
317 newic = newiCode (IPUSH, IC_RIGHT (ic), NULL);
319 bytesPushed += getSize(operandType(IC_RIGHT(ic)));
321 addiCodeToeBBlock (ebp, newic, ip);
322 newic->lineno = lineno;
327 newic = newiCode (CALL, operandFromSymbol (func), NULL);
328 IC_RESULT (newic) = IC_RESULT (ic);
329 newic->parmBytes+=bytesPushed;
330 addiCodeToeBBlock (ebp, newic, ip);
331 newic->lineno = lineno;
335 extern operand *geniCodeRValue (operand *, bool);
337 /*-----------------------------------------------------------------*/
338 /* convilong - converts int or long mults or divs to fcalls */
339 /*-----------------------------------------------------------------*/
341 convilong (iCode * ic, eBBlock * ebp, sym_link * type, int op)
344 iCode *ip = ic->next;
346 int lineno = ic->lineno;
351 // Easy special case which avoids function call: modulo by a literal power
352 // of two can be replaced by a bitwise AND.
353 if (op == '%' && isOperandLiteral(IC_RIGHT(ic)))
355 unsigned litVal = (unsigned)(operandLitValue(IC_RIGHT(ic)));
357 // See if literal value is a power of 2.
358 while (litVal && !(litVal & 1))
364 // discard first high bit set.
371 IC_RIGHT(ic) = operandFromLit(operandLitValue(IC_RIGHT(ic)) - 1);
376 remiCodeFromeBBlock (ebp, ic);
379 /* depending on the type */
380 for (bwd = 0; bwd < 3; bwd++)
382 for (su = 0; su < 2; su++)
384 if (compareType (type, __multypes[bwd][su]) == 1)
387 func = __muldiv[0][bwd][su];
389 func = __muldiv[1][bwd][su];
391 func = __muldiv[2][bwd][su];
393 func = __rlrr[1][bwd][su];
395 func = __rlrr[0][bwd][su];
396 else if (op == RIGHT_OP)
397 func = __rlrr[1][bwd][su];
398 else if (op == LEFT_OP)
399 func = __rlrr[0][bwd][su];
408 /* if int & long support routines NOT compiled as reentrant */
409 if (!options.intlong_rent)
412 if (IS_REGPARM (FUNC_ARGS(func->type)->etype)) {
413 newic = newiCode (SEND, IC_LEFT (ic), NULL);
414 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
418 newic = newiCode ('=', NULL, IC_LEFT (ic));
419 IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
421 addiCodeToeBBlock (ebp, newic, ip);
422 newic->lineno = lineno;
425 if (IS_REGPARM (FUNC_ARGS(func->type)->next->etype)) {
426 newic = newiCode (SEND, IC_RIGHT (ic), NULL);
427 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->next->etype);
431 newic = newiCode ('=', NULL, IC_RIGHT (ic));
432 IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type)->next);
434 addiCodeToeBBlock (ebp, newic, ip);
435 newic->lineno = lineno;
440 /* compiled as reentrant then push */
442 if (IS_REGPARM (FUNC_ARGS(func->type)->next->etype))
444 newic = newiCode (SEND, IC_RIGHT (ic), NULL);
445 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->next->etype);
449 newic = newiCode (IPUSH, IC_RIGHT (ic), NULL);
452 bytesPushed += getSize(operandType(IC_RIGHT(ic)));
454 addiCodeToeBBlock (ebp, newic, ip);
455 newic->lineno = lineno;
457 /* insert push left */
458 if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
460 newic = newiCode (SEND, IC_LEFT (ic), NULL);
461 newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
465 newic = newiCode (IPUSH, IC_LEFT (ic), NULL);
468 bytesPushed += getSize(operandType(IC_LEFT(ic)));
470 addiCodeToeBBlock (ebp, newic, ip);
471 newic->lineno = lineno;
476 newic = newiCode (CALL, operandFromSymbol (func), NULL);
477 IC_RESULT (newic) = IC_RESULT (ic);
478 newic->lineno = lineno;
479 newic->parmBytes+=bytesPushed; // to clear the stack after the call
480 addiCodeToeBBlock (ebp, newic, ip);
483 /*-----------------------------------------------------------------*/
484 /* convertToFcall - converts some operations to fcalls */
485 /*-----------------------------------------------------------------*/
487 convertToFcall (eBBlock ** ebbs, int count)
491 /* for all blocks do */
492 for (i = 0; i < count; i++)
496 /* for all instructions in the block do */
497 for (ic = ebbs[i]->sch; ic; ic = ic->next)
500 /* floating point operations are
501 converted to function calls */
502 if ((IS_CONDITIONAL (ic) ||
503 IS_ARITHMETIC_OP (ic)) &&
504 (IS_FLOAT (operandType (IC_RIGHT (ic)))))
507 cnvToFcall (ic, ebbs[i]);
510 /* casting is a little different */
513 if (IS_FLOAT (operandType (IC_RIGHT (ic))))
514 cnvFromFloatCast (ic, ebbs[i]);
515 else if (IS_FLOAT (operandType (IC_LEFT (ic))))
516 cnvToFloatCast (ic, ebbs[i]);
519 /* if long / int mult or divide or mod */
520 if (ic->op == '*' || ic->op == '/' || ic->op == '%')
522 sym_link *leftType = operandType (IC_LEFT (ic));
524 if (IS_INTEGRAL (leftType) && getSize (leftType) > port->support.muldiv)
526 sym_link *rightType = operandType (IC_RIGHT (ic));
528 if (port->hasNativeMulFor != NULL &&
529 port->hasNativeMulFor (ic, leftType, rightType))
531 /* Leave as native */
535 convilong (ic, ebbs[i], leftType, ic->op);
540 if (ic->op == RRC || ic->op == RLC || ic->op == LEFT_OP || ic->op == RIGHT_OP)
542 sym_link *type = operandType (IC_LEFT (ic));
544 if (IS_INTEGRAL (type) && getSize (type) > port->support.shift && port->support.shift >= 0)
546 convilong (ic, ebbs[i], type, ic->op);
553 /*-----------------------------------------------------------------*/
554 /* replaceRegEqv - replace all local variables with their reqv */
555 /*-----------------------------------------------------------------*/
557 replaceRegEqv (eBBlock ** ebbs, int count)
561 for (i = 0; i < count; i++)
566 for (ic = ebbs[i]->sch; ic; ic = ic->next)
575 if (IS_TRUE_SYMOP (IC_COND (ic)) &&
576 OP_REQV (IC_COND (ic)))
577 IC_COND (ic) = opFromOpWithDU (OP_REQV (IC_COND (ic)),
578 OP_SYMBOL (IC_COND (ic))->defs,
579 OP_SYMBOL (IC_COND (ic))->uses);
584 if (ic->op == JUMPTABLE)
586 if (IS_TRUE_SYMOP (IC_JTCOND (ic)) &&
587 OP_REQV (IC_JTCOND (ic)))
588 IC_JTCOND (ic) = opFromOpWithDU (OP_REQV (IC_JTCOND (ic)),
589 OP_SYMBOL (IC_JTCOND (ic))->defs,
590 OP_SYMBOL (IC_JTCOND (ic))->uses);
594 if (ic->op == RECEIVE)
596 if (OP_SYMBOL (IC_RESULT (ic))->addrtaken)
597 OP_SYMBOL (IC_RESULT (ic))->isspilt = 1;
601 if (IC_RESULT (ic) &&
602 IS_TRUE_SYMOP (IC_RESULT (ic)) &&
603 OP_REQV (IC_RESULT (ic)))
605 if (POINTER_SET (ic))
607 IC_RESULT (ic) = opFromOpWithDU (OP_REQV (IC_RESULT (ic)),
608 OP_SYMBOL (IC_RESULT (ic))->defs,
609 OP_SYMBOL (IC_RESULT (ic))->uses);
610 IC_RESULT (ic)->isaddr = 1;
613 IC_RESULT (ic) = opFromOpWithDU (OP_REQV (IC_RESULT (ic)),
614 OP_SYMBOL (IC_RESULT (ic))->defs,
615 OP_SYMBOL (IC_RESULT (ic))->uses);
619 IS_TRUE_SYMOP (IC_RIGHT (ic)) &&
620 OP_REQV (IC_RIGHT (ic)))
622 IC_RIGHT (ic) = opFromOpWithDU (OP_REQV (IC_RIGHT (ic)),
623 OP_SYMBOL (IC_RIGHT (ic))->defs,
624 OP_SYMBOL (IC_RIGHT (ic))->uses);
625 IC_RIGHT (ic)->isaddr = 0;
629 IS_TRUE_SYMOP (IC_LEFT (ic)) &&
630 OP_REQV (IC_LEFT (ic)))
632 IC_LEFT (ic) = opFromOpWithDU (OP_REQV (IC_LEFT (ic)),
633 OP_SYMBOL (IC_LEFT (ic))->defs,
634 OP_SYMBOL (IC_LEFT (ic))->uses);
635 IC_LEFT (ic)->isaddr = 0;
641 /*-----------------------------------------------------------------*/
642 /* killDeadCode - eliminates dead assignments */
643 /*-----------------------------------------------------------------*/
645 killDeadCode (eBBlock ** ebbs, int count)
652 /* basic algorithm :- */
653 /* first the exclusion rules :- */
654 /* 1. if result is a global or volatile then skip */
655 /* 2. if assignment and result is a temp & isaddr then skip */
656 /* since this means array & pointer access, will be taken */
657 /* care of by alias analysis. */
658 /* 3. if the result is used in the remainder of the block skip */
659 /* 4. if this definition does not reach the end of the block */
660 /* i.e. the result is not present in the outExprs then KILL */
661 /* 5. if it reaches the end of block & is used by some success */
664 /* this whole process is carried on iteratively till no change */
669 /* for all blocks do */
670 for (i = 0; i < count; i++)
674 /* for all instructions in the block do */
675 for (ic = ebbs[i]->sch; ic; ic = ic->next)
685 /* if the result is volatile then continue */
686 if (IC_RESULT (ic) && isOperandVolatile (IC_RESULT (ic), FALSE))
689 /* if the result is a temp & isaddr then skip */
690 if (IC_RESULT (ic) && POINTER_SET (ic))
693 /* if the result is used in the remainder of the */
694 /* block then skip */
695 if (usedInRemaining (IC_RESULT (ic), ic->next))
698 /* does this definition reach the end of the block
699 or the usage is zero then we can kill */
700 if (!bitVectBitValue (ebbs[i]->outDefs, ic->key))
701 kill = 1; /* if not we can kill it */
704 /* if this is a global variable or function parameter */
705 /* we cannot kill anyway */
706 if (isOperandGlobal (IC_RESULT (ic)) ||
707 (OP_SYMBOL (IC_RESULT (ic))->_isparm &&
708 !OP_SYMBOL (IC_RESULT (ic))->ismyparm))
711 /* if we are sure there are no usages */
712 if (bitVectIsZero (OP_USES (IC_RESULT (ic))))
718 /* reset visited flag */
719 for (j = 0; j < count; ebbs[j++]->visited = 0);
721 /* find out if this definition is alive */
722 if (applyToSet (ebbs[i]->succList,
731 /* kill this one if required */
737 remiCodeFromeBBlock (ebbs[i], ic);
739 /* now delete from defUseSet */
740 deleteItemIf (&ebbs[i]->outExprs, ifDiCodeIsX, ic);
741 bitVectUnSetBit (ebbs[i]->outDefs, ic->key);
743 /* and defset of the block */
744 bitVectUnSetBit (ebbs[i]->defSet, ic->key);
746 /* for the left & right remove the usage */
747 if (IS_SYMOP (IC_LEFT (ic)))
748 bitVectUnSetBit (OP_USES (IC_LEFT (ic)), ic->key);
750 if (IS_SYMOP (IC_RIGHT (ic)))
751 bitVectUnSetBit (OP_USES (IC_RIGHT (ic)), ic->key);
754 } /* end of all instructions */
756 if (!ebbs[i]->sch && !ebbs[i]->noPath)
757 disconBBlock (ebbs[i], ebbs, count);
759 } /* end of for all blocks */
763 } /* end of while(1) */
768 /*-----------------------------------------------------------------*/
769 /* printCyclomatic - prints the cyclomatic information */
770 /*-----------------------------------------------------------------*/
772 printCyclomatic (eBBlock ** ebbs, int count)
774 int nEdges = elementsInSet (graphEdges);
777 for (i = 0; i < count; i++)
778 nNodes += (!ebbs[i]->noPath);
780 /* print the information */
781 werror (I_CYCLOMATIC, currFunc->name, nEdges, nNodes, nEdges - nNodes + 2);
784 /*-----------------------------------------------------------------*/
785 /* discardDeadParamReceives - remove any RECEIVE opcodes which */
786 /* refer to dead variables. */
787 /*-----------------------------------------------------------------*/
789 discardDeadParamReceives (eBBlock ** ebbs, int count)
795 for (i = 0; i < count; i++)
797 for (ic = ebbs[i]->sch; ic; ic = ic->next)
799 if (ic->op == RECEIVE)
801 if (IC_RESULT (ic) && OP_SYMBOL (IC_RESULT (ic))
802 && !OP_SYMBOL (IC_RESULT (ic))->used)
805 fprintf (stderr, "discarding dead receive for %s\n",
806 OP_SYMBOL (IC_RESULT (ic))->name);
808 dummyIcode.next = ic->next;
809 remiCodeFromeBBlock (ebbs[i], ic);
817 /*-----------------------------------------------------------------*/
818 /* eBBlockFromiCode - creates extended basic blocks from iCode */
819 /* will return an array of eBBlock pointers */
820 /*-----------------------------------------------------------------*/
822 eBBlockFromiCode (iCode * ic)
824 eBBlock **ebbs = NULL;
832 /* if nothing passed then return nothing */
839 /* optimize the chain for labels & gotos
840 this will eliminate redundant labels and
841 will change jump to jumps by jumps */
842 ic = iCodeLabelOptimize (ic);
844 /* break it down into basic blocks */
845 ebbs = iCodeBreakDown (ic, &count);
848 /* compute the control flow */
849 computeControlFlow (ebbs, count, 0);
851 /* dumpraw if asked for */
852 if (options.dump_raw)
853 dumpEbbsToFileExt (DUMP_RAW0, ebbs, count);
855 /* replace the local variables with their
856 register equivalents : the liveRange computation
857 along with the register allocation will determine
858 if it finally stays in the registers */
859 replaceRegEqv (ebbs, count);
861 /* create loop regions */
862 loops = createLoopRegions (ebbs, count);
864 /* dumpraw if asked for */
865 if (options.dump_raw)
866 dumpEbbsToFileExt (DUMP_RAW1, ebbs, count);
868 /* do common subexpression elimination for each block */
869 change = cseAllBlocks (ebbs, saveCount, FALSE);
871 /* dumpraw if asked for */
872 if (options.dump_raw)
873 dumpEbbsToFileExt (DUMP_CSE, ebbs, count);
875 /* compute the data flow */
876 computeDataFlow (ebbs, saveCount);
878 /* dumpraw if asked for */
879 if (options.dump_raw)
880 dumpEbbsToFileExt (DUMP_DFLOW, ebbs, count);
882 /* global common subexpression elimination */
883 if (optimize.global_cse)
885 change += cseAllBlocks (ebbs, saveCount, FALSE);
886 if (options.dump_gcse)
887 dumpEbbsToFileExt (DUMP_GCSE, ebbs, saveCount);
891 // compute the dataflow only
892 assert(cseAllBlocks (ebbs, saveCount, TRUE)==0);
895 kchange = killDeadCode (ebbs, saveCount);
897 if (options.dump_kill)
898 dumpEbbsToFileExt (DUMP_DEADCODE, ebbs, count);
900 /* do loop optimizations */
901 change += (lchange = loopOptimizations (loops, ebbs, count));
902 if (options.dump_loop)
903 dumpEbbsToFileExt (DUMP_LOOP, ebbs, count);
905 /* recompute the data flow and apply global cse again
906 if loops optimizations or dead code caused a change:
907 loops will brings out of the loop which then may be
908 available for use in the later blocks: dead code
909 elimination could potentially disconnect some blocks
910 conditional flow may be efected so we need to apply
911 subexpression once more */
912 if (lchange || kchange)
914 computeDataFlow (ebbs, saveCount);
915 change += cseAllBlocks (ebbs, saveCount, FALSE);
916 if (options.dump_loop)
917 dumpEbbsToFileExt (DUMP_LOOPG, ebbs, count);
919 /* if loop optimizations caused a change then do
920 dead code elimination once more : this will
921 get rid of the extra assignments to the induction
922 variables created during loop optimizations */
923 killDeadCode (ebbs, saveCount);
925 if (options.dump_loop)
926 dumpEbbsToFileExt (DUMP_LOOPD, ebbs, count);
930 /* sort it back by block number */
931 qsort (ebbs, saveCount, sizeof (eBBlock *), bbNumCompare);
933 if (!options.lessPedantic) {
934 // this is a good place to check missing return values
936 // the user is on his own with naked functions...
937 if (!IS_VOID(currFunc->etype)
938 && !FUNC_ISNAKED(currFunc->type)) {
940 // make sure all predecessors of the last block end in a return
941 for (bp=setFirstItem(ebbs[saveCount-1]->predList);
943 bp=setNextItem(ebbs[saveCount-1]->predList)) {
944 if (bp->ech->op != RETURN) {
945 werror (W_VOID_FUNC, currFunc->name);
952 /* if cyclomatic info requested then print it */
953 if (options.cyclomatic)
954 printCyclomatic (ebbs, saveCount);
956 /* convert operations with support routines
957 written in C to function calls : Iam doing
958 this at this point since I want all the
959 operations to be as they are for optimzations */
960 convertToFcall (ebbs, count);
962 /* compute the live ranges */
963 computeLiveRanges (ebbs, count);
965 if (options.dump_range)
966 dumpEbbsToFileExt (DUMP_RANGE, ebbs, count);
968 /* Now that we have the live ranges, discard parameter
969 * receives for unused parameters.
971 discardDeadParamReceives (ebbs, count);
973 /* allocate registers & generate code */
974 port->assignRegisters (ebbs, count);
976 /* throw away blocks */
977 setToNull ((void **) &graphEdges);
984 /* (add-hook 'c-mode-hook (lambda () (setq c-basic-offset 4))) */