]>
Commit | Line | Data |
---|---|---|
1a4d82fc | 1 | //===-- AMDGPUAsmPrinter.h - Print AMDGPU assembly code ---------*- C++ -*-===// |
970d7e83 LB |
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 | ||
1a4d82fc JJ |
15 | #ifndef LLVM_LIB_TARGET_R600_AMDGPUASMPRINTER_H |
16 | #define LLVM_LIB_TARGET_R600_AMDGPUASMPRINTER_H | |
970d7e83 LB |
17 | |
18 | #include "llvm/CodeGen/AsmPrinter.h" | |
1a4d82fc | 19 | #include <vector> |
970d7e83 LB |
20 | |
21 | namespace llvm { | |
22 | ||
23 | class AMDGPUAsmPrinter : public AsmPrinter { | |
1a4d82fc JJ |
24 | private: |
25 | struct SIProgramInfo { | |
26 | SIProgramInfo() : | |
85aaf69f SL |
27 | VGPRBlocks(0), |
28 | SGPRBlocks(0), | |
1a4d82fc JJ |
29 | Priority(0), |
30 | FloatMode(0), | |
31 | Priv(0), | |
32 | DX10Clamp(0), | |
33 | DebugMode(0), | |
34 | IEEEMode(0), | |
35 | ScratchSize(0), | |
85aaf69f SL |
36 | ComputePGMRSrc1(0), |
37 | LDSBlocks(0), | |
38 | ScratchBlocks(0), | |
39 | ComputePGMRSrc2(0), | |
40 | NumVGPR(0), | |
41 | NumSGPR(0), | |
1a4d82fc JJ |
42 | FlatUsed(false), |
43 | VCCUsed(false), | |
44 | CodeLen(0) {} | |
970d7e83 | 45 | |
1a4d82fc | 46 | // Fields set in PGM_RSRC1 pm4 packet. |
85aaf69f SL |
47 | uint32_t VGPRBlocks; |
48 | uint32_t SGPRBlocks; | |
1a4d82fc JJ |
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; | |
970d7e83 | 56 | |
85aaf69f SL |
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; | |
1a4d82fc | 68 | bool FlatUsed; |
970d7e83 | 69 | |
1a4d82fc JJ |
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; | |
970d7e83 LB |
79 | |
80 | /// \brief Emit register usage information so that the GPU driver | |
81 | /// can correctly setup the GPU state. | |
1a4d82fc JJ |
82 | void EmitProgramInfoR600(const MachineFunction &MF); |
83 | void EmitProgramInfoSI(const MachineFunction &MF, const SIProgramInfo &KernelInfo); | |
85aaf69f SL |
84 | void EmitAmdKernelCodeT(const MachineFunction &MF, |
85 | const SIProgramInfo &KernelInfo) const; | |
1a4d82fc JJ |
86 | |
87 | public: | |
88 | explicit AMDGPUAsmPrinter(TargetMachine &TM, MCStreamer &Streamer); | |
89 | ||
90 | bool runOnMachineFunction(MachineFunction &MF) override; | |
91 | ||
92 | const char *getPassName() const override { | |
93 | return "AMDGPU Assembly Printer"; | |
94 | } | |
970d7e83 LB |
95 | |
96 | /// Implemented in AMDGPUMCInstLower.cpp | |
1a4d82fc JJ |
97 | void EmitInstruction(const MachineInstr *MI) override; |
98 | ||
99 | void EmitEndOfAsmFile(Module &M) override; | |
100 | ||
101 | protected: | |
102 | bool DisasmEnabled; | |
103 | std::vector<std::string> DisasmLines, HexLines; | |
104 | size_t DisasmLineMaxLen; | |
970d7e83 LB |
105 | }; |
106 | ||
107 | } // End anonymous llvm | |
108 | ||
1a4d82fc | 109 | #endif |