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

Last change on this file since 4997 was 4997, checked in by matszpk, 11 months ago

CLRadeonExtender: GCNDisasm: Add support for SMRD immediate 32-bit literal for offset if arch==GCN1.1. Some changes in assembler.

File size: 6.4 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              bool useSRMDLit = false);
48    // decode GCN operand (version without literal)
49    static void decodeGCNOperandNoLit(GCNDisassembler& dasm, cxuint op, cxuint regNum,
50              char*& bufPtr, GPUArchMask arch, FloatLitType floatLit = FLTLIT_NONE);
51    // decodee GCN operand (include literal, can decode relocations)
52    static char* decodeGCNOperand(GCNDisassembler& dasm, size_t codePos,
53              RelocIter& relocIter, cxuint op, cxuint regNum, GPUArchMask arch,
54              uint32_t literal = 0, FloatLitType floatLit = FLTLIT_NONE,
55              bool useSMRDLit = false);
56   
57    static void decodeSOPCEncoding(GCNDisassembler& dasm,
58             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
59             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal);
60   
61    static void decodeSOPPEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
62             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
63             uint32_t literal, size_t pos);
64   
65    static void decodeSOP1Encoding(GCNDisassembler& dasm,
66             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
67             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal);
68   
69    static void decodeSOP2Encoding(GCNDisassembler& dasm,
70             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
71             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal);
72   
73    static void decodeSOPKEncoding(GCNDisassembler& dasm,
74             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
75             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal);
76   
77    static void decodeSMRDEncoding(GCNDisassembler& dasm,
78            size_t codePos, RelocIter& relocIter, cxuint spacesToAdd,
79            GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
80            uint32_t literal);
81   
82    static void decodeSMEMEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
83            GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
84            uint32_t insnCode2);
85   
86    static void decodeVOPCEncoding(GCNDisassembler& dasm,
87             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
88             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal,
89             FloatLitType displayFloatLits, Flags flags);
90   
91    static void decodeVOP1Encoding(GCNDisassembler& dasm,
92             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
93             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal,
94             FloatLitType displayFloatLits);
95   
96    static void decodeVOP2Encoding(GCNDisassembler& dasm,
97             size_t codePos, RelocIter& relocIter, cxuint spacesToAdd, GPUArchMask arch,
98             const GCNInstruction& gcnInsn, uint32_t insnCode, uint32_t literal,
99             FloatLitType displayFloatLits, Flags flags);
100   
101    static void decodeVOP3Encoding(GCNDisassembler& dasm, size_t codePos,
102            RelocIter& relocIter, cxuint spacesToAdd,
103            GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
104            uint32_t insnCode2, uint32_t literal, FloatLitType displayFloatLits,
105            Flags flags);
106   
107    static void decodeVINTRPEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
108             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode);
109   
110    static void decodeDSEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
111             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
112             uint32_t insnCode2);
113   
114    static void decodeMUBUFEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
115            GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
116            uint32_t insnCode2);
117   
118    static void decodeMIMGEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
119             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
120             uint32_t insnCode2);
121    static void decodeMIMGEncodingGFX10(GCNDisassembler& dasm, cxuint spacesToAdd,
122             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
123             uint32_t insnCode2, uint32_t insnCode3, uint32_t insnCode4,
124             uint32_t insnCode5);
125   
126    static void decodeEXPEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
127             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
128             uint32_t insnCode2);
129
130    static void printFLATAddr(cxuint flatMode, char*& bufPtr, uint32_t insnCode2,
131                              cxuint nullCode);
132   
133    static void decodeFLATEncoding(GCNDisassembler& dasm, cxuint spacesToAdd,
134             GPUArchMask arch, const GCNInstruction& gcnInsn, uint32_t insnCode,
135             uint32_t insnCode2);
136};
137
138};
139
140#endif
Note: See TracBrowser for help on using the repository browser.