1 //===-- llvm/Target/Machine.h - General Target Information -------*- C++ -*-==//
3 // This file describes the general parts of a Target machine.
5 //===----------------------------------------------------------------------===//
7 #ifndef LLVM_TARGET_TARGETMACHINE_H
8 #define LLVM_TARGET_TARGETMACHINE_H
10 #include "llvm/Target/TargetData.h"
11 #include "Support/NonCopyable.h"
13 class MachineInstrInfo;
14 class MachineInstrDescriptor;
15 class MachineSchedInfo;
17 class MachineFrameInfo;
18 class MachineCacheInfo;
22 //---------------------------------------------------------------------------
23 // class TargetMachine
26 // Primary interface to the complete machine description for the
27 // target machine. All target-specific information should be
28 // accessible through this interface.
30 //---------------------------------------------------------------------------
32 class TargetMachine : public NonCopyableV {
34 const std::string TargetName;
35 const TargetData DataLayout; // Calculates type size & alignment
36 int optSizeForSubWordData;
38 int maxAtomicMemOpWordSize;
41 TargetMachine(const std::string &targetname, // Can only create subclasses...
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, PtrSize, PtrAl,
47 DoubleAl, FloatAl, LongAl, IntAl,
50 virtual ~TargetMachine() {}
53 // Interfaces to the major aspects of target machine information:
54 // -- Instruction opcode and operand information
55 // -- Pipelines and scheduling information
56 // -- Register information
58 virtual const MachineInstrInfo& getInstrInfo() const = 0;
59 virtual const MachineSchedInfo& getSchedInfo() const = 0;
60 virtual const MachineRegInfo& getRegInfo() const = 0;
61 virtual const MachineFrameInfo& getFrameInfo() const = 0;
62 virtual const MachineCacheInfo& getCacheInfo() const = 0;
65 // Data storage information
67 virtual unsigned int findOptimalStorageSize (const Type* ty) const;
70 // compileMethod - Everything neccesary to compile a method into the
71 // built in representation. This allows the target to have complete control
72 // over how it does compilation. This does not emit assembly or output
73 // machine code, however; those are done later.
75 virtual bool compileMethod(Method *M) = 0;
78 // emitAssembly - Output assembly language code (a .s file) for the specified
79 // method. The specified method must have been compiled before this may be
82 virtual void emitAssembly(const Method *M, std::ostream &OutStr) const = 0;
85 // emitAssembly - Output assembly language code (a .s file) for global
86 // components of the specified module. This assumes that methods have been
89 virtual void emitAssembly(const Module *M, std::ostream &OutStr) const = 0;
92 // freeCompiledMethod - Release all memory associated with the compiled image
95 virtual void freeCompiledMethod(Method *M) = 0;