/*
* Copyright (C) 2020 Weber Yann
*
* This file is part of pyrpn.
*
* pyrpn is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* pyrpn is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with pyrpn. If not, see .
*/
#ifndef __rpn_lib__h__
#define __rpn_lib__h__
#include "config.h"
#include
/**@defgroup rpn_lib RPNlib
* @brief Precompiled x86_64 assembly operations
* @ingroup rpn_compile
*/
/**@file rpn_lib.h
* @brief "Import" symbols defined in @ref rpn_lib.asm using @ref CODE_PART macro.
*
* For each symbol (piece of compiled assembly code) @ref CODE_PART defines :
* - void *NAME : the pointer on compiled code
* - unsigned long NAME_sz : the size of the code portion
*
* @see rpn_lib.asm
* @ingroup rpn_lib
*/
/**@file rpn_lib.asm
* @brief x86_64 RPN expression operations implementations
*
* Exported symbols are found in @ref rpn_lib.h
* @ingroup rpn_lib
*/
/**@brief Code part size macro */
#define CODE_SZ(NAME) NAME ## _sz
/**@brief macro to declare a code part and associated size */
#define CODE_PART(NAME) const extern void* NAME; \
/**@brief Cord part size */\
extern const unsigned long NAME ## _sz
/**@brief Define the type of value manipulated by RPN expressions
*
* Use it for stack and arguments items
* @todo use it */
typedef unsigned long int rpn_value_t;
/**@brief Small alias for PyLong_FromUnsignedLong */
#define PyLong_FromRpnValue_t PyLong_FromUnsignedLong
/**@brief Small alias for PyLong_AsUnsignedLong */
#define PyLong_AsRpnValue_t PyLong_AsUnsignedLong
/**@brief Function heading code
*
* - stack frame creation
* - argument processing
* - etc.
* @ingroup rpn_lib */
CODE_PART(rpn_exec);
/**@brief Function ends and ret code
*
* - pop and return head of stack value
* - stack frame deletion
* @ingroup rpn_lib */
CODE_PART(rpn_exec_ret);
/**@brief Constant value pushing symbol
* @note except a value to be set
* @ingroup rpn_lib */
CODE_PART(rpn_value);
/**@brief Argument pushing symbol
* @note except a value to be set
* @ingroup rpn_lib */
CODE_PART(rpn_arg);
/**@brief Addition symbol
* @ingroup rpn_lib */
CODE_PART(rpn_add);
/**@brief Substraction symbol
* @ingroup rpn_lib */
CODE_PART(rpn_sub);
/**@brief Division symbol
* @ingroup rpn_lib */
CODE_PART(rpn_div);
/**@brief Multiplication symbol
* @ingroup rpn_lib */
CODE_PART(rpn_mul);
/**@brief Modulo symbol
* @ingroup rpn_lib */
CODE_PART(rpn_mod);
/**@brief Left shift symbol
* @ingroup rpn_lib */
CODE_PART(rpn_shl);
/**@brief Right shift symbol
* @ingroup rpn_lib */
CODE_PART(rpn_shr);
/**@brief Value exchange symbol
* @ingroup rpn_lib */
CODE_PART(rpn_xchg);
/**@brief Head of stack duplication
* @ingroup rpn_lib */
CODE_PART(rpn_dup);
/**@brief Arithmetic negation
* @ingroup rpn_lib */
CODE_PART(rpn_neg);
/**@brief Binary not
* @ingroup rpn_lib */
CODE_PART(rpn_not);
/**@brief Binary and
* @ingroup rpn_lib */
CODE_PART(rpn_and);
/**@brief Binary or
* @ingroup rpn_lib */
CODE_PART(rpn_or);
/**@brief Binary xor
* @ingroup rpn_lib */
CODE_PART(rpn_xor);
/**@brief Pop head of stack
* @ingroup rpn_lib */
CODE_PART(rpn_pop_op);
#endif