source: CLRX/CLRadeonExtender/trunk/amdasm/AsmROCmInternals.h @ 3668

Last change on this file since 3668 was 3668, checked in by matszpk, 2 years ago

CLRadeonExtender: AsmROCm: Add '.newbinfmt' and '.globaldata' pseudo-ops. ROCmBinGen: small fixes.

File size: 7.1 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_ASMROCMINTERNALS_H__
21#define __CLRX_ASMROCMINTERNALS_H__
22
23#include <CLRX/Config.h>
24#include <cstdint>
25#include <string>
26#include <unordered_set>
27#include <utility>
28#include <memory>
29#include <CLRX/utils/Utilities.h>
30#include <CLRX/amdasm/Assembler.h>
31#include "GCNInternals.h"
32#include "AsmInternals.h"
33
34namespace CLRX
35{
36
37enum ROCmConfigValueTarget
38{
39    ROCMCVAL_SGPRSNUM,
40    ROCMCVAL_VGPRSNUM,
41    ROCMCVAL_PRIVMODE,
42    ROCMCVAL_DEBUGMODE,
43    ROCMCVAL_DX10CLAMP,
44    ROCMCVAL_IEEEMODE,
45    ROCMCVAL_TGSIZE,
46    ROCMCVAL_FLOATMODE,
47    ROCMCVAL_PRIORITY,
48    ROCMCVAL_EXCEPTIONS,
49    ROCMCVAL_USERDATANUM,
50    ROCMCVAL_PGMRSRC1,
51    ROCMCVAL_PGMRSRC2,
52    ROCMCVAL_KERNEL_CODE_ENTRY_OFFSET,
53    ROCMCVAL_KERNEL_CODE_PREFETCH_OFFSET,
54    ROCMCVAL_KERNEL_CODE_PREFETCH_SIZE,
55    ROCMCVAL_MAX_SCRATCH_BACKING_MEMORY,
56    ROCMCVAL_USE_PRIVATE_SEGMENT_BUFFER,
57    ROCMCVAL_USE_DISPATCH_PTR,
58    ROCMCVAL_USE_QUEUE_PTR,
59    ROCMCVAL_USE_KERNARG_SEGMENT_PTR,
60    ROCMCVAL_USE_DISPATCH_ID,
61    ROCMCVAL_USE_FLAT_SCRATCH_INIT,
62    ROCMCVAL_USE_PRIVATE_SEGMENT_SIZE,
63    ROCMCVAL_USE_ORDERED_APPEND_GDS,
64    ROCMCVAL_PRIVATE_ELEM_SIZE,
65    ROCMCVAL_USE_PTR64,
66    ROCMCVAL_USE_DYNAMIC_CALL_STACK,
67    ROCMCVAL_USE_DEBUG_ENABLED,
68    ROCMCVAL_USE_XNACK_ENABLED,
69    ROCMCVAL_WORKITEM_PRIVATE_SEGMENT_SIZE,
70    ROCMCVAL_WORKGROUP_GROUP_SEGMENT_SIZE,
71    ROCMCVAL_GDS_SEGMENT_SIZE,
72    ROCMCVAL_KERNARG_SEGMENT_SIZE,
73    ROCMCVAL_WORKGROUP_FBARRIER_COUNT,
74    ROCMCVAL_WAVEFRONT_SGPR_COUNT,
75    ROCMCVAL_WORKITEM_VGPR_COUNT,
76    ROCMCVAL_DEBUG_WAVEFRONT_PRIVATE_SEGMENT_OFFSET_SGPR,
77    ROCMCVAL_DEBUG_PRIVATE_SEGMENT_BUFFER_SGPR,
78    ROCMCVAL_KERNARG_SEGMENT_ALIGN,
79    ROCMCVAL_GROUP_SEGMENT_ALIGN,
80    ROCMCVAL_PRIVATE_SEGMENT_ALIGN,
81    ROCMCVAL_WAVEFRONT_SIZE,
82    ROCMCVAL_CALL_CONVENTION,
83    ROCMCVAL_RUNTIME_LOADER_KERNEL_SYMBOL
84};
85
86struct CLRX_INTERNAL AsmROCmPseudoOps: AsmPseudoOps
87{
88    static bool checkPseudoOpName(const CString& string);
89   
90    // .arch_minor
91    static void setArchMinor(AsmROCmHandler& handler, const char* linePtr);
92    // .arch_stepping
93    static void setArchStepping(AsmROCmHandler& handler, const char* linePtr);
94    // set elf eflags
95    static void setEFlags(AsmROCmHandler& handler, const char* linePtr);
96   
97    // .target
98    static void setTarget(AsmROCmHandler& handler, const char* linePtr);
99   
100    /* user configuration pseudo-ops */
101    static void doConfig(AsmROCmHandler& handler, const char* pseudoOpPlace,
102                      const char* linePtr);
103    // .control_directive (open this seciton)
104    static void doControlDirective(AsmROCmHandler& handler, const char* pseudoOpPlace,
105                      const char* linePtr);
106    // .metadata
107    static void addMetadata(AsmROCmHandler& handler, const char* pseudoOpPlace,
108                      const char* linePtr);
109   
110    // .fkernel (define kernel as function kernel)
111    static void doFKernel(AsmROCmHandler& handler, const char* pseudoOpPlace,
112                      const char* linePtr);
113    // .globaldata (go to global data (.rodata))
114    static void doGlobalData(AsmROCmHandler& handler, const char* pseudoOpPlace,
115                      const char* linePtr);
116    // .newbinfmt
117    static void setNewBinFormat(AsmROCmHandler& handler, const char* linePtr);
118   
119    // checkConfigValue, setConfigValueMain routines used by other handlers
120    // to check and set AMD HSA config value
121    static bool checkConfigValue(Assembler& asmr, const char* valuePlace,
122                    ROCmConfigValueTarget target, uint64_t value);
123    static void setConfigValueMain(AsmAmdHsaKernelConfig& config,
124                        ROCmConfigValueTarget target, uint64_t value);
125    // set config value
126    static void setConfigValue(AsmROCmHandler& handler, const char* pseudoOpPlace,
127                      const char* linePtr, ROCmConfigValueTarget target);
128   
129    // setConfigBoolValueMain routines used by other handlers to set AMD HSA config values
130    static void setConfigBoolValueMain(AsmAmdHsaKernelConfig& config,
131                        ROCmConfigValueTarget target);
132    // set boolean config value
133    static void setConfigBoolValue(AsmROCmHandler& handler, const char* pseudoOpPlace,
134                      const char* linePtr, ROCmConfigValueTarget target);
135   
136    static void setDefaultHSAFeatures(AsmROCmHandler& handler, const char* pseudoOpPlace,
137                      const char* linePtr);
138    // .dims (set dimensions)
139    static void setDimensions(AsmROCmHandler& handler, const char* pseudoOpPlace,
140                      const char* linePtr);
141    // common routine used by other handlers to parse AMD HSA machine
142    static bool parseMachine(Assembler& asmr, const char* linePtr,
143                uint16_t& machineKind, uint16_t& machineMajor, uint16_t& machineMinor,
144                uint16_t& machineStepping);
145    // .machine
146    static void setMachine(AsmROCmHandler& handler, const char* pseudoOpPlace,
147                      const char* linePtr);
148    // common routine used by other handlers to parse AMD HSA code version
149    static bool parseCodeVersion(Assembler& asmr, const char* linePtr,
150                uint16_t& codeMajor, uint16_t& codeMinor);
151    // .codeversion
152    static void setCodeVersion(AsmROCmHandler& handler, const char* pseudoOpPlace,
153                      const char* linePtr);
154    // common routine used by other handlers to parse AMD HSA reserved registers
155    static bool parseReservedXgprs(Assembler& asmr, const char* linePtr, bool inVgpr,
156                uint16_t& gprFirst, uint16_t& gprCount);
157    // .reserved_sgprs or .reserved_vgprs
158    static void setReservedXgprs(AsmROCmHandler& handler, const char* pseudoOpPlace,
159                      const char* linePtr, bool inVgpr);
160    // .use_grid_workgroup_count
161    static void setUseGridWorkGroupCount(AsmROCmHandler& handler,
162                      const char* pseudoOpPlace, const char* linePtr);
163   
164    // .kcode (open kernel code)
165    static void doKCode(AsmROCmHandler& handler, const char* pseudoOpPlace,
166                      const char* linePtr);
167    // .kcodeend (close kernel code)
168    static void doKCodeEnd(AsmROCmHandler& handler, const char* pseudoOpPlace,
169                      const char* linePtr);
170    static void updateKCodeSel(AsmROCmHandler& handler,
171                      const std::vector<cxuint>& oldset);
172};
173
174};
175
176#endif
Note: See TracBrowser for help on using the repository browser.