Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[builtins] Generate __multc3 for z/OS #77554

Merged
merged 7 commits into from Jan 12, 2024

Conversation

perry-ca
Copy link
Contributor

#68132 ended up removing __multc3 & __divtc3 from compiler-rt library builds that have QUAD_PRECISION but not TF_MODE. I added support for QUAD_PRECISION to use the native long double representation if not in TF_MODE.

Copy link

github-actions bot commented Jan 10, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@perry-ca perry-ca changed the title Generate __multc3 for z/OS [builtins] Generate __multc3 for z/OS Jan 10, 2024
#elif __LDBL_MANT_DIG__ == 113 || \
(__FLT_RADIX__ == 16 && __LDBL_MANT_DIG__ == 28)
// Use long double instead of __float128 if it matches the IEEE 128-bit format
// or the IBM hexadecimal format.
#define CRT_LDBL_128BIT
#define CRT_HAS_F128
#define CRT_HAS_IEEE_TF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These last two macros should only be defined for the __LDBL_MANT_DIG__ == 113 case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CRT_HAS_F128 needs to be defined for hex float too. The Qcomplex and COMPLEXTF_REAL/COMPLEXTF_IMAGINARY ids are only defined if CRT_HAS_F128 is defined and multc3.c/divtc3.c depend on those.

I agree with CRT_HAS_IEEE_TF. This should also only be defined if CRT_HAS_TF_MODE is defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double checked and Qcomplex is defined via CRT_LDBL_128BIT. I can limit CRT_HAS_F128 to IEEE too.

@@ -15,8 +15,6 @@
#include "int_lib.h"
#include "int_math.h"

#if defined(CRT_HAS_TF_MODE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this diff still needed? The macro should be defined with the change to int_types.h. Or is the problem here that int128 is not supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int128 isn't supported on z/OS yet. This change enables quad precision without needing to have TF mode enabled. We need this diff otherwise we don't get __multc3 defined.

perry-ca and others added 2 commits January 11, 2024 14:21
Co-authored-by: Alexander Richardson <mail@alexrichardson.me>
Co-authored-by: Alexander Richardson <mail@alexrichardson.me>
@@ -15,8 +15,6 @@
#include "int_lib.h"
#include "int_math.h"

#if defined(CRT_HAS_TF_MODE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we support architectures without a "tf" floating point type. To be safe I believe we still need a guard here since this file is compiled unconditionally. We just have to replace it with "CRT_HAS_F128".

A nice future cleanup would be to change CRT_HAS_TF_MODE to actually mean tf_float exists and explicitly guard for INT128 where needed. But that is a larger cleanup that probably shouldn't be part of this PR.

@@ -13,8 +13,6 @@
#define QUAD_PRECISION
#include "fp_lib.h"

#if defined(CRT_HAS_TF_MODE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest replacing this with CRT_HAS_F128 as noted below (unless you're will to audit all current uses of CRT_HAS_TF_MODE since that currently is a proxy for TF_MODE&&INT128 rather than just TF_MODE).

Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this looks good to me now and should not change anything for other targets.

@perry-ca
Copy link
Contributor Author

Thanks. I don't have write access yet. Would you be able to merge this.

@arichardson arichardson merged commit cc0065a into llvm:main Jan 12, 2024
4 checks passed
@perry-ca perry-ca deleted the compiler-rt-quad-funcs branch January 12, 2024 05:05
vitalybuka added a commit that referenced this pull request Jan 12, 2024
@@ -374,10 +376,10 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) {
#endif
}

#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE)
#elif defined(QUAD_PRECISION)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was actually required. Probably needs to be changed to #elif defined(QUAD_PRECISION) && defined(CRT_HAS_F128). @perry-ca Could you open a new PR with this change? See #77898 and #77880

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've put up #77981 for review.

justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
llvm#68132 ended up removing
__multc3 & __divtc3 from compiler-rt library builds that have
QUAD_PRECISION but not TF_MODE due to missing int128 support. I added support for QUAD_PRECISION to
use the native hex float long double representation.

---------

Co-authored-by: Alexander Richardson <mail@alexrichardson.me>
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants