68 pObj2 =
Ivy_Multi_rec( ppObjs + nObjs/2, nObjs - nObjs/2, Type );
69 return Ivy_Oper( pObj1, pObj2, Type );
85 static char NumBits[32] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5};
89 int nArgsNew, nEvals, i, k;
98 return Ivy_Oper( pArgsInit[0], pArgsInit[1], Type );
103 for ( i = 0; i < nArgs; i++ )
105 pArgs[i] = pArgsInit[i];
107 pEva->Mask = (1 << i);
118 for ( i = 1; i < nArgsNew; i++ )
119 for ( k = 0; k < i; k++ )
122 pEva = pEvals + nArgsNew;
123 pEva->Mask = pEvals[k].Mask | pEvals[i].Mask;
124 pEva->Weight = NumBits[pEva->Mask];
125 pEva->Cost = pEvals[k].Cost + pEvals[i].Cost + NumBits[pEvals[k].Mask & pEvals[i].Mask];
126 pEva->Level = 1 +
IVY_MAX(pEvals[k].Level, pEvals[i].Level);
131 if ( pEvaBest->Weight < pEva->Weight ||
132 pEvaBest->Weight == pEva->Weight && pEvaBest->Cost > pEva->Cost ||
133 pEvaBest->Weight == pEva->Weight && pEvaBest->Cost == pEva->Cost && pEvaBest->Level > pEva->Level )
136 pArgs[nArgsNew++] = pTemp;
137 if ( nArgsNew == 15 )
145 if ( nArgsNew == nArgs )
151 if ( nArgsNew == nArgs + 1 )
153 assert( pEvaBest - pEvals == nArgs );
155 for ( i = 0; i < nArgs; i++ )
156 if ( i != (
int)pEvaBest->Fan0 && i != (
int)pEvaBest->Fan1 )
157 pArgs[k++] = pArgs[i];
158 pArgs[k++] = pArgs[nArgs];
165 if ( (
int)pEvaBest->Mask == ((1 << nArgs) - 1) )
170 for ( i = 1; i < nArgsNew; i++ )
171 for ( k = 0; k < i; k++ )
173 pEva = pEvals + nEvals;
174 pEva->Mask = pEvals[k].Mask | pEvals[i].Mask;
175 pEva->Weight = NumBits[pEva->Mask];
176 pEva->Cost = pEvals[k].Cost + pEvals[i].Cost + NumBits[pEvals[k].Mask & pEvals[i].Mask];
177 pEva->Level = 1 +
IVY_MAX(pEvals[k].Level, pEvals[i].Level);
181 if ( pEvaBest->Weight < pEva->Weight ||
182 pEvaBest->Weight == pEva->Weight && pEvaBest->Cost > pEva->Cost ||
183 pEvaBest->Weight == pEva->Weight && pEvaBest->Cost == pEva->Cost && pEvaBest->Level > pEva->Level )
188 assert( pEvaBest - pEvals >= nArgsNew );
197 for ( i = 0; i < nArgs; i++ )
198 if ( (pEvaBest->Mask & (1 << i)) == 0 )
199 pArgs[k++] = pArgs[i];
201 assert( k == nArgs - (
int)pEvaBest->Weight + 1 );
225 return Ivy_Oper( pNode0, pNode1, Type );
244 for ( i = 0; i < nArgs-1; i++ )
247 for ( j = i+1; j < nArgs; j++ )
251 pArgs[i] = pArgs[iBest];
252 pArgs[iBest] = pTemp;
272 for ( i = 0; i < nArgs; i++ )
273 if ( pArray[i] == pNode )
276 pArray[nArgs++] = pNode;
278 for ( i = nArgs-1; i > 0; i-- )
281 pNode2 = pArray[i-1];
285 pArray[i-1] = pNode1;
310 return Ivy_Oper( pArgs[0], pArgs[1], Type );
312 pNodeNew =
Ivy_Oper( pArgs[nArgs-1], pArgs[nArgs-2], Type );
333 int nArgsOld = nArgs;
334 for ( i = 0; i < nArgs; i++ )
335 printf(
"%d[%d] ", i,
Ivy_Regular(pArgs[i])->Level );
336 for ( i = 1; i < nArgs; i++ )
337 for ( k = 0; k < i; k++ )
342 printf(
"%d[%d]=(%d,%d) ", nArgs,
Ivy_Regular(pTemp)->Level, k, i );
343 pArgs[nArgs++] = pTemp;
346 printf(
" ((%d/%d)) ", nArgsOld, nArgs-nArgsOld );
366 int i, k, m, nArgsNew,
Counter = 0;
379 for ( i = 0; i < nArgs; i++ )
381 pArgsRef[nArgsNew++] = pArgs[i];
385 for ( i = 0; i < nArgsNew; i++ )
386 for ( k = i + 1; k < nArgsNew; k++ )
393 for ( i = 0; i < nArgsNew; i++ )
394 for ( k = i + 1; k < nArgsNew; k++ )
398 for ( m = 0; m < nArgs; m++ )
399 if ( pArgs[m] != pArgsRef[i] && pArgs[m] != pArgsRef[k] )
400 pArgs[nArgsNew++] = pArgs[m];
401 pArgs[nArgsNew++] = pTemp;
402 assert( nArgsNew == nArgs - 1 );
static Ivy_Obj_t * Ivy_MultiBuild_rec(Ivy_Eval_t *pEvals, int iNum, Ivy_Obj_t **pArgs, int nArgs, Ivy_Type_t Type)
Ivy_Obj_t * Ivy_MultiBalance_rec(Ivy_Obj_t **pArgs, int nArgs, Ivy_Type_t Type)
Ivy_Obj_t * Ivy_Oper(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1, Ivy_Type_t Type)
FUNCTION DEFINITIONS ///.
Ivy_Obj_t * Ivy_Multi_rec(Ivy_Obj_t **ppObjs, int nObjs, Ivy_Type_t Type)
FUNCTION DEFINITIONS ///.
Ivy_Obj_t * Ivy_TableLookup(Ivy_Man_t *p, Ivy_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
static void Ivy_MultiSort(Ivy_Obj_t **pArgs, int nArgs)
Ivy_Obj_t * Ivy_Multi1(Ivy_Obj_t **pArgs, int nArgs, Ivy_Type_t Type)
static int Ivy_ObjRefs(Ivy_Obj_t *pObj)
#define ABC_NAMESPACE_IMPL_END
static Ivy_Obj_t * Ivy_Regular(Ivy_Obj_t *p)
#define ABC_NAMESPACE_IMPL_START
static Ivy_Obj_t * Ivy_ObjCreateGhost(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1, Ivy_Type_t Type, Ivy_Init_t Init)
typedefABC_NAMESPACE_IMPL_START struct Ivy_Eval_t_ Ivy_Eval_t
DECLARATIONS ///.
static Ivy_Obj_t * Ivy_MultiEval(Ivy_Obj_t **pArgs, int nArgs, Ivy_Type_t Type)
Ivy_Obj_t * Ivy_Multi(Ivy_Obj_t **pArgsInit, int nArgs, Ivy_Type_t Type)
Ivy_Obj_t * Ivy_Multi2(Ivy_Obj_t **pArgs, int nArgs, Ivy_Type_t Type)
static int Ivy_MultiPushUniqueOrderByLevel(Ivy_Obj_t **pArray, int nArgs, Ivy_Obj_t *pNode)