blob: 85de57d90acedba2128c32abed993fbad0def2b4 [file] [log] [blame]
Justin Holewinskid8e4ed22011-09-28 14:32:04 +00001//===-- 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
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);
37
38 virtual bool runOnMachineFunction(MachineFunction &MF);
39
40 virtual void EmitFunctionBodyStart();
41 virtual void EmitFunctionBodyEnd();
42
43 virtual void EmitInstruction(const MachineInstr *MI);
44
45 void printOperand(const MachineInstr *MI, int opNum, raw_ostream &OS);
46 void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &OS,
47 const char *Modifier = 0);
48 void printReturnOperand(const MachineInstr *MI, int opNum, raw_ostream &OS,
49 const char *Modifier = 0);
50 void printPredicateOperand(const MachineInstr *MI, raw_ostream &O);
51
52 void printCall(const MachineInstr *MI, raw_ostream &O);
53
54 unsigned GetOrCreateSourceID(StringRef FileName,
55 StringRef DirName);
56
57 MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
58 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
59
60 // autogen'd.
61 void printInstruction(const MachineInstr *MI, raw_ostream &OS);
62 static const char *getRegisterName(unsigned RegNo);
63
64private:
65 void EmitVariableDeclaration(const GlobalVariable *gv);
66 void EmitFunctionDeclaration();
67
68 StringMap<unsigned> SourceIdMap;
69}; // class PTXAsmPrinter
70} // namespace llvm
71
72#endif
73