LLVM API Documentation

MCModule.h
Go to the documentation of this file.
00001 //===-- llvm/MC/MCModule.h - MCModule class ---------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the declaration of the MCModule class, which is used to
00011 // represent a complete, disassembled object file or executable.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_MC_MCMODULE_H
00016 #define LLVM_MC_MCMODULE_H
00017 
00018 #include "llvm/ADT/DenseMap.h"
00019 #include "llvm/ADT/IntervalMap.h"
00020 #include "llvm/ADT/SmallPtrSet.h"
00021 #include "llvm/Support/DataTypes.h"
00022 
00023 namespace llvm {
00024 
00025 class MCAtom;
00026 
00027 /// MCModule - This class represent a completely disassembled object file or
00028 /// executable.  It comprises a list of MCAtom's, and a branch target table.
00029 /// Each atom represents a contiguous range of either instructions or data.
00030 class MCModule {
00031   /// AtomAllocationTracker - An MCModule owns its component MCAtom's, so it
00032   /// must track them in order to ensure they are properly freed as atoms are
00033   /// merged or otherwise manipulated.
00034   SmallPtrSet<MCAtom*, 8> AtomAllocationTracker;
00035 
00036   /// OffsetMap - Efficiently maps offset ranges to MCAtom's.
00037   IntervalMap<uint64_t, MCAtom*> OffsetMap;
00038 
00039   /// BranchTargetMap - Maps offsets that are determined to be branches and
00040   /// can be statically resolved to their target offsets.
00041   DenseMap<uint64_t, MCAtom*> BranchTargetMap;
00042 
00043   friend class MCAtom;
00044 
00045   /// remap - Update the interval mapping for an MCAtom.
00046   void remap(MCAtom *Atom, uint64_t NewBegin, uint64_t NewEnd);
00047 
00048 public:
00049   MCModule(IntervalMap<uint64_t, MCAtom*>::Allocator &A) : OffsetMap(A) { }
00050 
00051   /// createAtom - Creates a new MCAtom covering the specified offset range.
00052   MCAtom *createAtom(MCAtom::AtomType Type, uint64_t Begin, uint64_t End);
00053 };
00054 
00055 }
00056 
00057 #endif
00058