* Privatize the TargetName
[oota-llvm.git] / include / llvm / Target / TargetMachine.h
1 //===-- llvm/Target/Machine.h - General Target Information -------*- C++ -*-==//
2 //
3 // This file describes the general parts of a Target machine.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef LLVM_TARGET_TARGETMACHINE_H
8 #define LLVM_TARGET_TARGETMACHINE_H
9
10 #include "llvm/Target/TargetData.h"
11 #include "Support/NonCopyable.h"
12
13 class MachineInstrInfo;
14 class MachineInstrDescriptor;
15 class MachineSchedInfo;
16 class MachineRegInfo;
17 class MachineFrameInfo;
18 class MachineCacheInfo;
19 class MachineOptInfo;
20 class PassManager;
21 class Pass;
22
23 //---------------------------------------------------------------------------
24 // class TargetMachine
25 // 
26 // Purpose:
27 //   Primary interface to the complete machine description for the
28 //   target machine.  All target-specific information should be
29 //   accessible through this interface.
30 // 
31 //---------------------------------------------------------------------------
32
33 class TargetMachine : public NonCopyableV {
34   const std::string Name;
35 public:
36   const TargetData DataLayout;          // Calculates type size & alignment
37   
38 protected:
39   TargetMachine(const std::string &name, // Can only create subclasses...
40                 unsigned char SubWordSize = 1, unsigned char IntRegSize = 8,
41                 unsigned char PtrSize = 8, unsigned char PtrAl = 8,
42                 unsigned char DoubleAl = 8, unsigned char FloatAl = 4,
43                 unsigned char LongAl = 8, unsigned char IntAl = 4,
44                 unsigned char ShortAl = 2, unsigned char ByteAl = 1)
45     : Name(name), DataLayout(name, SubWordSize, IntRegSize, PtrSize, PtrAl,
46                              DoubleAl, FloatAl, LongAl,
47                              IntAl, ShortAl, ByteAl) {}
48 public:
49   virtual ~TargetMachine() {}
50
51   const std::string &getName() const { return Name; }
52   
53   // 
54   // Interfaces to the major aspects of target machine information:
55   // -- Instruction opcode and operand information
56   // -- Pipelines and scheduling information
57   // -- Register information
58   // -- Stack frame information
59   // -- Cache hierarchy information
60   // -- Machine-level optimization information (peephole only)
61   // 
62   virtual const MachineInstrInfo&       getInstrInfo() const = 0;
63   virtual const MachineSchedInfo&       getSchedInfo() const = 0;
64   virtual const MachineRegInfo&         getRegInfo()   const = 0;
65   virtual const MachineFrameInfo&       getFrameInfo() const = 0;
66   virtual const MachineCacheInfo&       getCacheInfo() const = 0;
67   virtual const MachineOptInfo&         getOptInfo()   const = 0;
68
69   // Data storage information
70   // 
71   virtual unsigned findOptimalStorageSize(const Type* ty) const;
72   
73   /// addPassesToEmitAssembly - Add passes to the specified pass manager to get
74   /// assembly langage code emited.  Typically this will involve several steps
75   /// of code generation.  This method should return true if code generation is
76   /// not supported.
77   ///
78   virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) {
79     return true;
80   }
81
82   /// addPassesToJITCompile - Add passes to the specified pass manager to
83   /// implement a fast dynamic compiler for this target.  Return true if this is
84   /// not supported for this target.
85   ///
86   virtual bool addPassesToJITCompile(PassManager &PM) { return true; }
87
88   /// getPrologEpilogCodeInserter - Create pass to insert prolog/epilog code.
89   /// 
90   virtual Pass* getPrologEpilogInsertionPass() = 0;
91
92   /// getFunctionAsmPrinterPass - Create a pass to write out the generated
93   /// machine code for a single function to the generated assembly file.
94   /// 
95   virtual Pass* getFunctionAsmPrinterPass(std::ostream &Out) = 0;
96
97   /// getModuleAsmPrinterPass - Create a pass to write out module-level
98   /// information to the generated assembly file.
99   /// 
100   virtual Pass* getModuleAsmPrinterPass(std::ostream &Out) = 0;
101
102   /// getEmitBytecodeToAsmPass - Create a pass to emit the final LLVM bytecode
103   /// to the generated assembly file.
104   /// 
105   virtual Pass* getEmitBytecodeToAsmPass(std::ostream &Out) = 0;
106 };
107
108 #endif