llvm-6502/include/llvm/MC/MCAtom.h
Owen Anderson 124e182103 Start stubbing out MCModule and MCAtom, which provide an API for accessing the rich disassembly of a complete object or executable.
These are very much a work in progress, and not really useful yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140345 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-22 22:32:22 +00:00

76 lines
2.2 KiB
C++

//===-- llvm/MC/MCAtom.h - MCAtom class ---------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the declaration of the MCAtom class, which is used to
// represent a contiguous region in a decoded object that is uniformly data or
// instructions;
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_MC_MCATOM_H
#define LLVM_MC_MCATOM_H
#include "llvm/MC/MCInst.h"
#include "llvm/Support/DataTypes.h"
#include <vector>
namespace llvm {
class MCModule;
/// MCData - An entry in a data MCAtom.
// NOTE: This may change to a more complex type in the future.
typedef uint8_t MCData;
/// MCAtom - Represents a contiguous range of either instructions (a TextAtom)
/// or data (a DataAtom). Address ranges are expressed as _closed_ intervals.
class MCAtom {
friend class MCModule;
typedef enum { TextAtom, DataAtom } AtomType;
AtomType Type;
MCModule *Parent;
uint64_t Begin, End;
std::vector<std::pair<uint64_t, MCInst> > Text;
std::vector<MCData> Data;
// Private constructor - only callable by MCModule
MCAtom(AtomType T, MCModule *P, uint64_t B, uint64_t E)
: Type(T), Parent(P), Begin(B), End(E) { }
public:
bool isTextAtom() { return Type == TextAtom; }
bool isDataAtom() { return Type == DataAtom; }
void addInst(const MCInst &I, uint64_t Address) {
assert(Type == TextAtom && "Trying to add MCInst to a non-text atom!");
Text.push_back(std::make_pair(Address, I));
}
void addData(const MCData &D) {
assert(Type == DataAtom && "Trying to add MCData to a non-data atom!");
Data.push_back(D);
}
/// split - Splits the atom in two at a given address, which must align with
/// and instruction boundary if this is a TextAtom. Returns the newly created
/// atom representing the high part of the split.
MCAtom *split(uint64_t SplitPt);
/// truncate - Truncates an atom so that TruncPt is the last byte address
/// contained in the atom.
void truncate(uint64_t TruncPt);
};
}
#endif