1 //===-- PTXTargetMachine.cpp - Define TargetMachine for PTX ---------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Top-level implementation for the PTX target.
12 //===----------------------------------------------------------------------===//
15 #include "PTXMCAsmInfo.h"
16 #include "PTXTargetMachine.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/Target/TargetRegistry.h"
19 #include "llvm/Support/raw_ostream.h"
24 MCStreamer *createPTXAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
25 bool isVerboseAsm, bool useLoc,
26 MCInstPrinter *InstPrint,
28 TargetAsmBackend *TAB,
32 extern "C" void LLVMInitializePTXTarget() {
33 RegisterTargetMachine<PTXTargetMachine> X(ThePTXTarget);
34 RegisterAsmInfo<PTXMCAsmInfo> Y(ThePTXTarget);
35 TargetRegistry::RegisterAsmStreamer(ThePTXTarget, createPTXAsmStreamer);
39 const char* DataLayout32 = "e-p:32:32-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64";
40 const char* DataLayout64 = "e-p:64:64-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64";
43 // DataLayout and FrameLowering are filled with dummy data
44 PTXTargetMachine::PTXTargetMachine(const Target &T,
45 const std::string &TT,
46 const std::string &FS)
48 // FIXME: This feels like a dirty hack, but Subtarget does not appear to be
49 // initialized at this point, and we need to finish initialization of
51 DataLayout((FS.find("64bit") != FS.npos) ? DataLayout64 : DataLayout32),
52 LLVMTargetMachine(T, TT),
53 FrameLowering(Subtarget),
58 bool PTXTargetMachine::addInstSelector(PassManagerBase &PM,
59 CodeGenOpt::Level OptLevel) {
60 PM.add(createPTXISelDag(*this, OptLevel));
64 bool PTXTargetMachine::addPostRegAlloc(PassManagerBase &PM,
65 CodeGenOpt::Level OptLevel) {
66 // PTXMFInfoExtract must after register allocation!
67 PM.add(createPTXMFInfoExtract(*this, OptLevel));