blob: 0e9f5181ed565dbcb1786a678d303c70f4dda8d2 [file] [log] [blame]
Nick Lewyckyf7a3c502010-09-07 18:14:24 +00001//===-- 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 Christopher50880d02010-09-18 18:52:28 +000015#include "PTXMCAsmInfo.h"
Nick Lewyckyf7a3c502010-09-07 18:14:24 +000016#include "PTXTargetMachine.h"
Eric Christopher50880d02010-09-18 18:52:28 +000017#include "llvm/PassManager.h"
Nick Lewyckyf7a3c502010-09-07 18:14:24 +000018#include "llvm/Target/TargetRegistry.h"
19
20using namespace llvm;
21
Rafael Espindolaa484f2c2010-11-28 14:48:34 +000022namespace llvm {
23 MCStreamer *createPTXAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
Rafael Espindola1c952b92010-12-09 23:48:29 +000024 bool isVerboseAsm, bool useLoc,
Rafael Espindolaa484f2c2010-11-28 14:48:34 +000025 MCInstPrinter *InstPrint,
26 MCCodeEmitter *CE,
27 bool ShowInst);
28}
29
Eric Christopher50880d02010-09-18 18:52:28 +000030extern "C" void LLVMInitializePTXTarget() {
Nick Lewyckyf7a3c502010-09-07 18:14:24 +000031 RegisterTargetMachine<PTXTargetMachine> X(ThePTXTarget);
Eric Christopher50880d02010-09-18 18:52:28 +000032 RegisterAsmInfo<PTXMCAsmInfo> Y(ThePTXTarget);
Che-Liang Chioud77f2a42010-11-08 02:58:44 +000033 TargetRegistry::RegisterAsmStreamer(ThePTXTarget, createPTXAsmStreamer);
Nick Lewyckyf7a3c502010-09-07 18:14:24 +000034}
35
Eric Christopher50880d02010-09-18 18:52:28 +000036// DataLayout and FrameInfo are filled with dummy data
Nick Lewyckyf7a3c502010-09-07 18:14:24 +000037PTXTargetMachine::PTXTargetMachine(const Target &T,
38 const std::string &TT,
Eric Christopher50880d02010-09-18 18:52:28 +000039 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 Korobeynikov33464912010-11-15 00:06:54 +000042 FrameInfo(Subtarget),
Eric Christopher50880d02010-09-18 18:52:28 +000043 InstrInfo(*this),
44 TLInfo(*this),
45 Subtarget(TT, FS) {
46}
47
48bool PTXTargetMachine::addInstSelector(PassManagerBase &PM,
49 CodeGenOpt::Level OptLevel) {
50 PM.add(createPTXISelDag(*this, OptLevel));
Che-Liang Chiou3278c422010-11-08 03:00:52 +000051 PM.add(createPTXMFInfoExtract(*this, OptLevel));
Eric Christopher50880d02010-09-18 18:52:28 +000052 return false;
Nick Lewyckyf7a3c502010-09-07 18:14:24 +000053}