/* expr.c -operands, expressions-
Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
static void current_location (expressionS *);
static void clean_up_expression (expressionS * expressionP);
static segT operand (expressionS *, enum expr_mode);
-static operatorT operator (int *);
+static operatorT operatorf (int *);
extern const char EXP_CHARS[], FLT_CHARS[];
#ifdef md_operator
{
- operatorT operator = md_operator (name, 1, &c);
+ operatorT op = md_operator (name, 1, &c);
- switch (operator)
+ switch (op)
{
case O_uminus:
*input_line_pointer = c;
default:
break;
}
- if (operator != O_absent && operator != O_illegal)
+ if (op != O_absent && op != O_illegal)
{
*input_line_pointer = c;
expr (9, expressionP, mode);
expressionP->X_add_symbol = make_expr_symbol (expressionP);
expressionP->X_op_symbol = NULL;
expressionP->X_add_number = 0;
- expressionP->X_op = operator;
+ expressionP->X_op = op;
break;
}
}
}
void
-expr_set_rank (operatorT operator, operator_rankT rank)
+expr_set_rank (operatorT op, operator_rankT rank)
{
- gas_assert (operator >= O_md1 && operator < ARRAY_SIZE (op_rank));
- op_rank[operator] = rank;
+ gas_assert (op >= O_md1 && op < ARRAY_SIZE (op_rank));
+ op_rank[op] = rank;
}
/* Initialize the expression parser. */
Does not advance INPUT_LINE_POINTER. */
static inline operatorT
-operator (int *num_chars)
+operatorf (int *num_chars)
{
int c;
operatorT ret;
if (is_name_beginner (c))
{
char *name = input_line_pointer;
- char c = get_symbol_end ();
+ char ec = get_symbol_end ();
- ret = md_operator (name, 2, &c);
+ ret = md_operator (name, 2, &ec);
switch (ret)
{
case O_absent:
- *input_line_pointer = c;
+ *input_line_pointer = ec;
input_line_pointer = name;
break;
case O_uminus:
ret = O_illegal;
/* FALLTHROUGH */
default:
- *input_line_pointer = c;
+ *input_line_pointer = ec;
*num_chars = input_line_pointer - name;
input_line_pointer = name;
return ret;
/* operand () gobbles spaces. */
know (*input_line_pointer != ' ');
- op_left = operator (&op_chars);
+ op_left = operatorf (&op_chars);
while (op_left != O_illegal && op_rank[(int) op_left] > rank)
{
segT rightseg;
}
}
- op_right = operator (&op_chars);
+ op_right = operatorf (&op_chars);
know (op_right == O_illegal || op_left == O_index
|| op_rank[(int) op_right] <= op_rank[(int) op_left]);
/* Help out with CSE. */
valueT final_val = expressionP->X_add_number;
symbolS *add_symbol = expressionP->X_add_symbol;
+ symbolS *orig_add_symbol = add_symbol;
symbolS *op_symbol = expressionP->X_op_symbol;
operatorT op = expressionP->X_op;
valueT left, right;
left = right;
seg_left = seg_right;
add_symbol = op_symbol;
+ orig_add_symbol = expressionP->X_op_symbol;
op = O_symbol;
break;
}
{
if (op == O_bit_exclusive_or || op == O_bit_inclusive_or)
{
- if (seg_right != absolute_section || right != 0)
+ if (!(seg_right == absolute_section && right == 0))
{
seg_left = seg_right;
left = right;
add_symbol = op_symbol;
+ orig_add_symbol = expressionP->X_op_symbol;
}
op = O_symbol;
break;
}
else if (op == O_left_shift || op == O_right_shift)
{
- if (seg_left != absolute_section || left != 0)
+ if (!(seg_left == absolute_section && left == 0))
{
op = O_symbol;
break;
seg_left = seg_right;
left = right;
add_symbol = op_symbol;
+ orig_add_symbol = expressionP->X_op_symbol;
op = O_symbol;
break;
}
op = O_symbol;
break;
}
- else if (left != right
- || ((seg_left != reg_section || seg_right != reg_section)
- && (seg_left != undefined_section
- || seg_right != undefined_section
- || add_symbol != op_symbol)))
+ else if (!(left == right
+ && ((seg_left == reg_section && seg_right == reg_section)
+ || (seg_left == undefined_section
+ && seg_right == undefined_section
+ && add_symbol == op_symbol))))
return 0;
else if (op == O_bit_and || op == O_bit_inclusive_or)
{
op = O_constant;
else if (seg_left == reg_section && final_val == 0)
op = O_register;
- else if (add_symbol != expressionP->X_add_symbol)
+ else if (!symbol_same_p (add_symbol, orig_add_symbol))
final_val += left;
expressionP->X_add_symbol = add_symbol;
}