TargetMachine.h revision 14e3c4448677595697f300a7de4b185f1398b4bb
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
13class MachineInstrInfo;
14class MachineInstrDescriptor;
15class MachineSchedInfo;
16class MachineRegInfo;
17class MachineFrameInfo;
18class MachineCacheInfo;
19class PassManager;
20
21//---------------------------------------------------------------------------
22// class TargetMachine
23//
24// Purpose:
25//   Primary interface to the complete machine description for the
26//   target machine.  All target-specific information should be
27//   accessible through this interface.
28//
29//---------------------------------------------------------------------------
30
31class TargetMachine : public NonCopyableV {
32public:
33  const std::string TargetName;
34  const TargetData DataLayout;		// Calculates type size & alignment
35  int              optSizeForSubWordData;
36  int	           minMemOpWordSize;
37  int	           maxAtomicMemOpWordSize;
38
39protected:
40  TargetMachine(const std::string &targetname, // Can only create subclasses...
41                unsigned char IntRegSize = 8,
42		unsigned char PtrSize = 8, unsigned char PtrAl = 8,
43		unsigned char DoubleAl = 8, unsigned char FloatAl = 4,
44		unsigned char LongAl = 8, unsigned char IntAl = 4,
45		unsigned char ShortAl = 2, unsigned char ByteAl = 1)
46    : TargetName(targetname), DataLayout(targetname, IntRegSize,
47                                         PtrSize, PtrAl,
48					 DoubleAl, FloatAl, LongAl, IntAl,
49					 ShortAl, ByteAl) { }
50public:
51  virtual ~TargetMachine() {}
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  //
59  virtual const MachineInstrInfo&       getInstrInfo() const = 0;
60  virtual const MachineSchedInfo&       getSchedInfo() const = 0;
61  virtual const MachineRegInfo&	        getRegInfo()   const = 0;
62  virtual const MachineFrameInfo&       getFrameInfo() const = 0;
63  virtual const MachineCacheInfo&       getCacheInfo() const = 0;
64
65  //
66  // Data storage information
67  //
68  virtual unsigned int	findOptimalStorageSize	(const Type* ty) const;
69
70  //
71  // addPassesToEmitAssembly - Add passes to the specified pass manager to get
72  // assembly langage code emited.  Typically this will involve several steps of
73  // code generation.
74  //
75  virtual void addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) = 0;
76};
77
78#endif
79