If a global variable has a specified alignment that is less than the preferred
[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                                    MCInstPrinter *InstPrint,
27                                    MCCodeEmitter *CE,
28                                    TargetAsmBackend *TAB,
29                                    bool ShowInst);
30 }
31
32 extern "C" void LLVMInitializePTXTarget() {
33   RegisterTargetMachine<PTXTargetMachine> X(ThePTXTarget);
34   RegisterAsmInfo<PTXMCAsmInfo> Y(ThePTXTarget);
35   TargetRegistry::RegisterAsmStreamer(ThePTXTarget, createPTXAsmStreamer);
36 }
37
38 namespace {
39   const char* DataLayout32 =
40     "e-p:32:32-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64";
41   const char* DataLayout64 =
42     "e-p:64:64-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64";
43 }
44
45 // DataLayout and FrameLowering are filled with dummy data
46 PTXTargetMachine::PTXTargetMachine(const Target &T,
47                                    const std::string &TT,
48                                    const std::string &FS)
49   : LLVMTargetMachine(T, TT),
50     // FIXME: This feels like a dirty hack, but Subtarget does not appear to be
51     //        initialized at this point, and we need to finish initialization of
52     //        DataLayout.
53     DataLayout((FS.find("64bit") != FS.npos) ? DataLayout64 : DataLayout32),
54     Subtarget(TT, FS),
55     FrameLowering(Subtarget),
56     InstrInfo(*this),
57     TLInfo(*this) {
58 }
59
60 bool PTXTargetMachine::addInstSelector(PassManagerBase &PM,
61                                        CodeGenOpt::Level OptLevel) {
62   PM.add(createPTXISelDag(*this, OptLevel));
63   return false;
64 }
65
66 bool PTXTargetMachine::addPostRegAlloc(PassManagerBase &PM,
67                                        CodeGenOpt::Level OptLevel) {
68   // PTXMFInfoExtract must after register allocation!
69   PM.add(createPTXMFInfoExtract(*this, OptLevel));
70   return false;
71 }