opcode.h 649 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef OPCODE_H
  2. #define OPCODE_H
  3. #include "symbol.h"
  4. enum opcode {
  5. #define OPCODE(OP,NG,SW,TF,N,FL) OP_##OP,
  6. #define OPCODE_RANGE(OP,S,E) OP_##OP = OP_##S, OP_##OP##_END = OP_##E,
  7. #include "opcode.def"
  8. #undef OPCODE
  9. #undef OPCODE_RANGE
  10. OP_LAST, /* keep this one last! */
  11. };
  12. extern const struct opcode_table {
  13. int negate:8;
  14. int swap:8;
  15. int to_float:8;
  16. unsigned int arity:2;
  17. unsigned int flags:6;
  18. #define OPF_NONE 0
  19. #define OPF_TARGET (1 << 0)
  20. } opcode_table[];
  21. static inline int opcode_float(int opcode, struct symbol *type)
  22. {
  23. if (!type || !is_float_type(type))
  24. return opcode;
  25. return opcode_table[opcode].to_float;
  26. }
  27. #endif