summaryrefslogtreecommitdiffstats
path: root/tinySIGCOMP/src/tcomp_instructions.h
blob: ae2c5b490752035462e596ec89185cd9769199e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
*	
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*	
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*	
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/

/**@file tcomp_instructions.h
 * @brief List of all supported UDVM instructions as per RFC 3320 subclause 9.
 *
 * @author Mamadou Diop <diopmamadou(at)yahoo.fr>
 *

 */

#ifndef TCOMP_INSTRUCTIONS_H
#define TCOMP_INSTRUCTIONS_H

/************************************************************************************
* Instruction								Bytecode value		Cost in UDVM cycles	*
*************************************************************************************/
#define TCOMP_UDVM_INST__DECOMPRESSION_FAILURE		0					//1
#define TCOMP_UDVM_INST__AND						1					//1
#define TCOMP_UDVM_INST__OR							2					//1
#define TCOMP_UDVM_INST__NOT						3					//1
#define TCOMP_UDVM_INST__LSHIFT						4					//1
#define TCOMP_UDVM_INST__RSHIFT						5					//1
#define TCOMP_UDVM_INST__ADD						6					//1
#define TCOMP_UDVM_INST__SUBTRACT					7					//1
#define TCOMP_UDVM_INST__MULTIPLY					8					//1
#define TCOMP_UDVM_INST__DIVIDE						9					//1
#define TCOMP_UDVM_INST__REMAINDER					10					//1
#define TCOMP_UDVM_INST__SORT_ASCENDING				11					//1 + k * (ceiling(log2(k)) + n)
#define TCOMP_UDVM_INST__SORT_DESCENDING			12					//1 + k * (ceiling(log2(k)) + n)
#define TCOMP_UDVM_INST__SHA_1						13					//1 + length
#define TCOMP_UDVM_INST__LOAD						14					//1
#define TCOMP_UDVM_INST__MULTILOAD					15					//1 + n
#define TCOMP_UDVM_INST__PUSH						16					//1
#define TCOMP_UDVM_INST__POP						17					//1
#define TCOMP_UDVM_INST__COPY						18					//1 + length
#define TCOMP_UDVM_INST__COPY_LITERAL				19					//1 + length
#define TCOMP_UDVM_INST__COPY_OFFSET				20					//1 + length
#define TCOMP_UDVM_INST__MEMSET						21					//1 + length
#define TCOMP_UDVM_INST__JUMP						22					//1
#define TCOMP_UDVM_INST__COMPARE					23					//1
#define TCOMP_UDVM_INST__CALL						24					//1
#define TCOMP_UDVM_INST__RETURN						25					//1
#define TCOMP_UDVM_INST__SWITCH						26					//1 + n
#define TCOMP_UDVM_INST__CRC						27					//1 + length
#define TCOMP_UDVM_INST__INPUT_BYTES				28					//1 + length
#define TCOMP_UDVM_INST__INPUT_BITS					29					//1
#define TCOMP_UDVM_INST__INPUT_HUFFMAN				30					//1 + n
#define TCOMP_UDVM_INST__STATE_ACCESS				31					//1 + state_length
#define TCOMP_UDVM_INST__STATE_CREATE				32					//1 + state_length
#define TCOMP_UDVM_INST__STATE_FREE					33					//1
#define TCOMP_UDVM_INST__OUTPUT						34					//1 + output_length
#define TCOMP_UDVM_INST__END_MESSAGE				35					//1 + state_length

typedef struct tcomp_inst_desc_s
{
	int32_t code;
	const char* desc;
}
tcomp_inst_desc_t;

static const tcomp_inst_desc_t TCOMP_INST_DESCRIPTIONS[] =
{
	{ TCOMP_UDVM_INST__DECOMPRESSION_FAILURE, "DECOMPRESSION_FAILURE"},
	{ TCOMP_UDVM_INST__AND, "AND"},
	{ TCOMP_UDVM_INST__OR, "OR"},
	{ TCOMP_UDVM_INST__NOT, "NOT"},
	{ TCOMP_UDVM_INST__LSHIFT, "LSHIFT"},
	{ TCOMP_UDVM_INST__RSHIFT, "RSHIFT"},
	{ TCOMP_UDVM_INST__ADD, "ADD"},
	{ TCOMP_UDVM_INST__SUBTRACT, "SUBTRACT"},
	{ TCOMP_UDVM_INST__MULTIPLY, "MULTIPLY"},
	{ TCOMP_UDVM_INST__DIVIDE, "DIVIDE"},
	{ TCOMP_UDVM_INST__REMAINDER, "REMAINDER"},
	{ TCOMP_UDVM_INST__SORT_ASCENDING, "SORT-ASCENDING"},
	{ TCOMP_UDVM_INST__SORT_DESCENDING, "SORT-DESCENDING"},
	{ TCOMP_UDVM_INST__SHA_1, "SHA-1"},
	{ TCOMP_UDVM_INST__LOAD, "LOAD"},
	{ TCOMP_UDVM_INST__MULTILOAD, "MULTILOAD"},
	{ TCOMP_UDVM_INST__PUSH, "PUSH"},
	{ TCOMP_UDVM_INST__POP, "POP"},
	{ TCOMP_UDVM_INST__COPY, "COPY"},
	{ TCOMP_UDVM_INST__COPY_LITERAL, "COPY-LITERAL"},
	{ TCOMP_UDVM_INST__COPY_OFFSET, "COPY-OFFSET"},
	{ TCOMP_UDVM_INST__MEMSET, "MEMSET"},
	{ TCOMP_UDVM_INST__JUMP, "JUMP"},
	{ TCOMP_UDVM_INST__COMPARE, "COMPARE"},
	{ TCOMP_UDVM_INST__CALL, "CALL"},
	{ TCOMP_UDVM_INST__RETURN, "RETURN"},
	{ TCOMP_UDVM_INST__SWITCH, "SWITCH"},
	{ TCOMP_UDVM_INST__CRC, "CRC"},
	{ TCOMP_UDVM_INST__INPUT_BYTES, "INPUT-BYTES"},
	{ TCOMP_UDVM_INST__INPUT_BITS, "INPUT-BITS"},
	{ TCOMP_UDVM_INST__INPUT_HUFFMAN, "INPUT-HUFFMAN"},
	{ TCOMP_UDVM_INST__STATE_ACCESS, "STATE-ACCESS"},
	{ TCOMP_UDVM_INST__STATE_CREATE, "STATE-CREATE"},
	{ TCOMP_UDVM_INST__STATE_FREE, "STATE-FREE"},
	{ TCOMP_UDVM_INST__OUTPUT, "OUTPUT"},
	{ TCOMP_UDVM_INST__END_MESSAGE, "END-MESSAGE"},
};

#endif /* TCOMP_INSTRUCTIONS_H */
OpenPOWER on IntegriCloud