1 //===-- llvm/Target/TargetMachine.h - Target Information --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the general parts of a Target machine.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TARGET_TARGETMACHINE_H
15 #define LLVM_TARGET_TARGETMACHINE_H
17 #include "llvm/Target/TargetData.h"
22 class TargetInstrInfo;
23 class TargetInstrDescriptor;
25 class TargetSchedInfo;
27 class TargetFrameInfo;
28 class MachineCodeEmitter;
30 class FunctionPassManager;
33 class IntrinsicLowering;
35 //===----------------------------------------------------------------------===//
37 /// TargetMachine - Primary interface to the complete machine description for
38 /// the target machine. All target-specific information should be accessible
39 /// through this interface.
42 const std::string Name;
43 const TargetData DataLayout; // Calculates type size & alignment
44 IntrinsicLowering *IL; // Specifies how to lower intrinsic calls
46 TargetMachine(const TargetMachine&); // DO NOT IMPLEMENT
47 void operator=(const TargetMachine&); // DO NOT IMPLEMENT
48 protected: // Can only create subclasses...
49 TargetMachine(const std::string &name, IntrinsicLowering *IL,
50 bool LittleEndian = false,
51 unsigned char PtrSize = 8, unsigned char PtrAl = 8,
52 unsigned char DoubleAl = 8, unsigned char FloatAl = 4,
53 unsigned char LongAl = 8, unsigned char IntAl = 4,
54 unsigned char ShortAl = 2, unsigned char ByteAl = 1,
55 unsigned char BoolAl = 1);
57 /// This constructor is used for targets that support arbitrary TargetData
58 /// layouts, like the C backend. It initializes the TargetData to match that
59 /// of the specified module.
61 TargetMachine(const std::string &name, IntrinsicLowering *IL,
64 virtual ~TargetMachine();
66 /// getModuleMatchQuality - This static method should be implemented by
67 /// targets to indicate how closely they match the specified module. This is
68 /// used by the LLC tool to determine which target to use when an explicit
69 /// -march option is not specified. If a target returns zero, it will never
70 /// be chosen without an explicit -march option.
71 static unsigned getModuleMatchQuality(const Module &M) { return 0; }
73 /// getJITMatchQuality - This static method should be implemented by targets
74 /// that provide JIT capabilities to indicate how suitable they are for
75 /// execution on the current host. If a value of 0 is returned, the target
76 /// will not be used unless an explicit -march option is used.
77 static unsigned getJITMatchQuality() { return 0; }
80 const std::string &getName() const { return Name; }
82 /// getIntrinsicLowering - This method returns a reference to an
83 /// IntrinsicLowering instance which should be used by the code generator to
84 /// lower unknown intrinsic functions to the equivalent LLVM expansion.
86 IntrinsicLowering &getIntrinsicLowering() const { return *IL; }
88 // Interfaces to the major aspects of target machine information:
89 // -- Instruction opcode and operand information
90 // -- Pipelines and scheduling information
91 // -- Stack frame information
93 virtual const TargetInstrInfo *getInstrInfo() const { return 0; }
94 virtual const TargetFrameInfo *getFrameInfo() const { return 0; }
95 const TargetData &getTargetData() const { return DataLayout; }
97 /// getRegisterInfo - If register information is available, return it. If
98 /// not, return null. This is kept separate from RegInfo until RegInfo has
99 /// details of graph coloring register allocation removed from it.
101 virtual const MRegisterInfo* getRegisterInfo() const { return 0; }
103 /// getJITInfo - If this target supports a JIT, return information for it,
104 /// otherwise return null.
106 virtual TargetJITInfo *getJITInfo() { return 0; }
108 // These are deprecated interfaces.
109 virtual const TargetSchedInfo *getSchedInfo() const { return 0; }
110 virtual const SparcV9RegInfo *getRegInfo() const { return 0; }
112 /// addPassesToEmitAssembly - Add passes to the specified pass manager to get
113 /// assembly langage code emitted. Typically this will involve several steps
114 /// of code generation. This method should return true if assembly emission
115 /// is not supported.
117 virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) {
121 /// addPassesToEmitMachineCode - Add passes to the specified pass manager to
122 /// get machine code emitted. This uses a MachineCodeEmitter object to handle
123 /// actually outputting the machine code and resolving things like the address
124 /// of functions. This method should returns true if machine code emission is
127 virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
128 MachineCodeEmitter &MCE) {
133 } // End llvm namespace