Jia Liu | 31d157a | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- PTXAsmPrinter.h - Print machine code to a PTX file ------*- C++ -*-===// |
Justin Holewinski | d8e4ed2 | 2011-09-28 14:32:04 +0000 | [diff] [blame] | 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: |
| 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 Holewinski | d8e4ed2 | 2011-09-28 14:32:04 +0000 | [diff] [blame] | 37 | virtual void EmitFunctionBodyStart(); |
| 38 | virtual void EmitFunctionBodyEnd(); |
Justin Holewinski | ed0e4c8 | 2011-09-28 14:32:06 +0000 | [diff] [blame] | 39 | virtual void EmitFunctionEntryLabel(); |
Justin Holewinski | d8e4ed2 | 2011-09-28 14:32:04 +0000 | [diff] [blame] | 40 | virtual void EmitInstruction(const MachineInstr *MI); |
| 41 | |
Justin Holewinski | d8e4ed2 | 2011-09-28 14:32:04 +0000 | [diff] [blame] | 42 | unsigned GetOrCreateSourceID(StringRef FileName, |
| 43 | StringRef DirName); |
| 44 | |
| 45 | MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol); |
Justin Holewinski | f51b7e5 | 2011-09-30 14:36:36 +0000 | [diff] [blame] | 46 | MCOperand lowerOperand(const MachineOperand &MO); |
Justin Holewinski | d8e4ed2 | 2011-09-28 14:32:04 +0000 | [diff] [blame] | 47 | |
| 48 | private: |
| 49 | void EmitVariableDeclaration(const GlobalVariable *gv); |
Dan Bailey | 96e6458 | 2011-11-11 14:45:12 +0000 | [diff] [blame] | 50 | void EmitFunctionDeclaration(const Function* func); |
Justin Holewinski | d8e4ed2 | 2011-09-28 14:32:04 +0000 | [diff] [blame] | 51 | |
| 52 | StringMap<unsigned> SourceIdMap; |
| 53 | }; // class PTXAsmPrinter |
| 54 | } // namespace llvm |
| 55 | |
| 56 | #endif |
| 57 | |