2013-11-10 09:03:59 +08:00
|
|
|
//===-- AMDGPUAsmPrinter.h - Print AMDGPU assembly code ---------*- C++ -*-===//
|
2012-12-12 05:25:42 +08: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-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_R600_AMDGPUASMPRINTER_H
|
|
|
|
#define LLVM_LIB_TARGET_R600_AMDGPUASMPRINTER_H
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
2013-10-12 13:02:51 +08:00
|
|
|
#include <vector>
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class AMDGPUAsmPrinter : public AsmPrinter {
|
2013-12-05 13:15:35 +08:00
|
|
|
private:
|
|
|
|
struct SIProgramInfo {
|
2014-04-16 06:40:47 +08:00
|
|
|
SIProgramInfo() :
|
2014-12-03 05:28:53 +08:00
|
|
|
VGPRBlocks(0),
|
|
|
|
SGPRBlocks(0),
|
2014-06-27 01:22:30 +08:00
|
|
|
Priority(0),
|
|
|
|
FloatMode(0),
|
|
|
|
Priv(0),
|
|
|
|
DX10Clamp(0),
|
|
|
|
DebugMode(0),
|
|
|
|
IEEEMode(0),
|
2014-07-21 23:45:01 +08:00
|
|
|
ScratchSize(0),
|
2014-12-03 05:28:53 +08:00
|
|
|
ComputePGMRSrc1(0),
|
|
|
|
LDSBlocks(0),
|
|
|
|
ScratchBlocks(0),
|
|
|
|
ComputePGMRSrc2(0),
|
|
|
|
NumVGPR(0),
|
|
|
|
NumSGPR(0),
|
2014-09-15 23:41:53 +08:00
|
|
|
FlatUsed(false),
|
|
|
|
VCCUsed(false),
|
2014-06-27 01:22:30 +08:00
|
|
|
CodeLen(0) {}
|
2014-04-16 06:40:47 +08:00
|
|
|
|
2014-06-27 01:22:30 +08:00
|
|
|
// Fields set in PGM_RSRC1 pm4 packet.
|
2014-12-03 05:28:53 +08:00
|
|
|
uint32_t VGPRBlocks;
|
|
|
|
uint32_t SGPRBlocks;
|
2014-06-27 01:22:30 +08:00
|
|
|
uint32_t Priority;
|
|
|
|
uint32_t FloatMode;
|
|
|
|
uint32_t Priv;
|
|
|
|
uint32_t DX10Clamp;
|
|
|
|
uint32_t DebugMode;
|
|
|
|
uint32_t IEEEMode;
|
2014-07-21 23:45:01 +08:00
|
|
|
uint32_t ScratchSize;
|
2014-06-27 01:22:30 +08:00
|
|
|
|
2014-12-03 05:28:53 +08: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 23:41:53 +08:00
|
|
|
bool FlatUsed;
|
|
|
|
|
2014-06-27 01:22:30 +08:00
|
|
|
// Bonus information for debugging.
|
2014-09-15 23:41:53 +08:00
|
|
|
bool VCCUsed;
|
2014-04-16 06:40:47 +08:00
|
|
|
uint64_t CodeLen;
|
2013-12-05 13:15:35 +08:00
|
|
|
};
|
|
|
|
|
2014-07-13 11:06:43 +08:00
|
|
|
void getSIProgramInfo(SIProgramInfo &Out, const MachineFunction &MF) const;
|
|
|
|
void findNumUsedRegistersSI(const MachineFunction &MF,
|
2013-12-05 13:15:35 +08: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 11:06:43 +08:00
|
|
|
void EmitProgramInfoR600(const MachineFunction &MF);
|
|
|
|
void EmitProgramInfoSI(const MachineFunction &MF, const SIProgramInfo &KernelInfo);
|
2014-12-03 06:00:07 +08:00
|
|
|
void EmitAmdKernelCodeT(const MachineFunction &MF,
|
|
|
|
const SIProgramInfo &KernelInfo) const;
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
public:
|
2015-01-19 04:29:04 +08:00
|
|
|
explicit AMDGPUAsmPrinter(TargetMachine &TM,
|
|
|
|
std::unique_ptr<MCStreamer> Streamer);
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2014-04-29 15:57:24 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2014-04-29 15:57:24 +08:00
|
|
|
const char *getPassName() const override {
|
2012-12-12 05:25:42 +08:00
|
|
|
return "AMDGPU Assembly Printer";
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Implemented in AMDGPUMCInstLower.cpp
|
2014-04-29 15:57:24 +08:00
|
|
|
void EmitInstruction(const MachineInstr *MI) override;
|
2013-10-12 13:02:51 +08:00
|
|
|
|
2014-07-21 22:01:14 +08:00
|
|
|
void EmitEndOfAsmFile(Module &M) override;
|
|
|
|
|
2015-04-08 09:09:26 +08:00
|
|
|
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
|
|
|
unsigned AsmVariant, const char *ExtraCode,
|
|
|
|
raw_ostream &O);
|
|
|
|
|
2013-10-12 13:02:51 +08:00
|
|
|
protected:
|
|
|
|
std::vector<std::string> DisasmLines, HexLines;
|
|
|
|
size_t DisasmLineMaxLen;
|
2012-12-12 05:25:42 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End anonymous llvm
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#endif
|