Commit graph

866 commits

Author SHA1 Message Date
Luna
82878ef32c
Improve Objective-C support (#4777)
* WIP: Objective-C support

* Further work on implementation

* ObjC dynamic cast

* Add swift stub class attribute

* Classes, protocols and ivars

* Fix compilation issues

* Fix objc ir codegen

* Add objc linker option

* Add swift stub classref get ir gen

* Minor cleanup

* Fix objc link flag being added on non-darwin platforms

* Refactor objc gen

* remove use of std::nullopt

* Emit protocol tables

* Remove unused variable

* Formatting

* Fix build in release mode. Thanks for nothing, c++.

* Fix consistency

* Fix dynamic casts

* Fix tocall parentfd ref and arm msgsend call

* Make instance variables work

* Implicitly add isa pointer to objc classes.

* Fix protocol referencing & allow pragma mangle

* Fix protocol linkage

* Fix direct call support

* always generate var type for methods

* Fix test 16096a

* Fix extern ivar symbol gen, retain method decls

* Remove arm32 and x86 support

* Check method and ivar info before pushing to member list

* Make ObjcMethod info untyped.

* Make ivar and method gen more robust

* Generate optional protocol symbols

* Use bitcasting instead of creating multiple type defs

* Fix invalid protocol list struct gen

* More codegen robustness

* emit protocol table as const

* Make protocol table anon struct

* Fix callable type, generate protocol_list_t properly.

* Cast vthis to argtype

* Handle protorefs and classrefs properly

* seperate label ref and deref

* Fix method lookup

* Enable objective-c tests

* Enable objc_call_static test

* Scan both classes and protocols for method ref

* Enable objective-c tests on arm as well.

* supress objc linker warning in tests

* Fix class and protocol gen structure

* Fix objc_protocol_sections test

* ObjcMethod only get callee for functions with bodies

* Fix protocol class method gen

* Make ObjcMethod anon again

* Fix missing emit calls

* Fix classref gen

* Implement some of the requested changes

* Enable compilable tests

* Fix property selector gen, ugly hack for final funcs.

* Fix segfault in referencing fd->type

* Refactor implementation

* Fix null references in class and method lookup

* include unordered_map

* Get functionality on-par with prev impl.

* Fix super context calls

* Move -L-w flag to d_do_test and use IN_LLVM in objc.d/h

* add LDC version tag to -L-w flag

* Update CHANGELOG.md
2024-12-03 04:26:27 +01:00
liushuyu
ce45b2e8b1 gen/llvm.h: add a type parameter to GET_INTRINSIC_DECL macro ...
... because now LLVM requires most intrinsics to have parameter types
specified
2024-11-26 08:46:15 -07:00
Martin Kinkelin
2463fe9949 Merge remote-tracking branch 'origin/master' into merge-2.110 2024-08-02 19:15:45 +02:00
Martin Kinkelin
a3d4f32284
Merge pull request #4710 from kinke/getOpaquePtrType
Remove some typed-IR-pointer left-overs
2024-07-26 20:08:27 +02:00
Martin Kinkelin
c271cf9fae Merge remote-tracking branch 'origin/master' into merge-2.110 2024-07-19 17:54:45 +02:00
Martin Kinkelin
866be1e8cb
Fix bit field IR storage from weird integer to i8 array (#4708)
Fixes #4646.
2024-07-19 17:53:32 +02:00
Martin Kinkelin
0c1623c1a0 Replace getVoidPtrType() 2024-07-18 23:21:10 +02:00
Martin Kinkelin
18709bb77f Replace getPtrToType() 2024-07-18 22:33:24 +02:00
Martin Kinkelin
c9ac30c236 Adapt to free-standing size(Type*) function 2024-07-16 16:22:35 +02:00
Martin Kinkelin
a37c2ab5f0 Get rid of now unused variables 2024-05-20 17:48:59 +02:00
Martin Kinkelin
4818101c3e Get rid of some superfluous GEPs with (0, 0) indices 2024-05-20 17:30:02 +02:00
Martin Kinkelin
1ea2ba1df7 Get rid of base flag in DtoTypeInfoOf() 2024-05-20 17:30:01 +02:00
Martin Kinkelin
4c74f64a9c Get rid of D type param in DtoConstSlice() 2024-05-20 17:30:01 +02:00
Martin Kinkelin
d140f2a283 Skip superfluous IR pointer bitcasts, now that they are always opaque 2024-05-20 16:45:09 +02:00
Martin Kinkelin
e7091dd0c7 Drop support for LLVM < 14
LLVM 14 is the first version supporting both new pass manager and
opaque IR pointers.
2024-05-12 03:53:03 +02:00
Johan Engelen
bc00d4b775
Add memory invariant assumptions for virtual calls to improve devirtualization (#4596)
Assumptions:
- class methods do not change the object's vtable pointer
- loads through vtable pointer are invariant (vtables are immutable throughout program life)
2024-04-05 16:14:38 +02:00
Martin Kinkelin
078f0532ca Don't forward-declare magic intrinsics mapping to instructions
It's ugly in general, and apparently causes LTO issues on Windows.

This required a larger refactoring.
2024-03-16 16:28:09 +01:00
Martin Kinkelin
0a69a8451a Add support for new ulong[] hex string literals 2024-03-09 02:19:38 +01:00
Martin Kinkelin
9041c0bf67 Adapt to free functions in dmd C++ namespace now 2024-03-03 19:14:00 +01:00
Martin Kinkelin
a3aadfcce8 Adapt to new multi-dimensional array allocation lowering
Fixes runnable/test28.d.
2024-01-19 19:42:17 +01:00
Johan Engelen
91d306894e
Add support for LLVM 17. (#4533) 2023-12-03 19:07:31 +01:00
Martin Kinkelin
01d8805dc5 Detect invalid array-append with -betterC
To fix new fail_compilation/test24159.d.
2023-12-02 19:32:56 +01:00
Martin Kinkelin
97fdc26b30 Merge fix: Adapt to new CatAssignExp::lowering field 2023-12-02 19:32:56 +01:00
Martin Kinkelin
406df56b82 Add new CLI options -fno-moduleinfo and -fno-rtti
Using the same names as GDC.
2023-11-06 21:25:18 +01:00
Martin Kinkelin
2b3ffeb882 Merge fix: Adapt to removed CommaExp::copy() 2023-11-06 01:10:16 +01:00
Martin Kinkelin
d6d79187e6 Merge fix: Adapt to removed error/warning members 2023-11-06 01:10:16 +01:00
Martin Kinkelin
c5704c764d Adapt to new _d_newitemT template lowering for heap-allocations of structs 2023-08-26 16:48:04 +02:00
Martin Kinkelin
5d3ded9eeb Remove legacy LL[Maybe]Align 2023-07-29 02:09:35 +02:00
Martin Kinkelin
9ce57807c0 Drop support for LLVM 9 and LLVM 10 2023-07-29 01:12:43 +02:00
Martin Kinkelin
67885a8ef7 Adapt to new _d_arraycatnTX template lowering 2023-07-16 13:46:34 +02:00
Martin Kinkelin
a6dc3fa73a Adapt to new _d_arraysetlengthT template lowering 2023-07-16 13:43:00 +02:00
Martin Kinkelin
8151a5f65c Merge fixes to get compiler to compile 2023-07-15 19:25:11 +02:00
Martin Kinkelin
145cf715c0 ImportC: Lower AssertExp to C assert
Fixes runnable/testcheck.c.
2023-03-25 17:48:54 +01:00
Martin Kinkelin
56c6a3f5be Allocate scope dynamic-array literals on the stack
A new D v2.102 feature, tested by tests/dmd/runnable/test20734.d.
2023-02-19 01:43:09 +01:00
Martin Kinkelin
3a59ee81c9 Adapt to vector comparisons now yielding a vector mask
Except for identity comparisons, which still yield a scalar bool.
(DMD doesn't support vector identity comparisons for some reason.)
2023-02-19 01:43:09 +01:00
Martin Kinkelin
5f46c65ab5
Fix v1.31 regression wrt. unresolved IrAggr (#4312)
And use `IrTypeClass::getVtblType()` to get the vtable LLVM array
type, instead of deriving it from the `IrClass::getVtblSymbol()`
global (invoking that function may define the vtable!).

I've hit some compiler crashes for the Symmetry code base, on
Windows only. I guess the problem surfaced due to
`-link-defaultlib-shared`, which on Windows causes some vtables of
instantiated classes to be defined whenever accessing the vtable
symbol. I don't have a reduced test case unfortunately.
2023-02-06 17:02:07 +01:00
Martin Kinkelin
58c4b8bdae
Fix #4309 - missing i1/void-to-i8 promotion for GEP pointee type (#4310) 2023-01-28 17:54:30 +01:00
Martin Kinkelin
bdb247e697 Use DtoGEPi64 for 64-bit targets only
Primarily to more robustly deal with potentially truncated const-
folded offsets (according to target bitness), such as after
https://github.com/dlang/dmd/pull/14299, where we've been emitting
a 64-bit GEP with index 4294967286 for the `codegen/gh2865.d` test
case and 32-bit targets (vs. 64-bit index `-10` before that new
upstream truncation).

Switch back to 32-bit GEPs for non-64-bit targets, and accordingly
to a 32-bit index `-10` for that test case.
2023-01-22 18:05:55 +01:00
Martin Kinkelin
153f8ccdce Fix regression for LDC-specific elide-scope-class-finalization optimization
`NewExp.type` can apparently newly be a yet-unresolved `TypeIdentifier`.
Resolve it in that case to a `TypeClass` now.

Also defer the has-dtor check for the whole class hierarchy of the
*dynamic* type from that LDC-specific frontend addition to the glue
layer, as I'm not sure we can rely on `ClassDeclaration.dtor` having
been set at that time already.

I've chosen to keep storing a single extra LDC-specific *bit*
(`onstackWithMatchingDynType`) instead of storing the full dynamic
class type. While this slightly weakens the optimization (no
optimization for non-equivalent static/dynamic class types anymore),
it doesn't increase the AST node size. And I think almost all cases
use an equivalent type anyway (e.g., the DMD frontend itself only uses
`scope` class allocations with equivalent types).
2023-01-21 18:38:28 +01:00
Martin Kinkelin
2d15347ebe Merge remote-tracking branch 'origin/master' into merge-2.101 2023-01-15 13:49:20 +01:00
Zachary Yedidia
8006b95b7e
Fix miscompilation when adding a 64-bit constant to a symbol (#4283)
Fixes #4264
2022-12-21 00:32:36 +01:00
Martin Kinkelin
72391f7210 Support new new AA syntax, lowering to a _aaNew call 2022-12-01 01:59:50 +01:00
Martin Kinkelin
14759a744e ImportC: Account for StringExp typed as static array with length > string length
Fixes dmd-testsuite's compilable/test23066.c.
2022-10-07 00:04:46 +02:00
Martin Kinkelin
e040d28745 Merge remote-tracking branch 'origin/master' into pre-monorepo 2022-10-04 14:19:56 +02:00
Nicholas Wilson
906037988f
Move abi*.* to abi/ (#4192) 2022-09-21 13:16:04 +00:00
Nicholas Wilson
1951db6d1d
Deprecate -check-printf-calls (#4183) 2022-09-18 10:25:43 +08:00
Nicholas Wilson
f27b9461b8
remove warnInvalidPrintfCall, it is handled by dmd (#4179) 2022-09-18 06:56:59 +08:00
Martin Kinkelin
b81c2b5510 Adapt to new array-append frontend lowerings 2022-09-15 21:00:53 +02:00
Martin Kinkelin
dd5f696d2e Merge remote-tracking branch 'origin/master' into pre-monorepo
Conflicts:
	gen/toir.cpp
	runtime/druntime
2022-09-15 14:56:49 +02:00
Nicholas Wilson
af51b700be
Rename DtoAggrPaint to DtoSlicePaint (#4174)
It only does two elements and is exclusively used for slices
2022-09-15 20:44:28 +08:00