@@ -382,6 +382,9 @@ static OPERAND *convert_int_size(int, OPERAND *, LL_Type *);
382382static OPERAND * convert_int_to_ptr (OPERAND * , LL_Type * );
383383static 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 )
386389static 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+
81848227static char *
81858228vect_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.
0 commit comments