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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-03-11 16:00:27 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUASMPRINTER_H
|
|
|
|
#define LLVM_LIB_TARGET_AMDGPU_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 {
|
|
|
|
|
2016-03-11 16:00:27 +08:00
|
|
|
class AMDGPUAsmPrinter final : 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),
|
2016-04-26 23:43:14 +08:00
|
|
|
ReservedVGPRFirst(0),
|
|
|
|
ReservedVGPRCount(0),
|
2014-09-15 23:41:53 +08:00
|
|
|
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;
|
|
|
|
|
2016-04-27 01:24:40 +08:00
|
|
|
// If ReservedVGPRCount is 0 then must be 0. Otherwise, this is the first
|
|
|
|
// fixed VGPR number reserved.
|
2016-04-26 23:43:14 +08:00
|
|
|
uint16_t ReservedVGPRFirst;
|
2016-04-27 01:24:40 +08:00
|
|
|
// The number of consecutive VGPRs reserved.
|
2016-04-26 23:43:14 +08:00
|
|
|
uint16_t ReservedVGPRCount;
|
|
|
|
|
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
|
|
|
|
2015-06-27 05:14:58 +08:00
|
|
|
void EmitFunctionBodyStart() override;
|
|
|
|
|
2015-11-06 19:45:14 +08:00
|
|
|
void EmitFunctionEntryLabel() override;
|
|
|
|
|
2015-12-03 01:00:42 +08:00
|
|
|
void EmitGlobalVariable(const GlobalVariable *GV) override;
|
|
|
|
|
2016-01-13 01:18:17 +08:00
|
|
|
void EmitStartOfAsmFile(Module &M) override;
|
|
|
|
|
2015-04-08 09:09:26 +08:00
|
|
|
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
|
|
|
unsigned AsmVariant, const char *ExtraCode,
|
2015-04-08 10:07:05 +08:00
|
|
|
raw_ostream &O) override;
|
2015-04-08 09:09:26 +08:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2015-06-23 17:49:53 +08:00
|
|
|
} // End anonymous llvm
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#endif
|