Adjust prototype
[oota-llvm.git] / include / llvm / CodeGen / AsmPrinter.h
1 //===-- llvm/CodeGen/AsmPrinter.h - AsmPrinter Framework --------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This class is intended to be used as a base class for target-specific
11 // asmwriters.  This class primarily takes care of printing global constants,
12 // which are printed in a very similar way across all targets.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_CODEGEN_ASMPRINTER_H
17 #define LLVM_CODEGEN_ASMPRINTER_H
18
19 #include "llvm/CodeGen/MachineFunctionPass.h"
20 #include "llvm/Support/DataTypes.h"
21
22 namespace llvm {
23   class Constant;
24   class Mangler;
25
26   class AsmPrinter : public MachineFunctionPass {
27   protected:
28     /// Output stream on which we're printing assembly code.
29     ///
30     std::ostream &O;
31
32     /// Target machine description.
33     ///
34     TargetMachine &TM;
35
36     /// Name-mangler for global names.
37     ///
38     Mangler *Mang;
39
40     /// Cache of mangled name for current function. This is recalculated at the
41     /// beginning of each call to runOnMachineFunction().
42     ///
43     std::string CurrentFnName;
44
45     //===------------------------------------------------------------------===//
46     // Properties to be set by the derived class ctor, used to configure the
47     // asmwriter.
48
49     /// CommentString - This indicates the comment character used by the
50     /// assembler.
51     const char *CommentString;     // Defaults to "#"
52
53     /// GlobalPrefix - If this is set to a non-empty string, it is prepended
54     /// onto all global symbols.  This is often used for "_" or ".".
55     const char *GlobalPrefix;    // Defaults to ""
56
57     /// ZeroDirective - this should be set to the directive used to get some
58     /// number of zero bytes emitted to the current section.  Common cases are
59     /// "\t.zero\t" and "\t.space\t".  If this is set to null, the
60     /// Data*bitsDirective's will be used to emit zero bytes.
61     const char *ZeroDirective;   // Defaults to "\t.zero\t"
62
63     /// AsciiDirective - This directive allows emission of an ascii string with
64     /// the standard C escape characters embedded into it.
65     const char *AsciiDirective;
66     
67     /// DataDirectives - These directives are used to output some unit of
68     /// integer data to the current section.  If a data directive is set to
69     /// null, smaller data directives will be used to emit the large sizes.
70     const char *Data8bitsDirective;   // Defaults to "\t.byte\t"
71     const char *Data16bitsDirective;  // Defaults to "\t.short\t"
72     const char *Data32bitsDirective;  // Defaults to "\t.long\t"
73     const char *Data64bitsDirective;  // Defaults to "\t.quad\t"
74
75     /// AlignDirective - The directive used to emit round up to an alignment
76     /// boundary.
77     ///
78     const char *AlignDirective;       // Defaults to "\t.align\t"
79
80     /// AlignmentIsInBytes - If this is true (the default) then the asmprinter
81     /// emits ".align N" directives, where N is the number of bytes to align to.
82     /// Otherwise, it emits ".align log2(N)", e.g. 3 to align to an 8 byte
83     /// boundary.
84     bool AlignmentIsInBytes;          // Defaults to true
85
86     AsmPrinter(std::ostream &o, TargetMachine &tm)
87       : O(o), TM(tm),
88         CommentString("#"),
89         GlobalPrefix(""),
90         ZeroDirective("\t.zero\t"),
91         AsciiDirective("\t.ascii\t"),
92         Data8bitsDirective("\t.byte\t"),
93         Data16bitsDirective("\t.short\t"),
94         Data32bitsDirective("\t.long\t"),
95         Data64bitsDirective("\t.quad\t"),
96         AlignDirective("\t.align\t"),
97         AlignmentIsInBytes(true) {
98     }
99
100     /// doInitialization - Set up the AsmPrinter when we are working on a new
101     /// module.  If your pass overrides this, it must make sure to explicitly
102     /// call this implementation.
103     bool doInitialization(Module &M);
104
105     /// doFinalization - Shut down the asmprinter.  If you override this in your
106     /// pass, you must make sure to call it explicitly.
107     bool doFinalization(Module &M);
108
109     /// setupMachineFunction - This should be called when a new MachineFunction
110     /// is being processed from runOnMachineFunction.
111     void setupMachineFunction(MachineFunction &MF);
112
113     /// emitAlignment - Emit an alignment directive to the specified power of
114     /// two boundary.  For example, if you pass in 3 here, you will get an 8
115     /// byte alignment.
116     void emitAlignment(unsigned NumBits) const;
117
118     /// emitZeros - Emit a block of zeros.
119     ///
120     void emitZeros(uint64_t NumZeros) const;
121
122     /// emitConstantValueOnly - Print out the specified constant, without a
123     /// storage class.  Only constants of first-class type are allowed here.
124     void emitConstantValueOnly(const Constant *CV);
125
126     /// emitGlobalConstant - Print a general LLVM constant to the .s file.
127     ///
128     void emitGlobalConstant(const Constant* CV);
129   };
130 }
131
132 #endif