Skip to content

Commit c93c836

Browse files
authored
Merge pull request #266 from ThePortlandGroup/nv_stage
Pull 2017-10-10T17-30 Recent NVIDIA Changes
2 parents 44cba05 + 1987887 commit c93c836

File tree

10 files changed

+131
-124
lines changed

10 files changed

+131
-124
lines changed

runtime/flang/ldread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ read_record(void)
14681468
{
14691469
if (internal_file) {
14701470
if (n_irecs == 0)
1471-
return FIO_EEOF;
1471+
return 0;
14721472
if (accessed)
14731473
in_recp += rec_len;
14741474
n_irecs--;

runtime/flangrti/erfc_scaled.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
#pragma global - Mx, 6, 0x100
2020

2121
#include "mthdecls.h"
22-
#if defined(TARGET_WIN) || defined(win32) || defined(TARGET_OSX)
2322
#include <float.h>
24-
#else
25-
#include <values.h>
26-
#endif
2723

2824
#define pi 3.1415926535897932384626434
2925
#define sqrtpi 1.77245385090551602729

runtime/flangrti/erfc_scaledf.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
#pragma global - Mx, 6, 0x100
2020

2121
#include "mthdecls.h"
22-
#if defined(TARGET_WIN) || defined(win32) || defined(TARGET_OSX)
2322
#include <float.h>
24-
#else
25-
#include <values.h>
26-
#endif
2723

2824
#define pi 3.1415926535897932384626434f
2925
#define sqrtpi 1.77245385090551602729f

tools/flang1/flang1exe/rest.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,13 +1573,6 @@ transform_call(int std, int ast)
15731573
int newargt2, astnew, func;
15741574
int sdsc_mem = get_member_descriptor(sptr);
15751575

1576-
if (SCOPEG(sptrsdsc) != stb.curr_scope) {
1577-
/* localize this descriptor */
1578-
sptrsdsc = insert_dup_sym(sptrsdsc);
1579-
SDSCP(sptr, sptrsdsc);
1580-
SCOPEP(sptrsdsc, stb.curr_scope);
1581-
}
1582-
15831576
newargt2 = mk_argt(2);
15841577
ARGT_ARG(newargt2, 0) = mk_id(sptrsdsc);
15851578

tools/flang1/flang1exe/semant3.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,10 +1271,8 @@ semant3(int rednum, SST *top)
12711271
dtype = DTY(dtype + 1);
12721272
if (DTY(dtype) == TY_DERIVED) {
12731273
int mem;
1274-
sptr1 = resolve_sym_aliases(SST_SYMG(RHS(rhstop))); /* FS#18393 */
1275-
if (STYPEG(sptr1) != ST_PROC && STYPEG(sptr1) != ST_ENTRY &&
1276-
STYPEG(sptr1) != ST_USERGENERIC && STYPEG(sptr1) != ST_UNKNOWN)
1277-
goto normal_cvar_ref_component;
1274+
sptr1 = SST_SYMG(RHS(rhstop));
1275+
sptr1 = resolve_sym_aliases(sptr1);
12781276
switch (A_TYPEG(SST_ASTG(RHS(1)))) {
12791277
case A_ID:
12801278
case A_LABEL:
@@ -1292,7 +1290,7 @@ semant3(int rednum, SST *top)
12921290
dtype = DTY(dtype + 1);
12931291
mem = 0;
12941292
sptr1 = get_implementation(dtype, sptr1, 0, &mem);
1295-
if (sptr1)
1293+
if (sptr1 > NOSYM)
12961294
sptr1 = BINDG(mem);
12971295

12981296
if (sptr1 &&
@@ -1313,7 +1311,7 @@ semant3(int rednum, SST *top)
13131311
if (!NOPASSG(mem))
13141312
push_tbp_arg(itemp);
13151313

1316-
i = NMPTRG(mem);
1314+
i = NMPTRG(mem);
13171315
ast = SST_ASTG(RHS(1));
13181316
ast = mkmember(dtype, ast, i);
13191317
if (ast) {

tools/flang1/flang1exe/semfunc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ need_tmp_retval(int func_sptr, int param_dummy)
760760
static int
761761
gen_finalized_result(int fval, int func_sptr)
762762
{
763-
if (!ALLOCATTRG(fval) && !POINTERG(fval) && has_finalized_component(fval)) {
763+
if (!ALLOCATTRG(fval) && !POINTERG(fval) && has_finalized_component(fval)) {
764764
/* Need to finalize the function result after it's assigned to LHS.
765765
* If the result is allocatable, then finalization is handled during
766766
* automatic deallocation (i.e., the runtime call to dealloc_poly03,
@@ -769,8 +769,8 @@ gen_finalized_result(int fval, int func_sptr)
769769
* whether such objects are finalized).
770770
*/
771771
int std = add_stmt(mk_stmt(A_CONTINUE, 0));
772-
if (STYPEG(fval) == ST_UNKNOWN || STYPEG(fval) == ST_IDENT) {
773772

773+
if (STYPEG(fval) == ST_UNKNOWN || STYPEG(fval) == ST_IDENT) {
774774
fval = getsymbol(SYMNAME(fval));
775775
if (STYPEG(fval) == ST_PROC) {
776776
/* function result variable name same as its function */
@@ -783,10 +783,12 @@ gen_finalized_result(int fval, int func_sptr)
783783
SCP(fval, SC_LOCAL);
784784
DTYPEP(fval, DTYPEG(func_sptr));
785785
DCLDP(fval, 1);
786+
init_derived_type(fval, 0, std);
787+
std = add_stmt(mk_stmt(A_CONTINUE, 0));
786788
}
787789
gen_finalization_for_sym(fval, std, 0);
788-
}
789-
return fval;
790+
}
791+
return fval;
790792
}
791793

792794
/** \brief Write ILMs to call a function.

tools/flang2/docs/xflag.n

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3796,6 +3796,8 @@ Allow character strings in CUDA Fortran
37963796
Allow some formatted print statements in CUDA Fortran, EXPERIMENTAL
37973797
.XB 0x20000:
37983798
Don't allow statements between the DO loops of a cuf kernels do construct
3799+
.XB 0x40000:
3800+
reserved
37993801

38003802
.XF "138:"
38013803
vect prefetch limit

tools/flang2/flang2exe/cg.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
if (c) \
5353
; \
5454
else \
55-
asrt_failed(__FILE__, __LINE__)
55+
fprintf(stderr, "asrt failed. line %d, file %s\n", __LINE__, __FILE__)
5656
#else
5757
#define asrt(c)
5858
#endif
@@ -61,6 +61,9 @@
6161

6262
#define FIRST_AILI(bih) cg.bih_info[bih].first_aili
6363

64+
#define IL_OPMASK_LD IL_LD /* (20 Sept 17): temporary */
65+
#define IL_OPMASK_ST IL_ST /* (20 Sept 17): temporary */
66+
6467
/*---------------------------------------------------
6568
* Support for 64-bit integers (via scutil functions)
6669
*-------------------------------------------------*/
@@ -330,7 +333,7 @@ struct bih_info {
330333
int pre_first_lili; /* first LILI in this block; used during PRE */
331334
int first_lili; /* first LILI in the EBB containing this block*/
332335
int last_lili; /* last LILI in the EBB containing this block */
333-
int pressure[4]; /* register pressures for this block */
336+
int pressure[6]; /* register pressures for this block */
334337
};
335338

336339
/*-------------------------------
@@ -537,7 +540,7 @@ typedef struct AILI {
537540
short rc_sptr; /* sptr for a memop of a spill */
538541
CC_RELATION cc; /* condition code ... one of CC_RELATION values */
539542
int number; /* this AILI # */
540-
short pressure[4]; /* OPT2 reg assignment: reg pressures for this aili */
543+
short pressure[6]; /* OPT2 reg assignment: reg pressures for this AILI */
541544
struct AILI *prev; /* pointer to previous aili in list */
542545
struct AILI *next; /* pointer to next aili in list */
543546
short branch_num; /* if XBIT_TREGION_CSE, 1 means AILI is in the 'if'
@@ -570,7 +573,7 @@ typedef struct RCAND {
570573
OPRND *regop; /* pointer to the corresponding OP_REG operand */
571574
int nme; /* names table entry for corresp. variable */
572575
int next; /* used to form various lists of candidates */
573-
REGCLASS regclass; /* REG_GP or REG_XM */
576+
REGCLASS regclass; /* REG_GP, REG_XM or REG_OPMASK */
574577
AILI *first_use; /* beginning of the candidate's live interval */
575578
AILI *last_use; /* end of this candidate's live interval */
576579
struct live_range_item *live_range;

tools/flang2/flang2exe/iliutil.c

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11683,50 +11683,60 @@ jsrsearch(int ilix)
1168311683
int
1168411684
alt_qjsr(int ilix)
1168511685
{
11686+
int altx, j, noprs;
11687+
ILI_OP opc;
11688+
1168611689
if (ILI_ALT(ilix)) {
11687-
if (IL_TYPE(ILI_OPC(ILI_ALT(ilix))) == ILTY_DEFINE)
11690+
altx = ILI_ALT(ilix);
11691+
opc = ILI_OPC(altx);
11692+
if (IL_TYPE(opc) == ILTY_DEFINE)
1168811693
return 1;
11689-
{
11690-
/*
11691-
* A bug (asrt) occurred with the 32-bit cg where the BIH_QJSR
11692-
* flag was not set, but the block contained a QJSR -- alt_qjsr(),
11693-
* when called from flow(, is supposed to detect qjsrs alt ili.
11694-
* There are just a few cases where the ALT ILI does not
11695-
* immediately reference a QJSR, but it's an ILI whose operand
11696-
* is a QJSR; an example of this is a 64-bit relational fo
11697-
* something like
11698-
* if ( i8 .gt. 0 )
11699-
* 49 QJSR 342~<__mth_i_kcmpz> 48^
11700-
* 50 DFRIR 49^ ir( 1)
11701-
* 51 ICMPZ 50^ gt
11702-
* 52 KCMPZ 47^ gt 51^-alt
11703-
* ...
11704-
* The solution for now is to check just one level below the
11705-
* ALT -- this isn't general at all, so the next time the bug
11706-
* occurs, may have to implement a complete fix (i.e., just
11707-
* call the 'new' routine, qjsr_in(), above);
11708-
*/
11709-
int altx;
11710-
ILI_OP opc;
11711-
int noprs, j;
11712-
altx = ILI_ALT(ilix);
11713-
opc = ILI_OPC(altx);
11714-
noprs = IL_OPRS(opc);
11715-
for (j = 1; j <= noprs; ++j) {
11716-
if (IL_ISLINK(opc, j)) {
11717-
if (IL_TYPE(ILI_OPC(ILI_OPND(altx, j))) == ILTY_DEFINE)
11718-
return 1;
11719-
}
11694+
11695+
/* In a few cases a QJSR's result ILI (namely a 'define' ILI such
11696+
* as IL_DFRDP, etc) is not 'altx' itself but rather an operand of
11697+
* 'altx'. For example, if the C99 ABI is used on x86 then a
11698+
* complex*16 function result is returned in a pair of registers,
11699+
* %xmm0 and %xmm1, and the ILI 'altx' is
11700+
* IL_DPDP2DCMPLX( IL_DFRDP(...), IL_DFRDP(...) ). Also on x86-32
11701+
* a 64-bit condition such as:
11702+
*
11703+
* if (i8 .gt. 0)
11704+
*
11705+
* gives rise to ILIs such as:
11706+
*
11707+
* 49 QJSR 342~<__mth_i_kcmpz> 48^
11708+
* 50 DFRIR 49^ ir( 1)
11709+
* 51 ICMPZ 50^ gt
11710+
* 52 KCMPZ 47^ gt 51^-alt
11711+
*
11712+
* The solution for now is to check whether any operand of 'altx'
11713+
* is a define ILI.
11714+
*
11715+
* This deals with the cases that we're currently aware of, but if
11716+
* a situation arises in which the define ILI is more deeply
11717+
* nested in 'altx's ILI tree then we'll have to implement a
11718+
* complete fix, e.g. by calling 'qjsr_in()'. Note, if this
11719+
* function fails to detect a QJSR ILI that is present in 'altx's
11720+
* ILI tree then the x86 native CG may indicate this by generating
11721+
* the warning ICE "gen_lilis: BIH_QJSR needs to be set for bih
11722+
* <bih_number>".
11723+
*/
11724+
noprs = IL_OPRS(opc);
11725+
for (j = 1; j <= noprs; ++j) {
11726+
if (IL_ISLINK(opc, j) &&
11727+
IL_TYPE(ILI_OPC(ILI_OPND(altx, j))) == ILTY_DEFINE) {
11728+
return 1;
1172011729
}
1172111730
}
1172211731
}
11732+
1172311733
switch (ILI_OPC(ilix)) {
1172411734
case IL_FSINCOS:
1172511735
case IL_DSINCOS:
1172611736
return 1;
1172711737
}
1172811738
return 0;
11729-
}
11739+
} /* end alt_qjsr(int ilix) */
1173011740

1173111741
/** \brief Look for 'QJSR' in this tree
1173211742
*/

0 commit comments

Comments
 (0)