2010-09-07 18:14:24 +00:00
|
|
|
//===-- PTXTargetMachine.cpp - Define TargetMachine for PTX ---------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Top-level implementation for the PTX target.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "PTX.h"
|
|
|
|
#include "PTXTargetMachine.h"
|
2010-09-18 18:52:28 +00:00
|
|
|
#include "llvm/PassManager.h"
|
2011-08-24 18:08:43 +00:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2011-03-02 07:36:48 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2010-09-07 18:14:24 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2010-11-28 14:48:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
MCStreamer *createPTXAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
2010-12-10 07:39:47 +00:00
|
|
|
bool isVerboseAsm, bool useLoc,
|
2011-04-30 03:44:37 +00:00
|
|
|
bool useCFI,
|
2010-11-28 14:48:34 +00:00
|
|
|
MCInstPrinter *InstPrint,
|
|
|
|
MCCodeEmitter *CE,
|
2011-07-25 23:24:55 +00:00
|
|
|
MCAsmBackend *MAB,
|
2011-06-17 20:55:01 +00:00
|
|
|
bool ShowInst);
|
2010-11-28 14:48:34 +00:00
|
|
|
}
|
|
|
|
|
2010-09-18 18:52:28 +00:00
|
|
|
extern "C" void LLVMInitializePTXTarget() {
|
2011-04-20 15:37:17 +00:00
|
|
|
|
|
|
|
RegisterTargetMachine<PTX32TargetMachine> X(ThePTX32Target);
|
|
|
|
RegisterTargetMachine<PTX64TargetMachine> Y(ThePTX64Target);
|
|
|
|
|
|
|
|
TargetRegistry::RegisterAsmStreamer(ThePTX32Target, createPTXAsmStreamer);
|
|
|
|
TargetRegistry::RegisterAsmStreamer(ThePTX64Target, createPTXAsmStreamer);
|
2010-09-07 18:14:24 +00:00
|
|
|
}
|
|
|
|
|
2011-03-02 07:36:48 +00:00
|
|
|
namespace {
|
2011-03-02 07:58:46 +00:00
|
|
|
const char* DataLayout32 =
|
|
|
|
"e-p:32:32-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64";
|
|
|
|
const char* DataLayout64 =
|
|
|
|
"e-p:64:64-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64";
|
2011-03-02 07:36:48 +00:00
|
|
|
}
|
|
|
|
|
2011-01-10 12:39:04 +00:00
|
|
|
// DataLayout and FrameLowering are filled with dummy data
|
2010-09-07 18:14:24 +00:00
|
|
|
PTXTargetMachine::PTXTargetMachine(const Target &T,
|
2011-07-20 07:51:56 +00:00
|
|
|
StringRef TT, StringRef CPU, StringRef FS,
|
|
|
|
Reloc::Model RM, CodeModel::Model CM,
|
|
|
|
bool is64Bit)
|
|
|
|
: LLVMTargetMachine(T, TT, CPU, FS, RM, CM),
|
2011-04-20 15:37:17 +00:00
|
|
|
DataLayout(is64Bit ? DataLayout64 : DataLayout32),
|
2011-06-30 01:53:36 +00:00
|
|
|
Subtarget(TT, CPU, FS, is64Bit),
|
2011-01-10 12:39:04 +00:00
|
|
|
FrameLowering(Subtarget),
|
2011-03-02 07:58:46 +00:00
|
|
|
InstrInfo(*this),
|
|
|
|
TLInfo(*this) {
|
2010-09-18 18:52:28 +00:00
|
|
|
}
|
|
|
|
|
2011-07-19 06:37:02 +00:00
|
|
|
PTX32TargetMachine::PTX32TargetMachine(const Target &T, StringRef TT,
|
|
|
|
StringRef CPU, StringRef FS,
|
2011-07-20 07:51:56 +00:00
|
|
|
Reloc::Model RM, CodeModel::Model CM)
|
|
|
|
: PTXTargetMachine(T, TT, CPU, FS, RM, CM, false) {
|
2011-04-20 15:37:17 +00:00
|
|
|
}
|
|
|
|
|
2011-07-19 06:37:02 +00:00
|
|
|
PTX64TargetMachine::PTX64TargetMachine(const Target &T, StringRef TT,
|
|
|
|
StringRef CPU, StringRef FS,
|
2011-07-20 07:51:56 +00:00
|
|
|
Reloc::Model RM, CodeModel::Model CM)
|
|
|
|
: PTXTargetMachine(T, TT, CPU, FS, RM, CM, true) {
|
2011-04-20 15:37:17 +00:00
|
|
|
}
|
|
|
|
|
2010-09-18 18:52:28 +00:00
|
|
|
bool PTXTargetMachine::addInstSelector(PassManagerBase &PM,
|
|
|
|
CodeGenOpt::Level OptLevel) {
|
|
|
|
PM.add(createPTXISelDag(*this, OptLevel));
|
2011-01-01 10:50:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PTXTargetMachine::addPostRegAlloc(PassManagerBase &PM,
|
|
|
|
CodeGenOpt::Level OptLevel) {
|
|
|
|
// PTXMFInfoExtract must after register allocation!
|
2010-11-08 03:00:52 +00:00
|
|
|
PM.add(createPTXMFInfoExtract(*this, OptLevel));
|
2010-09-18 18:52:28 +00:00
|
|
|
return false;
|
2010-09-07 18:14:24 +00:00
|
|
|
}
|