Commit graph

69 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
Martin Kinkelin
b27a1e0076 Lazily define class *memory* IR type
To break remaining cycles in DtoType() - a class *ref* is an opaque
IR pointer nowadays.
2024-08-18 19:34:28 +02:00
Martin Kinkelin
ba9af8d3d1 Tighten checks for IR aggregate sizes 2024-08-18 15:30:51 +02:00
Martin Kinkelin
0c1623c1a0 Replace getVoidPtrType() 2024-07-18 23:21:10 +02:00
Martin Kinkelin
d16fba3030 Rework packed-ness of IR aggregates
Base it on the IR alignments of the fields only.

Also fix the alignment of variables captured by ref (=> pointer
alignment, not the pointee's) and captured lazy params (=>
delegate alignment) in nested frames, something that cropped up with
a new assertion.
2022-08-14 14:54:27 +02:00
Martin Kinkelin
9dd4d5a2ab [assert that IR aggregate type sizes match the D size] 2022-08-06 15:11:48 +02:00
Martin Kinkelin
3f716ff75e Refactoring: Introduce getIrType()
As *the* way to access the IrType associated with a Type via its `ctype`
field. Most importantly, it makes sure all access is redirected to the
*unqualified* type's `ctype`, which allows to get rid of the 'multiple
types' workaround for aggregates in DtoType(). Those were e.g. hit for
`shared struct SpinLock`, where the struct's type includes the `shared`
modifier...
2020-11-13 15:43:18 +01:00
Martin Kinkelin
4ac7f0554b Adapt to frontend refactorings 2019-12-22 16:29:45 +01:00
Martin Kinkelin
5e93ed0dfd Upgrade front-end & libs to v2.085.0-beta.1 2019-03-01 18:19:00 +01:00
Martin Kinkelin
4a23399236 Aim for consistent #includes (order + dir prefix)
I surely missed a few.
2018-10-20 16:19:46 +02:00
FeepingCreature
5bd2c7ff0d fix issue 2422 - remove overzealous error check (#2423)
* fix issue 2422
remove overzealous error check - global.errors may be nonzero due to speculative error at this point!
ie. when trying to speculatively make a constant class expression
2017-11-24 17:00:07 +08:00
Johan Engelen
3b28e79a9f Remove unused variables. 2017-01-20 22:21:39 +01:00
Martin
16d15e01cb Use opaque [N x i8*] for vtables
This fixes the forward-referencing issue #1741.
2016-11-21 21:54:53 +01:00
Martin
e1394fad5f Build vtable type lazily 2016-11-19 15:29:19 +01:00
Martin
ac93f4d0af Run functionSemantic() instead of full semantic3() to infer return type 2016-08-19 22:57:04 +02:00
Rainer Schuetze
1b4d8569b8 fix issue #1473: ICE when implementing extern(C++) interfaces 2016-05-08 22:11:55 +02:00
David Nadlinger
bb784bd7a4 ir: Implement new inheritance object layout
This is as per DMD a54e89d, but has not been tested all too carefully
yet – there still seem to be issues with extern(C++) interfaces (see
test suite).
2016-04-03 15:15:14 +01:00
David Nadlinger
6d2ac89aa3 irtypeclass: Rename addBaseClassData since it handles not just base classes, document better [nfc] 2016-04-03 15:15:14 +01:00
David Nadlinger
6a59286339 irtypeclass: Some constification/modernisation [nfc] 2016-04-03 15:15:14 +01:00
David Nadlinger
9f998a398d Initial merge of upstream v2.071.0-b2
Notably, the glue layer side of the changed multiple interface
inheritance layout (DMD a54e89d) has not been implemented yet.

This corresponds to DMD commit 3f6a763c0589dd03c1c206eafd434b593702564e.
2016-04-03 15:15:14 +01:00
Johan Engelen
29ce4012af dmd2 --> ddmd. Merge (almost all of) our changes to dmd source into the new D source of dmd 2.069.2.
Also adds the CMake infrastructure to compile and link the D source files.

The build is partially broken:
- A few files in Phobos and druntime do not build
- MSVC build is broken because of unresolved symbols involving reals
2016-01-28 19:03:58 +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
52532985a9 IR source directory: use C++11 inline-initialization in headers 2015-11-01 19:30:04 +01:00
Martin
2d959ea540 Make use of C++11 range-based for
Should be available now that support for LLVM < 3.5 has been dropped.
2015-11-01 14:49:04 +01:00
Martin
60d676e2a1 Drop support for LLVM < 3.5
This allows to clean up the code a little.
2015-10-30 22:24:05 +01:00
Alexey Prokhin
9314fc1c1c Fix issue 726: Wrong alignment for struct fields on x86_64/amd64 2014-10-11 18:12:11 +04:00
Alexey Prokhin
0b180be099 [cleanup] Merge common code in IrTypeStruct::get() and IrTypeClass::addBaseClassData() 2014-10-11 17:58:18 +04:00
David Nadlinger
bff766b379 Track member field index in IrTypeAggr, not IrField.
This fixes a regression introduced in caa2f15c8a. The IrDsymbol
metadata is obviously reset in between modules, while IrTypes
are not. Thus, we can never set symbol metadata when resolving
types, as the symbol data will be wrong in all modules following
the one where the type was first resolved.

GitHub: Fixes #739.
2014-10-11 03:28:49 +02:00
David Nadlinger
de742a06e2 [cleanup] Remove unused IrTypeAggr::default_fields and accessors. 2014-10-11 03:28:48 +02:00
Alexey Prokhin
66a392a5c2 Rename Type::irtype to ctype for consistency with dmd and gdc 2014-10-05 16:55:12 +04:00
Alexey Prokhin
caa2f15c8a Remove VarDeclaration::aggrIndex 2014-10-05 16:08:52 +04:00
Alexey Prokhin
0676e460ec C++ classes do not have monitors 2014-07-10 15:26:09 +04:00
kai
c6f856c01e Remove last uses of ArrayIter<>. 2014-01-12 18:07:27 +01:00
kai
6287a4d422 Replace ArrayIter<> with Array<>::iterator.
Just use the new iterator instead of the old Java-like class.
Also removes a dead iterator and replaces an iterator with a
pointer in some place.
2014-01-11 14:48:41 +01:00
David Nadlinger
68f8e38f51 Merge branch 'master' into merge-2.064. 2013-12-26 12:37:03 +01:00
David Nadlinger
f85d2a5a0a Respect type alignment when choosing padding fields.
Fixes ABI mismatch when e.g. padding a 28 byte union from a
20 byte member, where previously, an i64 would be emitted,
yielding a 32 byte LLVM struct size on ulong.alignof == 8
platforms.

Test case will follow on the 2.064 branch.
2013-12-26 12:35:19 +01:00
David Nadlinger
cb341586e3 First merge of 2.064 beta.
This corresponds to DMD commit a913ce4bc59a94a022a27e390fc841f4aededffb.

Doesn't build Phobos yet.
2013-10-29 19:21:15 +01:00
Alexey Prokhin
b819975c84 Eliminate the need for TypeFunction::funcdecl 2013-10-05 19:03:03 +04:00
Alexey Prokhin
90bb32d2d8 extern(C++) interfaces 2013-06-22 17:33:00 +04:00
David Nadlinger
292caa1438 Merge the 2.063 frontend. 2013-06-12 20:16:37 +02:00
David Nadlinger
848dee32d4 Store bools as i8.
I really hope we can refactor this to use a less leaky
abstraction later – it should at least be possible to merge
voidToI8 and i1ToI8.
2013-06-07 03:20:54 +02:00
kai
1e4a8fffc2 Remove DMDV1 and DMDV2. 2013-03-06 10:20:24 +01:00
kai
a11459bc31 "The Great Renaming" continues.
More changes to match the renamed files of LLVM 3.3.
2013-01-06 17:17:30 +01:00
David Nadlinger
a3a511ca55 Refactored IrType construction to use static get() method.
This also allows us to enable the assert in IrType::IrType.

Unfortunately, this is mostly a "peace of mind" commit, there
doesn't seem to have been a bug actually caused by the transitory
duplicate IrTypePointer/IrTypeStruct instances.

The remaining xyz2llvm static methods are not exactly pretty,
they should probably just be folded into get.
2012-12-20 23:52:09 +01:00
David Nadlinger
464c695814 Renamed IrType::get/IrType::getD, treat classes as the special case they are. 2012-12-20 23:52:09 +01:00
David Nadlinger
59a4a02e49 Cleanup: Avoid signed/unsigned comparisons.
The ones ones left are for DMD-defined constants.
2012-12-20 01:21:09 +01:00
David Nadlinger
f68e914da6 Workaround for ICE due to auto return type not being inferred.
GitHub: Fixes #217.
2012-12-19 22:55:18 +01:00
David Nadlinger
9458911839 Added LLVM-style license headers to all our files. 2012-12-16 17:19:14 +01:00
kai
311297b096 Prefer C++-style casts.
This is based on Item 2 of "More Effective C++". In general, the C++ cast operators are more expressive and easy to find,
e.g. by grep. Using const_cast also shuts up some compiler warnings.
2012-08-03 06:32:23 +02:00