This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Change int64_t from 'long long int' to 'long int' for AArch64 target.
Needs ReviewPublic

Authored by kevin.qin on Feb 20 2014, 3:53 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

Hi Tim, Joerg and other reviewers,

Most 64-bit targets define int64_t as long int, and AArch64 should make same definition to follow LP64 model. In GNU tool chain, int64_t is defined as long int for 64-bit target. So to get consistent with GNU, it's better Changing int64_t from 'long long int' to 'long int', otherwise clang will get different name mangling suffix compared with g++.

Also, this patch will fix the bug in http://llvm.org/bugs/show_bug.cgi?id=18892.

Diff Detail

Event Timeline

joerg added a comment.Feb 20 2014, 4:29 AM

No objections from me.

Hi Kevin,

I think this patch will break 32-bit ARM and 64-bit Darwin, both of
which define int64_t to be "long long" for various reasons (32-bit ARM
because "long" is 32-bits, Darwin because Just Because. ;-)).

ItaniumMangle should be fine: that mangling is only used on AArch64
non-Darwin so globally changing it is fine. Targets.cpp looks fine to
me as well.

For SemaChecking.cpp, the getNeonEltType is shared among all
implementations; perhaps give it another bool parameter and rename the
existing one? IsPolyUnsigned & IsInt64Long for example.

NeonEmitter.cpp is a bigger problem, since there doesn't appear to be
an "int64_t" type string available. It seems reasonably easy to add
one (lib/AST/ASTContext.cpp -- DecodeTypeFromStr and a comment in
Builtins.def), but I'm not sure if there's a better solution (we're
running out of letters!)

There are also a couple of bugs on the host side:

  • qmask |= 1ULL << GetNeonEnum(Proto, TypeVec[ti]);

+ qmask |= 1UL << GetNeonEnum(Proto, TypeVec[ti]);

qmask and mask are Clang-internal 64-bit variables. This change will
truncate various lines in arm_neon.inc (#included into
lib/Sema/SemaChecking.cpp) when Clang is built on platforms with a
32-bit long.

The same goes for the change to the "case".

Cheers.

Tim.

Hi folks,

I created a test file where I include arm_neon.h.

I am using Linaro GCC 4.8 (calling the installation dir $GCC48). And it
fails to compile my test with errors like:

typedef attribute((neon_vector_type(1))) int64_t int64x1_t;

I invoke clang setting -target, --sysroot, -gcc-toolchain, mfpu=neon
variables:

clang -mfpu=neon --target=aarch64-linux-gnu
-sysroot=$$GCC48/aarch64-linux-gnu/libc --gcc-toolchain=$GCC48 test.c

The problem is the word size defined as 64 bits in this gcc header file:
$GCC48/aarch64-linux-gnu/libc/usr/include/bits/wordsize.h

It should be 32 bits.

It seems this commit from Jiangning works around the in GCC sysroot issue:
3dc9e80234b0112a0463feaf65049bcd858d1d36 (For AArch64, support
builtin neon vector type with 'long' as base element type)

But it looks like GCC should be fixed instead.

What do you think?

Ana.

kevin.qin updated this revision to Unknown Object (????).Feb 20 2014, 11:40 PM

Hi Tim,

Thanks for review. I added a new modifier 'W' to represent int64, and change to use it instead of 'LL' in NeonEmitter.cpp. Then I think the effect on 32-bit ARM target would be fixed. Also fixed other bugs you mentioned and added a test case to show how int64_t and uint64_t be mangled for both ARM and AArch64. Please review again.

Hi Kevin,

I think this patch looks good, thanks for updating it.

Cheers.

Tim