Skip to content

Commit 02505f4

Browse files
authored
Merge pull request #452 from ThePortlandGroup/nv_stage
Pull 2018-04-25T17-03 Recent NVIDIA Changes
2 parents 5f0fc8d + 36263b9 commit 02505f4

File tree

22 files changed

+577
-459
lines changed

22 files changed

+577
-459
lines changed

include/flang/Error/errmsg-in.n

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,3 +1472,4 @@ Pragma operator errors.
14721472
.MS S 1012 "Threadprivate variables are not supported in acc routine - $"
14731473
.MS S 1013 "Static Threadprivate variables are not supported - $"
14741474
.MS S 1014 "Global Threadprivate variables are not supported - $"
1475+
.MS S 1015 "Cannot access private intrinsic - $"

runtime/flang/shmem_reduce.h

Lines changed: 0 additions & 36 deletions
This file was deleted.

runtime/flang/transfer.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
2+
* Copyright (c) 1995-2018, NVIDIA CORPORATION. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
1919

2020
#include "stdioInterf.h"
2121
#include "fioMacros.h"
22-
22+
#include "type.h"
2323
/* transfer intrinsic */
2424

2525
static int I8(next_index)(__INT_T *index, F90_Desc *s)
@@ -60,10 +60,28 @@ void ENTFTN(TRANSFER, transfer)(void *rb, /* result base */
6060

6161
result_scalar = F90_TAG_G(result) != __DESC;
6262
source_scalar = F90_TAG_G(source) != __DESC;
63-
rsize = *rs;
63+
if (*rs == 0 && (F90_TAG_G(result) == __POLY)) {
64+
OBJECT_DESC *dest = (OBJECT_DESC *)result;
65+
TYPE_DESC *dest_td = dest ? dest->type : 0;
66+
if (dest_td != NULL) {
67+
rsize = ((OBJECT_DESC*)dest_td)->size;
68+
} else {
69+
rsize = *rs;
70+
}
71+
} else {
72+
rsize = *rs;
73+
}
74+
6475
if (result_scalar && source_scalar) {
65-
if (rsize > *ms)
76+
OBJECT_DESC *src = (OBJECT_DESC *)source;
77+
TYPE_DESC *src_td = src ? src->type : 0;
78+
if (*ms == 0 && (F90_TAG_G(source) == __POLY) && src_td != NULL) {
79+
if (rsize > ((OBJECT_DESC*)src_td)->size) {
80+
rsize = ((OBJECT_DESC*)src_td)->size;
81+
}
82+
} else if (rsize > *ms) {
6683
rsize = *ms;
84+
}
6785
__fort_bcopy(rb, sb, rsize);
6886
return;
6987
}

tools/flang1/flang1exe/dpm_out.c

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,9 +1749,9 @@ undouble_callee_args_f90(void)
17491749
static LOGICAL
17501750
arg_has_descriptor(int oldarg)
17511751
{
1752-
return oldarg > NOSYM && (ASSUMSHPG(oldarg) || POINTERG(oldarg) ||
1753-
IS_PROC_DUMMYG(oldarg) ||
1754-
ALLOCATTRG(oldarg) || is_kopy_in_needed(oldarg));
1752+
return oldarg > NOSYM &&
1753+
(ASSUMSHPG(oldarg) || POINTERG(oldarg) || IS_PROC_DUMMYG(oldarg) ||
1754+
ALLOCATTRG(oldarg) || is_kopy_in_needed(oldarg));
17551755
}
17561756

17571757
void
@@ -2613,7 +2613,7 @@ newargs_for_entry(int this_entry)
26132613
*/
26142614
set_preserve_descriptor(CLASSG(arg) || is_procedure_ptr(arg) ||
26152615
(sem.which_pass && IS_PROC_DUMMYG(arg)) ||
2616-
( ALLOCDESCG(arg) && RESULTG(arg)));
2616+
(ALLOCDESCG(arg) && RESULTG(arg)));
26172617

26182618
newdsc = sym_get_arg_sec(arg);
26192619
set_preserve_descriptor(0);
@@ -3970,7 +3970,7 @@ set_assumed_bounds(int arg, int entry, int actual)
39703970
int dtype;
39713971
int r;
39723972
int i, ndim;
3973-
int ast, ast1, ast2, ast_glb;
3973+
int ast, ast1, ast2, ast_gbl;
39743974
int sav = 0;
39753975
int tmp_lb, tmp_ub;
39763976
int std;
@@ -4010,9 +4010,9 @@ set_assumed_bounds(int arg, int entry, int actual)
40104010
if (XBIT(58, 0x400000) && TARGETG(arg)) {
40114011
DESCUSEDP(arg, 1);
40124012
ndim = rank_of_sym(arg);
4013-
assert(r==ndim,"set_assumed_bounds: rank mismatch", ndim,ERR_Fatal);
4013+
assert(r == ndim, "set_assumed_bounds: rank mismatch", ndim, ERR_Fatal);
40144014
assert(ASSUMSHPG(arg), "set_assumed_bounds(): wrong shape", 0, ERR_Fatal);
4015-
assert(SCG(arg) == SC_DUMMY,"set_assumed_bounds(): expected dummy arg",
4015+
assert(SCG(arg) == SC_DUMMY, "set_assumed_bounds(): expected dummy arg",
40164016
SCG(arg), ERR_Fatal);
40174017
ast_visit(1, 1);
40184018
for (i = 0; i < ndim; i++) {
@@ -4022,7 +4022,6 @@ set_assumed_bounds(int arg, int entry, int actual)
40224022
AD_LWAST(ad, i) = get_global_lower(newdsc, i);
40234023
if (oldast)
40244024
ast_replace(oldast, AD_LWAST(ad, i));
4025-
40264025

40274026
oldast = AD_UPAST(ad, i);
40284027
a = get_extent(newdsc, i);
@@ -4043,7 +4042,6 @@ set_assumed_bounds(int arg, int entry, int actual)
40434042
}
40444043
}
40454044

4046-
40474045
for (i = 0; i < ndim; ++i) {
40484046
AD_MLPYR(ad, i) = get_local_multiplier(newdsc, i);
40494047
}
@@ -4053,12 +4051,13 @@ set_assumed_bounds(int arg, int entry, int actual)
40534051
if (ast)
40544052
AD_ZBASE(ad) = ast_rewrite(ast);
40554053
ast_unvisit();
4056-
goto check_optional;
4054+
/* goto check_optional; */
40574055
}
40584056

40594057
/* arg is assumed shape, need to set (and maybe fix if !TARGET) its bounds */
4060-
if( XBIT(58,0x400000) && !TARGETG(arg) )
4061-
SDSCS1P(arg, 1); /* see comment below regarding these xbits */
4058+
if (XBIT(58, 0x400000) && !TARGETG(arg)) {
4059+
SDSCS1P(arg, 1); /* see comment below regarding these xbits */
4060+
}
40624061
for (i = 0; i < r; ++i) {
40634062
tmp_lb = AD_LWAST(ad, i); /* temp for lower bound */
40644063
/* declare it by changing the scope */
@@ -4071,16 +4070,16 @@ set_assumed_bounds(int arg, int entry, int actual)
40714070
ast1 = mk_isz_cval(1, astb.bnd.dtype);
40724071
if (A_TYPEG(tmp_lb) == A_CNST) {
40734072
sav = tmp_lb;
4074-
} else if (XBIT(54,2) || (XBIT(58,0x400000) && TARGETG(arg))) {
4073+
} else if (XBIT(54, 2) || (XBIT(58, 0x400000) && TARGETG(arg))) {
40754074
/* lower bound assignment */
40764075
/* lb = <global lower bound> */
4077-
ast_glb = get_global_lower(newdsc, i);
4076+
ast_gbl = get_global_lower(newdsc, i);
40784077
sav = ast1;
40794078
ast2 = mk_stmt(A_ASN, 0);
40804079
A_DESTP(ast2, tmp_lb);
4081-
A_SRCP(ast2, ast_glb);
4080+
A_SRCP(ast2, ast_gbl);
40824081
std = add_stmt_after(ast2, std);
4083-
} else if (tmp_lb != ast1 ) {
4082+
} else if (tmp_lb != ast1) {
40844083
/* output lower bound assignment */
40854084
/* lb = <declared lower bound> */
40864085
sav = ast1;
@@ -4091,19 +4090,17 @@ set_assumed_bounds(int arg, int entry, int actual)
40914090
}
40924091

40934092
/* did we not set lower bound to 1 in to_assumed_shape() or
4094-
* mk_assumed_shape() because TARGET was not yet available
4093+
* mk_assumed_shape() because TARGET was not yet available
40954094
* (still in parser) when this xbit was set?
40964095
*/
4097-
if( XBIT(58,0x400000) && !TARGETG(arg) )
4098-
{
4099-
if(AD_LWBD(ad, i) == AD_LWAST(ad, i))
4100-
{
4101-
AD_LWBD(ad, i) = astb.bnd.one; /* set in both routines */
4102-
/* following only set in mk_assumed_shape() */
4103-
if(AD_LWBD(ad, i) && A_TYPEG(AD_LWBD(ad, i)) != A_CNST &&
4104-
cc_tmp_var(AD_LWBD(ad, i)))
4105-
AD_LWAST(ad, i) = astb.bnd.one;
4106-
}
4096+
if (XBIT(58, 0x400000) && !TARGETG(arg)) {
4097+
if (AD_LWBD(ad, i) == AD_LWAST(ad, i)) {
4098+
AD_LWBD(ad, i) = astb.bnd.one; /* set in both routines */
4099+
/* following only set in mk_assumed_shape() */
4100+
if (AD_LWBD(ad, i) && A_TYPEG(AD_LWBD(ad, i)) != A_CNST &&
4101+
cc_tmp_var(AD_LWBD(ad, i)))
4102+
AD_LWAST(ad, i) = astb.bnd.one;
4103+
}
41074104
}
41084105

41094106
/* no need for upper bounds for pointer dummys */

tools/flang1/flang1exe/dtypeutl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,8 @@ size_ast_of(int ast, DTYPE dtype)
783783
case TY_DERIVED:
784784
if (!sptr)
785785
sptr = DTY(dtype + 1);
786-
if (DTY(dtype + 2) <= 0 && (!CLASSG(sptr) || !DTY(dtype + 1))) {
786+
if (DTY(dtype + 2) <= 0 && !UNLPOLYG(DTY(dtype+3)) &&
787+
(!CLASSG(sptr) || !DTY(dtype + 1))) {
787788
errsev(151);
788789
return mk_isz_cval(4, astb.bnd.dtype);
789790
} else {

tools/flang1/flang1exe/lower.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997-2017, NVIDIA CORPORATION. All rights reserved.
2+
* Copyright (c) 1997-2018, NVIDIA CORPORATION. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@
3535
static int errors;
3636

3737
static void lower_start_subroutine(int);
38-
static void lower_end_subroutine();
38+
static void lower_end_subroutine(void);
3939
static void lower_program(int);
4040
static void save_contained(void);
4141
static void init_contained(void);
@@ -355,7 +355,7 @@ lower_start_subroutine(int rutype)
355355
} /* lower_start_subroutine */
356356

357357
static void
358-
lower_end_subroutine()
358+
lower_end_subroutine(void)
359359
{
360360
fprintf(lowersym.lowerfile, "end\n");
361361
if (STB_LOWER()) {
@@ -423,7 +423,8 @@ markid(int astx, int *unused)
423423
SDSCG(sptr) < lowersym.last_outer_sym_orig)
424424
outerflags[SDSCG(sptr) - lowersym.first_outer_sym] |= 1;
425425
break;
426-
default:;
426+
default:
427+
break;
427428
}
428429
dtype = DTYPEG(sptr);
429430
if (dtype && DTY(dtype) == TY_ARRAY) {
@@ -570,7 +571,8 @@ lower_end_contains(void)
570571
}
571572
}
572573
break;
573-
default:;
574+
default:
575+
break;
574576
}
575577
}
576578
outer = 0;

tools/flang1/flang1exe/lowersym.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4434,6 +4434,8 @@ lower_symbol(int sptr)
44344434
putbit("aret", ARETG(sptr));
44354435
putbit("vararg", 0);
44364436
putbit("parref", PARREFG(sptr));
4437+
if (SCG(sptr) == SC_DUMMY)
4438+
putval("descriptor", IS_PROC_DUMMYG(sptr) ? SDSCG(sptr) : 0);
44374439
if (gbl.stbfil && DTY(DTYPEG(sptr) + 2)) {
44384440
if (fvalfirst) {
44394441
putsym(NULL, FVALG(sptr));

tools/flang1/flang1exe/module.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939

4040
/* ModuleId is an index into usedb.base[] */
4141
typedef enum {
42-
NO_MODULE = 0,
43-
FIRST_MODULE = 3, /* 1 and 2 are not used */
44-
ISO_C_MOD = FIRST_MODULE, /* iso_c_binding module */
45-
IEEE_ARITH_MOD, /* ieee_arithmetic module */
46-
IEEE_FEATURES_MOD, /* ieee_features module */
47-
ISO_FORTRAN_ENV, /* iso_fortan_env module */
48-
NML_MOD, /* namelist */
49-
FIRST_USER_MODULE, /* beginning of use modules */
50-
MODULE_ID_MAX = 0x7fffffff,
42+
NO_MODULE = 0,
43+
FIRST_MODULE = 3, /* 1 and 2 are not used */
44+
ISO_C_MOD = FIRST_MODULE, /* iso_c_binding module */
45+
IEEE_ARITH_MOD, /* ieee_arithmetic module */
46+
IEEE_FEATURES_MOD, /* ieee_features module */
47+
ISO_FORTRAN_ENV, /* iso_fortan_env module */
48+
NML_MOD, /* namelist */
49+
FIRST_USER_MODULE, /* beginning of use modules */
50+
MODULE_ID_MAX = 0x7fffffff,
5151
} MODULE_ID;
5252

5353
/* The index into usedb of the module of the current USE statement.
@@ -283,8 +283,7 @@ add_use_rename(SPTR local, SPTR global, LOGICAL is_operator)
283283
*/
284284
if (!VALID_RENAME_SYM(global)) {
285285
SPTR sptr;
286-
for (sptr = first_hash(global); sptr;
287-
sptr = HASHLKG(sptr)) {
286+
for (sptr = first_hash(global); sptr; sptr = HASHLKG(sptr)) {
288287
if (NMPTRG(sptr) == NMPTRG(global) && SCOPEG(sptr) == SCOPEG(global) &&
289288
VALID_RENAME_SYM(sptr)) {
290289
if (ST_ISVAR(sptr) && SYMLKG(sptr) &&
@@ -716,7 +715,7 @@ apply_use(MODULE_ID m_id)
716715
while ((scope = next_scope(scope)) != 0 &&
717716
get_scope_level(scope) >= save_sem_scope_level) {
718717
int o, nexto;
719-
scope->private = TRUE;
718+
scope->Private = TRUE;
720719
for (o = onlylist; o; o = nexto) {
721720
nexto = SYMI_NEXT(o);
722721
if (SCOPEG(SYMI_SPTR(o)) == scope->sptr) {
@@ -1130,7 +1129,6 @@ mod_implicit(int firstc, int lastc, int dtype)
11301129
impl.base[i].firstc = firstc;
11311130
impl.base[i].lastc = lastc;
11321131
impl.base[i].dtype = dtype;
1133-
11341132
}
11351133

11361134
static void
@@ -1461,7 +1459,7 @@ MOD_CMN_IDX(int xpriv, int xchar, int xlong, int xinitd, int thrd_priv,
14611459
#define N_MOD_CMN sizeof(mod_cmn) / sizeof(int)
14621460
static int mod_cmn_naln[N_MOD_CMN];
14631461

1464-
typedef struct itemx {/* generic item record */
1462+
typedef struct itemx { /* generic item record */
14651463
int val;
14661464
struct itemx *next;
14671465
} ITEMX;
@@ -1783,8 +1781,9 @@ fix_module_common(void)
17831781
}
17841782
dty = DTYG(dtype);
17851783
if ((dty == TY_CHAR || dty == TY_NCHAR) && ADJLENG(sptr)) {
1786-
error(310, 3, gbl.lineno, "Adjustable-length character variables are "
1787-
"not allowed in a MODULE -",
1784+
error(310, 3, gbl.lineno,
1785+
"Adjustable-length character variables are "
1786+
"not allowed in a MODULE -",
17881787
SYMNAME(sptr));
17891788
err = 1;
17901789
}
@@ -1800,8 +1799,9 @@ fix_module_common(void)
18001799
dtype = DTYPEG(sptr);
18011800
dty = DTYG(dtype);
18021801
if ((dty == TY_CHAR || dty == TY_NCHAR) && ADJLENG(sptr)) {
1803-
error(310, 3, gbl.lineno, "Adjustable-length character variables are "
1804-
"not allowed in a MODULE -",
1802+
error(310, 3, gbl.lineno,
1803+
"Adjustable-length character variables are "
1804+
"not allowed in a MODULE -",
18051805
SYMNAME(sptr));
18061806
err = 1;
18071807
}
@@ -2382,10 +2382,10 @@ mod_add_subprogram(int subp)
23822382
i++;
23832383
}
23842384
}
2385-
if (XBIT(52,0x80)) {
2385+
if (XBIT(52, 0x80)) {
23862386
char linkage_name[2048];
2387-
snprintf(linkage_name, sizeof(linkage_name),
2388-
".%s.%s", modu_name, SYMNAME(new_sb));
2387+
snprintf(linkage_name, sizeof(linkage_name), ".%s.%s", modu_name,
2388+
SYMNAME(new_sb));
23892389
ALTNAMEP(new_sb, getstring(linkage_name, strlen(linkage_name)));
23902390
}
23912391
return new_sb;
@@ -2405,7 +2405,7 @@ export_public_used_modules(int scopelevel)
24052405
if (sem.mod_public_flag && sem.scope_stack) {
24062406
SCOPESTACK *scope = get_scope(scopelevel);
24072407
for (; scope != 0; scope = next_scope(scope)) {
2408-
if (scope->kind == SCOPE_USE && !scope->private) {
2408+
if (scope->kind == SCOPE_USE && !scope->Private) {
24092409
export_public_module(scope->sptr, scope->except);
24102410
}
24112411
}

0 commit comments

Comments
 (0)