MC: Make TargetAsmBackend available to the AsmStreamer.
[oota-llvm.git] / lib / Target / PTX / PTXTargetMachine.cpp
1 //===-- PTXTargetMachine.cpp - Define TargetMachine for PTX ---------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Top-level implementation for the PTX target.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "PTX.h"
15 #include "PTXMCAsmInfo.h"
16 #include "PTXTargetMachine.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/Target/TargetRegistry.h"
19
20 using namespace llvm;
21
22 namespace llvm {
23   MCStreamer *createPTXAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
24                                    bool isVerboseAsm, bool useLoc,
25                                    MCInstPrinter *InstPrint,
26                                    MCCodeEmitter *CE,
27                                    TargetAsmBackend *TAB,
28                                    bool ShowInst);
29 }
30
31 extern "C" void LLVMInitializePTXTarget() {
32   RegisterTargetMachine<PTXTargetMachine> X(ThePTXTarget);
33   RegisterAsmInfo<PTXMCAsmInfo> Y(ThePTXTarget);
34   TargetRegistry::RegisterAsmStreamer(ThePTXTarget, createPTXAsmStreamer);
35 }
36
37 // DataLayout and FrameInfo are filled with dummy data
38 PTXTargetMachine::PTXTargetMachine(const Target &T,
39                                    const std::string &TT,
40                                    const std::string &FS)
41   : LLVMTargetMachine(T, TT),
42     DataLayout("e-p:32:32-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64"),
43     FrameInfo(Subtarget),
44     InstrInfo(*this),
45     TLInfo(*this),
46     Subtarget(TT, FS) {
47 }
48
49 bool PTXTargetMachine::addInstSelector(PassManagerBase &PM,
50                                        CodeGenOpt::Level OptLevel) {
51   PM.add(createPTXISelDag(*this, OptLevel));
52   PM.add(createPTXMFInfoExtract(*this, OptLevel));
53   return false;
54 }