diff options
Diffstat (limited to 'include/llvm/MC')
-rw-r--r-- | include/llvm/MC/MCAssembler.h | 43 | ||||
-rw-r--r-- | include/llvm/MC/MCObjectStreamer.h | 2 | ||||
-rw-r--r-- | include/llvm/MC/MCStreamer.h | 19 |
3 files changed, 57 insertions, 7 deletions
diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index d48a0b40a7..174a755272 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -50,7 +50,8 @@ public: FT_Fill, FT_Inst, FT_Org, - FT_Dwarf + FT_Dwarf, + FT_LEB }; private: @@ -338,6 +339,40 @@ public: static bool classof(const MCOrgFragment *) { return true; } }; +class MCLEBFragment : public MCFragment { + /// Value - The value this fragment should contain. + const MCExpr *Value; + + /// IsSigned - True if this is a sleb128, false if uleb128. + bool IsSigned; + + /// Size - The current size estimate. + uint64_t Size; + +public: + MCLEBFragment(const MCExpr &Value_, bool IsSigned_, MCSectionData *SD) + : MCFragment(FT_LEB, SD), + Value(&Value_), IsSigned(IsSigned_), Size(1) {} + + /// @name Accessors + /// @{ + + const MCExpr &getValue() const { return *Value; } + + bool isSigned() const { return IsSigned; } + + uint64_t getSize() const { return Size; } + + void setSize(uint64_t Size_) { Size = Size_; } + + /// @} + + static bool classof(const MCFragment *F) { + return F->getKind() == MCFragment::FT_LEB; + } + static bool classof(const MCLEBFragment *) { return true; } +}; + class MCDwarfLineAddrFragment : public MCFragment { /// LineDelta - the value of the difference between the two line numbers /// between two .loc dwarf directives. @@ -677,6 +712,12 @@ private: /// were adjusted. bool LayoutOnce(const MCObjectWriter &Writer, MCAsmLayout &Layout); + bool RelaxInstruction(const MCObjectWriter &Writer, MCAsmLayout &Layout, + MCInstFragment &IF); + + bool RelaxLEB(const MCObjectWriter &Writer, MCAsmLayout &Layout, + MCLEBFragment &IF); + /// FinishLayout - Finalize a layout, including fragment lowering. void FinishLayout(MCAsmLayout &Layout); diff --git a/include/llvm/MC/MCObjectStreamer.h b/include/llvm/MC/MCObjectStreamer.h index 3e8b7561e4..8c21c10522 100644 --- a/include/llvm/MC/MCObjectStreamer.h +++ b/include/llvm/MC/MCObjectStreamer.h @@ -60,6 +60,8 @@ public: /// @name MCStreamer Interface /// @{ + virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0); + virtual void EmitSLEB128Value(const MCExpr *Value, unsigned AddrSpace = 0); virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol); virtual void SwitchSection(const MCSection *Section); virtual void EmitInstruction(const MCInst &Inst); diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 53877b1add..fd6e6901ff 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -244,13 +244,20 @@ namespace llvm { virtual void EmitIntValue(uint64_t Value, unsigned Size, unsigned AddrSpace = 0); - /// EmitULEB128Value - Special case of EmitValue that takes an ULEB128 and - /// emits the needed bytes for the encoded value. - virtual void EmitULEB128Value(uint64_t Value, unsigned AddrSpace = 0); - /// EmitSLEB128Value - Special case of EmitValue that takes an SLEB128 and - /// emits the needed bytes for the encoded value. - virtual void EmitSLEB128Value(int64_t Value, unsigned AddrSpace = 0); + virtual void EmitULEB128Value(const MCExpr *Value, + unsigned AddrSpace = 0) = 0; + + virtual void EmitSLEB128Value(const MCExpr *Value, + unsigned AddrSpace = 0) = 0; + + /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the + /// client having to pass in a MCExpr for constant integers. + virtual void EmitULEB128IntValue(uint64_t Value, unsigned AddrSpace = 0); + + /// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the + /// client having to pass in a MCExpr for constant integers. + virtual void EmitSLEB128IntValue(int64_t Value, unsigned AddrSpace = 0); /// EmitSymbolValue - Special case of EmitValue that avoids the client /// having to pass in a MCExpr for MCSymbols. |