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