Skip to content

x86-64 Android: long double is binary128 but has no lowering — any long double signature, arithmetic, static initializer or variadic use is refused #1730

Description

@davidgmbb

This is the x86-64 counterpart of #72; #1720 fixes the AArch64 side.

Observed

Since #761, buster models x86-64 Android long double as IEEE binary128, matching Clang: __LDBL_MANT_DIG__ is 113 and sizeof(long double) is 16. There is no lowering for that format on x86-64, though, so every use beyond declaring one is refused:

$ build/Release/ide cc -c -target x86_64-linux-android f.c
long double f(long double a, long double b) { return a + b; }
  -> C IR lowering does not yet support the parameter or return value types of function 'f'
double f(double x) { long double y = x; return (double)(y * 2); }
  -> C IR lowering does not yet support wide floating-point arithmetic
static long double k = 1.5L;
  -> C IR lowering: cannot fold '1.5L' in a static initializer
printf("%Lf", (long double)x);
  -> C IR lowering does not yet support the parameter or return value types of function 'printf'

For reference, clang --target=x86_64-linux-android passes binary128 in XMM registers (SSE class, one register per value) and lowers a + b to call __addtf3.

A stale comment compounds this. c_ir_target_supports_f80 in src/buster/lib/compiler/frontend/c/c_gen.c still says x86-64 Android "deliberately shares" the 80-bit System V long double. The data layout says binary128, and that predicate correctly returns false.

Expected

x86-64 Android long double works like AArch64 after #1720, matching Clang's objects. That means:

Reproduction details

Uncertainty

Done when

The four snippets above compile for x86_64-linux-android in all MIR allocators with zero fallback, a Clang-oracled fixture (like compiler_driver_test_aarch64_binary128_runtime) passes, and the stale c_ir_target_supports_f80 comment is corrected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions