2004-07-11 02:43:43 +00:00
|
|
|
//===-- Target/TargetMachineRegistry.h - Target Registration ----*- C++ -*-===//
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2004-07-11 02:43:43 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2004-07-11 02:43:43 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file exposes two classes: the TargetMachineRegistry class, which allows
|
|
|
|
// tools to inspect all of registered targets, and the RegisterTarget class,
|
|
|
|
// which TargetMachine implementations should use to register themselves with
|
|
|
|
// the system.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H
|
|
|
|
#define LLVM_TARGET_TARGETMACHINEREGISTRY_H
|
|
|
|
|
2009-01-16 07:02:28 +00:00
|
|
|
#include "llvm/Module.h"
|
2009-07-15 20:24:03 +00:00
|
|
|
#include "llvm/Target/TargetRegistry.h"
|
2004-07-11 03:59:46 +00:00
|
|
|
|
2004-07-11 02:43:43 +00:00
|
|
|
namespace llvm {
|
|
|
|
class Module;
|
2009-07-15 20:24:03 +00:00
|
|
|
class Target;
|
2004-07-11 02:43:43 +00:00
|
|
|
class TargetMachine;
|
2009-01-16 06:53:46 +00:00
|
|
|
|
2004-07-11 02:43:43 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
/// RegisterTarget - This class is used to make targets automatically register
|
2009-07-15 20:24:03 +00:00
|
|
|
/// themselves with the tools they are linked with. Targets should define an
|
|
|
|
/// single global Target instance and register it using the TargetRegistry
|
|
|
|
/// interfaces. Targets must also include a static instance of this class.
|
|
|
|
///
|
2009-01-16 06:53:46 +00:00
|
|
|
/// The type 'TargetMachineImpl' should provide a constructor with two
|
2006-05-15 17:25:05 +00:00
|
|
|
/// parameters:
|
|
|
|
/// - const Module& M: the module that is being compiled:
|
2009-01-16 06:53:46 +00:00
|
|
|
/// - const std::string& FS: target-specific string describing target
|
2006-05-15 17:25:05 +00:00
|
|
|
/// flavour.
|
2009-01-16 06:53:46 +00:00
|
|
|
|
2004-07-11 02:43:43 +00:00
|
|
|
template<class TargetMachineImpl>
|
2007-10-17 21:28:48 +00:00
|
|
|
struct RegisterTarget {
|
2009-07-16 02:41:19 +00:00
|
|
|
RegisterTarget(Target &T, const char *Name, const char *ShortDesc) {
|
2009-07-15 20:24:03 +00:00
|
|
|
TargetRegistry::RegisterTargetMachine(T, &Allocator);
|
|
|
|
}
|
2007-10-17 21:28:48 +00:00
|
|
|
|
2004-07-11 02:43:43 +00:00
|
|
|
private:
|
2009-07-15 20:24:03 +00:00
|
|
|
static TargetMachine *Allocator(const Target &T, const Module &M,
|
|
|
|
const std::string &FS) {
|
|
|
|
return new TargetMachineImpl(T, M, FS);
|
2004-07-11 02:43:43 +00:00
|
|
|
}
|
|
|
|
};
|
2004-07-11 03:59:46 +00:00
|
|
|
|
2004-07-11 02:43:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|