blob: 74c8d58a3e9b924557e9c65572b03d6cb1cd275f [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- PTXAsmPrinter.h - Print machine code to a PTX file ------*- C++ -*-===//
Justin Holewinskid8e4ed22011-09-28 14:32:04 +00002//
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// PTX Assembly printer class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef PTXASMPRINTER_H
15#define PTXASMPRINTER_H
16
17#include "PTX.h"
18#include "PTXTargetMachine.h"
19#include "llvm/ADT/StringMap.h"
20#include "llvm/CodeGen/AsmPrinter.h"
21#include "llvm/Support/Compiler.h"
22
23namespace llvm {
24
25class MCOperand;
26
27class LLVM_LIBRARY_VISIBILITY PTXAsmPrinter : public AsmPrinter {
28public:
29 explicit PTXAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
30 : AsmPrinter(TM, Streamer) {}
31
32 const char *getPassName() const { return "PTX Assembly Printer"; }
33
34 bool doFinalization(Module &M);
35
36 virtual void EmitStartOfAsmFile(Module &M);
Justin Holewinskid8e4ed22011-09-28 14:32:04 +000037 virtual void EmitFunctionBodyStart();
38 virtual void EmitFunctionBodyEnd();
Justin Holewinskied0e4c82011-09-28 14:32:06 +000039 virtual void EmitFunctionEntryLabel();
Justin Holewinskid8e4ed22011-09-28 14:32:04 +000040 virtual void EmitInstruction(const MachineInstr *MI);
41
Justin Holewinskid8e4ed22011-09-28 14:32:04 +000042 unsigned GetOrCreateSourceID(StringRef FileName,
43 StringRef DirName);
44
45 MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
Justin Holewinskif51b7e52011-09-30 14:36:36 +000046 MCOperand lowerOperand(const MachineOperand &MO);
Justin Holewinskid8e4ed22011-09-28 14:32:04 +000047
48private:
49 void EmitVariableDeclaration(const GlobalVariable *gv);
Dan Bailey96e64582011-11-11 14:45:12 +000050 void EmitFunctionDeclaration(const Function* func);
Justin Holewinskid8e4ed22011-09-28 14:32:04 +000051
52 StringMap<unsigned> SourceIdMap;
53}; // class PTXAsmPrinter
54} // namespace llvm
55
56#endif
57