source: CLRX/CLRadeonExtender/trunk/amdasm/GCNDisasmInternals.h @ 4833

Last change on this file since 4833 was 4833, checked in by matszpk, 14 months ago

CLRadeonExtender: Disasm: Add literals to VOP3 encoding for GFX10.

File size: 6.3 KB
Line 
1/*
2 *  CLRadeonExtender - Unofficial OpenCL Radeon Extensions Library
3 *  Copyright (C) 2014-2018 Mateusz Szpakowski
4 *
5 *  This library is free software; you can redistribute it and/or
6 *  modify it under the terms of the GNU Lesser General Public
7 *  License as published by the Free Software Foundation; either
8 *  version 2.1 of the License, or (at your option) any later version.
9 *
10 *  This library is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 *  Lesser General Public License for more details.
14 *
15 *  You should have received a copy of the GNU Lesser General Public
16 *  License along with this library; if not, write to the Free Software
17 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19
20#ifndef __CLRX_GCNDISASMINTERNALS_H__
21#define __CLRX_GCNDISASMINTERNALS_H__
22
23#include <CLRX/Config.h>
24#include <CLRX/utils/Utilities.h>
25#include <CLRX/utils/GPUId.h>
26#include <CLRX/amdasm/Disassembler.h>
27#include "GCNInternals.h"
28
29namespace CLRX
30{
31
32// type of floating litera
33enum FloatLitType: cxbyte
34{
35    FLTLIT_NONE,    // none
36    FLTLIT_F32,     // single precision
37    FLTLIT_F16      // half precision
38};
39
40// GCN disassembler code in structure (this allow to access private code of
41// GCNDisassembler by these routines
42struct CLRX_INTERNAL GCNDisasmUtils
43{
44    typedef GCNDisassembler::RelocIter RelocIter;
45    static void printLiteral(GCNDisassembler& dasm, size_t codePos, RelocIter& relocIter,
46              uint32_t literal, FloatLitType floatLit, bool optional);
47    // decode GCN operand (version without literal)
48    static void decodeGCNOperandNoLit(GCNDisassembler& dasm, cxuint op, cxuint regNum,
49              char*& bufPtr, GPUArchMask arch, FloatLitType floatLit = FLTLIT_NONE);
50    // decodee GCN operand (include literal, can decode relocations)
51    static char* decodeGCNOperand(GCNDisassembler& dasm, size_t codePos,
52              RelocIter& relocIter, cxuint op, cxuint regNum, GPUArchMask arch,
53              uint32_t literal = 0, FloatLitType floatLit = FLTLIT_NONE);
54   
55    static void decodeSOPCEncoding(GCNDisassembler& dasm,
56             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
57             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal);
58   
59    static void decodeSOPPEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
60             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
61             uint32_t literal, size_t pos);
62   
63    static void decodeSOP1Encoding(GCNDisassembler& dasm,
64             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
65             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal);
66   
67    static void decodeSOP2Encoding(GCNDisassembler& dasm,
68             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
69             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal);
70   
71    static void decodeSOPKEncoding(GCNDisassembler& dasm,
72             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
73             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal);
74   
75    static void decodeSMRDEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
76            GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode);
77   
78    static void decodeSMEMEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
79            GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
80            uint32_t insnCode2);
81   
82    static void decodeVOPCEncoding(GCNDisassembler& dasm,
83             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
84             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal,
85             FloatLitType displayFloatLits, Flags flags);
86   
87    static void decodeVOP1Encoding(GCNDisassembler& dasm,
88             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
89             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal,
90             FloatLitType displayFloatLits);
91   
92    static void decodeVOP2Encoding(GCNDisassembler& dasm,
93             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
94             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal,
95             FloatLitType displayFloatLits, Flags flags);
96   
97    static void decodeVOP3Encoding(GCNDisassembler& dasm, size_t codePos,
98            RelocIter& relocIter, cxuint spacesToAdd,
99            GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
100            uint32_t insnCode2, uint32_t literal, FloatLitType displayFloatLits,
101            Flags flags);
102   
103    static void decodeVINTRPEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
104             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode);
105   
106    static void decodeDSEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
107             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
108             uint32_t insnCode2);
109   
110    static void decodeMUBUFEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
111            GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
112            uint32_t insnCode2);
113   
114    static void decodeMIMGEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
115             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
116             uint32_t insnCode2);
117    static void decodeMIMGEncodingGFX10(GCNDisassembler& dasm, cxuint spacesToAdd,
118             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
119             uint32_t insnCode2, uint32_t insnCode3, uint32_t insnCode4,
120             uint32_t insnCode5);
121   
122    static void decodeEXPEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
123             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
124             uint32_t insnCode2);
125
126    static void printFLATAddr(cxuint flatMode, char*& bufPtr, uint32_t insnCode2,
127                              cxuint nullCode);
128   
129    static void decodeFLATEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
130             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
131             uint32_t insnCode2);
132};
133
134};
135
136#endif
Note: See TracBrowser for help on using the repository browser.