// FIXME: We shouldn't need this header, but we need it until there is a
// different interface to get the TargetAsmInfo.
#include "llvm/Target/TargetMachine.h"
-// FIXME: We shouldn't need this header, but we need it until there is a
-// different interface to the target machines.
-#include "llvm/Module.h"
#include <string>
#include <cassert>
typedef unsigned (*TripleMatchQualityFnTy)(const std::string &TT);
typedef TargetMachine *(*TargetMachineCtorTy)(const Target &,
- const Module &,
const std::string &,
const std::string &);
typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &,
/// feature set; it should always be provided. Generally this should be
/// either the target triple from the module, or the target triple of the
/// host if that does not exist.
- TargetMachine *createTargetMachine(const Module &M,
- const std::string &Triple,
+ TargetMachine *createTargetMachine(const std::string &Triple,
const std::string &Features) const {
if (!TargetMachineCtorFn)
return 0;
- return TargetMachineCtorFn(*this, M, Triple, Features);
+ return TargetMachineCtorFn(*this, Triple, Features);
+ }
+ TargetMachine *createTargetMachine(const Module &M,
+ const std::string &Triple,
+ const std::string &Features) const {
+ return createTargetMachine(Triple, Features);
}
/// createAsmPrinter - Create a target specific assembly printer pass.
};
/// TargetRegistry - Generic interface to target specific features.
- //
- // FIXME: Provide Target* iterator.
struct TargetRegistry {
class iterator {
const Target *Current;
}
private:
- static TargetMachine *Allocator(const Target &T, const Module &M,
- const std::string &TT,
+ static TargetMachine *Allocator(const Target &T, const std::string &TT,
const std::string &FS) {
return new TargetMachineImpl(T, TT, FS);
}
};
- template<class TargetMachineImpl>
- struct RegisterTargetMachineDeprecated {
- RegisterTargetMachineDeprecated(Target &T) {
- TargetRegistry::RegisterTargetMachine(T, &Allocator);
- }
-
- private:
- static TargetMachine *Allocator(const Target &T, const Module &M,
- const std::string &TT,
- const std::string &FS) {
- return new TargetMachineImpl(T, M, FS);
- }
- };
-
/// RegisterAsmPrinter - Helper template for registering a target specific
/// assembly printer, for use in the target machine initialization
/// function. Usage:
namespace llvm {
struct CTargetMachine : public TargetMachine {
- const TargetData DataLayout; // Calculates type size & alignment
-
- CTargetMachine(const Target &T, const Module &M,
- const std::string &FS)
- : TargetMachine(T), DataLayout(&M) {}
+ CTargetMachine(const Target &T, const std::string &TT, const std::string &FS)
+ : TargetMachine(T) {}
virtual bool WantsWholeFile() const { return true; }
virtual bool addPassesToEmitWholeFile(PassManager &PM,
class formatted_raw_ostream;
struct CPPTargetMachine : public TargetMachine {
- const TargetData DataLayout; // Calculates type size & alignment
-
- CPPTargetMachine(const Target &T, const Module &M,
+ CPPTargetMachine(const Target &T, const std::string &TT,
const std::string &FS)
- : TargetMachine(T), DataLayout(&M) {}
+ : TargetMachine(T) {}
virtual bool WantsWholeFile() const { return true; }
virtual bool addPassesToEmitWholeFile(PassManager &PM,
namespace llvm {
// TargetMachine for the MSIL
struct VISIBILITY_HIDDEN MSILTarget : public TargetMachine {
- const TargetData DataLayout; // Calculates type size & alignment
-
- MSILTarget(const Target &T, const Module &M, const std::string &FS)
- : TargetMachine(T), DataLayout(&M) {}
+ MSILTarget(const Target &T, const std::string &TT, const std::string &FS)
+ : TargetMachine(T) {}
virtual bool WantsWholeFile() const { return true; }
virtual bool addPassesToEmitWholeFile(PassManager &PM,
extern "C" void LLVMInitializeMSILTarget() {
// Register the target.
- RegisterTargetMachineDeprecated<MSILTarget> X(TheMSILTarget);
+ RegisterTargetMachine<MSILTarget> X(TheMSILTarget);
}
bool MSILModule::runOnModule(Module &M) {