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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 Define the type of value manipulated by RPN expressions
  48. *
  49. * Use it for stack and arguments items
  50. * @todo use it */
  51. typedef unsigned long int rpn_value_t;
  52. /**@brief Function heading code
  53. *
  54. * - stack frame creation
  55. * - argument processing
  56. * - etc.
  57. * @ingroup rpn_lib */
  58. CODE_PART(rpn_exec);
  59. /**@brief Function ends and ret code
  60. *
  61. * - pop and return head of stack value
  62. * - stack frame deletion
  63. * @ingroup rpn_lib */
  64. CODE_PART(rpn_exec_ret);
  65. /**@brief Constant value pushing symbol
  66. * @note except a value to be set
  67. * @ingroup rpn_lib */
  68. CODE_PART(rpn_value);
  69. /**@brief Argument pushing symbol
  70. * @note except a value to be set
  71. * @ingroup rpn_lib */
  72. CODE_PART(rpn_arg);
  73. /**@brief Addition symbol
  74. * @ingroup rpn_lib */
  75. CODE_PART(rpn_add);
  76. /**@brief Substraction symbol
  77. * @ingroup rpn_lib */
  78. CODE_PART(rpn_sub);
  79. /**@brief Division symbol
  80. * @ingroup rpn_lib */
  81. CODE_PART(rpn_div);
  82. /**@brief Multiplication symbol
  83. * @ingroup rpn_lib */
  84. CODE_PART(rpn_mul);
  85. /**@brief Modulo symbol
  86. * @ingroup rpn_lib */
  87. CODE_PART(rpn_mod);
  88. /**@brief Left shift symbol
  89. * @ingroup rpn_lib */
  90. CODE_PART(rpn_shl);
  91. /**@brief Right shift symbol
  92. * @ingroup rpn_lib */
  93. CODE_PART(rpn_shr);
  94. /**@brief Value exchange symbol
  95. * @ingroup rpn_lib */
  96. CODE_PART(rpn_xchg);
  97. /**@brief Head of stack duplication
  98. * @ingroup rpn_lib */
  99. CODE_PART(rpn_dup);
  100. /**@brief Arithmetic negation
  101. * @ingroup rpn_lib */
  102. CODE_PART(rpn_neg);
  103. /**@brief Binary not
  104. * @ingroup rpn_lib */
  105. CODE_PART(rpn_not);
  106. /**@brief Binary and
  107. * @ingroup rpn_lib */
  108. CODE_PART(rpn_and);
  109. /**@brief Binary or
  110. * @ingroup rpn_lib */
  111. CODE_PART(rpn_or);
  112. /**@brief Binary xor
  113. * @ingroup rpn_lib */
  114. CODE_PART(rpn_xor);
  115. /**@brief Pop head of stack
  116. * @ingroup rpn_lib */
  117. CODE_PART(rpn_pop_op);
  118. #endif