1 //===-- PTXAsmPrinter.h - Print machine code to a PTX file ----------------===//
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 // 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 
23 namespace llvm {
24 
25 class MCOperand;
26 
27 class LLVM_LIBRARY_VISIBILITY PTXAsmPrinter : public AsmPrinter {
28 public:
PTXAsmPrinter(TargetMachine & TM,MCStreamer & Streamer)29   explicit PTXAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
30     : AsmPrinter(TM, Streamer) {}
31 
getPassName()32   const char *getPassName() const { return "PTX Assembly Printer"; }
33 
34   bool doFinalization(Module &M);
35 
36   virtual void EmitStartOfAsmFile(Module &M);
37   virtual void EmitFunctionBodyStart();
38   virtual void EmitFunctionBodyEnd();
39   virtual void EmitFunctionEntryLabel();
40   virtual void EmitInstruction(const MachineInstr *MI);
41 
42   unsigned GetOrCreateSourceID(StringRef FileName,
43                                StringRef DirName);
44 
45   MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
46   MCOperand lowerOperand(const MachineOperand &MO);
47 
48 private:
49   void EmitVariableDeclaration(const GlobalVariable *gv);
50   void EmitFunctionDeclaration();
51 
52   StringMap<unsigned> SourceIdMap;
53 }; // class PTXAsmPrinter
54 } // namespace llvm
55 
56 #endif
57 
58