Commit graph

37 commits

Author SHA1 Message Date
Martin
de9149f1b6 Remove getLVal() from DValue and add DtoL/RVal() overloads 2016-06-13 22:30:16 +02:00
Martin
963a10b225 Let DValue types handle memory-only types consistently
I.e., disallow memory-only values from being represented as DImValues
and disallow getRVal() for such types instead of returning the address.
2016-06-13 22:30:14 +02:00
Martin
e3e2f4b2e9 DValue: Remove method getType()
Use the existing public field directly instead.

It's shorter and different than LLValue's getType() (making it easier
to discriminate DValues and LLValues for experienced LDC devs imho).
2016-06-13 22:30:13 +02:00
Martin
dd21a805ee Trim signature of method ABIRewrite::type() 2016-05-29 11:04:29 +02:00
Martin
fc6c340661 Optimize ABIRewrite system for lvalues
Allow ABIRewrites to return the D parameter's LL value directly.
Most rewrites store to memory anyway, so let the D parameter point
directly to that memory instead of a dedicated alloca bitcopy.
2016-05-28 21:03:56 +02:00
Dan Olson
deb3847f75 ARM AAPCS: struct rewrite with 8-byte alignment
structs with 8-byte alignment or greater needs to be rewritten as
array of i64 to be compatible with the AAPCS C ABI.
2016-04-19 05:16:38 +00:00
Kai Nacke
c1c7846e74 Introduce new ABI class for PPC64LE.
The ABI for PPC/PPC64 big-endian is quite similar.
But the ABI for PPC64 little-endian is more like the ARM ABI.
2016-03-28 03:14:00 +02:00
Kai Nacke
657df158ba Linux/AArch64: Better ABI implementation. 2016-03-13 01:54:16 +00:00
Dan Olson
b9b4564d22 Implement ARM AAPCS ABI
This is the bulk of the AAPCS (Procedure Call Standard for the ARM
Architecture) used for C interop.  This will be used for both arm and
thumb target triples.  The extern(D) ABI tries to follows the AAPCS with
a few exceptions.
2016-02-05 09:04:09 -08:00
Martin
b8de3531a8 Fixes and adaptations for generic x86 and Win64 TargetABIs
* x86: Return most POD aggregates <= 8 bytes in registers
  * For extern(D), as in official Win32 D ABI specs [previously: sret]
  * For all other calling conventions too, except for Linux and NetBSD
    [previously: OSX and MSVC only]
* MSVC++ and extern(C++): treat structs with constructors as non-POD,
                          for both x86 and Win64 ABIs
* Win64: Pass and return magic C++ structs directly as LL aggregates,
         rendering MSVCLongDoubleRewrite obsolete
* x86: Fix regression introduced by previous commits wrt. passing the
       last struct argument in EAX register
2015-12-08 19:15:15 +01:00
Martin
386622848f Win64 ABI: Rewrite magic __c_long_double struct as double
__c_long and __c_ulong have already been passed directly as LL structs
containing a single 32-bit value, i.e., as 32-bit scalars in the end.

__c_long_double on the other hand was rewritten to a 64-bit integer as any
other 64-bit POD struct, and so passed in a GP register instead of an XMM
register.
2015-12-06 17:37:48 +01:00
Martin
7c544be9d1 Respect explicit type alignments for LL args passed im- and explicitly by value
And for sret args too, except for MSVC targets.

At least on Win64, the sret align attributes lead to ICEs for std.bitmanip
and std.uni (release only), when computing the known alignment in the LLVM
inliner pass:

Assertion failed: I->getParent()->getParent() ==
Q.CxtI->getParent()->getParent() && "Got assumption for the wrong function!",
file C:\LDC\llvm\lib\Analysis\ValueTracking.cpp, line 711
2015-12-04 23:25:06 +01:00
Martin
0671e91d6b Remove getTypePaddedSize() and use getTypeAllocSize() instead
The functions were equivalent, only leading to confusion.
2015-12-04 22:23:09 +01:00
Martin
ddfaac10b3 Rename DtoAggrCopy/ZeroInit() to DtoMemCpy/SetZero() overloads
And replace some obvious load->store combos by a memcpy.
2015-12-04 22:23:09 +01:00
Martin
740a21eb8f Rename DtoIsPassedByRef() to DtoIsInMemoryOnly()
Motivation: issue #937
2015-12-04 22:23:09 +01:00
Martin
04ab1c2441 Clarify semantics of TargetABI::passByVal() 2015-11-02 23:35:27 +01:00
David Nadlinger
9df487edff gen/ir: clang-tidy the world 2015-11-02 11:30:40 +02:00
David Nadlinger
44b0f7b615 driver/gen/ir: clang-format the world
This uses the LLVM style, which makes sense for sharing code
with other LLVM projects. The DMD code we use will soon all
be in D anyway.
2015-11-02 00:28:01 +02:00
Martin
b13565c17e Refactor common i1ToI8(voidToI8(DtoType(...))) code occurrences 2015-10-03 22:58:00 +02:00
Martin
80c677be46 Slightly refactor ABIRewrite interface for clarification
* put(): pass DValue alone, without explicit D type
* get(): pass LLValue instead of a faked DValue
2015-09-26 00:30:24 +02:00
Martin
9e194bfe2c Refactor store-to-new-alloca code occurrences. 2015-09-25 17:12:42 +02:00
Martin
01e3e372fa Win64 ABI fix: return non-POD structs via sret.
And get rid of obsolete integer rewrites on Win64 and PPC.
2015-02-28 22:51:51 +01:00
Martin
dbe801ddff Refactor ABI rewrites. 2015-02-23 22:52:12 +01:00
Martin
3f02467d31 Improve some ABI rewrites.
Support structs/static arrays and basic types in X86_64_C_struct_rewrite.
2015-02-23 22:52:11 +01:00
Martin
42c793d12b Use single ByVal ABI rewrite for both Win64 and PPC. 2015-02-23 22:52:11 +01:00
Martin
d8bdb77e47 Get rid of CfloatToInt ABI rewrite and extend CompositeToInt.
CompositeToInt now also accepts complex number pairs and all other types,
not just pointers to structs/static arrays.
2015-02-23 22:52:10 +01:00
Martin
9c9d0f66c7 Don't swap real and imaginary parts of complex numbers.
Rely on LLVM to select a sane order, don't use DMD as reference anymore.
2015-02-23 22:52:10 +01:00
Martin
51b45675cc Support for Windows x64 ABI. 2013-02-10 22:08:35 +01:00
David Nadlinger
0a96aea868 Sort includes according to style guidelines:
1. Main include corresponding to .cpp file, if any.
 2. DMD and LDC includes.
 3. LLVM includes.
 4. System includes.

Also updated a few include guards to match the default format.
2013-02-07 21:20:55 +01:00
David Nadlinger
9458911839 Added LLVM-style license headers to all our files. 2012-12-16 17:19:14 +01:00
David Nadlinger
62bfda0259 Fix #113 - promotion of small static array arguments to registers. 2012-06-06 22:55:59 +02:00
Alexey Prokhin
629f13929e WIP: port to llvm 3.0 2011-10-25 15:43:39 +04:00
Alexey Prokhin
7f0ecdf7b9 More X86_64 ABI 2011-03-26 19:30:17 +03:00
Alexey Prokhin
70aee84c70 Fix passing of a padded struct to a function 2011-02-26 20:16:01 +03:00
Alexey Prokhin
20e6c65200 To follow D ABI, swap real and imaginary parts of a complex return value on X86_64
TODO: should we disable this transformation for ldc1 in order to keep its ABI unchanged?
2011-02-26 13:04:09 +03:00
Alexey Prokhin
53fe662957 Fix a bunch of incorrect assert 2011-02-25 22:29:34 +03:00
Frits van Bommel
541f3723cd Intrinsics shouldn't see struct padding, so use a special TargetABI for them
that removes it.
This unbreaks the `llvm_*_with_overflow` intrinsics.
2009-05-16 13:06:49 +02:00