#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCLinkerOptimizationHint.h"
+#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCWinEH.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/SMLoc.h"
class MCInstPrinter;
class MCSection;
class MCStreamer;
-class MCSymbol;
+class MCSymbolELF;
class MCSymbolRefExpr;
class MCSubtargetInfo;
class StringRef;
MCTargetStreamer(MCStreamer &S);
virtual ~MCTargetStreamer();
- const MCStreamer &getStreamer() { return Streamer; }
+ MCStreamer &getStreamer() { return Streamer; }
// Allow a target to add behavior to the EmitLabel of MCStreamer.
virtual void emitLabel(MCSymbol *Symbol);
// Allow a target to add behavior to the emitAssignment of MCStreamer.
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value);
- virtual void finish();
-};
-
-class AArch64TargetStreamer : public MCTargetStreamer {
-public:
- AArch64TargetStreamer(MCStreamer &S);
- ~AArch64TargetStreamer() override;
-
- void finish() override;
-
- /// Callback used to implement the ldr= pseudo.
- /// Add a new entry to the constant pool for the current section and return an
- /// MCExpr that can be used to refer to the constant pool location.
- const MCExpr *addConstantPoolEntry(const MCExpr *, unsigned Size);
-
- /// Callback used to implemnt the .ltorg directive.
- /// Emit contents of constant pool for the current section.
- void emitCurrentConstantPool();
-
- /// Callback used to implement the .inst directive.
- virtual void emitInst(uint32_t Inst);
+ virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS,
+ const MCInst &Inst, const MCSubtargetInfo &STI);
-private:
- std::unique_ptr<AssemblerConstantPools> ConstantPools;
+ virtual void finish();
};
// FIXME: declared here because it is used from
void finish() override;
+ /// Reset any state between object emissions, i.e. the equivalent of
+ /// MCStreamer's reset method.
+ virtual void reset();
+
/// Callback used to implement the ldr= pseudo.
/// Add a new entry to the constant pool for the current section and return an
/// MCExpr that can be used to refer to the constant pool location.
- const MCExpr *addConstantPoolEntry(const MCExpr *);
+ const MCExpr *addConstantPoolEntry(const MCExpr *, SMLoc Loc);
/// Callback used to implemnt the .ltorg directive.
/// Emit contents of constant pool for the current section.
return SectionStack.back().first;
return MCSectionSubPair();
}
+ MCSection *getCurrentSectionOnly() const { return getCurrentSection().first; }
/// \brief Return the previous section that the streamer is emitting code to.
MCSectionSubPair getPreviousSection() const {
bool PopSection() {
if (SectionStack.size() <= 1)
return false;
- MCSectionSubPair oldSection = SectionStack.pop_back_val().first;
- MCSectionSubPair curSection = SectionStack.back().first;
-
- if (oldSection != curSection)
- ChangeSection(curSection.first, curSection.second);
+ auto I = SectionStack.end();
+ --I;
+ MCSectionSubPair OldSection = I->first;
+ --I;
+ MCSectionSubPair NewSection = I->first;
+
+ if (OldSection != NewSection)
+ ChangeSection(NewSection.first, NewSection.second);
+ SectionStack.pop_back();
return true;
}
///
/// Each emitted symbol will be tracked in the ordering table,
/// so we can sort on them later.
- void AssignSection(MCSymbol *Symbol, MCSection *Section);
+ void AssignFragment(MCSymbol *Symbol, MCFragment *Fragment);
/// \brief Emit a label for \p Symbol into the current section.
///
/// \brief Marks the end of the symbol definition.
virtual void EndCOFFSymbolDef();
+ virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol);
+
/// \brief Emits a COFF section index.
///
/// \param Symbol - Symbol the section number relocation should point to.
///
/// This corresponds to an assembler statement such as:
/// .size symbol, expression
- virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value);
+ virtual void emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value);
/// \brief Emit a Linker Optimization Hint (LOH) directive.
/// \param Args - Arguments of the LOH.
/// match a native machine width.
/// \param Loc - The location of the expression for error reporting.
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
- const SMLoc &Loc = SMLoc());
+ SMLoc Loc = SMLoc());
- void EmitValue(const MCExpr *Value, unsigned Size,
- const SMLoc &Loc = SMLoc());
+ void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc());
/// \brief Special case of EmitValue that avoids the client having
/// to pass in a MCExpr for constant integers.
/// \brief Emit NumBytes worth of zeros.
/// This function properly handles data in virtual sections.
- virtual void EmitZeros(uint64_t NumBytes);
+ void EmitZeros(uint64_t NumBytes);
/// \brief Emit some number of copies of \p Value until the byte alignment \p
/// ByteAlignment is reached.
/// \param Offset - The offset to reach. This may be an expression, but the
/// expression must be associated with the current section.
/// \param Value - The value to use when filling bytes.
- /// \return false on success, true if the offset was invalid.
- virtual bool EmitValueToOffset(const MCExpr *Offset,
- unsigned char Value = 0);
+ virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value = 0);
/// @}
unsigned Isa, unsigned Discriminator,
StringRef FileName);
- /// Emit the absolute difference between two symbols if possible.
+ /// Emit the absolute difference between two symbols.
///
/// \pre Offset of \c Hi is greater than the offset \c Lo.
- /// \return true on success.
- virtual bool emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo,
- unsigned Size) {
- return false;
- }
+ virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo,
+ unsigned Size);
virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID);
virtual void EmitCFISections(bool EH, bool Debug);
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
virtual void EmitCFIEscape(StringRef Values);
+ virtual void EmitCFIGnuArgsSize(int64_t Size);
virtual void EmitCFISignalFrame();
virtual void EmitCFIUndefined(int64_t Register);
virtual void EmitCFIRegister(int64_t Register1, int64_t Register2);
virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except);
virtual void EmitWinEHHandlerData();
+ virtual void EmitSyntaxDirective();
+
+ /// \brief Emit a .reloc directive.
+ /// Returns true if the relocation could not be emitted because Name is not
+ /// known.
+ virtual bool EmitRelocDirective(const MCExpr &Offset, StringRef Name,
+ const MCExpr *Expr, SMLoc Loc) {
+ return true;
+ }
+
/// \brief Emit the given \p Instruction into the current section.
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);
/// the hasRawTextSupport() predicate. By default this aborts.
void EmitRawText(const Twine &String);
- /// \brief Causes any cached state to be written out.
- virtual void Flush() {}
-
/// \brief Streamer specific finalization.
virtual void FinishImpl();
/// \brief Finish emission of machine code.