Skip to content

Commit b6f66f5

Browse files
authored
Merge pull request #117 from ThePortlandGroup/nv_stage
Pull 2017-06-29T13-22 Recent NVIDIA Changes
2 parents 9c2bc63 + 4905e3e commit b6f66f5

File tree

17 files changed

+370
-1756
lines changed

17 files changed

+370
-1756
lines changed

tools/flang2/flang2exe/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ set(SOURCES
7575
lili2llvm.c
7676
ll_dbgutl.c
7777
dwarf_names.c
78-
xprolog.c
7978
llassem.c
8079
llassem_common.c
8180
asm_anno.c
@@ -94,8 +93,6 @@ set(SOURCES
9493
ll_builder.c
9594
llopt.c
9695
llsched.c
97-
sched-util.c
98-
sched-dag.c
9996
machreg.c
10097
ccffinfo.c
10198
kmpcutil.c

tools/flang2/flang2exe/atomic_common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717

1818

19-
#ifndef PGI_ATOMIC_COMMON_DEF
20-
#define PGI_ATOMIC_COMMON_DEF
19+
#ifndef ATOMIC_COMMON_H
20+
#define ATOMIC_COMMON_H
2121

2222
/** Specifies memory order of an atomic operation.
2323
Values corresponding to C11/C++11 memory orders are guaranteed

tools/flang2/flang2exe/cgmain.c

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ static OPERAND *convert_int_size(int, OPERAND *, LL_Type *);
382382
static OPERAND *convert_int_to_ptr(OPERAND *, LL_Type *);
383383
static OPERAND *gen_call_vminmax_intrinsic(int ilix, OPERAND *op1,
384384
OPERAND *op2);
385+
static OPERAND *gen_extract_value_ll(OPERAND *, LL_Type *, LL_Type *, int);
386+
static OPERAND *gen_extract_value(OPERAND *, DTYPE, DTYPE, int);
387+
385388
#if defined(TARGET_LLVM_POWER)
386389
static OPERAND *gen_call_vminmax_power_intrinsic(int ilix, OPERAND *op1,
387390
OPERAND *op2);
@@ -1499,6 +1502,10 @@ msz_dtype(MSZ msz)
14991502
#endif
15001503
case MSZ_F32:
15011504
return DT_256;
1505+
#ifdef LONG_DOUBLE_FLOAT128
1506+
case MSZ_F16:
1507+
return DT_FLOAT128;
1508+
#endif
15021509
default:
15031510
assert(0, "msz_dtype, bad value", msz, 4);
15041511
}
@@ -2154,6 +2161,12 @@ write_instructions(LL_Module *module)
21542161
case LL_FLOAT:
21552162
print_token(" 0.0");
21562163
break;
2164+
case LL_X86_FP80:
2165+
print_token(" 0xK00000000000000000000");
2166+
break;
2167+
case LL_FP128:
2168+
print_token(" 0xL00000000000000000000000000000000");
2169+
break;
21572170
case LL_PPC_FP128:
21582171
print_token(" 0xM00000000000000000000000000000000");
21592172
break;
@@ -3117,6 +3130,15 @@ make_stmt(STMT_Type stmt_type, int ilix, LOGICAL deletable, int next_bih_label,
31173130
LL_Type *ty = make_lltype_from_dtype(DT_DCMPLX);
31183131
op1 = gen_llvm_expr(rhs_ili, ty);
31193132
store_flags = ldst_instr_flags_from_dtype(DT_DCMPLX);
3133+
#ifdef LONG_DOUBLE_FLOAT128
3134+
} else if (ILI_OPC(ilix) == IL_FLOAT128ST) {
3135+
LL_Type *ty = make_lltype_from_dtype(DT_FLOAT128);
3136+
op1 = gen_llvm_expr(rhs_ili, ty);
3137+
store_flags = ldst_instr_flags_from_dtype(DT_FLOAT128);
3138+
#endif
3139+
/* we let any other LONG_DOUBLE_X87 fall into the default case as
3140+
* conversion is done (if needed) implicitly via convert_float_size()
3141+
*/
31203142
} else {
31213143
LL_Type *ty = make_type_from_msz(msz);
31223144
op1 = gen_llvm_expr(rhs_ili, ty);
@@ -3855,6 +3877,15 @@ gen_abs_expr(int ilix)
38553877
zero_op = gen_llvm_expr(ad1ili(IL_DCON, getcon(dtmp.tmp, DT_DBLE)),
38563878
operand->ll_type);
38573879
break;
3880+
#ifdef LONG_DOUBLE_FLOAT128
3881+
case IL_FLOAT128ABS:
3882+
cc_itype = IL_FLOAT128CMP;
3883+
cc_val = convert_to_llvm_cc(CC_LT, CMP_FLT);
3884+
op2 = gen_llvm_expr(ad1ili(IL_FLOAT128CHS, lhs_ili), operand->ll_type);
3885+
zero_op = gen_llvm_expr(ad1ili(IL_FLOAT128CON, stb.float128_0),
3886+
operand->ll_type);
3887+
break;
3888+
#endif
38583889
}
38593890
cmp_op = make_tmp_op(bool_type, make_tmps());
38603891

@@ -5935,6 +5966,9 @@ get_next_arg(int arg_ili)
59355966
case IL_ARGSP:
59365967
case IL_GARG:
59375968
case IL_GARGRET:
5969+
#ifdef LONG_DOUBLE_FLOAT128
5970+
case IL_FLOAT128ARG:
5971+
#endif
59385972
return ILI_OPND(arg_ili, 2);
59395973

59405974
case IL_DAAR:
@@ -8161,6 +8195,14 @@ gen_llvm_expr(int ilix, LL_Type *expected_type)
81618195
ll_type_int_bits(expected_type)) {
81628196
operand = convert_ptr_to_int(operand, expected_type);
81638197
break;
8198+
} else if (ll_type_int_bits(operand->ll_type) &&
8199+
(expected_type->data_type == LL_X86_FP80)) {
8200+
assert(ll_type_bytes(operand->ll_type) <= ll_type_bytes(expected_type),
8201+
"bitcast of int larger than long long to FP80",
8202+
ll_type_bytes(operand->ll_type),
8203+
ERR_Fatal);
8204+
operand = convert_sint_to_float(operand, expected_type);
8205+
break;
81648206
} else if (ll_type_int_bits(operand->ll_type) &&
81658207
ll_type_is_fp(expected_type)) {
81668208
assert(ll_type_bytes(operand->ll_type) == ll_type_bytes(expected_type),
@@ -8181,6 +8223,7 @@ gen_llvm_expr(int ilix, LL_Type *expected_type)
81818223
return operand;
81828224
} /* gen_llvm_expr */
81838225

8226+
81848227
static char *
81858228
vect_power_intrinsic_name(int ilix)
81868229
{
@@ -9889,7 +9932,7 @@ make_type_from_opc(ILI_OP opc)
98899932
* the other possibility is jump ILI with expressions, or cast due
98909933
* to array manipulations. These are mostly
98919934
* of integer type, as the the evaluation of a condition is inherently
9892-
* integral.
9935+
* integral. However, notice first two cases, which are of type LLT_PTR.
98939936
*/
98949937
switch (opc) {
98959938
case IL_ACMP:
@@ -10050,6 +10093,19 @@ make_type_from_opc(ILI_OP opc)
1005010093
case IL_ALLOC:
1005110094
llt = make_lltype_from_dtype(DT_CPTR);
1005210095
break;
10096+
#ifdef LONG_DOUBLE_FLOAT128
10097+
case IL_FLOAT128CON:
10098+
case IL_FLOAT128ABS:
10099+
case IL_FLOAT128CHS:
10100+
case IL_FLOAT128RNDINT:
10101+
case IL_FLOAT128ADD:
10102+
case IL_FLOAT128SUB:
10103+
case IL_FLOAT128MUL:
10104+
case IL_FLOAT128DIV:
10105+
case IL_FLOAT128CMP:
10106+
llt = make_lltype_from_dtype(DT_FLOAT128);
10107+
break;
10108+
#endif
1005310109
default:
1005410110
DBGTRACE2("###make_type_from_opc(): unknown opc %d(%s)", opc, IL_NAME(opc))
1005510111
assert(0, "make_type_from_opc: unknown opc", opc, 4);
@@ -10891,6 +10947,19 @@ gen_constant(int sptr, int tdtype, INT conval0, INT conval1, int flags)
1089110947

1089210948
break;
1089310949

10950+
case DT_FLOAT128:
10951+
size += 36;
10952+
constant = getitem(LLVM_LONGTERM_AREA, size);
10953+
if (flags & FLG_OMIT_OP_TYPE)
10954+
snprintf(constant, size, "0xL%08x%08x%08x%08x",
10955+
CONVAL1G(sptr), CONVAL2G(sptr),
10956+
CONVAL3G(sptr), CONVAL4G(sptr));
10957+
else
10958+
snprintf(constant, size, "%s 0xL%08x%08x%08x%08x", ctype,
10959+
CONVAL1G(sptr), CONVAL2G(sptr),
10960+
CONVAL3G(sptr), CONVAL4G(sptr));
10961+
break;
10962+
1089410963
default:
1089510964
if (!llvm_info.no_debug_info) {
1089610965
DBGTRACE3("### gen_constant; sptr %d, unknown dtype: %d(%s)", sptr, dtype,
@@ -11157,9 +11226,9 @@ process_formal_arguments(LL_ABI_Info *abi)
1115711226

1115811227
/* Make a name for the real LLVM IR argument. This will also be used by
1115911228
* build_routine_and_parameter_entries(). */
11160-
arg_op->string = (char *)
11161-
ll_create_local_name(llvm_info.curr_func, "%s%s",
11162-
get_llvm_name(arg->sptr), suffix);
11229+
arg_op->string = (char *)ll_create_local_name(llvm_info.curr_func, "%s%s",
11230+
get_llvm_name(arg->sptr),
11231+
suffix);
1116311232

1116411233
/* Emit code in the entry block that saves the argument into the local
1116511234
* variable. The pointer bitcast takes care of the coercion.

tools/flang2/flang2exe/cgsched.h

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

tools/flang2/flang2exe/iliutil.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11302,6 +11302,9 @@ mem_size(TY_KIND ty)
1130211302
case TY_USINT:
1130311303
msz = MSZ_UHWORD;
1130411304
break;
11305+
case TY_FLOAT128:
11306+
msz = MSZ_F16;
11307+
break;
1130511308
default:
1130611309
msz = MSZ_UNDEF;
1130711310
}

tools/flang2/flang2exe/ll_structure.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,8 @@ LLTypeGetBytesUnchecked(LL_Type *type, int *noSize)
969969
return 4;
970970
case LL_DOUBLE:
971971
return 8;
972-
case LL_FP128:
973972
case LL_X86_FP80:
973+
case LL_FP128:
974974
case LL_PPC_FP128:
975975
return 16;
976976
case LL_PTR:
@@ -1626,7 +1626,7 @@ ll_get_struct_type(LLVMModuleRef module, int struct_id, int required)
16261626
/**
16271627
\brief Get an anonymous struct type.
16281628
1629-
Anonumous structs are identified by their contents, they don't have a name.
1629+
Anonymous structs are identified by their contents, they don't have a name.
16301630
This will either return an existing anonymous struct type with the required
16311631
elements, or create a new type with a copy of the elements array.
16321632

tools/flang2/flang2exe/llutil.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,10 @@ get_dtype_from_arg_opc(ILI_OP opc)
934934
case IL_ARGKR:
935935
case IL_DAKR:
936936
return DT_INT8;
937+
#ifdef LONG_DOUBLE_FLOAT128
938+
case IL_FLOAT128ARG:
939+
return DT_FLOAT128;
940+
#endif
937941
default:
938942
return 0;
939943
}
@@ -1043,6 +1047,10 @@ dtype_from_return_type(ILI_OP ret_opc)
10431047
return DT_INT8;
10441048
case IL_DFRCS:
10451049
return DT_CMPLX;
1050+
#ifdef LONG_DOUBLE_FLOAT128
1051+
case IL_FLOAT128RESULT:
1052+
return DT_FLOAT128;
1053+
#endif
10461054
default:
10471055
interr("dtype_from_return_type(), bad return opc", ret_opc, 4);
10481056
}
@@ -1367,6 +1375,23 @@ make_constval_op(LL_Type *ll_type, INT conval0, INT conval1)
13671375
return op;
13681376
}
13691377

1378+
OPERAND *
1379+
make_constval_opL(LL_Type *ll_type, INT conval0, INT conval1,
1380+
INT conval2, INT conval3)
1381+
{
1382+
OPERAND *op;
1383+
1384+
op = make_operand();
1385+
op->ot_type = OT_CONSTVAL;
1386+
op->ll_type = ll_type;
1387+
op->val.conval[0] = conval0;
1388+
op->val.conval[1] = conval1;
1389+
op->val.conval[2] = conval2;
1390+
op->val.conval[3] = conval3;
1391+
1392+
return op;
1393+
}
1394+
13701395
OPERAND *
13711396
make_constval32_op(int idx)
13721397
{
@@ -1921,7 +1946,13 @@ write_constant_value(int sptr, LL_Type *type, INT conval0, INT conval1,
19211946
case LL_X86_FP80:
19221947
assert(sptr, "write_constant_value(): x87 constant without sptr", 0, 4);
19231948
fprintf(LLVMFIL, "0xK%08x%08x%04x", CONVAL1G(sptr), CONVAL2G(sptr),
1924-
CONVAL3G(sptr) >> 16);
1949+
(unsigned short)(CONVAL3G(sptr) >> 16));
1950+
return;
1951+
1952+
case LL_FP128:
1953+
assert(sptr, "write_constant_value(): fp128 constant without sptr", 0, 4);
1954+
fprintf(LLVMFIL, "0xL%08x%08x%08x%08x", CONVAL1G(sptr), CONVAL2G(sptr),
1955+
CONVAL3G(sptr), CONVAL4G(sptr));
19251956
return;
19261957

19271958
case LL_PPC_FP128:
@@ -3079,7 +3110,7 @@ add_init_const_op(int dtype, OPERAND *cur_op, ISZ_T conval, ISZ_T *repeat_cnt,
30793110
case TY_DCMPLX:
30803111
cur_op->next = make_constval_op(make_lltype_from_dtype(DT_DBLE),
30813112
CONVAL2G(CONVAL1G(conval)),
3082-
CONVAL1G(CONVAL1G(conval)));
3113+
CONVAL1G(CONVAL1G(conval)));
30833114
cur_op->next->next = make_constval_op(make_lltype_from_dtype(DT_DBLE),
30843115
CONVAL2G(CONVAL2G(conval)),
30853116
CONVAL1G(CONVAL2G(conval)));

tools/flang2/flang2exe/llutil.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ typedef enum OperandFlag_t {
3737
typedef enum OperandOutputFlag_t {
3838
FLG_OMIT_OP_TYPE = (1 << 0),
3939
FLG_AS_UNSIGNED = (1 << 1),
40-
FLG_FIXUP_RETURN_TYPE = (1 << 2)
40+
FLG_FIXUP_RETURN_TYPE = (1 << 2),
41+
FLG_INNER_TYPED_COMPLEX = (1 << 3)
4142
} OperandOutputFlag_t;
4243

4344
#define LLTNAMEG(llt) llvm_type_names[(llt)->kind]
@@ -171,7 +172,7 @@ typedef struct OPERAND {
171172
union {
172173
int cc; /**< condition code value */
173174
int sptr; /**< sptr value */
174-
INT conval[2]; /**< constant value for OT_INDEX */
175+
INT conval[4]; /**< constant value */
175176
ISZ_T address; /**< address value for type OT_MEMBER */
176177
} val;
177178
char *string; /**< hold routine name for llvm intrinsic calls */
@@ -437,6 +438,8 @@ const char *llutil_strdup(const char *);
437438
OPERAND *make_operand(void);
438439
OPERAND *make_constval32_op(int);
439440
OPERAND *make_constval_op(LL_Type *ll_type, INT conval0, INT conval1);
441+
OPERAND *make_constval_opL(LL_Type *ll_type, INT conval0, INT conval1,
442+
INT conval2, INT conval3);
440443
OPERAND *make_constsptr_op(int sptr);
441444
OPERAND *make_var_op(int);
442445

0 commit comments

Comments
 (0)