]> granicus.if.org Git - yasm/commitdiff
Get rid of calc_bc_dist_func, the only times this was used was when
authorPeter Johnson <peter@tortall.net>
Wed, 7 Jun 2006 04:01:33 +0000 (04:01 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 7 Jun 2006 04:01:33 +0000 (04:01 -0000)
yasm_common_calc_bc_dist was used.  Rename yasm_common_calc_bc_dist to
yasm_calc_bc_dist, call it directly from the expr functions, and change
higher-level callers to boolean flags of whether to calculate bc distance
or not.

svn path=/branches/new-optimizer/; revision=1550

34 files changed:
libyasm/bc-align.c
libyasm/bc-data.c
libyasm/bc-incbin.c
libyasm/bc-insn.c
libyasm/bc-reserve.c
libyasm/bytecode.c
libyasm/bytecode.h
libyasm/coretype.h
libyasm/expr.c
libyasm/expr.h
libyasm/value.c
libyasm/value.h
modules/arch/x86/x86arch.c
modules/arch/x86/x86bc.c
modules/arch/x86/x86expr.c
modules/arch/x86/x86id.c
modules/dbgfmts/codeview/cv-symline.c
modules/dbgfmts/dwarf2/dwarf2-aranges.c
modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c
modules/dbgfmts/dwarf2/dwarf2-info.c
modules/dbgfmts/dwarf2/dwarf2-line.c
modules/listfmts/nasm/nasm-listfmt.c
modules/objfmts/bin/bin-objfmt.c
modules/objfmts/coff/coff-objfmt.c
modules/objfmts/elf/elf-objfmt.c
modules/objfmts/elf/elf.c
modules/objfmts/xdf/xdf-objfmt.c
modules/parsers/gas/gas-bison.y
modules/parsers/nasm/nasm-bison.y
modules/preprocs/nasm/nasm-pp.c
tools/python-yasm/bytecode.pxi
tools/python-yasm/coretype.pxi
tools/python-yasm/expr.pxi
tools/python-yasm/value.pxi

index 0506a506292fd92d3ca6c99bae2769fe96ae6806..152b96251a79dc807e1cd23e75e695aafd6016dc 100644 (file)
@@ -106,13 +106,13 @@ static void
 bc_align_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc)
 {
     bytecode_align *align = (bytecode_align *)bc->contents;
-    if (!yasm_expr_get_intnum(&align->boundary, NULL))
+    if (!yasm_expr_get_intnum(&align->boundary, 0))
        yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                       N_("align boundary must be a constant"));
-    if (align->fill && !yasm_expr_get_intnum(&align->fill, NULL))
+    if (align->fill && !yasm_expr_get_intnum(&align->fill, 0))
        yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                       N_("align fill must be a constant"));
-    if (align->maxskip && !yasm_expr_get_intnum(&align->maxskip, NULL))
+    if (align->maxskip && !yasm_expr_get_intnum(&align->maxskip, 0))
        yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                       N_("align maximum skip must be a constant"));
 }
@@ -165,7 +165,7 @@ bc_align_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
     bytecode_align *align = (bytecode_align *)bc->contents;
     unsigned long len;
     unsigned long boundary =
-       yasm_intnum_get_uint(yasm_expr_get_intnum(&align->boundary, NULL));
+       yasm_intnum_get_uint(yasm_expr_get_intnum(&align->boundary, 0));
 
     if (boundary == 0)
        return 0;
@@ -178,8 +178,7 @@ bc_align_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
            return 0;
        if (align->maxskip) {
            unsigned long maxskip =
-               yasm_intnum_get_uint(yasm_expr_get_intnum(&align->maxskip,
-                                                         NULL));
+               yasm_intnum_get_uint(yasm_expr_get_intnum(&align->maxskip, 0));
            if (len > maxskip)
                return 0;
        }
@@ -187,7 +186,7 @@ bc_align_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
 
     if (align->fill) {
        unsigned long v;
-       v = yasm_intnum_get_uint(yasm_expr_get_intnum(&align->fill, NULL));
+       v = yasm_intnum_get_uint(yasm_expr_get_intnum(&align->fill, 0));
        memset(*bufp, (int)v, len);
        *bufp += len;
     } else if (align->code_fill) {
index c6913bdce4839700efa295d4287276d74c5edec1..b58b56bd0956e402d80a734a63335bf7b0e13e5b 100644 (file)
@@ -116,7 +116,7 @@ bc_data_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc)
                break;
            case DV_ULEB128:
            case DV_SLEB128:
-               intn = yasm_expr_get_intnum(&dv->data.val.abs, NULL);
+               intn = yasm_expr_get_intnum(&dv->data.val.abs, 0);
                if (!intn) {
                    yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                                   N_("LEB128 requires constant values"));
@@ -157,7 +157,7 @@ bc_data_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
                break;
            case DV_ULEB128:
            case DV_SLEB128:
-               intn = yasm_expr_get_intnum(&dv->data.val.abs, NULL);
+               intn = yasm_expr_get_intnum(&dv->data.val.abs, 0);
                if (!intn)
                    yasm_internal_error(N_("non-constant in data_tobytes"));
                bc->len +=
@@ -197,7 +197,7 @@ bc_data_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
                break;
            case DV_ULEB128:
            case DV_SLEB128:
-               intn = yasm_expr_get_intnum(&dv->data.val.abs, NULL);
+               intn = yasm_expr_get_intnum(&dv->data.val.abs, 234);
                if (!intn)
                    yasm_internal_error(N_("non-constant in data_tobytes"));
                *bufp +=
@@ -231,7 +231,7 @@ yasm_bc_create_data(yasm_datavalhead *datahead, unsigned int size,
            case DV_VALUE:
            case DV_ULEB128:
            case DV_SLEB128:
-               intn = yasm_expr_get_intnum(&dv->data.val.abs, NULL);
+               intn = yasm_expr_get_intnum(&dv->data.val.abs, 0);
                if (intn && dv->type == DV_VALUE && (arch || size == 1))
                    len += size;
                else if (intn && dv->type == DV_ULEB128)
@@ -279,7 +279,7 @@ yasm_bc_create_data(yasm_datavalhead *datahead, unsigned int size,
            case DV_VALUE:
            case DV_ULEB128:
            case DV_SLEB128:
-               intn = yasm_expr_get_intnum(&dv->data.val.abs, NULL);
+               intn = yasm_expr_get_intnum(&dv->data.val.abs, 0);
                if (intn && dv->type == DV_VALUE && (arch || size == 1)) {
                    if (size == 1)
                        yasm_intnum_get_sized(intn,
index 7201f8df800928f018df9597abd7a722d22bec7a..cf8dc27884934ac4565bda046865c57c8727ddd4 100644 (file)
@@ -134,7 +134,7 @@ bc_incbin_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
 
     /* Try to convert start to integer value */
     if (incbin->start) {
-       num = yasm_expr_get_intnum(&incbin->start, NULL);
+       num = yasm_expr_get_intnum(&incbin->start, 0);
        if (num)
            start = yasm_intnum_get_uint(num);
        if (!num) {
@@ -147,7 +147,7 @@ bc_incbin_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
 
     /* Try to convert maxlen to integer value */
     if (incbin->maxlen) {
-       num = yasm_expr_get_intnum(&incbin->maxlen, NULL);
+       num = yasm_expr_get_intnum(&incbin->maxlen, 0);
        if (num)
            maxlen = yasm_intnum_get_uint(num);
        if (!num) {
@@ -206,7 +206,7 @@ bc_incbin_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
 
     /* Convert start to integer value */
     if (incbin->start) {
-       num = yasm_expr_get_intnum(&incbin->start, NULL);
+       num = yasm_expr_get_intnum(&incbin->start, 0);
        if (!num)
            yasm_internal_error(
                N_("could not determine start in bc_tobytes_incbin"));
index 4d3afacbe79d0b4ffebdc4d690ebb91104552aa3..6e63e311754cfa8c2012e80c0bcafd735933ad32 100644 (file)
@@ -205,7 +205,7 @@ bc_insn_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc)
                if (op->data.ea)
                    op->data.ea->disp.abs =
                        yasm_expr__level_tree(op->data.ea->disp.abs, 1, 1, 0,
-                                             NULL, NULL, NULL, NULL);
+                                             0, NULL, NULL, NULL);
                if (yasm_error_occurred()) {
                    /* Add a pointer to where it was used to the error */
                    yasm_error_fetch(&eclass, &str, &xrefline, &xrefstr);
@@ -222,8 +222,8 @@ bc_insn_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc)
                break;
            case YASM_INSN__OPERAND_IMM:
                op->data.val =
-                   yasm_expr__level_tree(op->data.val, 1, 1, 1, NULL, NULL,
-                                         NULL, NULL);
+                   yasm_expr__level_tree(op->data.val, 1, 1, 1, 0, NULL, NULL,
+                                         NULL);
                if (yasm_error_occurred()) {
                    /* Add a pointer to where it was used to the error */
                    yasm_error_fetch(&eclass, &str, &xrefline, &xrefstr);
index 03280d180a8f1a404a11c99c2dc1d326e0d89885..2be15122de37783e5c733c8c0d8c132eafd013c2 100644 (file)
@@ -114,7 +114,7 @@ bc_reserve_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
     if (!reserve->numitems)
        return 0;
 
-    num = yasm_expr_get_intnum(&reserve->numitems, NULL);
+    num = yasm_expr_get_intnum(&reserve->numitems, 0);
     if (!num) {
        /* Check for use of floats first. */
        if (reserve->numitems &&
index e008da1aa205068f465f3972f78823b1be07f25b..327e8751bf8f667bb9d99f2ffe3c00a54633fad1 100644 (file)
@@ -179,7 +179,7 @@ yasm_bc_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc)
 }
 
 /*@null@*/ yasm_intnum *
-yasm_common_calc_bc_dist(yasm_bytecode *precbc1, yasm_bytecode *precbc2)
+yasm_calc_bc_dist(yasm_bytecode *precbc1, yasm_bytecode *precbc2)
 {
     unsigned long dist;
     yasm_intnum *intn;
@@ -261,7 +261,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
     unsigned long datasize, multiple, i;
     int error = 0;
 
-    if (yasm_bc_get_multiple(bc, &multiple, NULL) || multiple == 0) {
+    if (yasm_bc_get_multiple(bc, &multiple, 1) || multiple == 0) {
        *bufsize = 0;
        return NULL;
     }
@@ -300,7 +300,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
 
 int
 yasm_bc_get_multiple(yasm_bytecode *bc, unsigned long *multiple,
-                    yasm_calc_bc_dist_func calc_bc_dist)
+                    int calc_bc_dist)
 {
     /*@dependent@*/ /*@null@*/ const yasm_intnum *num;
 
index 181d1bb5b6696ef4b4b8ef12f90e5366f7750b37..3013eb00597ff02959949d33d913199122fc49cb 100644 (file)
@@ -299,12 +299,13 @@ void yasm_bc_print(const yasm_bytecode *bc, FILE *f, int indent_level);
  */
 void yasm_bc_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc);
 
-/** Common version of calc_bc_dist that takes offsets from bytecodes.
- * Should be used for the final stages of optimizers as well as in yasm_objfmt
- * yasm_expr output functions.
- * \see yasm_calc_bc_dist_func for parameter descriptions.
+/** Determine the distance between the starting offsets of two bytecodes.
+ * \param precbc1      preceding bytecode to the first bytecode
+ * \param precbc2      preceding bytecode to the second bytecode
+ * \return Distance in bytes between the two bytecodes (bc2-bc1), or NULL if
+ *        the distance was indeterminate.
  */
-/*@null@*/ /*@only@*/ yasm_intnum *yasm_common_calc_bc_dist
+/*@null@*/ /*@only@*/ yasm_intnum *yasm_calc_bc_dist
     (yasm_bytecode *precbc1, yasm_bytecode *precbc2);
 
 /**
@@ -378,11 +379,12 @@ int yasm_bc_expand(yasm_bytecode *bc, int span, long old_val, long new_val,
 /** Get the bytecode multiple value as an unsigned long integer.
  * \param bc           bytecode
  * \param multiple     multiple value (output)
- * \param calc_bc_dist bytecode distance calculation function (optional)
+ * \param calc_bc_dist nonzero if distances between bytecodes should be
+ *                     calculated, 0 if error should be returned in this case
  * \return 1 on error (set with yasm_error_set), 0 on success.
  */
 int yasm_bc_get_multiple(yasm_bytecode *bc, /*@out@*/ unsigned long *multiple,
-                        /*@null@*/ yasm_calc_bc_dist_func calc_bc_dist);
+                        int calc_bc_dist);
 
 /** Create a new data value from an expression.
  * \param expn expression
index 89e5ed355caec49a0162dce949179820447e317d..3fed09afad6073457279a428eb0edafeb752aea1 100644 (file)
@@ -230,15 +230,6 @@ typedef enum {
     YASM_SYM_DLOCAL = 1 << 3   /**< If symbol is explicitly declared LOCAL */
 } yasm_sym_vis;
 
-/** Determine the distance between the starting offsets of two bytecodes.
- * \param precbc1      preceding bytecode to the first bytecode
- * \param precbc2      preceding bytecode to the second bytecode
- * \return Distance in bytes between the two bytecodes (bc2-bc1), or NULL if
- *        the distance was indeterminate.
- */
-typedef /*@null@*/ /*@only@*/ yasm_intnum * (*yasm_calc_bc_dist_func)
-    (yasm_bytecode *precbc1, yasm_bytecode *precbc2);
-
 /** Convert yasm_value to its byte representation.  Usually implemented by
  * object formats to keep track of relocations and verify legal expressions.
  * Must put the value into the least significant bits of the destination,
index a0f55693825db9b3e995eb0b3a11e1d7dd82ab5c..95522b372993475e6cd6b668c1abef293daebf38 100644 (file)
@@ -187,8 +187,7 @@ yasm_expr_reg(unsigned long reg)
  * possible.  Uses a simple n^2 algorithm because n is usually quite small.
  */
 static /*@only@*/ yasm_expr *
-expr_xform_bc_dist(/*@returned@*/ /*@only@*/ yasm_expr *e,
-                  yasm_calc_bc_dist_func calc_bc_dist)
+expr_xform_bc_dist(/*@returned@*/ /*@only@*/ yasm_expr *e)
 {
     int i;
     /*@dependent@*/ yasm_section *sect;
@@ -244,7 +243,7 @@ expr_xform_bc_dist(/*@returned@*/ /*@only@*/ yasm_expr *e,
                yasm_symrec_get_label(e->terms[j].data.sym, &precbc2) &&
                (sect = yasm_bc_get_section(precbc2)) &&
                sect == sect2 &&
-               (dist = calc_bc_dist(precbc, precbc2))) {
+               (dist = yasm_calc_bc_dist(precbc, precbc2))) {
                /* Change the symrec term to an integer */
                e->terms[j].type = YASM_EXPR_INT;
                e->terms[j].data.intn = dist;
@@ -731,7 +730,7 @@ typedef struct yasm__exprentry {
 /* Level an entire expn tree, expanding equ's as we go */
 yasm_expr *
 yasm_expr__level_tree(yasm_expr *e, int fold_const, int simplify_ident,
-                     int simplify_reg_mul, yasm_calc_bc_dist_func calc_bc_dist,
+                     int simplify_reg_mul, int calc_bc_dist,
                      yasm_expr_xform_func expr_xform_extra,
                      void *expr_xform_extra_data, yasm__exprhead *eh)
 {
@@ -838,11 +837,11 @@ yasm_expr__level_tree(yasm_expr *e, int fold_const, int simplify_ident,
     e = expr_level_op(e, fold_const, simplify_ident, simplify_reg_mul);
     if (calc_bc_dist || expr_xform_extra) {
        if (calc_bc_dist)
-           e = expr_xform_bc_dist(e, calc_bc_dist);
+           e = expr_xform_bc_dist(e);
        if (expr_xform_extra)
            e = expr_xform_extra(e, expr_xform_extra_data);
        e = yasm_expr__level_tree(e, fold_const, simplify_ident,
-                                 simplify_reg_mul, NULL, NULL, NULL, NULL);
+                                 simplify_reg_mul, 0, NULL, NULL, NULL);
     }
     return e;
 }
@@ -1132,7 +1131,7 @@ yasm_expr_extract_wrt(yasm_expr **ep)
 
 /*@-unqualifiedtrans -nullderef -nullstate -onlytrans@*/
 yasm_intnum *
-yasm_expr_get_intnum(yasm_expr **ep, yasm_calc_bc_dist_func calc_bc_dist)
+yasm_expr_get_intnum(yasm_expr **ep, int calc_bc_dist)
 {
     *ep = yasm_expr_simplify(*ep, calc_bc_dist);
 
@@ -1148,7 +1147,7 @@ const yasm_symrec *
 yasm_expr_get_symrec(yasm_expr **ep, int simplify)
 {
     if (simplify)
-       *ep = yasm_expr_simplify(*ep, NULL);
+       *ep = yasm_expr_simplify(*ep, 0);
 
     if ((*ep)->op == YASM_EXPR_IDENT &&
        ((*ep)->terms[0].type == YASM_EXPR_SYM ||
@@ -1164,7 +1163,7 @@ const unsigned long *
 yasm_expr_get_reg(yasm_expr **ep, int simplify)
 {
     if (simplify)
-       *ep = yasm_expr_simplify(*ep, NULL);
+       *ep = yasm_expr_simplify(*ep, 0);
 
     if ((*ep)->op == YASM_EXPR_IDENT && (*ep)->terms[0].type == YASM_EXPR_REG)
        return &((*ep)->terms[0].data.reg);
index 59b3b5ae8db8d5a7cdfb2330a7f02c7348ceecb4..801594eb40545e5c343ec84467e328e57a6fe73e 100644 (file)
@@ -148,7 +148,8 @@ SLIST_HEAD(yasm__exprhead, yasm__exprentry);
  * \param fold_const       enable constant folding if nonzero
  * \param simplify_ident    simplify identities
  * \param simplify_reg_mul  simplify REG*1 identities
- * \param calc_bc_dist     bytecode distance-calculation function
+ * \param calc_bc_dist     nonzero if distances between bytecodes should be
+ *                         calculated, 0 if they should be left intact
  * \param expr_xform_extra  extra transformation function
  * \param expr_xform_extra_data        data to pass to expr_xform_extra
  * \param eh               call with NULL (for internal use in recursion)
@@ -156,8 +157,7 @@ SLIST_HEAD(yasm__exprhead, yasm__exprentry);
  */
 /*@only@*/ /*@null@*/ yasm_expr *yasm_expr__level_tree
     (/*@returned@*/ /*@only@*/ /*@null@*/ yasm_expr *e, int fold_const,
-     int simplify_ident, int simplify_reg_mul,
-     /*@null@*/ yasm_calc_bc_dist_func calc_bc_dist,
+     int simplify_ident, int simplify_reg_mul, int calc_bc_dist,
      /*@null@*/ yasm_expr_xform_func expr_xform_extra,
      /*@null@*/ void *expr_xform_extra_data, /*@null@*/ yasm__exprhead *eh);
 
@@ -165,7 +165,7 @@ SLIST_HEAD(yasm__exprhead, yasm__exprentry);
  * branches and simplifies integer-only subexpressions.  Simplified version
  * of yasm_expr__level_tree().
  * \param e    expression
- * \param cbd  bytecode distance-calculation function
+ * \param cbd  if distance between bytecodes should be calculated
  * \return Simplified expression.
  */
 #define yasm_expr_simplify(e, cbd) \
@@ -192,13 +192,14 @@ SLIST_HEAD(yasm__exprhead, yasm__exprentry);
 
 /** Get the integer value of an expression if it's just an integer.
  * \param ep           expression (pointer to)
- * \param calc_bc_dist bytecode distance-calculation function
+ * \param calc_bc_dist nonzero if distances between bytecodes should be
+ *                     calculated, 0 if NULL should be returned in this case
  * \return NULL if the expression is too complex (contains anything other than
  *         integers, ie floats, non-valued labels, registers); otherwise the
  *         intnum value of the expression.
  */
 /*@dependent@*/ /*@null@*/ yasm_intnum *yasm_expr_get_intnum
-    (yasm_expr **ep, /*@null@*/ yasm_calc_bc_dist_func calc_bc_dist);
+    (yasm_expr **ep, int calc_bc_dist);
 
 /** Get the symbol value of an expression if it's just a symbol.
  * \param ep           expression (pointer to)
index 375d3a1327b378f0985b9047546914b2d7fb27aa..14d4d3556d38ce51b9bfcbc07adbd00418dc01b3 100644 (file)
@@ -416,7 +416,7 @@ yasm_value_finalize_expr(yasm_value *value, yasm_expr *e, unsigned int size)
     }
 
     yasm_value_initialize(value, yasm_expr__level_tree
-                         (e, 1, 1, 0, NULL, NULL, NULL, NULL), size);
+                         (e, 1, 1, 0, 0, NULL, NULL, NULL), size);
 
     /* quit early if there was an issue in simplify() */
     if (yasm_error_occurred())
@@ -457,7 +457,7 @@ yasm_value_finalize_expr(yasm_value *value, yasm_expr *e, unsigned int size)
     if (value_finalize_scan(value, value->abs, 0))
        return 1;
 
-    value->abs = yasm_expr__level_tree(value->abs, 1, 1, 0, NULL, NULL, NULL,
+    value->abs = yasm_expr__level_tree(value->abs, 1, 1, 0, 0, NULL, NULL,
                                       NULL);
 
     /* Simplify 0 in abs to NULL */
@@ -480,7 +480,7 @@ yasm_value_finalize(yasm_value *value)
 int
 yasm_value_output_basic(yasm_value *value, /*@out@*/ unsigned char *buf,
                        size_t destsize, yasm_bytecode *bc, int warn,
-                       yasm_arch *arch, yasm_calc_bc_dist_func calc_bc_dist)
+                       yasm_arch *arch)
 {
     /*@dependent@*/ /*@null@*/ yasm_intnum *intn = NULL;
     /*@only@*/ yasm_intnum *outval;
@@ -507,7 +507,7 @@ yasm_value_output_basic(yasm_value *value, /*@out@*/ unsigned char *buf,
        }
 
        /* Handle integer expressions */
-       intn = yasm_expr_get_intnum(&value->abs, calc_bc_dist);
+       intn = yasm_expr_get_intnum(&value->abs, 1);
        if (!intn) {
            yasm_error_set(YASM_ERROR_TOO_COMPLEX,
                           N_("expression too complex"));
index 6aef60117f3c7a5833b6497ea21b81c996418d3c..1cde996c0b60f0c3cfd31b81abb26dd8bd970221 100644 (file)
@@ -123,8 +123,7 @@ int yasm_value_finalize_expr(/*@out@*/ yasm_value *value,
  */
 int yasm_value_output_basic
     (yasm_value *value, /*@out@*/ unsigned char *buf, size_t destsize,
-     yasm_bytecode *bc, int warn, yasm_arch *arch,
-     yasm_calc_bc_dist_func calc_bc_dist);
+     yasm_bytecode *bc, int warn, yasm_arch *arch);
 
 /** Print a value.  For debugging purposes.
  * \param value                value
index 72b2b4da0694eec3b7760619930890d33a0ae288..0089b615abb94a99838036c1f4ca84605ec275c0 100644 (file)
@@ -130,7 +130,7 @@ x86_parse_directive(yasm_arch *arch, const char *name,
     if (yasm__strcasecmp(name, "bits") == 0) {
        if ((vp = yasm_vps_first(valparams)) && !vp->val &&
            vp->param != NULL &&
-           (intn = yasm_expr_get_intnum(&vp->param, NULL)) != NULL &&
+           (intn = yasm_expr_get_intnum(&vp->param, 0)) != NULL &&
            (lval = yasm_intnum_get_int(intn)) &&
            (lval == 16 || lval == 32 || lval == 64))
            arch_x86->mode_bits = (unsigned char)lval;
index d5bbfa1832de794e4bfd8ffcff4c084a9c5fdb69..6c56ac4b8d24fc4980d17350b257f7a13057e12b 100644 (file)
@@ -554,7 +554,7 @@ x86_bc_insn_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
        long val;
 
        if (imm->val.abs)
-           num = yasm_expr_get_intnum(&imm->val.abs, NULL);
+           num = yasm_expr_get_intnum(&imm->val.abs, 0);
 
        /* TODO: check imm->len vs. sized len from expr? */
 
index 01a1cb4587b39a808f20768d8b560d0591b1f0bb..8f62158c5ae8f7b1ce3835cbce1a738133c5dd91 100644 (file)
@@ -259,8 +259,7 @@ x86_expr_checkea_getregusage(yasm_expr **ep, /*@null@*/ int *indexreg,
     yasm_expr *e, *wrt;
 
     /*@-unqualifiedtrans@*/
-    *ep = yasm_expr__level_tree(*ep, 1, 1, indexreg == 0, NULL, NULL, NULL,
-                               NULL);
+    *ep = yasm_expr__level_tree(*ep, 1, 1, indexreg == 0, 0, NULL, NULL, NULL);
 
     /* Check for WRT rip first */
     wrt = yasm_expr_extract_wrt(ep);
@@ -295,7 +294,7 @@ x86_expr_checkea_getregusage(yasm_expr **ep, /*@null@*/ int *indexreg,
            return 1;
        case 2:
            /* Need to simplify again */
-           *ep = yasm_expr__level_tree(*ep, 1, 1, indexreg == 0, NULL, NULL,
+           *ep = yasm_expr__level_tree(*ep, 1, 1, indexreg == 0, 0, NULL,
                                        NULL, NULL);
            e = *ep;
            break;
@@ -386,7 +385,7 @@ x86_expr_checkea_getregusage(yasm_expr **ep, /*@null@*/ int *indexreg,
     /* Simplify expr, which is now really just the displacement. This
      * should get rid of the 0's we put in for registers in the callback.
      */
-    *ep = yasm_expr_simplify(*ep, NULL);
+    *ep = yasm_expr_simplify(*ep, 0);
     /* e = *ep; */
 
     return 0;
@@ -499,7 +498,7 @@ x86_checkea_calc_displen(x86_effaddr *x86_ea, unsigned int wordsize, int noreg,
         * equaling zero is probably a rare case, so we ignore it for now.
         */
        if (x86_ea->ea.disp.abs &&
-           !(intn = yasm_expr_get_intnum(&x86_ea->ea.disp.abs, NULL))) {
+           !(intn = yasm_expr_get_intnum(&x86_ea->ea.disp.abs, 0))) {
            /* expr still has unknown values: treat like BP/EBP above */
            x86_ea->ea.need_nonzero_len = 1;
            x86_ea->modrm |= 0100;
index f0245707de1d1aa929f38100eaa86db282876877..514cc28da2c7806af0da75f7e5267b05dbe04056 100644 (file)
@@ -2513,7 +2513,7 @@ yasm_x86__finalize_insn(yasm_arch *arch, yasm_bytecode *bc,
                case OPT_Imm1:
                    if (op->type == YASM_INSN__OPERAND_IMM) {
                        const yasm_intnum *num;
-                       num = yasm_expr_get_intnum(&op->data.val, NULL);
+                       num = yasm_expr_get_intnum(&op->data.val, 0);
                        if (!num || !yasm_intnum_is_pos1(num))
                            mismatch = 1;
                    } else
@@ -2918,8 +2918,7 @@ yasm_x86__finalize_insn(yasm_arch *arch, yasm_bytecode *bc,
             */
            if (!insn->imm->val.abs ||
                yasm_intnum_check_size(
-                   yasm_expr_get_intnum(&insn->imm->val.abs, NULL),
-                   32, 0, 1)) {
+                   yasm_expr_get_intnum(&insn->imm->val.abs, 0), 32, 0, 1)) {
                /* Throwaway REX byte */
                unsigned char rex_temp = 0;
 
index 78c1059a0998fe70a7a24192828c204d7e335e02..44e599732bc62b871bba50765cd90f7c3cb4c604 100644 (file)
@@ -753,7 +753,7 @@ cv8_symhead_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
 
     /* Total length of info (following this field) - 4 bytes */
     yasm_intnum_set_uint(cval, bc->len);
-    intn = yasm_common_calc_bc_dist(head->start_prevbc, head->end_prevbc);
+    intn = yasm_calc_bc_dist(head->start_prevbc, head->end_prevbc);
     yasm_intnum_calc(intn, YASM_EXPR_SUB, cval);
     yasm_arch_intnum_tobytes(dbgfmt_cv->arch, intn, buf, 4, 32, 0, bc, 0);
     buf += 4;
@@ -891,8 +891,8 @@ cv8_lineinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
     YASM_WRITE_8(buf, 0);
 
     /* Section length covered by line number info */
-    cval = yasm_common_calc_bc_dist(yasm_section_bcs_first(li->sect),
-                                   yasm_section_bcs_last(li->sect));
+    cval = yasm_calc_bc_dist(yasm_section_bcs_first(li->sect),
+                            yasm_section_bcs_last(li->sect));
     yasm_arch_intnum_tobytes(dbgfmt_cv->arch, cval, buf, 4, 32, 0, bc, 0);
     buf += 4;
 
index b8056fd638d8f9aa563759f39d0a76d1c9a54c6f..7ce855532cfd87537ab5de29be7d3b0cc9860ace 100644 (file)
@@ -71,8 +71,8 @@ dwarf2_generate_aranges_section(yasm_section *sect, /*@null@*/ void *d)
        yasm_expr_sym(yasm_dwarf2__bc_sym(dbgfmt_dwarf2->symtab,
                                          yasm_section_bcs_first(sect))), 0);
     length = yasm_expr_create_ident(
-       yasm_expr_int(yasm_common_calc_bc_dist(
-           yasm_section_bcs_first(sect), yasm_section_bcs_last(sect))), 0);
+       yasm_expr_int(yasm_calc_bc_dist(yasm_section_bcs_first(sect),
+                                       yasm_section_bcs_last(sect))), 0);
     dwarf2_append_arange(info->debug_aranges, start, length,
                         dbgfmt_dwarf2->sizeof_address);
 
index 54f10f4f8c6fed023609898ae59f20edcca9735d..c5f807fdc485785d06f9572aad397eb1e02aee3c 100644 (file)
@@ -274,7 +274,7 @@ dwarf2_head_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d,
 
     /* Total length of aranges info (following this field) */
     cval = yasm_intnum_create_uint(dbgfmt_dwarf2->sizeof_offset);
-    intn = yasm_common_calc_bc_dist(head->start_prevbc, head->end_prevbc);
+    intn = yasm_calc_bc_dist(head->start_prevbc, head->end_prevbc);
     yasm_intnum_calc(intn, YASM_EXPR_SUB, cval);
     yasm_arch_intnum_tobytes(dbgfmt_dwarf2->arch, intn, buf,
                             dbgfmt_dwarf2->sizeof_offset,
index 11ac620b764e824ffd1b73c356fe968ad0dbf9cf..99bef0f85477113c5a86c3ac85b813ee1a253cb9 100644 (file)
@@ -333,7 +333,7 @@ yasm_dwarf2__generate_info(yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2,
        abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_high_pc, DW_FORM_addr);
        dwarf2_append_expr(debug_info,
            yasm_expr_create(YASM_EXPR_ADD, yasm_expr_sym(first),
-               yasm_expr_int(yasm_common_calc_bc_dist(
+               yasm_expr_int(yasm_calc_bc_dist(
                    yasm_section_bcs_first(main_code),
                    yasm_section_bcs_last(main_code))), 0),
            dbgfmt_dwarf2->sizeof_address, 0);
index e4c35fdcafa80de53069ea7d28f3d9780409c6bf..85e860e5ff750d77fa83b9f703d657190eb8e0c7 100644 (file)
@@ -837,7 +837,7 @@ yasm_dwarf2__line_directive(yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2,
            yasm_xfree(loc);
            return 0;
        }
-       intn = yasm_expr_get_intnum(&vp->param, NULL);
+       intn = yasm_expr_get_intnum(&vp->param, 0);
        if (!intn) {
            yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                           N_("file number is not a constant"));
@@ -859,7 +859,7 @@ yasm_dwarf2__line_directive(yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2,
            yasm_xfree(loc);
            return 0;
        }
-       intn = yasm_expr_get_intnum(&vp->param, NULL);
+       intn = yasm_expr_get_intnum(&vp->param, 0);
        if (!intn) {
            yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                           N_("file number is not a constant"));
@@ -888,7 +888,7 @@ yasm_dwarf2__line_directive(yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2,
        /* Optional column number */
        vp = yasm_vps_next(vp);
        if (vp && vp->param) {
-           intn = yasm_expr_get_intnum(&vp->param, NULL);
+           intn = yasm_expr_get_intnum(&vp->param, 0);
            if (!intn) {
                yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                               N_("column number is not a constant"));
@@ -914,7 +914,7 @@ yasm_dwarf2__line_directive(yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2,
                    yasm_xfree(loc);
                    return 0;
                }
-               intn = yasm_expr_get_intnum(&vp->param, NULL);
+               intn = yasm_expr_get_intnum(&vp->param, 0);
                if (!intn) {
                    yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                                   N_("is_stmt value is not a constant"));
@@ -937,7 +937,7 @@ yasm_dwarf2__line_directive(yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2,
                    yasm_xfree(loc);
                    return 0;
                }
-               intn = yasm_expr_get_intnum(&vp->param, NULL);
+               intn = yasm_expr_get_intnum(&vp->param, 0);
                if (!intn) {
                    yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                                   N_("isa value is not a constant"));
@@ -977,7 +977,7 @@ yasm_dwarf2__line_directive(yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2,
        }
 
        /* Otherwise.. first vp is the file number */
-       file_intn = yasm_expr_get_intnum(&vp->param, NULL);
+       file_intn = yasm_expr_get_intnum(&vp->param, 0);
        if (!file_intn) {
            yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                           N_("file number is not a constant"));
index 0f19723474d2bb2502ce996df9cab0a68db5d56b..427ffa355f8238ea0baf4c982e4a0c1b7011c99c 100644 (file)
@@ -92,8 +92,8 @@ nasm_listfmt_output_value(yasm_value *value, unsigned char *buf,
     assert(info != NULL);
 
     /* Output */
-    switch (yasm_value_output_basic(value, buf, destsize, bc, warn, info->arch,
-                                   NULL)) {
+    switch (yasm_value_output_basic(value, buf, destsize, bc, warn,
+                                   info->arch)) {
        case -1:
            return 1;
        case 0:
@@ -121,7 +121,7 @@ nasm_listfmt_output_value(yasm_value *value, unsigned char *buf,
     }
 
     if (value->abs) {
-       intn = yasm_expr_get_intnum(&value->abs, NULL);
+       intn = yasm_expr_get_intnum(&value->abs, 0);
        if (intn)
            return yasm_arch_intnum_tobytes(info->arch, intn, buf, destsize,
                                            valsize, 0, bc, 0);
@@ -216,7 +216,7 @@ nasm_listfmt_output(yasm_listfmt *listfmt, FILE *f, yasm_linemap *linemap,
                 */
                bigbuf = yasm_bc_tobytes(bc, buf, &size, &gap, &info,
                                         nasm_listfmt_output_value, NULL);
-               yasm_bc_get_multiple(bc, &multiple, NULL);
+               yasm_bc_get_multiple(bc, &multiple, 1);
                size /= multiple;
 
                /* output bytes with reloc information */
index da84defdfd8088fa4efdb0677c3fcb1103fb9509..6e8954fd60c2406060ae04f4321b6201efac6735 100644 (file)
@@ -120,8 +120,7 @@ bin_objfmt_expr_xform(/*@returned@*/ /*@only@*/ yasm_expr *e,
             e->terms[i].type == YASM_EXPR_SYMEXP) &&
            yasm_symrec_get_label(e->terms[i].data.sym, &precbc) &&
            (sect = yasm_bc_get_section(precbc)) &&
-           (dist = yasm_common_calc_bc_dist(yasm_section_bcs_first(sect),
-                                            precbc))) {
+           (dist = yasm_calc_bc_dist(yasm_section_bcs_first(sect), precbc))) {
            const yasm_expr *start = yasm_section_get_start(sect);
            e->terms[i].type = YASM_EXPR_EXPR;
            e->terms[i].data.expn =
@@ -162,11 +161,11 @@ bin_objfmt_output_value(yasm_value *value, unsigned char *buf, size_t destsize,
     /* Simplify absolute portion of value, transforming symrecs */
     if (value->abs)
        value->abs = yasm_expr__level_tree
-           (value->abs, 1, 1, 1, NULL, bin_objfmt_expr_xform, NULL, NULL);
+           (value->abs, 1, 1, 1, 0, bin_objfmt_expr_xform, NULL, NULL);
 
     /* Output */
     switch (yasm_value_output_basic(value, buf, destsize, bc, warn,
-                                   info->objfmt_bin->arch, NULL)) {
+                                   info->objfmt_bin->arch)) {
        case -1:
            return 1;
        case 0:
@@ -261,7 +260,7 @@ bin_objfmt_output(yasm_objfmt *objfmt, FILE *f, /*@unused@*/ int all_syms,
     /* Find out the start of .text */
     startexpr = yasm_expr_copy(yasm_section_get_start(text));
     assert(startexpr != NULL);
-    startnum = yasm_expr_get_intnum(&startexpr, NULL);
+    startnum = yasm_expr_get_intnum(&startexpr, 0);
     if (!startnum) {
        yasm_error_set(YASM_ERROR_TOO_COMPLEX,
                       N_("ORG expression too complex"));
@@ -404,7 +403,7 @@ bin_objfmt_section_switch(yasm_objfmt *objfmt, yasm_valparamhead *valparams,
                    return NULL;
                }
                
-               align_expr = yasm_expr_get_intnum(&vp->param, NULL);
+               align_expr = yasm_expr_get_intnum(&vp->param, 0);
                if (!align_expr) {
                    yasm_error_set(YASM_ERROR_VALUE,
                                N_("argument to `%s' is not a power of two"),
index 6a3a995756274cd46aca2f7304cf6595286f3f3f..1a328ab01cde538f44a6c36d73da76186bbe89c4 100644 (file)
@@ -441,15 +441,14 @@ coff_objfmt_output_value(yasm_value *value, unsigned char *buf, size_t destsize,
     objfmt_coff = info->objfmt_coff;
 
     if (value->abs)
-       value->abs = yasm_expr_simplify(value->abs, yasm_common_calc_bc_dist);
+       value->abs = yasm_expr_simplify(value->abs, 1);
 
     /* Try to output constant and PC-relative section-local first.
      * Note this does NOT output any value with a SEG, WRT, external,
      * cross-section, or non-PC-relative reference (those are handled below).
      */
     switch (yasm_value_output_basic(value, buf, destsize, bc, warn,
-                                   info->objfmt_coff->arch,
-                                   yasm_common_calc_bc_dist)) {
+                                   info->objfmt_coff->arch)) {
        case -1:
            return 1;
        case 0:
@@ -488,7 +487,7 @@ coff_objfmt_output_value(yasm_value *value, unsigned char *buf, size_t destsize,
                               N_("coff: wrt expression too complex"));
                return 1;
            }
-           dist = yasm_common_calc_bc_dist(wrt_precbc, rel_precbc);
+           dist = yasm_calc_bc_dist(wrt_precbc, rel_precbc);
            if (!dist) {
                yasm_error_set(YASM_ERROR_TOO_COMPLEX,
                               N_("coff: cannot wrt across sections"));
@@ -505,8 +504,7 @@ coff_objfmt_output_value(yasm_value *value, unsigned char *buf, size_t destsize,
 
                csymd = yasm_symrec_get_data(sym, &coff_symrec_data_cb);
                assert(csymd != NULL);
-               common_size = yasm_expr_get_intnum(&csymd->size,
-                                                  yasm_common_calc_bc_dist);
+               common_size = yasm_expr_get_intnum(&csymd->size, 1);
                if (!common_size) {
                    yasm_error_set(YASM_ERROR_TOO_COMPLEX,
                                   N_("coff: common size too complex"));
@@ -663,7 +661,7 @@ coff_objfmt_output_value(yasm_value *value, unsigned char *buf, size_t destsize,
     }
 
     if (value->abs) {
-       yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, NULL);
+       yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0);
        if (!intn2) {
            yasm_error_set(YASM_ERROR_TOO_COMPLEX,
                           N_("coff: relocation too complex"));
@@ -1010,8 +1008,7 @@ coff_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d)
                    yasm_expr *abs_start;
 
                    abs_start = yasm_expr_copy(yasm_section_get_start(sect));
-                   intn = yasm_expr_get_intnum(&abs_start,
-                                               yasm_common_calc_bc_dist);
+                   intn = yasm_expr_get_intnum(&abs_start, 1);
                    if (!intn) {
                        yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                            N_("absolute section start not an integer expression"));
@@ -1029,8 +1026,7 @@ coff_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d)
            }
        } else if ((equ_val = yasm_symrec_get_equ(sym))) {
            yasm_expr *equ_val_copy = yasm_expr_copy(equ_val);
-           intn = yasm_expr_get_intnum(&equ_val_copy,
-                                       yasm_common_calc_bc_dist);
+           intn = yasm_expr_get_intnum(&equ_val_copy, 1);
            if (!intn) {
                if (vis & YASM_SYM_GLOBAL) {
                    yasm_error_set(YASM_ERROR_NOT_CONSTANT,
@@ -1044,8 +1040,7 @@ coff_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d)
            scnum = 0xffff;     /* -1 = absolute symbol */
        } else {
            if (vis & YASM_SYM_COMMON) {
-               intn = yasm_expr_get_intnum(&csymd->size,
-                                           yasm_common_calc_bc_dist);
+               intn = yasm_expr_get_intnum(&csymd->size, 1);
                if (!intn) {
                    yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                        N_("COMMON data size not an integer expression"));
@@ -1524,7 +1519,7 @@ coff_objfmt_section_switch(yasm_objfmt *objfmt, yasm_valparamhead *valparams,
        } else if (yasm__strcasecmp(vp->val, "align") == 0 && vp->param) {
            if (objfmt_coff->win32) {
                /*@dependent@*/ /*@null@*/ const yasm_intnum *align_expr;
-               align_expr = yasm_expr_get_intnum(&vp->param, NULL);
+               align_expr = yasm_expr_get_intnum(&vp->param, 0);
                if (!align_expr) {
                    yasm_error_set(YASM_ERROR_VALUE,
                                   N_("argument to `%s' is not a power of two"),
index 2beeffbf2b65c2800a8b30529a36c07be30054d6..4f08ec9221fea90ccbb3c440c3518d9ade889e00 100644 (file)
@@ -307,15 +307,14 @@ elf_objfmt_output_value(yasm_value *value, unsigned char *buf, size_t destsize,
        yasm_internal_error("null info struct");
 
     if (value->abs)
-       value->abs = yasm_expr_simplify(value->abs, yasm_common_calc_bc_dist);
+       value->abs = yasm_expr_simplify(value->abs, 1);
 
     /* Try to output constant and PC-relative section-local first.
      * Note this does NOT output any value with a SEG, WRT, external,
      * cross-section, or non-PC-relative reference (those are handled below).
      */
     switch (yasm_value_output_basic(value, buf, destsize, bc, warn,
-                                   info->objfmt_elf->arch,
-                                   yasm_common_calc_bc_dist)) {
+                                   info->objfmt_elf->arch)) {
        case -1:
            return 1;
        case 0:
@@ -381,7 +380,7 @@ elf_objfmt_output_value(yasm_value *value, unsigned char *buf, size_t destsize,
     intn = yasm_intnum_create_uint(intn_val);
 
     if (value->abs) {
-       yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, NULL);
+       yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0);
        if (!intn2) {
            yasm_error_set(YASM_ERROR_TOO_COMPLEX,
                           N_("elf: relocation too complex"));
@@ -913,7 +912,7 @@ elf_objfmt_section_switch(yasm_objfmt *objfmt, yasm_valparamhead *valparams,
        else if (yasm__strcasecmp(vp->val, "align") == 0 && vp->param) {
             /*@dependent@*/ /*@null@*/ const yasm_intnum *align_expr;
 
-            align_expr = yasm_expr_get_intnum(&vp->param, NULL);
+            align_expr = yasm_expr_get_intnum(&vp->param, 0);
             if (!align_expr) {
                 yasm_error_set(YASM_ERROR_VALUE,
                               N_("argument to `%s' is not a power of two"),
@@ -938,7 +937,7 @@ elf_objfmt_section_switch(yasm_objfmt *objfmt, yasm_valparamhead *valparams,
            if (objext_valparams && (vp = yasm_vps_first(objext_valparams))
                && vp->param) {
 
-               merge_intn = yasm_expr_get_intnum(&vp->param, NULL);
+               merge_intn = yasm_expr_get_intnum(&vp->param, 0);
                if (!merge_intn)
                    yasm_warn_set(YASM_WARN_GENERAL,
                                  N_("invalid merge entity size"));
@@ -1071,7 +1070,7 @@ elf_objfmt_common_declare(yasm_objfmt *objfmt, const char *name,
             if (!vp->val && vp->param) {
                 /*@dependent@*/ /*@null@*/ const yasm_intnum *align_expr;
 
-                align_expr = yasm_expr_get_intnum(&vp->param, NULL);
+                align_expr = yasm_expr_get_intnum(&vp->param, 0);
                 if (!align_expr) {
                     yasm_error_set(YASM_ERROR_VALUE,
                        N_("alignment constraint is not a power of two"));
index f2426c016fd18b32f9535b61f2054af783c4664c..ce1e9dcbcb79196504b0875279255d2ddc708e02 100644 (file)
@@ -441,7 +441,7 @@ elf_symtab_write_to_file(FILE *f, elf_symtab_head *symtab,
        /* get size (if specified); expr overrides stored integer */
        if (entry->xsize) {
            size_intn = yasm_intnum_copy(
-               yasm_expr_get_intnum(&entry->xsize, yasm_common_calc_bc_dist));
+               yasm_expr_get_intnum(&entry->xsize, 1));
            if (!size_intn) {
                yasm_error_set(YASM_ERROR_VALUE,
                               N_("size specifier not an integer expression"));
@@ -459,8 +459,7 @@ elf_symtab_write_to_file(FILE *f, elf_symtab_head *symtab,
            if (equ_expr_c != NULL) {
                const yasm_intnum *equ_intn;
                yasm_expr *equ_expr = yasm_expr_copy(equ_expr_c);
-               equ_intn = yasm_expr_get_intnum(&equ_expr,
-                                               yasm_common_calc_bc_dist);
+               equ_intn = yasm_expr_get_intnum(&equ_expr, 1);
 
                if (equ_intn == NULL) {
                    yasm_error_set(YASM_ERROR_VALUE,
index 56fe213cb8fbfbf29338ff6364f64a097d61bcdb..543c9d09dd95c20ab07d65c4cb75655d11d069da 100644 (file)
@@ -173,15 +173,14 @@ xdf_objfmt_output_value(yasm_value *value, unsigned char *buf, size_t destsize,
     objfmt_xdf = info->objfmt_xdf;
 
     if (value->abs)
-       value->abs = yasm_expr_simplify(value->abs, yasm_common_calc_bc_dist);
+       value->abs = yasm_expr_simplify(value->abs, 1);
 
     /* Try to output constant and PC-relative section-local first.
      * Note this does NOT output any value with a SEG, WRT, external,
      * cross-section, or non-PC-relative reference (those are handled below).
      */
     switch (yasm_value_output_basic(value, buf, destsize, bc, warn,
-                                   info->objfmt_xdf->arch,
-                                   yasm_common_calc_bc_dist)) {
+                                   info->objfmt_xdf->arch)) {
        case -1:
            return 1;
        case 0:
@@ -231,7 +230,7 @@ xdf_objfmt_output_value(yasm_value *value, unsigned char *buf, size_t destsize,
        intn = yasm_intnum_create_uint(0);
 
     if (value->abs) {
-       yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, NULL);
+       yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0);
        if (!intn2) {
            yasm_error_set(YASM_ERROR_TOO_COMPLEX,
                           N_("xdf: relocation too complex"));
@@ -500,8 +499,7 @@ xdf_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d)
                    yasm_expr *abs_start;
 
                    abs_start = yasm_expr_copy(yasm_section_get_start(sect));
-                   intn = yasm_expr_get_intnum(&abs_start,
-                                               yasm_common_calc_bc_dist);
+                   intn = yasm_expr_get_intnum(&abs_start, 1);
                    if (!intn) {
                        yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                            N_("absolute section start not an integer expression"));
@@ -519,8 +517,7 @@ xdf_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d)
            }
        } else if ((equ_val = yasm_symrec_get_equ(sym))) {
            yasm_expr *equ_val_copy = yasm_expr_copy(equ_val);
-           intn = yasm_expr_get_intnum(&equ_val_copy,
-                                       yasm_common_calc_bc_dist);
+           intn = yasm_expr_get_intnum(&equ_val_copy, 1);
            if (!intn) {
                if (vis & YASM_SYM_GLOBAL) {
                    yasm_error_set(YASM_ERROR_NOT_CONSTANT,
@@ -727,7 +724,7 @@ xdf_objfmt_section_switch(yasm_objfmt *objfmt, yasm_valparamhead *valparams,
            flags |= XDF_SECT_FLAT;
        } else if (yasm__strcasecmp(vp->val, "absolute") == 0 && vp->param) {
            flags |= XDF_SECT_ABSOLUTE;
-           absaddr = yasm_expr_get_intnum(&vp->param, NULL);
+           absaddr = yasm_expr_get_intnum(&vp->param, 0);
            if (!absaddr) {
                yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                               N_("argument to `%s' is not an integer"),
@@ -735,7 +732,7 @@ xdf_objfmt_section_switch(yasm_objfmt *objfmt, yasm_valparamhead *valparams,
                return NULL;
            }
        } else if (yasm__strcasecmp(vp->val, "virtual") == 0 && vp->param) {
-           vaddr = yasm_expr_get_intnum(&vp->param, NULL);
+           vaddr = yasm_expr_get_intnum(&vp->param, 0);
            if (!vaddr) {
                yasm_error_set(YASM_ERROR_NOT_CONSTANT,
                               N_("argument to `%s' is not an integer"),
@@ -745,7 +742,7 @@ xdf_objfmt_section_switch(yasm_objfmt *objfmt, yasm_valparamhead *valparams,
        } else if (yasm__strcasecmp(vp->val, "align") == 0 && vp->param) {
            /*@dependent@*/ /*@null@*/ const yasm_intnum *align_expr;
 
-           align_expr = yasm_expr_get_intnum(&vp->param, NULL);
+           align_expr = yasm_expr_get_intnum(&vp->param, 0);
            if (!align_expr) {
                yasm_error_set(YASM_ERROR_VALUE,
                               N_("argument to `%s' is not a power of two"),
index 0eba1c8ff48ac3cd1ea0e3da77bfcc25d58fb770..209b371271193323d5d63a58065a40a45fad9be6 100644 (file)
@@ -200,7 +200,7 @@ lineexp: instr
     }
     /* Macro directives */
     | DIR_REPT expr {
-       yasm_intnum *intn = yasm_expr_get_intnum(&$2, NULL);
+       yasm_intnum *intn = yasm_expr_get_intnum(&$2, 0);
 
        $$ = (yasm_bytecode *)NULL;
        if (!intn) {
@@ -932,7 +932,7 @@ gas_parser_align(yasm_parser_gas *parser_gas, yasm_section *sect,
                                    yasm_expr_expr(boundval), cur_line);
 
     /* Largest .align in the section specifies section alignment. */
-    boundintn = yasm_expr_get_intnum(&boundval, NULL);
+    boundintn = yasm_expr_get_intnum(&boundval, 0);
     if (boundintn) {
        unsigned long boundint = yasm_intnum_get_uint(boundintn);
 
@@ -995,7 +995,7 @@ gas_parser_dir_fill(yasm_parser_gas *parser_gas, /*@only@*/ yasm_expr *repeat,
 
     if (size) {
        /*@dependent@*/ /*@null@*/ yasm_intnum *intn;
-       intn = yasm_expr_get_intnum(&size, NULL);
+       intn = yasm_expr_get_intnum(&size, 0);
        if (!intn) {
            yasm_error_set(YASM_ERROR_NOT_ABSOLUTE,
                           N_("size must be an absolute expression"));
index ab5c0b67e7390f4a581204e8b241b435bfb59388..c477e245176498730c34a0fa22f98b7c3e445c5c 100644 (file)
@@ -621,7 +621,7 @@ nasm_parser_directive(yasm_parser_nasm *parser_nasm, const char *name,
         * Note: this doesn't match NASM behavior, but is a lot more
         * intelligent!
         */
-       boundintn = yasm_expr_get_intnum(&boundval, NULL);
+       boundintn = yasm_expr_get_intnum(&boundval, 0);
        if (boundintn) {
            unsigned long boundint = yasm_intnum_get_uint(boundintn);
 
@@ -649,7 +649,7 @@ nasm_parser_directive(yasm_parser_nasm *parser_nasm, const char *name,
                                    strlen(vp->val));
            else if (vp->param) {
                const yasm_intnum *intcpu;
-               intcpu = yasm_expr_get_intnum(&vp->param, NULL);
+               intcpu = yasm_expr_get_intnum(&vp->param, 0);
                if (!intcpu)
                    yasm_error_set(YASM_ERROR_SYNTAX,
                                   N_("invalid argument to [%s]"), "CPU");
index 81548d6fabbb6f9f060f80898797b605dfd9ab2e..823b4bc29c47b618cb7d16f909542d59093650bd 100644 (file)
@@ -1709,7 +1709,7 @@ if_condition(Token * tline, int i)
            if (tokval.t_type)
                error(ERR_WARNING,
                        "trailing garbage after expression ignored");
-           intn = yasm_expr_get_intnum(&evalresult, NULL);
+           intn = yasm_expr_get_intnum(&evalresult, 0);
            if (!intn)
            {
                error(ERR_NONFATAL,
@@ -2468,7 +2468,7 @@ do_directive(Token * tline)
            if (tokval.t_type)
                error(ERR_WARNING,
                        "trailing garbage after expression ignored");
-           intn = yasm_expr_get_intnum(&evalresult, NULL);
+           intn = yasm_expr_get_intnum(&evalresult, 0);
            if (!intn)
            {
                error(ERR_NONFATAL, "non-constant value given to `%%rotate'");
@@ -2529,7 +2529,7 @@ do_directive(Token * tline)
                if (tokval.t_type)
                    error(ERR_WARNING,
                          "trailing garbage after expression ignored");
-               intn = yasm_expr_get_intnum(&evalresult, NULL);
+               intn = yasm_expr_get_intnum(&evalresult, 0);
                if (!intn)
                {
                    error(ERR_NONFATAL, "non-constant value given to `%%rep'");
@@ -2924,7 +2924,7 @@ do_directive(Token * tline)
                free_tlist(origline);
                return DIRECTIVE_FOUND;
            }
-           intn = yasm_expr_get_intnum(&evalresult, NULL);
+           intn = yasm_expr_get_intnum(&evalresult, 0);
            if (!intn)
            {
                error(ERR_NONFATAL, "non-constant value given to `%%substr`");
@@ -3028,7 +3028,7 @@ do_directive(Token * tline)
                error(ERR_WARNING,
                        "trailing garbage after expression ignored");
 
-           intn = yasm_expr_get_intnum(&evalresult, NULL);
+           intn = yasm_expr_get_intnum(&evalresult, 0);
            if (!intn)
            {
                error(ERR_NONFATAL,
index 1c3e5ab4983d14a77929cab78f10c99a69693153..a3f495947a2ca5af92d2a017683f10068589adf7 100644 (file)
@@ -91,16 +91,21 @@ cdef extern from "libyasm/bytecode.h":
     cdef void yasm_bc_destroy(yasm_bytecode *bc)
     cdef void yasm_bc_print(yasm_bytecode *bc, FILE *f, int indent_level)
     cdef void yasm_bc_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc)
-    cdef yasm_intnum *yasm_common_calc_bc_dist(yasm_bytecode *precbc1,
+    cdef yasm_intnum *yasm_calc_bc_dist(yasm_bytecode *precbc1,
             yasm_bytecode *precbc2)
-    cdef yasm_bc_resolve_flags yasm_bc_resolve(yasm_bytecode *bc, int save,
-            yasm_calc_bc_dist_func calc_bc_dist)
+    ctypedef void (*yasm_bc_add_span_func) (void *add_span_data,
+            yasm_bytecode *bc, int id, yasm_value *value,
+            yasm_bytecode *origin_prevbc, long neg_thres, long pos_thres)
+    cdef int yasm_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
+                              void *add_span_data)
+    cdef int yasm_bc_expand(yasm_bytecode *bc, int span, long old_val,
+                            long new_val, long *neg_thres, long *pos_thres)
     cdef unsigned char* yasm_bc_tobytes(yasm_bytecode *bc,
             unsigned char *buf, unsigned long *bufsize, int *gap, void *d,
             yasm_output_value_func output_value,
             yasm_output_reloc_func output_reloc)
     cdef int yasm_bc_get_multiple(yasm_bytecode *bc, unsigned long *multiple,
-                                  yasm_calc_bc_dist_func calc_bc_dist)
+                                  int calc_bc_dist)
 
     cdef yasm_dataval* yasm_dv_create_expr(yasm_expr *expn)
     cdef yasm_dataval* yasm_dv_create_string(char *contents, size_t len)
@@ -117,8 +122,10 @@ cdef extern from "libyasm/bc-int.h":
         void (*destroy) (void *contents)
         void (*c_print "print") (void *contents, FILE *f, int indent_level)
         void (*finalize) (yasm_bytecode *bc, yasm_bytecode *prev_bc)
-        yasm_bc_resolve_flags (*resolve) (yasm_bytecode *bc, int save,
-                                          yasm_calc_bc_dist_func calc_bc_dist)
+        int (*calc_len) (yasm_bytecode *bc, yasm_bc_add_span_func add_span,
+                        void *add_span_data)
+        int (*expand) (yasm_bytecode *bc, int span, long old_val, long new_val,
+                      long *neg_thres, long *pos_thres)
         int (*tobytes) (yasm_bytecode *bc, unsigned char **bufp, void *d,
                        yasm_output_value_func output_value,
                        yasm_output_reloc_func output_reloc)
index c0aabcad6c931e82d4c2650d5e6199f6300222ca..6146b908be014b810492d942b921069420cb454e 100644 (file)
@@ -113,8 +113,6 @@ cdef extern from "libyasm/coretype.h":
         YASM_SYM_EXTERN
         YASM_SYM_DLOCAL
 
-    ctypedef yasm_intnum*(*yasm_calc_bc_dist_func)(yasm_bytecode *precbc1,
-            yasm_bytecode *precbc2)
     ctypedef int*(*yasm_output_value_func)(yasm_value *value, unsigned char
             *buf, size_t destsize, unsigned long offset, yasm_bytecode *bc,
             int warn, void *d)
index 64b132d68b28406f22f4ca31b7cbc60b73a2f633..a33ce6874ec96ce5c538c55989488c0092a83243 100644 (file)
@@ -45,15 +45,13 @@ cdef extern from "libyasm/expr.h":
 
     cdef struct yasm__exprhead
     cdef yasm_expr *yasm_expr__level_tree(yasm_expr *e, int fold_const,
-            int simplify_ident, int simplify_reg_mul,
-            yasm_calc_bc_dist_func calc_bc_dist,
+            int simplify_ident, int simplify_reg_mul, int calc_bc_dist,
             yasm_expr_xform_func expr_xform_extra,
             void *expr_xform_extra_data, yasm__exprhead *eh, int *error)
-    cdef yasm_expr *yasm_expr_simplify(yasm_expr *e, yasm_calc_bc_dist_func cbd)
+    cdef yasm_expr *yasm_expr_simplify(yasm_expr *e, int calc_bc_dist)
     cdef yasm_expr *yasm_expr_extract_segoff(yasm_expr **ep)
     cdef yasm_expr *yasm_expr_extract_wrt(yasm_expr **ep)
-    cdef yasm_intnum *yasm_expr_get_intnum(yasm_expr **ep,
-            yasm_calc_bc_dist_func calc_bc_dist)
+    cdef yasm_intnum *yasm_expr_get_intnum(yasm_expr **ep, int calc_bc_dist)
     cdef yasm_symrec *yasm_expr_get_symrec(yasm_expr **ep, int simplify)
     cdef unsigned long *yasm_expr_get_reg(yasm_expr **ep, int simplify)
     cdef void yasm_expr_print(yasm_expr *e, FILE *f)
@@ -179,8 +177,8 @@ cdef class Expression:
     def __dealloc__(self):
         if self.expr != NULL: yasm_expr_destroy(self.expr)
 
-    def simplify(self):
-        self.expr = yasm_expr_simplify(self.expr, NULL) # TODO: cbd
+    def simplify(self, calc_bc_dist=False):
+        self.expr = yasm_expr_simplify(self.expr, calc_bc_dist)
 
     def extract_segoff(self):
         cdef yasm_expr *retval
@@ -196,9 +194,9 @@ cdef class Expression:
             raise ValueError("not a WRT expression")
         return __make_expression(retval)
 
-    def get_intnum(self):
+    def get_intnum(self, calc_bc_dist=False):
         cdef yasm_intnum *retval
-        retval = yasm_expr_get_intnum(&self.expr, NULL) # TODO: cbd
+        retval = yasm_expr_get_intnum(&self.expr, calc_bc_dist)
         if retval == NULL:
             raise ValueError("not an intnum expression")
         return __make_intnum(yasm_intnum_copy(retval))
index 81b1f2dfa2928161dd5303eb971a611b5bb75a8b..11fe0d847b9efe414a3d520d55e0d55b43157631 100644 (file)
@@ -33,8 +33,7 @@ cdef extern from "libyasm/value.h":
     cdef int yasm_value_finalize_expr(yasm_value *value, yasm_expr *e,
                                       unsigned int size)
     cdef int yasm_value_output_basic(yasm_value *value, unsigned char *buf,
-            size_t destsize, yasm_bytecode *bc, int warn, yasm_arch *arch,
-            yasm_calc_bc_dist_func calc_bc_dist)
+            size_t destsize, yasm_bytecode *bc, int warn, yasm_arch *arch)
     cdef void yasm_value_print(yasm_value *value, FILE *f, int indent_level)
 
 cdef class Value: