mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-10-10 00:25:06 -04:00
Remove additional function pointers that never change
Remove additional cached function pointers which point to static variables which are never actually changed. Just refer to the global variable instead. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
22
eval.c
22
eval.c
@@ -1,6 +1,6 @@
|
|||||||
/* ----------------------------------------------------------------------- *
|
/* ----------------------------------------------------------------------- *
|
||||||
*
|
*
|
||||||
* Copyright 1996-2012 The NASM Authors - All Rights Reserved
|
* Copyright 1996-2016 The NASM Authors - All Rights Reserved
|
||||||
* See the file AUTHORS included with the NASM distribution for
|
* See the file AUTHORS included with the NASM distribution for
|
||||||
* the specific copyright holders.
|
* the specific copyright holders.
|
||||||
*
|
*
|
||||||
@@ -54,7 +54,6 @@
|
|||||||
#define TEMPEXPR_DELTA 8
|
#define TEMPEXPR_DELTA 8
|
||||||
|
|
||||||
static scanner scan; /* Address of scanner routine */
|
static scanner scan; /* Address of scanner routine */
|
||||||
static lfunc labelfunc; /* Address of label routine */
|
|
||||||
|
|
||||||
static expr **tempexprs = NULL;
|
static expr **tempexprs = NULL;
|
||||||
static int ntempexprs;
|
static int ntempexprs;
|
||||||
@@ -68,7 +67,6 @@ static struct tokenval *tokval; /* The current token */
|
|||||||
static int i; /* The t_type of tokval */
|
static int i; /* The t_type of tokval */
|
||||||
|
|
||||||
static void *scpriv;
|
static void *scpriv;
|
||||||
static struct location *location; /* Pointer to current line's segment,offset */
|
|
||||||
static int *opflags;
|
static int *opflags;
|
||||||
|
|
||||||
static struct eval_hints *hint;
|
static struct eval_hints *hint;
|
||||||
@@ -890,11 +888,11 @@ static expr *expr6(int critical)
|
|||||||
case TOKEN_HERE:
|
case TOKEN_HERE:
|
||||||
case TOKEN_BASE:
|
case TOKEN_BASE:
|
||||||
/*
|
/*
|
||||||
* If !location->known, this indicates that no
|
* If !location.known, this indicates that no
|
||||||
* symbol, Here or Base references are valid because we
|
* symbol, Here or Base references are valid because we
|
||||||
* are in preprocess-only mode.
|
* are in preprocess-only mode.
|
||||||
*/
|
*/
|
||||||
if (!location->known) {
|
if (!location.known) {
|
||||||
nasm_error(ERR_NONFATAL,
|
nasm_error(ERR_NONFATAL,
|
||||||
"%s not supported in preprocess-only mode",
|
"%s not supported in preprocess-only mode",
|
||||||
(i == TOKEN_HERE ? "`$'" :
|
(i == TOKEN_HERE ? "`$'" :
|
||||||
@@ -906,13 +904,13 @@ static expr *expr6(int critical)
|
|||||||
|
|
||||||
type = EXPR_SIMPLE; /* might get overridden by UNKNOWN */
|
type = EXPR_SIMPLE; /* might get overridden by UNKNOWN */
|
||||||
if (i == TOKEN_BASE) {
|
if (i == TOKEN_BASE) {
|
||||||
label_seg = in_abs_seg ? abs_seg : location->segment;
|
label_seg = in_abs_seg ? abs_seg : location.segment;
|
||||||
label_ofs = 0;
|
label_ofs = 0;
|
||||||
} else if (i == TOKEN_HERE) {
|
} else if (i == TOKEN_HERE) {
|
||||||
label_seg = in_abs_seg ? abs_seg : location->segment;
|
label_seg = in_abs_seg ? abs_seg : location.segment;
|
||||||
label_ofs = in_abs_seg ? abs_offset : location->offset;
|
label_ofs = in_abs_seg ? abs_offset : location.offset;
|
||||||
} else {
|
} else {
|
||||||
if (!labelfunc(tokval->t_charptr, &label_seg, &label_ofs)) {
|
if (!lookup_label(tokval->t_charptr, &label_seg, &label_ofs)) {
|
||||||
scope = local_scope(tokval->t_charptr);
|
scope = local_scope(tokval->t_charptr);
|
||||||
if (critical == 2) {
|
if (critical == 2) {
|
||||||
nasm_error(ERR_NONFATAL, "symbol `%s%s' undefined",
|
nasm_error(ERR_NONFATAL, "symbol `%s%s' undefined",
|
||||||
@@ -951,12 +949,6 @@ static expr *expr6(int critical)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void eval_global_info(lfunc lookup_label, struct location * locp)
|
|
||||||
{
|
|
||||||
labelfunc = lookup_label;
|
|
||||||
location = locp;
|
|
||||||
}
|
|
||||||
|
|
||||||
expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv,
|
expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv,
|
||||||
int *fwref, int critical, struct eval_hints *hints)
|
int *fwref, int critical, struct eval_hints *hints)
|
||||||
{
|
{
|
||||||
|
|||||||
7
eval.h
7
eval.h
@@ -38,13 +38,6 @@
|
|||||||
#ifndef NASM_EVAL_H
|
#ifndef NASM_EVAL_H
|
||||||
#define NASM_EVAL_H
|
#define NASM_EVAL_H
|
||||||
|
|
||||||
/*
|
|
||||||
* Called once to tell the evaluator what output format is
|
|
||||||
* providing segment-base details, and what function can be used to
|
|
||||||
* look labels up.
|
|
||||||
*/
|
|
||||||
void eval_global_info(lfunc lookup_label, struct location * locp);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The evaluator itself.
|
* The evaluator itself.
|
||||||
*/
|
*/
|
||||||
|
|||||||
4
nasm.c
4
nasm.c
@@ -116,7 +116,7 @@ int64_t global_offset_changed; /* referenced in labels.c */
|
|||||||
int64_t prev_offset_changed;
|
int64_t prev_offset_changed;
|
||||||
int32_t stall_count;
|
int32_t stall_count;
|
||||||
|
|
||||||
static struct location location;
|
struct location location;
|
||||||
int in_abs_seg; /* Flag we are in ABSOLUTE seg */
|
int in_abs_seg; /* Flag we are in ABSOLUTE seg */
|
||||||
int32_t abs_seg; /* ABSOLUTE segment basis */
|
int32_t abs_seg; /* ABSOLUTE segment basis */
|
||||||
int32_t abs_offset; /* ABSOLUTE offset */
|
int32_t abs_offset; /* ABSOLUTE offset */
|
||||||
@@ -364,8 +364,6 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (ofmt->stdmac)
|
if (ofmt->stdmac)
|
||||||
preproc->extra_stdmac(ofmt->stdmac);
|
preproc->extra_stdmac(ofmt->stdmac);
|
||||||
parser_global_info(&location);
|
|
||||||
eval_global_info(ofmt, lookup_label, &location);
|
|
||||||
|
|
||||||
/* define some macros dependent of command-line */
|
/* define some macros dependent of command-line */
|
||||||
define_macros_late();
|
define_macros_late();
|
||||||
|
|||||||
1
nasm.h
1
nasm.h
@@ -220,6 +220,7 @@ struct location {
|
|||||||
int32_t segment;
|
int32_t segment;
|
||||||
int known;
|
int known;
|
||||||
};
|
};
|
||||||
|
extern struct location location;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Expression-evaluator datatype. Expressions, within the
|
* Expression-evaluator datatype. Expressions, within the
|
||||||
|
|||||||
12
parser.c
12
parser.c
@@ -61,12 +61,6 @@ static int is_comma_next(void);
|
|||||||
|
|
||||||
static int i;
|
static int i;
|
||||||
static struct tokenval tokval;
|
static struct tokenval tokval;
|
||||||
static struct location *location; /* Pointer to current line's segment,offset */
|
|
||||||
|
|
||||||
void parser_global_info(struct location * locp)
|
|
||||||
{
|
|
||||||
location = locp;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int prefix_slot(int prefix)
|
static int prefix_slot(int prefix)
|
||||||
{
|
{
|
||||||
@@ -431,14 +425,14 @@ restart_parse:
|
|||||||
}
|
}
|
||||||
if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
|
if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
|
||||||
/*
|
/*
|
||||||
* FIXME: location->segment could be NO_SEG, in which case
|
* FIXME: location.segment could be NO_SEG, in which case
|
||||||
* it is possible we should be passing 'abs_seg'. Look into this.
|
* it is possible we should be passing 'abs_seg'. Look into this.
|
||||||
* Work out whether that is *really* what we should be doing.
|
* Work out whether that is *really* what we should be doing.
|
||||||
* Generally fix things. I think this is right as it is, but
|
* Generally fix things. I think this is right as it is, but
|
||||||
* am still not certain.
|
* am still not certain.
|
||||||
*/
|
*/
|
||||||
ldef(result->label, in_abs_seg ? abs_seg : location->segment,
|
ldef(result->label, in_abs_seg ? abs_seg : location.segment,
|
||||||
location->offset, NULL, true, false);
|
location.offset, NULL, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
parser.h
1
parser.h
@@ -39,7 +39,6 @@
|
|||||||
#ifndef NASM_PARSER_H
|
#ifndef NASM_PARSER_H
|
||||||
#define NASM_PARSER_H
|
#define NASM_PARSER_H
|
||||||
|
|
||||||
void parser_global_info(struct location *locp);
|
|
||||||
insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef);
|
insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef);
|
||||||
void cleanup_insn(insn *instruction);
|
void cleanup_insn(insn *instruction);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user