Skip to content

Commit

Permalink
Merge SVN 4878
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Sep 23, 2024
1 parent caeacd5 commit ddd6348
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 194 deletions.
11 changes: 11 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@
search tree
* parser.y (_end_search): if search has no AT END create an implicit one
at END-SEARCH for better trace and debugging
* flag.def, typeck.c: new option "fast-compare" (cb_flag_fast_compare,
defaulting to on) to disable old and new optimizations
* cobc.c: disable cb_flag_fast_compare for -fsyntax-only and on compiler
errors to improve parsing time
* tree.c (cb_fits_int, cb_fits_long_long): constant ZERO fits both
integer types
* tree.c (cb_field_size): return FIELD_SIZE_UNKNOWN for constants and
fields with ANY LENGTH
* typeck.c (cb_build_cond_default, cb_build_cond_fields): extracted
from cb_build_cond


2022-12-14 Simon Sobisch <[email protected]>

Expand Down
3 changes: 3 additions & 0 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7896,6 +7896,7 @@ process_translate (struct filename *fn)
/* If processing raised errors set syntax-only flag to not
loose the information "no codegen occurred" */
cb_flag_syntax_only = 1;
cb_flag_fast_compare = 0;
return 1;
}
if (cb_flag_syntax_only) {
Expand Down Expand Up @@ -9023,6 +9024,7 @@ process_file (struct filename *fn, int status)
/* If preprocessing raised errors go on but only check syntax */
if (fn->has_error) {
cb_flag_syntax_only = 1;
cb_flag_fast_compare = 0;
}
} else
if (cb_src_list_file) {
Expand Down Expand Up @@ -9156,6 +9158,7 @@ main (int argc, char **argv)
cobc_flag_module = 1;
}
} else {
cb_flag_fast_compare = 0;
cb_compile_level = CB_LEVEL_TRANSLATE;
cobc_flag_main = 0;
cobc_flag_module = 0;
Expand Down
3 changes: 3 additions & 0 deletions cobc/flag.def
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ CB_FLAG (cb_flag_stack_extended, 1, "stack-extended",
CB_FLAG_ON (cb_flag_fast_math, 0, "fast-math",
_(" -ffast-math Disables emitting faster arithmetic logic"))

CB_FLAG_ON (cb_flag_fast_compare, 0, "fast-compare",
_(" -fno-fast-compare disables inline comparisions\n"))

/* Normal flags */

CB_FLAG_ON (cb_flag_remove_unreachable, 1, "remove-unreachable",
Expand Down
30 changes: 22 additions & 8 deletions cobc/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,9 @@ cb_fits_int (const cb_tree x)
case CB_TAG_INTEGER:
return 1;
default:
if (x == cb_zero) {
return 1;
}
return 0;
}
}
Expand Down Expand Up @@ -1777,6 +1780,9 @@ cb_fits_long_long (const cb_tree x)
case CB_TAG_INTEGER:
return 1;
default:
if (x == cb_zero) {
return 1;
}
return 0;
}
}
Expand Down Expand Up @@ -4268,22 +4274,24 @@ cb_field_add (struct cb_field *f, struct cb_field *p)
int
cb_field_size (const cb_tree x)
{
struct cb_reference *r;
struct cb_field *f;

switch (CB_TREE_TAG (x)) {
case CB_TAG_LITERAL:
return CB_LITERAL (x)->size;
case CB_TAG_FIELD:
f = CB_FIELD (x);
case CB_TAG_FIELD: {
const struct cb_field *f = CB_FIELD (x);
if (f->flag_any_length) {
return FIELD_SIZE_UNKNOWN;
}
if (f->usage == CB_USAGE_COMP_X
&& f->compx_size > 0) {
return f->compx_size;
}
return CB_FIELD (x)->size;
case CB_TAG_REFERENCE:
r = CB_REFERENCE (x);
f = CB_FIELD (r->value);
return f->size;
}
case CB_TAG_REFERENCE: {
const struct cb_reference *r = CB_REFERENCE (x);
const struct cb_field *f = CB_FIELD (r->value);
if (r->length) {
if (CB_LITERAL_P (r->length)) {
return cb_get_int (r->length);
Expand All @@ -4296,12 +4304,18 @@ cb_field_size (const cb_tree x)
} else {
return FIELD_SIZE_UNKNOWN;
}
} else if (f->flag_any_length) {
return FIELD_SIZE_UNKNOWN;
} else if (f->usage == CB_USAGE_COMP_X
&& f->compx_size > 0) {
return f->compx_size;
} else {
return f->size;
}
}
case CB_TAG_CONST:
/* depends on its actual usage */
return FIELD_SIZE_UNKNOWN;

/* LCOV_EXCL_START */
default:
Expand Down
Loading

0 comments on commit ddd6348

Please sign in to comment.