return 0;
}
+static inline void eline_mov_before(ScfEfunction* f, intptr_t dst, intptr_t src)
+{
+ ScfEline* el = f->elines[src];
+ intptr_t i;
+
+ for (i = src + 1; i < f->n_elines; i++)
+ f->elines[i - 1] = f->elines[i];
+
+ for (i = f->n_elines - 1; i > dst; i--)
+ f->elines[i] = f->elines[i - 1];
+
+ f->elines[dst] = el;
+}
+
static int __ses_layout_lines4(ScfEfunction* f)
{
scf_vector_t* paths;
ScfEcomponent* B;
ScfEline* el;
ScfEpin* Bp;
+ ScfEpin* Bn;
ScfEpin* p;
intptr_t i;
intptr_t j;
intptr_t k;
+ intptr_t n;
+ intptr_t __n;
paths = scf_vector_alloc();
if (!paths)
B = f->components[0];
Bp = B->pins[SCF_EDA_Battery_POS];
+ Bn = B->pins[SCF_EDA_Battery_NEG];
for (i = 0; i < paths->size; i++) {
Bpath = paths->data[i];
for (j = 0; j < Bpath->pins->size; j += 2) {
p = Bpath->pins->data[j];
- k = __ses_find_eline_index(f, p->lid);
- SCF_XCHG(f->elines[k], f->elines[j / 2]);
+ n = __ses_find_eline_index(f, p->lid);
+ SCF_XCHG(f->elines[n], f->elines[j / 2]);
}
p = Bpath->pins->data[j - 1];
- k = __ses_find_eline_index(f, p->lid);
- SCF_XCHG(f->elines[k], f->elines[j / 2 + 1]);
+ n = __ses_find_eline_index(f, p->lid);
+ SCF_XCHG(f->elines[n], f->elines[j / 2 + 1]);
+
+ for (i = 0; i < paths->size; i++) {
+ path = paths->data[i];
+
+ if (path == Bpath)
+ continue;
+
+ __n = __ses_find_eline_index(f, Bn->lid);
+
+ 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);
+ break;
+ }
+ }
+
+ if (k < 0) {
+ n = __ses_find_eline_index(f, p->lid);
+
+ eline_mov_before(f, __n, n);
+ __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);
+
+ eline_mov_before(f, __n, n);
+ __n = n;
+ }
+ }
ret = 0;
end: