[llvm-commits] [llvm] r73994 - in /llvm/trunk/include/llvm/MC: MCContext.h MCStreamer.h

Daniel Dunbar daniel at zuster.org
Tue Jun 23 13:24:18 PDT 2009


Author: ddunbar
Date: Tue Jun 23 15:24:17 2009
New Revision: 73994

URL: http://llvm.org/viewvc/llvm-project?rev=73994&view=rev
Log:
Start sketching MCStreamer interface.

Added:
    llvm/trunk/include/llvm/MC/MCContext.h
    llvm/trunk/include/llvm/MC/MCStreamer.h

Added: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=73994&view=auto

==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (added)
+++ llvm/trunk/include/llvm/MC/MCContext.h Tue Jun 23 15:24:17 2009
@@ -0,0 +1,41 @@
+//===- MCContext.h - Machine Code Context -----------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_MC_MCCONTEXT_H
+#define LLVM_MC_MCCONTEXT_H
+
+namespace llvm {
+  class MCAtom;
+  class MCImm;
+  class MCSection;
+  class MCSymbol;
+
+  /// MCContext - Context object for machine code objects.
+  class MCContext {
+    MCContext(const MCContext&); // DO NOT IMPLEMENT
+    MCContext &operator=(const MCContext&); // DO NOT IMPLEMENT
+
+  public:
+    MCContext();
+    ~MCContext();
+
+    MCSection *GetSection(const char *Name);
+    MCAtom *CreateAtom(MCSection *Section);
+    MCSymbol *CreateSymbol(MCAtom *Atom,
+                           const char *Name,
+                           bool IsTemporary);
+    MCSymbol *LookupSymbol(const char *Name) const;
+
+    void SetSymbolValue(MCSymbol *Sym, const MCImm &Value);
+    const MCImm &GetSymbolValue(MCSymbol *Sym) const;
+  };
+
+} // end namespace llvm
+
+#endif

Added: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=73994&view=auto

==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (added)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Tue Jun 23 15:24:17 2009
@@ -0,0 +1,61 @@
+//===- MCStreamer.h - High-level Streaming Machine Code Output --*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_MC_MCSTREAMER_H
+#define LLVM_MC_MCSTREAMER_H
+
+namespace llvm {
+  class MCAtom;
+  class MCContext;
+  class MCImm;
+  class MCInst;
+  class MCSection;
+  class MCSymbol;
+  class raw_ostream;
+
+  /// MCStreamer - Streaming machine code generation interface.
+  class MCStreamer {
+  public:
+    enum SymbolAttr {
+      Global,
+      Weak,
+      PrivateExtern
+    };
+
+  private:
+    MCContext &Context;
+
+    MCStreamer(const MCStreamer&); // DO NOT IMPLEMENT
+    MCStreamer &operator=(const MCStreamer&); // DO NOT IMPLEMENT
+
+  public:
+    MCStreamer(MCContext &Ctx);
+    virtual ~MCStreamer();
+
+    MCContext &getContext() const { return Context; }
+
+    virtual void SwitchSection(MCSection *Sect) = 0;
+
+    virtual void EmitSymbol(MCSymbol *Sym);
+    virtual void EmitSymbolAssignment(MCSymbol *Sym, const MCImm &Value) = 0;
+    virtual void EmitSymbolAttribute(MCSymbol *Sym, 
+                                     SymbolAttr Attr) = 0;
+
+    virtual void EmitBytes(const char *Data, unsigned Length) = 0;
+    virtual void EmitValue(const MCImm &Value, unsigned Size) = 0;
+    virtual void EmitInstruction(const MCInst &Inst) = 0;
+  };
+
+  MCStreamer *createAsmStreamer(MCContext &Ctx, raw_ostream &OS);
+  MCStreamer *createMachOStreamer(MCContext &Ctx, raw_ostream &OS);
+  MCStreamer *createELFStreamer(MCContext &Ctx, raw_ostream &OS);
+
+} // end namespace llvm
+
+#endif





More information about the llvm-commits mailing list