__ses_layout_path()
authoryu.dongliang <18588496441@163.com>
Wed, 8 Nov 2023 03:59:12 +0000 (11:59 +0800)
committeryu.dongliang <18588496441@163.com>
Wed, 8 Nov 2023 03:59:12 +0000 (11:59 +0800)
ses_layout.c

index 9e71e315834b99eca66c727c37bcbaf14065652a..1bdcfa7f812a601b18281cb6a8be064e04e074ba 100644 (file)
@@ -558,10 +558,98 @@ static inline void eline_mov_before(ScfEfunction* f, intptr_t dst, intptr_t src)
 
 int _topo_print(scf_vector_t* paths);
 
+static int __ses_layout_path(ScfEfunction* f, ses_path_t* path, ses_path_t* base)
+{
+       ScfEcomponent* c;
+       ScfEline*      el;
+       ScfEpin*       bp;
+       ScfEpin*       p;
+       ScfEpin*       pc;
+       ScfEpin*       pe;
+
+       intptr_t j;
+       intptr_t k;
+       intptr_t n;
+       intptr_t __n;
+
+       bp  = base->pins->data[base->pins->size - 1];
+       __n = __ses_find_eline_index(f, bp->lid);
+
+       scf_logd("path: %d, __n: %ld, l%ld\n", path->index, __n, f->elines[__n]->id);
+
+       for (j = path->pins->size - 1; j > 0; j -= 2) {
+               p  = path->pins->data[j];
+
+               for (k = base->pins->size - 1; k >= 0; k--) {
+                       bp = base->pins->data[k];
+
+                       if (p->lid == bp->lid) {
+                               __n = __ses_find_eline_index(f, bp->lid);
+
+                               scf_logw("__n: %ld, l%ld\n", __n, f->elines[__n]->id);
+                               break;
+                       }
+               }
+
+               if (k < 0) {
+                       n  = __ses_find_eline_index(f, p->lid);
+
+                       if (SCF_EDA_NPN == p->cid && SCF_EDA_NPN_B == p->id) {
+                               c  = f->components[p->cid];
+                               pc = c->pins[SCF_EDA_NPN_C];
+                               pe = c->pins[SCF_EDA_NPN_E];
+
+                               intptr_t ic = __ses_find_eline_index(f, pc->lid);
+                               intptr_t ie = __ses_find_eline_index(f, pe->lid);
+
+                               if (ic > ie)
+                                       __n = ic;
+                               else
+                                       __n = ie;
+
+                               scf_loge("c%ldp%ld, ic: %ld, ie: %ld\n", p->cid, p->id, ic, ie);
+                       }
+
+                       eline_mov_before(f, __n, n);
+               }
+       }
+
+       p = path->pins->data[0];
+
+       for (k = base->pins->size - 1; k >= 0; k--) {
+               bp = base->pins->data[k];
+
+               if (p->lid == bp->lid) {
+                       __n = __ses_find_eline_index(f, bp->lid);
+                       break;
+               }
+       }
+
+       if (k < 0) {
+               n  = __ses_find_eline_index(f, p->lid);
+
+               if (SCF_EDA_NPN == p->cid && SCF_EDA_NPN_B == p->id) {
+                       c  = f->components[p->cid];
+                       pc = c->pins[SCF_EDA_NPN_C];
+                       pe = c->pins[SCF_EDA_NPN_E];
+
+                       intptr_t ic = __ses_find_eline_index(f, pc->lid);
+                       intptr_t ie = __ses_find_eline_index(f, pe->lid);
+                       if (ic > ie)
+                               __n = ic;
+                       else
+                               __n = ie;
+                       scf_loge("c%ldp%ld, ic: %ld, ie: %ld\n", p->cid, p->id, ic, ie);
+               }
+
+               eline_mov_before(f, __n, n);
+       }
+}
+
 static int __ses_layout_lines4(ScfEfunction* f)
 {
        scf_vector_t*  paths;
-       ses_path_t*    Bpath;
+       ses_path_t*    base;
        ses_path_t*    path;
 
        ScfEcomponent* B;
@@ -596,9 +684,9 @@ static int __ses_layout_lines4(ScfEfunction* f)
        Bn = B->pins[SCF_EDA_Battery_NEG];
 
        for (i = 0; i < paths->size; i++) {
-               Bpath     = paths->data[i];
+               base      = paths->data[i];
 
-               p = Bpath->pins->data[0];
+               p = base->pins->data[0];
                if (p->lid == Bp->lid)
                        break;
        }
@@ -606,14 +694,14 @@ static int __ses_layout_lines4(ScfEfunction* f)
        if (i >= paths->size)
                goto end;
 
-       for (j = 0; j < Bpath->pins->size; j += 2) {
-               p  =        Bpath->pins->data[j];
+       for (j = 0; j < base->pins->size; j += 2) {
+               p  =        base->pins->data[j];
 
                n  = __ses_find_eline_index(f, p->lid);
                SCF_XCHG(f->elines[n], f->elines[j / 2]);
        }
 
-       p = Bpath->pins->data[j - 1];
+       p = base->pins->data[j - 1];
        n = __ses_find_eline_index(f, p->lid);
        SCF_XCHG(f->elines[n], f->elines[j / 2 + 1]);
        scf_logd("j: %ld, l%ld\n", j / 2 + 1, f->elines[j / 2 + 1]->id);
@@ -621,80 +709,10 @@ static int __ses_layout_lines4(ScfEfunction* f)
        for (i = 0; i < paths->size; i++) {
                path      = paths->data[i];
 
-               if (path == Bpath)
+               if (path == base)
                        continue;
 
-               __n = __ses_find_eline_index(f, Bn->lid);
-               scf_logd("path: %d, __n: %ld, l%ld\n", path->index, __n, f->elines[__n]->id);
-
-               for (j = path->pins->size - 1; j > 0; j -= 2) {
-                       p  = path->pins->data[j];
-
-                       for (k = Bpath->pins->size - 1; k >= 0; k--) {
-                               Bp = Bpath->pins->data[k];
-
-                               if (p->lid == Bp->lid) {
-                                       __n = __ses_find_eline_index(f, Bp->lid);
-
-                                       scf_logw("__n: %ld, l%ld\n", __n, f->elines[__n]->id);
-                                       break;
-                               }
-                       }
-
-                       if (k < 0) {
-                               n  = __ses_find_eline_index(f, p->lid);
-
-                               if (SCF_EDA_NPN == p->cid && SCF_EDA_NPN_B == p->id) {
-                                       c  = f->components[p->cid];
-                                       pc = c->pins[SCF_EDA_NPN_C];
-                                       pe = c->pins[SCF_EDA_NPN_E];
-
-                                       intptr_t ic = __ses_find_eline_index(f, pc->lid);
-                                       intptr_t ie = __ses_find_eline_index(f, pe->lid);
-
-                                       if (ic > ie)
-                                               __n = ic;
-                                       else
-                                               __n = ie;
-
-                                       scf_loge("c%ldp%ld, ic: %ld, ie: %ld\n", p->cid, p->id, ic, ie);
-                               }
-
-                               eline_mov_before(f, __n, n);
-                       }
-               }
-
-               p = path->pins->data[0];
-
-               for (k = Bpath->pins->size - 1; k >= 0; k--) {
-                       Bp = Bpath->pins->data[k];
-
-                       if (p->lid == Bp->lid) {
-                               __n = __ses_find_eline_index(f, Bp->lid);
-                               break;
-                       }
-               }
-
-               if (k < 0) {
-                       n  = __ses_find_eline_index(f, p->lid);
-
-                       if (SCF_EDA_NPN == p->cid && SCF_EDA_NPN_B == p->id) {
-                               c  = f->components[p->cid];
-                               pc = c->pins[SCF_EDA_NPN_C];
-                               pe = c->pins[SCF_EDA_NPN_E];
-
-                               intptr_t ic = __ses_find_eline_index(f, pc->lid);
-                               intptr_t ie = __ses_find_eline_index(f, pe->lid);
-                               if (ic > ie)
-                                       __n = ic;
-                               else
-                                       __n = ie;
-                               scf_loge("c%ldp%ld, ic: %ld, ie: %ld\n", p->cid, p->id, ic, ie);
-                       }
-
-                       eline_mov_before(f, __n, n);
-               }
-               printf("\n");
+               __ses_layout_path(f, path, base);
        }
 
        ret = 0;