1
1
/* ******************************************************************************
2
- * Copyright (c) 2000, 2019 IBM Corp. and others
2
+ * Copyright (c) 2000, 2020 IBM Corp. and others
3
3
*
4
4
* This program and the accompanying materials are made available under
5
5
* the terms of the Eclipse Public License 2.0 which accompanies this
@@ -225,50 +225,48 @@ void TR_InterferenceGraph::virtualRemoveNodeFromIG(TR_IGNode *igNode)
225
225
// Partition the nodes identified by the 'workingSet' bit vector into sets
226
226
// based on their degree.
227
227
//
228
- void TR_InterferenceGraph::partitionNodesIntoDegreeSets (CS2::ABitVector<TR::Allocator> & workingSet,
229
- CS2::ABitVector<TR::Allocator> & colourableDegreeSet,
230
- CS2::ABitVector<TR::Allocator> & notColourableDegreeSet)
228
+ void TR_InterferenceGraph::partitionNodesIntoDegreeSets (TR_BitVector * workingSet,
229
+ TR_BitVector * colourableDegreeSet,
230
+ TR_BitVector * notColourableDegreeSet)
231
231
{
232
232
int32_t i;
233
- CS2::ABitVector<TR::Allocator>::Cursor bvc ( workingSet);
233
+ TR_BitVectorIterator bvi (* workingSet);
234
234
235
235
TR_ASSERT (getNumColours () > 0 ,
236
236
" can't partition without knowing the number of available colours\n " );
237
237
238
238
// Empty the existing degree sets.
239
239
//
240
- colourableDegreeSet.Clear ();
241
- colourableDegreeSet.GrowTo (getNumColours ());
242
- notColourableDegreeSet.Clear ();
243
- notColourableDegreeSet.GrowTo (getNumColours ());
240
+ colourableDegreeSet->empty ();
241
+ notColourableDegreeSet->empty ();
244
242
245
243
// Partition the specified nodes into sets based on their working degree.
246
244
//
247
- for (bvc. SetToFirstOne (); bvc. Valid (); bvc. SetToNextOne ())
248
- {
249
- i = bvc ;
250
-
251
- if (getNodeTable (i)->getWorkingDegree () < getNumColours ())
252
- {
253
- colourableDegreeSet[i] = 1 ;
254
- }
255
- else
256
- {
257
- notColourableDegreeSet[i] = 1 ;
258
- }
259
- }
245
+ while (bvi. hasMoreElements ())
246
+ {
247
+ i = bvi. getNextElement () ;
248
+
249
+ if (getNodeTable (i)->getWorkingDegree () < getNumColours ())
250
+ {
251
+ colourableDegreeSet-> set (i) ;
252
+ }
253
+ else
254
+ {
255
+ notColourableDegreeSet-> set (i) ;
256
+ }
257
+ }
260
258
261
259
#ifdef DEBUG
262
260
if (debug (" traceIG" ))
263
261
{
264
262
diagnostic (" \n Partitioned Nodes\n " );
265
263
diagnostic (" -----------------\n " );
266
264
267
- diagnostic (" \n [%4d] degree < %-10d : " , colourableDegreeSet. PopulationCount (), getNumColours ());
268
- (* comp ()) << colourableDegreeSet ;
265
+ diagnostic (" \n [%4d] degree < %-10d : " , colourableDegreeSet-> elementCount (), getNumColours ());
266
+ colourableDegreeSet-> print ( comp ());
269
267
270
- diagnostic (" \n [%4d] degree < MAX_DEGREE : " , notColourableDegreeSet. PopulationCount ());
271
- (* comp ()) << notColourableDegreeSet ;
268
+ diagnostic (" \n [%4d] degree < MAX_DEGREE : " , notColourableDegreeSet-> elementCount ());
269
+ notColourableDegreeSet-> print ( comp ());
272
270
diagnostic (" \n\n " );
273
271
}
274
272
#endif
@@ -344,13 +342,11 @@ bool TR_InterferenceGraph::simplify()
344
342
345
343
if (getNumNodes ()==0 ) return true ;
346
344
347
- CS2::ABitVector<TR::Allocator> workingSet ( comp ()-> allocator () );
348
- workingSet. SetAll (getNumNodes ());
345
+ TR_BitVector * workingSet = new ( trStackMemory ()) TR_BitVector ( getNumNodes (), trMemory (), stackAlloc );
346
+ workingSet-> setAll (getNumNodes ());
349
347
350
- CS2::ABitVector<TR::Allocator> colourableDegreeSet (comp ()->allocator ());
351
- CS2::ABitVector<TR::Allocator> notColourableDegreeSet (comp ()->allocator ());
352
- colourableDegreeSet.GrowTo (getNumNodes ());
353
- notColourableDegreeSet.GrowTo (getNumNodes ());
348
+ TR_BitVector * colourableDegreeSet = new (trStackMemory ()) TR_BitVector (getNumNodes (), trMemory (), stackAlloc);
349
+ TR_BitVector * notColourableDegreeSet = new (trStackMemory ()) TR_BitVector (getNumNodes (), trMemory (), stackAlloc);
354
350
355
351
for (i=0 ; i<getNumNodes (); i++)
356
352
{
@@ -360,20 +356,20 @@ bool TR_InterferenceGraph::simplify()
360
356
igNode->setColour (UNCOLOURED);
361
357
}
362
358
363
- while (!workingSet. IsZero ())
359
+ while (!workingSet-> isEmpty ())
364
360
{
365
361
partitionNodesIntoDegreeSets (workingSet,colourableDegreeSet,notColourableDegreeSet);
366
362
367
363
// Push nodes from the colourable set onto the stack and adjust the degrees of
368
364
// their neighbours until there are no nodes remaining in the colourable set.
369
365
//
370
- if (!colourableDegreeSet. IsZero ())
366
+ if (!colourableDegreeSet-> isEmpty ())
371
367
{
372
- CS2::ABitVector<TR::Allocator>::Cursor colourableCursor ( colourableDegreeSet);
368
+ TR_BitVectorIterator bvi (* colourableDegreeSet);
373
369
374
- for (colourableCursor. SetToFirstOne (); colourableCursor. Valid (); colourableCursor. SetToNextOne ())
370
+ while (bvi. hasMoreElements ())
375
371
{
376
- igNode = getNodeTable (colourableCursor );
372
+ igNode = getNodeTable (bvi. getNextElement () );
377
373
378
374
if (debug (" traceIG" ))
379
375
{
@@ -382,7 +378,7 @@ bool TR_InterferenceGraph::simplify()
382
378
}
383
379
384
380
virtualRemoveNodeFromIG (igNode);
385
- workingSet[ igNode->getIndex ()] = 0 ;
381
+ workingSet-> reset ( igNode->getIndex ()) ;
386
382
getNodeStack ()->push (igNode);
387
383
}
388
384
@@ -394,21 +390,22 @@ bool TR_InterferenceGraph::simplify()
394
390
// There are no nodes left in the colourable set. Choose a spill candidate among nodes in
395
391
// the non-colourable degree set.
396
392
//
397
- TR_ASSERT (!notColourableDegreeSet. IsZero (),
393
+ TR_ASSERT (!notColourableDegreeSet-> isEmpty (),
398
394
" not colourable set must contain at least one member\n " );
399
395
400
- CS2::ABitVector<TR::Allocator>::Cursor notColourableCursor (notColourableDegreeSet);
401
- if (!notColourableDegreeSet.IsZero ())
396
+ // CS2::ABitVector<TR::Allocator>::Cursor notColourableCursor(notColourableDegreeSet);
397
+ TR_BitVectorIterator bvi;
398
+ if (!notColourableDegreeSet->isEmpty ())
402
399
{
403
400
// Choose the node from this degree set with the largest degree
404
401
// and optimistically push it onto the stack.
405
402
//
406
403
int32_t degree = -1 ;
407
404
408
405
bestSpillNode = NULL ;
409
- for (notColourableCursor. SetToFirstOne (); notColourableCursor. Valid (); notColourableCursor. SetToNextOne ())
406
+ while (bvi. hasMoreElements ())
410
407
{
411
- igNode = getNodeTable (notColourableCursor );
408
+ igNode = getNodeTable (bvi. getNextElement () );
412
409
if (igNode->getDegree () > degree)
413
410
{
414
411
degree = igNode->getDegree ();
@@ -419,7 +416,7 @@ bool TR_InterferenceGraph::simplify()
419
416
TR_ASSERT (bestSpillNode, " Could not find a spill candidate.\n " );
420
417
421
418
virtualRemoveNodeFromIG (bestSpillNode);
422
- workingSet[ bestSpillNode->getIndex ()] = 0 ;
419
+ workingSet-> reset ( bestSpillNode->getIndex ()) ;
423
420
getNodeStack ()->push (bestSpillNode);
424
421
}
425
422
}
@@ -435,18 +432,16 @@ bool TR_InterferenceGraph::select()
435
432
TR_IGNode *igNode;
436
433
TR_BitVectorIterator bvi;
437
434
438
- CS2::ABitVector<TR::Allocator> availableColours (comp ()->allocator ());
439
- CS2::ABitVector<TR::Allocator> assignedColours (comp ()->allocator ());
440
- availableColours.GrowTo (getNumColours ());
441
- assignedColours.GrowTo (getNumColours ());
435
+ TR_BitVector *availableColours = new (trStackMemory ()) TR_BitVector (getNumColours (), trMemory (), stackAlloc);
436
+ TR_BitVector *assignedColours = new (trStackMemory ()) TR_BitVector (getNumColours (), trMemory (), stackAlloc);
442
437
443
438
setNumberOfColoursUsedToColour (0 );
444
439
445
440
while (!getNodeStack ()->isEmpty ())
446
441
{
447
442
igNode = getNodeStack ()->pop ();
448
443
449
- availableColours. SetAll (getNumColours ());
444
+ availableColours-> setAll (getNumColours ());
450
445
451
446
ListIterator<TR_IGNode> iterator (&igNode->getAdjList ());
452
447
TR_IGNode *adjCursor = iterator.getFirst ();
@@ -455,7 +450,7 @@ bool TR_InterferenceGraph::select()
455
450
{
456
451
if (adjCursor->getColour () != UNCOLOURED)
457
452
{
458
- availableColours[ adjCursor->getColour ()] = 0 ;
453
+ availableColours-> reset ( adjCursor->getColour ()) ;
459
454
}
460
455
461
456
adjCursor = iterator.getNext ();
@@ -464,16 +459,21 @@ bool TR_InterferenceGraph::select()
464
459
if (debug (" traceIG" ))
465
460
{
466
461
diagnostic (" SELECT: For IG node #%d (%p), available colours = " , igNode->getIndex (), igNode);
467
- (* comp ()) << availableColours ;
462
+ availableColours-> print (_compilation) ;
468
463
diagnostic (" \n " );
469
464
}
470
465
471
- if (!availableColours.IsZero ())
466
+ bvi.setBitVector (*availableColours);
467
+
468
+ if (bvi.hasMoreElements ())
472
469
{
473
- IGNodeColour colour = (IGNodeColour)availableColours. FirstOne ();
470
+ IGNodeColour colour = (IGNodeColour)bvi. getNextElement ();
474
471
igNode->setColour (colour);
475
472
476
- assignedColours[colour] = 1 ;
473
+ if (!assignedColours->isSet (colour))
474
+ {
475
+ assignedColours->set (colour);
476
+ }
477
477
478
478
if (debug (" traceIG" ))
479
479
{
@@ -493,7 +493,7 @@ bool TR_InterferenceGraph::select()
493
493
}
494
494
}
495
495
496
- setNumberOfColoursUsedToColour (assignedColours. PopulationCount ());
496
+ setNumberOfColoursUsedToColour (assignedColours-> elementCount ());
497
497
return true ;
498
498
}
499
499
0 commit comments