2013-11-10 01:03:59 +00:00
|
|
|
//===-- AMDGPUAsmPrinter.h - Print AMDGPU assembly code ---------*- C++ -*-===//
|
2012-12-11 21:25:42 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
|
|
|
/// \brief AMDGPU Assembly printer class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_LIB_TARGET_R600_AMDGPUASMPRINTER_H
|
|
|
|
#define LLVM_LIB_TARGET_R600_AMDGPUASMPRINTER_H
|
2012-12-11 21:25:42 +00:00
|
|
|
|
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
2013-10-12 05:02:51 +00:00
|
|
|
#include <vector>
|
2012-12-11 21:25:42 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class AMDGPUAsmPrinter : public AsmPrinter {
|
2013-12-05 05:15:35 +00:00
|
|
|
private:
|
|
|
|
struct SIProgramInfo {
|
2014-04-15 22:40:47 +00:00
|
|
|
SIProgramInfo() :
|
2014-12-02 21:28:53 +00:00
|
|
|
VGPRBlocks(0),
|
|
|
|
SGPRBlocks(0),
|
2014-06-26 17:22:30 +00:00
|
|
|
Priority(0),
|
|
|
|
FloatMode(0),
|
|
|
|
Priv(0),
|
|
|
|
DX10Clamp(0),
|
|
|
|
DebugMode(0),
|
|
|
|
IEEEMode(0),
|
2014-07-21 15:45:01 +00:00
|
|
|
ScratchSize(0),
|
2014-12-02 21:28:53 +00:00
|
|
|
ComputePGMRSrc1(0),
|
|
|
|
LDSBlocks(0),
|
|
|
|
ScratchBlocks(0),
|
|
|
|
ComputePGMRSrc2(0),
|
|
|
|
NumVGPR(0),
|
|
|
|
NumSGPR(0),
|
2014-09-15 15:41:53 +00:00
|
|
|
FlatUsed(false),
|
|
|
|
VCCUsed(false),
|
2014-06-26 17:22:30 +00:00
|
|
|
CodeLen(0) {}
|
2014-04-15 22:40:47 +00:00
|
|
|
|
2014-06-26 17:22:30 +00:00
|
|
|
// Fields set in PGM_RSRC1 pm4 packet.
|
2014-12-02 21:28:53 +00:00
|
|
|
uint32_t VGPRBlocks;
|
|
|
|
uint32_t SGPRBlocks;
|
2014-06-26 17:22:30 +00:00
|
|
|
uint32_t Priority;
|
|
|
|
uint32_t FloatMode;
|
|
|
|
uint32_t Priv;
|
|
|
|
uint32_t DX10Clamp;
|
|
|
|
uint32_t DebugMode;
|
|
|
|
uint32_t IEEEMode;
|
2014-07-21 15:45:01 +00:00
|
|
|
uint32_t ScratchSize;
|
2014-06-26 17:22:30 +00:00
|
|
|
|
2014-12-02 21:28:53 +00:00
|
|
|
uint64_t ComputePGMRSrc1;
|
|
|
|
|
|
|
|
// Fields set in PGM_RSRC2 pm4 packet.
|
|
|
|
uint32_t LDSBlocks;
|
|
|
|
uint32_t ScratchBlocks;
|
|
|
|
|
|
|
|
uint64_t ComputePGMRSrc2;
|
|
|
|
|
|
|
|
uint32_t NumVGPR;
|
|
|
|
uint32_t NumSGPR;
|
|
|
|
uint32_t LDSSize;
|
2014-09-15 15:41:53 +00:00
|
|
|
bool FlatUsed;
|
|
|
|
|
2014-06-26 17:22:30 +00:00
|
|
|
// Bonus information for debugging.
|
2014-09-15 15:41:53 +00:00
|
|
|
bool VCCUsed;
|
2014-04-15 22:40:47 +00:00
|
|
|
uint64_t CodeLen;
|
2013-12-05 05:15:35 +00:00
|
|
|
};
|
|
|
|
|
2014-07-13 03:06:43 +00:00
|
|
|
void getSIProgramInfo(SIProgramInfo &Out, const MachineFunction &MF) const;
|
|
|
|
void findNumUsedRegistersSI(const MachineFunction &MF,
|
2013-12-05 05:15:35 +00:00
|
|
|
unsigned &NumSGPR,
|
|
|
|
unsigned &NumVGPR) const;
|
|
|
|
|
|
|
|
/// \brief Emit register usage information so that the GPU driver
|
|
|
|
/// can correctly setup the GPU state.
|
2014-07-13 03:06:43 +00:00
|
|
|
void EmitProgramInfoR600(const MachineFunction &MF);
|
|
|
|
void EmitProgramInfoSI(const MachineFunction &MF, const SIProgramInfo &KernelInfo);
|
2014-12-02 22:00:07 +00:00
|
|
|
void EmitAmdKernelCodeT(const MachineFunction &MF,
|
|
|
|
const SIProgramInfo &KernelInfo) const;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
|
|
|
public:
|
2015-01-18 20:29:04 +00:00
|
|
|
explicit AMDGPUAsmPrinter(TargetMachine &TM,
|
|
|
|
std::unique_ptr<MCStreamer> Streamer);
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2014-04-29 07:57:24 +00:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2014-04-29 07:57:24 +00:00
|
|
|
const char *getPassName() const override {
|
2012-12-11 21:25:42 +00:00
|
|
|
return "AMDGPU Assembly Printer";
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Implemented in AMDGPUMCInstLower.cpp
|
2014-04-29 07:57:24 +00:00
|
|
|
void EmitInstruction(const MachineInstr *MI) override;
|
2013-10-12 05:02:51 +00:00
|
|
|
|
2014-07-21 14:01:14 +00:00
|
|
|
void EmitEndOfAsmFile(Module &M) override;
|
|
|
|
|
2013-10-12 05:02:51 +00:00
|
|
|
protected:
|
|
|
|
std::vector<std::string> DisasmLines, HexLines;
|
|
|
|
size_t DisasmLineMaxLen;
|
2012-12-11 21:25:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End anonymous llvm
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#endif
|