Commit graph

291 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
0c1623c1a0 Replace getVoidPtrType() 2024-07-18 23:21:10 +02:00
Martin Kinkelin
a37c2ab5f0 Get rid of now unused variables 2024-05-20 17:48:59 +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
Martin Kinkelin
8f6867e456 Fix compile error with LLVM 18 2024-03-28 16:42:51 +01:00
liushuyu
fc4d884d2d
Multiple changes ...
* Use getVoidPtrType helper
* Replace #define with constexpr
2024-03-26 14:48:36 -06:00
liushuyu
b8a96faf92 tree-wide: port LDC to LLVM 18 2024-03-26 14:45:35 -06:00
Martin Kinkelin
ef72dedd7c
Refactor away LDC-specific FuncDeclaration::intrinsicName (#4595)
Using `mangleOverride` directly instead. Also get rid of superfluous
string copies. And for LLVMatomic_rmw, don't store the operation
string in the instantiated FuncDeclarations anymore, but fetch it
from the parent TemplateDeclaration.
2024-03-21 16:50:06 +01:00
Martin Kinkelin
bb2dec2f87 Adapt to free arrayOf(Type*) function 2024-03-03 22:12:16 +01:00
Martin Kinkelin
9041c0bf67 Adapt to free functions in dmd C++ namespace now 2024-03-03 19:14:00 +01:00
Martin Kinkelin
b06beb049a Handle invalid orderings for fence intrinsic
By not emitting any IR instruction, like clang.
2024-01-19 02:29:21 +01:00
Martin Kinkelin
d6d79187e6 Merge fix: Adapt to removed error/warning members 2023-11-06 01:10:16 +01:00
Martin Kinkelin
9b50726ae2 Fix multiple va_start calls in a single extern(D) function
This is supposed to work (verified via clang), and we need to properly
va_copy the implicit _argptr, so that each resulting `ap` is independent.
Fixes a new subtest in dmd-testsuite's runnable/variadic.d on Posix
x86_64.
2023-08-30 16:08:13 +02:00
Martin Kinkelin
87b22436e4 Fix function pointers/delegates on Harvard architectures
Resolves issue #4432 by setting the address space of such IR pointers.
2023-08-05 12:21:50 +02:00
Martin Kinkelin
69d636a15a Remove legacy LLCallBasePtr 2023-07-29 02:09:35 +02:00
Martin Kinkelin
5d3ded9eeb Remove legacy LL[Maybe]Align 2023-07-29 02:09:35 +02:00
Johan Engelen
338f352bdb
Add ldc.attributes.callingConvention("...") (#4299)
Add ldc.attributes.callingConvention("...")
2023-01-19 22:44:19 +01:00
Nicholas Wilson
906037988f
Move abi*.* to abi/ (#4192) 2022-09-21 13:16:04 +00: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
Nicholas Wilson
2476641551
Remove unused variable from ImplicitArgumentsBuilder (#4166) 2022-09-14 15:10:55 +08:00
Nicholas Wilson
5c789fa209
Remove getContainedType from ImplicitArgumentsBuilder (#4164) 2022-09-14 09:29:28 +08:00
Nicholas Wilson
4c7a714b4b
Remove getContainedType in DtoMemCpy (#4162) 2022-09-14 08:36:24 +08:00
Nicholas Wilson
f5318a4494
Remove getContainedType in tocall.cpp (#4153) 2022-09-13 20:08:22 +08:00
Nicholas Wilson
86a44ce36b
Rework DtoCallable to remove getPointerElementType (#4041) 2022-09-03 08:06:02 +08:00
Nicholas Wilson
404a5021cc
Use typed gep in tocallcpp (#4095) 2022-09-02 18:09:14 +08:00
Nicholas Wilson
634a301d0f
Use typed loads in tocall.cpp (#4053) 2022-08-28 14:32:58 +08:00
Nicholas Wilson
602a0512a0
Remove getPointeeType from tocall.cpp (#4033) 2022-08-21 14:46:32 +08:00
Nicholas Wilson
f0a3abf1dc
Remove getPointeeType from DtoVolatileLoad (#4024) 2022-08-20 05:23:17 +00:00
Martin Kinkelin
bdef01e7cc Raise min LLVM version to 9.0 2022-04-25 23:11:48 +02:00
Martin Kinkelin
8527b3f9c8 Work around llvm::PointerType::getElementType() being deprecated in LLVM 14 2022-03-30 19:53:47 +02:00
Martin Kinkelin
143d7b3171 Fix compile & link errors against LLVM 14 2022-03-30 13:51:18 +02:00
Nicholas Wilson
4349388563
Prepare for LLVM15: Headers, attributes (#3936)
`llvm::AttrBuilder` was changed to require an LLVMContext in its constructor, and can no longer be copied.

declare `DEBIG_TYPE` after includes for the GC2Stack pass as `llvm/Support/GenericDomTreeConstruction.h `(included from `llvm/IR/Dominators.h` `#define`s and `#undef`s it.

`llvm::DIBuilder::createExpression` now takes an `ArrayRef<uint64_t>` instead of `int64_t`. EmitLocalVariable has similarly changed
2022-03-11 16:38:49 +01:00
Martin Kinkelin
0fd5c6ec16
Merge pull request #3873 from kinke/no_reverse
Don't reverse parameters order for extern(D)
2022-03-08 17:03:17 +01:00
Martin Kinkelin
7b6810b01b Fix LLVM 13 deprecation messages during build 2022-02-26 19:15:46 +01:00
Martin Kinkelin
dc25da9557 ABI: Handle extern(C++) delegates for 32-bit MSVC with __thiscall convention 2022-02-22 14:48:38 +01:00
Martin Kinkelin
5a2f3ed87f Upgrade frontend & libs to v2.099.0-beta.1+ (dlang/dmd@1c31d85613) 2022-02-16 20:52:07 +01:00
Martin Kinkelin
5aed4b6728 ImportC: Add support for __builtin_va_{start,copy,end}
Fixes dmd-testsuite's runnable/test22597.c.
2021-12-21 04:07:06 +01:00
Martin Kinkelin
efa4189483
Keep default alignment for atomic instructions, for LLVM 13+ too (#3859) 2021-10-24 23:34:15 +00:00
Martin Kinkelin
019e9c8e30 Add support for LLVM 13 2021-10-11 19:20:15 +02:00
Nicholas Wilson
1568d0cdca
Fix compilation with LLVM 14 (#3822) 2021-09-17 16:41:49 +02:00
Martin Kinkelin
369cfd13ce Adapt to TY enum class 2021-09-07 16:51:19 +02:00
Martin Kinkelin
3cdd5b58cb LLVM 12: Add type information to sret and byval parameter attributes
This fixes the failing bitcode writer assertions.
2021-04-27 23:48:26 +02:00
Martin Kinkelin
693e764787 Treat temporaries as rvalue expressions when ABI-rewriting function call arguments
Thus preventing bitcopies for IndirectByvalRewrite, passing the
temporary directly by ref instead.

This fixes druntime's stdcpp-memory test.
2021-04-04 18:46:11 +02:00
Martin Kinkelin
d3574b9835 DtoTypeInfoOf(): Make Loc param mandatory and move to 1st position 2020-12-13 15:15:37 +01:00
Martin Kinkelin
a9aafac862 Glue layer: Make all mutable Loc & params const 2020-12-13 15:01:19 +01:00
DaveP1776
3f9d05ac16 Fix missing location information for error reporting of TypeInfo in betterC
This fixes an issue where any instantiation of TypeInfo in the final
output would lead to a cryptic error with no file or line information.
This change brings ldc in line with dmd's reporting of the same error,
which at least gives file and line information to discover the problem.
2020-12-12 22:41:21 -05: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