+/*-----------------------------------------------------------------*/
+/* firstDeOf - finds the first definition in seq for op */
+/*-----------------------------------------------------------------*/
+static iCode *firstDefOf (operand *op)
+{
+ int i;
+ iCode *ric=NULL,*lic=NULL;
+ int fSeq = INT_MAX;
+
+ if (!OP_DEFS(op))
+ return NULL;
+
+ for (i=0; i < OP_DEFS(op)->size ;i++) {
+ if (bitVectBitValue(OP_DEFS(op),i) &&
+ (lic = hTabItemWithKey(iCodehTab,i)) &&
+ lic->seq < fSeq) {
+
+ fSeq = lic->seq ;
+ ric = lic;
+ }
+ }
+ return ric;
+}
+/*-----------------------------------------------------------------*/
+/* useDefLoopCheck - check for uses before init inside loops */
+/*-----------------------------------------------------------------*/
+static void useDefLoopCheck(operand *op,iCode *ic)
+{
+ /* this is for situations like the following
+ int a,b;
+
+ while (...) {
+ a = ... ;
+ ...
+ _some_usage_of_b_;
+ ...
+ b = ... ;
+ }
+ in this case the definition of 'b' will flow to the usages
+ but register allocator cannot handle these situations.so
+ will mark as spilt */
+
+ int i =0, fdSeq ;
+ int er=0;
+ iCode *tic ;
+
+ /* get the first definition */
+ if (!(tic = firstDefOf(op)))
+ return ;
+
+ fdSeq = tic->seq;
+ /* now go thru the usages & make sure they follow
+ the first definition */
+ for (i=0; i <= OP_USES(op)->size;i++ ) {
+ if (bitVectBitValue(OP_USES(op),i) &&
+ (tic = hTabItemWithKey(iCodehTab,i)) &&
+ tic->seq < fdSeq){
+ er = 1;
+ break;
+ }
+ }
+
+ /* found a usage without definition */
+ if (er) {
+ if (OP_SYMBOL(op)->isreqv && SPIL_LOC(op) ) {
+
+ werror(W_LOCAL_NOINIT,
+ SPIL_LOC(op)->name,
+ ic->filename,ic->lineno);
+ } else {
+
+ werror(W_LOCAL_NOINIT,
+ OP_SYMBOL(op)->name,
+ ic->filename,ic->lineno);
+ }
+ OP_SYMBOL(op)->isspilt = 1;
+ }
+}
+