param_key: fix container of when no struct member is referenced
[smatch.git] / opcode.h
blobb74ba02d94bdd52dc1bdba55a6b5d08ecb93ce4e
1 #ifndef OPCODE_H
2 #define OPCODE_H
4 #include "symbol.h"
6 enum opcode {
7 #define OPCODE(OP,NG,SW,SG,TF,N,FL) OP_##OP,
8 #define OPCODE_RANGE(OP,S,E) OP_##OP = OP_##S, OP_##OP##_END = OP_##E,
9 #include "opcode.def"
10 #undef OPCODE
11 #undef OPCODE_RANGE
12 OP_LAST, /* keep this one last! */
15 extern const struct opcode_table {
16 int negate:8;
17 int swap:8;
18 int sign:8;
19 int to_float:8;
20 unsigned int arity:2;
21 unsigned int :6;
22 unsigned int flags:8;
23 #define OPF_NONE 0
24 #define OPF_TARGET (1 << 0)
25 #define OPF_COMMU (1 << 1)
26 #define OPF_ASSOC (1 << 2)
27 #define OPF_UNOP (1 << 3)
28 #define OPF_BINOP (1 << 4)
29 #define OPF_COMPARE (1 << 5)
30 #define OPF_SIGNED (1 << 6)
31 #define OPF_UNSIGNED (1 << 7)
32 } opcode_table[];
35 static inline int opcode_negate(int opcode)
37 return opcode_table[opcode].negate;
40 static inline int opcode_swap(int opcode)
42 return opcode_table[opcode].swap;
45 static inline int opcode_float(int opcode, struct symbol *type)
47 if (!type || !is_float_type(type))
48 return opcode;
49 return opcode_table[opcode].to_float;
52 #endif