Skip to content

Commit e74ac47

Browse files
authored
Merge pull request #149 from ThePortlandGroup/nv_stage
Pull 2017-07-18T11-09 Recent NVIDIA Changes
2 parents cd44bcd + 4bc4bf5 commit e74ac47

File tree

2 files changed

+25
-29
lines changed

2 files changed

+25
-29
lines changed

tools/flang1/flang1exe/semant.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static void save_host(INTERF *);
5555
static void restore_host(INTERF *, LOGICAL);
5656
static void check_end_subprogram(int, int);
5757
static char *name_of_rutype(int);
58+
static void convert_intrinsics_to_idents(void);
5859
static int chk_intrinsic(int, LOGICAL, LOGICAL);
5960
static int create_func_entry(int);
6061
static int create_func_entry_result(int);
@@ -1447,6 +1448,7 @@ semant1(int rednum, SST *top)
14471448
CNULL);
14481449
goto executable_shared;
14491450
}
1451+
convert_intrinsics_to_idents();
14501452
save_host(&host_state);
14511453
gbl.internal = 1;
14521454
restore_host(&host_state, TRUE);
@@ -11988,6 +11990,23 @@ name_of_rutype(int rutype)
1198811990
return "";
1198911991
}
1199011992

11993+
/* If an intrinsic is declared in a host subprogram and not otherwise used,
11994+
* convert it to an identifier for the internal subprograms to share.
11995+
*/
11996+
static void
11997+
convert_intrinsics_to_idents()
11998+
{
11999+
SPTR sptr;
12000+
assert(gbl.currsub && gbl.internal == 0,
12001+
"only applicable for non-internal subprogram", 0, ERR_Severe);
12002+
for (sptr = NOSYM + 1; sptr < stb.firstusym; ++sptr) {
12003+
if (DCLDG(sptr) && !EXPSTG(sptr) && IS_INTRINSIC(STYPEG(sptr))) {
12004+
SPTR new_sptr = newsym(sptr);
12005+
STYPEP(new_sptr, ST_IDENT);
12006+
}
12007+
}
12008+
}
12009+
1199112010
/*
1199212011
* In certain contexts, a new symbol must be created immediately
1199312012
* if the identifier is an intrinsic rather than relying on newsym().

tools/flang2/flang2exe/exp_rte.c

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3013,14 +3013,14 @@ exp_call(ILM_OP opc, ILM *ilmp, int curilm)
30133013
case IM_CDFUNCA:
30143014
i = 4;
30153015
share_cfunc:
3016+
ilm1 = ILM_OPND(ilmp, i);
3017+
dtype = IILM_OPND(ilm1, 2);
3018+
if (IILM_OPC(ilm1) == IM_FARG || IILM_OPC(ilm1) == IM_FARGF)
3019+
ilm1 = IILM_OPND(ilm1, 1);
3020+
cfunc = ILM_RESULT(ilm1);
3021+
cfunc_nme = NME_OF(ilm1);
30163022
if (CFUNCG(exp_call_sym) || (funcptr_flags & FUNCPTR_BINDC) ||
30173023
CMPLXFUNC_C) {
3018-
ilm1 = ILM_OPND(ilmp, i);
3019-
dtype = IILM_OPND(ilm1, 2);
3020-
if (IILM_OPC(ilm1) == IM_FARG || IILM_OPC(ilm1) == IM_FARGF)
3021-
ilm1 = IILM_OPND(ilm1, 1);
3022-
cfunc = ILM_RESULT(ilm1);
3023-
cfunc_nme = NME_OF(ilm1);
30243024
ADDRTKNP(IILM_OPND(ilm1, 1), 1);
30253025
nargs--;
30263026
if (opc == IM_CFUNCA || opc == IM_CDFUNCA) {
@@ -3035,29 +3035,6 @@ exp_call(ILM_OP opc, ILM *ilmp, int curilm)
30353035
garg_ili[0].dtype = dtype;
30363036
garg_ili[0].nme = cfunc_nme;
30373037
}
3038-
break;
3039-
}
3040-
if ((funcptr_flags & FUNCPTR_BINDC)) {
3041-
ilm1 = ILM_OPND(ilmp, 4);
3042-
} else {
3043-
ilm1 = ILM_OPND(ilmp, 3);
3044-
}
3045-
dtype = IILM_OPND(ilm1, 2);
3046-
if (IILM_OPC(ilm1) == IM_FARG)
3047-
ilm1 = IILM_OPND(ilm1, 1);
3048-
else if (IILM_OPC(ilm1) == IM_FARGF)
3049-
ilm1 = IILM_OPND(ilm1, 1);
3050-
cfunc = ILM_RESULT(ilm1);
3051-
cfunc_nme = NME_OF(ilm1);
3052-
if ((funcptr_flags & FUNCPTR_BINDC)) {
3053-
i = 4; /* ilm pointer to first arg */
3054-
if (XBIT(121, 0x800)) {
3055-
garg_ili[0].ilix = cfunc;
3056-
garg_ili[0].dtype = dtype;
3057-
garg_ili[0].nme = cfunc_nme;
3058-
}
3059-
} else {
3060-
i = 3; /* ilm pointer to first arg */
30613038
}
30623039
break;
30633040
case IM_CHVFUNCA:

0 commit comments

Comments
 (0)