LLVM API Documentation

AMDGPUAsmPrinter.h
Go to the documentation of this file.
00001 //===-- AMDGPUAsmPrinter.h - Print AMDGPU assembly code ---------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 /// \file
00011 /// \brief AMDGPU Assembly printer class.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_LIB_TARGET_R600_AMDGPUASMPRINTER_H
00016 #define LLVM_LIB_TARGET_R600_AMDGPUASMPRINTER_H
00017 
00018 #include "llvm/CodeGen/AsmPrinter.h"
00019 #include <vector>
00020 
00021 namespace llvm {
00022 
00023 class AMDGPUAsmPrinter : public AsmPrinter {
00024 private:
00025   struct SIProgramInfo {
00026     SIProgramInfo() :
00027       NumVGPR(0),
00028       NumSGPR(0),
00029       Priority(0),
00030       FloatMode(0),
00031       Priv(0),
00032       DX10Clamp(0),
00033       DebugMode(0),
00034       IEEEMode(0),
00035       ScratchSize(0),
00036       FlatUsed(false),
00037       VCCUsed(false),
00038       CodeLen(0) {}
00039 
00040     // Fields set in PGM_RSRC1 pm4 packet.
00041     uint32_t NumVGPR;
00042     uint32_t NumSGPR;
00043     uint32_t Priority;
00044     uint32_t FloatMode;
00045     uint32_t Priv;
00046     uint32_t DX10Clamp;
00047     uint32_t DebugMode;
00048     uint32_t IEEEMode;
00049     uint32_t ScratchSize;
00050 
00051     bool FlatUsed;
00052 
00053     // Bonus information for debugging.
00054     bool VCCUsed;
00055     uint64_t CodeLen;
00056   };
00057 
00058   void getSIProgramInfo(SIProgramInfo &Out, const MachineFunction &MF) const;
00059   void findNumUsedRegistersSI(const MachineFunction &MF,
00060                               unsigned &NumSGPR,
00061                               unsigned &NumVGPR) const;
00062 
00063   /// \brief Emit register usage information so that the GPU driver
00064   /// can correctly setup the GPU state.
00065   void EmitProgramInfoR600(const MachineFunction &MF);
00066   void EmitProgramInfoSI(const MachineFunction &MF, const SIProgramInfo &KernelInfo);
00067 
00068 public:
00069   explicit AMDGPUAsmPrinter(TargetMachine &TM, MCStreamer &Streamer);
00070 
00071   bool runOnMachineFunction(MachineFunction &MF) override;
00072 
00073   const char *getPassName() const override {
00074     return "AMDGPU Assembly Printer";
00075   }
00076 
00077   /// Implemented in AMDGPUMCInstLower.cpp
00078   void EmitInstruction(const MachineInstr *MI) override;
00079 
00080   void EmitEndOfAsmFile(Module &M) override;
00081 
00082 protected:
00083   bool DisasmEnabled;
00084   std::vector<std::string> DisasmLines, HexLines;
00085   size_t DisasmLineMaxLen;
00086 };
00087 
00088 } // End anonymous llvm
00089 
00090 #endif