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;
23 //---------------------------------------------------------------------------
24 // class TargetMachine
27 // Primary interface to the complete machine description for the
28 // target machine. All target-specific information should be
29 // accessible through this interface.
31 //---------------------------------------------------------------------------
33 class TargetMachine : public NonCopyableV {
35 const std::string TargetName;
36 const TargetData DataLayout; // Calculates type size & alignment
37 int optSizeForSubWordData;
39 int maxAtomicMemOpWordSize;
42 TargetMachine(const std::string &targetname, // Can only create subclasses...
43 unsigned char IntRegSize = 8,
44 unsigned char PtrSize = 8, unsigned char PtrAl = 8,
45 unsigned char DoubleAl = 8, unsigned char FloatAl = 4,
46 unsigned char LongAl = 8, unsigned char IntAl = 4,
47 unsigned char ShortAl = 2, unsigned char ByteAl = 1)
48 : TargetName(targetname), DataLayout(targetname, IntRegSize,
50 DoubleAl, FloatAl, LongAl, IntAl,
53 virtual ~TargetMachine() {}
56 // Interfaces to the major aspects of target machine information:
57 // -- Instruction opcode and operand information
58 // -- Pipelines and scheduling information
59 // -- Register information
60 // -- Stack frame information
61 // -- Cache hierarchy information
62 // -- Machine-level optimization information (peephole only)
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 virtual const MachineCacheInfo& getCacheInfo() const = 0;
69 virtual const MachineOptInfo& getOptInfo() const = 0;
71 // Data storage information
73 virtual unsigned int findOptimalStorageSize (const Type* ty) const;
75 /// addPassesToEmitAssembly - Add passes to the specified pass manager to get
76 /// assembly langage code emited. Typically this will involve several steps
77 /// of code generation. This method should return true if code generation is
80 virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) {
84 /// addPassesToJITCompile - Add passes to the specified pass manager to
85 /// implement a fast dynamic compiler for this target. Return true if this is
86 /// not supported for this target.
88 virtual bool addPassesToJITCompile(PassManager &PM) { return true; }
90 /// getPrologEpilogCodeInserter - Create pass to insert prolog/epilog code.
92 virtual Pass* getPrologEpilogInsertionPass() = 0;
94 /// getFunctionAsmPrinterPass - Create a pass to write out the generated
95 /// machine code for a single function to the generated assembly file.
97 virtual Pass* getFunctionAsmPrinterPass(std::ostream &Out) = 0;
99 /// getModuleAsmPrinterPass - Create a pass to write out module-level
100 /// information to the generated assembly file.
102 virtual Pass* getModuleAsmPrinterPass(std::ostream &Out) = 0;
104 /// getEmitBytecodeToAsmPass - Create a pass to emit the final LLVM bytecode
105 /// to the generated assembly file.
107 virtual Pass* getEmitBytecodeToAsmPass(std::ostream &Out) = 0;