Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.0 KiB

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