1
//===- lib/MC/MCModule.cpp - MCModule implementation ----------------------===//
3
// The LLVM Compiler Infrastructure
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
8
//===----------------------------------------------------------------------===//
10
#include "llvm/MC/MCAtom.h"
11
#include "llvm/MC/MCModule.h"
15
MCAtom *MCModule::createAtom(MCAtom::AtomType Type,
16
uint64_t Begin, uint64_t End) {
17
assert(Begin < End && "Creating MCAtom with endpoints reversed?");
19
// Check for atoms already covering this range.
20
IntervalMap<uint64_t, MCAtom*>::iterator I = OffsetMap.find(Begin);
21
assert((!I.valid() || I.start() < End) && "Offset range already occupied!");
23
// Create the new atom and add it to our maps.
24
MCAtom *NewAtom = new MCAtom(Type, this, Begin, End);
25
AtomAllocationTracker.insert(NewAtom);
26
OffsetMap.insert(Begin, End, NewAtom);
30
// remap - Update the interval mapping for an atom.
31
void MCModule::remap(MCAtom *Atom, uint64_t NewBegin, uint64_t NewEnd) {
32
// Find and erase the old mapping.
33
IntervalMap<uint64_t, MCAtom*>::iterator I = OffsetMap.find(Atom->Begin);
34
assert(I.valid() && "Atom offset not found in module!");
35
assert(*I == Atom && "Previous atom mapping was invalid!");
38
// Insert the new mapping.
39
OffsetMap.insert(NewBegin, NewEnd, Atom);
41
// Update the atom internal bounds.
42
Atom->Begin = NewBegin;