| 1 |
/* Parse tree dumper |
| 2 |
Copyright (C) 2003-2025 Free Software Foundation, Inc. |
| 3 |
Contributed by Steven Bosscher |
| 4 |
|
| 5 |
This file is part of GCC. |
| 6 |
|
| 7 |
GCC is free software; you can redistribute it and/or modify it under |
| 8 |
the terms of the GNU General Public License as published by the Free |
| 9 |
Software Foundation; either version 3, or (at your option) any later |
| 10 |
version. |
| 11 |
|
| 12 |
GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 |
for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with GCC; see the file COPYING3. If not see |
| 19 |
<http://www.gnu.org/licenses/>. */ |
| 20 |
|
| 21 |
|
| 22 |
/* Actually this is just a collection of routines that used to be |
| 23 |
scattered around the sources. Now that they are all in a single |
| 24 |
file, almost all of them can be static, and the other files don't |
| 25 |
have this mess in them. |
| 26 |
|
| 27 |
As a nice side-effect, this file can act as documentation of the |
| 28 |
gfc_code and gfc_expr structures and all their friends and |
| 29 |
relatives. |
| 30 |
|
| 31 |
TODO: Dump DATA. */ |
| 32 |
|
| 33 |
#include "config.h" |
| 34 |
#include "system.h" |
| 35 |
#include "coretypes.h" |
| 36 |
#include "gfortran.h" |
| 37 |
#include "constructor.h" |
| 38 |
#include "version.h" |
| 39 |
#include "parse.h" /* For gfc_ascii_statement. */ |
| 40 |
#include "omp-api.h" /* For omp_get_name_from_fr_id. */ |
| 41 |
#include "gomp-constants.h" /* For GOMP_INTEROP_IFR_SEPARATOR. */ |
| 42 |
|
| 43 |
/* Keep track of indentation for symbol tree dumps. */ |
| 44 |
static int show_level = 0; |
| 45 |
|
| 46 |
/* The file handle we're dumping to is kept in a static variable. This |
| 47 |
is not too cool, but it avoids a lot of passing it around. */ |
| 48 |
static FILE *dumpfile; |
| 49 |
|
| 50 |
/* Forward declaration of some of the functions. */ |
| 51 |
static void show_expr (gfc_expr *p); |
| 52 |
static void show_code_node (int, gfc_code *); |
| 53 |
static void show_namespace (gfc_namespace *ns); |
| 54 |
static void show_code (int, gfc_code *); |
| 55 |
static void show_symbol (gfc_symbol *); |
| 56 |
static void show_typespec (gfc_typespec *); |
| 57 |
static void show_ref (gfc_ref *); |
| 58 |
static void show_attr (symbol_attribute *, const char *); |
| 59 |
|
| 60 |
DEBUG_FUNCTION void |
| 61 |
debug (symbol_attribute *attr) |
| 62 |
{ |
| 63 |
FILE *tmp = dumpfile; |
| 64 |
dumpfile = stderr; |
| 65 |
show_attr (attr, NULL); |
| 66 |
fputc ('\n', dumpfile); |
| 67 |
dumpfile = tmp; |
| 68 |
} |
| 69 |
|
| 70 |
DEBUG_FUNCTION void |
| 71 |
debug (gfc_formal_arglist *formal) |
| 72 |
{ |
| 73 |
FILE *tmp = dumpfile; |
| 74 |
dumpfile = stderr; |
| 75 |
for (; formal; formal = formal->next) |
| 76 |
{ |
| 77 |
fputc ('\n', dumpfile); |
| 78 |
show_symbol (formal->sym); |
| 79 |
} |
| 80 |
fputc ('\n', dumpfile); |
| 81 |
dumpfile = tmp; |
| 82 |
} |
| 83 |
|
| 84 |
DEBUG_FUNCTION void |
| 85 |
debug (symbol_attribute attr) |
| 86 |
{ |
| 87 |
debug (&attr); |
| 88 |
} |
| 89 |
|
| 90 |
DEBUG_FUNCTION void |
| 91 |
debug (gfc_expr *e) |
| 92 |
{ |
| 93 |
FILE *tmp = dumpfile; |
| 94 |
dumpfile = stderr; |
| 95 |
if (e != NULL) |
| 96 |
{ |
| 97 |
show_expr (e); |
| 98 |
fputc (' ', dumpfile); |
| 99 |
show_typespec (&e->ts); |
| 100 |
} |
| 101 |
else |
| 102 |
fputs ("() ", dumpfile); |
| 103 |
|
| 104 |
fputc ('\n', dumpfile); |
| 105 |
dumpfile = tmp; |
| 106 |
} |
| 107 |
|
| 108 |
DEBUG_FUNCTION void |
| 109 |
debug (gfc_typespec *ts) |
| 110 |
{ |
| 111 |
FILE *tmp = dumpfile; |
| 112 |
dumpfile = stderr; |
| 113 |
show_typespec (ts); |
| 114 |
fputc ('\n', dumpfile); |
| 115 |
dumpfile = tmp; |
| 116 |
} |
| 117 |
|
| 118 |
DEBUG_FUNCTION void |
| 119 |
debug (gfc_typespec ts) |
| 120 |
{ |
| 121 |
debug (&ts); |
| 122 |
} |
| 123 |
|
| 124 |
DEBUG_FUNCTION void |
| 125 |
debug (gfc_ref *p) |
| 126 |
{ |
| 127 |
FILE *tmp = dumpfile; |
| 128 |
dumpfile = stderr; |
| 129 |
show_ref (p); |
| 130 |
fputc ('\n', dumpfile); |
| 131 |
dumpfile = tmp; |
| 132 |
} |
| 133 |
|
| 134 |
DEBUG_FUNCTION void |
| 135 |
debug (gfc_namespace *ns) |
| 136 |
{ |
| 137 |
FILE *tmp = dumpfile; |
| 138 |
dumpfile = stderr; |
| 139 |
show_namespace (ns); |
| 140 |
fputc ('\n', dumpfile); |
| 141 |
dumpfile = tmp; |
| 142 |
} |
| 143 |
|
| 144 |
DEBUG_FUNCTION void |
| 145 |
gfc_debug_expr (gfc_expr *e) |
| 146 |
{ |
| 147 |
FILE *tmp = dumpfile; |
| 148 |
dumpfile = stderr; |
| 149 |
show_expr (e); |
| 150 |
fputc ('\n', dumpfile); |
| 151 |
dumpfile = tmp; |
| 152 |
} |
| 153 |
|
| 154 |
/* Allow for dumping of a piece of code in the debugger. */ |
| 155 |
|
| 156 |
DEBUG_FUNCTION void |
| 157 |
gfc_debug_code (gfc_code *c) |
| 158 |
{ |
| 159 |
FILE *tmp = dumpfile; |
| 160 |
dumpfile = stderr; |
| 161 |
show_code (1, c); |
| 162 |
fputc ('\n', dumpfile); |
| 163 |
dumpfile = tmp; |
| 164 |
} |
| 165 |
|
| 166 |
DEBUG_FUNCTION void |
| 167 |
debug (gfc_symbol *sym) |
| 168 |
{ |
| 169 |
FILE *tmp = dumpfile; |
| 170 |
dumpfile = stderr; |
| 171 |
show_symbol (sym); |
| 172 |
fputc ('\n', dumpfile); |
| 173 |
dumpfile = tmp; |
| 174 |
} |
| 175 |
|
| 176 |
/* Do indentation for a specific level. */ |
| 177 |
|
| 178 |
static inline void |
| 179 |
code_indent (int level, gfc_st_label *label) |
| 180 |
{ |
| 181 |
int i; |
| 182 |
|
| 183 |
if (label != NULL) |
| 184 |
fprintf (dumpfile, "%-5d ", label->value); |
| 185 |
|
| 186 |
for (i = 0; i < (2 * level - (label ? 6 : 0)); i++) |
| 187 |
fputc (' ', dumpfile); |
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
/* Simple indentation at the current level. This one |
| 192 |
is used to show symbols. */ |
| 193 |
|
| 194 |
static inline void |
| 195 |
show_indent (void) |
| 196 |
{ |
| 197 |
fputc ('\n', dumpfile); |
| 198 |
code_indent (show_level, NULL); |
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
/* Show type-specific information. */ |
| 203 |
|
| 204 |
static void |
| 205 |
show_typespec (gfc_typespec *ts) |
| 206 |
{ |
| 207 |
if (ts->type == BT_ASSUMED) |
| 208 |
{ |
| 209 |
fputs ("(TYPE(*))", dumpfile); |
| 210 |
return; |
| 211 |
} |
| 212 |
|
| 213 |
fprintf (dumpfile, "(%s ", gfc_basic_typename (ts->type)); |
| 214 |
|
| 215 |
switch (ts->type) |
| 216 |
{ |
| 217 |
case BT_DERIVED: |
| 218 |
case BT_CLASS: |
| 219 |
case BT_UNION: |
| 220 |
fprintf (dumpfile, "%s", ts->u.derived->name); |
| 221 |
break; |
| 222 |
|
| 223 |
case BT_CHARACTER: |
| 224 |
if (ts->u.cl) |
| 225 |
show_expr (ts->u.cl->length); |
| 226 |
fprintf(dumpfile, " %d", ts->kind); |
| 227 |
break; |
| 228 |
|
| 229 |
default: |
| 230 |
fprintf (dumpfile, "%d", ts->kind); |
| 231 |
break; |
| 232 |
} |
| 233 |
if (ts->is_c_interop) |
| 234 |
fputs (" C_INTEROP", dumpfile); |
| 235 |
|
| 236 |
if (ts->is_iso_c) |
| 237 |
fputs (" ISO_C", dumpfile); |
| 238 |
|
| 239 |
if (ts->deferred) |
| 240 |
fputs (" DEFERRED", dumpfile); |
| 241 |
|
| 242 |
fputc (')', dumpfile); |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
/* Show an actual argument list. */ |
| 247 |
|
| 248 |
static void |
| 249 |
show_actual_arglist (gfc_actual_arglist *a) |
| 250 |
{ |
| 251 |
fputc ('(', dumpfile); |
| 252 |
|
| 253 |
for (; a; a = a->next) |
| 254 |
{ |
| 255 |
fputc ('(', dumpfile); |
| 256 |
if (a->name != NULL) |
| 257 |
fprintf (dumpfile, "%s = ", a->name); |
| 258 |
if (a->expr != NULL) |
| 259 |
show_expr (a->expr); |
| 260 |
else |
| 261 |
fputs ("(arg not-present)", dumpfile); |
| 262 |
|
| 263 |
fputc (')', dumpfile); |
| 264 |
if (a->next != NULL) |
| 265 |
fputc (' ', dumpfile); |
| 266 |
} |
| 267 |
|
| 268 |
fputc (')', dumpfile); |
| 269 |
} |
| 270 |
|
| 271 |
|
| 272 |
/* Show a gfc_array_spec array specification structure. */ |
| 273 |
|
| 274 |
static void |
| 275 |
show_array_spec (gfc_array_spec *as) |
| 276 |
{ |
| 277 |
const char *c; |
| 278 |
int i; |
| 279 |
|
| 280 |
if (as == NULL) |
| 281 |
{ |
| 282 |
fputs ("()", dumpfile); |
| 283 |
return; |
| 284 |
} |
| 285 |
|
| 286 |
fprintf (dumpfile, "(%d [%d]", as->rank, as->corank); |
| 287 |
|
| 288 |
if (as->rank + as->corank > 0 || as->rank == -1) |
| 289 |
{ |
| 290 |
switch (as->type) |
| 291 |
{ |
| 292 |
case AS_EXPLICIT: c = "AS_EXPLICIT"; break; |
| 293 |
case AS_DEFERRED: c = "AS_DEFERRED"; break; |
| 294 |
case AS_ASSUMED_SIZE: c = "AS_ASSUMED_SIZE"; break; |
| 295 |
case AS_ASSUMED_SHAPE: c = "AS_ASSUMED_SHAPE"; break; |
| 296 |
case AS_ASSUMED_RANK: c = "AS_ASSUMED_RANK"; break; |
| 297 |
default: |
| 298 |
gfc_internal_error ("show_array_spec(): Unhandled array shape " |
| 299 |
"type."); |
| 300 |
} |
| 301 |
fprintf (dumpfile, " %s ", c); |
| 302 |
|
| 303 |
for (i = 0; i < as->rank + as->corank; i++) |
| 304 |
{ |
| 305 |
show_expr (as->lower[i]); |
| 306 |
fputc (' ', dumpfile); |
| 307 |
show_expr (as->upper[i]); |
| 308 |
fputc (' ', dumpfile); |
| 309 |
} |
| 310 |
} |
| 311 |
|
| 312 |
fputc (')', dumpfile); |
| 313 |
} |
| 314 |
|
| 315 |
|
| 316 |
/* Show a gfc_array_ref array reference structure. */ |
| 317 |
|
| 318 |
static void |
| 319 |
show_array_ref (gfc_array_ref * ar) |
| 320 |
{ |
| 321 |
int i; |
| 322 |
|
| 323 |
fputc ('(', dumpfile); |
| 324 |
|
| 325 |
switch (ar->type) |
| 326 |
{ |
| 327 |
case AR_FULL: |
| 328 |
fputs ("FULL", dumpfile); |
| 329 |
break; |
| 330 |
|
| 331 |
case AR_SECTION: |
| 332 |
for (i = 0; i < ar->dimen; i++) |
| 333 |
{ |
| 334 |
/* There are two types of array sections: either the |
| 335 |
elements are identified by an integer array ('vector'), |
| 336 |
or by an index range. In the former case we only have to |
| 337 |
print the start expression which contains the vector, in |
| 338 |
the latter case we have to print any of lower and upper |
| 339 |
bound and the stride, if they're present. */ |
| 340 |
|
| 341 |
if (ar->start[i] != NULL) |
| 342 |
show_expr (ar->start[i]); |
| 343 |
|
| 344 |
if (ar->dimen_type[i] == DIMEN_RANGE) |
| 345 |
{ |
| 346 |
fputc (':', dumpfile); |
| 347 |
|
| 348 |
if (ar->end[i] != NULL) |
| 349 |
show_expr (ar->end[i]); |
| 350 |
|
| 351 |
if (ar->stride[i] != NULL) |
| 352 |
{ |
| 353 |
fputc (':', dumpfile); |
| 354 |
show_expr (ar->stride[i]); |
| 355 |
} |
| 356 |
} |
| 357 |
|
| 358 |
if (i != ar->dimen - 1) |
| 359 |
fputs (" , ", dumpfile); |
| 360 |
} |
| 361 |
break; |
| 362 |
|
| 363 |
case AR_ELEMENT: |
| 364 |
for (i = 0; i < ar->dimen; i++) |
| 365 |
{ |
| 366 |
show_expr (ar->start[i]); |
| 367 |
if (i != ar->dimen - 1) |
| 368 |
fputs (" , ", dumpfile); |
| 369 |
} |
| 370 |
break; |
| 371 |
|
| 372 |
case AR_UNKNOWN: |
| 373 |
fputs ("UNKNOWN", dumpfile); |
| 374 |
break; |
| 375 |
|
| 376 |
default: |
| 377 |
gfc_internal_error ("show_array_ref(): Unknown array reference"); |
| 378 |
} |
| 379 |
|
| 380 |
fputc (')', dumpfile); |
| 381 |
if (ar->codimen == 0) |
| 382 |
return; |
| 383 |
|
| 384 |
/* Show coarray part of the reference, if any. */ |
| 385 |
fputc ('[',dumpfile); |
| 386 |
for (i = ar->dimen; i < ar->dimen + ar->codimen; i++) |
| 387 |
{ |
| 388 |
if (ar->dimen_type[i] == DIMEN_STAR) |
| 389 |
fputc('*',dumpfile); |
| 390 |
else if (ar->dimen_type[i] == DIMEN_THIS_IMAGE) |
| 391 |
fputs("THIS_IMAGE", dumpfile); |
| 392 |
else |
| 393 |
{ |
| 394 |
show_expr (ar->start[i]); |
| 395 |
if (ar->end[i]) |
| 396 |
{ |
| 397 |
fputc(':', dumpfile); |
| 398 |
show_expr (ar->end[i]); |
| 399 |
} |
| 400 |
} |
| 401 |
if (i != ar->dimen + ar->codimen - 1) |
| 402 |
fputs (" , ", dumpfile); |
| 403 |
|
| 404 |
} |
| 405 |
fputc (']',dumpfile); |
| 406 |
} |
| 407 |
|
| 408 |
|
| 409 |
/* Show a list of gfc_ref structures. */ |
| 410 |
|
| 411 |
static void |
| 412 |
show_ref (gfc_ref *p) |
| 413 |
{ |
| 414 |
for (; p; p = p->next) |
| 415 |
switch (p->type) |
| 416 |
{ |
| 417 |
case REF_ARRAY: |
| 418 |
show_array_ref (&p->u.ar); |
| 419 |
break; |
| 420 |
|
| 421 |
case REF_COMPONENT: |
| 422 |
fprintf (dumpfile, " %% %s", p->u.c.component->name); |
| 423 |
break; |
| 424 |
|
| 425 |
case REF_SUBSTRING: |
| 426 |
fputc ('(', dumpfile); |
| 427 |
show_expr (p->u.ss.start); |
| 428 |
fputc (':', dumpfile); |
| 429 |
show_expr (p->u.ss.end); |
| 430 |
fputc (')', dumpfile); |
| 431 |
break; |
| 432 |
|
| 433 |
case REF_INQUIRY: |
| 434 |
switch (p->u.i) |
| 435 |
{ |
| 436 |
case INQUIRY_KIND: |
| 437 |
fprintf (dumpfile, " INQUIRY_KIND "); |
| 438 |
break; |
| 439 |
case INQUIRY_LEN: |
| 440 |
fprintf (dumpfile, " INQUIRY_LEN "); |
| 441 |
break; |
| 442 |
case INQUIRY_RE: |
| 443 |
fprintf (dumpfile, " INQUIRY_RE "); |
| 444 |
break; |
| 445 |
case INQUIRY_IM: |
| 446 |
fprintf (dumpfile, " INQUIRY_IM "); |
| 447 |
} |
| 448 |
break; |
| 449 |
|
| 450 |
default: |
| 451 |
gfc_internal_error ("show_ref(): Bad component code"); |
| 452 |
} |
| 453 |
} |
| 454 |
|
| 455 |
|
| 456 |
/* Display a constructor. Works recursively for array constructors. */ |
| 457 |
|
| 458 |
static void |
| 459 |
show_constructor (gfc_constructor_base base) |
| 460 |
{ |
| 461 |
gfc_constructor *c; |
| 462 |
for (c = gfc_constructor_first (base); c; c = gfc_constructor_next (c)) |
| 463 |
{ |
| 464 |
if (c->iterator == NULL) |
| 465 |
show_expr (c->expr); |
| 466 |
else |
| 467 |
{ |
| 468 |
fputc ('(', dumpfile); |
| 469 |
show_expr (c->expr); |
| 470 |
|
| 471 |
fputc (' ', dumpfile); |
| 472 |
show_expr (c->iterator->var); |
| 473 |
fputc ('=', dumpfile); |
| 474 |
show_expr (c->iterator->start); |
| 475 |
fputc (',', dumpfile); |
| 476 |
show_expr (c->iterator->end); |
| 477 |
fputc (',', dumpfile); |
| 478 |
show_expr (c->iterator->step); |
| 479 |
|
| 480 |
fputc (')', dumpfile); |
| 481 |
} |
| 482 |
|
| 483 |
if (gfc_constructor_next (c) != NULL) |
| 484 |
fputs (" , ", dumpfile); |
| 485 |
} |
| 486 |
} |
| 487 |
|
| 488 |
|
| 489 |
static void |
| 490 |
show_char_const (const gfc_char_t *c, gfc_charlen_t length) |
| 491 |
{ |
| 492 |
fputc ('\'', dumpfile); |
| 493 |
for (size_t i = 0; i < (size_t) length; i++) |
| 494 |
{ |
| 495 |
if (c[i] == '\'') |
| 496 |
fputs ("''", dumpfile); |
| 497 |
else |
| 498 |
fputs (gfc_print_wide_char (c[i]), dumpfile); |
| 499 |
} |
| 500 |
fputc ('\'', dumpfile); |
| 501 |
} |
| 502 |
|
| 503 |
|
| 504 |
/* Show a component-call expression. */ |
| 505 |
|
| 506 |
static void |
| 507 |
show_compcall (gfc_expr* p) |
| 508 |
{ |
| 509 |
gcc_assert (p->expr_type == EXPR_COMPCALL); |
| 510 |
|
| 511 |
fprintf (dumpfile, "%s", p->symtree->n.sym->name); |
| 512 |
show_ref (p->ref); |
| 513 |
fprintf (dumpfile, "%s", p->value.compcall.name); |
| 514 |
|
| 515 |
show_actual_arglist (p->value.compcall.actual); |
| 516 |
} |
| 517 |
|
| 518 |
|
| 519 |
/* Show an expression. */ |
| 520 |
|
| 521 |
static void |
| 522 |
show_expr (gfc_expr *p) |
| 523 |
{ |
| 524 |
const char *c; |
| 525 |
int i; |
| 526 |
|
| 527 |
if (p == NULL) |
| 528 |
{ |
| 529 |
fputs ("()", dumpfile); |
| 530 |
return; |
| 531 |
} |
| 532 |
|
| 533 |
switch (p->expr_type) |
| 534 |
{ |
| 535 |
case EXPR_SUBSTRING: |
| 536 |
show_char_const (p->value.character.string, p->value.character.length); |
| 537 |
show_ref (p->ref); |
| 538 |
break; |
| 539 |
|
| 540 |
case EXPR_STRUCTURE: |
| 541 |
fprintf (dumpfile, "%s(", p->ts.u.derived->name); |
| 542 |
show_constructor (p->value.constructor); |
| 543 |
fputc (')', dumpfile); |
| 544 |
break; |
| 545 |
|
| 546 |
case EXPR_ARRAY: |
| 547 |
fputs ("(/ ", dumpfile); |
| 548 |
show_constructor (p->value.constructor); |
| 549 |
fputs (" /)", dumpfile); |
| 550 |
|
| 551 |
show_ref (p->ref); |
| 552 |
break; |
| 553 |
|
| 554 |
case EXPR_NULL: |
| 555 |
fputs ("NULL()", dumpfile); |
| 556 |
break; |
| 557 |
|
| 558 |
case EXPR_CONSTANT: |
| 559 |
switch (p->ts.type) |
| 560 |
{ |
| 561 |
case BT_INTEGER: |
| 562 |
mpz_out_str (dumpfile, 10, p->value.integer); |
| 563 |
|
| 564 |
if (p->ts.kind != gfc_default_integer_kind) |
| 565 |
fprintf (dumpfile, "_%d", p->ts.kind); |
| 566 |
break; |
| 567 |
|
| 568 |
case BT_UNSIGNED: |
| 569 |
mpz_out_str (dumpfile, 10, p->value.integer); |
| 570 |
fputc('u', dumpfile); |
| 571 |
|
| 572 |
if (p->ts.kind != gfc_default_integer_kind) |
| 573 |
fprintf (dumpfile, "_%d", p->ts.kind); |
| 574 |
break; |
| 575 |
|
| 576 |
case BT_LOGICAL: |
| 577 |
if (p->value.logical) |
| 578 |
fputs (".true.", dumpfile); |
| 579 |
else |
| 580 |
fputs (".false.", dumpfile); |
| 581 |
break; |
| 582 |
|
| 583 |
case BT_REAL: |
| 584 |
mpfr_out_str (dumpfile, 10, 0, p->value.real, GFC_RND_MODE); |
| 585 |
if (p->ts.kind != gfc_default_real_kind) |
| 586 |
fprintf (dumpfile, "_%d", p->ts.kind); |
| 587 |
break; |
| 588 |
|
| 589 |
case BT_CHARACTER: |
| 590 |
show_char_const (p->value.character.string, |
| 591 |
p->value.character.length); |
| 592 |
break; |
| 593 |
|
| 594 |
case BT_COMPLEX: |
| 595 |
fputs ("(complex ", dumpfile); |
| 596 |
|
| 597 |
mpfr_out_str (dumpfile, 10, 0, mpc_realref (p->value.complex), |
| 598 |
GFC_RND_MODE); |
| 599 |
if (p->ts.kind != gfc_default_complex_kind) |
| 600 |
fprintf (dumpfile, "_%d", p->ts.kind); |
| 601 |
|
| 602 |
fputc (' ', dumpfile); |
| 603 |
|
| 604 |
mpfr_out_str (dumpfile, 10, 0, mpc_imagref (p->value.complex), |
| 605 |
GFC_RND_MODE); |
| 606 |
if (p->ts.kind != gfc_default_complex_kind) |
| 607 |
fprintf (dumpfile, "_%d", p->ts.kind); |
| 608 |
|
| 609 |
fputc (')', dumpfile); |
| 610 |
break; |
| 611 |
|
| 612 |
case BT_BOZ: |
| 613 |
if (p->boz.rdx == 2) |
| 614 |
fputs ("b'", dumpfile); |
| 615 |
else if (p->boz.rdx == 8) |
| 616 |
fputs ("o'", dumpfile); |
| 617 |
else |
| 618 |
fputs ("z'", dumpfile); |
| 619 |
fprintf (dumpfile, "%s'", p->boz.str); |
| 620 |
break; |
| 621 |
|
| 622 |
case BT_HOLLERITH: |
| 623 |
fprintf (dumpfile, HOST_WIDE_INT_PRINT_DEC "H", |
| 624 |
p->representation.length); |
| 625 |
c = p->representation.string; |
| 626 |
for (i = 0; i < p->representation.length; i++, c++) |
| 627 |
{ |
| 628 |
fputc (*c, dumpfile); |
| 629 |
} |
| 630 |
break; |
| 631 |
|
| 632 |
default: |
| 633 |
fputs ("???", dumpfile); |
| 634 |
break; |
| 635 |
} |
| 636 |
|
| 637 |
if (p->representation.string) |
| 638 |
{ |
| 639 |
fputs (" {", dumpfile); |
| 640 |
c = p->representation.string; |
| 641 |
for (i = 0; i < p->representation.length; i++, c++) |
| 642 |
{ |
| 643 |
fprintf (dumpfile, "%.2x", (unsigned int) *c); |
| 644 |
if (i < p->representation.length - 1) |
| 645 |
fputc (',', dumpfile); |
| 646 |
} |
| 647 |
fputc ('}', dumpfile); |
| 648 |
} |
| 649 |
|
| 650 |
break; |
| 651 |
|
| 652 |
case EXPR_VARIABLE: |
| 653 |
if (p->symtree->n.sym->ns && p->symtree->n.sym->ns->proc_name) |
| 654 |
fprintf (dumpfile, "%s:", p->symtree->n.sym->ns->proc_name->name); |
| 655 |
fprintf (dumpfile, "%s", p->symtree->n.sym->name); |
| 656 |
show_ref (p->ref); |
| 657 |
break; |
| 658 |
|
| 659 |
case EXPR_OP: |
| 660 |
fputc ('(', dumpfile); |
| 661 |
switch (p->value.op.op) |
| 662 |
{ |
| 663 |
case INTRINSIC_UPLUS: |
| 664 |
fputs ("U+ ", dumpfile); |
| 665 |
break; |
| 666 |
case INTRINSIC_UMINUS: |
| 667 |
fputs ("U- ", dumpfile); |
| 668 |
break; |
| 669 |
case INTRINSIC_PLUS: |
| 670 |
fputs ("+ ", dumpfile); |
| 671 |
break; |
| 672 |
case INTRINSIC_MINUS: |
| 673 |
fputs ("- ", dumpfile); |
| 674 |
break; |
| 675 |
case INTRINSIC_TIMES: |
| 676 |
fputs ("* ", dumpfile); |
| 677 |
break; |
| 678 |
case INTRINSIC_DIVIDE: |
| 679 |
fputs ("/ ", dumpfile); |
| 680 |
break; |
| 681 |
case INTRINSIC_POWER: |
| 682 |
fputs ("** ", dumpfile); |
| 683 |
break; |
| 684 |
case INTRINSIC_CONCAT: |
| 685 |
fputs ("// ", dumpfile); |
| 686 |
break; |
| 687 |
case INTRINSIC_AND: |
| 688 |
fputs ("AND ", dumpfile); |
| 689 |
break; |
| 690 |
case INTRINSIC_OR: |
| 691 |
fputs ("OR ", dumpfile); |
| 692 |
break; |
| 693 |
case INTRINSIC_EQV: |
| 694 |
fputs ("EQV ", dumpfile); |
| 695 |
break; |
| 696 |
case INTRINSIC_NEQV: |
| 697 |
fputs ("NEQV ", dumpfile); |
| 698 |
break; |
| 699 |
case INTRINSIC_EQ: |
| 700 |
case INTRINSIC_EQ_OS: |
| 701 |
fputs ("== ", dumpfile); |
| 702 |
break; |
| 703 |
case INTRINSIC_NE: |
| 704 |
case INTRINSIC_NE_OS: |
| 705 |
fputs ("/= ", dumpfile); |
| 706 |
break; |
| 707 |
case INTRINSIC_GT: |
| 708 |
case INTRINSIC_GT_OS: |
| 709 |
fputs ("> ", dumpfile); |
| 710 |
break; |
| 711 |
case INTRINSIC_GE: |
| 712 |
case INTRINSIC_GE_OS: |
| 713 |
fputs (">= ", dumpfile); |
| 714 |
break; |
| 715 |
case INTRINSIC_LT: |
| 716 |
case INTRINSIC_LT_OS: |
| 717 |
fputs ("< ", dumpfile); |
| 718 |
break; |
| 719 |
case INTRINSIC_LE: |
| 720 |
case INTRINSIC_LE_OS: |
| 721 |
fputs ("<= ", dumpfile); |
| 722 |
break; |
| 723 |
case INTRINSIC_NOT: |
| 724 |
fputs ("NOT ", dumpfile); |
| 725 |
break; |
| 726 |
case INTRINSIC_PARENTHESES: |
| 727 |
fputs ("parens ", dumpfile); |
| 728 |
break; |
| 729 |
|
| 730 |
default: |
| 731 |
gfc_internal_error |
| 732 |
("show_expr(): Bad intrinsic in expression"); |
| 733 |
} |
| 734 |
|
| 735 |
show_expr (p->value.op.op1); |
| 736 |
|
| 737 |
if (p->value.op.op2) |
| 738 |
{ |
| 739 |
fputc (' ', dumpfile); |
| 740 |
show_expr (p->value.op.op2); |
| 741 |
} |
| 742 |
|
| 743 |
fputc (')', dumpfile); |
| 744 |
break; |
| 745 |
|
| 746 |
case EXPR_FUNCTION: |
| 747 |
if (p->value.function.name == NULL) |
| 748 |
{ |
| 749 |
fprintf (dumpfile, "%s", p->symtree->n.sym->name); |
| 750 |
if (gfc_is_proc_ptr_comp (p)) |
| 751 |
show_ref (p->ref); |
| 752 |
fputc ('[', dumpfile); |
| 753 |
show_actual_arglist (p->value.function.actual); |
| 754 |
fputc (']', dumpfile); |
| 755 |
} |
| 756 |
else |
| 757 |
{ |
| 758 |
fprintf (dumpfile, "%s", p->value.function.name); |
| 759 |
if (gfc_is_proc_ptr_comp (p)) |
| 760 |
show_ref (p->ref); |
| 761 |
fputc ('[', dumpfile); |
| 762 |
fputc ('[', dumpfile); |
| 763 |
show_actual_arglist (p->value.function.actual); |
| 764 |
fputc (']', dumpfile); |
| 765 |
fputc (']', dumpfile); |
| 766 |
} |
| 767 |
|
| 768 |
break; |
| 769 |
|
| 770 |
case EXPR_COMPCALL: |
| 771 |
show_compcall (p); |
| 772 |
break; |
| 773 |
|
| 774 |
default: |
| 775 |
gfc_internal_error ("show_expr(): Don't know how to show expr"); |
| 776 |
} |
| 777 |
} |
| 778 |
|
| 779 |
/* Show symbol attributes. The flavor and intent are followed by |
| 780 |
whatever single bit attributes are present. */ |
| 781 |
|
| 782 |
static void |
| 783 |
show_attr (symbol_attribute *attr, const char * module) |
| 784 |
{ |
| 785 |
fputc ('(', dumpfile); |
| 786 |
if (attr->flavor != FL_UNKNOWN) |
| 787 |
{ |
| 788 |
if (attr->flavor == FL_DERIVED && attr->pdt_template) |
| 789 |
fputs ("PDT-TEMPLATE ", dumpfile); |
| 790 |
else |
| 791 |
fprintf (dumpfile, "%s ", gfc_code2string (flavors, attr->flavor)); |
| 792 |
} |
| 793 |
if (attr->access != ACCESS_UNKNOWN) |
| 794 |
fprintf (dumpfile, "%s ", gfc_code2string (access_types, attr->access)); |
| 795 |
if (attr->proc != PROC_UNKNOWN) |
| 796 |
fprintf (dumpfile, "%s ", gfc_code2string (procedures, attr->proc)); |
| 797 |
if (attr->save != SAVE_NONE) |
| 798 |
fprintf (dumpfile, "%s", gfc_code2string (save_status, attr->save)); |
| 799 |
|
| 800 |
if (attr->artificial) |
| 801 |
fputs (" ARTIFICIAL", dumpfile); |
| 802 |
if (attr->allocatable) |
| 803 |
fputs (" ALLOCATABLE", dumpfile); |
| 804 |
if (attr->asynchronous) |
| 805 |
fputs (" ASYNCHRONOUS", dumpfile); |
| 806 |
if (attr->codimension) |
| 807 |
fputs (" CODIMENSION", dumpfile); |
| 808 |
if (attr->dimension) |
| 809 |
fputs (" DIMENSION", dumpfile); |
| 810 |
if (attr->contiguous) |
| 811 |
fputs (" CONTIGUOUS", dumpfile); |
| 812 |
if (attr->external) |
| 813 |
fputs (" EXTERNAL", dumpfile); |
| 814 |
if (attr->intrinsic) |
| 815 |
fputs (" INTRINSIC", dumpfile); |
| 816 |
if (attr->optional) |
| 817 |
fputs (" OPTIONAL", dumpfile); |
| 818 |
if (attr->pdt_kind) |
| 819 |
fputs (" KIND", dumpfile); |
| 820 |
if (attr->pdt_len) |
| 821 |
fputs (" LEN", dumpfile); |
| 822 |
if (attr->pointer) |
| 823 |
fputs (" POINTER", dumpfile); |
| 824 |
if (attr->subref_array_pointer) |
| 825 |
fputs (" SUBREF-ARRAY-POINTER", dumpfile); |
| 826 |
if (attr->cray_pointer) |
| 827 |
fputs (" CRAY-POINTER", dumpfile); |
| 828 |
if (attr->cray_pointee) |
| 829 |
fputs (" CRAY-POINTEE", dumpfile); |
| 830 |
if (attr->is_protected) |
| 831 |
fputs (" PROTECTED", dumpfile); |
| 832 |
if (attr->value) |
| 833 |
fputs (" VALUE", dumpfile); |
| 834 |
if (attr->volatile_) |
| 835 |
fputs (" VOLATILE", dumpfile); |
| 836 |
if (attr->threadprivate) |
| 837 |
fputs (" THREADPRIVATE", dumpfile); |
| 838 |
if (attr->temporary) |
| 839 |
fputs (" TEMPORARY", dumpfile); |
| 840 |
if (attr->target) |
| 841 |
fputs (" TARGET", dumpfile); |
| 842 |
if (attr->dummy) |
| 843 |
{ |
| 844 |
fputs (" DUMMY", dumpfile); |
| 845 |
if (attr->intent != INTENT_UNKNOWN) |
| 846 |
fprintf (dumpfile, "(%s)", gfc_intent_string (attr->intent)); |
| 847 |
} |
| 848 |
|
| 849 |
if (attr->result) |
| 850 |
fputs (" RESULT", dumpfile); |
| 851 |
if (attr->entry) |
| 852 |
fputs (" ENTRY", dumpfile); |
| 853 |
if (attr->entry_master) |
| 854 |
fputs (" ENTRY-MASTER", dumpfile); |
| 855 |
if (attr->mixed_entry_master) |
| 856 |
fputs (" MIXED-ENTRY-MASTER", dumpfile); |
| 857 |
if (attr->is_bind_c) |
| 858 |
fputs (" BIND(C)", dumpfile); |
| 859 |
|
| 860 |
if (attr->data) |
| 861 |
fputs (" DATA", dumpfile); |
| 862 |
if (attr->use_assoc) |
| 863 |
{ |
| 864 |
fputs (" USE-ASSOC", dumpfile); |
| 865 |
if (module != NULL) |
| 866 |
fprintf (dumpfile, "(%s)", module); |
| 867 |
} |
| 868 |
|
| 869 |
if (attr->in_namelist) |
| 870 |
fputs (" IN-NAMELIST", dumpfile); |
| 871 |
if (attr->in_common) |
| 872 |
fputs (" IN-COMMON", dumpfile); |
| 873 |
if (attr->in_equivalence) |
| 874 |
fputs (" IN-EQUIVALENCE", dumpfile); |
| 875 |
|
| 876 |
if (attr->abstract) |
| 877 |
fputs (" ABSTRACT", dumpfile); |
| 878 |
if (attr->function) |
| 879 |
fputs (" FUNCTION", dumpfile); |
| 880 |
if (attr->subroutine) |
| 881 |
fputs (" SUBROUTINE", dumpfile); |
| 882 |
if (attr->implicit_type) |
| 883 |
fputs (" IMPLICIT-TYPE", dumpfile); |
| 884 |
|
| 885 |
if (attr->sequence) |
| 886 |
fputs (" SEQUENCE", dumpfile); |
| 887 |
if (attr->alloc_comp) |
| 888 |
fputs (" ALLOC-COMP", dumpfile); |
| 889 |
if (attr->pointer_comp) |
| 890 |
fputs (" POINTER-COMP", dumpfile); |
| 891 |
if (attr->proc_pointer_comp) |
| 892 |
fputs (" PROC-POINTER-COMP", dumpfile); |
| 893 |
if (attr->private_comp) |
| 894 |
fputs (" PRIVATE-COMP", dumpfile); |
| 895 |
if (attr->zero_comp) |
| 896 |
fputs (" ZERO-COMP", dumpfile); |
| 897 |
if (attr->coarray_comp) |
| 898 |
fputs (" COARRAY-COMP", dumpfile); |
| 899 |
if (attr->lock_comp) |
| 900 |
fputs (" LOCK-COMP", dumpfile); |
| 901 |
if (attr->event_comp) |
| 902 |
fputs (" EVENT-COMP", dumpfile); |
| 903 |
if (attr->defined_assign_comp) |
| 904 |
fputs (" DEFINED-ASSIGNED-COMP", dumpfile); |
| 905 |
if (attr->unlimited_polymorphic) |
| 906 |
fputs (" UNLIMITED-POLYMORPHIC", dumpfile); |
| 907 |
if (attr->has_dtio_procs) |
| 908 |
fputs (" HAS-DTIO-PROCS", dumpfile); |
| 909 |
if (attr->caf_token) |
| 910 |
fputs (" CAF-TOKEN", dumpfile); |
| 911 |
if (attr->select_type_temporary) |
| 912 |
fputs (" SELECT-TYPE-TEMPORARY", dumpfile); |
| 913 |
if (attr->associate_var) |
| 914 |
fputs (" ASSOCIATE-VAR", dumpfile); |
| 915 |
if (attr->pdt_kind) |
| 916 |
fputs (" PDT-KIND", dumpfile); |
| 917 |
if (attr->pdt_len) |
| 918 |
fputs (" PDT-LEN", dumpfile); |
| 919 |
if (attr->pdt_type) |
| 920 |
fputs (" PDT-TYPE", dumpfile); |
| 921 |
if (attr->pdt_array) |
| 922 |
fputs (" PDT-ARRAY", dumpfile); |
| 923 |
if (attr->pdt_string) |
| 924 |
fputs (" PDT-STRING", dumpfile); |
| 925 |
if (attr->omp_udr_artificial_var) |
| 926 |
fputs (" OMP-UDR-ARTIFICIAL-VAR", dumpfile); |
| 927 |
if (attr->omp_declare_target) |
| 928 |
fputs (" OMP-DECLARE-TARGET", dumpfile); |
| 929 |
if (attr->omp_declare_target_link) |
| 930 |
fputs (" OMP-DECLARE-TARGET-LINK", dumpfile); |
| 931 |
if (attr->omp_declare_target_indirect) |
| 932 |
fputs (" OMP-DECLARE-TARGET-INDIRECT", dumpfile); |
| 933 |
if (attr->omp_device_type == OMP_DEVICE_TYPE_HOST) |
| 934 |
fputs (" OMP-DEVICE-TYPE-HOST", dumpfile); |
| 935 |
if (attr->omp_device_type == OMP_DEVICE_TYPE_NOHOST) |
| 936 |
fputs (" OMP-DEVICE-TYPE-NOHOST", dumpfile); |
| 937 |
if (attr->omp_device_type == OMP_DEVICE_TYPE_ANY) |
| 938 |
fputs (" OMP-DEVICE-TYPE-ANY", dumpfile); |
| 939 |
if (attr->omp_allocate) |
| 940 |
fputs (" OMP-ALLOCATE", dumpfile); |
| 941 |
|
| 942 |
if (attr->oacc_declare_create) |
| 943 |
fputs (" OACC-DECLARE-CREATE", dumpfile); |
| 944 |
if (attr->oacc_declare_copyin) |
| 945 |
fputs (" OACC-DECLARE-COPYIN", dumpfile); |
| 946 |
if (attr->oacc_declare_deviceptr) |
| 947 |
fputs (" OACC-DECLARE-DEVICEPTR", dumpfile); |
| 948 |
if (attr->oacc_declare_device_resident) |
| 949 |
fputs (" OACC-DECLARE-DEVICE-RESIDENT", dumpfile); |
| 950 |
|
| 951 |
switch (attr->oacc_routine_lop) |
| 952 |
{ |
| 953 |
case OACC_ROUTINE_LOP_NONE: |
| 954 |
case OACC_ROUTINE_LOP_ERROR: |
| 955 |
break; |
| 956 |
|
| 957 |
case OACC_ROUTINE_LOP_GANG: |
| 958 |
fputs (" OACC-ROUTINE-LOP-GANG", dumpfile); |
| 959 |
break; |
| 960 |
|
| 961 |
case OACC_ROUTINE_LOP_WORKER: |
| 962 |
fputs (" OACC-ROUTINE-LOP-WORKER", dumpfile); |
| 963 |
break; |
| 964 |
|
| 965 |
case OACC_ROUTINE_LOP_VECTOR: |
| 966 |
fputs (" OACC-ROUTINE-LOP-VECTOR", dumpfile); |
| 967 |
break; |
| 968 |
|
| 969 |
case OACC_ROUTINE_LOP_SEQ: |
| 970 |
fputs (" OACC-ROUTINE-LOP-SEQ", dumpfile); |
| 971 |
break; |
| 972 |
} |
| 973 |
|
| 974 |
if (attr->elemental) |
| 975 |
fputs (" ELEMENTAL", dumpfile); |
| 976 |
if (attr->pure) |
| 977 |
fputs (" PURE", dumpfile); |
| 978 |
if (attr->implicit_pure) |
| 979 |
fputs (" IMPLICIT-PURE", dumpfile); |
| 980 |
if (attr->recursive) |
| 981 |
fputs (" RECURSIVE", dumpfile); |
| 982 |
if (attr->unmaskable) |
| 983 |
fputs (" UNMASKABKE", dumpfile); |
| 984 |
if (attr->masked) |
| 985 |
fputs (" MASKED", dumpfile); |
| 986 |
if (attr->contained) |
| 987 |
fputs (" CONTAINED", dumpfile); |
| 988 |
if (attr->mod_proc) |
| 989 |
fputs (" MOD-PROC", dumpfile); |
| 990 |
if (attr->module_procedure) |
| 991 |
fputs (" MODULE-PROCEDURE", dumpfile); |
| 992 |
if (attr->public_used) |
| 993 |
fputs (" PUBLIC_USED", dumpfile); |
| 994 |
if (attr->array_outer_dependency) |
| 995 |
fputs (" ARRAY-OUTER-DEPENDENCY", dumpfile); |
| 996 |
if (attr->noreturn) |
| 997 |
fputs (" NORETURN", dumpfile); |
| 998 |
if (attr->always_explicit) |
| 999 |
fputs (" ALWAYS-EXPLICIT", dumpfile); |
| 1000 |
if (attr->is_main_program) |
| 1001 |
fputs (" IS-MAIN-PROGRAM", dumpfile); |
| 1002 |
if (attr->oacc_routine_nohost) |
| 1003 |
fputs (" OACC-ROUTINE-NOHOST", dumpfile); |
| 1004 |
if (attr->temporary) |
| 1005 |
fputs (" TEMPORARY", dumpfile); |
| 1006 |
if (attr->assign) |
| 1007 |
fputs (" ASSIGN", dumpfile); |
| 1008 |
if (attr->not_always_present) |
| 1009 |
fputs (" NOT-ALWAYS-PRESENT", dumpfile); |
| 1010 |
if (attr->implied_index) |
| 1011 |
fputs (" IMPLIED-INDEX", dumpfile); |
| 1012 |
if (attr->proc_pointer) |
| 1013 |
fputs (" PROC-POINTER", dumpfile); |
| 1014 |
if (attr->fe_temp) |
| 1015 |
fputs (" FE-TEMP", dumpfile); |
| 1016 |
if (attr->automatic) |
| 1017 |
fputs (" AUTOMATIC", dumpfile); |
| 1018 |
if (attr->class_pointer) |
| 1019 |
fputs (" CLASS-POINTER", dumpfile); |
| 1020 |
if (attr->used_in_submodule) |
| 1021 |
fputs (" USED-IN-SUBMODULE", dumpfile); |
| 1022 |
if (attr->use_only) |
| 1023 |
fputs (" USE-ONLY", dumpfile); |
| 1024 |
if (attr->use_rename) |
| 1025 |
fputs (" USE-RENAME", dumpfile); |
| 1026 |
if (attr->imported) |
| 1027 |
fputs (" IMPORTED", dumpfile); |
| 1028 |
if (attr->host_assoc) |
| 1029 |
fputs (" HOST-ASSOC", dumpfile); |
| 1030 |
if (attr->generic) |
| 1031 |
fputs (" GENERIC", dumpfile); |
| 1032 |
if (attr->generic_copy) |
| 1033 |
fputs (" GENERIC-COPY", dumpfile); |
| 1034 |
if (attr->untyped) |
| 1035 |
fputs (" UNTYPED", dumpfile); |
| 1036 |
if (attr->extension) |
| 1037 |
fprintf (dumpfile, " EXTENSION(%u)", attr->extension); |
| 1038 |
if (attr->is_class) |
| 1039 |
fputs (" IS-CLASS", dumpfile); |
| 1040 |
if (attr->class_ok) |
| 1041 |
fputs (" CLASS-OK", dumpfile); |
| 1042 |
if (attr->vtab) |
| 1043 |
fputs (" VTAB", dumpfile); |
| 1044 |
if (attr->vtype) |
| 1045 |
fputs (" VTYPE", dumpfile); |
| 1046 |
if (attr->module_procedure) |
| 1047 |
fputs (" MODULE-PROCEDURE", dumpfile); |
| 1048 |
if (attr->if_source == IFSRC_DECL) |
| 1049 |
fputs (" IFSRC-DECL", dumpfile); |
| 1050 |
if (attr->if_source == IFSRC_IFBODY) |
| 1051 |
fputs (" IFSRC-IFBODY", dumpfile); |
| 1052 |
|
| 1053 |
for (int i = 0; i < EXT_ATTR_LAST; i++) |
| 1054 |
{ |
| 1055 |
if (attr->ext_attr & (1 << i)) |
| 1056 |
{ |
| 1057 |
fputs (" ATTRIBUTE-", dumpfile); |
| 1058 |
for (const char *p = ext_attr_list[i].name; p && *p; p++) |
| 1059 |
putc (TOUPPER (*p), dumpfile); |
| 1060 |
} |
| 1061 |
} |
| 1062 |
|
| 1063 |
fputc (')', dumpfile); |
| 1064 |
} |
| 1065 |
|
| 1066 |
|
| 1067 |
/* Show components of a derived type. */ |
| 1068 |
|
| 1069 |
static void |
| 1070 |
show_components (gfc_symbol *sym) |
| 1071 |
{ |
| 1072 |
gfc_component *c; |
| 1073 |
|
| 1074 |
for (c = sym->components; c; c = c->next) |
| 1075 |
{ |
| 1076 |
show_indent (); |
| 1077 |
fprintf (dumpfile, "(%s ", c->name); |
| 1078 |
show_typespec (&c->ts); |
| 1079 |
if (c->kind_expr) |
| 1080 |
{ |
| 1081 |
fputs (" kind_expr: ", dumpfile); |
| 1082 |
show_expr (c->kind_expr); |
| 1083 |
} |
| 1084 |
if (c->param_list) |
| 1085 |
{ |
| 1086 |
fputs ("PDT parameters", dumpfile); |
| 1087 |
show_actual_arglist (c->param_list); |
| 1088 |
} |
| 1089 |
|
| 1090 |
if (c->attr.allocatable) |
| 1091 |
fputs (" ALLOCATABLE", dumpfile); |
| 1092 |
if (c->attr.pdt_kind) |
| 1093 |
fputs (" KIND", dumpfile); |
| 1094 |
if (c->attr.pdt_len) |
| 1095 |
fputs (" LEN", dumpfile); |
| 1096 |
if (c->attr.pointer) |
| 1097 |
fputs (" POINTER", dumpfile); |
| 1098 |
if (c->attr.proc_pointer) |
| 1099 |
fputs (" PPC", dumpfile); |
| 1100 |
if (c->attr.dimension) |
| 1101 |
fputs (" DIMENSION", dumpfile); |
| 1102 |
fputc (' ', dumpfile); |
| 1103 |
show_array_spec (c->as); |
| 1104 |
if (c->attr.access) |
| 1105 |
fprintf (dumpfile, " %s", gfc_code2string (access_types, c->attr.access)); |
| 1106 |
fputc (')', dumpfile); |
| 1107 |
if (c->next != NULL) |
| 1108 |
fputc (' ', dumpfile); |
| 1109 |
} |
| 1110 |
} |
| 1111 |
|
| 1112 |
|
| 1113 |
/* Show the f2k_derived namespace with procedure bindings. */ |
| 1114 |
|
| 1115 |
static void |
| 1116 |
show_typebound_proc (gfc_typebound_proc* tb, const char* name) |
| 1117 |
{ |
| 1118 |
show_indent (); |
| 1119 |
|
| 1120 |
if (tb->is_generic) |
| 1121 |
fputs ("GENERIC", dumpfile); |
| 1122 |
else |
| 1123 |
{ |
| 1124 |
fputs ("PROCEDURE, ", dumpfile); |
| 1125 |
if (tb->nopass) |
| 1126 |
fputs ("NOPASS", dumpfile); |
| 1127 |
else |
| 1128 |
{ |
| 1129 |
if (tb->pass_arg) |
| 1130 |
fprintf (dumpfile, "PASS(%s)", tb->pass_arg); |
| 1131 |
else |
| 1132 |
fputs ("PASS", dumpfile); |
| 1133 |
} |
| 1134 |
if (tb->non_overridable) |
| 1135 |
fputs (", NON_OVERRIDABLE", dumpfile); |
| 1136 |
} |
| 1137 |
|
| 1138 |
if (tb->access == ACCESS_PUBLIC) |
| 1139 |
fputs (", PUBLIC", dumpfile); |
| 1140 |
else |
| 1141 |
fputs (", PRIVATE", dumpfile); |
| 1142 |
|
| 1143 |
fprintf (dumpfile, " :: %s => ", name); |
| 1144 |
|
| 1145 |
if (tb->is_generic) |
| 1146 |
{ |
| 1147 |
gfc_tbp_generic* g; |
| 1148 |
for (g = tb->u.generic; g; g = g->next) |
| 1149 |
{ |
| 1150 |
fputs (g->specific_st->name, dumpfile); |
| 1151 |
if (g->next) |
| 1152 |
fputs (", ", dumpfile); |
| 1153 |
} |
| 1154 |
} |
| 1155 |
else |
| 1156 |
fputs (tb->u.specific->n.sym->name, dumpfile); |
| 1157 |
} |
| 1158 |
|
| 1159 |
static void |
| 1160 |
show_typebound_symtree (gfc_symtree* st) |
| 1161 |
{ |
| 1162 |
gcc_assert (st->n.tb); |
| 1163 |
show_typebound_proc (st->n.tb, st->name); |
| 1164 |
} |
| 1165 |
|
| 1166 |
static void |
| 1167 |
show_f2k_derived (gfc_namespace* f2k) |
| 1168 |
{ |
| 1169 |
gfc_finalizer* f; |
| 1170 |
int op; |
| 1171 |
|
| 1172 |
show_indent (); |
| 1173 |
fputs ("Procedure bindings:", dumpfile); |
| 1174 |
++show_level; |
| 1175 |
|
| 1176 |
/* Finalizer bindings. */ |
| 1177 |
for (f = f2k->finalizers; f; f = f->next) |
| 1178 |
{ |
| 1179 |
show_indent (); |
| 1180 |
fprintf (dumpfile, "FINAL %s", f->proc_tree->n.sym->name); |
| 1181 |
} |
| 1182 |
|
| 1183 |
/* Type-bound procedures. */ |
| 1184 |
gfc_traverse_symtree (f2k->tb_sym_root, &show_typebound_symtree); |
| 1185 |
|
| 1186 |
--show_level; |
| 1187 |
|
| 1188 |
show_indent (); |
| 1189 |
fputs ("Operator bindings:", dumpfile); |
| 1190 |
++show_level; |
| 1191 |
|
| 1192 |
/* User-defined operators. */ |
| 1193 |
gfc_traverse_symtree (f2k->tb_uop_root, &show_typebound_symtree); |
| 1194 |
|
| 1195 |
/* Intrinsic operators. */ |
| 1196 |
for (op = GFC_INTRINSIC_BEGIN; op != GFC_INTRINSIC_END; ++op) |
| 1197 |
if (f2k->tb_op[op]) |
| 1198 |
show_typebound_proc (f2k->tb_op[op], |
| 1199 |
gfc_op2string ((gfc_intrinsic_op) op)); |
| 1200 |
|
| 1201 |
--show_level; |
| 1202 |
} |
| 1203 |
|
| 1204 |
|
| 1205 |
/* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we |
| 1206 |
show the interface. Information needed to reconstruct the list of |
| 1207 |
specific interfaces associated with a generic symbol is done within |
| 1208 |
that symbol. */ |
| 1209 |
|
| 1210 |
static void |
| 1211 |
show_symbol (gfc_symbol *sym) |
| 1212 |
{ |
| 1213 |
gfc_formal_arglist *formal; |
| 1214 |
gfc_interface *intr; |
| 1215 |
int i,len; |
| 1216 |
|
| 1217 |
if (sym == NULL) |
| 1218 |
return; |
| 1219 |
|
| 1220 |
fprintf (dumpfile, "|| symbol: '%s' ", sym->name); |
| 1221 |
len = strlen (sym->name); |
| 1222 |
for (i=len; i<12; i++) |
| 1223 |
fputc(' ', dumpfile); |
| 1224 |
|
| 1225 |
if (sym->binding_label) |
| 1226 |
fprintf (dumpfile,"|| binding_label: '%s' ", sym->binding_label); |
| 1227 |
|
| 1228 |
++show_level; |
| 1229 |
|
| 1230 |
show_indent (); |
| 1231 |
fputs ("type spec : ", dumpfile); |
| 1232 |
show_typespec (&sym->ts); |
| 1233 |
|
| 1234 |
show_indent (); |
| 1235 |
fputs ("attributes: ", dumpfile); |
| 1236 |
show_attr (&sym->attr, sym->module); |
| 1237 |
|
| 1238 |
if (sym->value) |
| 1239 |
{ |
| 1240 |
show_indent (); |
| 1241 |
fputs ("value: ", dumpfile); |
| 1242 |
show_expr (sym->value); |
| 1243 |
} |
| 1244 |
|
| 1245 |
if (sym->ts.type != BT_CLASS && sym->as) |
| 1246 |
{ |
| 1247 |
show_indent (); |
| 1248 |
fputs ("Array spec:", dumpfile); |
| 1249 |
show_array_spec (sym->as); |
| 1250 |
} |
| 1251 |
else if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->as) |
| 1252 |
{ |
| 1253 |
show_indent (); |
| 1254 |
fputs ("Array spec:", dumpfile); |
| 1255 |
show_array_spec (CLASS_DATA (sym)->as); |
| 1256 |
} |
| 1257 |
|
| 1258 |
if (sym->generic) |
| 1259 |
{ |
| 1260 |
show_indent (); |
| 1261 |
fputs ("Generic interfaces:", dumpfile); |
| 1262 |
for (intr = sym->generic; intr; intr = intr->next) |
| 1263 |
fprintf (dumpfile, " %s", intr->sym->name); |
| 1264 |
} |
| 1265 |
|
| 1266 |
if (sym->result) |
| 1267 |
{ |
| 1268 |
show_indent (); |
| 1269 |
fprintf (dumpfile, "result: %s", sym->result->name); |
| 1270 |
} |
| 1271 |
|
| 1272 |
if (sym->components) |
| 1273 |
{ |
| 1274 |
show_indent (); |
| 1275 |
fputs ("components: ", dumpfile); |
| 1276 |
show_components (sym); |
| 1277 |
} |
| 1278 |
|
| 1279 |
if (sym->f2k_derived) |
| 1280 |
{ |
| 1281 |
show_indent (); |
| 1282 |
if (sym->hash_value) |
| 1283 |
fprintf (dumpfile, "hash: %d", sym->hash_value); |
| 1284 |
show_f2k_derived (sym->f2k_derived); |
| 1285 |
} |
| 1286 |
|
| 1287 |
if (sym->formal) |
| 1288 |
{ |
| 1289 |
show_indent (); |
| 1290 |
fputs ("Formal arglist:", dumpfile); |
| 1291 |
|
| 1292 |
for (formal = sym->formal; formal; formal = formal->next) |
| 1293 |
{ |
| 1294 |
if (formal->sym != NULL) |
| 1295 |
fprintf (dumpfile, " %s", formal->sym->name); |
| 1296 |
else |
| 1297 |
fputs (" [Alt Return]", dumpfile); |
| 1298 |
} |
| 1299 |
} |
| 1300 |
|
| 1301 |
if (sym->formal_ns && (sym->formal_ns->proc_name != sym) |
| 1302 |
&& sym->attr.proc != PROC_ST_FUNCTION |
| 1303 |
&& !sym->attr.entry) |
| 1304 |
{ |
| 1305 |
show_indent (); |
| 1306 |
fputs ("Formal namespace", dumpfile); |
| 1307 |
show_namespace (sym->formal_ns); |
| 1308 |
} |
| 1309 |
|
| 1310 |
if (sym->attr.flavor == FL_VARIABLE |
| 1311 |
&& sym->param_list) |
| 1312 |
{ |
| 1313 |
show_indent (); |
| 1314 |
fputs ("PDT parameters", dumpfile); |
| 1315 |
show_actual_arglist (sym->param_list); |
| 1316 |
} |
| 1317 |
|
| 1318 |
if (sym->attr.flavor == FL_NAMELIST) |
| 1319 |
{ |
| 1320 |
gfc_namelist *nl; |
| 1321 |
show_indent (); |
| 1322 |
fputs ("variables : ", dumpfile); |
| 1323 |
for (nl = sym->namelist; nl; nl = nl->next) |
| 1324 |
fprintf (dumpfile, " %s",nl->sym->name); |
| 1325 |
} |
| 1326 |
|
| 1327 |
--show_level; |
| 1328 |
} |
| 1329 |
|
| 1330 |
|
| 1331 |
/* Show a user-defined operator. Just prints an operator |
| 1332 |
and the name of the associated subroutine, really. */ |
| 1333 |
|
| 1334 |
static void |
| 1335 |
show_uop (gfc_user_op *uop) |
| 1336 |
{ |
| 1337 |
gfc_interface *intr; |
| 1338 |
|
| 1339 |
show_indent (); |
| 1340 |
fprintf (dumpfile, "%s:", uop->name); |
| 1341 |
|
| 1342 |
for (intr = uop->op; intr; intr = intr->next) |
| 1343 |
fprintf (dumpfile, " %s", intr->sym->name); |
| 1344 |
} |
| 1345 |
|
| 1346 |
|
| 1347 |
/* Workhorse function for traversing the user operator symtree. */ |
| 1348 |
|
| 1349 |
static void |
| 1350 |
traverse_uop (gfc_symtree *st, void (*func) (gfc_user_op *)) |
| 1351 |
{ |
| 1352 |
if (st == NULL) |
| 1353 |
return; |
| 1354 |
|
| 1355 |
(*func) (st->n.uop); |
| 1356 |
|
| 1357 |
traverse_uop (st->left, func); |
| 1358 |
traverse_uop (st->right, func); |
| 1359 |
} |
| 1360 |
|
| 1361 |
|
| 1362 |
/* Traverse the tree of user operator nodes. */ |
| 1363 |
|
| 1364 |
void |
| 1365 |
gfc_traverse_user_op (gfc_namespace *ns, void (*func) (gfc_user_op *)) |
| 1366 |
{ |
| 1367 |
traverse_uop (ns->uop_root, func); |
| 1368 |
} |
| 1369 |
|
| 1370 |
|
| 1371 |
/* Function to display a common block. */ |
| 1372 |
|
| 1373 |
static void |
| 1374 |
show_common (gfc_symtree *st) |
| 1375 |
{ |
| 1376 |
gfc_symbol *s; |
| 1377 |
|
| 1378 |
show_indent (); |
| 1379 |
fprintf (dumpfile, "common: /%s/ ", st->name); |
| 1380 |
|
| 1381 |
s = st->n.common->head; |
| 1382 |
while (s) |
| 1383 |
{ |
| 1384 |
fprintf (dumpfile, "%s", s->name); |
| 1385 |
s = s->common_next; |
| 1386 |
if (s) |
| 1387 |
fputs (", ", dumpfile); |
| 1388 |
} |
| 1389 |
fputc ('\n', dumpfile); |
| 1390 |
} |
| 1391 |
|
| 1392 |
|
| 1393 |
/* Worker function to display the symbol tree. */ |
| 1394 |
|
| 1395 |
static void |
| 1396 |
show_symtree (gfc_symtree *st) |
| 1397 |
{ |
| 1398 |
int len, i; |
| 1399 |
|
| 1400 |
show_indent (); |
| 1401 |
|
| 1402 |
len = strlen(st->name); |
| 1403 |
fprintf (dumpfile, "symtree: '%s'", st->name); |
| 1404 |
|
| 1405 |
for (i=len; i<12; i++) |
| 1406 |
fputc(' ', dumpfile); |
| 1407 |
|
| 1408 |
if (st->ambiguous) |
| 1409 |
fputs( " Ambiguous", dumpfile); |
| 1410 |
|
| 1411 |
if (st->n.sym->ns != gfc_current_ns) |
| 1412 |
fprintf (dumpfile, "|| symbol: '%s' from namespace '%s'", st->n.sym->name, |
| 1413 |
st->n.sym->ns->proc_name->name); |
| 1414 |
else |
| 1415 |
show_symbol (st->n.sym); |
| 1416 |
} |
| 1417 |
|
| 1418 |
|
| 1419 |
/******************* Show gfc_code structures **************/ |
| 1420 |
|
| 1421 |
|
| 1422 |
/* Show a list of code structures. Mutually recursive with |
| 1423 |
show_code_node(). */ |
| 1424 |
|
| 1425 |
static void |
| 1426 |
show_code (int level, gfc_code *c) |
| 1427 |
{ |
| 1428 |
for (; c; c = c->next) |
| 1429 |
show_code_node (level, c); |
| 1430 |
} |
| 1431 |
|
| 1432 |
static void |
| 1433 |
show_iterator (gfc_namespace *ns) |
| 1434 |
{ |
| 1435 |
for (gfc_symbol *sym = ns->omp_affinity_iterators; sym; sym = sym->tlink) |
| 1436 |
{ |
| 1437 |
gfc_constructor *c; |
| 1438 |
if (sym != ns->omp_affinity_iterators) |
| 1439 |
fputc (',', dumpfile); |
| 1440 |
fputs (sym->name, dumpfile); |
| 1441 |
fputc ('=', dumpfile); |
| 1442 |
c = gfc_constructor_first (sym->value->value.constructor); |
| 1443 |
show_expr (c->expr); |
| 1444 |
fputc (':', dumpfile); |
| 1445 |
c = gfc_constructor_next (c); |
| 1446 |
show_expr (c->expr); |
| 1447 |
c = gfc_constructor_next (c); |
| 1448 |
if (c) |
| 1449 |
{ |
| 1450 |
fputc (':', dumpfile); |
| 1451 |
show_expr (c->expr); |
| 1452 |
} |
| 1453 |
} |
| 1454 |
} |
| 1455 |
|
| 1456 |
static void |
| 1457 |
show_omp_namelist (int list_type, gfc_omp_namelist *n) |
| 1458 |
{ |
| 1459 |
gfc_namespace *ns_iter = NULL, *ns_curr = gfc_current_ns; |
| 1460 |
gfc_omp_namelist *n2 = n; |
| 1461 |
for (; n; n = n->next) |
| 1462 |
{ |
| 1463 |
gfc_current_ns = ns_curr; |
| 1464 |
if (list_type == OMP_LIST_AFFINITY || list_type == OMP_LIST_DEPEND) |
| 1465 |
{ |
| 1466 |
gfc_current_ns = n->u2.ns ? n->u2.ns : ns_curr; |
| 1467 |
if (n->u2.ns != ns_iter) |
| 1468 |
{ |
| 1469 |
if (n != n2) |
| 1470 |
{ |
| 1471 |
fputs (") ", dumpfile); |
| 1472 |
if (list_type == OMP_LIST_AFFINITY) |
| 1473 |
fputs ("AFFINITY (", dumpfile); |
| 1474 |
else if (n->u.depend_doacross_op == OMP_DOACROSS_SINK_FIRST) |
| 1475 |
fputs ("DOACROSS (", dumpfile); |
| 1476 |
else |
| 1477 |
fputs ("DEPEND (", dumpfile); |
| 1478 |
} |
| 1479 |
if (n->u2.ns) |
| 1480 |
{ |
| 1481 |
fputs ("ITERATOR(", dumpfile); |
| 1482 |
show_iterator (n->u2.ns); |
| 1483 |
fputc (')', dumpfile); |
| 1484 |
fputc (list_type == OMP_LIST_AFFINITY ? ':' : ',', dumpfile); |
| 1485 |
} |
| 1486 |
} |
| 1487 |
ns_iter = n->u2.ns; |
| 1488 |
} |
| 1489 |
else if (list_type == OMP_LIST_INIT && n != n2) |
| 1490 |
fputs (") INIT(", dumpfile); |
| 1491 |
if (list_type == OMP_LIST_ALLOCATE) |
| 1492 |
{ |
| 1493 |
if (n->u2.allocator) |
| 1494 |
{ |
| 1495 |
fputs ("allocator(", dumpfile); |
| 1496 |
show_expr (n->u2.allocator); |
| 1497 |
fputc (')', dumpfile); |
| 1498 |
} |
| 1499 |
if (n->expr && n->u.align) |
| 1500 |
fputc (',', dumpfile); |
| 1501 |
if (n->u.align) |
| 1502 |
{ |
| 1503 |
fputs ("align(", dumpfile); |
| 1504 |
show_expr (n->u.align); |
| 1505 |
fputc (')', dumpfile); |
| 1506 |
} |
| 1507 |
if (n->u2.allocator || n->u.align) |
| 1508 |
fputc (':', dumpfile); |
| 1509 |
if (n->expr) |
| 1510 |
show_expr (n->expr); |
| 1511 |
else |
| 1512 |
fputs (n->sym->name, dumpfile); |
| 1513 |
if (n->next) |
| 1514 |
fputs (") ALLOCATE(", dumpfile); |
| 1515 |
continue; |
| 1516 |
} |
| 1517 |
if ((list_type == OMP_LIST_MAP || list_type == OMP_LIST_CACHE) |
| 1518 |
&& n->u.map.readonly) |
| 1519 |
fputs ("readonly,", dumpfile); |
| 1520 |
if (list_type == OMP_LIST_REDUCTION) |
| 1521 |
switch (n->u.reduction_op) |
| 1522 |
{ |
| 1523 |
case OMP_REDUCTION_PLUS: |
| 1524 |
case OMP_REDUCTION_TIMES: |
| 1525 |
case OMP_REDUCTION_MINUS: |
| 1526 |
case OMP_REDUCTION_AND: |
| 1527 |
case OMP_REDUCTION_OR: |
| 1528 |
case OMP_REDUCTION_EQV: |
| 1529 |
case OMP_REDUCTION_NEQV: |
| 1530 |
fprintf (dumpfile, "%s:", |
| 1531 |
gfc_op2string ((gfc_intrinsic_op) n->u.reduction_op)); |
| 1532 |
break; |
| 1533 |
case OMP_REDUCTION_MAX: fputs ("max:", dumpfile); break; |
| 1534 |
case OMP_REDUCTION_MIN: fputs ("min:", dumpfile); break; |
| 1535 |
case OMP_REDUCTION_IAND: fputs ("iand:", dumpfile); break; |
| 1536 |
case OMP_REDUCTION_IOR: fputs ("ior:", dumpfile); break; |
| 1537 |
case OMP_REDUCTION_IEOR: fputs ("ieor:", dumpfile); break; |
| 1538 |
case OMP_REDUCTION_USER: |
| 1539 |
if (n->u2.udr) |
| 1540 |
fprintf (dumpfile, "%s:", n->u2.udr->udr->name); |
| 1541 |
break; |
| 1542 |
default: break; |
| 1543 |
} |
| 1544 |
else if (list_type == OMP_LIST_DEPEND) |
| 1545 |
switch (n->u.depend_doacross_op) |
| 1546 |
{ |
| 1547 |
case OMP_DEPEND_IN: fputs ("in:", dumpfile); break; |
| 1548 |
case OMP_DEPEND_OUT: fputs ("out:", dumpfile); break; |
| 1549 |
case OMP_DEPEND_INOUT: fputs ("inout:", dumpfile); break; |
| 1550 |
case OMP_DEPEND_INOUTSET: fputs ("inoutset:", dumpfile); break; |
| 1551 |
case OMP_DEPEND_DEPOBJ: fputs ("depobj:", dumpfile); break; |
| 1552 |
case OMP_DEPEND_MUTEXINOUTSET: |
| 1553 |
fputs ("mutexinoutset:", dumpfile); |
| 1554 |
break; |
| 1555 |
case OMP_DEPEND_SINK_FIRST: |
| 1556 |
case OMP_DOACROSS_SINK_FIRST: |
| 1557 |
fputs ("sink:", dumpfile); |
| 1558 |
while (1) |
| 1559 |
{ |
| 1560 |
if (!n->sym) |
| 1561 |
fputs ("omp_cur_iteration", dumpfile); |
| 1562 |
else |
| 1563 |
fprintf (dumpfile, "%s", n->sym->name); |
| 1564 |
if (n->expr) |
| 1565 |
{ |
| 1566 |
fputc ('+', dumpfile); |
| 1567 |
show_expr (n->expr); |
| 1568 |
} |
| 1569 |
if (n->next == NULL) |
| 1570 |
break; |
| 1571 |
else if (n->next->u.depend_doacross_op != OMP_DOACROSS_SINK) |
| 1572 |
{ |
| 1573 |
if (n->next->u.depend_doacross_op |
| 1574 |
== OMP_DOACROSS_SINK_FIRST) |
| 1575 |
fputs (") DOACROSS(", dumpfile); |
| 1576 |
else |
| 1577 |
fputs (") DEPEND(", dumpfile); |
| 1578 |
break; |
| 1579 |
} |
| 1580 |
fputc (',', dumpfile); |
| 1581 |
n = n->next; |
| 1582 |
} |
| 1583 |
continue; |
| 1584 |
default: break; |
| 1585 |
} |
| 1586 |
else if (list_type == OMP_LIST_MAP) |
| 1587 |
switch (n->u.map.op) |
| 1588 |
{ |
| 1589 |
case OMP_MAP_ALLOC: fputs ("alloc:", dumpfile); break; |
| 1590 |
case OMP_MAP_TO: fputs ("to:", dumpfile); break; |
| 1591 |
case OMP_MAP_FROM: fputs ("from:", dumpfile); break; |
| 1592 |
case OMP_MAP_TOFROM: fputs ("tofrom:", dumpfile); break; |
| 1593 |
case OMP_MAP_PRESENT_ALLOC: fputs ("present,alloc:", dumpfile); break; |
| 1594 |
case OMP_MAP_PRESENT_TO: fputs ("present,to:", dumpfile); break; |
| 1595 |
case OMP_MAP_PRESENT_FROM: fputs ("present,from:", dumpfile); break; |
| 1596 |
case OMP_MAP_PRESENT_TOFROM: |
| 1597 |
fputs ("present,tofrom:", dumpfile); break; |
| 1598 |
case OMP_MAP_ALWAYS_TO: fputs ("always,to:", dumpfile); break; |
| 1599 |
case OMP_MAP_ALWAYS_FROM: fputs ("always,from:", dumpfile); break; |
| 1600 |
case OMP_MAP_ALWAYS_TOFROM: fputs ("always,tofrom:", dumpfile); break; |
| 1601 |
case OMP_MAP_ALWAYS_PRESENT_TO: |
| 1602 |
fputs ("always,present,to:", dumpfile); break; |
| 1603 |
case OMP_MAP_ALWAYS_PRESENT_FROM: |
| 1604 |
fputs ("always,present,from:", dumpfile); break; |
| 1605 |
case OMP_MAP_ALWAYS_PRESENT_TOFROM: |
| 1606 |
fputs ("always,present,tofrom:", dumpfile); break; |
| 1607 |
case OMP_MAP_DELETE: fputs ("delete:", dumpfile); break; |
| 1608 |
case OMP_MAP_RELEASE: fputs ("release:", dumpfile); break; |
| 1609 |
default: break; |
| 1610 |
} |
| 1611 |
else if (list_type == OMP_LIST_LINEAR && n->u.linear.old_modifier) |
| 1612 |
switch (n->u.linear.op) |
| 1613 |
{ |
| 1614 |
case OMP_LINEAR_REF: fputs ("ref(", dumpfile); break; |
| 1615 |
case OMP_LINEAR_VAL: fputs ("val(", dumpfile); break; |
| 1616 |
case OMP_LINEAR_UVAL: fputs ("uval(", dumpfile); break; |
| 1617 |
default: break; |
| 1618 |
} |
| 1619 |
else if (list_type == OMP_LIST_USES_ALLOCATORS) |
| 1620 |
{ |
| 1621 |
if (n->u.memspace_sym) |
| 1622 |
{ |
| 1623 |
fputs ("memspace(", dumpfile); |
| 1624 |
fputs (n->sym->name, dumpfile); |
| 1625 |
fputc (')', dumpfile); |
| 1626 |
} |
| 1627 |
if (n->u.memspace_sym && n->u2.traits_sym) |
| 1628 |
fputc (',', dumpfile); |
| 1629 |
if (n->u2.traits_sym) |
| 1630 |
{ |
| 1631 |
fputs ("traits(", dumpfile); |
| 1632 |
fputs (n->u2.traits_sym->name, dumpfile); |
| 1633 |
fputc (')', dumpfile); |
| 1634 |
} |
| 1635 |
if (n->u.memspace_sym || n->u2.traits_sym) |
| 1636 |
fputc (':', dumpfile); |
| 1637 |
fputs (n->sym->name, dumpfile); |
| 1638 |
if (n->next) |
| 1639 |
fputs (", ", dumpfile); |
| 1640 |
continue; |
| 1641 |
} |
| 1642 |
else if (list_type == OMP_LIST_INIT) |
| 1643 |
{ |
| 1644 |
if (n->u.init.target) |
| 1645 |
fputs ("target,", dumpfile); |
| 1646 |
if (n->u.init.targetsync) |
| 1647 |
fputs ("targetsync,", dumpfile); |
| 1648 |
if (n->u2.init_interop) |
| 1649 |
{ |
| 1650 |
char *str = n->u2.init_interop; |
| 1651 |
fputs ("prefer_type(", dumpfile); |
| 1652 |
while (str[0] == (char) GOMP_INTEROP_IFR_SEPARATOR) |
| 1653 |
{ |
| 1654 |
bool has_fr = false; |
| 1655 |
fputc ('{', dumpfile); |
| 1656 |
str++; |
| 1657 |
while (str[0] != (char) GOMP_INTEROP_IFR_SEPARATOR) |
| 1658 |
{ |
| 1659 |
if (has_fr) |
| 1660 |
fputc (',', dumpfile); |
| 1661 |
has_fr = true; |
| 1662 |
fputs ("fr(\"", dumpfile); |
| 1663 |
fputs (omp_get_name_from_fr_id (str[0]), dumpfile); |
| 1664 |
fputs ("\")", dumpfile); |
| 1665 |
str++; |
| 1666 |
} |
| 1667 |
str++; |
| 1668 |
if (has_fr && str[0] != '\0') |
| 1669 |
fputc (',', dumpfile); |
| 1670 |
while (str[0] != '\0') |
| 1671 |
{ |
| 1672 |
fputs ("attr(\"", dumpfile); |
| 1673 |
fputs (str, dumpfile); |
| 1674 |
fputs ("\")", dumpfile); |
| 1675 |
str += strlen (str) + 1; |
| 1676 |
if (str[0] != '\0') |
| 1677 |
fputc (',', dumpfile); |
| 1678 |
} |
| 1679 |
str++; |
| 1680 |
fputc ('}', dumpfile); |
| 1681 |
if (str[0] != '\0') |
| 1682 |
fputs (", ", dumpfile); |
| 1683 |
} |
| 1684 |
fputc (')', dumpfile); |
| 1685 |
} |
| 1686 |
fputc (':', dumpfile); |
| 1687 |
} |
| 1688 |
fprintf (dumpfile, "%s", n->sym ? n->sym->name : "omp_all_memory"); |
| 1689 |
if (list_type == OMP_LIST_LINEAR && n->u.linear.op != OMP_LINEAR_DEFAULT) |
| 1690 |
fputc (')', dumpfile); |
| 1691 |
if (n->expr) |
| 1692 |
{ |
| 1693 |
fputc (':', dumpfile); |
| 1694 |
show_expr (n->expr); |
| 1695 |
} |
| 1696 |
if (n->next) |
| 1697 |
fputc (',', dumpfile); |
| 1698 |
} |
| 1699 |
gfc_current_ns = ns_curr; |
| 1700 |
} |
| 1701 |
|
| 1702 |
static void |
| 1703 |
show_omp_assumes (gfc_omp_assumptions *assume) |
| 1704 |
{ |
| 1705 |
for (int i = 0; i < assume->n_absent; i++) |
| 1706 |
{ |
| 1707 |
fputs (" ABSENT (", dumpfile); |
| 1708 |
fputs (gfc_ascii_statement (assume->absent[i], true), dumpfile); |
| 1709 |
fputc (')', dumpfile); |
| 1710 |
} |
| 1711 |
for (int i = 0; i < assume->n_contains; i++) |
| 1712 |
{ |
| 1713 |
fputs (" CONTAINS (", dumpfile); |
| 1714 |
fputs (gfc_ascii_statement (assume->contains[i], true), dumpfile); |
| 1715 |
fputc (')', dumpfile); |
| 1716 |
} |
| 1717 |
for (gfc_expr_list *el = assume->holds; el; el = el->next) |
| 1718 |
{ |
| 1719 |
fputs (" HOLDS (", dumpfile); |
| 1720 |
show_expr (el->expr); |
| 1721 |
fputc (')', dumpfile); |
| 1722 |
} |
| 1723 |
if (assume->no_openmp) |
| 1724 |
fputs (" NO_OPENMP", dumpfile); |
| 1725 |
if (assume->no_openmp_routines) |
| 1726 |
fputs (" NO_OPENMP_ROUTINES", dumpfile); |
| 1727 |
if (assume->no_parallelism) |
| 1728 |
fputs (" NO_PARALLELISM", dumpfile); |
| 1729 |
} |
| 1730 |
|
| 1731 |
/* Show OpenMP or OpenACC clauses. */ |
| 1732 |
|
| 1733 |
static void |
| 1734 |
show_omp_clauses (gfc_omp_clauses *omp_clauses) |
| 1735 |
{ |
| 1736 |
int list_type, i; |
| 1737 |
|
| 1738 |
switch (omp_clauses->cancel) |
| 1739 |
{ |
| 1740 |
case OMP_CANCEL_UNKNOWN: |
| 1741 |
break; |
| 1742 |
case OMP_CANCEL_PARALLEL: |
| 1743 |
fputs (" PARALLEL", dumpfile); |
| 1744 |
break; |
| 1745 |
case OMP_CANCEL_SECTIONS: |
| 1746 |
fputs (" SECTIONS", dumpfile); |
| 1747 |
break; |
| 1748 |
case OMP_CANCEL_DO: |
| 1749 |
fputs (" DO", dumpfile); |
| 1750 |
break; |
| 1751 |
case OMP_CANCEL_TASKGROUP: |
| 1752 |
fputs (" TASKGROUP", dumpfile); |
| 1753 |
break; |
| 1754 |
} |
| 1755 |
if (omp_clauses->if_expr) |
| 1756 |
{ |
| 1757 |
fputs (" IF(", dumpfile); |
| 1758 |
show_expr (omp_clauses->if_expr); |
| 1759 |
fputc (')', dumpfile); |
| 1760 |
} |
| 1761 |
for (i = 0; i < OMP_IF_LAST; i++) |
| 1762 |
if (omp_clauses->if_exprs[i]) |
| 1763 |
{ |
| 1764 |
static const char *ifs[] = { |
| 1765 |
"CANCEL", |
| 1766 |
"PARALLEL", |
| 1767 |
"SIMD", |
| 1768 |
"TASK", |
| 1769 |
"TASKLOOP", |
| 1770 |
"TARGET", |
| 1771 |
"TARGET DATA", |
| 1772 |
"TARGET UPDATE", |
| 1773 |
"TARGET ENTER DATA", |
| 1774 |
"TARGET EXIT DATA" |
| 1775 |
}; |
| 1776 |
fputs (" IF(", dumpfile); |
| 1777 |
fputs (ifs[i], dumpfile); |
| 1778 |
fputs (": ", dumpfile); |
| 1779 |
show_expr (omp_clauses->if_exprs[i]); |
| 1780 |
fputc (')', dumpfile); |
| 1781 |
} |
| 1782 |
if (omp_clauses->self_expr) |
| 1783 |
{ |
| 1784 |
fputs (" SELF(", dumpfile); |
| 1785 |
show_expr (omp_clauses->self_expr); |
| 1786 |
fputc (')', dumpfile); |
| 1787 |
} |
| 1788 |
if (omp_clauses->final_expr) |
| 1789 |
{ |
| 1790 |
fputs (" FINAL(", dumpfile); |
| 1791 |
show_expr (omp_clauses->final_expr); |
| 1792 |
fputc (')', dumpfile); |
| 1793 |
} |
| 1794 |
if (omp_clauses->num_threads) |
| 1795 |
{ |
| 1796 |
fputs (" NUM_THREADS(", dumpfile); |
| 1797 |
show_expr (omp_clauses->num_threads); |
| 1798 |
fputc (')', dumpfile); |
| 1799 |
} |
| 1800 |
if (omp_clauses->async) |
| 1801 |
{ |
| 1802 |
fputs (" ASYNC", dumpfile); |
| 1803 |
if (omp_clauses->async_expr) |
| 1804 |
{ |
| 1805 |
fputc ('(', dumpfile); |
| 1806 |
show_expr (omp_clauses->async_expr); |
| 1807 |
fputc (')', dumpfile); |
| 1808 |
} |
| 1809 |
} |
| 1810 |
if (omp_clauses->num_gangs_expr) |
| 1811 |
{ |
| 1812 |
fputs (" NUM_GANGS(", dumpfile); |
| 1813 |
show_expr (omp_clauses->num_gangs_expr); |
| 1814 |
fputc (')', dumpfile); |
| 1815 |
} |
| 1816 |
if (omp_clauses->num_workers_expr) |
| 1817 |
{ |
| 1818 |
fputs (" NUM_WORKERS(", dumpfile); |
| 1819 |
show_expr (omp_clauses->num_workers_expr); |
| 1820 |
fputc (')', dumpfile); |
| 1821 |
} |
| 1822 |
if (omp_clauses->vector_length_expr) |
| 1823 |
{ |
| 1824 |
fputs (" VECTOR_LENGTH(", dumpfile); |
| 1825 |
show_expr (omp_clauses->vector_length_expr); |
| 1826 |
fputc (')', dumpfile); |
| 1827 |
} |
| 1828 |
if (omp_clauses->gang) |
| 1829 |
{ |
| 1830 |
fputs (" GANG", dumpfile); |
| 1831 |
if (omp_clauses->gang_num_expr || omp_clauses->gang_static_expr) |
| 1832 |
{ |
| 1833 |
fputc ('(', dumpfile); |
| 1834 |
if (omp_clauses->gang_num_expr) |
| 1835 |
{ |
| 1836 |
fprintf (dumpfile, "num:"); |
| 1837 |
show_expr (omp_clauses->gang_num_expr); |
| 1838 |
} |
| 1839 |
if (omp_clauses->gang_num_expr && omp_clauses->gang_static) |
| 1840 |
fputc (',', dumpfile); |
| 1841 |
if (omp_clauses->gang_static) |
| 1842 |
{ |
| 1843 |
fprintf (dumpfile, "static:"); |
| 1844 |
if (omp_clauses->gang_static_expr) |
| 1845 |
show_expr (omp_clauses->gang_static_expr); |
| 1846 |
else |
| 1847 |
fputc ('*', dumpfile); |
| 1848 |
} |
| 1849 |
fputc (')', dumpfile); |
| 1850 |
} |
| 1851 |
} |
| 1852 |
if (omp_clauses->worker) |
| 1853 |
{ |
| 1854 |
fputs (" WORKER", dumpfile); |
| 1855 |
if (omp_clauses->worker_expr) |
| 1856 |
{ |
| 1857 |
fputc ('(', dumpfile); |
| 1858 |
show_expr (omp_clauses->worker_expr); |
| 1859 |
fputc (')', dumpfile); |
| 1860 |
} |
| 1861 |
} |
| 1862 |
if (omp_clauses->vector) |
| 1863 |
{ |
| 1864 |
fputs (" VECTOR", dumpfile); |
| 1865 |
if (omp_clauses->vector_expr) |
| 1866 |
{ |
| 1867 |
fputc ('(', dumpfile); |
| 1868 |
show_expr (omp_clauses->vector_expr); |
| 1869 |
fputc (')', dumpfile); |
| 1870 |
} |
| 1871 |
} |
| 1872 |
if (omp_clauses->sched_kind != OMP_SCHED_NONE) |
| 1873 |
{ |
| 1874 |
const char *type; |
| 1875 |
switch (omp_clauses->sched_kind) |
| 1876 |
{ |
| 1877 |
case OMP_SCHED_STATIC: type = "STATIC"; break; |
| 1878 |
case OMP_SCHED_DYNAMIC: type = "DYNAMIC"; break; |
| 1879 |
case OMP_SCHED_GUIDED: type = "GUIDED"; break; |
| 1880 |
case OMP_SCHED_RUNTIME: type = "RUNTIME"; break; |
| 1881 |
case OMP_SCHED_AUTO: type = "AUTO"; break; |
| 1882 |
default: |
| 1883 |
gcc_unreachable (); |
| 1884 |
} |
| 1885 |
fputs (" SCHEDULE (", dumpfile); |
| 1886 |
if (omp_clauses->sched_simd) |
| 1887 |
{ |
| 1888 |
if (omp_clauses->sched_monotonic |
| 1889 |
|| omp_clauses->sched_nonmonotonic) |
| 1890 |
fputs ("SIMD, ", dumpfile); |
| 1891 |
else |
| 1892 |
fputs ("SIMD: ", dumpfile); |
| 1893 |
} |
| 1894 |
if (omp_clauses->sched_monotonic) |
| 1895 |
fputs ("MONOTONIC: ", dumpfile); |
| 1896 |
else if (omp_clauses->sched_nonmonotonic) |
| 1897 |
fputs ("NONMONOTONIC: ", dumpfile); |
| 1898 |
fputs (type, dumpfile); |
| 1899 |
if (omp_clauses->chunk_size) |
| 1900 |
{ |
| 1901 |
fputc (',', dumpfile); |
| 1902 |
show_expr (omp_clauses->chunk_size); |
| 1903 |
} |
| 1904 |
fputc (')', dumpfile); |
| 1905 |
} |
| 1906 |
if (omp_clauses->default_sharing != OMP_DEFAULT_UNKNOWN) |
| 1907 |
{ |
| 1908 |
const char *type; |
| 1909 |
switch (omp_clauses->default_sharing) |
| 1910 |
{ |
| 1911 |
case OMP_DEFAULT_NONE: type = "NONE"; break; |
| 1912 |
case OMP_DEFAULT_PRIVATE: type = "PRIVATE"; break; |
| 1913 |
case OMP_DEFAULT_SHARED: type = "SHARED"; break; |
| 1914 |
case OMP_DEFAULT_FIRSTPRIVATE: type = "FIRSTPRIVATE"; break; |
| 1915 |
case OMP_DEFAULT_PRESENT: type = "PRESENT"; break; |
| 1916 |
default: |
| 1917 |
gcc_unreachable (); |
| 1918 |
} |
| 1919 |
fprintf (dumpfile, " DEFAULT(%s)", type); |
| 1920 |
} |
| 1921 |
if (omp_clauses->tile_list) |
| 1922 |
{ |
| 1923 |
gfc_expr_list *list; |
| 1924 |
fputs (" TILE(", dumpfile); |
| 1925 |
for (list = omp_clauses->tile_list; list; list = list->next) |
| 1926 |
{ |
| 1927 |
show_expr (list->expr); |
| 1928 |
if (list->next) |
| 1929 |
fputs (", ", dumpfile); |
| 1930 |
} |
| 1931 |
fputc (')', dumpfile); |
| 1932 |
} |
| 1933 |
if (omp_clauses->wait_list) |
| 1934 |
{ |
| 1935 |
gfc_expr_list *list; |
| 1936 |
fputs (" WAIT(", dumpfile); |
| 1937 |
for (list = omp_clauses->wait_list; list; list = list->next) |
| 1938 |
{ |
| 1939 |
show_expr (list->expr); |
| 1940 |
if (list->next) |
| 1941 |
fputs (", ", dumpfile); |
| 1942 |
} |
| 1943 |
fputc (')', dumpfile); |
| 1944 |
} |
| 1945 |
if (omp_clauses->seq) |
| 1946 |
fputs (" SEQ", dumpfile); |
| 1947 |
if (omp_clauses->independent) |
| 1948 |
fputs (" INDEPENDENT", dumpfile); |
| 1949 |
if (omp_clauses->order_concurrent) |
| 1950 |
{ |
| 1951 |
fputs (" ORDER(", dumpfile); |
| 1952 |
if (omp_clauses->order_unconstrained) |
| 1953 |
fputs ("UNCONSTRAINED:", dumpfile); |
| 1954 |
else if (omp_clauses->order_reproducible) |
| 1955 |
fputs ("REPRODUCIBLE:", dumpfile); |
| 1956 |
fputs ("CONCURRENT)", dumpfile); |
| 1957 |
} |
| 1958 |
if (omp_clauses->ordered) |
| 1959 |
{ |
| 1960 |
if (omp_clauses->orderedc) |
| 1961 |
fprintf (dumpfile, " ORDERED(%d)", omp_clauses->orderedc); |
| 1962 |
else |
| 1963 |
fputs (" ORDERED", dumpfile); |
| 1964 |
} |
| 1965 |
if (omp_clauses->untied) |
| 1966 |
fputs (" UNTIED", dumpfile); |
| 1967 |
if (omp_clauses->mergeable) |
| 1968 |
fputs (" MERGEABLE", dumpfile); |
| 1969 |
if (omp_clauses->nowait) |
| 1970 |
fputs (" NOWAIT", dumpfile); |
| 1971 |
if (omp_clauses->collapse) |
| 1972 |
fprintf (dumpfile, " COLLAPSE(%d)", omp_clauses->collapse); |
| 1973 |
for (list_type = 0; list_type < OMP_LIST_NUM; list_type++) |
| 1974 |
if (omp_clauses->lists[list_type] != NULL) |
| 1975 |
{ |
| 1976 |
const char *type = NULL; |
| 1977 |
switch (list_type) |
| 1978 |
{ |
| 1979 |
case OMP_LIST_PRIVATE: type = "PRIVATE"; break; |
| 1980 |
case OMP_LIST_FIRSTPRIVATE: type = "FIRSTPRIVATE"; break; |
| 1981 |
case OMP_LIST_LASTPRIVATE: type = "LASTPRIVATE"; break; |
| 1982 |
case OMP_LIST_COPYPRIVATE: type = "COPYPRIVATE"; break; |
| 1983 |
case OMP_LIST_SHARED: type = "SHARED"; break; |
| 1984 |
case OMP_LIST_COPYIN: type = "COPYIN"; break; |
| 1985 |
case OMP_LIST_UNIFORM: type = "UNIFORM"; break; |
| 1986 |
case OMP_LIST_AFFINITY: type = "AFFINITY"; break; |
| 1987 |
case OMP_LIST_ALIGNED: type = "ALIGNED"; break; |
| 1988 |
case OMP_LIST_LINEAR: type = "LINEAR"; break; |
| 1989 |
case OMP_LIST_DEPEND: |
| 1990 |
if (omp_clauses->lists[list_type] |
| 1991 |
&& (omp_clauses->lists[list_type]->u.depend_doacross_op |
| 1992 |
== OMP_DOACROSS_SINK_FIRST)) |
| 1993 |
type = "DOACROSS"; |
| 1994 |
else |
| 1995 |
type = "DEPEND"; |
| 1996 |
break; |
| 1997 |
case OMP_LIST_MAP: type = "MAP"; break; |
| 1998 |
case OMP_LIST_TO: type = "TO"; break; |
| 1999 |
case OMP_LIST_FROM: type = "FROM"; break; |
| 2000 |
case OMP_LIST_REDUCTION: |
| 2001 |
case OMP_LIST_REDUCTION_INSCAN: |
| 2002 |
case OMP_LIST_REDUCTION_TASK: type = "REDUCTION"; break; |
| 2003 |
case OMP_LIST_IN_REDUCTION: type = "IN_REDUCTION"; break; |
| 2004 |
case OMP_LIST_TASK_REDUCTION: type = "TASK_REDUCTION"; break; |
| 2005 |
case OMP_LIST_DEVICE_RESIDENT: type = "DEVICE_RESIDENT"; break; |
| 2006 |
case OMP_LIST_ENTER: type = "ENTER"; break; |
| 2007 |
case OMP_LIST_LINK: type = "LINK"; break; |
| 2008 |
case OMP_LIST_USE_DEVICE: type = "USE_DEVICE"; break; |
| 2009 |
case OMP_LIST_CACHE: type = "CACHE"; break; |
| 2010 |
case OMP_LIST_IS_DEVICE_PTR: type = "IS_DEVICE_PTR"; break; |
| 2011 |
case OMP_LIST_USE_DEVICE_PTR: type = "USE_DEVICE_PTR"; break; |
| 2012 |
case OMP_LIST_HAS_DEVICE_ADDR: type = "HAS_DEVICE_ADDR"; break; |
| 2013 |
case OMP_LIST_USE_DEVICE_ADDR: type = "USE_DEVICE_ADDR"; break; |
| 2014 |
case OMP_LIST_NONTEMPORAL: type = "NONTEMPORAL"; break; |
| 2015 |
case OMP_LIST_ALLOCATE: type = "ALLOCATE"; break; |
| 2016 |
case OMP_LIST_SCAN_IN: type = "INCLUSIVE"; break; |
| 2017 |
case OMP_LIST_SCAN_EX: type = "EXCLUSIVE"; break; |
| 2018 |
case OMP_LIST_USES_ALLOCATORS: type = "USES_ALLOCATORS"; break; |
| 2019 |
case OMP_LIST_INIT: type = "INIT"; break; |
| 2020 |
case OMP_LIST_USE: type = "USE"; break; |
| 2021 |
case OMP_LIST_DESTROY: type = "DESTROY"; break; |
| 2022 |
default: |
| 2023 |
gcc_unreachable (); |
| 2024 |
} |
| 2025 |
fprintf (dumpfile, " %s(", type); |
| 2026 |
if (list_type == OMP_LIST_REDUCTION_INSCAN) |
| 2027 |
fputs ("inscan, ", dumpfile); |
| 2028 |
if (list_type == OMP_LIST_REDUCTION_TASK) |
| 2029 |
fputs ("task, ", dumpfile); |
| 2030 |
if ((list_type == OMP_LIST_TO || list_type == OMP_LIST_FROM) |
| 2031 |
&& omp_clauses->lists[list_type]->u.present_modifier) |
| 2032 |
fputs ("present:", dumpfile); |
| 2033 |
show_omp_namelist (list_type, omp_clauses->lists[list_type]); |
| 2034 |
fputc (')', dumpfile); |
| 2035 |
} |
| 2036 |
if (omp_clauses->safelen_expr) |
| 2037 |
{ |
| 2038 |
fputs (" SAFELEN(", dumpfile); |
| 2039 |
show_expr (omp_clauses->safelen_expr); |
| 2040 |
fputc (')', dumpfile); |
| 2041 |
} |
| 2042 |
if (omp_clauses->simdlen_expr) |
| 2043 |
{ |
| 2044 |
fputs (" SIMDLEN(", dumpfile); |
| 2045 |
show_expr (omp_clauses->simdlen_expr); |
| 2046 |
fputc (')', dumpfile); |
| 2047 |
} |
| 2048 |
if (omp_clauses->inbranch) |
| 2049 |
fputs (" INBRANCH", dumpfile); |
| 2050 |
if (omp_clauses->notinbranch) |
| 2051 |
fputs (" NOTINBRANCH", dumpfile); |
| 2052 |
if (omp_clauses->proc_bind != OMP_PROC_BIND_UNKNOWN) |
| 2053 |
{ |
| 2054 |
const char *type; |
| 2055 |
switch (omp_clauses->proc_bind) |
| 2056 |
{ |
| 2057 |
case OMP_PROC_BIND_PRIMARY: type = "PRIMARY"; break; |
| 2058 |
case OMP_PROC_BIND_MASTER: type = "MASTER"; break; |
| 2059 |
case OMP_PROC_BIND_SPREAD: type = "SPREAD"; break; |
| 2060 |
case OMP_PROC_BIND_CLOSE: type = "CLOSE"; break; |
| 2061 |
default: |
| 2062 |
gcc_unreachable (); |
| 2063 |
} |
| 2064 |
fprintf (dumpfile, " PROC_BIND(%s)", type); |
| 2065 |
} |
| 2066 |
if (omp_clauses->bind != OMP_BIND_UNSET) |
| 2067 |
{ |
| 2068 |
const char *type; |
| 2069 |
switch (omp_clauses->bind) |
| 2070 |
{ |
| 2071 |
case OMP_BIND_TEAMS: type = "TEAMS"; break; |
| 2072 |
case OMP_BIND_PARALLEL: type = "PARALLEL"; break; |
| 2073 |
case OMP_BIND_THREAD: type = "THREAD"; break; |
| 2074 |
default: |
| 2075 |
gcc_unreachable (); |
| 2076 |
} |
| 2077 |
fprintf (dumpfile, " BIND(%s)", type); |
| 2078 |
} |
| 2079 |
if (omp_clauses->num_teams_upper) |
| 2080 |
{ |
| 2081 |
fputs (" NUM_TEAMS(", dumpfile); |
| 2082 |
if (omp_clauses->num_teams_lower) |
| 2083 |
{ |
| 2084 |
show_expr (omp_clauses->num_teams_lower); |
| 2085 |
fputc (':', dumpfile); |
| 2086 |
} |
| 2087 |
show_expr (omp_clauses->num_teams_upper); |
| 2088 |
fputc (')', dumpfile); |
| 2089 |
} |
| 2090 |
if (omp_clauses->device) |
| 2091 |
{ |
| 2092 |
fputs (" DEVICE(", dumpfile); |
| 2093 |
if (omp_clauses->ancestor) |
| 2094 |
fputs ("ANCESTOR:", dumpfile); |
| 2095 |
show_expr (omp_clauses->device); |
| 2096 |
fputc (')', dumpfile); |
| 2097 |
} |
| 2098 |
if (omp_clauses->thread_limit) |
| 2099 |
{ |
| 2100 |
fputs (" THREAD_LIMIT(", dumpfile); |
| 2101 |
show_expr (omp_clauses->thread_limit); |
| 2102 |
fputc (')', dumpfile); |
| 2103 |
} |
| 2104 |
if (omp_clauses->dist_sched_kind != OMP_SCHED_NONE) |
| 2105 |
{ |
| 2106 |
fputs (" DIST_SCHEDULE (STATIC", dumpfile); |
| 2107 |
if (omp_clauses->dist_chunk_size) |
| 2108 |
{ |
| 2109 |
fputc (',', dumpfile); |
| 2110 |
show_expr (omp_clauses->dist_chunk_size); |
| 2111 |
} |
| 2112 |
fputc (')', dumpfile); |
| 2113 |
} |
| 2114 |
for (int i = 0; i < OMP_DEFAULTMAP_CAT_NUM; i++) |
| 2115 |
{ |
| 2116 |
const char *dfltmap; |
| 2117 |
if (omp_clauses->defaultmap[i] == OMP_DEFAULTMAP_UNSET) |
| 2118 |
continue; |
| 2119 |
fputs (" DEFAULTMAP (", dumpfile); |
| 2120 |
switch (omp_clauses->defaultmap[i]) |
| 2121 |
{ |
| 2122 |
case OMP_DEFAULTMAP_ALLOC: dfltmap = "ALLOC"; break; |
| 2123 |
case OMP_DEFAULTMAP_TO: dfltmap = "TO"; break; |
| 2124 |
case OMP_DEFAULTMAP_FROM: dfltmap = "FROM"; break; |
| 2125 |
case OMP_DEFAULTMAP_TOFROM: dfltmap = "TOFROM"; break; |
| 2126 |
case OMP_DEFAULTMAP_FIRSTPRIVATE: dfltmap = "FIRSTPRIVATE"; break; |
| 2127 |
case OMP_DEFAULTMAP_NONE: dfltmap = "NONE"; break; |
| 2128 |
case OMP_DEFAULTMAP_DEFAULT: dfltmap = "DEFAULT"; break; |
| 2129 |
case OMP_DEFAULTMAP_PRESENT: dfltmap = "PRESENT"; break; |
| 2130 |
default: gcc_unreachable (); |
| 2131 |
} |
| 2132 |
fputs (dfltmap, dumpfile); |
| 2133 |
if (i != OMP_DEFAULTMAP_CAT_UNCATEGORIZED) |
| 2134 |
{ |
| 2135 |
fputc (':', dumpfile); |
| 2136 |
switch ((enum gfc_omp_defaultmap_category) i) |
| 2137 |
{ |
| 2138 |
case OMP_DEFAULTMAP_CAT_SCALAR: dfltmap = "SCALAR"; break; |
| 2139 |
case OMP_DEFAULTMAP_CAT_AGGREGATE: dfltmap = "AGGREGATE"; break; |
| 2140 |
case OMP_DEFAULTMAP_CAT_ALLOCATABLE: dfltmap = "ALLOCATABLE"; break; |
| 2141 |
case OMP_DEFAULTMAP_CAT_POINTER: dfltmap = "POINTER"; break; |
| 2142 |
default: gcc_unreachable (); |
| 2143 |
} |
| 2144 |
fputs (dfltmap, dumpfile); |
| 2145 |
} |
| 2146 |
fputc (')', dumpfile); |
| 2147 |
} |
| 2148 |
if (omp_clauses->weak) |
| 2149 |
fputs (" WEAK", dumpfile); |
| 2150 |
if (omp_clauses->compare) |
| 2151 |
fputs (" COMPARE", dumpfile); |
| 2152 |
if (omp_clauses->nogroup) |
| 2153 |
fputs (" NOGROUP", dumpfile); |
| 2154 |
if (omp_clauses->simd) |
| 2155 |
fputs (" SIMD", dumpfile); |
| 2156 |
if (omp_clauses->threads) |
| 2157 |
fputs (" THREADS", dumpfile); |
| 2158 |
if (omp_clauses->grainsize) |
| 2159 |
{ |
| 2160 |
fputs (" GRAINSIZE(", dumpfile); |
| 2161 |
if (omp_clauses->grainsize_strict) |
| 2162 |
fputs ("strict: ", dumpfile); |
| 2163 |
show_expr (omp_clauses->grainsize); |
| 2164 |
fputc (')', dumpfile); |
| 2165 |
} |
| 2166 |
if (omp_clauses->filter) |
| 2167 |
{ |
| 2168 |
fputs (" FILTER(", dumpfile); |
| 2169 |
show_expr (omp_clauses->filter); |
| 2170 |
fputc (')', dumpfile); |
| 2171 |
} |
| 2172 |
if (omp_clauses->hint) |
| 2173 |
{ |
| 2174 |
fputs (" HINT(", dumpfile); |
| 2175 |
show_expr (omp_clauses->hint); |
| 2176 |
fputc (')', dumpfile); |
| 2177 |
} |
| 2178 |
if (omp_clauses->num_tasks) |
| 2179 |
{ |
| 2180 |
fputs (" NUM_TASKS(", dumpfile); |
| 2181 |
if (omp_clauses->num_tasks_strict) |
| 2182 |
fputs ("strict: ", dumpfile); |
| 2183 |
show_expr (omp_clauses->num_tasks); |
| 2184 |
fputc (')', dumpfile); |
| 2185 |
} |
| 2186 |
if (omp_clauses->priority) |
| 2187 |
{ |
| 2188 |
fputs (" PRIORITY(", dumpfile); |
| 2189 |
show_expr (omp_clauses->priority); |
| 2190 |
fputc (')', dumpfile); |
| 2191 |
} |
| 2192 |
if (omp_clauses->detach) |
| 2193 |
{ |
| 2194 |
fputs (" DETACH(", dumpfile); |
| 2195 |
show_expr (omp_clauses->detach); |
| 2196 |
fputc (')', dumpfile); |
| 2197 |
} |
| 2198 |
if (omp_clauses->destroy) |
| 2199 |
fputs (" DESTROY", dumpfile); |
| 2200 |
if (omp_clauses->depend_source) |
| 2201 |
fputs (" DEPEND(source)", dumpfile); |
| 2202 |
if (omp_clauses->doacross_source) |
| 2203 |
fputs (" DOACROSS(source:)", dumpfile); |
| 2204 |
if (omp_clauses->capture) |
| 2205 |
fputs (" CAPTURE", dumpfile); |
| 2206 |
if (omp_clauses->depobj_update != OMP_DEPEND_UNSET) |
| 2207 |
{ |
| 2208 |
const char *deptype; |
| 2209 |
fputs (" UPDATE(", dumpfile); |
| 2210 |
switch (omp_clauses->depobj_update) |
| 2211 |
{ |
| 2212 |
case OMP_DEPEND_IN: deptype = "IN"; break; |
| 2213 |
case OMP_DEPEND_OUT: deptype = "OUT"; break; |
| 2214 |
case OMP_DEPEND_INOUT: deptype = "INOUT"; break; |
| 2215 |
case OMP_DEPEND_INOUTSET: deptype = "INOUTSET"; break; |
| 2216 |
case OMP_DEPEND_MUTEXINOUTSET: deptype = "MUTEXINOUTSET"; break; |
| 2217 |
default: gcc_unreachable (); |
| 2218 |
} |
| 2219 |
fputs (deptype, dumpfile); |
| 2220 |
fputc (')', dumpfile); |
| 2221 |
} |
| 2222 |
if (omp_clauses->atomic_op != GFC_OMP_ATOMIC_UNSET) |
| 2223 |
{ |
| 2224 |
const char *atomic_op; |
| 2225 |
switch (omp_clauses->atomic_op & GFC_OMP_ATOMIC_MASK) |
| 2226 |
{ |
| 2227 |
case GFC_OMP_ATOMIC_READ: atomic_op = "READ"; break; |
| 2228 |
case GFC_OMP_ATOMIC_WRITE: atomic_op = "WRITE"; break; |
| 2229 |
case GFC_OMP_ATOMIC_UPDATE: atomic_op = "UPDATE"; break; |
| 2230 |
default: gcc_unreachable (); |
| 2231 |
} |
| 2232 |
fputc (' ', dumpfile); |
| 2233 |
fputs (atomic_op, dumpfile); |
| 2234 |
} |
| 2235 |
if (omp_clauses->memorder != OMP_MEMORDER_UNSET) |
| 2236 |
{ |
| 2237 |
const char *memorder; |
| 2238 |
switch (omp_clauses->memorder) |
| 2239 |
{ |
| 2240 |
case OMP_MEMORDER_ACQ_REL: memorder = "ACQ_REL"; break; |
| 2241 |
case OMP_MEMORDER_ACQUIRE: memorder = "AQUIRE"; break; |
| 2242 |
case OMP_MEMORDER_RELAXED: memorder = "RELAXED"; break; |
| 2243 |
case OMP_MEMORDER_RELEASE: memorder = "RELEASE"; break; |
| 2244 |
case OMP_MEMORDER_SEQ_CST: memorder = "SEQ_CST"; break; |
| 2245 |
default: gcc_unreachable (); |
| 2246 |
} |
| 2247 |
fputc (' ', dumpfile); |
| 2248 |
fputs (memorder, dumpfile); |
| 2249 |
} |
| 2250 |
if (omp_clauses->fail != OMP_MEMORDER_UNSET) |
| 2251 |
{ |
| 2252 |
const char *memorder; |
| 2253 |
switch (omp_clauses->fail) |
| 2254 |
{ |
| 2255 |
case OMP_MEMORDER_ACQUIRE: memorder = "AQUIRE"; break; |
| 2256 |
case OMP_MEMORDER_RELAXED: memorder = "RELAXED"; break; |
| 2257 |
case OMP_MEMORDER_SEQ_CST: memorder = "SEQ_CST"; break; |
| 2258 |
default: gcc_unreachable (); |
| 2259 |
} |
| 2260 |
fputs (" FAIL(", dumpfile); |
| 2261 |
fputs (memorder, dumpfile); |
| 2262 |
putc (')', dumpfile); |
| 2263 |
} |
| 2264 |
if (omp_clauses->at != OMP_AT_UNSET) |
| 2265 |
{ |
| 2266 |
if (omp_clauses->at != OMP_AT_COMPILATION) |
| 2267 |
fputs (" AT (COMPILATION)", dumpfile); |
| 2268 |
else |
| 2269 |
fputs (" AT (EXECUTION)", dumpfile); |
| 2270 |
} |
| 2271 |
if (omp_clauses->severity != OMP_SEVERITY_UNSET) |
| 2272 |
{ |
| 2273 |
if (omp_clauses->severity != OMP_SEVERITY_FATAL) |
| 2274 |
fputs (" SEVERITY (FATAL)", dumpfile); |
| 2275 |
else |
| 2276 |
fputs (" SEVERITY (WARNING)", dumpfile); |
| 2277 |
} |
| 2278 |
if (omp_clauses->message) |
| 2279 |
{ |
| 2280 |
fputs (" ERROR (", dumpfile); |
| 2281 |
show_expr (omp_clauses->message); |
| 2282 |
fputc (')', dumpfile); |
| 2283 |
} |
| 2284 |
if (omp_clauses->assume) |
| 2285 |
show_omp_assumes (omp_clauses->assume); |
| 2286 |
if (omp_clauses->full) |
| 2287 |
fputs (" FULL", dumpfile); |
| 2288 |
if (omp_clauses->partial) |
| 2289 |
{ |
| 2290 |
fputs (" PARTIAL", dumpfile); |
| 2291 |
if (omp_clauses->partial > 0) |
| 2292 |
fprintf (dumpfile, "(%d)", omp_clauses->partial); |
| 2293 |
} |
| 2294 |
if (omp_clauses->sizes_list) |
| 2295 |
{ |
| 2296 |
gfc_expr_list *sizes; |
| 2297 |
fputs (" SIZES(", dumpfile); |
| 2298 |
for (sizes = omp_clauses->sizes_list; sizes; sizes = sizes->next) |
| 2299 |
{ |
| 2300 |
show_expr (sizes->expr); |
| 2301 |
if (sizes->next) |
| 2302 |
fputs (", ", dumpfile); |
| 2303 |
} |
| 2304 |
fputc (')', dumpfile); |
| 2305 |
} |
| 2306 |
if (omp_clauses->novariants) |
| 2307 |
{ |
| 2308 |
fputs (" NOVARIANTS(", dumpfile); |
| 2309 |
show_expr (omp_clauses->novariants); |
| 2310 |
fputc (')', dumpfile); |
| 2311 |
} |
| 2312 |
if (omp_clauses->nocontext) |
| 2313 |
{ |
| 2314 |
fputs (" NOCONTEXT(", dumpfile); |
| 2315 |
show_expr (omp_clauses->nocontext); |
| 2316 |
fputc (')', dumpfile); |
| 2317 |
} |
| 2318 |
} |
| 2319 |
|
| 2320 |
/* Show a single OpenMP or OpenACC directive node and everything underneath it |
| 2321 |
if necessary. */ |
| 2322 |
|
| 2323 |
static void |
| 2324 |
show_omp_node (int level, gfc_code *c) |
| 2325 |
{ |
| 2326 |
gfc_omp_clauses *omp_clauses = NULL; |
| 2327 |
const char *name = NULL; |
| 2328 |
bool is_oacc = false; |
| 2329 |
|
| 2330 |
switch (c->op) |
| 2331 |
{ |
| 2332 |
case EXEC_OACC_PARALLEL_LOOP: |
| 2333 |
name = "PARALLEL LOOP"; is_oacc = true; break; |
| 2334 |
case EXEC_OACC_PARALLEL: name = "PARALLEL"; is_oacc = true; break; |
| 2335 |
case EXEC_OACC_KERNELS_LOOP: name = "KERNELS LOOP"; is_oacc = true; break; |
| 2336 |
case EXEC_OACC_KERNELS: name = "KERNELS"; is_oacc = true; break; |
| 2337 |
case EXEC_OACC_SERIAL_LOOP: name = "SERIAL LOOP"; is_oacc = true; break; |
| 2338 |
case EXEC_OACC_SERIAL: name = "SERIAL"; is_oacc = true; break; |
| 2339 |
case EXEC_OACC_DATA: name = "DATA"; is_oacc = true; break; |
| 2340 |
case EXEC_OACC_HOST_DATA: name = "HOST_DATA"; is_oacc = true; break; |
| 2341 |
case EXEC_OACC_LOOP: name = "LOOP"; is_oacc = true; break; |
| 2342 |
case EXEC_OACC_UPDATE: name = "UPDATE"; is_oacc = true; break; |
| 2343 |
case EXEC_OACC_WAIT: name = "WAIT"; is_oacc = true; break; |
| 2344 |
case EXEC_OACC_CACHE: name = "CACHE"; is_oacc = true; break; |
| 2345 |
case EXEC_OACC_ENTER_DATA: name = "ENTER DATA"; is_oacc = true; break; |
| 2346 |
case EXEC_OACC_EXIT_DATA: name = "EXIT DATA"; is_oacc = true; break; |
| 2347 |
case EXEC_OMP_ALLOCATE: name = "ALLOCATE"; break; |
| 2348 |
case EXEC_OMP_ALLOCATORS: name = "ALLOCATORS"; break; |
| 2349 |
case EXEC_OMP_ASSUME: name = "ASSUME"; break; |
| 2350 |
case EXEC_OMP_ATOMIC: name = "ATOMIC"; break; |
| 2351 |
case EXEC_OMP_BARRIER: name = "BARRIER"; break; |
| 2352 |
case EXEC_OMP_CANCEL: name = "CANCEL"; break; |
| 2353 |
case EXEC_OMP_CANCELLATION_POINT: name = "CANCELLATION POINT"; break; |
| 2354 |
case EXEC_OMP_CRITICAL: name = "CRITICAL"; break; |
| 2355 |
case EXEC_OMP_DISPATCH: |
| 2356 |
name = "DISPATCH"; |
| 2357 |
break; |
| 2358 |
case EXEC_OMP_DISTRIBUTE: name = "DISTRIBUTE"; break; |
| 2359 |
case EXEC_OMP_DISTRIBUTE_PARALLEL_DO: |
| 2360 |
name = "DISTRIBUTE PARALLEL DO"; break; |
| 2361 |
case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD: |
| 2362 |
name = "DISTRIBUTE PARALLEL DO SIMD"; break; |
| 2363 |
case EXEC_OMP_DISTRIBUTE_SIMD: name = "DISTRIBUTE SIMD"; break; |
| 2364 |
case EXEC_OMP_DO: name = "DO"; break; |
| 2365 |
case EXEC_OMP_DO_SIMD: name = "DO SIMD"; break; |
| 2366 |
case EXEC_OMP_ERROR: name = "ERROR"; break; |
| 2367 |
case EXEC_OMP_FLUSH: name = "FLUSH"; break; |
| 2368 |
case EXEC_OMP_INTEROP: name = "INTEROP"; break; |
| 2369 |
case EXEC_OMP_LOOP: name = "LOOP"; break; |
| 2370 |
case EXEC_OMP_MASKED: name = "MASKED"; break; |
| 2371 |
case EXEC_OMP_MASKED_TASKLOOP: name = "MASKED TASKLOOP"; break; |
| 2372 |
case EXEC_OMP_MASKED_TASKLOOP_SIMD: name = "MASKED TASKLOOP SIMD"; break; |
| 2373 |
case EXEC_OMP_MASTER: name = "MASTER"; break; |
| 2374 |
case EXEC_OMP_MASTER_TASKLOOP: name = "MASTER TASKLOOP"; break; |
| 2375 |
case EXEC_OMP_MASTER_TASKLOOP_SIMD: name = "MASTER TASKLOOP SIMD"; break; |
| 2376 |
case EXEC_OMP_METADIRECTIVE: name = "METADIRECTIVE"; break; |
| 2377 |
case EXEC_OMP_ORDERED: name = "ORDERED"; break; |
| 2378 |
case EXEC_OMP_DEPOBJ: name = "DEPOBJ"; break; |
| 2379 |
case EXEC_OMP_PARALLEL: name = "PARALLEL"; break; |
| 2380 |
case EXEC_OMP_PARALLEL_DO: name = "PARALLEL DO"; break; |
| 2381 |
case EXEC_OMP_PARALLEL_DO_SIMD: name = "PARALLEL DO SIMD"; break; |
| 2382 |
case EXEC_OMP_PARALLEL_LOOP: name = "PARALLEL LOOP"; break; |
| 2383 |
case EXEC_OMP_PARALLEL_MASTER: name = "PARALLEL MASTER"; break; |
| 2384 |
case EXEC_OMP_PARALLEL_MASKED: name = "PARALLEL MASK"; break; |
| 2385 |
case EXEC_OMP_PARALLEL_MASKED_TASKLOOP: |
| 2386 |
name = "PARALLEL MASK TASKLOOP"; break; |
| 2387 |
case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD: |
| 2388 |
name = "PARALLEL MASK TASKLOOP SIMD"; break; |
| 2389 |
case EXEC_OMP_PARALLEL_MASTER_TASKLOOP: |
| 2390 |
name = "PARALLEL MASTER TASKLOOP"; break; |
| 2391 |
case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD: |
| 2392 |
name = "PARALLEL MASTER TASKLOOP SIMD"; break; |
| 2393 |
case EXEC_OMP_PARALLEL_SECTIONS: name = "PARALLEL SECTIONS"; break; |
| 2394 |
case EXEC_OMP_PARALLEL_WORKSHARE: name = "PARALLEL WORKSHARE"; break; |
| 2395 |
case EXEC_OMP_SCAN: name = "SCAN"; break; |
| 2396 |
case EXEC_OMP_SCOPE: name = "SCOPE"; break; |
| 2397 |
case EXEC_OMP_SECTIONS: name = "SECTIONS"; break; |
| 2398 |
case EXEC_OMP_SIMD: name = "SIMD"; break; |
| 2399 |
case EXEC_OMP_SINGLE: name = "SINGLE"; break; |
| 2400 |
case EXEC_OMP_TARGET: name = "TARGET"; break; |
| 2401 |
case EXEC_OMP_TARGET_DATA: name = "TARGET DATA"; break; |
| 2402 |
case EXEC_OMP_TARGET_ENTER_DATA: name = "TARGET ENTER DATA"; break; |
| 2403 |
case EXEC_OMP_TARGET_EXIT_DATA: name = "TARGET EXIT DATA"; break; |
| 2404 |
case EXEC_OMP_TARGET_PARALLEL: name = "TARGET PARALLEL"; break; |
| 2405 |
case EXEC_OMP_TARGET_PARALLEL_DO: name = "TARGET PARALLEL DO"; break; |
| 2406 |
case EXEC_OMP_TARGET_PARALLEL_DO_SIMD: |
| 2407 |
name = "TARGET_PARALLEL_DO_SIMD"; break; |
| 2408 |
case EXEC_OMP_TARGET_PARALLEL_LOOP: name = "TARGET PARALLEL LOOP"; break; |
| 2409 |
case EXEC_OMP_TARGET_SIMD: name = "TARGET SIMD"; break; |
| 2410 |
case EXEC_OMP_TARGET_TEAMS: name = "TARGET TEAMS"; break; |
| 2411 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE: |
| 2412 |
name = "TARGET TEAMS DISTRIBUTE"; break; |
| 2413 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO: |
| 2414 |
name = "TARGET TEAMS DISTRIBUTE PARALLEL DO"; break; |
| 2415 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: |
| 2416 |
name = "TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD"; break; |
| 2417 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD: |
| 2418 |
name = "TARGET TEAMS DISTRIBUTE SIMD"; break; |
| 2419 |
case EXEC_OMP_TARGET_TEAMS_LOOP: name = "TARGET TEAMS LOOP"; break; |
| 2420 |
case EXEC_OMP_TARGET_UPDATE: name = "TARGET UPDATE"; break; |
| 2421 |
case EXEC_OMP_TASK: name = "TASK"; break; |
| 2422 |
case EXEC_OMP_TASKGROUP: name = "TASKGROUP"; break; |
| 2423 |
case EXEC_OMP_TASKLOOP: name = "TASKLOOP"; break; |
| 2424 |
case EXEC_OMP_TASKLOOP_SIMD: name = "TASKLOOP SIMD"; break; |
| 2425 |
case EXEC_OMP_TASKWAIT: name = "TASKWAIT"; break; |
| 2426 |
case EXEC_OMP_TASKYIELD: name = "TASKYIELD"; break; |
| 2427 |
case EXEC_OMP_TEAMS: name = "TEAMS"; break; |
| 2428 |
case EXEC_OMP_TEAMS_DISTRIBUTE: name = "TEAMS DISTRIBUTE"; break; |
| 2429 |
case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO: |
| 2430 |
name = "TEAMS DISTRIBUTE PARALLEL DO"; break; |
| 2431 |
case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: |
| 2432 |
name = "TEAMS DISTRIBUTE PARALLEL DO SIMD"; break; |
| 2433 |
case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD: name = "TEAMS DISTRIBUTE SIMD"; break; |
| 2434 |
case EXEC_OMP_TEAMS_LOOP: name = "TEAMS LOOP"; break; |
| 2435 |
case EXEC_OMP_TILE: name = "TILE"; break; |
| 2436 |
case EXEC_OMP_UNROLL: name = "UNROLL"; break; |
| 2437 |
case EXEC_OMP_WORKSHARE: name = "WORKSHARE"; break; |
| 2438 |
default: |
| 2439 |
gcc_unreachable (); |
| 2440 |
} |
| 2441 |
fprintf (dumpfile, "!$%s %s", is_oacc ? "ACC" : "OMP", name); |
| 2442 |
switch (c->op) |
| 2443 |
{ |
| 2444 |
case EXEC_OACC_PARALLEL_LOOP: |
| 2445 |
case EXEC_OACC_PARALLEL: |
| 2446 |
case EXEC_OACC_KERNELS_LOOP: |
| 2447 |
case EXEC_OACC_KERNELS: |
| 2448 |
case EXEC_OACC_SERIAL_LOOP: |
| 2449 |
case EXEC_OACC_SERIAL: |
| 2450 |
case EXEC_OACC_DATA: |
| 2451 |
case EXEC_OACC_HOST_DATA: |
| 2452 |
case EXEC_OACC_LOOP: |
| 2453 |
case EXEC_OACC_UPDATE: |
| 2454 |
case EXEC_OACC_WAIT: |
| 2455 |
case EXEC_OACC_CACHE: |
| 2456 |
case EXEC_OACC_ENTER_DATA: |
| 2457 |
case EXEC_OACC_EXIT_DATA: |
| 2458 |
case EXEC_OMP_ALLOCATE: |
| 2459 |
case EXEC_OMP_ALLOCATORS: |
| 2460 |
case EXEC_OMP_ASSUME: |
| 2461 |
case EXEC_OMP_CANCEL: |
| 2462 |
case EXEC_OMP_CANCELLATION_POINT: |
| 2463 |
case EXEC_OMP_DISPATCH: |
| 2464 |
case EXEC_OMP_DISTRIBUTE: |
| 2465 |
case EXEC_OMP_DISTRIBUTE_PARALLEL_DO: |
| 2466 |
case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD: |
| 2467 |
case EXEC_OMP_DISTRIBUTE_SIMD: |
| 2468 |
case EXEC_OMP_DO: |
| 2469 |
case EXEC_OMP_DO_SIMD: |
| 2470 |
case EXEC_OMP_ERROR: |
| 2471 |
case EXEC_OMP_INTEROP: |
| 2472 |
case EXEC_OMP_LOOP: |
| 2473 |
case EXEC_OMP_ORDERED: |
| 2474 |
case EXEC_OMP_MASKED: |
| 2475 |
case EXEC_OMP_PARALLEL: |
| 2476 |
case EXEC_OMP_PARALLEL_DO: |
| 2477 |
case EXEC_OMP_PARALLEL_DO_SIMD: |
| 2478 |
case EXEC_OMP_PARALLEL_LOOP: |
| 2479 |
case EXEC_OMP_PARALLEL_MASKED: |
| 2480 |
case EXEC_OMP_PARALLEL_MASKED_TASKLOOP: |
| 2481 |
case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD: |
| 2482 |
case EXEC_OMP_PARALLEL_MASTER: |
| 2483 |
case EXEC_OMP_PARALLEL_MASTER_TASKLOOP: |
| 2484 |
case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD: |
| 2485 |
case EXEC_OMP_PARALLEL_SECTIONS: |
| 2486 |
case EXEC_OMP_PARALLEL_WORKSHARE: |
| 2487 |
case EXEC_OMP_SCAN: |
| 2488 |
case EXEC_OMP_SCOPE: |
| 2489 |
case EXEC_OMP_SECTIONS: |
| 2490 |
case EXEC_OMP_SIMD: |
| 2491 |
case EXEC_OMP_SINGLE: |
| 2492 |
case EXEC_OMP_TARGET: |
| 2493 |
case EXEC_OMP_TARGET_DATA: |
| 2494 |
case EXEC_OMP_TARGET_ENTER_DATA: |
| 2495 |
case EXEC_OMP_TARGET_EXIT_DATA: |
| 2496 |
case EXEC_OMP_TARGET_PARALLEL: |
| 2497 |
case EXEC_OMP_TARGET_PARALLEL_DO: |
| 2498 |
case EXEC_OMP_TARGET_PARALLEL_DO_SIMD: |
| 2499 |
case EXEC_OMP_TARGET_PARALLEL_LOOP: |
| 2500 |
case EXEC_OMP_TARGET_SIMD: |
| 2501 |
case EXEC_OMP_TARGET_TEAMS: |
| 2502 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE: |
| 2503 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO: |
| 2504 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: |
| 2505 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD: |
| 2506 |
case EXEC_OMP_TARGET_TEAMS_LOOP: |
| 2507 |
case EXEC_OMP_TARGET_UPDATE: |
| 2508 |
case EXEC_OMP_TASK: |
| 2509 |
case EXEC_OMP_TASKLOOP: |
| 2510 |
case EXEC_OMP_TASKLOOP_SIMD: |
| 2511 |
case EXEC_OMP_TEAMS: |
| 2512 |
case EXEC_OMP_TEAMS_DISTRIBUTE: |
| 2513 |
case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO: |
| 2514 |
case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: |
| 2515 |
case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD: |
| 2516 |
case EXEC_OMP_TEAMS_LOOP: |
| 2517 |
case EXEC_OMP_TILE: |
| 2518 |
case EXEC_OMP_UNROLL: |
| 2519 |
case EXEC_OMP_WORKSHARE: |
| 2520 |
omp_clauses = c->ext.omp_clauses; |
| 2521 |
break; |
| 2522 |
case EXEC_OMP_CRITICAL: |
| 2523 |
omp_clauses = c->ext.omp_clauses; |
| 2524 |
if (omp_clauses) |
| 2525 |
fprintf (dumpfile, " (%s)", c->ext.omp_clauses->critical_name); |
| 2526 |
break; |
| 2527 |
case EXEC_OMP_DEPOBJ: |
| 2528 |
omp_clauses = c->ext.omp_clauses; |
| 2529 |
if (omp_clauses) |
| 2530 |
{ |
| 2531 |
fputc ('(', dumpfile); |
| 2532 |
show_expr (c->ext.omp_clauses->depobj); |
| 2533 |
fputc (')', dumpfile); |
| 2534 |
} |
| 2535 |
break; |
| 2536 |
case EXEC_OMP_FLUSH: |
| 2537 |
if (c->ext.omp_namelist) |
| 2538 |
{ |
| 2539 |
fputs (" (", dumpfile); |
| 2540 |
show_omp_namelist (OMP_LIST_NUM, c->ext.omp_namelist); |
| 2541 |
fputc (')', dumpfile); |
| 2542 |
} |
| 2543 |
return; |
| 2544 |
case EXEC_OMP_BARRIER: |
| 2545 |
case EXEC_OMP_TASKWAIT: |
| 2546 |
case EXEC_OMP_TASKYIELD: |
| 2547 |
return; |
| 2548 |
case EXEC_OACC_ATOMIC: |
| 2549 |
case EXEC_OMP_ATOMIC: |
| 2550 |
omp_clauses = c->block ? c->block->ext.omp_clauses : NULL; |
| 2551 |
break; |
| 2552 |
default: |
| 2553 |
break; |
| 2554 |
} |
| 2555 |
if (omp_clauses) |
| 2556 |
show_omp_clauses (omp_clauses); |
| 2557 |
fputc ('\n', dumpfile); |
| 2558 |
|
| 2559 |
/* OpenMP and OpenACC executable directives don't have associated blocks. */ |
| 2560 |
if (c->op == EXEC_OACC_CACHE || c->op == EXEC_OACC_UPDATE |
| 2561 |
|| c->op == EXEC_OACC_ENTER_DATA || c->op == EXEC_OACC_EXIT_DATA |
| 2562 |
|| c->op == EXEC_OMP_TARGET_UPDATE || c->op == EXEC_OMP_TARGET_ENTER_DATA |
| 2563 |
|| c->op == EXEC_OMP_TARGET_EXIT_DATA || c->op == EXEC_OMP_SCAN |
| 2564 |
|| c->op == EXEC_OMP_DEPOBJ || c->op == EXEC_OMP_ERROR |
| 2565 |
|| c->op == EXEC_OMP_INTEROP |
| 2566 |
|| (c->op == EXEC_OMP_ORDERED && c->block == NULL)) |
| 2567 |
return; |
| 2568 |
if (c->op == EXEC_OMP_SECTIONS || c->op == EXEC_OMP_PARALLEL_SECTIONS) |
| 2569 |
{ |
| 2570 |
gfc_code *d = c->block; |
| 2571 |
while (d != NULL) |
| 2572 |
{ |
| 2573 |
show_code (level + 1, d->next); |
| 2574 |
if (d->block == NULL) |
| 2575 |
break; |
| 2576 |
code_indent (level, 0); |
| 2577 |
fputs ("!$OMP SECTION\n", dumpfile); |
| 2578 |
d = d->block; |
| 2579 |
} |
| 2580 |
} |
| 2581 |
else if (c->op == EXEC_OMP_METADIRECTIVE) |
| 2582 |
{ |
| 2583 |
gfc_omp_variant *variant = c->ext.omp_variants; |
| 2584 |
|
| 2585 |
while (variant) |
| 2586 |
{ |
| 2587 |
code_indent (level + 1, 0); |
| 2588 |
if (variant->selectors) |
| 2589 |
fputs ("WHEN ()\n", dumpfile); |
| 2590 |
else |
| 2591 |
fputs ("DEFAULT ()\n", dumpfile); |
| 2592 |
/* TODO: Print selector. */ |
| 2593 |
show_code (level + 2, variant->code); |
| 2594 |
if (variant->next) |
| 2595 |
fputs ("\n", dumpfile); |
| 2596 |
variant = variant->next; |
| 2597 |
} |
| 2598 |
} |
| 2599 |
else |
| 2600 |
show_code (level + 1, c->block->next); |
| 2601 |
if (c->op == EXEC_OMP_ATOMIC) |
| 2602 |
return; |
| 2603 |
fputc ('\n', dumpfile); |
| 2604 |
code_indent (level, 0); |
| 2605 |
fprintf (dumpfile, "!$%s END %s", is_oacc ? "ACC" : "OMP", name); |
| 2606 |
if (c->op == EXEC_OMP_CRITICAL && c->ext.omp_clauses) |
| 2607 |
fprintf (dumpfile, " (%s)", c->ext.omp_clauses->critical_name); |
| 2608 |
} |
| 2609 |
|
| 2610 |
|
| 2611 |
/* Show a single code node and everything underneath it if necessary. */ |
| 2612 |
|
| 2613 |
static void |
| 2614 |
show_code_node (int level, gfc_code *c) |
| 2615 |
{ |
| 2616 |
gfc_forall_iterator *fa; |
| 2617 |
gfc_open *open; |
| 2618 |
gfc_case *cp; |
| 2619 |
gfc_alloc *a; |
| 2620 |
gfc_code *d; |
| 2621 |
gfc_close *close; |
| 2622 |
gfc_filepos *fp; |
| 2623 |
gfc_inquire *i; |
| 2624 |
gfc_dt *dt; |
| 2625 |
gfc_namespace *ns; |
| 2626 |
|
| 2627 |
if (c->here) |
| 2628 |
{ |
| 2629 |
fputc ('\n', dumpfile); |
| 2630 |
code_indent (level, c->here); |
| 2631 |
} |
| 2632 |
else |
| 2633 |
show_indent (); |
| 2634 |
|
| 2635 |
switch (c->op) |
| 2636 |
{ |
| 2637 |
case EXEC_END_PROCEDURE: |
| 2638 |
break; |
| 2639 |
|
| 2640 |
case EXEC_NOP: |
| 2641 |
fputs ("NOP", dumpfile); |
| 2642 |
break; |
| 2643 |
|
| 2644 |
case EXEC_CONTINUE: |
| 2645 |
fputs ("CONTINUE", dumpfile); |
| 2646 |
break; |
| 2647 |
|
| 2648 |
case EXEC_ENTRY: |
| 2649 |
fprintf (dumpfile, "ENTRY %s", c->ext.entry->sym->name); |
| 2650 |
break; |
| 2651 |
|
| 2652 |
case EXEC_INIT_ASSIGN: |
| 2653 |
case EXEC_ASSIGN: |
| 2654 |
fputs ("ASSIGN ", dumpfile); |
| 2655 |
show_expr (c->expr1); |
| 2656 |
fputc (' ', dumpfile); |
| 2657 |
show_expr (c->expr2); |
| 2658 |
break; |
| 2659 |
|
| 2660 |
case EXEC_LABEL_ASSIGN: |
| 2661 |
fputs ("LABEL ASSIGN ", dumpfile); |
| 2662 |
show_expr (c->expr1); |
| 2663 |
fprintf (dumpfile, " %d", c->label1->value); |
| 2664 |
break; |
| 2665 |
|
| 2666 |
case EXEC_POINTER_ASSIGN: |
| 2667 |
fputs ("POINTER ASSIGN ", dumpfile); |
| 2668 |
show_expr (c->expr1); |
| 2669 |
fputc (' ', dumpfile); |
| 2670 |
show_expr (c->expr2); |
| 2671 |
break; |
| 2672 |
|
| 2673 |
case EXEC_GOTO: |
| 2674 |
fputs ("GOTO ", dumpfile); |
| 2675 |
if (c->label1) |
| 2676 |
fprintf (dumpfile, "%d", c->label1->value); |
| 2677 |
else |
| 2678 |
{ |
| 2679 |
show_expr (c->expr1); |
| 2680 |
d = c->block; |
| 2681 |
if (d != NULL) |
| 2682 |
{ |
| 2683 |
fputs (", (", dumpfile); |
| 2684 |
for (; d; d = d ->block) |
| 2685 |
{ |
| 2686 |
code_indent (level, d->label1); |
| 2687 |
if (d->block != NULL) |
| 2688 |
fputc (',', dumpfile); |
| 2689 |
else |
| 2690 |
fputc (')', dumpfile); |
| 2691 |
} |
| 2692 |
} |
| 2693 |
} |
| 2694 |
break; |
| 2695 |
|
| 2696 |
case EXEC_CALL: |
| 2697 |
case EXEC_ASSIGN_CALL: |
| 2698 |
if (c->resolved_sym) |
| 2699 |
fprintf (dumpfile, "CALL %s ", c->resolved_sym->name); |
| 2700 |
else if (c->symtree) |
| 2701 |
fprintf (dumpfile, "CALL %s ", c->symtree->name); |
| 2702 |
else |
| 2703 |
fputs ("CALL ?? ", dumpfile); |
| 2704 |
|
| 2705 |
show_actual_arglist (c->ext.actual); |
| 2706 |
break; |
| 2707 |
|
| 2708 |
case EXEC_COMPCALL: |
| 2709 |
fputs ("CALL ", dumpfile); |
| 2710 |
show_compcall (c->expr1); |
| 2711 |
break; |
| 2712 |
|
| 2713 |
case EXEC_CALL_PPC: |
| 2714 |
fputs ("CALL ", dumpfile); |
| 2715 |
show_expr (c->expr1); |
| 2716 |
show_actual_arglist (c->ext.actual); |
| 2717 |
break; |
| 2718 |
|
| 2719 |
case EXEC_RETURN: |
| 2720 |
fputs ("RETURN ", dumpfile); |
| 2721 |
if (c->expr1) |
| 2722 |
show_expr (c->expr1); |
| 2723 |
break; |
| 2724 |
|
| 2725 |
case EXEC_PAUSE: |
| 2726 |
fputs ("PAUSE ", dumpfile); |
| 2727 |
|
| 2728 |
if (c->expr1 != NULL) |
| 2729 |
show_expr (c->expr1); |
| 2730 |
else |
| 2731 |
fprintf (dumpfile, "%d", c->ext.stop_code); |
| 2732 |
|
| 2733 |
break; |
| 2734 |
|
| 2735 |
case EXEC_ERROR_STOP: |
| 2736 |
fputs ("ERROR ", dumpfile); |
| 2737 |
/* Fall through. */ |
| 2738 |
|
| 2739 |
case EXEC_STOP: |
| 2740 |
fputs ("STOP ", dumpfile); |
| 2741 |
|
| 2742 |
if (c->expr1 != NULL) |
| 2743 |
show_expr (c->expr1); |
| 2744 |
else |
| 2745 |
fprintf (dumpfile, "%d", c->ext.stop_code); |
| 2746 |
if (c->expr2 != NULL) |
| 2747 |
{ |
| 2748 |
fputs (" QUIET=", dumpfile); |
| 2749 |
show_expr (c->expr2); |
| 2750 |
} |
| 2751 |
|
| 2752 |
break; |
| 2753 |
|
| 2754 |
case EXEC_FAIL_IMAGE: |
| 2755 |
fputs ("FAIL IMAGE ", dumpfile); |
| 2756 |
break; |
| 2757 |
|
| 2758 |
case EXEC_CHANGE_TEAM: |
| 2759 |
fputs ("CHANGE TEAM", dumpfile); |
| 2760 |
break; |
| 2761 |
|
| 2762 |
case EXEC_END_TEAM: |
| 2763 |
fputs ("END TEAM", dumpfile); |
| 2764 |
break; |
| 2765 |
|
| 2766 |
case EXEC_FORM_TEAM: |
| 2767 |
fputs ("FORM TEAM", dumpfile); |
| 2768 |
break; |
| 2769 |
|
| 2770 |
case EXEC_SYNC_TEAM: |
| 2771 |
fputs ("SYNC TEAM", dumpfile); |
| 2772 |
break; |
| 2773 |
|
| 2774 |
case EXEC_SYNC_ALL: |
| 2775 |
fputs ("SYNC ALL ", dumpfile); |
| 2776 |
if (c->expr2 != NULL) |
| 2777 |
{ |
| 2778 |
fputs (" stat=", dumpfile); |
| 2779 |
show_expr (c->expr2); |
| 2780 |
} |
| 2781 |
if (c->expr3 != NULL) |
| 2782 |
{ |
| 2783 |
fputs (" errmsg=", dumpfile); |
| 2784 |
show_expr (c->expr3); |
| 2785 |
} |
| 2786 |
break; |
| 2787 |
|
| 2788 |
case EXEC_SYNC_MEMORY: |
| 2789 |
fputs ("SYNC MEMORY ", dumpfile); |
| 2790 |
if (c->expr2 != NULL) |
| 2791 |
{ |
| 2792 |
fputs (" stat=", dumpfile); |
| 2793 |
show_expr (c->expr2); |
| 2794 |
} |
| 2795 |
if (c->expr3 != NULL) |
| 2796 |
{ |
| 2797 |
fputs (" errmsg=", dumpfile); |
| 2798 |
show_expr (c->expr3); |
| 2799 |
} |
| 2800 |
break; |
| 2801 |
|
| 2802 |
case EXEC_SYNC_IMAGES: |
| 2803 |
fputs ("SYNC IMAGES image-set=", dumpfile); |
| 2804 |
if (c->expr1 != NULL) |
| 2805 |
show_expr (c->expr1); |
| 2806 |
else |
| 2807 |
fputs ("* ", dumpfile); |
| 2808 |
if (c->expr2 != NULL) |
| 2809 |
{ |
| 2810 |
fputs (" stat=", dumpfile); |
| 2811 |
show_expr (c->expr2); |
| 2812 |
} |
| 2813 |
if (c->expr3 != NULL) |
| 2814 |
{ |
| 2815 |
fputs (" errmsg=", dumpfile); |
| 2816 |
show_expr (c->expr3); |
| 2817 |
} |
| 2818 |
break; |
| 2819 |
|
| 2820 |
case EXEC_EVENT_POST: |
| 2821 |
case EXEC_EVENT_WAIT: |
| 2822 |
if (c->op == EXEC_EVENT_POST) |
| 2823 |
fputs ("EVENT POST ", dumpfile); |
| 2824 |
else |
| 2825 |
fputs ("EVENT WAIT ", dumpfile); |
| 2826 |
|
| 2827 |
fputs ("event-variable=", dumpfile); |
| 2828 |
if (c->expr1 != NULL) |
| 2829 |
show_expr (c->expr1); |
| 2830 |
if (c->expr4 != NULL) |
| 2831 |
{ |
| 2832 |
fputs (" until_count=", dumpfile); |
| 2833 |
show_expr (c->expr4); |
| 2834 |
} |
| 2835 |
if (c->expr2 != NULL) |
| 2836 |
{ |
| 2837 |
fputs (" stat=", dumpfile); |
| 2838 |
show_expr (c->expr2); |
| 2839 |
} |
| 2840 |
if (c->expr3 != NULL) |
| 2841 |
{ |
| 2842 |
fputs (" errmsg=", dumpfile); |
| 2843 |
show_expr (c->expr3); |
| 2844 |
} |
| 2845 |
break; |
| 2846 |
|
| 2847 |
case EXEC_LOCK: |
| 2848 |
case EXEC_UNLOCK: |
| 2849 |
if (c->op == EXEC_LOCK) |
| 2850 |
fputs ("LOCK ", dumpfile); |
| 2851 |
else |
| 2852 |
fputs ("UNLOCK ", dumpfile); |
| 2853 |
|
| 2854 |
fputs ("lock-variable=", dumpfile); |
| 2855 |
if (c->expr1 != NULL) |
| 2856 |
show_expr (c->expr1); |
| 2857 |
if (c->expr4 != NULL) |
| 2858 |
{ |
| 2859 |
fputs (" acquired_lock=", dumpfile); |
| 2860 |
show_expr (c->expr4); |
| 2861 |
} |
| 2862 |
if (c->expr2 != NULL) |
| 2863 |
{ |
| 2864 |
fputs (" stat=", dumpfile); |
| 2865 |
show_expr (c->expr2); |
| 2866 |
} |
| 2867 |
if (c->expr3 != NULL) |
| 2868 |
{ |
| 2869 |
fputs (" errmsg=", dumpfile); |
| 2870 |
show_expr (c->expr3); |
| 2871 |
} |
| 2872 |
break; |
| 2873 |
|
| 2874 |
case EXEC_ARITHMETIC_IF: |
| 2875 |
fputs ("IF ", dumpfile); |
| 2876 |
show_expr (c->expr1); |
| 2877 |
fprintf (dumpfile, " %d, %d, %d", |
| 2878 |
c->label1->value, c->label2->value, c->label3->value); |
| 2879 |
break; |
| 2880 |
|
| 2881 |
case EXEC_IF: |
| 2882 |
d = c->block; |
| 2883 |
fputs ("IF ", dumpfile); |
| 2884 |
show_expr (d->expr1); |
| 2885 |
|
| 2886 |
++show_level; |
| 2887 |
show_code (level + 1, d->next); |
| 2888 |
--show_level; |
| 2889 |
|
| 2890 |
d = d->block; |
| 2891 |
for (; d; d = d->block) |
| 2892 |
{ |
| 2893 |
fputs("\n", dumpfile); |
| 2894 |
code_indent (level, 0); |
| 2895 |
if (d->expr1 == NULL) |
| 2896 |
fputs ("ELSE", dumpfile); |
| 2897 |
else |
| 2898 |
{ |
| 2899 |
fputs ("ELSE IF ", dumpfile); |
| 2900 |
show_expr (d->expr1); |
| 2901 |
} |
| 2902 |
|
| 2903 |
++show_level; |
| 2904 |
show_code (level + 1, d->next); |
| 2905 |
--show_level; |
| 2906 |
} |
| 2907 |
|
| 2908 |
if (c->label1) |
| 2909 |
code_indent (level, c->label1); |
| 2910 |
else |
| 2911 |
show_indent (); |
| 2912 |
|
| 2913 |
fputs ("ENDIF", dumpfile); |
| 2914 |
break; |
| 2915 |
|
| 2916 |
case EXEC_BLOCK: |
| 2917 |
{ |
| 2918 |
const char *blocktype, *sname = NULL; |
| 2919 |
gfc_namespace *saved_ns; |
| 2920 |
gfc_association_list *alist; |
| 2921 |
|
| 2922 |
if (c->ext.block.ns && c->ext.block.ns->code |
| 2923 |
&& c->ext.block.ns->code->op == EXEC_SELECT_TYPE) |
| 2924 |
{ |
| 2925 |
gfc_expr *fcn = c->ext.block.ns->code->expr1; |
| 2926 |
blocktype = "SELECT TYPE"; |
| 2927 |
/* expr1 is _loc(assoc_name->vptr) */ |
| 2928 |
if (fcn && fcn->expr_type == EXPR_FUNCTION) |
| 2929 |
sname = fcn->value.function.actual->expr->symtree->n.sym->name; |
| 2930 |
} |
| 2931 |
else if (c->ext.block.assoc) |
| 2932 |
blocktype = "ASSOCIATE"; |
| 2933 |
else |
| 2934 |
blocktype = "BLOCK"; |
| 2935 |
show_indent (); |
| 2936 |
fprintf (dumpfile, "%s ", blocktype); |
| 2937 |
for (alist = c->ext.block.assoc; alist; alist = alist->next) |
| 2938 |
{ |
| 2939 |
fprintf (dumpfile, " %s = ", sname ? sname : alist->name); |
| 2940 |
show_expr (alist->target); |
| 2941 |
} |
| 2942 |
|
| 2943 |
++show_level; |
| 2944 |
ns = c->ext.block.ns; |
| 2945 |
saved_ns = gfc_current_ns; |
| 2946 |
gfc_current_ns = ns; |
| 2947 |
gfc_traverse_symtree (ns->sym_root, show_symtree); |
| 2948 |
gfc_current_ns = saved_ns; |
| 2949 |
show_code (show_level, ns->code); |
| 2950 |
--show_level; |
| 2951 |
show_indent (); |
| 2952 |
fprintf (dumpfile, "END %s ", blocktype); |
| 2953 |
break; |
| 2954 |
} |
| 2955 |
|
| 2956 |
case EXEC_END_BLOCK: |
| 2957 |
/* Only come here when there is a label on an |
| 2958 |
END ASSOCIATE construct. */ |
| 2959 |
break; |
| 2960 |
|
| 2961 |
case EXEC_SELECT: |
| 2962 |
case EXEC_SELECT_TYPE: |
| 2963 |
case EXEC_SELECT_RANK: |
| 2964 |
d = c->block; |
| 2965 |
fputc ('\n', dumpfile); |
| 2966 |
code_indent (level, 0); |
| 2967 |
if (c->op == EXEC_SELECT_RANK) |
| 2968 |
fputs ("SELECT RANK ", dumpfile); |
| 2969 |
else if (c->op == EXEC_SELECT_TYPE) |
| 2970 |
fputs ("SELECT CASE ", dumpfile); // Preceded by SELECT TYPE construct |
| 2971 |
else |
| 2972 |
fputs ("SELECT CASE ", dumpfile); |
| 2973 |
show_expr (c->expr1); |
| 2974 |
|
| 2975 |
for (; d; d = d->block) |
| 2976 |
{ |
| 2977 |
fputc ('\n', dumpfile); |
| 2978 |
code_indent (level, 0); |
| 2979 |
fputs ("CASE ", dumpfile); |
| 2980 |
for (cp = d->ext.block.case_list; cp; cp = cp->next) |
| 2981 |
{ |
| 2982 |
fputc ('(', dumpfile); |
| 2983 |
show_expr (cp->low); |
| 2984 |
fputc (' ', dumpfile); |
| 2985 |
show_expr (cp->high); |
| 2986 |
fputc (')', dumpfile); |
| 2987 |
fputc (' ', dumpfile); |
| 2988 |
} |
| 2989 |
|
| 2990 |
show_code (level + 1, d->next); |
| 2991 |
fputc ('\n', dumpfile); |
| 2992 |
} |
| 2993 |
|
| 2994 |
code_indent (level, c->label1); |
| 2995 |
fputs ("END SELECT", dumpfile); |
| 2996 |
break; |
| 2997 |
|
| 2998 |
case EXEC_WHERE: |
| 2999 |
fputs ("WHERE ", dumpfile); |
| 3000 |
|
| 3001 |
d = c->block; |
| 3002 |
show_expr (d->expr1); |
| 3003 |
fputc ('\n', dumpfile); |
| 3004 |
|
| 3005 |
show_code (level + 1, d->next); |
| 3006 |
|
| 3007 |
for (d = d->block; d; d = d->block) |
| 3008 |
{ |
| 3009 |
code_indent (level, 0); |
| 3010 |
fputs ("ELSE WHERE ", dumpfile); |
| 3011 |
show_expr (d->expr1); |
| 3012 |
fputc ('\n', dumpfile); |
| 3013 |
show_code (level + 1, d->next); |
| 3014 |
} |
| 3015 |
|
| 3016 |
code_indent (level, 0); |
| 3017 |
fputs ("END WHERE", dumpfile); |
| 3018 |
break; |
| 3019 |
|
| 3020 |
|
| 3021 |
case EXEC_FORALL: |
| 3022 |
fputs ("FORALL ", dumpfile); |
| 3023 |
for (fa = c->ext.concur.forall_iterator; fa; fa = fa->next) |
| 3024 |
{ |
| 3025 |
show_expr (fa->var); |
| 3026 |
fputc (' ', dumpfile); |
| 3027 |
show_expr (fa->start); |
| 3028 |
fputc (':', dumpfile); |
| 3029 |
show_expr (fa->end); |
| 3030 |
fputc (':', dumpfile); |
| 3031 |
show_expr (fa->stride); |
| 3032 |
|
| 3033 |
if (fa->next != NULL) |
| 3034 |
fputc (',', dumpfile); |
| 3035 |
} |
| 3036 |
|
| 3037 |
if (c->expr1 != NULL) |
| 3038 |
{ |
| 3039 |
fputc (',', dumpfile); |
| 3040 |
show_expr (c->expr1); |
| 3041 |
} |
| 3042 |
fputc ('\n', dumpfile); |
| 3043 |
|
| 3044 |
show_code (level + 1, c->block->next); |
| 3045 |
|
| 3046 |
code_indent (level, 0); |
| 3047 |
fputs ("END FORALL", dumpfile); |
| 3048 |
break; |
| 3049 |
|
| 3050 |
case EXEC_CRITICAL: |
| 3051 |
fputs ("CRITICAL\n", dumpfile); |
| 3052 |
show_code (level + 1, c->block->next); |
| 3053 |
code_indent (level, 0); |
| 3054 |
fputs ("END CRITICAL", dumpfile); |
| 3055 |
break; |
| 3056 |
|
| 3057 |
case EXEC_DO: |
| 3058 |
fputs ("DO ", dumpfile); |
| 3059 |
if (c->label1) |
| 3060 |
fprintf (dumpfile, " %-5d ", c->label1->value); |
| 3061 |
|
| 3062 |
show_expr (c->ext.iterator->var); |
| 3063 |
fputc ('=', dumpfile); |
| 3064 |
show_expr (c->ext.iterator->start); |
| 3065 |
fputc (' ', dumpfile); |
| 3066 |
show_expr (c->ext.iterator->end); |
| 3067 |
fputc (' ', dumpfile); |
| 3068 |
show_expr (c->ext.iterator->step); |
| 3069 |
|
| 3070 |
++show_level; |
| 3071 |
show_code (level + 1, c->block->next); |
| 3072 |
--show_level; |
| 3073 |
|
| 3074 |
if (c->label1) |
| 3075 |
break; |
| 3076 |
|
| 3077 |
show_indent (); |
| 3078 |
fputs ("END DO", dumpfile); |
| 3079 |
break; |
| 3080 |
|
| 3081 |
case EXEC_DO_CONCURRENT: |
| 3082 |
fputs ("DO CONCURRENT ", dumpfile); |
| 3083 |
for (fa = c->ext.concur.forall_iterator; fa; fa = fa->next) |
| 3084 |
{ |
| 3085 |
show_expr (fa->var); |
| 3086 |
fputc (' ', dumpfile); |
| 3087 |
show_expr (fa->start); |
| 3088 |
fputc (':', dumpfile); |
| 3089 |
show_expr (fa->end); |
| 3090 |
fputc (':', dumpfile); |
| 3091 |
show_expr (fa->stride); |
| 3092 |
|
| 3093 |
if (fa->next != NULL) |
| 3094 |
fputc (',', dumpfile); |
| 3095 |
} |
| 3096 |
|
| 3097 |
if (c->expr1 != NULL) |
| 3098 |
{ |
| 3099 |
fputc (',', dumpfile); |
| 3100 |
show_expr (c->expr1); |
| 3101 |
} |
| 3102 |
|
| 3103 |
if (c->ext.concur.locality[LOCALITY_LOCAL]) |
| 3104 |
{ |
| 3105 |
fputs (" LOCAL (", dumpfile); |
| 3106 |
|
| 3107 |
for (gfc_expr_list *el = c->ext.concur.locality[LOCALITY_LOCAL]; |
| 3108 |
el; el = el->next) |
| 3109 |
{ |
| 3110 |
show_expr (el->expr); |
| 3111 |
if (el->next) |
| 3112 |
fputc (',', dumpfile); |
| 3113 |
} |
| 3114 |
fputc (')', dumpfile); |
| 3115 |
} |
| 3116 |
|
| 3117 |
if (c->ext.concur.locality[LOCALITY_LOCAL_INIT]) |
| 3118 |
{ |
| 3119 |
fputs (" LOCAL_INIT (", dumpfile); |
| 3120 |
for (gfc_expr_list *el = c->ext.concur.locality[LOCALITY_LOCAL_INIT]; |
| 3121 |
el; el = el->next) |
| 3122 |
{ |
| 3123 |
show_expr (el->expr); |
| 3124 |
if (el->next) |
| 3125 |
fputc (',', dumpfile); |
| 3126 |
} |
| 3127 |
fputc (')', dumpfile); |
| 3128 |
} |
| 3129 |
|
| 3130 |
if (c->ext.concur.locality[LOCALITY_SHARED]) |
| 3131 |
{ |
| 3132 |
fputs (" SHARED (", dumpfile); |
| 3133 |
for (gfc_expr_list *el = c->ext.concur.locality[LOCALITY_SHARED]; |
| 3134 |
el; el = el->next) |
| 3135 |
{ |
| 3136 |
show_expr (el->expr); |
| 3137 |
if (el->next) |
| 3138 |
fputc (',', dumpfile); |
| 3139 |
} |
| 3140 |
fputc (')', dumpfile); |
| 3141 |
} |
| 3142 |
|
| 3143 |
if (c->ext.concur.default_none) |
| 3144 |
{ |
| 3145 |
fputs (" DEFAULT (NONE)", dumpfile); |
| 3146 |
} |
| 3147 |
|
| 3148 |
if (c->ext.concur.locality[LOCALITY_REDUCE]) |
| 3149 |
{ |
| 3150 |
gfc_expr_list *el = c->ext.concur.locality[LOCALITY_REDUCE]; |
| 3151 |
while (el) |
| 3152 |
{ |
| 3153 |
fputs (" REDUCE (", dumpfile); |
| 3154 |
if (el->expr) |
| 3155 |
{ |
| 3156 |
if (el->expr->expr_type == EXPR_FUNCTION) |
| 3157 |
{ |
| 3158 |
const char *name; |
| 3159 |
switch (el->expr->value.function.isym->id) |
| 3160 |
{ |
| 3161 |
case GFC_ISYM_MIN: |
| 3162 |
name = "MIN"; |
| 3163 |
break; |
| 3164 |
case GFC_ISYM_MAX: |
| 3165 |
name = "MAX"; |
| 3166 |
break; |
| 3167 |
case GFC_ISYM_IAND: |
| 3168 |
name = "IAND"; |
| 3169 |
break; |
| 3170 |
case GFC_ISYM_IOR: |
| 3171 |
name = "IOR"; |
| 3172 |
break; |
| 3173 |
case GFC_ISYM_IEOR: |
| 3174 |
name = "IEOR"; |
| 3175 |
break; |
| 3176 |
default: |
| 3177 |
gcc_unreachable (); |
| 3178 |
} |
| 3179 |
fputs (name, dumpfile); |
| 3180 |
} |
| 3181 |
else |
| 3182 |
show_expr (el->expr); |
| 3183 |
} |
| 3184 |
else |
| 3185 |
{ |
| 3186 |
fputs ("(NULL)", dumpfile); |
| 3187 |
} |
| 3188 |
|
| 3189 |
fputc (':', dumpfile); |
| 3190 |
el = el->next; |
| 3191 |
|
| 3192 |
while (el && el->expr && el->expr->expr_type == EXPR_VARIABLE) |
| 3193 |
{ |
| 3194 |
show_expr (el->expr); |
| 3195 |
el = el->next; |
| 3196 |
if (el && el->expr && el->expr->expr_type == EXPR_VARIABLE) |
| 3197 |
fputc (',', dumpfile); |
| 3198 |
} |
| 3199 |
|
| 3200 |
fputc (')', dumpfile); |
| 3201 |
} |
| 3202 |
} |
| 3203 |
|
| 3204 |
++show_level; |
| 3205 |
|
| 3206 |
show_code (level + 1, c->block->next); |
| 3207 |
--show_level; |
| 3208 |
code_indent (level, c->label1); |
| 3209 |
show_indent (); |
| 3210 |
fputs ("END DO", dumpfile); |
| 3211 |
break; |
| 3212 |
|
| 3213 |
case EXEC_DO_WHILE: |
| 3214 |
fputs ("DO WHILE ", dumpfile); |
| 3215 |
show_expr (c->expr1); |
| 3216 |
fputc ('\n', dumpfile); |
| 3217 |
|
| 3218 |
show_code (level + 1, c->block->next); |
| 3219 |
|
| 3220 |
code_indent (level, c->label1); |
| 3221 |
fputs ("END DO", dumpfile); |
| 3222 |
break; |
| 3223 |
|
| 3224 |
case EXEC_CYCLE: |
| 3225 |
fputs ("CYCLE", dumpfile); |
| 3226 |
if (c->symtree) |
| 3227 |
fprintf (dumpfile, " %s", c->symtree->n.sym->name); |
| 3228 |
break; |
| 3229 |
|
| 3230 |
case EXEC_EXIT: |
| 3231 |
fputs ("EXIT", dumpfile); |
| 3232 |
if (c->symtree) |
| 3233 |
fprintf (dumpfile, " %s", c->symtree->n.sym->name); |
| 3234 |
break; |
| 3235 |
|
| 3236 |
case EXEC_ALLOCATE: |
| 3237 |
fputs ("ALLOCATE ", dumpfile); |
| 3238 |
if (c->expr1) |
| 3239 |
{ |
| 3240 |
fputs (" STAT=", dumpfile); |
| 3241 |
show_expr (c->expr1); |
| 3242 |
} |
| 3243 |
|
| 3244 |
if (c->expr2) |
| 3245 |
{ |
| 3246 |
fputs (" ERRMSG=", dumpfile); |
| 3247 |
show_expr (c->expr2); |
| 3248 |
} |
| 3249 |
|
| 3250 |
if (c->expr3) |
| 3251 |
{ |
| 3252 |
if (c->expr3->mold) |
| 3253 |
fputs (" MOLD=", dumpfile); |
| 3254 |
else |
| 3255 |
fputs (" SOURCE=", dumpfile); |
| 3256 |
show_expr (c->expr3); |
| 3257 |
} |
| 3258 |
|
| 3259 |
for (a = c->ext.alloc.list; a; a = a->next) |
| 3260 |
{ |
| 3261 |
fputc (' ', dumpfile); |
| 3262 |
show_expr (a->expr); |
| 3263 |
} |
| 3264 |
|
| 3265 |
break; |
| 3266 |
|
| 3267 |
case EXEC_DEALLOCATE: |
| 3268 |
fputs ("DEALLOCATE ", dumpfile); |
| 3269 |
if (c->expr1) |
| 3270 |
{ |
| 3271 |
fputs (" STAT=", dumpfile); |
| 3272 |
show_expr (c->expr1); |
| 3273 |
} |
| 3274 |
|
| 3275 |
if (c->expr2) |
| 3276 |
{ |
| 3277 |
fputs (" ERRMSG=", dumpfile); |
| 3278 |
show_expr (c->expr2); |
| 3279 |
} |
| 3280 |
|
| 3281 |
for (a = c->ext.alloc.list; a; a = a->next) |
| 3282 |
{ |
| 3283 |
fputc (' ', dumpfile); |
| 3284 |
show_expr (a->expr); |
| 3285 |
} |
| 3286 |
|
| 3287 |
break; |
| 3288 |
|
| 3289 |
case EXEC_OPEN: |
| 3290 |
fputs ("OPEN", dumpfile); |
| 3291 |
open = c->ext.open; |
| 3292 |
|
| 3293 |
if (open->unit) |
| 3294 |
{ |
| 3295 |
fputs (" UNIT=", dumpfile); |
| 3296 |
show_expr (open->unit); |
| 3297 |
} |
| 3298 |
if (open->iomsg) |
| 3299 |
{ |
| 3300 |
fputs (" IOMSG=", dumpfile); |
| 3301 |
show_expr (open->iomsg); |
| 3302 |
} |
| 3303 |
if (open->iostat) |
| 3304 |
{ |
| 3305 |
fputs (" IOSTAT=", dumpfile); |
| 3306 |
show_expr (open->iostat); |
| 3307 |
} |
| 3308 |
if (open->file) |
| 3309 |
{ |
| 3310 |
fputs (" FILE=", dumpfile); |
| 3311 |
show_expr (open->file); |
| 3312 |
} |
| 3313 |
if (open->status) |
| 3314 |
{ |
| 3315 |
fputs (" STATUS=", dumpfile); |
| 3316 |
show_expr (open->status); |
| 3317 |
} |
| 3318 |
if (open->access) |
| 3319 |
{ |
| 3320 |
fputs (" ACCESS=", dumpfile); |
| 3321 |
show_expr (open->access); |
| 3322 |
} |
| 3323 |
if (open->form) |
| 3324 |
{ |
| 3325 |
fputs (" FORM=", dumpfile); |
| 3326 |
show_expr (open->form); |
| 3327 |
} |
| 3328 |
if (open->recl) |
| 3329 |
{ |
| 3330 |
fputs (" RECL=", dumpfile); |
| 3331 |
show_expr (open->recl); |
| 3332 |
} |
| 3333 |
if (open->blank) |
| 3334 |
{ |
| 3335 |
fputs (" BLANK=", dumpfile); |
| 3336 |
show_expr (open->blank); |
| 3337 |
} |
| 3338 |
if (open->position) |
| 3339 |
{ |
| 3340 |
fputs (" POSITION=", dumpfile); |
| 3341 |
show_expr (open->position); |
| 3342 |
} |
| 3343 |
if (open->action) |
| 3344 |
{ |
| 3345 |
fputs (" ACTION=", dumpfile); |
| 3346 |
show_expr (open->action); |
| 3347 |
} |
| 3348 |
if (open->delim) |
| 3349 |
{ |
| 3350 |
fputs (" DELIM=", dumpfile); |
| 3351 |
show_expr (open->delim); |
| 3352 |
} |
| 3353 |
if (open->pad) |
| 3354 |
{ |
| 3355 |
fputs (" PAD=", dumpfile); |
| 3356 |
show_expr (open->pad); |
| 3357 |
} |
| 3358 |
if (open->decimal) |
| 3359 |
{ |
| 3360 |
fputs (" DECIMAL=", dumpfile); |
| 3361 |
show_expr (open->decimal); |
| 3362 |
} |
| 3363 |
if (open->encoding) |
| 3364 |
{ |
| 3365 |
fputs (" ENCODING=", dumpfile); |
| 3366 |
show_expr (open->encoding); |
| 3367 |
} |
| 3368 |
if (open->round) |
| 3369 |
{ |
| 3370 |
fputs (" ROUND=", dumpfile); |
| 3371 |
show_expr (open->round); |
| 3372 |
} |
| 3373 |
if (open->sign) |
| 3374 |
{ |
| 3375 |
fputs (" SIGN=", dumpfile); |
| 3376 |
show_expr (open->sign); |
| 3377 |
} |
| 3378 |
if (open->convert) |
| 3379 |
{ |
| 3380 |
fputs (" CONVERT=", dumpfile); |
| 3381 |
show_expr (open->convert); |
| 3382 |
} |
| 3383 |
if (open->asynchronous) |
| 3384 |
{ |
| 3385 |
fputs (" ASYNCHRONOUS=", dumpfile); |
| 3386 |
show_expr (open->asynchronous); |
| 3387 |
} |
| 3388 |
if (open->err != NULL) |
| 3389 |
fprintf (dumpfile, " ERR=%d", open->err->value); |
| 3390 |
|
| 3391 |
break; |
| 3392 |
|
| 3393 |
case EXEC_CLOSE: |
| 3394 |
fputs ("CLOSE", dumpfile); |
| 3395 |
close = c->ext.close; |
| 3396 |
|
| 3397 |
if (close->unit) |
| 3398 |
{ |
| 3399 |
fputs (" UNIT=", dumpfile); |
| 3400 |
show_expr (close->unit); |
| 3401 |
} |
| 3402 |
if (close->iomsg) |
| 3403 |
{ |
| 3404 |
fputs (" IOMSG=", dumpfile); |
| 3405 |
show_expr (close->iomsg); |
| 3406 |
} |
| 3407 |
if (close->iostat) |
| 3408 |
{ |
| 3409 |
fputs (" IOSTAT=", dumpfile); |
| 3410 |
show_expr (close->iostat); |
| 3411 |
} |
| 3412 |
if (close->status) |
| 3413 |
{ |
| 3414 |
fputs (" STATUS=", dumpfile); |
| 3415 |
show_expr (close->status); |
| 3416 |
} |
| 3417 |
if (close->err != NULL) |
| 3418 |
fprintf (dumpfile, " ERR=%d", close->err->value); |
| 3419 |
break; |
| 3420 |
|
| 3421 |
case EXEC_BACKSPACE: |
| 3422 |
fputs ("BACKSPACE", dumpfile); |
| 3423 |
goto show_filepos; |
| 3424 |
|
| 3425 |
case EXEC_ENDFILE: |
| 3426 |
fputs ("ENDFILE", dumpfile); |
| 3427 |
goto show_filepos; |
| 3428 |
|
| 3429 |
case EXEC_REWIND: |
| 3430 |
fputs ("REWIND", dumpfile); |
| 3431 |
goto show_filepos; |
| 3432 |
|
| 3433 |
case EXEC_FLUSH: |
| 3434 |
fputs ("FLUSH", dumpfile); |
| 3435 |
|
| 3436 |
show_filepos: |
| 3437 |
fp = c->ext.filepos; |
| 3438 |
|
| 3439 |
if (fp->unit) |
| 3440 |
{ |
| 3441 |
fputs (" UNIT=", dumpfile); |
| 3442 |
show_expr (fp->unit); |
| 3443 |
} |
| 3444 |
if (fp->iomsg) |
| 3445 |
{ |
| 3446 |
fputs (" IOMSG=", dumpfile); |
| 3447 |
show_expr (fp->iomsg); |
| 3448 |
} |
| 3449 |
if (fp->iostat) |
| 3450 |
{ |
| 3451 |
fputs (" IOSTAT=", dumpfile); |
| 3452 |
show_expr (fp->iostat); |
| 3453 |
} |
| 3454 |
if (fp->err != NULL) |
| 3455 |
fprintf (dumpfile, " ERR=%d", fp->err->value); |
| 3456 |
break; |
| 3457 |
|
| 3458 |
case EXEC_INQUIRE: |
| 3459 |
fputs ("INQUIRE", dumpfile); |
| 3460 |
i = c->ext.inquire; |
| 3461 |
|
| 3462 |
if (i->unit) |
| 3463 |
{ |
| 3464 |
fputs (" UNIT=", dumpfile); |
| 3465 |
show_expr (i->unit); |
| 3466 |
} |
| 3467 |
if (i->file) |
| 3468 |
{ |
| 3469 |
fputs (" FILE=", dumpfile); |
| 3470 |
show_expr (i->file); |
| 3471 |
} |
| 3472 |
|
| 3473 |
if (i->iomsg) |
| 3474 |
{ |
| 3475 |
fputs (" IOMSG=", dumpfile); |
| 3476 |
show_expr (i->iomsg); |
| 3477 |
} |
| 3478 |
if (i->iostat) |
| 3479 |
{ |
| 3480 |
fputs (" IOSTAT=", dumpfile); |
| 3481 |
show_expr (i->iostat); |
| 3482 |
} |
| 3483 |
if (i->exist) |
| 3484 |
{ |
| 3485 |
fputs (" EXIST=", dumpfile); |
| 3486 |
show_expr (i->exist); |
| 3487 |
} |
| 3488 |
if (i->opened) |
| 3489 |
{ |
| 3490 |
fputs (" OPENED=", dumpfile); |
| 3491 |
show_expr (i->opened); |
| 3492 |
} |
| 3493 |
if (i->number) |
| 3494 |
{ |
| 3495 |
fputs (" NUMBER=", dumpfile); |
| 3496 |
show_expr (i->number); |
| 3497 |
} |
| 3498 |
if (i->named) |
| 3499 |
{ |
| 3500 |
fputs (" NAMED=", dumpfile); |
| 3501 |
show_expr (i->named); |
| 3502 |
} |
| 3503 |
if (i->name) |
| 3504 |
{ |
| 3505 |
fputs (" NAME=", dumpfile); |
| 3506 |
show_expr (i->name); |
| 3507 |
} |
| 3508 |
if (i->access) |
| 3509 |
{ |
| 3510 |
fputs (" ACCESS=", dumpfile); |
| 3511 |
show_expr (i->access); |
| 3512 |
} |
| 3513 |
if (i->sequential) |
| 3514 |
{ |
| 3515 |
fputs (" SEQUENTIAL=", dumpfile); |
| 3516 |
show_expr (i->sequential); |
| 3517 |
} |
| 3518 |
|
| 3519 |
if (i->direct) |
| 3520 |
{ |
| 3521 |
fputs (" DIRECT=", dumpfile); |
| 3522 |
show_expr (i->direct); |
| 3523 |
} |
| 3524 |
if (i->form) |
| 3525 |
{ |
| 3526 |
fputs (" FORM=", dumpfile); |
| 3527 |
show_expr (i->form); |
| 3528 |
} |
| 3529 |
if (i->formatted) |
| 3530 |
{ |
| 3531 |
fputs (" FORMATTED", dumpfile); |
| 3532 |
show_expr (i->formatted); |
| 3533 |
} |
| 3534 |
if (i->unformatted) |
| 3535 |
{ |
| 3536 |
fputs (" UNFORMATTED=", dumpfile); |
| 3537 |
show_expr (i->unformatted); |
| 3538 |
} |
| 3539 |
if (i->recl) |
| 3540 |
{ |
| 3541 |
fputs (" RECL=", dumpfile); |
| 3542 |
show_expr (i->recl); |
| 3543 |
} |
| 3544 |
if (i->nextrec) |
| 3545 |
{ |
| 3546 |
fputs (" NEXTREC=", dumpfile); |
| 3547 |
show_expr (i->nextrec); |
| 3548 |
} |
| 3549 |
if (i->blank) |
| 3550 |
{ |
| 3551 |
fputs (" BLANK=", dumpfile); |
| 3552 |
show_expr (i->blank); |
| 3553 |
} |
| 3554 |
if (i->position) |
| 3555 |
{ |
| 3556 |
fputs (" POSITION=", dumpfile); |
| 3557 |
show_expr (i->position); |
| 3558 |
} |
| 3559 |
if (i->action) |
| 3560 |
{ |
| 3561 |
fputs (" ACTION=", dumpfile); |
| 3562 |
show_expr (i->action); |
| 3563 |
} |
| 3564 |
if (i->read) |
| 3565 |
{ |
| 3566 |
fputs (" READ=", dumpfile); |
| 3567 |
show_expr (i->read); |
| 3568 |
} |
| 3569 |
if (i->write) |
| 3570 |
{ |
| 3571 |
fputs (" WRITE=", dumpfile); |
| 3572 |
show_expr (i->write); |
| 3573 |
} |
| 3574 |
if (i->readwrite) |
| 3575 |
{ |
| 3576 |
fputs (" READWRITE=", dumpfile); |
| 3577 |
show_expr (i->readwrite); |
| 3578 |
} |
| 3579 |
if (i->delim) |
| 3580 |
{ |
| 3581 |
fputs (" DELIM=", dumpfile); |
| 3582 |
show_expr (i->delim); |
| 3583 |
} |
| 3584 |
if (i->pad) |
| 3585 |
{ |
| 3586 |
fputs (" PAD=", dumpfile); |
| 3587 |
show_expr (i->pad); |
| 3588 |
} |
| 3589 |
if (i->convert) |
| 3590 |
{ |
| 3591 |
fputs (" CONVERT=", dumpfile); |
| 3592 |
show_expr (i->convert); |
| 3593 |
} |
| 3594 |
if (i->asynchronous) |
| 3595 |
{ |
| 3596 |
fputs (" ASYNCHRONOUS=", dumpfile); |
| 3597 |
show_expr (i->asynchronous); |
| 3598 |
} |
| 3599 |
if (i->decimal) |
| 3600 |
{ |
| 3601 |
fputs (" DECIMAL=", dumpfile); |
| 3602 |
show_expr (i->decimal); |
| 3603 |
} |
| 3604 |
if (i->encoding) |
| 3605 |
{ |
| 3606 |
fputs (" ENCODING=", dumpfile); |
| 3607 |
show_expr (i->encoding); |
| 3608 |
} |
| 3609 |
if (i->pending) |
| 3610 |
{ |
| 3611 |
fputs (" PENDING=", dumpfile); |
| 3612 |
show_expr (i->pending); |
| 3613 |
} |
| 3614 |
if (i->round) |
| 3615 |
{ |
| 3616 |
fputs (" ROUND=", dumpfile); |
| 3617 |
show_expr (i->round); |
| 3618 |
} |
| 3619 |
if (i->sign) |
| 3620 |
{ |
| 3621 |
fputs (" SIGN=", dumpfile); |
| 3622 |
show_expr (i->sign); |
| 3623 |
} |
| 3624 |
if (i->size) |
| 3625 |
{ |
| 3626 |
fputs (" SIZE=", dumpfile); |
| 3627 |
show_expr (i->size); |
| 3628 |
} |
| 3629 |
if (i->id) |
| 3630 |
{ |
| 3631 |
fputs (" ID=", dumpfile); |
| 3632 |
show_expr (i->id); |
| 3633 |
} |
| 3634 |
|
| 3635 |
if (i->err != NULL) |
| 3636 |
fprintf (dumpfile, " ERR=%d", i->err->value); |
| 3637 |
break; |
| 3638 |
|
| 3639 |
case EXEC_IOLENGTH: |
| 3640 |
fputs ("IOLENGTH ", dumpfile); |
| 3641 |
show_expr (c->expr1); |
| 3642 |
goto show_dt_code; |
| 3643 |
break; |
| 3644 |
|
| 3645 |
case EXEC_READ: |
| 3646 |
fputs ("READ", dumpfile); |
| 3647 |
goto show_dt; |
| 3648 |
|
| 3649 |
case EXEC_WRITE: |
| 3650 |
fputs ("WRITE", dumpfile); |
| 3651 |
|
| 3652 |
show_dt: |
| 3653 |
dt = c->ext.dt; |
| 3654 |
if (dt->io_unit) |
| 3655 |
{ |
| 3656 |
fputs (" UNIT=", dumpfile); |
| 3657 |
show_expr (dt->io_unit); |
| 3658 |
} |
| 3659 |
|
| 3660 |
if (dt->format_expr) |
| 3661 |
{ |
| 3662 |
fputs (" FMT=", dumpfile); |
| 3663 |
show_expr (dt->format_expr); |
| 3664 |
} |
| 3665 |
|
| 3666 |
if (dt->format_label != NULL) |
| 3667 |
fprintf (dumpfile, " FMT=%d", dt->format_label->value); |
| 3668 |
if (dt->namelist) |
| 3669 |
fprintf (dumpfile, " NML=%s", dt->namelist->name); |
| 3670 |
|
| 3671 |
if (dt->iomsg) |
| 3672 |
{ |
| 3673 |
fputs (" IOMSG=", dumpfile); |
| 3674 |
show_expr (dt->iomsg); |
| 3675 |
} |
| 3676 |
if (dt->iostat) |
| 3677 |
{ |
| 3678 |
fputs (" IOSTAT=", dumpfile); |
| 3679 |
show_expr (dt->iostat); |
| 3680 |
} |
| 3681 |
if (dt->size) |
| 3682 |
{ |
| 3683 |
fputs (" SIZE=", dumpfile); |
| 3684 |
show_expr (dt->size); |
| 3685 |
} |
| 3686 |
if (dt->rec) |
| 3687 |
{ |
| 3688 |
fputs (" REC=", dumpfile); |
| 3689 |
show_expr (dt->rec); |
| 3690 |
} |
| 3691 |
if (dt->advance) |
| 3692 |
{ |
| 3693 |
fputs (" ADVANCE=", dumpfile); |
| 3694 |
show_expr (dt->advance); |
| 3695 |
} |
| 3696 |
if (dt->id) |
| 3697 |
{ |
| 3698 |
fputs (" ID=", dumpfile); |
| 3699 |
show_expr (dt->id); |
| 3700 |
} |
| 3701 |
if (dt->pos) |
| 3702 |
{ |
| 3703 |
fputs (" POS=", dumpfile); |
| 3704 |
show_expr (dt->pos); |
| 3705 |
} |
| 3706 |
if (dt->asynchronous) |
| 3707 |
{ |
| 3708 |
fputs (" ASYNCHRONOUS=", dumpfile); |
| 3709 |
show_expr (dt->asynchronous); |
| 3710 |
} |
| 3711 |
if (dt->blank) |
| 3712 |
{ |
| 3713 |
fputs (" BLANK=", dumpfile); |
| 3714 |
show_expr (dt->blank); |
| 3715 |
} |
| 3716 |
if (dt->decimal) |
| 3717 |
{ |
| 3718 |
fputs (" DECIMAL=", dumpfile); |
| 3719 |
show_expr (dt->decimal); |
| 3720 |
} |
| 3721 |
if (dt->delim) |
| 3722 |
{ |
| 3723 |
fputs (" DELIM=", dumpfile); |
| 3724 |
show_expr (dt->delim); |
| 3725 |
} |
| 3726 |
if (dt->pad) |
| 3727 |
{ |
| 3728 |
fputs (" PAD=", dumpfile); |
| 3729 |
show_expr (dt->pad); |
| 3730 |
} |
| 3731 |
if (dt->round) |
| 3732 |
{ |
| 3733 |
fputs (" ROUND=", dumpfile); |
| 3734 |
show_expr (dt->round); |
| 3735 |
} |
| 3736 |
if (dt->sign) |
| 3737 |
{ |
| 3738 |
fputs (" SIGN=", dumpfile); |
| 3739 |
show_expr (dt->sign); |
| 3740 |
} |
| 3741 |
|
| 3742 |
show_dt_code: |
| 3743 |
for (c = c->block->next; c; c = c->next) |
| 3744 |
show_code_node (level + (c->next != NULL), c); |
| 3745 |
return; |
| 3746 |
|
| 3747 |
case EXEC_TRANSFER: |
| 3748 |
fputs ("TRANSFER ", dumpfile); |
| 3749 |
show_expr (c->expr1); |
| 3750 |
break; |
| 3751 |
|
| 3752 |
case EXEC_DT_END: |
| 3753 |
fputs ("DT_END", dumpfile); |
| 3754 |
dt = c->ext.dt; |
| 3755 |
|
| 3756 |
if (dt->err != NULL) |
| 3757 |
fprintf (dumpfile, " ERR=%d", dt->err->value); |
| 3758 |
if (dt->end != NULL) |
| 3759 |
fprintf (dumpfile, " END=%d", dt->end->value); |
| 3760 |
if (dt->eor != NULL) |
| 3761 |
fprintf (dumpfile, " EOR=%d", dt->eor->value); |
| 3762 |
break; |
| 3763 |
|
| 3764 |
case EXEC_WAIT: |
| 3765 |
fputs ("WAIT", dumpfile); |
| 3766 |
|
| 3767 |
if (c->ext.wait != NULL) |
| 3768 |
{ |
| 3769 |
gfc_wait *wait = c->ext.wait; |
| 3770 |
if (wait->unit) |
| 3771 |
{ |
| 3772 |
fputs (" UNIT=", dumpfile); |
| 3773 |
show_expr (wait->unit); |
| 3774 |
} |
| 3775 |
if (wait->iostat) |
| 3776 |
{ |
| 3777 |
fputs (" IOSTAT=", dumpfile); |
| 3778 |
show_expr (wait->iostat); |
| 3779 |
} |
| 3780 |
if (wait->iomsg) |
| 3781 |
{ |
| 3782 |
fputs (" IOMSG=", dumpfile); |
| 3783 |
show_expr (wait->iomsg); |
| 3784 |
} |
| 3785 |
if (wait->id) |
| 3786 |
{ |
| 3787 |
fputs (" ID=", dumpfile); |
| 3788 |
show_expr (wait->id); |
| 3789 |
} |
| 3790 |
if (wait->err) |
| 3791 |
fprintf (dumpfile, " ERR=%d", wait->err->value); |
| 3792 |
if (wait->end) |
| 3793 |
fprintf (dumpfile, " END=%d", wait->end->value); |
| 3794 |
if (wait->eor) |
| 3795 |
fprintf (dumpfile, " EOR=%d", wait->eor->value); |
| 3796 |
} |
| 3797 |
break; |
| 3798 |
|
| 3799 |
case EXEC_OACC_PARALLEL_LOOP: |
| 3800 |
case EXEC_OACC_PARALLEL: |
| 3801 |
case EXEC_OACC_KERNELS_LOOP: |
| 3802 |
case EXEC_OACC_KERNELS: |
| 3803 |
case EXEC_OACC_SERIAL_LOOP: |
| 3804 |
case EXEC_OACC_SERIAL: |
| 3805 |
case EXEC_OACC_DATA: |
| 3806 |
case EXEC_OACC_HOST_DATA: |
| 3807 |
case EXEC_OACC_LOOP: |
| 3808 |
case EXEC_OACC_UPDATE: |
| 3809 |
case EXEC_OACC_WAIT: |
| 3810 |
case EXEC_OACC_CACHE: |
| 3811 |
case EXEC_OACC_ENTER_DATA: |
| 3812 |
case EXEC_OACC_EXIT_DATA: |
| 3813 |
case EXEC_OMP_ALLOCATE: |
| 3814 |
case EXEC_OMP_ALLOCATORS: |
| 3815 |
case EXEC_OMP_ASSUME: |
| 3816 |
case EXEC_OMP_ATOMIC: |
| 3817 |
case EXEC_OMP_CANCEL: |
| 3818 |
case EXEC_OMP_CANCELLATION_POINT: |
| 3819 |
case EXEC_OMP_BARRIER: |
| 3820 |
case EXEC_OMP_CRITICAL: |
| 3821 |
case EXEC_OMP_DEPOBJ: |
| 3822 |
case EXEC_OMP_DISPATCH: |
| 3823 |
case EXEC_OMP_DISTRIBUTE: |
| 3824 |
case EXEC_OMP_DISTRIBUTE_PARALLEL_DO: |
| 3825 |
case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD: |
| 3826 |
case EXEC_OMP_DISTRIBUTE_SIMD: |
| 3827 |
case EXEC_OMP_DO: |
| 3828 |
case EXEC_OMP_DO_SIMD: |
| 3829 |
case EXEC_OMP_ERROR: |
| 3830 |
case EXEC_OMP_INTEROP: |
| 3831 |
case EXEC_OMP_FLUSH: |
| 3832 |
case EXEC_OMP_LOOP: |
| 3833 |
case EXEC_OMP_MASKED: |
| 3834 |
case EXEC_OMP_MASKED_TASKLOOP: |
| 3835 |
case EXEC_OMP_MASKED_TASKLOOP_SIMD: |
| 3836 |
case EXEC_OMP_MASTER: |
| 3837 |
case EXEC_OMP_MASTER_TASKLOOP: |
| 3838 |
case EXEC_OMP_MASTER_TASKLOOP_SIMD: |
| 3839 |
case EXEC_OMP_METADIRECTIVE: |
| 3840 |
case EXEC_OMP_ORDERED: |
| 3841 |
case EXEC_OMP_PARALLEL: |
| 3842 |
case EXEC_OMP_PARALLEL_DO: |
| 3843 |
case EXEC_OMP_PARALLEL_DO_SIMD: |
| 3844 |
case EXEC_OMP_PARALLEL_LOOP: |
| 3845 |
case EXEC_OMP_PARALLEL_MASKED: |
| 3846 |
case EXEC_OMP_PARALLEL_MASKED_TASKLOOP: |
| 3847 |
case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD: |
| 3848 |
case EXEC_OMP_PARALLEL_MASTER: |
| 3849 |
case EXEC_OMP_PARALLEL_MASTER_TASKLOOP: |
| 3850 |
case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD: |
| 3851 |
case EXEC_OMP_PARALLEL_SECTIONS: |
| 3852 |
case EXEC_OMP_PARALLEL_WORKSHARE: |
| 3853 |
case EXEC_OMP_SCAN: |
| 3854 |
case EXEC_OMP_SCOPE: |
| 3855 |
case EXEC_OMP_SECTIONS: |
| 3856 |
case EXEC_OMP_SIMD: |
| 3857 |
case EXEC_OMP_SINGLE: |
| 3858 |
case EXEC_OMP_TARGET: |
| 3859 |
case EXEC_OMP_TARGET_DATA: |
| 3860 |
case EXEC_OMP_TARGET_ENTER_DATA: |
| 3861 |
case EXEC_OMP_TARGET_EXIT_DATA: |
| 3862 |
case EXEC_OMP_TARGET_PARALLEL: |
| 3863 |
case EXEC_OMP_TARGET_PARALLEL_DO: |
| 3864 |
case EXEC_OMP_TARGET_PARALLEL_DO_SIMD: |
| 3865 |
case EXEC_OMP_TARGET_PARALLEL_LOOP: |
| 3866 |
case EXEC_OMP_TARGET_SIMD: |
| 3867 |
case EXEC_OMP_TARGET_TEAMS: |
| 3868 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE: |
| 3869 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO: |
| 3870 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: |
| 3871 |
case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD: |
| 3872 |
case EXEC_OMP_TARGET_TEAMS_LOOP: |
| 3873 |
case EXEC_OMP_TARGET_UPDATE: |
| 3874 |
case EXEC_OMP_TASK: |
| 3875 |
case EXEC_OMP_TASKGROUP: |
| 3876 |
case EXEC_OMP_TASKLOOP: |
| 3877 |
case EXEC_OMP_TASKLOOP_SIMD: |
| 3878 |
case EXEC_OMP_TASKWAIT: |
| 3879 |
case EXEC_OMP_TASKYIELD: |
| 3880 |
case EXEC_OMP_TEAMS: |
| 3881 |
case EXEC_OMP_TEAMS_DISTRIBUTE: |
| 3882 |
case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO: |
| 3883 |
case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: |
| 3884 |
case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD: |
| 3885 |
case EXEC_OMP_TEAMS_LOOP: |
| 3886 |
case EXEC_OMP_TILE: |
| 3887 |
case EXEC_OMP_UNROLL: |
| 3888 |
case EXEC_OMP_WORKSHARE: |
| 3889 |
show_omp_node (level, c); |
| 3890 |
break; |
| 3891 |
|
| 3892 |
default: |
| 3893 |
gfc_internal_error ("show_code_node(): Bad statement code"); |
| 3894 |
} |
| 3895 |
} |
| 3896 |
|
| 3897 |
|
| 3898 |
/* Show an equivalence chain. */ |
| 3899 |
|
| 3900 |
static void |
| 3901 |
show_equiv (gfc_equiv *eq) |
| 3902 |
{ |
| 3903 |
show_indent (); |
| 3904 |
fputs ("Equivalence: ", dumpfile); |
| 3905 |
while (eq) |
| 3906 |
{ |
| 3907 |
show_expr (eq->expr); |
| 3908 |
eq = eq->eq; |
| 3909 |
if (eq) |
| 3910 |
fputs (", ", dumpfile); |
| 3911 |
} |
| 3912 |
} |
| 3913 |
|
| 3914 |
|
| 3915 |
/* Show a freakin' whole namespace. */ |
| 3916 |
|
| 3917 |
static void |
| 3918 |
show_namespace (gfc_namespace *ns) |
| 3919 |
{ |
| 3920 |
gfc_interface *intr; |
| 3921 |
gfc_namespace *save; |
| 3922 |
int op; |
| 3923 |
gfc_equiv *eq; |
| 3924 |
int i; |
| 3925 |
|
| 3926 |
gcc_assert (ns); |
| 3927 |
save = gfc_current_ns; |
| 3928 |
|
| 3929 |
show_indent (); |
| 3930 |
fputs ("Namespace:", dumpfile); |
| 3931 |
|
| 3932 |
i = 0; |
| 3933 |
do |
| 3934 |
{ |
| 3935 |
int l = i; |
| 3936 |
while (i < GFC_LETTERS - 1 |
| 3937 |
&& gfc_compare_types (&ns->default_type[i+1], |
| 3938 |
&ns->default_type[l])) |
| 3939 |
i++; |
| 3940 |
|
| 3941 |
if (i > l) |
| 3942 |
fprintf (dumpfile, " %c-%c: ", l+'A', i+'A'); |
| 3943 |
else |
| 3944 |
fprintf (dumpfile, " %c: ", l+'A'); |
| 3945 |
|
| 3946 |
show_typespec(&ns->default_type[l]); |
| 3947 |
i++; |
| 3948 |
} while (i < GFC_LETTERS); |
| 3949 |
|
| 3950 |
if (ns->proc_name != NULL) |
| 3951 |
{ |
| 3952 |
show_indent (); |
| 3953 |
fprintf (dumpfile, "procedure name = %s", ns->proc_name->name); |
| 3954 |
} |
| 3955 |
|
| 3956 |
++show_level; |
| 3957 |
gfc_current_ns = ns; |
| 3958 |
gfc_traverse_symtree (ns->common_root, show_common); |
| 3959 |
|
| 3960 |
gfc_traverse_symtree (ns->sym_root, show_symtree); |
| 3961 |
|
| 3962 |
for (op = GFC_INTRINSIC_BEGIN; op != GFC_INTRINSIC_END; op++) |
| 3963 |
{ |
| 3964 |
/* User operator interfaces */ |
| 3965 |
intr = ns->op[op]; |
| 3966 |
if (intr == NULL) |
| 3967 |
continue; |
| 3968 |
|
| 3969 |
show_indent (); |
| 3970 |
fprintf (dumpfile, "Operator interfaces for %s:", |
| 3971 |
gfc_op2string ((gfc_intrinsic_op) op)); |
| 3972 |
|
| 3973 |
for (; intr; intr = intr->next) |
| 3974 |
fprintf (dumpfile, " %s", intr->sym->name); |
| 3975 |
} |
| 3976 |
|
| 3977 |
if (ns->uop_root != NULL) |
| 3978 |
{ |
| 3979 |
show_indent (); |
| 3980 |
fputs ("User operators:\n", dumpfile); |
| 3981 |
gfc_traverse_user_op (ns, show_uop); |
| 3982 |
} |
| 3983 |
|
| 3984 |
for (eq = ns->equiv; eq; eq = eq->next) |
| 3985 |
show_equiv (eq); |
| 3986 |
|
| 3987 |
if (ns->oacc_declare) |
| 3988 |
{ |
| 3989 |
struct gfc_oacc_declare *decl; |
| 3990 |
/* Dump !$ACC DECLARE clauses. */ |
| 3991 |
for (decl = ns->oacc_declare; decl; decl = decl->next) |
| 3992 |
{ |
| 3993 |
show_indent (); |
| 3994 |
fprintf (dumpfile, "!$ACC DECLARE"); |
| 3995 |
show_omp_clauses (decl->clauses); |
| 3996 |
} |
| 3997 |
} |
| 3998 |
|
| 3999 |
if (ns->omp_assumes) |
| 4000 |
{ |
| 4001 |
show_indent (); |
| 4002 |
fprintf (dumpfile, "!$OMP ASSUMES"); |
| 4003 |
show_omp_assumes (ns->omp_assumes); |
| 4004 |
} |
| 4005 |
|
| 4006 |
fputc ('\n', dumpfile); |
| 4007 |
show_indent (); |
| 4008 |
fputs ("code:", dumpfile); |
| 4009 |
show_code (show_level, ns->code); |
| 4010 |
--show_level; |
| 4011 |
|
| 4012 |
for (ns = ns->contained; ns; ns = ns->sibling) |
| 4013 |
{ |
| 4014 |
fputs ("\nCONTAINS\n", dumpfile); |
| 4015 |
++show_level; |
| 4016 |
show_namespace (ns); |
| 4017 |
--show_level; |
| 4018 |
} |
| 4019 |
|
| 4020 |
fputc ('\n', dumpfile); |
| 4021 |
gfc_current_ns = save; |
| 4022 |
} |
| 4023 |
|
| 4024 |
|
| 4025 |
/* Main function for dumping a parse tree. */ |
| 4026 |
|
| 4027 |
void |
| 4028 |
gfc_dump_parse_tree (gfc_namespace *ns, FILE *file) |
| 4029 |
{ |
| 4030 |
dumpfile = file; |
| 4031 |
show_namespace (ns); |
| 4032 |
} |
| 4033 |
|
| 4034 |
/* This part writes BIND(C) prototypes and declatations, and prototypes |
| 4035 |
for EXTERNAL preocedures, for use in a C programs. */ |
| 4036 |
|
| 4037 |
static void write_interop_decl (gfc_symbol *); |
| 4038 |
static void write_proc (gfc_symbol *, bool); |
| 4039 |
static void show_external_symbol (gfc_gsymbol *, void *); |
| 4040 |
static void write_type (gfc_symbol *sym); |
| 4041 |
static void write_funptr_fcn (gfc_symbol *); |
| 4042 |
|
| 4043 |
/* Do we need to write out an #include <ISO_Fortran_binding.h> or not? */ |
| 4044 |
|
| 4045 |
static void |
| 4046 |
has_cfi_cdesc (gfc_gsymbol *gsym, void *p) |
| 4047 |
{ |
| 4048 |
bool *data_p = (bool *) p; |
| 4049 |
gfc_formal_arglist *f; |
| 4050 |
gfc_symbol *sym; |
| 4051 |
|
| 4052 |
if (*data_p) |
| 4053 |
return; |
| 4054 |
|
| 4055 |
if (gsym->ns == NULL || gsym->sym_name == NULL ) |
| 4056 |
return; |
| 4057 |
|
| 4058 |
gfc_find_symbol (gsym->sym_name, gsym->ns, 0, &sym); |
| 4059 |
|
| 4060 |
if (sym == NULL || sym->attr.flavor != FL_PROCEDURE || !sym->attr.is_bind_c) |
| 4061 |
return; |
| 4062 |
|
| 4063 |
for (f = sym->formal; f; f = f->next) |
| 4064 |
{ |
| 4065 |
gfc_symbol *s; |
| 4066 |
s = f->sym; |
| 4067 |
if (s->as && (s->as->type == AS_ASSUMED_RANK || s->as->type == AS_ASSUMED_SHAPE)) |
| 4068 |
{ |
| 4069 |
*data_p = true; |
| 4070 |
return; |
| 4071 |
} |
| 4072 |
} |
| 4073 |
} |
| 4074 |
|
| 4075 |
static bool |
| 4076 |
need_iso_fortran_binding () |
| 4077 |
{ |
| 4078 |
bool needs_include = false; |
| 4079 |
|
| 4080 |
if (gfc_gsym_root == NULL) |
| 4081 |
return false; |
| 4082 |
|
| 4083 |
gfc_traverse_gsymbol (gfc_gsym_root, has_cfi_cdesc, (void *) &needs_include); |
| 4084 |
return needs_include; |
| 4085 |
} |
| 4086 |
|
| 4087 |
void |
| 4088 |
gfc_dump_c_prototypes (FILE *file) |
| 4089 |
{ |
| 4090 |
bool bind_c = true; |
| 4091 |
int error_count; |
| 4092 |
gfc_namespace *ns; |
| 4093 |
gfc_get_errors (NULL, &error_count); |
| 4094 |
if (error_count != 0) |
| 4095 |
return; |
| 4096 |
|
| 4097 |
if (gfc_gsym_root == NULL) |
| 4098 |
return; |
| 4099 |
|
| 4100 |
dumpfile = file; |
| 4101 |
if (need_iso_fortran_binding ()) |
| 4102 |
fputs ("#include <ISO_Fortran_binding.h>\n\n", dumpfile); |
| 4103 |
|
| 4104 |
for (ns = gfc_global_ns_list; ns; ns = ns->sibling) |
| 4105 |
gfc_traverse_ns (ns, write_type); |
| 4106 |
|
| 4107 |
gfc_traverse_gsymbol (gfc_gsym_root, show_external_symbol, (void *) &bind_c); |
| 4108 |
} |
| 4109 |
|
| 4110 |
/* Loop over all external symbols, writing out their declarations. */ |
| 4111 |
|
| 4112 |
static bool seen_conflict; |
| 4113 |
|
| 4114 |
void |
| 4115 |
gfc_dump_external_c_prototypes (FILE * file) |
| 4116 |
{ |
| 4117 |
bool bind_c = false; |
| 4118 |
int error_count; |
| 4119 |
|
| 4120 |
gfc_get_errors (NULL, &error_count); |
| 4121 |
if (error_count != 0) |
| 4122 |
return; |
| 4123 |
|
| 4124 |
dumpfile = file; |
| 4125 |
seen_conflict = false; |
| 4126 |
fprintf (dumpfile, |
| 4127 |
_("/* Prototypes for external procedures generated from %s\n" |
| 4128 |
" by GNU Fortran %s%s.\n\n" |
| 4129 |
" Use of this interface is discouraged, consider using the\n" |
| 4130 |
" BIND(C) feature of standard Fortran instead. */\n\n"), |
| 4131 |
gfc_source_file, pkgversion_string, version_string); |
| 4132 |
|
| 4133 |
if (gfc_gsym_root == NULL) |
| 4134 |
return; |
| 4135 |
|
| 4136 |
gfc_traverse_gsymbol (gfc_gsym_root, show_external_symbol, (void *) &bind_c); |
| 4137 |
if (seen_conflict) |
| 4138 |
fprintf (dumpfile, |
| 4139 |
_("\n\n/* WARNING: Because of differing arguments to an external\n" |
| 4140 |
" procedure, this header file is not compatible with -std=c23." |
| 4141 |
"\n\n Use another -std option to compile. */\n")); |
| 4142 |
} |
| 4143 |
|
| 4144 |
/* Callback function for dumping external symbols, be they BIND(C) or |
| 4145 |
external. */ |
| 4146 |
|
| 4147 |
static void |
| 4148 |
show_external_symbol (gfc_gsymbol *gsym, void *data) |
| 4149 |
{ |
| 4150 |
bool bind_c, *data_p; |
| 4151 |
gfc_symbol *sym; |
| 4152 |
const char *name; |
| 4153 |
|
| 4154 |
if (gsym->ns == NULL) |
| 4155 |
return; |
| 4156 |
|
| 4157 |
name = gsym->sym_name ? gsym->sym_name : gsym->name; |
| 4158 |
|
| 4159 |
gfc_find_symbol (name, gsym->ns, 0, &sym); |
| 4160 |
if (sym == NULL) |
| 4161 |
return; |
| 4162 |
|
| 4163 |
data_p = (bool *) data; |
| 4164 |
bind_c = *data_p; |
| 4165 |
|
| 4166 |
if (bind_c) |
| 4167 |
{ |
| 4168 |
if (!sym->attr.is_bind_c) |
| 4169 |
return; |
| 4170 |
|
| 4171 |
write_interop_decl (sym); |
| 4172 |
} |
| 4173 |
else |
| 4174 |
{ |
| 4175 |
if (sym->attr.flavor != FL_PROCEDURE || sym->attr.is_bind_c) |
| 4176 |
return; |
| 4177 |
write_proc (sym, false); |
| 4178 |
} |
| 4179 |
} |
| 4180 |
|
| 4181 |
enum type_return { T_OK=0, T_WARN, T_ERROR }; |
| 4182 |
|
| 4183 |
/* Return the name of the type for later output. Both function pointers and |
| 4184 |
void pointers will be mapped to void *. */ |
| 4185 |
|
| 4186 |
static enum type_return |
| 4187 |
get_c_type_name (gfc_typespec *ts, gfc_array_spec *as, const char **pre, |
| 4188 |
const char **type_name, bool *asterisk, const char **post, |
| 4189 |
bool func_ret) |
| 4190 |
{ |
| 4191 |
static char post_buffer[40]; |
| 4192 |
enum type_return ret; |
| 4193 |
ret = T_ERROR; |
| 4194 |
|
| 4195 |
*pre = " "; |
| 4196 |
*asterisk = false; |
| 4197 |
*post = ""; |
| 4198 |
*type_name = "<error>"; |
| 4199 |
|
| 4200 |
if (as && (as->type == AS_ASSUMED_RANK || as->type == AS_ASSUMED_SHAPE)) |
| 4201 |
{ |
| 4202 |
*asterisk = true; |
| 4203 |
*post = ""; |
| 4204 |
*type_name = "CFI_cdesc_t"; |
| 4205 |
return T_OK; |
| 4206 |
} |
| 4207 |
|
| 4208 |
if (ts->type == BT_REAL || ts->type == BT_INTEGER || ts->type == BT_COMPLEX |
| 4209 |
|| ts->type == BT_UNSIGNED) |
| 4210 |
{ |
| 4211 |
if (ts->is_c_interop && ts->interop_kind) |
| 4212 |
ret = T_OK; |
| 4213 |
else |
| 4214 |
ret = T_WARN; |
| 4215 |
|
| 4216 |
for (int i = 0; i < ISOCBINDING_NUMBER; i++) |
| 4217 |
{ |
| 4218 |
if (c_interop_kinds_table[i].f90_type == ts->type |
| 4219 |
&& c_interop_kinds_table[i].value == ts->kind) |
| 4220 |
{ |
| 4221 |
/* Skip over 'c_'. */ |
| 4222 |
*type_name = c_interop_kinds_table[i].name + 2; |
| 4223 |
if (strcmp (*type_name, "long_long") == 0) |
| 4224 |
*type_name = "long long"; |
| 4225 |
if (strcmp (*type_name, "long_double") == 0) |
| 4226 |
*type_name = "long double"; |
| 4227 |
if (strcmp (*type_name, "signed_char") == 0) |
| 4228 |
*type_name = "signed char"; |
| 4229 |
else if (strcmp (*type_name, "size_t") == 0) |
| 4230 |
*type_name = "ssize_t"; |
| 4231 |
else if (strcmp (*type_name, "float_complex") == 0) |
| 4232 |
*type_name = "__GFORTRAN_FLOAT_COMPLEX"; |
| 4233 |
else if (strcmp (*type_name, "double_complex") == 0) |
| 4234 |
*type_name = "__GFORTRAN_DOUBLE_COMPLEX"; |
| 4235 |
else if (strcmp (*type_name, "long_double_complex") == 0) |
| 4236 |
*type_name = "__GFORTRAN_LONG_DOUBLE_COMPLEX"; |
| 4237 |
else if (strcmp (*type_name, "unsigned") == 0) |
| 4238 |
*type_name = "unsigned int"; |
| 4239 |
else if (strcmp (*type_name, "unsigned_char") == 0) |
| 4240 |
*type_name = "unsigned char"; |
| 4241 |
else if (strcmp (*type_name, "unsigned_short") == 0) |
| 4242 |
*type_name = "unsigned short int"; |
| 4243 |
else if (strcmp (*type_name, "unsigned_long") == 0) |
| 4244 |
*type_name = "unsigned long int"; |
| 4245 |
else if (strcmp (*type_name, "unsigned_long long") == 0) |
| 4246 |
*type_name = "unsigned long long int"; |
| 4247 |
break; |
| 4248 |
} |
| 4249 |
} |
| 4250 |
} |
| 4251 |
else if (ts->type == BT_LOGICAL) |
| 4252 |
{ |
| 4253 |
if (ts->is_c_interop && ts->interop_kind) |
| 4254 |
{ |
| 4255 |
*type_name = "_Bool"; |
| 4256 |
ret = T_OK; |
| 4257 |
} |
| 4258 |
else |
| 4259 |
{ |
| 4260 |
/* Let's select an appropriate int, with a warning. */ |
| 4261 |
for (int i = 0; i < ISOCBINDING_NUMBER; i++) |
| 4262 |
{ |
| 4263 |
if (c_interop_kinds_table[i].f90_type == BT_INTEGER |
| 4264 |
&& c_interop_kinds_table[i].value == ts->kind) |
| 4265 |
{ |
| 4266 |
*type_name = c_interop_kinds_table[i].name + 2; |
| 4267 |
ret = T_WARN; |
| 4268 |
} |
| 4269 |
} |
| 4270 |
} |
| 4271 |
} |
| 4272 |
else if (ts->type == BT_CHARACTER) |
| 4273 |
{ |
| 4274 |
if (ts->is_c_interop) |
| 4275 |
{ |
| 4276 |
*type_name = "char"; |
| 4277 |
ret = T_OK; |
| 4278 |
} |
| 4279 |
else |
| 4280 |
{ |
| 4281 |
if (ts->kind == gfc_default_character_kind) |
| 4282 |
*type_name = "char"; |
| 4283 |
else |
| 4284 |
/* Let's select an appropriate int. */ |
| 4285 |
for (int i = 0; i < ISOCBINDING_NUMBER; i++) |
| 4286 |
{ |
| 4287 |
if (c_interop_kinds_table[i].f90_type == BT_INTEGER |
| 4288 |
&& c_interop_kinds_table[i].value == ts->kind) |
| 4289 |
{ |
| 4290 |
*type_name = c_interop_kinds_table[i].name + 2; |
| 4291 |
break; |
| 4292 |
} |
| 4293 |
} |
| 4294 |
ret = T_WARN; |
| 4295 |
|
| 4296 |
} |
| 4297 |
} |
| 4298 |
else if (ts->type == BT_DERIVED) |
| 4299 |
{ |
| 4300 |
if (ts->u.derived->from_intmod == INTMOD_ISO_C_BINDING) |
| 4301 |
{ |
| 4302 |
if (strcmp (ts->u.derived->name, "c_ptr") == 0) |
| 4303 |
*type_name = "void"; |
| 4304 |
else if (strcmp (ts->u.derived->name, "c_funptr") == 0) |
| 4305 |
{ |
| 4306 |
*type_name = "int "; |
| 4307 |
if (func_ret) |
| 4308 |
{ |
| 4309 |
*pre = "("; |
| 4310 |
*post = "())"; |
| 4311 |
} |
| 4312 |
else |
| 4313 |
{ |
| 4314 |
*pre = "("; |
| 4315 |
*post = ")()"; |
| 4316 |
} |
| 4317 |
} |
| 4318 |
*asterisk = true; |
| 4319 |
ret = T_OK; |
| 4320 |
} |
| 4321 |
else |
| 4322 |
*type_name = ts->u.derived->name; |
| 4323 |
|
| 4324 |
ret = T_OK; |
| 4325 |
} |
| 4326 |
|
| 4327 |
if (ret != T_ERROR && as && as->type == AS_EXPLICIT) |
| 4328 |
{ |
| 4329 |
mpz_t sz; |
| 4330 |
bool size_ok; |
| 4331 |
size_ok = spec_size (as, &sz); |
| 4332 |
if (size_ok) |
| 4333 |
{ |
| 4334 |
gmp_snprintf (post_buffer, sizeof(post_buffer), "[%Zd]", sz); |
| 4335 |
*post = post_buffer; |
| 4336 |
mpz_clear (sz); |
| 4337 |
*asterisk = false; |
| 4338 |
} |
| 4339 |
else |
| 4340 |
*asterisk = true; |
| 4341 |
} |
| 4342 |
return ret; |
| 4343 |
} |
| 4344 |
|
| 4345 |
/* Write out a declaration. */ |
| 4346 |
|
| 4347 |
static void |
| 4348 |
write_decl (gfc_typespec *ts, gfc_array_spec *as, const char *sym_name, |
| 4349 |
bool func_ret, locus *where, bool bind_c) |
| 4350 |
{ |
| 4351 |
const char *pre, *type_name, *post; |
| 4352 |
bool asterisk; |
| 4353 |
enum type_return rok; |
| 4354 |
|
| 4355 |
rok = get_c_type_name (ts, as, &pre, &type_name, &asterisk, &post, func_ret); |
| 4356 |
if (rok == T_ERROR) |
| 4357 |
{ |
| 4358 |
gfc_error_now ("Cannot convert %qs to interoperable type at %L", |
| 4359 |
gfc_typename (ts), where); |
| 4360 |
fprintf (dumpfile, "/* Cannot convert '%s' to interoperable type */", |
| 4361 |
gfc_typename (ts)); |
| 4362 |
return; |
| 4363 |
} |
| 4364 |
fputs (type_name, dumpfile); |
| 4365 |
fputs (pre, dumpfile); |
| 4366 |
if (asterisk) |
| 4367 |
fputs ("*", dumpfile); |
| 4368 |
|
| 4369 |
fputs (sym_name, dumpfile); |
| 4370 |
fputs (post, dumpfile); |
| 4371 |
|
| 4372 |
if (rok == T_WARN && bind_c) |
| 4373 |
fprintf (dumpfile," /* WARNING: Converting '%s' to interoperable type */", |
| 4374 |
gfc_typename (ts)); |
| 4375 |
} |
| 4376 |
|
| 4377 |
/* Write out an interoperable type. It will be written as a typedef |
| 4378 |
for a struct. */ |
| 4379 |
|
| 4380 |
static void |
| 4381 |
write_type (gfc_symbol *sym) |
| 4382 |
{ |
| 4383 |
gfc_component *c; |
| 4384 |
|
| 4385 |
/* Don't dump types that are not interoperable, our very own ISO C Binding |
| 4386 |
module, or vtypes. */ |
| 4387 |
|
| 4388 |
if (sym->from_intmod == INTMOD_ISO_C_BINDING || sym->attr.flavor != FL_DERIVED |
| 4389 |
|| sym->attr.vtype || !sym->attr.is_bind_c) |
| 4390 |
return; |
| 4391 |
|
| 4392 |
fprintf (dumpfile, "typedef struct %s {\n", sym->name); |
| 4393 |
for (c = sym->components; c; c = c->next) |
| 4394 |
{ |
| 4395 |
fputs (" ", dumpfile); |
| 4396 |
write_decl (&(c->ts), c->as, c->name, false, &sym->declared_at, true); |
| 4397 |
fputs (";\n", dumpfile); |
| 4398 |
} |
| 4399 |
|
| 4400 |
fprintf (dumpfile, "} %s;\n\n", sym->name); |
| 4401 |
} |
| 4402 |
|
| 4403 |
/* Write out a variable. */ |
| 4404 |
|
| 4405 |
static void |
| 4406 |
write_variable (gfc_symbol *sym) |
| 4407 |
{ |
| 4408 |
const char *sym_name; |
| 4409 |
|
| 4410 |
gcc_assert (sym->attr.flavor == FL_VARIABLE); |
| 4411 |
|
| 4412 |
if (sym->binding_label) |
| 4413 |
sym_name = sym->binding_label; |
| 4414 |
else |
| 4415 |
sym_name = sym->name; |
| 4416 |
|
| 4417 |
fputs ("extern ", dumpfile); |
| 4418 |
write_decl (&(sym->ts), sym->as, sym_name, false, &sym->declared_at, true); |
| 4419 |
fputs (";\n", dumpfile); |
| 4420 |
} |
| 4421 |
|
| 4422 |
static void |
| 4423 |
write_formal_arglist (gfc_symbol *sym, bool bind_c) |
| 4424 |
{ |
| 4425 |
gfc_formal_arglist *f; |
| 4426 |
|
| 4427 |
for (f = sym->formal; f != NULL; f = f->next) |
| 4428 |
{ |
| 4429 |
enum type_return rok; |
| 4430 |
const char *intent_in; |
| 4431 |
gfc_symbol *s; |
| 4432 |
const char *pre, *type_name, *post; |
| 4433 |
bool asterisk; |
| 4434 |
|
| 4435 |
s = f->sym; |
| 4436 |
rok = get_c_type_name (&(s->ts), s->as, &pre, &type_name, &asterisk, |
| 4437 |
&post, false); |
| 4438 |
/* Procedure arguments have to be converted to function pointers. */ |
| 4439 |
if (s->attr.subroutine) |
| 4440 |
{ |
| 4441 |
fprintf (dumpfile, "void (*%s) (", s->name); |
| 4442 |
if (s->ext_dummy_arglist_mismatch) |
| 4443 |
seen_conflict = true; |
| 4444 |
else |
| 4445 |
write_formal_arglist (s, bind_c); |
| 4446 |
|
| 4447 |
fputc (')', dumpfile); |
| 4448 |
goto next; |
| 4449 |
} |
| 4450 |
|
| 4451 |
if (rok == T_ERROR) |
| 4452 |
{ |
| 4453 |
gfc_error_now ("Cannot convert %qs to interoperable type at %L", |
| 4454 |
gfc_typename (&s->ts), &s->declared_at); |
| 4455 |
fprintf (dumpfile, "/* Cannot convert '%s' to interoperable type */", |
| 4456 |
gfc_typename (&s->ts)); |
| 4457 |
return; |
| 4458 |
} |
| 4459 |
|
| 4460 |
if (s->attr.function) |
| 4461 |
{ |
| 4462 |
fprintf (dumpfile, "%s (*%s) (", type_name, s->name); |
| 4463 |
if (s->ext_dummy_arglist_mismatch) |
| 4464 |
seen_conflict = true; |
| 4465 |
else |
| 4466 |
write_formal_arglist (s, bind_c); |
| 4467 |
|
| 4468 |
fputc (')',dumpfile); |
| 4469 |
goto next; |
| 4470 |
} |
| 4471 |
|
| 4472 |
/* For explicit arrays, we already set the asterisk above. */ |
| 4473 |
if (!s->attr.value && !(s->as && s->as->type == AS_EXPLICIT)) |
| 4474 |
asterisk = true; |
| 4475 |
|
| 4476 |
if (s->attr.intent == INTENT_IN && !s->attr.value) |
| 4477 |
intent_in = "const "; |
| 4478 |
else |
| 4479 |
intent_in = ""; |
| 4480 |
|
| 4481 |
fputs (intent_in, dumpfile); |
| 4482 |
fputs (type_name, dumpfile); |
| 4483 |
fputs (pre, dumpfile); |
| 4484 |
if (asterisk) |
| 4485 |
fputs ("*", dumpfile); |
| 4486 |
|
| 4487 |
fputs (s->name, dumpfile); |
| 4488 |
fputs (post, dumpfile); |
| 4489 |
if (bind_c && rok == T_WARN) |
| 4490 |
fputs(" /* WARNING: non-interoperable KIND */ ", dumpfile); |
| 4491 |
|
| 4492 |
next: |
| 4493 |
if (f->next) |
| 4494 |
fputs(", ", dumpfile); |
| 4495 |
} |
| 4496 |
if (!bind_c) |
| 4497 |
for (f = sym->formal; f; f = f->next) |
| 4498 |
if (f->sym->ts.type == BT_CHARACTER) |
| 4499 |
fprintf (dumpfile, ", size_t %s_len", f->sym->name); |
| 4500 |
|
| 4501 |
} |
| 4502 |
|
| 4503 |
/* Write out an interoperable function returning a function pointer. Better |
| 4504 |
handled separately. As we know nothing about the type, assume void. |
| 4505 |
Function ponters can be freely converted in C anyway. */ |
| 4506 |
|
| 4507 |
static void |
| 4508 |
write_funptr_fcn (gfc_symbol *sym) |
| 4509 |
{ |
| 4510 |
fprintf (dumpfile, "void (*%s (", sym->binding_label); |
| 4511 |
write_formal_arglist (sym, 1); |
| 4512 |
fputs (")) ();\n", dumpfile); |
| 4513 |
} |
| 4514 |
|
| 4515 |
/* Write out a procedure, including its arguments. */ |
| 4516 |
static void |
| 4517 |
write_proc (gfc_symbol *sym, bool bind_c) |
| 4518 |
{ |
| 4519 |
const char *sym_name; |
| 4520 |
bool external_character; |
| 4521 |
|
| 4522 |
external_character = sym->ts.type == BT_CHARACTER && !bind_c; |
| 4523 |
|
| 4524 |
if (sym->binding_label) |
| 4525 |
sym_name = sym->binding_label; |
| 4526 |
else |
| 4527 |
sym_name = sym->name; |
| 4528 |
|
| 4529 |
if (sym->ts.type == BT_UNKNOWN || external_character) |
| 4530 |
{ |
| 4531 |
fprintf (dumpfile, "void "); |
| 4532 |
fputs (sym_name, dumpfile); |
| 4533 |
} |
| 4534 |
else |
| 4535 |
write_decl (&(sym->ts), sym->as, sym_name, true, &sym->declared_at, bind_c); |
| 4536 |
|
| 4537 |
if (!bind_c) |
| 4538 |
fputs ("_", dumpfile); |
| 4539 |
|
| 4540 |
fputs (" (", dumpfile); |
| 4541 |
if (external_character) |
| 4542 |
{ |
| 4543 |
fprintf (dumpfile, "char *result_%s, size_t result_%s_len", |
| 4544 |
sym_name, sym_name); |
| 4545 |
if (sym->formal) |
| 4546 |
fputs (", ", dumpfile); |
| 4547 |
} |
| 4548 |
write_formal_arglist (sym, bind_c); |
| 4549 |
fputs (");\n", dumpfile); |
| 4550 |
} |
| 4551 |
|
| 4552 |
|
| 4553 |
/* Write a C-interoperable declaration as a C prototype or extern |
| 4554 |
declaration. */ |
| 4555 |
|
| 4556 |
static void |
| 4557 |
write_interop_decl (gfc_symbol *sym) |
| 4558 |
{ |
| 4559 |
/* Only dump bind(c) entities. */ |
| 4560 |
if (!sym->attr.is_bind_c) |
| 4561 |
return; |
| 4562 |
|
| 4563 |
/* Don't dump our iso c module. */ |
| 4564 |
if (sym->from_intmod == INTMOD_ISO_C_BINDING) |
| 4565 |
return; |
| 4566 |
|
| 4567 |
if (sym->attr.flavor == FL_VARIABLE) |
| 4568 |
write_variable (sym); |
| 4569 |
else if (sym->attr.flavor == FL_DERIVED) |
| 4570 |
write_type (sym); |
| 4571 |
else if (sym->attr.flavor == FL_PROCEDURE) |
| 4572 |
{ |
| 4573 |
if (sym->ts.type == BT_DERIVED |
| 4574 |
&& sym->ts.u.derived->intmod_sym_id == ISOCBINDING_FUNPTR) |
| 4575 |
write_funptr_fcn (sym); |
| 4576 |
else |
| 4577 |
write_proc (sym, true); |
| 4578 |
} |
| 4579 |
} |
| 4580 |
|
| 4581 |
/* This section deals with dumping the global symbol tree. */ |
| 4582 |
|
| 4583 |
/* Callback function for printing out the contents of the tree. */ |
| 4584 |
|
| 4585 |
static void |
| 4586 |
show_global_symbol (gfc_gsymbol *gsym, void *f_data) |
| 4587 |
{ |
| 4588 |
FILE *out; |
| 4589 |
out = (FILE *) f_data; |
| 4590 |
|
| 4591 |
if (gsym->name) |
| 4592 |
fprintf (out, "name=%s", gsym->name); |
| 4593 |
|
| 4594 |
if (gsym->sym_name) |
| 4595 |
fprintf (out, ", sym_name=%s", gsym->sym_name); |
| 4596 |
|
| 4597 |
if (gsym->mod_name) |
| 4598 |
fprintf (out, ", mod_name=%s", gsym->mod_name); |
| 4599 |
|
| 4600 |
if (gsym->binding_label) |
| 4601 |
fprintf (out, ", binding_label=%s", gsym->binding_label); |
| 4602 |
|
| 4603 |
fputc ('\n', out); |
| 4604 |
} |
| 4605 |
|
| 4606 |
/* Show all global symbols. */ |
| 4607 |
|
| 4608 |
void |
| 4609 |
gfc_dump_global_symbols (FILE *f) |
| 4610 |
{ |
| 4611 |
if (gfc_gsym_root == NULL) |
| 4612 |
fprintf (f, "empty\n"); |
| 4613 |
else |
| 4614 |
gfc_traverse_gsymbol (gfc_gsym_root, show_global_symbol, (void *) f); |
| 4615 |
} |
| 4616 |
|
| 4617 |
/* Show an array ref. */ |
| 4618 |
|
| 4619 |
DEBUG_FUNCTION void |
| 4620 |
debug (gfc_array_ref *ar) |
| 4621 |
{ |
| 4622 |
FILE *tmp = dumpfile; |
| 4623 |
dumpfile = stderr; |
| 4624 |
show_array_ref (ar); |
| 4625 |
fputc ('\n', dumpfile); |
| 4626 |
dumpfile = tmp; |
| 4627 |
} |