mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
Revert "Add ADT/IntervalMap.", GCC doesn't like it.
This reverts r119772. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119773 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1,60 +0,0 @@
|
||||
//===- lib/Support/IntervalMap.cpp - A sorted interval map ----------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the few non-templated functions in IntervalMap.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ADT/IntervalMap.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace IntervalMapImpl {
|
||||
|
||||
IdxPair distribute(unsigned Nodes, unsigned Elements, unsigned Capacity,
|
||||
const unsigned *CurSize, unsigned NewSize[],
|
||||
unsigned Position, bool Grow) {
|
||||
assert(Elements + Grow <= Nodes * Capacity && "Not enough room for elements");
|
||||
assert(Position <= Elements && "Invalid position");
|
||||
if (!Nodes)
|
||||
return IdxPair();
|
||||
|
||||
// Trivial algorithm: left-leaning even distribution.
|
||||
const unsigned PerNode = (Elements + Grow) / Nodes;
|
||||
const unsigned Extra = (Elements + Grow) % Nodes;
|
||||
IdxPair PosPair = IdxPair(Nodes, 0);
|
||||
unsigned Sum = 0;
|
||||
for (unsigned n = 0; n != Nodes; ++n) {
|
||||
Sum += NewSize[n] = PerNode + (n < Extra);
|
||||
if (PosPair.first == Nodes && Sum > Position)
|
||||
PosPair = IdxPair(n, Position - (Sum - NewSize[n]));
|
||||
}
|
||||
assert(Sum == Elements + Grow && "Bad distribution sum");
|
||||
|
||||
// Subtract the Grow element that was added.
|
||||
if (Grow) {
|
||||
assert(PosPair.first < Nodes && "Bad algebra");
|
||||
assert(NewSize[PosPair.first] && "Too few elements to need Grow");
|
||||
--NewSize[PosPair.first];
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
Sum = 0;
|
||||
for (unsigned n = 0; n != Nodes; ++n) {
|
||||
assert(NewSize[n] <= Capacity && "Overallocated node");
|
||||
Sum += NewSize[n];
|
||||
}
|
||||
assert(Sum == Elements && "Bad distribution sum");
|
||||
#endif
|
||||
|
||||
return PosPair;
|
||||
}
|
||||
|
||||
} // namespace IntervalMapImpl
|
||||
} // namespace llvm
|
||||
|
Reference in New Issue
Block a user