1#ifndef OPCODE_H 2#define OPCODE_H 3 4#include "symbol.h" 5 6enum 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! */ 13}; 14 15extern 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[]; 33 34 35static inline int opcode_negate(int opcode) 36{ 37 return opcode_table[opcode].negate; 38} 39 40static inline int opcode_swap(int opcode) 41{ 42 return opcode_table[opcode].swap; 43} 44 45static inline int opcode_float(int opcode, struct symbol *type) 46{ 47 if (!type || !is_float_type(type)) 48 return opcode; 49 return opcode_table[opcode].to_float; 50} 51 52#endif 53