]> granicus.if.org Git - yasm/commitdiff
Hide details of yasm_arch_module structure, instead creating wrapper macro
authorPeter Johnson <peter@tortall.net>
Tue, 28 Oct 2003 18:58:55 +0000 (18:58 -0000)
committerPeter Johnson <peter@tortall.net>
Tue, 28 Oct 2003 18:58:55 +0000 (18:58 -0000)
"functions" that call down to the module level.  Doesn't really change the
internal complexities, just makes it easier to read and write code that
uses it.

svn path=/trunk/yasm/; revision=1080

17 files changed:
libyasm/arch.c
libyasm/arch.h
libyasm/expr.c
modules/arch/lc3b/lc3barch.c
modules/arch/lc3b/lc3barch.h
modules/arch/lc3b/lc3bid.re
modules/arch/x86/x86arch.h
modules/arch/x86/x86id.re
modules/dbgfmts/stabs/stabs-dbgfmt.c
modules/objfmts/bin/bin-objfmt.c
modules/objfmts/coff/coff-objfmt.c
modules/objfmts/dbg/dbg-objfmt.c
modules/objfmts/elf/elf-objfmt.c
modules/objfmts/elf/elf.c
modules/parsers/nasm/nasm-bison.y
modules/parsers/nasm/nasm-parser.h
modules/parsers/nasm/nasm-token.re

index 239e400c0697b407a1a2e2d71d42b920e500a3e5..a998a5c322523b75c795137023d5c4c23926011e 100644 (file)
 #include "arch.h"
 
 
-const yasm_arch_module *
-yasm_arch_get_module(yasm_arch *arch)
-{
-    return arch->module;
-}
-
 yasm_insn_operand *
 yasm_operand_create_reg(unsigned long reg)
 {
@@ -111,12 +105,12 @@ yasm_operand_print(const yasm_insn_operand *op, FILE *f, int indent_level,
     switch (op->type) {
        case YASM_INSN__OPERAND_REG:
            fprintf(f, "%*sReg=", indent_level, "");
-           arch->module->reg_print(arch, op->data.reg, f);
+           yasm_arch_reg_print(arch, op->data.reg, f);
            fprintf(f, "\n");
            break;
        case YASM_INSN__OPERAND_SEGREG:
            fprintf(f, "%*sSegReg=", indent_level, "");
-           arch->module->segreg_print(arch, op->data.reg, f);
+           yasm_arch_segreg_print(arch, op->data.reg, f);
            fprintf(f, "\n");
            break;
        case YASM_INSN__OPERAND_MEMORY:
@@ -134,7 +128,7 @@ yasm_operand_print(const yasm_insn_operand *op, FILE *f, int indent_level,
 }
 
 void
-yasm_ops_delete(yasm_insn_operandhead *headp, int content)
+yasm_ops_delete(yasm_insn_operands *headp, int content)
 {
     yasm_insn_operand *cur, *next;
 
@@ -159,7 +153,7 @@ yasm_ops_delete(yasm_insn_operandhead *headp, int content)
 }
 
 /*@null@*/ yasm_insn_operand *
-yasm_ops_append(yasm_insn_operandhead *headp,
+yasm_ops_append(yasm_insn_operands *headp,
                /*@returned@*/ /*@null@*/ yasm_insn_operand *op)
 {
     if (op) {
@@ -170,7 +164,7 @@ yasm_ops_append(yasm_insn_operandhead *headp,
 }
 
 void
-yasm_ops_print(const yasm_insn_operandhead *headp, FILE *f, int indent_level,
+yasm_ops_print(const yasm_insn_operands *headp, FILE *f, int indent_level,
               yasm_arch *arch)
 {
     yasm_insn_operand *cur;
@@ -179,16 +173,16 @@ yasm_ops_print(const yasm_insn_operandhead *headp, FILE *f, int indent_level,
        yasm_operand_print(cur, f, indent_level, arch);
 }
 
-yasm_insn_operandhead *
+yasm_insn_operands *
 yasm_ops_create(void)
 {
-    yasm_insn_operandhead *headp = yasm_xmalloc(sizeof(yasm_insn_operandhead));
+    yasm_insn_operands *headp = yasm_xmalloc(sizeof(yasm_insn_operands));
     yasm_ops_initialize(headp);
     return headp;
 }
 
 void
-yasm_ops_destroy(yasm_insn_operandhead *headp, int content)
+yasm_ops_destroy(yasm_insn_operands *headp, int content)
 {
     yasm_ops_delete(headp, content);
     yasm_xfree(headp);
@@ -197,7 +191,7 @@ yasm_ops_destroy(yasm_insn_operandhead *headp, int content)
 /* Non-macro yasm_ops_first() for non-YASM_LIB_INTERNAL users. */
 #undef yasm_ops_first
 yasm_insn_operand *
-yasm_ops_first(yasm_insn_operandhead *headp)
+yasm_ops_first(yasm_insn_operands *headp)
 {
     return STAILQ_FIRST(headp);
 }
index 031f868afc981ce0960161e62e3096f8f9d852f3..26a298544cece24d534c1d053f27727d897b3200 100644 (file)
@@ -49,19 +49,19 @@ typedef struct yasm_insn_operand yasm_insn_operand;
 /** A list of instruction operands (opaque type).
  * The list goes from left-to-right as parsed.
  */
-typedef struct yasm_insn_operandhead yasm_insn_operandhead;
+typedef struct yasm_insn_operands yasm_insn_operands;
 #ifdef YASM_LIB_INTERNAL
-/*@reldef@*/ STAILQ_HEAD(yasm_insn_operandhead, yasm_insn_operand);
+/*@reldef@*/ STAILQ_HEAD(yasm_insn_operands, yasm_insn_operand);
 #endif
 
-#ifdef YASM_LIB_INTERNAL
+#ifndef YASM_DOXYGEN
 /** Base #yasm_arch structure.  Must be present as the first element in any
  * #yasm_arch implementation.
  */
-struct yasm_arch {
+typedef struct yasm_arch_base {
     /** #yasm_arch_module implementation for this architecture. */
     const struct yasm_arch_module *module;
-};
+} yasm_arch_base;
 #endif
 
 /** "Flavor" of the parser.
@@ -96,12 +96,13 @@ typedef struct yasm_arch_machine {
 
 /** Version number of #yasm_arch_module interface.  Any functional change to
  * the #yasm_arch_module interface should simultaneously increment this number.
- * This version should be checked by #yasm_arch_module loaders to verify that
- * the expected version (the version defined by its libyasm header files)
- * matches the loaded module version (the version defined by the module's
- * libyasm header files).  Doing this will ensure that the module version's
- * function definitions match the module loader's function definitions.  The
- * version number must never be decreased.
+ * This version should be checked by #yasm_arch_module loaders (using
+ * yasm_arch_module_get_version()) to verify that the expected version (the
+ * version defined by its libyasm header files) matches the loaded module
+ * version (the version defined by the module's libyasm header files).  Doing
+ * this will ensure that the module version's function definitions match the
+ * module loader's function definitions.  The version number must never be
+ * decreased.
  */
 #define YASM_ARCH_VERSION      2
 
@@ -111,7 +112,10 @@ typedef struct yasm_arch_machine {
  *      to use/check previously stored data to see if it's been called before
  *      on the same piece of data.
  */
-typedef struct yasm_arch_module {
+typedef struct yasm_arch_module yasm_arch_module;
+
+#ifndef YASM_DOXYGEN
+struct yasm_arch_module {
     /** Version (see #YASM_ARCH_VERSION).  Should always be set to
      * #YASM_ARCH_VERSION by the module source and checked against
      * #YASM_ARCH_VERSION by the module loader.
@@ -131,172 +135,70 @@ typedef struct yasm_arch_module {
      */
     /*@only@*/ yasm_arch * (*create) (const char *machine);
 
-    /** Clean up, free any architecture-allocated memory. */
+    /** \copydoc yasm_arch_destroy() */
     void (*destroy) (/*@only@*/ yasm_arch *arch);
 
-    /** Get machine name in use. */
+    /** \copydoc yasm_arch_get_machine() */
     const char * (*get_machine) (const yasm_arch *arch);
 
-    /** Set any arch-specific variables.  For example, "mode_bits" in x86.
-     * \return Zero on success, non-zero on failure (variable does not exist).
-     */
+    /** \copydoc yasm_arch_set_var() */
     int (*set_var) (yasm_arch *arch, const char *var, unsigned long val);
 
-    /** Switch available instructions/registers/etc based on a user-specified
-     * CPU identifier.  Should modify behavior ONLY of parse_* functions!  The
-     * bytecode and output functions should be able to handle any CPU.
-     * \param cpuid    cpu identifier as in the input file
-     * \param line     virtual line (from yasm_linemap)
-     */
+    /** \copydoc yasm_arch_parse_cpu() */
     void (*parse_cpu) (yasm_arch *arch, const char *cpuid,
                       unsigned long line);
 
-    /** Check an generic identifier to see if it matches architecture specific
-     * names for instructions, registers, etc.  Unrecognized identifiers should
-     * be returned as #YASM_ARCH_CHECK_ID_NONE so they can be treated as normal
-     * symbols.  Any additional data beyond just the type (almost always
-     * necessary) should be returned into the space provided by the data
-     * parameter.
-     * \note Even though this is passed a data[4], only data[0] should be used
-     *      for #YASM_ARCH_CHECK_ID_TARGETMOD, #YASM_ARCH_CHECK_ID_REG, and
-     *      #YASM_ARCH_CHECK_ID_SEGREG return values.
-     * \param data     extra identification information (yasm_arch-specific)
-     *                 [output]
-     * \param id       identifier as in the input file
-     * \param line     virtual line (from yasm_linemap)
-     * \return General type of identifier (#yasm_arch_check_id_retval).
-     */
+    /** \copydoc yasm_arch_parse_check_id() */
     yasm_arch_check_id_retval (*parse_check_id)
        (yasm_arch *arch, unsigned long data[4], const char *id,
         unsigned long line);
 
-    /** Handle architecture-specific directives.
-     * Should modify behavior ONLY of parse functions, much like parse_cpu().
-     * \param name             directive name
-     * \param valparams                value/parameters
-     * \param objext_valparams object format extensions
-     *                         value/parameters
-     * \param headp            list of sections
-     * \param line             virtual line (as from yasm_linemap)
-     * \return Nonzero if directive was not recognized; 0 if directive was
-     *        recognized, even if it wasn't valid.
-     */
+    /** \copydoc yasm_arch_parse_directive() */
     int (*parse_directive) (yasm_arch *arch, const char *name,
                            yasm_valparamhead *valparams,
                            /*@null@*/ yasm_valparamhead *objext_valparams,
                            yasm_object *object, unsigned long line);
 
-    /** Create an instruction.  Creates a bytecode by matching the
-     * instruction data and the parameters given with a valid instruction.
-     * \param data             instruction data (from parse_check_id()); all
-     *                         zero indicates an empty instruction
-     * \param num_operands     number of operands parsed
-     * \param operands         list of operands (in parse order)
-     * \param cur_section      currently active section
-     * \param prev_bc          previously parsed bytecode in section (NULL if
-     *                         first bytecode in section)
-     * \param line             virtual line (from yasm_linemap)
-     * \return If no match is found (the instruction is invalid), NULL,
-     *        otherwise newly allocated bytecode containing instruction.
-     */
+    /** \copydoc yasm_arch_parse_insn() */
     /*@null@*/ yasm_bytecode * (*parse_insn)
        (yasm_arch *arch, const unsigned long data[4], int num_operands,
-        /*@null@*/ yasm_insn_operandhead *operands, yasm_bytecode *prev_bc,
+        /*@null@*/ yasm_insn_operands *operands, yasm_bytecode *prev_bc,
         unsigned long line);
 
-    /** Handle an instruction prefix.
-     * Modifies an instruction bytecode based on the prefix in data.
-     * \param bc       bytecode (must be instruction bytecode)
-     * \param data     prefix (from parse_check_id())
-     * \param line     virtual line (from yasm_linemap)
-     */
+    /** \copydoc yasm_arch_parse_prefix() */
     void (*parse_prefix) (yasm_arch *arch, yasm_bytecode *bc,
                          const unsigned long data[4], unsigned long line);
 
-    /** Handle an segment register instruction prefix.
-     * Modifies an instruction bytecode based on a segment register prefix.
-     * \param bc       bytecode (must be instruction bytecode)
-     * \param segreg   segment register (from parse_check_id())
-     * \param line     virtual line (from yasm_linemap)
-     */
+    /** \copydoc yasm_arch_parse_seg_prefix() */
     void (*parse_seg_prefix) (yasm_arch *arch, yasm_bytecode *bc,
                              unsigned long segreg, unsigned long line);
 
-    /** Handle a memory expression segment override.
-     * Modifies an instruction bytecode based on a segment override in a
-     * memory expression.
-     * \param bc       bytecode (must be instruction bytecode)
-     * \param segreg   segment register (from parse_check_id())
-     * \param line     virtual line (from yasm_linemap)
-     */
+    /** \copydoc yasm_arch_parse_seg_override() */
     void (*parse_seg_override) (yasm_arch *arch, yasm_effaddr *ea,
                                unsigned long segreg, unsigned long line);
 
-    /** Output #yasm_floatnum to buffer.  Puts the value into the least
-     * significant bits of the destination, or may be shifted into more
-     * significant bits by the shift parameter.  The destination bits are
-     * cleared before being set.
-     * Architecture-specific because of endianness.
-     * \param flt      floating point value
-     * \param buf      buffer to write into
-     * \param destsize destination size (in bytes)
-     * \param valsize  size (in bits)
-     * \param shift    left shift (in bits)
-     * \param warn     enables standard overflow/underflow warnings
-     * \param line     virtual line; may be 0 if warn is 0.
-     * \return Nonzero on error.
-     */
+    /** \copydoc yasm_arch_floatnum_tobytes() */
     int (*floatnum_tobytes) (yasm_arch *arch, const yasm_floatnum *flt,
                             unsigned char *buf, size_t destsize,
                             size_t valsize, size_t shift, int warn,
                             unsigned long line);
 
-    /** Output #yasm_intnum to buffer.  Puts the value into the least
-     * significant bits of the destination, or may be shifted into more
-     * significant bits by the shift parameter.  The destination bits are
-     * cleared before being set.
-     * \param intn     integer value
-     * \param buf      buffer to write into
-     * \param destsize destination size (in bytes)
-     * \param valsize  size (in bits)
-     * \param shift    left shift (in bits); may be negative to specify right
-     *                 shift (standard warnings include truncation to boundary)
-     * \param bc       bytecode being output ("parent" of value)
-     * \param rel      value is a relative displacement from bc
-     * \param warn     enables standard warnings (value doesn't fit into
-     *                 valsize bits)
-     * \param line     virtual line; may be 0 if warn is 0
-     * \return Nonzero on error.
-     */
+    /** \copydoc yasm_arch_intnum_tobytes() */
     int (*intnum_tobytes) (yasm_arch *arch, const yasm_intnum *intn,
                           unsigned char *buf, size_t destsize, size_t valsize,
                           int shift, const yasm_bytecode *bc, int rel,
                           int warn, unsigned long line);
 
-    /** Get the equivalent byte size of a register.
-     * \param reg      register
-     * \return 0 if there is no suitable equivalent size, otherwise the size.
-     */
+    /** \copydoc yasm_arch_get_reg_size() */
     unsigned int (*get_reg_size) (yasm_arch *arch, unsigned long reg);
 
-    /** Print a register.  For debugging purposes.
-     * \param f                        file
-     * \param indent_level     indentation level
-     * \param reg              register
-     */
+    /** \copydoc yasm_arch_reg_print() */
     void (*reg_print) (yasm_arch *arch, unsigned long reg, FILE *f);
 
-    /** Print a segment register.  For debugging purposes.
-     * \param f                        file
-     * \param indent_level     indentation level
-     * \param segreg           segment register
-     */
+    /** \copydoc yasm_arch_segreg_print() */
     void (*segreg_print) (yasm_arch *arch, unsigned long segreg, FILE *f);
 
-    /** Create an effective address from an expression.
-     * \param e        expression (kept, do not delete)
-     * \return Newly allocated effective address.
-     */
+    /** \copydoc yasm_arch_ea_create() */
     yasm_effaddr * (*ea_create) (yasm_arch *arch, /*@keep@*/ yasm_expr *e);
 
     /** NULL-terminated list of machines for this architecture. */
@@ -307,7 +209,8 @@ typedef struct yasm_arch_module {
 
     /** Canonical "word" size in bytes. */
     unsigned int wordsize;
-} yasm_arch_module;
+};
+#endif
 
 #ifdef YASM_LIB_INTERNAL
 /** An instruction operand. */
@@ -338,11 +241,301 @@ struct yasm_insn_operand {
 };
 #endif
 
-/** Get the yasm_arch_module implementation for a yasm_arch.
+/** Get the version number of an architecture module.
+ * \param module       architecture module
+ * \return Version number (see #YASM_ARCH_VERSION).
+ */
+unsigned int yasm_arch_module_version(const yasm_arch_module *module);
+
+/** Get the machines usable with an architecture module.
+ * \param module       architecture module
+ * \return NULL-terminated list of machines.
+ */
+const yasm_arch_machine *yasm_arch_module_machines
+    (const yasm_arch_module *module);
+
+/** Get the default machine keyword for an architecture module.
+ * \param module       architecture module
+ * \return Default machine keyword.
+ */
+const char *yasm_arch_module_def_machine(const yasm_arch_module *module);
+
+/** Get the one-line description of an architecture.
+ * \param arch     architecture
+ * \return keyword
+ */
+const char *yasm_arch_name(const yasm_arch *arch);
+
+/** Get the keyword used to select an architecture.
+ * \param arch     architecture
+ * \return keyword
+ */
+const char *yasm_arch_keyword(const yasm_arch *arch);
+
+/** Get the word size of an architecture.
+ * \param arch     architecture
+ * \return word size
+ */
+unsigned int yasm_arch_wordsize(const yasm_arch *arch);
+
+/** Create architecture.
+ * \param module       architecture module
+ * \param machine      keyword of machine in use (must be one listed in
+ *                     #machines)
+ * \return NULL if machine not recognized, otherwise new architecture.
+ */
+/*@only@*/ yasm_arch *yasm_arch_create(const yasm_arch_module *module,
+                                      const char *machine);
+
+/** Clean up, free any architecture-allocated memory.
+ * \param arch architecture
+ */
+void yasm_arch_destroy(/*@only@*/ yasm_arch *arch);
+
+/** Get architecture's active machine name.
+ * \param arch architecture
+ * \return Active machine name.
+ */
+const char *yasm_arch_get_machine(const yasm_arch *arch);
+
+/** Set any arch-specific variables.  For example, "mode_bits" in x86.
+ * \param arch architecture
+ * \param var  variable name
+ * \param val  value to set
+ * \return Zero on success, non-zero on failure (variable does not exist).
+ */
+int yasm_arch_set_var(yasm_arch *arch, const char *var, unsigned long val);
+
+/** Switch available instructions/registers/etc based on a user-specified
+ * CPU identifier.  Should modify behavior ONLY of parse_* functions!  The
+ * bytecode and output functions should be able to handle any CPU.
+ * \param arch architecture
+ * \param cpuid        cpu identifier as in the input file
+ * \param line virtual line (from yasm_linemap)
+ */
+void yasm_arch_parse_cpu(yasm_arch *arch, const char *cpuid,
+                        unsigned long line);
+
+/** Check an generic identifier to see if it matches architecture specific
+ * names for instructions, registers, etc.  Unrecognized identifiers should
+ * be returned as #YASM_ARCH_CHECK_ID_NONE so they can be treated as normal
+ * symbols.  Any additional data beyond just the type (almost always
+ * necessary) should be returned into the space provided by the data
+ * parameter.
+ * \note Even though this is passed a data[4], only data[0] should be used
+ *      for #YASM_ARCH_CHECK_ID_TARGETMOD, #YASM_ARCH_CHECK_ID_REG, and
+ *      #YASM_ARCH_CHECK_ID_SEGREG return values.
  * \param arch architecture
- * \return Module implementation.
+ * \param data extra identification information (yasm_arch-specific)
+ *             [output]
+ * \param id   identifier as in the input file
+ * \param line virtual line (from yasm_linemap)
+ * \return General type of identifier (#yasm_arch_check_id_retval).
+ */
+yasm_arch_check_id_retval yasm_arch_parse_check_id
+    (yasm_arch *arch, unsigned long data[4], const char *id,
+     unsigned long line);
+
+/** Handle architecture-specific directives.
+ * Should modify behavior ONLY of parse functions, much like parse_cpu().
+ * \param arch                 architecture
+ * \param name                 directive name
+ * \param valparams            value/parameters
+ * \param objext_valparams     object format extensions
+ *                             value/parameters
+ * \param object               object
+ * \param line                 virtual line (as from yasm_linemap)
+ * \return Nonzero if directive was not recognized; 0 if directive was
+ *        recognized, even if it wasn't valid.
+ */
+int yasm_arch_parse_directive(yasm_arch *arch, const char *name,
+                             yasm_valparamhead *valparams,
+                             /*@null@*/ yasm_valparamhead *objext_valparams,
+                             yasm_object *object, unsigned long line);
+
+/** Create an instruction.  Creates a bytecode by matching the
+ * instruction data and the parameters given with a valid instruction.
+ * \param arch         architecture
+ * \param data         instruction data (from parse_check_id()); all
+ *                             zero indicates an empty instruction
+ * \param num_operands number of operands parsed
+ * \param operands     list of operands (in parse order)
+ * \param prev_bc      previously parsed bytecode in section (NULL if
+ *                     first bytecode in section)
+ * \param line         virtual line (from yasm_linemap)
+ * \return If no match is found (the instruction is invalid), NULL,
+ *            otherwise newly allocated bytecode containing instruction.
+ */
+/*@null@*/ yasm_bytecode *yasm_arch_parse_insn
+    (yasm_arch *arch, const unsigned long data[4], int num_operands,
+     /*@null@*/ yasm_insn_operands *operands, yasm_bytecode *prev_bc,
+     unsigned long line);
+
+/** Handle an instruction prefix.
+ * Modifies an instruction bytecode based on the prefix in data.
+ * \param arch architecture
+ * \param bc   bytecode (must be instruction bytecode)
+ * \param data prefix (from parse_check_id())
+ * \param line virtual line (from yasm_linemap)
+ */
+void yasm_arch_parse_prefix(yasm_arch *arch, yasm_bytecode *bc,
+                           const unsigned long data[4], unsigned long line);
+
+/** Handle an segment register instruction prefix.
+ * Modifies an instruction bytecode based on a segment register prefix.
+ * \param arch         architecture
+ * \param bc           bytecode (must be instruction bytecode)
+ * \param segreg       segment register (from parse_check_id())
+ * \param line         virtual line (from yasm_linemap)
+ */
+void yasm_arch_parse_seg_prefix(yasm_arch *arch, yasm_bytecode *bc,
+                               unsigned long segreg, unsigned long line);
+
+/** Handle a memory expression segment override.
+ * Modifies an instruction bytecode based on a segment override in a
+ * memory expression.
+ * \param arch         architecture
+ * \param ea           effective address
+ * \param segreg       segment register (from parse_check_id())
+ * \param line         virtual line (from yasm_linemap)
+ */
+void yasm_arch_parse_seg_override(yasm_arch *arch, yasm_effaddr *ea,
+                                 unsigned long segreg, unsigned long line);
+
+/** Output #yasm_floatnum to buffer.  Puts the value into the least
+ * significant bits of the destination, or may be shifted into more
+ * significant bits by the shift parameter.  The destination bits are
+ * cleared before being set.
+ * Architecture-specific because of endianness.
+ * \param arch         architecture
+ * \param flt          floating point value
+ * \param buf          buffer to write into
+ * \param destsize     destination size (in bytes)
+ * \param valsize      size (in bits)
+ * \param shift                left shift (in bits)
+ * \param warn         enables standard overflow/underflow warnings
+ * \param line         virtual line; may be 0 if warn is 0.
+ * \return Nonzero on error.
+ */
+int yasm_arch_floatnum_tobytes(yasm_arch *arch, const yasm_floatnum *flt,
+                              unsigned char *buf, size_t destsize,
+                              size_t valsize, size_t shift, int warn,
+                              unsigned long line);
+
+/** Output #yasm_intnum to buffer.  Puts the value into the least
+ * significant bits of the destination, or may be shifted into more
+ * significant bits by the shift parameter.  The destination bits are
+ * cleared before being set.
+ * \param arch         architecture
+ * \param intn         integer value
+ * \param buf          buffer to write into
+ * \param destsize     destination size (in bytes)
+ * \param valsize      size (in bits)
+ * \param shift                left shift (in bits); may be negative to specify right
+ *                     shift (standard warnings include truncation to boundary)
+ * \param bc           bytecode being output ("parent" of value)
+ * \param rel          value is a relative displacement from bc
+ * \param warn         enables standard warnings (value doesn't fit into
+ *                     valsize bits)
+ * \param line         virtual line; may be 0 if warn is 0
+ * \return Nonzero on error.
  */
-const yasm_arch_module *yasm_arch_get_module(yasm_arch *arch);
+int yasm_arch_intnum_tobytes(yasm_arch *arch, const yasm_intnum *intn,
+                            unsigned char *buf, size_t destsize,
+                            size_t valsize, int shift,
+                            const yasm_bytecode *bc, int rel, int warn,
+                            unsigned long line);
+
+/** Get the equivalent byte size of a register.
+ * \param arch architecture
+ * \param reg  register
+ * \return 0 if there is no suitable equivalent size, otherwise the size.
+ */
+unsigned int yasm_arch_get_reg_size(yasm_arch *arch, unsigned long reg);
+
+/** Print a register.  For debugging purposes.
+ * \param arch         architecture
+ * \param reg          register
+ * \param f            file
+ */
+void yasm_arch_reg_print(yasm_arch *arch, unsigned long reg, FILE *f);
+
+/** Print a segment register.  For debugging purposes.
+ * \param arch         architecture
+ * \param segreg       segment register
+ * \param f            file
+ */
+void yasm_arch_segreg_print(yasm_arch *arch, unsigned long segreg, FILE *f);
+
+/** Create an effective address from an expression.
+ * \param arch architecture
+ * \param e    expression (kept, do not delete)
+ * \return Newly allocated effective address.
+ */
+yasm_effaddr *yasm_arch_ea_create(yasm_arch *arch, /*@keep@*/ yasm_expr *e);
+
+
+#ifndef YASM_DOXYGEN
+
+/* Inline macro implementations for arch functions */
+
+#define yasm_arch_module_version(module, machine)   (module->version)
+#define yasm_arch_module_machines(module, machine)  (module->machines)
+#define yasm_arch_module_def_machine(module, machine) \
+    (module->default_machine_keyword)
+
+#define yasm_arch_name(arch) \
+    (((yasm_arch_base *)arch)->module->name)
+#define yasm_arch_keyword(arch) \
+    (((yasm_arch_base *)arch)->module->keyword)
+#define yasm_arch_wordsize(arch) \
+    (((yasm_arch_base *)arch)->module->wordsize)
+
+#define yasm_arch_create(module, machine)   module->create(machine)
+
+#define yasm_arch_destroy(arch) \
+    ((yasm_arch_base *)arch)->module->destroy(arch)
+#define yasm_arch_get_machine(arch) \
+    ((yasm_arch_base *)arch)->module->get_machine(arch)
+#define yasm_arch_set_var(arch, var, val) \
+    ((yasm_arch_base *)arch)->module->set_var(arch, var, val)
+#define yasm_arch_parse_cpu(arch, cpuid, line) \
+    ((yasm_arch_base *)arch)->module->parse_cpu(arch, cpuid, line)
+#define yasm_arch_parse_check_id(arch, data, id, line) \
+    ((yasm_arch_base *)arch)->module->parse_check_id(arch, data, id, line)
+#define yasm_arch_parse_directive(arch, name, valparams, objext_valparams, \
+                                 object, line) \
+    ((yasm_arch_base *)arch)->module->parse_directive \
+       (arch, name, valparams, objext_valparams, object, line)
+#define yasm_arch_parse_insn(arch, data, num_operands, operands, prev_bc, \
+                            line) \
+    ((yasm_arch_base *)arch)->module->parse_insn \
+       (arch, data, num_operands, operands, prev_bc, line)
+#define yasm_arch_parse_prefix(arch, bc, data, line) \
+    ((yasm_arch_base *)arch)->module->parse_prefix(arch, bc, data, line)
+#define yasm_arch_parse_seg_prefix(arch, bc, segreg, line) \
+    ((yasm_arch_base *)arch)->module->parse_seg_prefix(arch, bc, segreg, line)
+#define yasm_arch_parse_seg_override(arch, ea, segreg, line) \
+    ((yasm_arch_base *)arch)->module->parse_seg_override \
+       (arch, ea, segreg, line)
+#define yasm_arch_floatnum_tobytes(arch, flt, buf, destsize, valsize, shift, \
+                                  warn, line) \
+    ((yasm_arch_base *)arch)->module->floatnum_tobytes \
+       (arch, flt, buf, destsize, valsize, shift, warn, line)
+#define yasm_arch_intnum_tobytes(arch, intn, buf, destsize, valsize, shift, \
+                                bc, rel, warn, line) \
+    ((yasm_arch_base *)arch)->module->intnum_tobytes \
+       (arch, intn, buf, destsize, valsize, shift, bc, rel, warn, line)
+#define yasm_arch_get_reg_size(arch, reg) \
+    ((yasm_arch_base *)arch)->module->get_reg_size(arch, reg)
+#define yasm_arch_reg_print(arch, reg, f) \
+    ((yasm_arch_base *)arch)->module->reg_print(arch, reg, f)
+#define yasm_arch_segreg_print(arch, segreg, f) \
+    ((yasm_arch_base *)arch)->module->segreg_print(arch, segreg, f)
+#define yasm_arch_ea_create(arch, e) \
+    ((yasm_arch_base *)arch)->module->ea_create(arch, e)
+
+#endif
 
 /** Create an instruction operand from a register.
  * \param reg  register
@@ -382,19 +575,19 @@ void yasm_operand_print(const yasm_insn_operand *op, FILE *f, int indent_level,
 /** Create a new list of instruction operands.
  * \return Newly allocated list.
  */
-yasm_insn_operandhead *yasm_ops_create(void);
+yasm_insn_operands *yasm_ops_create(void);
 
 /** Destroy a list of instruction operands (created with yasm_ops_create()).
  * \param headp                list of instruction operands
  * \param content      if nonzero, deletes content of each operand
  */
-void yasm_ops_destroy(yasm_insn_operandhead *headp, int content);
+void yasm_ops_destroy(yasm_insn_operands *headp, int content);
 
 /** Get the first operand in a list of instruction operands.
  * \param headp                list of instruction operands
  * \return First operand in list (NULL if list is empty).
  */
-yasm_insn_operand *yasm_ops_first(yasm_insn_operandhead *headp);
+yasm_insn_operand *yasm_ops_first(yasm_insn_operands *headp);
 
 /** Get the next operand in a list of instruction operands.
  * \param cur          previous operand
@@ -412,7 +605,7 @@ yasm_insn_operand *yasm_operand_next(yasm_insn_operand *cur);
  * \param headp                list of instruction operands
  * \param content      if nonzero, deletes content of each operand
  */
-void yasm_ops_delete(yasm_insn_operandhead *headp, int content);
+void yasm_ops_delete(yasm_insn_operands *headp, int content);
 #endif
 
 /** Add data value to the end of a list of instruction operands.
@@ -425,7 +618,7 @@ void yasm_ops_delete(yasm_insn_operandhead *headp, int content);
  *        otherwise NULL.
  */
 /*@null@*/ yasm_insn_operand *yasm_ops_append
-    (yasm_insn_operandhead *headp,
+    (yasm_insn_operands *headp,
      /*@returned@*/ /*@null@*/ yasm_insn_operand *op);
 
 /** Print a list of instruction operands.  For debugging purposes.
@@ -434,7 +627,7 @@ void yasm_ops_delete(yasm_insn_operandhead *headp, int content);
  * \param indent_level indentation level
  * \param headp                list of instruction operands
  */
-void yasm_ops_print(const yasm_insn_operandhead *headp, FILE *f,
-                   int indent_level, yasm_arch *arch);
+void yasm_ops_print(const yasm_insn_operands *headp, FILE *f, int indent_level,
+                   yasm_arch *arch);
 
 #endif
index f25a38db0f61bbdd1b043dce19bbd27f12841025..667b4c9d724566276952c0e1867d54c0f1a4b81c 100644 (file)
@@ -1258,7 +1258,7 @@ yasm_expr_print(const yasm_expr *e, FILE *f)
                break;
            case YASM_EXPR_REG:
                /* FIXME */
-               /*arch->module->reg_print(arch, e->terms[i].data.reg, f);*/
+               /*yasm_arch_reg_print(arch, e->terms[i].data.reg, f);*/
                break;
            case YASM_EXPR_NONE:
                break;
index 52482e956ad5ce47aad801ebf2f3b5594cd00a10..01fa52c04a440dc7513f4947cecefc3b6ae9ef81 100644 (file)
@@ -39,14 +39,14 @@ yasm_arch_module yasm_lc3b_LTX_arch;
 static /*@only@*/ yasm_arch *
 lc3b_create(const char *machine)
 {
-    yasm_arch *arch;
+    yasm_arch_base *arch;
 
     if (yasm__strcasecmp(machine, "lc3b") != 0)
        return NULL;
 
-    arch = yasm_xmalloc(sizeof(yasm_arch));
+    arch = yasm_xmalloc(sizeof(yasm_arch_base));
     arch->module = &yasm_lc3b_LTX_arch;
-    return arch;
+    return (yasm_arch *)arch;
 }
 
 static void
index 5ef5dbd4fd27349ce09e3030ad18f6e416098a7a..c9525a1e7c85387adc397f6fa89c75954ac0fda6 100644 (file)
@@ -62,7 +62,7 @@ yasm_arch_check_id_retval yasm_lc3b__parse_check_id
 
 /*@null@*/ yasm_bytecode *yasm_lc3b__parse_insn
     (yasm_arch *arch, const unsigned long data[2], int num_operands,
-     /*@null@*/ yasm_insn_operandhead *operands, yasm_bytecode *prev_bc,
+     /*@null@*/ yasm_insn_operands *operands, yasm_bytecode *prev_bc,
      unsigned long line);
 
 int yasm_lc3b__intnum_tobytes
index 5e5cdcd16e73859c60df13bc6f0de8a7d1318585..1d8cb7e808cebc07ed47d30679ba8342dcd5243c 100644 (file)
@@ -174,7 +174,7 @@ static const lc3b_insn_info trap_insn[] = {
 
 yasm_bytecode *
 yasm_lc3b__parse_insn(yasm_arch *arch, const unsigned long data[4],
-                     int num_operands, yasm_insn_operandhead *operands,
+                     int num_operands, yasm_insn_operands *operands,
                      yasm_bytecode *prev_bc, unsigned long line)
 {
     lc3b_new_insn_data d;
index e15570311d75a89ff6aadbbfa43283c87c790aad..e3f69f15ec388482f60e39ed4dff67566b6bc55c 100644 (file)
@@ -62,7 +62,7 @@
 #define CPU_Not64   (1UL<<25)  /* Not available (invalid) in 64-bit mode */
 
 typedef struct yasm_arch_x86 {
-    yasm_arch arch;    /* base structure */
+    yasm_arch_base arch;       /* base structure */
 
     /* What instructions/features are enabled? */
     unsigned long cpu_enabled;
@@ -209,7 +209,7 @@ yasm_arch_check_id_retval yasm_x86__parse_check_id
 
 /*@null@*/ yasm_bytecode *yasm_x86__parse_insn
     (yasm_arch *arch, const unsigned long data[2], int num_operands,
-     /*@null@*/ yasm_insn_operandhead *operands, yasm_bytecode *prev_bc,
+     /*@null@*/ yasm_insn_operands *operands, yasm_bytecode *prev_bc,
      unsigned long line);
 
 int yasm_x86__floatnum_tobytes
index 1a2da44244482b6d811b9df0c42de459bde6c20b..7dd6e43c6c626c96f12aab349d9d4697f429e3c9 100644 (file)
@@ -1520,7 +1520,7 @@ static const x86_insn_info xbts_insn[] = {
 
 static yasm_bytecode *
 x86_new_jmp(yasm_arch *arch, const unsigned long data[4], int num_operands,
-           yasm_insn_operandhead *operands, x86_insn_info *jinfo,
+           yasm_insn_operands *operands, x86_insn_info *jinfo,
            yasm_bytecode *prev_bc, unsigned long line)
 {
     yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch;
@@ -1642,7 +1642,7 @@ x86_new_jmp(yasm_arch *arch, const unsigned long data[4], int num_operands,
 
 yasm_bytecode *
 yasm_x86__parse_insn(yasm_arch *arch, const unsigned long data[4],
-                    int num_operands, yasm_insn_operandhead *operands,
+                    int num_operands, yasm_insn_operands *operands,
                     yasm_bytecode *prev_bc, unsigned long line)
 {
     yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch;
index da0c502f128d3ad2b950440a23fac2b13129f1fc..6ab083d4b6de90478a8aef4c557e0089577526ed 100644 (file)
@@ -342,10 +342,10 @@ stabs_dbgfmt_generate(yasm_object *object)
     stabs_stab *stab;
     yasm_bytecode *filebc, *nullbc, *laststr;
     yasm_section *stext;
-    const char *machine = cur_arch->module->get_machine(cur_arch);
+    const char *machine = yasm_arch_get_machine(cur_arch);
 
     /* Stablen is determined by arch/machine */
-    if (yasm__strcasecmp(cur_arch->module->keyword, "x86") == 0) {
+    if (yasm__strcasecmp(yasm_arch_keyword(cur_arch), "x86") == 0) {
        if (yasm__strcasecmp(machine, "x86") == 0) {
            info.stablen = 12;
        }
index 9efa84fa7a3ebf2b5b5a17123896e1a1ff085307..cb7706e7fd93738590798546646f190451813d83 100644 (file)
@@ -158,17 +158,16 @@ bin_objfmt_output_expr(yasm_expr **ep, unsigned char *buf, size_t destsize,
     if (flt) {
        if (shift < 0)
            yasm_internal_error(N_("attempting to negative shift a float"));
-       return cur_arch->module->floatnum_tobytes(cur_arch, flt, buf, destsize,
-                                                 valsize, (unsigned int)shift,
-                                                 warn, bc->line);
+       return yasm_arch_floatnum_tobytes(cur_arch, flt, buf, destsize,
+                                         valsize, (unsigned int)shift, warn,
+                                         bc->line);
     }
 
     /* Handle integer expressions */
     intn = yasm_expr_get_intnum(ep, NULL);
     if (intn)
-       return cur_arch->module->intnum_tobytes(cur_arch, intn, buf, destsize,
-                                               valsize, shift, bc, rel, warn,
-                                               bc->line);
+       return yasm_arch_intnum_tobytes(cur_arch, intn, buf, destsize, valsize,
+                                       shift, bc, rel, warn, bc->line);
 
     /* Check for complex float expressions */
     if (yasm_expr__contains(*ep, YASM_EXPR_FLOAT)) {
index 625fed6c06b5004c05f2999698755aa231f32482..349eb5f44615ff1efc34385b457e583da5b48fe2 100644 (file)
@@ -234,8 +234,8 @@ coff_common_initialize(const char *in_filename,
     cur_arch = a;
 
     /* Only support x86 arch, x86 machine */
-    if (yasm__strcasecmp(cur_arch->module->keyword, "x86") != 0 ||
-       yasm__strcasecmp(cur_arch->module->get_machine(cur_arch), "x86") != 0)
+    if (yasm__strcasecmp(yasm_arch_keyword(cur_arch), "x86") != 0 ||
+       yasm__strcasecmp(yasm_arch_get_machine(cur_arch), "x86") != 0)
        return 1;
 
     coff_objfmt_parse_scnum = 1;    /* section numbering starts at 1 */
@@ -321,9 +321,9 @@ coff_objfmt_output_expr(yasm_expr **ep, unsigned char *buf, size_t destsize,
     if (flt) {
        if (shift < 0)
            yasm_internal_error(N_("attempting to negative shift a float"));
-       return cur_arch->module->floatnum_tobytes(cur_arch, flt, buf, destsize,
-                                                 valsize, (unsigned int)shift,
-                                                 warn, bc->line);
+       return yasm_arch_floatnum_tobytes(cur_arch, flt, buf, destsize,
+                                         valsize, (unsigned int)shift, warn,
+                                         bc->line);
     }
 
     /* Handle integer expressions, with relocation if necessary */
@@ -396,9 +396,8 @@ coff_objfmt_output_expr(yasm_expr **ep, unsigned char *buf, size_t destsize,
     }
     intn = yasm_expr_get_intnum(ep, NULL);
     if (intn)
-       return cur_arch->module->intnum_tobytes(cur_arch, intn, buf, destsize,
-                                               valsize, shift, bc, rel, warn,
-                                               bc->line);
+       return yasm_arch_intnum_tobytes(cur_arch, intn, buf, destsize, valsize,
+                                       shift, bc, rel, warn, bc->line);
 
     /* Check for complex float expressions */
     if (yasm_expr__contains(*ep, YASM_EXPR_FLOAT)) {
index aa62cf3d15656a7538b71c0a1e7e464085c31d22..ab2a60e28063a60891ff4cd7ce521415a662c338 100644 (file)
@@ -62,7 +62,7 @@ dbg_objfmt_initialize(const char *in_filename, const char *obj_filename,
     }
     fprintf(dbg_objfmt_file,
            "initialize(\"%s\", \"%s\", %s dbgfmt, %s arch)\n",
-           in_filename, obj_filename, df->keyword, a->module->keyword);
+           in_filename, obj_filename, df->keyword, yasm_arch_keyword(a));
     return 0;
 }
 
index 5581f222a3873b3dc365c2b5ac4ce0bb1d5bac72..73429803034999c76a323816ce6377624664d8b8 100644 (file)
@@ -199,9 +199,8 @@ elf_objfmt_output_reloc(yasm_symrec *sym, yasm_bytecode *bc,
     if (elf_secthead_append_reloc(info->shead, reloc))
        elf_objfmt_parse_scnum++;
 
-    retval = cur_arch->module->intnum_tobytes(cur_arch, zero, buf, destsize,
-                                             valsize, 0, bc, rel, warn,
-                                             bc->line);
+    retval = yasm_arch_intnum_tobytes(cur_arch, zero, buf, destsize, valsize,
+                                     0, bc, rel, warn, bc->line);
     yasm_intnum_destroy(zero);
     return retval;
 }
@@ -227,9 +226,9 @@ elf_objfmt_output_expr(yasm_expr **ep, unsigned char *buf, size_t destsize,
     if (flt) {
        if (shift < 0)
            yasm_internal_error(N_("attempting to negative shift a float"));
-       return cur_arch->module->floatnum_tobytes(cur_arch, flt, buf, destsize,
-                                                 valsize, (unsigned int)shift,
-                                                 warn, bc->line);
+       return yasm_arch_floatnum_tobytes(cur_arch, flt, buf, destsize,
+                                         valsize, (unsigned int)shift, warn,
+                                         bc->line);
     }
 
     /* Handle integer expressions, with relocation if necessary */
@@ -279,9 +278,8 @@ elf_objfmt_output_expr(yasm_expr **ep, unsigned char *buf, size_t destsize,
 
     intn = yasm_expr_get_intnum(ep, NULL);
     if (intn)
-       return cur_arch->module->intnum_tobytes(cur_arch, intn, buf, destsize,
-                                               valsize, shift, bc, rel, warn,
-                                               bc->line);
+       return yasm_arch_intnum_tobytes(cur_arch, intn, buf, destsize, valsize,
+                                       shift, bc, rel, warn, bc->line);
 
     /* Check for complex float expressions */
     if (yasm_expr__contains(*ep, YASM_EXPR_FLOAT)) {
index a72881eb1c94cb5f31ab30d42021c4f0ee335e1e..b2c590880dfec61b9894128b18395347384590e0 100644 (file)
@@ -79,11 +79,11 @@ static enum {
 int
 elf_set_arch(yasm_arch *arch)
 {
-    const char *machine = arch->module->get_machine(arch);
+    const char *machine = yasm_arch_get_machine(arch);
     cur_arch = arch;
 
     /* TODO: support more than x86:x86, x86:amd64 */
-    if (yasm__strcasecmp(cur_arch->module->keyword, "x86") == 0) {
+    if (yasm__strcasecmp(yasm_arch_keyword(cur_arch), "x86") == 0) {
        if (yasm__strcasecmp(machine, "x86") == 0) {
            cur_machine = M_X86_32;
            cur_elf = ELF32;
index 2db48c22a7acfae0bfdd42afb48ccb8bcbe839c8..f95eea6fdc2b94c28604ae75dfa8f40952b327b9 100644 (file)
@@ -74,7 +74,7 @@ static void define_label(yasm_parser_nasm *parser_nasm, /*@only@*/ char *name,
     yasm_valparamhead dir_valparams;
     yasm_valparam *dir_valparam;
     struct {
-       yasm_insn_operandhead operands;
+       yasm_insn_operands operands;
        int num_operands;
     } insn_operands;
     yasm_insn_operand *insn_operand;
@@ -203,12 +203,13 @@ exp: instr
 ;
 
 instr: INSN            {
-       $$ = p_arch->module->parse_insn(p_arch, $1, 0, NULL,
-                                       parser_nasm->prev_bc, cur_line);
+       $$ = yasm_arch_parse_insn(parser_nasm->arch, $1, 0, NULL,
+                                 parser_nasm->prev_bc, cur_line);
     }
     | INSN operands    {
-       $$ = p_arch->module->parse_insn(p_arch, $1, $2.num_operands,
-           &$2.operands, parser_nasm->prev_bc, cur_line);
+       $$ = yasm_arch_parse_insn(parser_nasm->arch, $1, $2.num_operands,
+                                 &$2.operands, parser_nasm->prev_bc,
+                                 cur_line);
        yasm_ops_delete(&$2.operands, 0);
     }
     | INSN error       {
@@ -217,11 +218,11 @@ instr: INSN               {
     }
     | PREFIX instr     {
        $$ = $2;
-       p_arch->module->parse_prefix(p_arch, $$, $1, cur_line);
+       yasm_arch_parse_prefix(parser_nasm->arch, $$, $1, cur_line);
     }
     | SEGREG instr     {
        $$ = $2;
-       p_arch->module->parse_seg_prefix(p_arch, $$, $1[0], cur_line);
+       yasm_arch_parse_seg_prefix(parser_nasm->arch, $$, $1[0], cur_line);
     }
 ;
 
@@ -309,11 +310,11 @@ directive_valparam: direxpr       {
 
 /* memory addresses */
 memaddr: expr              {
-       $$ = p_arch->module->ea_create(p_arch, $1);
+       $$ = yasm_arch_ea_create(parser_nasm->arch, $1);
     }
     | SEGREG ':' memaddr    {
        $$ = $3;
-       p_arch->module->parse_seg_override(p_arch, $$, $1[0], cur_line);
+       yasm_arch_parse_seg_override(parser_nasm->arch, $$, $1[0], cur_line);
     }
     | SIZE_OVERRIDE memaddr { $$ = $2; yasm_ea_set_len($$, $1); }
     | NOSPLIT memaddr      { $$ = $2; yasm_ea_set_nosplit($$, 1); }
@@ -338,7 +339,7 @@ operand: '[' memaddr ']'    { $$ = yasm_operand_create_mem($2); }
     | SIZE_OVERRIDE operand {
        $$ = $2;
        if ($$->type == YASM_INSN__OPERAND_REG &&
-           p_arch->module->get_reg_size(p_arch, $$->data.reg) != $1)
+           yasm_arch_get_reg_size(parser_nasm->arch, $$->data.reg) != $1)
            yasm__error(cur_line, N_("cannot override register size"));
        else
            $$->size = $1;
@@ -597,7 +598,7 @@ nasm_parser_directive(yasm_parser_nasm *parser_nasm, const char *name,
     } else if (yasm__strcasecmp(name, "cpu") == 0) {
        yasm_vps_foreach(vp, valparams) {
            if (vp->val)
-               p_arch->module->parse_cpu(p_arch, vp->val, line);
+               yasm_arch_parse_cpu(parser_nasm->arch, vp->val, line);
            else if (vp->param) {
                const yasm_intnum *intcpu;
                intcpu = yasm_expr_get_intnum(&vp->param, NULL);
@@ -606,11 +607,11 @@ nasm_parser_directive(yasm_parser_nasm *parser_nasm, const char *name,
                else {
                    char strcpu[16];
                    sprintf(strcpu, "%lu", yasm_intnum_get_uint(intcpu));
-                   p_arch->module->parse_cpu(p_arch, strcpu, line);
+                   yasm_arch_parse_cpu(parser_nasm->arch, strcpu, line);
                }
            }
        }
-    } else if (!p_arch->module->parse_directive(p_arch, name, valparams,
+    } else if (!yasm_arch_parse_directive(parser_nasm->arch, name, valparams,
                    objext_valparams, parser_nasm->object, line)) {
        ;
     } else if (parser_nasm->objfmt->directive(name, valparams,
index 2486dba3f5634edc4f4352111f69382f9e768f7a..43d90ccc1f77e9cdcd458623183a317899459a23 100644 (file)
@@ -72,7 +72,6 @@ typedef struct yasm_parser_nasm {
 } yasm_parser_nasm;
 
 /* shorter access names to commonly used parser_nasm fields */
-#define p_arch         (parser_nasm->arch)
 #define p_symtab       (parser_nasm->symtab)
 
 #define cur_line       (yasm_linemap_get_current(parser_nasm->linemap))
index f6e5038b5d0b50109a577dc125fdc11587301a3c..582813a7b1bc4d72303d5097ebaf94f783282406 100644 (file)
@@ -289,71 +289,71 @@ scan:
        /* size specifiers */
        B Y T E         { lvalp->int_info = 1; RETURN(SIZE_OVERRIDE); }
        H W O R D       {
-           lvalp->int_info = p_arch->module->wordsize/2;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)/2;
            RETURN(SIZE_OVERRIDE);
        }
        W O R D         {
-           lvalp->int_info = p_arch->module->wordsize;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch);
            RETURN(SIZE_OVERRIDE);
        }
        D W O R D       {
-           lvalp->int_info = p_arch->module->wordsize*2;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)*2;
            RETURN(SIZE_OVERRIDE);
        }
        Q W O R D       {
-           lvalp->int_info = p_arch->module->wordsize*4;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)*4;
            RETURN(SIZE_OVERRIDE);
        }
        T W O R D       { lvalp->int_info = 10; RETURN(SIZE_OVERRIDE); }
        D Q W O R D     {
-           lvalp->int_info = p_arch->module->wordsize*8;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)*8;
            RETURN(SIZE_OVERRIDE);
        }
 
        /* pseudo-instructions */
        D B             { lvalp->int_info = 1; RETURN(DECLARE_DATA); }
        D H W           {
-           lvalp->int_info = p_arch->module->wordsize/2;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)/2;
            RETURN(DECLARE_DATA);
        }
        D W             {
-           lvalp->int_info = p_arch->module->wordsize;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch);
            RETURN(DECLARE_DATA);
        }
        D D             {
-           lvalp->int_info = p_arch->module->wordsize*2;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)*2;
            RETURN(DECLARE_DATA);
        }
        D Q             {
-           lvalp->int_info = p_arch->module->wordsize*4;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)*4;
            RETURN(DECLARE_DATA);
        }
        D T             { lvalp->int_info = 10; RETURN(DECLARE_DATA); }
        D D Q           {
-           lvalp->int_info = p_arch->module->wordsize*8;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)*8;
            RETURN(DECLARE_DATA);
        }
 
        R E S B         { lvalp->int_info = 1; RETURN(RESERVE_SPACE); }
        R E S H W       {
-           lvalp->int_info = p_arch->module->wordsize/2;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)/2;
            RETURN(RESERVE_SPACE);
        }
        R E S W         {
-           lvalp->int_info = p_arch->module->wordsize;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch);
            RETURN(RESERVE_SPACE);
        }
        R E S D         {
-           lvalp->int_info = p_arch->module->wordsize*2;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)*2;
            RETURN(RESERVE_SPACE);
        }
        R E S Q         {
-           lvalp->int_info = p_arch->module->wordsize*4;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)*4;
            RETURN(RESERVE_SPACE);
        }
        R E S T         { lvalp->int_info = 10; RETURN(RESERVE_SPACE); }
        R E S D Q       {
-           lvalp->int_info = p_arch->module->wordsize*8;
+           lvalp->int_info = yasm_arch_wordsize(parser_nasm->arch)*8;
            RETURN(RESERVE_SPACE);
        }
 
@@ -421,9 +421,9 @@ scan:
        [a-zA-Z_?][a-zA-Z0-9_$#@~.?]* {
            savech = s->tok[TOKLEN];
            s->tok[TOKLEN] = '\0';
-           check_id_ret = p_arch->module->parse_check_id(p_arch,
-                                                         lvalp->arch_data,
-                                                         s->tok, cur_line);
+           check_id_ret = yasm_arch_parse_check_id(parser_nasm->arch,
+                                                   lvalp->arch_data, s->tok,
+                                                   cur_line);
            s->tok[TOKLEN] = savech;
            switch (check_id_ret) {
                case YASM_ARCH_CHECK_ID_NONE: