Save.
authortwisti <none@none>
Wed, 23 Feb 2005 17:03:53 +0000 (17:03 +0000)
committertwisti <none@none>
Wed, 23 Feb 2005 17:03:53 +0000 (17:03 +0000)
src/vm/jit/schedule/schedule.c
src/vm/jit/schedule/schedule.h

index 61bc12046793986adcaed5699b06c71c6523f6e7..bb806a6c1fc56f239cd212f2f045ce97e42ba032 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: schedule.c 1961 2005-02-23 11:47:32Z twisti $
+   $Id: schedule.c 1963 2005-02-23 17:03:53Z twisti $
 
 */
 
@@ -83,7 +83,7 @@ minstruction *schedule_prepend_minstruction(minstruction *mi)
        tmpmi->opdep[0] = NULL;
        tmpmi->opdep[1] = NULL;
        tmpmi->opdep[2] = NULL;
-       tmpmi->sinknode = true;
+       tmpmi->issinknode = true;           /* initially all nodes are sink nodes */
 
        tmpmi->next = mi;                   /* link to next instruction           */
 
@@ -113,9 +113,9 @@ void schedule_calc_priority(minstruction *mi)
                        if (mi->opdep[i]->priority > pathpriority)
                                pathpriority = mi->opdep[i]->priority;
 
-                       /* depedent node is non-sink node */
+                       /* dependent node is non-sink node */
 
-                       mi->opdep[i]->sinknode = false;
+                       mi->opdep[i]->issinknode = false;
                }
        }
 
@@ -132,25 +132,62 @@ void schedule_calc_priority(minstruction *mi)
 void schedule_do_schedule(minstruction *mi)
 {
        minstruction *rootmi;
-       s4 i;
+       sinknode     *rootsn;
+       sinknode     *sn;
+       s4            i;
+       s4            icount;               /* number of basic block instruction  */
+
+       /* initialize variables */
 
        rootmi = mi;
+       rootsn = NULL;
+       icount = 0;
+
+       /* find all sink nodes */
+
+       while (mi) {
+               icount++;
+
+               /* if current node is a sink node, add it to the sink node list */
+
+               if (mi->issinknode) {
+                       sn = DNEW(sinknode);
+                       sn->mi = mi;
+                       sn->next = rootsn;
+                       rootsn = sn;
+               }
+
+               mi = mi->next;
+       }
+
+
+       /* walk through the instructions and do the actual scheduling */
+
+       for (i = 0; i < icount; i++) {
+               sn = rootsn;
+
+               /* first, find the highest priority path */
+
+               while (sn)
+                       sn = sn->next;
+       }
+
 
        printf("bb start ---\n");
 
+       mi = rootmi;
+
        while (mi) {
                printf("%p: ", mi);
 
 /*             disassinstr(&tmpmi->instr); */
                printf("%05x", mi->instr);
 
-               printf("   --> %d, %d, %d:   op1=%p, op2=%p, op3=%p\n", mi->sinknode, mi->latency, mi->priority, mi->opdep[0], mi->opdep[1], mi->opdep[2]);
+               printf("   --> %d, %d, %d:   op1=%p, op2=%p, op3=%p\n", mi->issinknode, mi->latency, mi->priority, mi->opdep[0], mi->opdep[1], mi->opdep[2]);
 
                mi = mi->next;
        }
        printf("bb end ---\n\n");
-
-       
 }
 
 
index 01cceb5f13a5c7aa223529c37fd8bc04a69ae505..3a7f49be28db4e638030ca6d6fe2760f07634729 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: schedule.h 1961 2005-02-23 11:47:32Z twisti $
+   $Id: schedule.h 1963 2005-02-23 17:03:53Z twisti $
 
 */
 
 #include "vm/jit/reg.h"
 
 
+typedef struct scheduledata scheduledata;
+typedef struct minstruction minstruction;
+typedef struct sinknode sinknode;
+
+
+/* scheduledata ****************************************************************
+
+   XXX
+
+*******************************************************************************/
+
+struct scheduledata {
+       minstruction **sink_nodes;          /* list containing sink nodes         */
+       minstruction **intregs_read_dep;
+       minstruction **intregs_write_dep;
+       minstruction **fltregs_read_dep;
+       minstruction **fltregs_write_dep;
+       minstruction *memory_write_dep;
+};
+
+
 /* minstruction ****************************************************************
 
    This structure contains all information for one machine instruction
 
 *******************************************************************************/
 
-typedef struct minstruction minstruction;
-
 struct minstruction {
        u4            instr;                /* machine instruction word           */
        u1            latency;              /* instruction latency                */
        s4            priority;             /* priority of this instruction node  */
        minstruction *opdep[3];             /* operand dependencies               */
-       bool          sinknode;
+       bool          issinknode;
        minstruction *next;                 /* link to next machine instruction   */
 };
 
 
-/* scheduledata ****************************************************************
+/* sinknode ********************************************************************
 
    XXX
 
 *******************************************************************************/
 
-typedef struct scheduledata scheduledata;
-
-struct scheduledata {
-       minstruction **sink_nodes;          /* list containing sink nodes         */
-       minstruction **intregs_read_dep;
-       minstruction **intregs_write_dep;
-       minstruction **fltregs_read_dep;
-       minstruction **fltregs_write_dep;
-       minstruction *memory_write_dep;
+struct sinknode {
+       minstruction *mi;                   /* link to machine instruction        */
+       sinknode     *next;                 /* link to next sink node             */
 };