CorTeX Core ABI 7
ToolTech Software · C++ library reference
Loading...
Searching...
No Matches
ctxAssembler.h
Go to the documentation of this file.
1//*****************************************************************************
2// File : ctxAssembler.h
3// Description : Compilation of virtual machine opcodes into assembler
4// Author : Anders Modén
5// Product : CorTeX 2.0.1
6//
7// Copyright © 2015- Anders Modén, Sweden
8//
9// NOTE: CorTeX is a software development kit (SDK)
10// for neural networks and genetic programming.
11// Licensed by Anders Modén.
12//
13//
14// Revision History...
15//
16// Who Date Description
17//
18// AMO 150708 Created file (1.0.0)
19//
20//******************************************************************************
21#ifndef __CTX_ASSEMBLER_H__
22#define __CTX_ASSEMBLER_H__
23
24#include "ctxVirtualMachine.h"
25
26
27class ctxAssembler : public gzReference
28{
29public:
30
31 CTX_EXPORT gzVoid insertOpcode(const gzUInt32& opcode);
32
34
36
37 CTX_EXPORT gzUInt64 getSize() const;
38
39 CTX_EXPORT gzUInt64 getInstructions() const;
40
41 CTX_EXPORT gzBool getProgram(gzDynamicArray<gzUInt32>& program,gzBool clearProgram=TRUE);
42
43 CTX_EXPORT gzBool getProgram(gzDynamicLargeArray<gzUInt32>& program,gzBool clearProgram=TRUE);
44
45 // ------ Utilities -------------------------------------------------
46
47 CTX_EXPORT gzVoid disasm(gzBool addComment = TRUE, gzBool addOffset = TRUE, gzMessageLevel level=GZ_MESSAGE_DEBUG);
48
49 CTX_EXPORT static gzVoid disasm(const gzUInt32* commands, gzUInt32 len, gzBool addComment = TRUE, gzBool addOffset = TRUE, gzMessageLevel level = GZ_MESSAGE_DEBUG);
50
51 CTX_EXPORT static gzVoid disasm(gzSerializeAdapter* adapter, const gzUInt32* commands , gzUInt32 len, gzBool addComment = TRUE, gzBool addOffset = TRUE);
52
53 CTX_EXPORT gzVoid disasm(gzSerializeAdapter* adapter, gzBool addComment = TRUE, gzBool addOffset = TRUE);
54
55 CTX_EXPORT gzBool importOpcodes(const gzUInt32* code, gzUInt32 length, gzBool stopAtReturn = TRUE);
56
57 CTX_EXPORT static gzVoid disasmSubRoutine(const gzUInt32* commands, gzArray<ctxCommandBufferSubRoutine>& subroutines, gzBool showInstructions = FALSE, gzBool showThreadInfo = FALSE, gzInt32 targetPass = -1,gzMessageLevel level = GZ_MESSAGE_DEBUG);
58
59 CTX_EXPORT static gzVoid disasmSubRoutine(gzSerializeAdapter* adapter, const gzUInt32* commands, gzArray<ctxCommandBufferSubRoutine>& subroutines, gzBool showInstructions=FALSE, gzBool showThreadInfo=FALSE, gzInt32 targetPass=-1);
60
61 // ------ MNEMONICS --------------------------------------------------
62
63
64 CTX_EXPORT gzVoid nop(); // no operation
65 CTX_EXPORT gzVoid drop(); // pop stack
66 CTX_EXPORT gzVoid dup(); // duplicate and push stack
67
68 CTX_EXPORT gzVoid mul_param(const gzUInt32& param_reg_index);
69 CTX_EXPORT gzVoid mul_const(const gzFloat& constant);
70 CTX_EXPORT gzVoid mul();
71
72 CTX_EXPORT gzVoid add_param(const gzUInt32& param_reg_index);
73
74 CTX_EXPORT gzVoid recall_param(const gzUInt32& param_reg_index);
75
76 CTX_EXPORT gzVoid store_value(const gzUInt32& value_reg_index);
77 CTX_EXPORT gzVoid recall_value(const gzUInt32& value_reg_index);
78
79 CTX_EXPORT gzVoid recall_input(const gzUInt32& input_reg_index);
80 CTX_EXPORT gzVoid recall_input_byte(const gzUInt32& input_reg_index);
81
82 CTX_EXPORT gzVoid test_drop_value(const gzUInt32& drop_reg_index);
83 CTX_EXPORT gzVoid zero_drop_value(const gzUInt32& drop_reg_index);
84
85 CTX_EXPORT gzVoid store_delta(const gzUInt32& delta_reg_index);
86 CTX_EXPORT gzVoid recall_delta(const gzUInt32& delta_reg_index);
87
88 CTX_EXPORT gzVoid sum_n(const gzUInt32& n);
89
90 CTX_EXPORT gzVoid nfu(const ctxNeuronType& neuron);
91 CTX_EXPORT gzVoid ndf(const ctxNeuronType& neuron);
92
93 CTX_EXPORT gzVoid ret();
94
95 CTX_EXPORT gzVoid neg();
96
97 CTX_EXPORT gzVoid max_n(const gzUInt32& n);
98
99 CTX_EXPORT gzVoid equ();
100
101 CTX_EXPORT gzVoid store_delta_sum(const gzUInt32& delta_sum_reg_index);
102 CTX_EXPORT gzVoid recall_delta_sum(const gzUInt32& delta_sum_reg_index);
103
104 CTX_EXPORT gzVoid store_wb(const gzUInt32& wb_reg_index);
105 CTX_EXPORT gzVoid recall_wb(const gzUInt32& wb_reg_index);
106 CTX_EXPORT gzVoid update_wb(const gzUInt32& wb_reg_index);
107
108 CTX_EXPORT gzVoid math(const ctxMathFuncType& func);
109
110 CTX_EXPORT gzVoid skip_n(const gzUInt32& n);
111
112 CTX_EXPORT gzVoid finalize_param(const gzUInt32& param_reg_index, const gzUInt32& delta_count);
113 CTX_EXPORT gzVoid finalize_delta(const gzUInt32& wb_delta_reg_index);
114
115 CTX_EXPORT gzVoid store_general(const gzUInt32& general_reg_index);
116 CTX_EXPORT gzVoid recall_general(const gzUInt32& general_reg_index);
117
118 CTX_EXPORT gzVoid div();
119
120 CTX_EXPORT gzVoid recall_expected(const gzUInt32& expected_reg_index);
121
122 CTX_EXPORT gzVoid sub();
123
124 CTX_EXPORT gzVoid load(const gzFloat& constant);
125
126 CTX_EXPORT gzVoid store_temp(const gzUInt32& temp_reg_index);
127 CTX_EXPORT gzVoid recall_temp(const gzUInt32& temp_reg_index);
128
130
132
134
135 CTX_EXPORT gzVoid gradient_update(const gzUInt32& param_reg_index, const gzUInt32& delta_reg_index,gzBool use_lambda, const gzUInt32& depth_level);
136
137 CTX_EXPORT gzVoid clear_delta_sum(const gzUInt32& delta_reg_index, const gzUInt32& range);
138
140
141 CTX_EXPORT gzVoid mul_n(const gzUInt32& n);
142
144
145 CTX_EXPORT gzVoid recall_page_value(const gzUInt32& value_reg_index, const gzInt32& page_offset);
146
147 CTX_EXPORT gzVoid recall_page_delta(const gzUInt32& delta_reg_index, const gzInt32& page_offset);
148
149 CTX_EXPORT gzVoid mad(const gzUInt32& register_count, ctxRegistrySourceIndex register_a , const gzUInt32& register_a_index , const gzUInt32& register_a_stride, ctxRegistrySourceIndex register_b, const gzUInt32& register_b_index, const gzUInt32& register_b_stride);
150
151 CTX_EXPORT gzVoid recall_source(const gzUInt32& register_count, ctxRegistrySourceIndex register_source, const gzUInt32& register_source_index, const gzUInt32& register_source_stride);
152
153 CTX_EXPORT gzVoid store_source(const gzUInt32& register_count, ctxRegistrySourceIndex register_source, const gzUInt32& register_source_index, const gzUInt32& register_source_stride);
154
155 // Utilities ----------------------------------------
156
157 CTX_EXPORT gzUInt32 compileTempTokens(gzUInt32 command, gzUInt32 sum_count, gzUInt32 steps, gzUInt32 in_id, gzUInt32 shortToken);
158
159 CTX_EXPORT gzVoid setBreakInstruction(gzUInt64 position);
160
161private:
162
163 gzRefList<gzRefData<gzDynamicArray<gzUInt32>>> m_instrList;
164
165 gzUInt64 m_breakInstruction=0;
166
167 gzUInt32 m_instructions = 0;
168};
169
170
171#endif //__CTX_ASSEMBLER_H__
172
gzVoid recall_input_byte(const gzUInt32 &input_reg_index)
gzVoid collect_delta_sum()
gzVoid recall_page_delta(const gzUInt32 &delta_reg_index, const gzInt32 &page_offset)
gzVoid sum_n(const gzUInt32 &n)
gzVoid nfu(const ctxNeuronType &neuron)
gzVoid store_value(const gzUInt32 &value_reg_index)
gzVoid addInstruction()
gzVoid recall_delta_sum(const gzUInt32 &delta_sum_reg_index)
gzVoid max_n(const gzUInt32 &n)
gzVoid store_source(const gzUInt32 &register_count, ctxRegistrySourceIndex register_source, const gzUInt32 &register_source_index, const gzUInt32 &register_source_stride)
gzVoid disasm(gzBool addComment=TRUE, gzBool addOffset=TRUE, gzMessageLevel level=GZ_MESSAGE_DEBUG)
gzUInt64 getInstructions() const
gzVoid store_temp(const gzUInt32 &temp_reg_index)
gzVoid max_4()
gzVoid store_general(const gzUInt32 &general_reg_index)
gzVoid div()
static gzVoid disasm(const gzUInt32 *commands, gzUInt32 len, gzBool addComment=TRUE, gzBool addOffset=TRUE, gzMessageLevel level=GZ_MESSAGE_DEBUG)
gzVoid sum_4()
gzVoid neg()
gzVoid finalize_delta(const gzUInt32 &wb_delta_reg_index)
gzVoid drop()
gzVoid disasm(gzSerializeAdapter *adapter, gzBool addComment=TRUE, gzBool addOffset=TRUE)
gzVoid recall_page_value(const gzUInt32 &value_reg_index, const gzInt32 &page_offset)
gzVoid dup()
gzVoid add_param(const gzUInt32 &param_reg_index)
gzVoid clamp()
gzVoid mul_param(const gzUInt32 &param_reg_index)
gzVoid recall_temp(const gzUInt32 &temp_reg_index)
gzVoid ret()
gzBool importOpcodes(const gzUInt32 *code, gzUInt32 length, gzBool stopAtReturn=TRUE)
gzVoid mul_const(const gzFloat &constant)
gzVoid insertOpcode(const gzUInt32 &opcode)
gzBool getProgram(gzDynamicLargeArray< gzUInt32 > &program, gzBool clearProgram=TRUE)
gzVoid load(const gzFloat &constant)
gzVoid recall_value(const gzUInt32 &value_reg_index)
gzVoid equ()
gzVoid recall_input(const gzUInt32 &input_reg_index)
gzVoid mad(const gzUInt32 &register_count, ctxRegistrySourceIndex register_a, const gzUInt32 &register_a_index, const gzUInt32 &register_a_stride, ctxRegistrySourceIndex register_b, const gzUInt32 &register_b_index, const gzUInt32 &register_b_stride)
static gzVoid disasmSubRoutine(const gzUInt32 *commands, gzArray< ctxCommandBufferSubRoutine > &subroutines, gzBool showInstructions=FALSE, gzBool showThreadInfo=FALSE, gzInt32 targetPass=-1, gzMessageLevel level=GZ_MESSAGE_DEBUG)
gzVoid update_wb(const gzUInt32 &wb_reg_index)
gzBool getProgram(gzDynamicArray< gzUInt32 > &program, gzBool clearProgram=TRUE)
gzVoid mul_n(const gzUInt32 &n)
gzUInt64 getSize() const
gzVoid clearProgram()
gzVoid setBreakInstruction(gzUInt64 position)
gzVoid test_drop_value(const gzUInt32 &drop_reg_index)
gzVoid nop()
gzVoid store_wb(const gzUInt32 &wb_reg_index)
gzVoid skip_n(const gzUInt32 &n)
gzVoid math(const ctxMathFuncType &func)
gzVoid finalize_param(const gzUInt32 &param_reg_index, const gzUInt32 &delta_count)
gzVoid mul()
gzVoid recall_delta(const gzUInt32 &delta_reg_index)
gzVoid gradient_update(const gzUInt32 &param_reg_index, const gzUInt32 &delta_reg_index, gzBool use_lambda, const gzUInt32 &depth_level)
gzVoid recall_param(const gzUInt32 &param_reg_index)
static gzVoid disasm(gzSerializeAdapter *adapter, const gzUInt32 *commands, gzUInt32 len, gzBool addComment=TRUE, gzBool addOffset=TRUE)
gzVoid recall_expected(const gzUInt32 &expected_reg_index)
gzVoid clear_delta_sum(const gzUInt32 &delta_reg_index, const gzUInt32 &range)
gzVoid store_delta_sum(const gzUInt32 &delta_sum_reg_index)
gzVoid ndf(const ctxNeuronType &neuron)
gzVoid store_delta(const gzUInt32 &delta_reg_index)
gzUInt32 compileTempTokens(gzUInt32 command, gzUInt32 sum_count, gzUInt32 steps, gzUInt32 in_id, gzUInt32 shortToken)
gzVoid mul_4()
gzVoid sub()
gzVoid recall_general(const gzUInt32 &general_reg_index)
static gzVoid disasmSubRoutine(gzSerializeAdapter *adapter, const gzUInt32 *commands, gzArray< ctxCommandBufferSubRoutine > &subroutines, gzBool showInstructions=FALSE, gzBool showThreadInfo=FALSE, gzInt32 targetPass=-1)
gzVoid zero_drop_value(const gzUInt32 &drop_reg_index)
gzVoid recall_wb(const gzUInt32 &wb_reg_index)
gzVoid recall_source(const gzUInt32 &register_count, ctxRegistrySourceIndex register_source, const gzUInt32 &register_source_index, const gzUInt32 &register_source_stride)
#define CTX_EXPORT
Definition ctxBase.h:68
ctxRegistrySourceIndex
ctxNeuronType
ctxMathFuncType