in calc_len().
svn path=/trunk/yasm/; revision=460
rel = (long)(target-offset);
/* short displacement must fit within -128 <= rel <= +127 */
if (rel >= -128 && rel <= 127) {
- /* It fits into a short displacement. Remember it fit as
- * such, and return minimal sizing.
- */
- jmprel->op_sel = JR_SHORT;
+ /* It fits into a short displacement. */
jrshort = 1;
} else {
/* Near for now, but could get shorter in the future. */
retval = 0;
}
} else {
- /* We have to assume it'll be a near displacement */
- jrshort = 0;
+ /* Assume whichever size is claimed as default by op_sel */
+ if (jmprel->op_sel == JR_SHORT)
+ jrshort = 1;
+ else
+ jrshort = 0;
retval = 0;
}
expr_delete(temp);
. rule_footer;
}
+sub action_setjrshort ( @ $ )
+{
+ my ($rule, $tokens, $func, $a_args, $count) = splice @_;
+ return rule_header ($rule, $tokens, $count)
+ . " if (\$2.op_sel == JR_NONE)\n"
+ . " \$2.op_sel = JR_SHORT;\n"
+ . " @$a_args\n"
+ . " \$\$ = $func;\n"
+ . rule_footer;
+}
+
sub get_token_number ( $ $ )
{
my ($tokens, $str) = splice @_;
}
# generate the grammar
- print GRAMMAR action ($rule, $tokens, $func, \@args, $count++);
+ # Specialcase jcc to set op_sel=JR_SHORT.
+ if ($rule =~ m/jcc/)
+ {
+ print GRAMMAR action_setjrshort ($rule, $tokens, $func, \@args, $count++);
+ }
+ else
+ {
+ print GRAMMAR action ($rule, $tokens, $func, \@args, $count++);
+ }
}
else
{
rel = (long)(target-offset);
/* short displacement must fit within -128 <= rel <= +127 */
if (rel >= -128 && rel <= 127) {
- /* It fits into a short displacement. Remember it fit as
- * such, and return minimal sizing.
- */
- jmprel->op_sel = JR_SHORT;
+ /* It fits into a short displacement. */
jrshort = 1;
} else {
/* Near for now, but could get shorter in the future. */
retval = 0;
}
} else {
- /* We have to assume it'll be a near displacement */
- jrshort = 0;
+ /* Assume whichever size is claimed as default by op_sel */
+ if (jmprel->op_sel == JR_SHORT)
+ jrshort = 1;
+ else
+ jrshort = 0;
retval = 0;
}
expr_delete(temp);
. rule_footer;
}
+sub action_setjrshort ( @ $ )
+{
+ my ($rule, $tokens, $func, $a_args, $count) = splice @_;
+ return rule_header ($rule, $tokens, $count)
+ . " if (\$2.op_sel == JR_NONE)\n"
+ . " \$2.op_sel = JR_SHORT;\n"
+ . " @$a_args\n"
+ . " \$\$ = $func;\n"
+ . rule_footer;
+}
+
sub get_token_number ( $ $ )
{
my ($tokens, $str) = splice @_;
}
# generate the grammar
- print GRAMMAR action ($rule, $tokens, $func, \@args, $count++);
+ # Specialcase jcc to set op_sel=JR_SHORT.
+ if ($rule =~ m/jcc/)
+ {
+ print GRAMMAR action_setjrshort ($rule, $tokens, $func, \@args, $count++);
+ }
+ else
+ {
+ print GRAMMAR action ($rule, $tokens, $func, \@args, $count++);
+ }
}
else
{