LLVM  3.7.0
AMDGPUAsmPrinter.h
Go to the documentation of this file.
1 //===-- AMDGPUAsmPrinter.h - Print AMDGPU assembly code ---------*- C++ -*-===//
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 /// \file
11 /// \brief AMDGPU Assembly printer class.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_R600_AMDGPUASMPRINTER_H
16 #define LLVM_LIB_TARGET_R600_AMDGPUASMPRINTER_H
17 
19 #include <vector>
20 
21 namespace llvm {
22 
23 class AMDGPUAsmPrinter : public AsmPrinter {
24 private:
25  struct SIProgramInfo {
26  SIProgramInfo() :
27  VGPRBlocks(0),
28  SGPRBlocks(0),
29  Priority(0),
30  FloatMode(0),
31  Priv(0),
32  DX10Clamp(0),
33  DebugMode(0),
34  IEEEMode(0),
35  ScratchSize(0),
36  ComputePGMRSrc1(0),
37  LDSBlocks(0),
38  ScratchBlocks(0),
39  ComputePGMRSrc2(0),
40  NumVGPR(0),
41  NumSGPR(0),
42  FlatUsed(false),
43  VCCUsed(false),
44  CodeLen(0) {}
45 
46  // Fields set in PGM_RSRC1 pm4 packet.
47  uint32_t VGPRBlocks;
48  uint32_t SGPRBlocks;
49  uint32_t Priority;
50  uint32_t FloatMode;
51  uint32_t Priv;
52  uint32_t DX10Clamp;
53  uint32_t DebugMode;
54  uint32_t IEEEMode;
55  uint32_t ScratchSize;
56 
57  uint64_t ComputePGMRSrc1;
58 
59  // Fields set in PGM_RSRC2 pm4 packet.
60  uint32_t LDSBlocks;
61  uint32_t ScratchBlocks;
62 
63  uint64_t ComputePGMRSrc2;
64 
65  uint32_t NumVGPR;
66  uint32_t NumSGPR;
67  uint32_t LDSSize;
68  bool FlatUsed;
69 
70  // Bonus information for debugging.
71  bool VCCUsed;
72  uint64_t CodeLen;
73  };
74 
75  void getSIProgramInfo(SIProgramInfo &Out, const MachineFunction &MF) const;
76  void findNumUsedRegistersSI(const MachineFunction &MF,
77  unsigned &NumSGPR,
78  unsigned &NumVGPR) const;
79 
80  /// \brief Emit register usage information so that the GPU driver
81  /// can correctly setup the GPU state.
82  void EmitProgramInfoR600(const MachineFunction &MF);
83  void EmitProgramInfoSI(const MachineFunction &MF, const SIProgramInfo &KernelInfo);
84  void EmitAmdKernelCodeT(const MachineFunction &MF,
85  const SIProgramInfo &KernelInfo) const;
86 
87 public:
89  std::unique_ptr<MCStreamer> Streamer);
90 
91  bool runOnMachineFunction(MachineFunction &MF) override;
92 
93  const char *getPassName() const override {
94  return "AMDGPU Assembly Printer";
95  }
96 
97  /// Implemented in AMDGPUMCInstLower.cpp
98  void EmitInstruction(const MachineInstr *MI) override;
99 
100  void EmitFunctionBodyStart() override;
101 
102  void EmitEndOfAsmFile(Module &M) override;
103 
104  bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
105  unsigned AsmVariant, const char *ExtraCode,
106  raw_ostream &O) override;
107 
108 protected:
109  std::vector<std::string> DisasmLines, HexLines;
111 };
112 
113 } // End anonymous llvm
114 
115 #endif
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
const MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:86
AMDGPUAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
void EmitInstruction(const MachineInstr *MI) override
Implemented in AMDGPUMCInstLower.cpp.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
TargetMachine & TM
Target machine description.
Definition: AsmPrinter.h:70
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:66
void EmitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
std::vector< std::string > HexLines
const char * getPassName() const override
getPassName - Return a nice clean name for a pass.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
std::vector< std::string > DisasmLines
Representation of each machine instruction.
Definition: MachineInstr.h:51
void EmitFunctionBodyStart() override
Targets can override this to emit stuff before the first basic block in the function.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
Primary interface to the complete machine description for the target machine.