1 //===-- llvm/MC/MCAtom.h - MCAtom class ---------------------*- C++ -*-===//
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 // This file contains the declaration of the MCAtom class, which is used to
11 // represent a contiguous region in a decoded object that is uniformly data or
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_MC_MCATOM_H
17 #define LLVM_MC_MCATOM_H
19 #include "llvm/MC/MCInst.h"
20 #include "llvm/Support/DataTypes.h"
27 /// MCData - An entry in a data MCAtom.
28 // NOTE: This may change to a more complex type in the future.
29 typedef uint8_t MCData;
31 /// MCAtom - Represents a contiguous range of either instructions (a TextAtom)
32 /// or data (a DataAtom). Address ranges are expressed as _closed_ intervals.
34 friend class MCModule;
35 typedef enum { TextAtom, DataAtom } AtomType;
41 std::vector<std::pair<uint64_t, MCInst> > Text;
42 std::vector<MCData> Data;
44 // Private constructor - only callable by MCModule
45 MCAtom(AtomType T, MCModule *P, uint64_t B, uint64_t E)
46 : Type(T), Parent(P), Begin(B), End(E) { }
49 bool isTextAtom() { return Type == TextAtom; }
50 bool isDataAtom() { return Type == DataAtom; }
52 void addInst(const MCInst &I, uint64_t Address, unsigned Size);
53 void addData(const MCData &D);
55 /// split - Splits the atom in two at a given address, which must align with
56 /// and instruction boundary if this is a TextAtom. Returns the newly created
57 /// atom representing the high part of the split.
58 MCAtom *split(uint64_t SplitPt);
60 /// truncate - Truncates an atom so that TruncPt is the last byte address
61 /// contained in the atom.
62 void truncate(uint64_t TruncPt);