1//===-- llvm/MC/MCModule.h - MCModule class ---------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the declaration of the MCModule class, which is used to
11// represent a complete, disassembled object file or executable.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_MC_MCMODULE_H
16#define LLVM_MC_MCMODULE_H
17
18#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/IntervalMap.h"
20#include "llvm/ADT/SmallPtrSet.h"
21#include "llvm/Support/DataTypes.h"
22
23namespace llvm {
24
25class MCAtom;
26
27/// MCModule - This class represent a completely disassembled object file or
28/// executable.  It comprises a list of MCAtom's, and a branch target table.
29/// Each atom represents a contiguous range of either instructions or data.
30class MCModule {
31  /// AtomAllocationTracker - An MCModule owns its component MCAtom's, so it
32  /// must track them in order to ensure they are properly freed as atoms are
33  /// merged or otherwise manipulated.
34  SmallPtrSet<MCAtom*, 8> AtomAllocationTracker;
35
36  /// OffsetMap - Efficiently maps offset ranges to MCAtom's.
37  IntervalMap<uint64_t, MCAtom*> OffsetMap;
38
39  /// BranchTargetMap - Maps offsets that are determined to be branches and
40  /// can be statically resolved to their target offsets.
41  DenseMap<uint64_t, MCAtom*> BranchTargetMap;
42
43  friend class MCAtom;
44
45  /// remap - Update the interval mapping for an MCAtom.
46  void remap(MCAtom *Atom, uint64_t NewBegin, uint64_t NewEnd);
47
48public:
49  MCModule(IntervalMap<uint64_t, MCAtom*>::Allocator &A) : OffsetMap(A) { }
50
51  /// createAtom - Creates a new MCAtom covering the specified offset range.
52  MCAtom *createAtom(MCAtom::AtomType Type, uint64_t Begin, uint64_t End);
53};
54
55}
56
57#endif
58
59