2003-09-30 20:37:50 +02:00
|
|
|
//===-- llvm/Target/TargetMachine.h - Target Information --------*- C++ -*-===//
|
2003-10-20 22:19:47 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-09-18 14:38:31 +02:00
|
|
|
//
|
|
|
|
// This file describes the general parts of a Target machine.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TARGET_TARGETMACHINE_H
|
|
|
|
#define LLVM_TARGET_TARGETMACHINE_H
|
|
|
|
|
|
|
|
#include "llvm/Target/TargetData.h"
|
2003-10-20 17:14:33 +02:00
|
|
|
#include <cassert>
|
2001-09-18 14:38:31 +02:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2003-01-13 01:21:32 +01:00
|
|
|
class TargetInstrInfo;
|
|
|
|
class TargetInstrDescriptor;
|
2003-12-20 02:22:19 +01:00
|
|
|
class TargetJITInfo;
|
2002-12-29 04:13:05 +01:00
|
|
|
class TargetSchedInfo;
|
2004-06-03 04:45:09 +02:00
|
|
|
class SparcV9RegInfo;
|
2002-12-28 21:13:29 +01:00
|
|
|
class TargetFrameInfo;
|
2002-12-02 22:00:50 +01:00
|
|
|
class MachineCodeEmitter;
|
2002-10-30 01:53:02 +01:00
|
|
|
class MRegisterInfo;
|
2003-08-13 20:17:27 +02:00
|
|
|
class FunctionPassManager;
|
2002-04-28 22:40:25 +02:00
|
|
|
class PassManager;
|
2002-09-16 17:39:35 +02:00
|
|
|
class Pass;
|
2003-12-28 22:23:38 +01:00
|
|
|
class IntrinsicLowering;
|
2001-09-18 14:38:31 +02:00
|
|
|
|
2002-12-28 21:13:29 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// TargetMachine - Primary interface to the complete machine description for
|
|
|
|
/// the target machine. All target-specific information should be accessible
|
|
|
|
/// through this interface.
|
|
|
|
///
|
2003-06-03 17:28:40 +02:00
|
|
|
class TargetMachine {
|
2002-10-29 22:48:17 +01:00
|
|
|
const std::string Name;
|
2003-12-28 22:23:38 +01:00
|
|
|
const TargetData DataLayout; // Calculates type size & alignment
|
|
|
|
IntrinsicLowering *IL; // Specifies how to lower intrinsic calls
|
2001-09-18 14:38:31 +02:00
|
|
|
|
2003-06-03 17:28:40 +02:00
|
|
|
TargetMachine(const TargetMachine&); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const TargetMachine&); // DO NOT IMPLEMENT
|
2003-12-28 22:23:38 +01:00
|
|
|
protected: // Can only create subclasses...
|
|
|
|
TargetMachine(const std::string &name, IntrinsicLowering *IL,
|
2004-07-01 22:42:00 +02:00
|
|
|
bool LittleEndian = false,
|
|
|
|
unsigned char PtrSize = 8, unsigned char PtrAl = 8,
|
|
|
|
unsigned char DoubleAl = 8, unsigned char FloatAl = 4,
|
|
|
|
unsigned char LongAl = 8, unsigned char IntAl = 4,
|
2004-07-23 03:08:13 +02:00
|
|
|
unsigned char ShortAl = 2, unsigned char ByteAl = 1,
|
|
|
|
unsigned char BoolAl = 1);
|
2004-03-03 03:12:47 +01:00
|
|
|
|
2004-08-11 01:10:21 +02:00
|
|
|
TargetMachine(const std::string &name, IntrinsicLowering *IL,
|
|
|
|
const TargetData &TD);
|
|
|
|
|
2004-07-01 22:42:00 +02:00
|
|
|
/// This constructor is used for targets that support arbitrary TargetData
|
|
|
|
/// layouts, like the C backend. It initializes the TargetData to match that
|
|
|
|
/// of the specified module.
|
|
|
|
///
|
2004-03-03 03:12:47 +01:00
|
|
|
TargetMachine(const std::string &name, IntrinsicLowering *IL,
|
|
|
|
const Module &M);
|
2001-09-18 14:38:31 +02:00
|
|
|
public:
|
2003-12-28 22:23:38 +01:00
|
|
|
virtual ~TargetMachine();
|
2002-10-29 22:12:46 +01:00
|
|
|
|
2004-07-11 04:43:07 +02:00
|
|
|
/// getModuleMatchQuality - This static method should be implemented by
|
|
|
|
/// targets to indicate how closely they match the specified module. This is
|
|
|
|
/// used by the LLC tool to determine which target to use when an explicit
|
|
|
|
/// -march option is not specified. If a target returns zero, it will never
|
|
|
|
/// be chosen without an explicit -march option.
|
|
|
|
static unsigned getModuleMatchQuality(const Module &M) { return 0; }
|
|
|
|
|
|
|
|
/// getJITMatchQuality - This static method should be implemented by targets
|
|
|
|
/// that provide JIT capabilities to indicate how suitable they are for
|
|
|
|
/// execution on the current host. If a value of 0 is returned, the target
|
|
|
|
/// will not be used unless an explicit -march option is used.
|
|
|
|
static unsigned getJITMatchQuality() { return 0; }
|
|
|
|
|
|
|
|
|
2002-10-29 22:48:17 +01:00
|
|
|
const std::string &getName() const { return Name; }
|
2003-12-28 22:23:38 +01:00
|
|
|
|
2004-07-01 22:42:00 +02:00
|
|
|
/// getIntrinsicLowering - This method returns a reference to an
|
|
|
|
/// IntrinsicLowering instance which should be used by the code generator to
|
|
|
|
/// lower unknown intrinsic functions to the equivalent LLVM expansion.
|
|
|
|
///
|
2003-12-28 22:23:38 +01:00
|
|
|
IntrinsicLowering &getIntrinsicLowering() const { return *IL; }
|
2002-10-29 22:48:17 +01:00
|
|
|
|
2001-09-18 14:38:31 +02:00
|
|
|
// Interfaces to the major aspects of target machine information:
|
|
|
|
// -- Instruction opcode and operand information
|
|
|
|
// -- Pipelines and scheduling information
|
2002-09-20 02:52:09 +02:00
|
|
|
// -- Stack frame information
|
2001-09-18 14:38:31 +02:00
|
|
|
//
|
2004-06-02 07:53:25 +02:00
|
|
|
virtual const TargetInstrInfo *getInstrInfo() const { return 0; }
|
|
|
|
virtual const TargetFrameInfo *getFrameInfo() const { return 0; }
|
2002-12-04 06:20:12 +01:00
|
|
|
const TargetData &getTargetData() const { return DataLayout; }
|
2002-09-20 02:52:09 +02:00
|
|
|
|
2002-10-30 01:53:02 +01:00
|
|
|
/// getRegisterInfo - If register information is available, return it. If
|
2002-12-28 21:13:29 +01:00
|
|
|
/// not, return null. This is kept separate from RegInfo until RegInfo has
|
|
|
|
/// details of graph coloring register allocation removed from it.
|
2002-10-30 01:53:02 +01:00
|
|
|
///
|
|
|
|
virtual const MRegisterInfo* getRegisterInfo() const { return 0; }
|
|
|
|
|
2003-12-20 02:22:19 +01:00
|
|
|
/// getJITInfo - If this target supports a JIT, return information for it,
|
|
|
|
/// otherwise return null.
|
|
|
|
///
|
|
|
|
virtual TargetJITInfo *getJITInfo() { return 0; }
|
|
|
|
|
2004-06-02 07:53:25 +02:00
|
|
|
// These are deprecated interfaces.
|
|
|
|
virtual const TargetSchedInfo *getSchedInfo() const { return 0; }
|
2004-06-03 04:45:09 +02:00
|
|
|
virtual const SparcV9RegInfo *getRegInfo() const { return 0; }
|
2004-06-02 07:53:25 +02:00
|
|
|
|
2002-10-28 02:02:24 +01:00
|
|
|
/// addPassesToEmitAssembly - Add passes to the specified pass manager to get
|
2002-12-02 22:00:50 +01:00
|
|
|
/// assembly langage code emitted. Typically this will involve several steps
|
|
|
|
/// of code generation. This method should return true if assembly emission
|
|
|
|
/// is not supported.
|
2002-10-28 02:02:24 +01:00
|
|
|
///
|
2002-10-29 22:12:46 +01:00
|
|
|
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) {
|
|
|
|
return true;
|
|
|
|
}
|
2002-09-16 17:39:35 +02:00
|
|
|
|
2002-12-02 22:00:50 +01:00
|
|
|
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
2003-08-13 20:17:27 +02:00
|
|
|
/// get machine code emitted. This uses a MachineCodeEmitter object to handle
|
2002-12-02 22:00:50 +01:00
|
|
|
/// actually outputting the machine code and resolving things like the address
|
|
|
|
/// of functions. This method should returns true if machine code emission is
|
2002-12-02 22:15:42 +01:00
|
|
|
/// not supported.
|
2002-10-29 21:51:10 +01:00
|
|
|
///
|
2003-08-13 20:17:27 +02:00
|
|
|
virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
|
2002-12-02 22:15:42 +01:00
|
|
|
MachineCodeEmitter &MCE) {
|
2002-12-02 22:00:50 +01:00
|
|
|
return true;
|
|
|
|
}
|
2001-09-18 14:38:31 +02:00
|
|
|
};
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-09-18 14:38:31 +02:00
|
|
|
#endif
|