Fast IFS using RPN notation
python
c
x86-64
nasm
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rpn_lib.h 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2020 Weber Yann
  3. *
  4. * This file is part of pyrpn.
  5. *
  6. * pyrpn is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * any later version.
  10. *
  11. * pyrpn is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with pyrpn. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __rpn_lib__h__
  20. #define __rpn_lib__h__
  21. #include "config.h"
  22. #include <sys/mman.h>
  23. /**@defgroup rpn_lib RPNlib
  24. * @brief Precompiled x86_64 assembly operations
  25. * @ingroup rpn_compile
  26. */
  27. /**@file rpn_lib.h
  28. * @brief "Import" symbols defined in @ref rpn_lib.asm using @ref CODE_PART macro.
  29. *
  30. * For each symbol (piece of compiled assembly code) @ref CODE_PART defines :
  31. * - void *NAME : the pointer on compiled code
  32. * - unsigned long NAME_sz : the size of the code portion
  33. *
  34. * @see rpn_lib.asm
  35. * @ingroup rpn_lib
  36. */
  37. /**@file rpn_lib.asm
  38. * @brief x86_64 RPN expression operations implementations
  39. *
  40. * Exported symbols are found in @ref rpn_lib.h
  41. * @ingroup rpn_lib
  42. */
  43. /**@brief Code part size macro */
  44. #define CODE_SZ(NAME) NAME ## _sz
  45. /**@brief macro to declare a code part and associated size */
  46. #define CODE_PART(NAME) const extern void* NAME; extern const unsigned long NAME ## _sz
  47. /**@brief Function heading code
  48. *
  49. * - stack frame creation
  50. * - argument processing
  51. * - etc.
  52. * @ingroup rpn_lib */
  53. CODE_PART(rpn_exec);
  54. /**@brief Function ends and ret code
  55. *
  56. * - pop and return head of stack value
  57. * - stack frame deletion
  58. * @ingroup rpn_lib */
  59. CODE_PART(rpn_exec_ret);
  60. /**@brief Constant value pushing symbol
  61. * @note except a value to be set
  62. * @ingroup rpn_lib */
  63. CODE_PART(rpn_value);
  64. /**@brief Argument pushing symbol
  65. * @note except a value to be set
  66. * @ingroup rpn_lib */
  67. CODE_PART(rpn_arg);
  68. /**@brief Addition symbol
  69. * @ingroup rpn_lib */
  70. CODE_PART(rpn_add);
  71. /**@brief Substraction symbol
  72. * @ingroup rpn_lib */
  73. CODE_PART(rpn_sub);
  74. /**@brief Division symbol
  75. * @ingroup rpn_lib */
  76. CODE_PART(rpn_div);
  77. /**@brief Multiplication symbol
  78. * @ingroup rpn_lib */
  79. CODE_PART(rpn_mul);
  80. /**@brief Modulo symbol
  81. * @ingroup rpn_lib */
  82. CODE_PART(rpn_mod);
  83. /**@brief Left shift symbol
  84. * @ingroup rpn_lib */
  85. CODE_PART(rpn_shl);
  86. /**@brief Right shift symbol
  87. * @ingroup rpn_lib */
  88. CODE_PART(rpn_shr);
  89. /**@brief Value exchange symbol
  90. * @ingroup rpn_lib */
  91. CODE_PART(rpn_xchg);
  92. /**@brief Head of stack duplication
  93. * @ingroup rpn_lib */
  94. CODE_PART(rpn_dup);
  95. /**@brief Arithmetic negation
  96. * @ingroup rpn_lib */
  97. CODE_PART(rpn_neg);
  98. /**@brief Binary not
  99. * @ingroup rpn_lib */
  100. CODE_PART(rpn_not);
  101. /**@brief Binary and
  102. * @ingroup rpn_lib */
  103. CODE_PART(rpn_and);
  104. /**@brief Binary or
  105. * @ingroup rpn_lib */
  106. CODE_PART(rpn_or);
  107. /**@brief Binary xor
  108. * @ingroup rpn_lib */
  109. CODE_PART(rpn_xor);
  110. /**@brief Pop head of stack
  111. * @ingroup rpn_lib */
  112. CODE_PART(rpn_pop_op);
  113. #endif