Add an option that allows one to "decode" the LSDA.
[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 #include "llvm/Support/raw_ostream.h"
20
21 using namespace llvm;
22
23 namespace llvm {
24   MCStreamer *createPTXAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
25                                    bool isVerboseAsm, bool useLoc,
26                                    bool useCFI,
27                                    MCInstPrinter *InstPrint,
28                                    MCCodeEmitter *CE,
29                                    TargetAsmBackend *TAB,
30                                    bool ShowInst,
31                                    bool DecodeLSDA);
32 }
33
34 extern "C" void LLVMInitializePTXTarget() {
35
36   RegisterTargetMachine<PTX32TargetMachine> X(ThePTX32Target);
37   RegisterTargetMachine<PTX64TargetMachine> Y(ThePTX64Target);
38
39   RegisterAsmInfo<PTXMCAsmInfo> Z(ThePTX32Target);
40   RegisterAsmInfo<PTXMCAsmInfo> W(ThePTX64Target);
41
42   TargetRegistry::RegisterAsmStreamer(ThePTX32Target, createPTXAsmStreamer);
43   TargetRegistry::RegisterAsmStreamer(ThePTX64Target, createPTXAsmStreamer);
44 }
45
46 namespace {
47   const char* DataLayout32 =
48     "e-p:32:32-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64";
49   const char* DataLayout64 =
50     "e-p:64:64-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64";
51 }
52
53 // DataLayout and FrameLowering are filled with dummy data
54 PTXTargetMachine::PTXTargetMachine(const Target &T,
55                                    const std::string &TT,
56                                    const std::string &FS,
57                                    bool is64Bit)
58   : LLVMTargetMachine(T, TT),
59     DataLayout(is64Bit ? DataLayout64 : DataLayout32),
60     Subtarget(TT, FS, is64Bit),
61     FrameLowering(Subtarget),
62     InstrInfo(*this),
63     TLInfo(*this) {
64 }
65
66 PTX32TargetMachine::PTX32TargetMachine(const Target &T,
67                                        const std::string& TT,
68                                        const std::string& FS)
69   : PTXTargetMachine(T, TT, FS, false) {
70 }
71
72 PTX64TargetMachine::PTX64TargetMachine(const Target &T,
73                                        const std::string& TT,
74                                        const std::string& FS)
75   : PTXTargetMachine(T, TT, FS, true) {
76 }
77
78 bool PTXTargetMachine::addInstSelector(PassManagerBase &PM,
79                                        CodeGenOpt::Level OptLevel) {
80   PM.add(createPTXISelDag(*this, OptLevel));
81   return false;
82 }
83
84 bool PTXTargetMachine::addPostRegAlloc(PassManagerBase &PM,
85                                        CodeGenOpt::Level OptLevel) {
86   // PTXMFInfoExtract must after register allocation!
87   PM.add(createPTXMFInfoExtract(*this, OptLevel));
88   return false;
89 }