From 3f4dcd92daef80f87919507b6baf2a97d4bfaa2e Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 22 Mar 2010 23:16:48 +0000 Subject: MC: Add MCInstFragment, not used yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99229 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAssembler.h | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'include/llvm/MC/MCAssembler.h') diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 8a7a785..ff32eb2 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -16,6 +16,7 @@ #include "llvm/ADT/ilist_node.h" #include "llvm/Support/Casting.h" #include "llvm/MC/MCFixup.h" +#include "llvm/MC/MCInst.h" #include "llvm/System/DataTypes.h" #include // FIXME: Shouldn't be needed. @@ -37,6 +38,8 @@ class TargetAsmBackend; /// MCAsmFixup - Represent a fixed size region of bytes inside some fragment /// which needs to be rewritten. This region will either be rewritten by the /// assembler or cause a relocation entry to be generated. +// +// FIXME: This should probably just be merged with MCFixup. class MCAsmFixup { public: /// Offset - The offset inside the fragment which needs to be rewritten. @@ -59,9 +62,10 @@ class MCFragment : public ilist_node { public: enum FragmentType { - FT_Data, FT_Align, + FT_Data, FT_Fill, + FT_Inst, FT_Org, FT_ZeroFill }; @@ -145,7 +149,6 @@ public: const SmallString<32> &getContents() const { return Contents; } /// @} - /// @name Fixup Access /// @{ @@ -177,6 +180,39 @@ public: virtual void dump(); }; +class MCInstFragment : public MCFragment { + /// Inst - The instruction this is a fragment for. + MCInst Inst; + + /// InstSize - The size of the currently encoded instruction. + unsigned InstSize; + +public: + MCInstFragment(MCInst _Inst, unsigned _InstSize, MCSectionData *SD = 0) + : MCFragment(FT_Inst, SD), Inst(_Inst), InstSize(_InstSize) {} + + /// @name Accessors + /// @{ + + unsigned getInstSize() const { return InstSize; } + + const MCInst &getInst() const { return Inst; } + + void setInst(MCInst Inst, unsigned InstSize) { + this->Inst = Inst; + this->InstSize = InstSize; + } + + /// @} + + static bool classof(const MCFragment *F) { + return F->getKind() == MCFragment::FT_Inst; + } + static bool classof(const MCInstFragment *) { return true; } + + virtual void dump(); +}; + class MCAlignFragment : public MCFragment { /// Alignment - The alignment to ensure, in bytes. unsigned Alignment; @@ -623,6 +659,9 @@ private: /// were adjusted. bool LayoutOnce(MCAsmLayout &Layout); + /// FinishLayout - Finalize a layout, including fragment lowering. + void FinishLayout(MCAsmLayout &Layout); + public: /// Find the symbol which defines the atom containing given address, inside /// the given section, or null if there is no such symbol. -- cgit v1.1