Start sketching MCStreamer interface.
[oota-llvm.git] / include / llvm / MC / MCStreamer.h
1 //===- MCStreamer.h - High-level Streaming Machine Code Output --*- 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 #ifndef LLVM_MC_MCSTREAMER_H
11 #define LLVM_MC_MCSTREAMER_H
12
13 namespace llvm {
14   class MCAtom;
15   class MCContext;
16   class MCImm;
17   class MCInst;
18   class MCSection;
19   class MCSymbol;
20   class raw_ostream;
21
22   /// MCStreamer - Streaming machine code generation interface.
23   class MCStreamer {
24   public:
25     enum SymbolAttr {
26       Global,
27       Weak,
28       PrivateExtern
29     };
30
31   private:
32     MCContext &Context;
33
34     MCStreamer(const MCStreamer&); // DO NOT IMPLEMENT
35     MCStreamer &operator=(const MCStreamer&); // DO NOT IMPLEMENT
36
37   public:
38     MCStreamer(MCContext &Ctx);
39     virtual ~MCStreamer();
40
41     MCContext &getContext() const { return Context; }
42
43     virtual void SwitchSection(MCSection *Sect) = 0;
44
45     virtual void EmitSymbol(MCSymbol *Sym);
46     virtual void EmitSymbolAssignment(MCSymbol *Sym, const MCImm &Value) = 0;
47     virtual void EmitSymbolAttribute(MCSymbol *Sym, 
48                                      SymbolAttr Attr) = 0;
49
50     virtual void EmitBytes(const char *Data, unsigned Length) = 0;
51     virtual void EmitValue(const MCImm &Value, unsigned Size) = 0;
52     virtual void EmitInstruction(const MCInst &Inst) = 0;
53   };
54
55   MCStreamer *createAsmStreamer(MCContext &Ctx, raw_ostream &OS);
56   MCStreamer *createMachOStreamer(MCContext &Ctx, raw_ostream &OS);
57   MCStreamer *createELFStreamer(MCContext &Ctx, raw_ostream &OS);
58
59 } // end namespace llvm
60
61 #endif