Add emitAssembly Method
[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 "llvm/Support/NonCopyable.h"
12
13 class TargetMachine;
14 class MachineInstrInfo;
15 class MachineInstrDescriptor;
16 class MachineSchedInfo;
17 class MachineRegInfo;
18
19 //---------------------------------------------------------------------------
20 // Data types used to define information about a single machine instruction
21 //---------------------------------------------------------------------------
22
23 typedef int MachineOpCode;
24 typedef int OpCodeMask;
25
26
27 //---------------------------------------------------------------------------
28 // class TargetMachine
29 // 
30 // Purpose:
31 //   Primary interface to the complete machine description for the
32 //   target machine.  All target-specific information should be
33 //   accessible through this interface.
34 // 
35 //---------------------------------------------------------------------------
36
37 class TargetMachine : public NonCopyableV {
38 public:
39   const string     TargetName;
40   const TargetData DataLayout;          // Calculates type size & alignment
41   int              optSizeForSubWordData;
42   int              minMemOpWordSize;
43   int              maxAtomicMemOpWordSize;
44   
45 protected:
46   TargetMachine(const string &targetname, // Can only create subclasses...
47                 unsigned char PtrSize = 8, unsigned char PtrAl = 8,
48                 unsigned char DoubleAl = 8, unsigned char FloatAl = 4,
49                 unsigned char LongAl = 8, unsigned char IntAl = 4,
50                 unsigned char ShortAl = 2, unsigned char ByteAl = 1)
51     : TargetName(targetname), DataLayout(targetname, PtrSize, PtrAl,
52                                          DoubleAl, FloatAl, LongAl, IntAl, 
53                                          ShortAl, ByteAl) { }
54 public:
55   virtual ~TargetMachine() {}
56   
57   // 
58   // Interfaces to the major aspects of target machine information:
59   // -- Instruction opcode and operand information
60   // -- Pipelines and scheduling information
61   // -- Register information
62   // 
63   virtual const MachineInstrInfo&       getInstrInfo() const = 0;
64   virtual const MachineSchedInfo&       getSchedInfo() const = 0;
65   virtual const MachineRegInfo&         getRegInfo()   const = 0;
66   
67   //
68   // Data storage information
69   // 
70   virtual unsigned int  findOptimalStorageSize  (const Type* ty) const;
71   
72   //
73   // compileMethod - Everything neccesary to compile a method into the
74   // built in representation.  This allows the target to have complete control
75   // over how it does compilation.  This does not emit assembly or output
76   // machine code, however; those are done later.
77   //
78   virtual bool compileMethod(Method *M) = 0;
79
80   //
81   // emitAssembly - Output assembly language code (a .s file) for the specified
82   // method. The specified method must have been compiled before this may be
83   // used.
84   //
85   virtual void emitAssembly(const Module *M, ostream &OutStr) = 0;
86 };
87
88 #endif