This is an archive of the discontinued LLVM Phabricator instance.

Create android x86_32 and x86_64 target info
ClosedPublic

Authored by tberghammer on Mar 16 2015, 9:08 AM.

Details

Summary

Create android x86_32 and x86_64 target info

On android x86_32 the long double is only 64 bits (compared to 80 bits
on linux x86_32) and on android x86_64 the long double is IEEEquad
(compared to x87DoubleExtended on linux x86_64). This CL creates new
TargetInfo classes for this targets to represent these differences.

Diff Detail

Repository
rL LLVM

Event Timeline

tberghammer retitled this revision from to Create android x86_32 target info.
tberghammer updated this object.
tberghammer edited the test plan for this revision. (Show Details)
tberghammer added a reviewer: danalbert.
tberghammer added a subscriber: Unknown Object (MLST).

It should be possible to test this, no?

I don't have too much knowledge about clang so I am not sure, but if I compile an executable with clang for android-x86 (from android ndk r10d) then the DWARF info will contain the right size for long double (8 byte).
I run into this issue from LLDB in a case where we create a clang AST context based on a module and a triple and we ended up with wrong size for long double.

chh added a subscriber: chh.Mar 16 2015, 4:31 PM

Sounds like you should be able to put a test in clang/test/CodeGen.

danalbert edited edge metadata.Mar 16 2015, 4:51 PM

IIRC we don't get this right for x86_64 either. Currently uses 80-bit long double, should be 128-bit.

Sounds like you should be able to put a test in clang/test/CodeGen.

I think this code isn't used during codegen because clang generates the correct DWARF description for long double (64 bit) for android-x86 but I might be wrong. I would appreciate if you can give me some hint about what type of tests should I add and how.

IIRC we don't get this right for x86_64 either. Currently uses 80-bit long double, should be 128-bit.

In this file we specify 128 bit for long double on x86_64 but I am not sure what android-x86_64 use. I will check it tomorrow and update the patch if necessary.

chh added a comment.Mar 16 2015, 6:45 PM

With my partial comparison with current Android prebuilt gcc x86 configuration, I think the following additional changes maybe needed in AndroidX86_32TargetInfo.

SuitableAlign = 32;
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
tberghammer edited edge metadata.

Added missing settings pointed out by @chh.

Checked android-x86_64 and based on my understanding it uses 128 bit long double what match with the configuration specified in Targets.cpp for X86_64TargetInfo.

chh added a comment.Mar 17 2015, 4:23 PM

For 64-bit mode, the long double size is correct but format is not compatible with current Android gcc configuration.
I am testing the following configuration, which seems to work with Android x86_64-eng target.

namespace {
// x86_64 Android target
class AndroidX86_64TargetInfo : public LinuxTargetInfo<X86_64TargetInfo> {
public:

AndroidX86_64TargetInfo(const llvm::Triple &Triple)
    : LinuxTargetInfo<X86_64TargetInfo>(Triple) {
  LongDoubleFormat = &llvm::APFloat::IEEEquad;
}

};
} // end anonymous namespace

....

case llvm::Triple::x86_64:

if (Triple.isOSDarwin() || Triple.isOSBinFormatMachO())
  return new DarwinX86_64TargetInfo(Triple);

switch (os) {
case llvm::Triple::Linux:
  if (Triple.getEnvironment() == llvm::Triple::Android)
    return new AndroidX86_64TargetInfo(Triple);
  else
    return new LinuxTargetInfo<X86_64TargetInfo>(Triple);
tberghammer retitled this revision from Create android x86_32 target info to Create android x86_32 and x86_64 target info.
tberghammer updated this object.

Add android x86_64 target info

Based on my experiments the current configuration is correct about the specification of long doubles on android as LLDB manage to read and write long double values in both effected configurations based on these values (after a few independent changes in LLDB).

needs testcase.

needs testcase.

Can you give me some information about what type of test case should I write and how?
(I don't know too much about how clang and the clang tests are working. Run into this issue while working on LLDB.)

I assume you started this with a .c file that produces different
output with this patch, no?

In any case, this patch should change the value of (for example)
sizeof(long double), no? If so you should be able to add a test to
clang/test/Sema

tberghammer added a comment.EditedMar 18 2015, 8:33 AM

I assume you started this with a .c file that produces different
output with this patch, no?

Actually I started with a test failure in LLDB what lead me to a wrong value in ASTContext::LongDoubleTy. I investigated that issue when ended up with this CL.

danalbert accepted this revision.Mar 24 2015, 9:36 AM
danalbert edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Mar 24 2015, 9:36 AM
This revision was automatically updated to reflect the committed changes.