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