Ghidra Decompiler Analysis Engine
opcodes.hh
Go to the documentation of this file.
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
18 
19 #ifndef __CPUI_OPCODES__
20 #define __CPUI_OPCODES__
21 
22 #include <string>
23 
24 using namespace std;
25 
35 enum OpCode {
36  CPUI_COPY = 1,
37  CPUI_LOAD = 2,
38  CPUI_STORE = 3,
39 
43 
44  CPUI_CALL = 7,
47  CPUI_RETURN = 10,
48 
49  // Integer/bit operations
50 
56  // This also indicates a borrow on unsigned substraction
60  CPUI_INT_ADD = 19,
61  CPUI_INT_SUB = 20,
67  CPUI_INT_XOR = 26,
68  CPUI_INT_AND = 27,
69  CPUI_INT_OR = 28,
74  CPUI_INT_DIV = 33,
76  CPUI_INT_REM = 35,
78 
82  CPUI_BOOL_OR = 40,
83 
84  // Floating point operations
85 
90  // Slot 45 is currently unused
92 
100 
107 
108  // Internal opcodes for simplification. Not
109  // typically generated in a direct translation.
110 
111  // Data-flow operations
114  CPUI_PIECE = 62,
116 
117  CPUI_CAST = 64,
118  CPUI_PTRADD = 65,
119  CPUI_PTRSUB = 66,
122  CPUI_NEW = 69,
123  CPUI_INSERT = 70,
126 
127  CPUI_MAX = 73
128 };
129 
130 extern const char *get_opname(OpCode opc);
131 extern OpCode get_opcode(const string &nm);
132 
133 extern OpCode get_booleanflip(OpCode opc,bool &reorder);
134 
135 #endif
CPUI_FLOAT_ROUND
@ CPUI_FLOAT_ROUND
Round towards nearest.
Definition: opcodes.hh:106
CPUI_FLOAT_NAN
@ CPUI_FLOAT_NAN
Not-a-number test (NaN)
Definition: opcodes.hh:91
CPUI_PIECE
@ CPUI_PIECE
Concatenate.
Definition: opcodes.hh:114
CPUI_CPOOLREF
@ CPUI_CPOOLREF
Recover a value from the constant pool.
Definition: opcodes.hh:121
CPUI_INT_NEGATE
@ CPUI_INT_NEGATE
Logical/bitwise negation (~)
Definition: opcodes.hh:66
CPUI_FLOAT_LESS
@ CPUI_FLOAT_LESS
Floating-point comparison, less-than (<)
Definition: opcodes.hh:88
CPUI_FLOAT_LESSEQUAL
@ CPUI_FLOAT_LESSEQUAL
Floating-point comparison, less-than-or-equal (<=)
Definition: opcodes.hh:89
CPUI_INT_DIV
@ CPUI_INT_DIV
Integer division, unsigned (/)
Definition: opcodes.hh:74
CPUI_FLOAT_NEG
@ CPUI_FLOAT_NEG
Floating-point negation (-)
Definition: opcodes.hh:97
CPUI_INT_ADD
@ CPUI_INT_ADD
Addition, signed or unsigned (+)
Definition: opcodes.hh:60
CPUI_INT_SDIV
@ CPUI_INT_SDIV
Integer division, signed (/)
Definition: opcodes.hh:75
CPUI_INT_SUB
@ CPUI_INT_SUB
Subtraction, signed or unsigned (-)
Definition: opcodes.hh:61
get_opname
const char * get_opname(OpCode opc)
Convert an OpCode to the name as a string.
Definition: opcodes.cc:58
CPUI_EXTRACT
@ CPUI_EXTRACT
Extract a bit-range.
Definition: opcodes.hh:124
CPUI_INT_EQUAL
@ CPUI_INT_EQUAL
Integer comparison, equality (==)
Definition: opcodes.hh:51
CPUI_FLOAT_SUB
@ CPUI_FLOAT_SUB
Floating-point subtraction (-)
Definition: opcodes.hh:96
CPUI_SUBPIECE
@ CPUI_SUBPIECE
Truncate.
Definition: opcodes.hh:115
CPUI_INT_LESSEQUAL
@ CPUI_INT_LESSEQUAL
Integer comparison, unsigned less-than-or-equal (<=)
Definition: opcodes.hh:57
CPUI_CBRANCH
@ CPUI_CBRANCH
Conditional branch.
Definition: opcodes.hh:41
CPUI_INT_2COMP
@ CPUI_INT_2COMP
Twos complement.
Definition: opcodes.hh:65
CPUI_FLOAT_ADD
@ CPUI_FLOAT_ADD
Floating-point addition (+)
Definition: opcodes.hh:93
CPUI_BRANCHIND
@ CPUI_BRANCHIND
Indirect branch (jumptable)
Definition: opcodes.hh:42
CPUI_INT_OR
@ CPUI_INT_OR
Logical/bitwise or (|)
Definition: opcodes.hh:69
CPUI_INT_NOTEQUAL
@ CPUI_INT_NOTEQUAL
Integer comparison, in-equality (!=)
Definition: opcodes.hh:52
CPUI_FLOAT_DIV
@ CPUI_FLOAT_DIV
Floating-point division (/)
Definition: opcodes.hh:94
CPUI_INT_LEFT
@ CPUI_INT_LEFT
Left shift (<<)
Definition: opcodes.hh:70
CPUI_BOOL_OR
@ CPUI_BOOL_OR
Boolean or (||)
Definition: opcodes.hh:82
CPUI_INT_SRIGHT
@ CPUI_INT_SRIGHT
Right shift, arithmetic (>>)
Definition: opcodes.hh:72
CPUI_NEW
@ CPUI_NEW
Allocate a new object (new)
Definition: opcodes.hh:122
CPUI_SEGMENTOP
@ CPUI_SEGMENTOP
Look-up a segmented address.
Definition: opcodes.hh:120
CPUI_FLOAT_EQUAL
@ CPUI_FLOAT_EQUAL
Floating-point comparison, equality (==)
Definition: opcodes.hh:86
CPUI_FLOAT_SQRT
@ CPUI_FLOAT_SQRT
Floating-point square root (sqrt)
Definition: opcodes.hh:99
CPUI_CALLIND
@ CPUI_CALLIND
Call through an indirect address.
Definition: opcodes.hh:45
CPUI_BOOL_NEGATE
@ CPUI_BOOL_NEGATE
Boolean negate (!)
Definition: opcodes.hh:79
get_opcode
OpCode get_opcode(const string &nm)
Convert a name string to the matching OpCode.
Definition: opcodes.cc:66
CPUI_INT_ZEXT
@ CPUI_INT_ZEXT
Zero extension.
Definition: opcodes.hh:58
CPUI_INT_RIGHT
@ CPUI_INT_RIGHT
Right shift, logical (>>)
Definition: opcodes.hh:71
CPUI_BOOL_AND
@ CPUI_BOOL_AND
Boolean and (&&)
Definition: opcodes.hh:81
CPUI_FLOAT_FLOOR
@ CPUI_FLOAT_FLOOR
Round towards -infinity.
Definition: opcodes.hh:105
CPUI_INT_SREM
@ CPUI_INT_SREM
Remainder/modulo, signed (%)
Definition: opcodes.hh:77
CPUI_CALL
@ CPUI_CALL
Call to an absolute address.
Definition: opcodes.hh:44
CPUI_FLOAT_CEIL
@ CPUI_FLOAT_CEIL
Round towards +infinity.
Definition: opcodes.hh:104
CPUI_MAX
@ CPUI_MAX
Value indicating the end of the op-code values.
Definition: opcodes.hh:127
CPUI_POPCOUNT
@ CPUI_POPCOUNT
Count the 1-bits.
Definition: opcodes.hh:125
CPUI_STORE
@ CPUI_STORE
Store at a pointer into a specified address space.
Definition: opcodes.hh:38
CPUI_LOAD
@ CPUI_LOAD
Load from a pointer into a specified address space.
Definition: opcodes.hh:37
CPUI_INT_SEXT
@ CPUI_INT_SEXT
Sign extension.
Definition: opcodes.hh:59
CPUI_MULTIEQUAL
@ CPUI_MULTIEQUAL
Phi-node operator.
Definition: opcodes.hh:112
CPUI_INT_LESS
@ CPUI_INT_LESS
Integer comparison, unsigned less-than (<)
Definition: opcodes.hh:55
CPUI_PTRADD
@ CPUI_PTRADD
Index into an array ([])
Definition: opcodes.hh:118
CPUI_FLOAT_NOTEQUAL
@ CPUI_FLOAT_NOTEQUAL
Floating-point comparison, in-equality (!=)
Definition: opcodes.hh:87
CPUI_BRANCH
@ CPUI_BRANCH
Always branch.
Definition: opcodes.hh:40
CPUI_BOOL_XOR
@ CPUI_BOOL_XOR
Boolean exclusive-or (^^)
Definition: opcodes.hh:80
CPUI_RETURN
@ CPUI_RETURN
Return from subroutine.
Definition: opcodes.hh:47
CPUI_INT_XOR
@ CPUI_INT_XOR
Logical/bitwise exclusive-or (^)
Definition: opcodes.hh:67
CPUI_INT_CARRY
@ CPUI_INT_CARRY
Test for unsigned carry.
Definition: opcodes.hh:62
CPUI_INT_SCARRY
@ CPUI_INT_SCARRY
Test for signed carry.
Definition: opcodes.hh:63
OpCode
OpCode
The op-code defining a specific p-code operation (PcodeOp)
Definition: opcodes.hh:35
CPUI_FLOAT_ABS
@ CPUI_FLOAT_ABS
Floating-point absolute value (abs)
Definition: opcodes.hh:98
CPUI_INSERT
@ CPUI_INSERT
Insert a bit-range.
Definition: opcodes.hh:123
CPUI_INDIRECT
@ CPUI_INDIRECT
Copy with an indirect effect.
Definition: opcodes.hh:113
CPUI_INT_AND
@ CPUI_INT_AND
Logical/bitwise and (&)
Definition: opcodes.hh:68
CPUI_CAST
@ CPUI_CAST
Cast from one data-type to another.
Definition: opcodes.hh:117
CPUI_PTRSUB
@ CPUI_PTRSUB
Drill down to a sub-field (->)
Definition: opcodes.hh:119
CPUI_INT_REM
@ CPUI_INT_REM
Remainder/modulo, unsigned (%)
Definition: opcodes.hh:76
CPUI_FLOAT_FLOAT2FLOAT
@ CPUI_FLOAT_FLOAT2FLOAT
Convert between different floating-point sizes.
Definition: opcodes.hh:102
CPUI_INT_SLESSEQUAL
@ CPUI_INT_SLESSEQUAL
Integer comparison, signed less-than-or-equal (<=)
Definition: opcodes.hh:54
get_booleanflip
OpCode get_booleanflip(OpCode opc, bool &reorder)
Get the complementary OpCode.
Definition: opcodes.cc:92
CPUI_INT_SBORROW
@ CPUI_INT_SBORROW
Test for signed borrow.
Definition: opcodes.hh:64
CPUI_COPY
@ CPUI_COPY
Copy one operand to another.
Definition: opcodes.hh:36
CPUI_FLOAT_MULT
@ CPUI_FLOAT_MULT
Floating-point multiplication (*)
Definition: opcodes.hh:95
CPUI_FLOAT_TRUNC
@ CPUI_FLOAT_TRUNC
Round towards zero.
Definition: opcodes.hh:103
CPUI_FLOAT_INT2FLOAT
@ CPUI_FLOAT_INT2FLOAT
Convert an integer to a floating-point.
Definition: opcodes.hh:101
CPUI_INT_MULT
@ CPUI_INT_MULT
Integer multiplication, signed and unsigned (*)
Definition: opcodes.hh:73
CPUI_INT_SLESS
@ CPUI_INT_SLESS
Integer comparison, signed less-than (<)
Definition: opcodes.hh:53
CPUI_CALLOTHER
@ CPUI_CALLOTHER
User-defined operation.
Definition: opcodes.hh:46