vm-expand.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Copyright 2001,2018
  2. Free Software Foundation, Inc.
  3. This file is part of Guile.
  4. Guile is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Lesser General Public License as published
  6. by the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. Guile is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  11. License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with Guile. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef VM_LABEL
  16. #define VM_LABEL(tag) l_##tag
  17. #define VM_OPCODE(tag) scm_op_##tag
  18. #ifdef HAVE_LABELS_AS_VALUES
  19. #define VM_TAG(tag) VM_LABEL(tag):
  20. #define VM_ADDR(tag) &&VM_LABEL(tag)
  21. #else /* not HAVE_LABELS_AS_VALUES */
  22. #define VM_TAG(tag) case VM_OPCODE(tag):
  23. #define VM_ADDR(tag) NULL
  24. #endif /* not HAVE_LABELS_AS_VALUES */
  25. #endif /* VM_LABEL */
  26. #undef VM_DEFINE_FUNCTION
  27. #undef VM_DEFINE_LOADER
  28. #define VM_DEFINE_FUNCTION(code,tag,name,nargs) \
  29. VM_DEFINE_INSTRUCTION(code,tag,name,0,nargs,1)
  30. #define VM_DEFINE_LOADER(code,tag,name) \
  31. VM_DEFINE_INSTRUCTION(code,tag,name,-1,0,1)
  32. #undef VM_DEFINE_INSTRUCTION
  33. /*
  34. * These will go to scm_instruction_table in instructions.c
  35. */
  36. #ifdef VM_INSTRUCTION_TO_TABLE
  37. #define VM_DEFINE_INSTRUCTION(code_,tag_,name_,len_,npop_,npush_) \
  38. table[VM_OPCODE (tag_)].opcode = code_; \
  39. table[VM_OPCODE (tag_)].name = name_; \
  40. table[VM_OPCODE (tag_)].len = len_; \
  41. table[VM_OPCODE (tag_)].npop = npop_; \
  42. table[VM_OPCODE (tag_)].npush = npush_;
  43. #else
  44. #ifdef VM_INSTRUCTION_TO_LABEL
  45. /*
  46. * These will go to jump_table in vm_engine.c
  47. */
  48. #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) jump_table[code] = VM_ADDR (tag);
  49. #else
  50. #ifdef VM_INSTRUCTION_TO_OPCODE
  51. /*
  52. * These will go to scm_opcode in instructions.h
  53. */
  54. #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_OPCODE (tag) = code,
  55. #else /* Otherwise */
  56. /*
  57. * These are directly included in vm_engine.c
  58. */
  59. #define VM_DEFINE_INSTRUCTION(code,tag,name,len,npop,npush) VM_TAG (tag)
  60. #endif /* VM_INSTRUCTION_TO_OPCODE */
  61. #endif /* VM_INSTRUCTION_TO_LABEL */
  62. #endif /* VM_INSTRUCTION_TO_TABLE */