R600: Use range for and fix missing consts.
[oota-llvm.git] / lib / Target / R600 / AMDGPUAsmPrinter.h
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 AMDGPU_ASMPRINTER_H
16 #define AMDGPU_ASMPRINTER_H
17
18 #include "llvm/CodeGen/AsmPrinter.h"
19 #include <string>
20 #include <vector>
21
22 namespace llvm {
23
24 class AMDGPUAsmPrinter : public AsmPrinter {
25 private:
26   struct SIProgramInfo {
27     SIProgramInfo() :
28       NumVGPR(0),
29       NumSGPR(0),
30       Priority(0),
31       FloatMode(0),
32       Priv(0),
33       DX10Clamp(0),
34       DebugMode(0),
35       IEEEMode(0),
36       CodeLen(0) {}
37
38     // Fields set in PGM_RSRC1 pm4 packet.
39     uint32_t NumVGPR;
40     uint32_t NumSGPR;
41     uint32_t Priority;
42     uint32_t FloatMode;
43     uint32_t Priv;
44     uint32_t DX10Clamp;
45     uint32_t DebugMode;
46     uint32_t IEEEMode;
47
48     // Bonus information for debugging.
49     uint64_t CodeLen;
50   };
51
52   void getSIProgramInfo(SIProgramInfo &Out, const MachineFunction &MF) const;
53   void findNumUsedRegistersSI(const MachineFunction &MF,
54                               unsigned &NumSGPR,
55                               unsigned &NumVGPR) const;
56
57   /// \brief Emit register usage information so that the GPU driver
58   /// can correctly setup the GPU state.
59   void EmitProgramInfoR600(const MachineFunction &MF);
60   void EmitProgramInfoSI(const MachineFunction &MF, const SIProgramInfo &KernelInfo);
61
62 public:
63   explicit AMDGPUAsmPrinter(TargetMachine &TM, MCStreamer &Streamer);
64
65   bool runOnMachineFunction(MachineFunction &MF) override;
66
67   const char *getPassName() const override {
68     return "AMDGPU Assembly Printer";
69   }
70
71   /// Implemented in AMDGPUMCInstLower.cpp
72   void EmitInstruction(const MachineInstr *MI) override;
73
74 protected:
75   bool DisasmEnabled;
76   std::vector<std::string> DisasmLines, HexLines;
77   size_t DisasmLineMaxLen;
78 };
79
80 } // End anonymous llvm
81
82 #endif //AMDGPU_ASMPRINTER_H