Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 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" |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 15 | #include "PTXMCAsmInfo.h" |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 16 | #include "PTXTargetMachine.h" |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 17 | #include "llvm/PassManager.h" |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetRegistry.h" |
| 19 | |
| 20 | using namespace llvm; |
| 21 | |
Rafael Espindola | a484f2c | 2010-11-28 14:48:34 +0000 | [diff] [blame] | 22 | namespace llvm { |
| 23 | MCStreamer *createPTXAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, |
Rafael Espindola | 1c952b9 | 2010-12-09 23:48:29 +0000 | [diff] [blame] | 24 | bool isVerboseAsm, bool useLoc, |
Rafael Espindola | a484f2c | 2010-11-28 14:48:34 +0000 | [diff] [blame] | 25 | MCInstPrinter *InstPrint, |
| 26 | MCCodeEmitter *CE, |
| 27 | bool ShowInst); |
| 28 | } |
| 29 | |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 30 | extern "C" void LLVMInitializePTXTarget() { |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 31 | RegisterTargetMachine<PTXTargetMachine> X(ThePTXTarget); |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 32 | RegisterAsmInfo<PTXMCAsmInfo> Y(ThePTXTarget); |
Che-Liang Chiou | d77f2a4 | 2010-11-08 02:58:44 +0000 | [diff] [blame] | 33 | TargetRegistry::RegisterAsmStreamer(ThePTXTarget, createPTXAsmStreamer); |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 36 | // DataLayout and FrameInfo are filled with dummy data |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 37 | PTXTargetMachine::PTXTargetMachine(const Target &T, |
| 38 | const std::string &TT, |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 39 | const std::string &FS) |
| 40 | : LLVMTargetMachine(T, TT), |
| 41 | DataLayout("e-p:32:32-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64"), |
Anton Korobeynikov | 3346491 | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 42 | FrameInfo(Subtarget), |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 43 | InstrInfo(*this), |
| 44 | TLInfo(*this), |
| 45 | Subtarget(TT, FS) { |
| 46 | } |
| 47 | |
| 48 | bool PTXTargetMachine::addInstSelector(PassManagerBase &PM, |
| 49 | CodeGenOpt::Level OptLevel) { |
| 50 | PM.add(createPTXISelDag(*this, OptLevel)); |
Che-Liang Chiou | 3278c42 | 2010-11-08 03:00:52 +0000 | [diff] [blame] | 51 | PM.add(createPTXMFInfoExtract(*this, OptLevel)); |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 52 | return false; |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 53 | } |