Commit graph

311 commits

Author SHA1 Message Date
Martin Kinkelin
6998886e89 Adapt to removed _d_array[set]ctor druntime hooks (replaced by templated lowerings) 2022-09-15 19:00:21 +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
Nicholas Wilson
6617daa45b
Fix issue 4134 (#4136) 2022-09-15 18:00:49 +08:00
Nicholas Wilson
a94262f509
Remove getContainedType from DtoArrayAssign (#4165) 2022-09-14 18:58:25 +08:00
Nicholas Wilson
4f35ff0b78
Remove getContainedType from callMemcmp (#4160) 2022-09-14 14:20:59 +08:00
Nicholas Wilson
c228ef51eb
Remove getContainedType from DtoSlice (#4161) 2022-09-13 20:18:35 +00:00
Nicholas Wilson
838146be71
Remove getContainedType from DtoMemSetZero (#4157) 2022-09-13 21:39:05 +08:00
Nicholas Wilson
f1a3ed5ede
Remove getContainedType from DtoSetArray (#4144) 2022-09-13 20:12:16 +08:00
Nicholas Wilson
ccd24cc09a
Use typed gep in arrays.cpp (#4098) 2022-09-03 05:32:40 +08:00
Nicholas Wilson
dc5caeb19d
Use typed gep in arrays.cpp (#4093) 2022-09-01 20:09:35 +08:00
Nicholas Wilson
f2155c6dd9
Use type gep in initializeArrayLiteral (#4092) 2022-09-01 17:14:57 +08:00
Nicholas Wilson
bd3d562d2a
Use typed gep in arrays.cpp (#4083) 2022-08-31 13:54:32 +08:00
Nicholas Wilson
beddcfd3ad
Use typed gep in arrays.cpp (#4075) 2022-08-31 11:50:41 +08:00
Nicholas Wilson
37aca9c940
Use typed load in arrays.cpp (#4055) 2022-08-29 10:24:05 +08:00
Nicholas Wilson
308d39cea0
Use typed load in arrays.cpp (#4064) 2022-08-28 17:24:35 +08:00
Nicholas Wilson
6daf215b3c
Remove getPointeeType from DtoSetArrayToNull (#4032) 2022-08-21 13:15:30 +08:00
Nicholas Wilson
842593f75b
Remove use of getPointerElementType in gen/arrays.cpp (#4021) 2022-08-21 10:39:00 +08:00
Martin Kinkelin
be20833b22 codegen: Support {Not,Logical,Identity,Cmp}Exp with non-bool type (for importC AST)
Fixing failing LDC assertions.
2022-04-30 23:46:47 +02:00
Martin Kinkelin
4b1f5516fd Pass isCfile parameter for all defaultInit() calls, for some extra importC zero-init
Fixes dmd-testsuite's runnable/test22994.c.
2022-04-30 19:54:20 +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
4bd8dcd91b Adapt to new TOK and EXP enum classes 2022-02-16 20:52:07 +01:00
Martin Kinkelin
e8997308f9 Always specify a pointee type for llvm::ConstantExpr::getGetElementPtr()
As required by LLVM 13.
2021-10-11 19:21:37 +02:00
Martin Kinkelin
f4ea32e496 ImportC: No bounds checks for 'incomplete' static arrays
Fixes dmd-testsuite's runnable/test22326.c.
2021-09-25 18:59:17 +02:00
Martin Kinkelin
fab82436dd Use new druntime hooks _d_arraybounds_{slice,index} for more informative RangeErrors
Fixing dmd-testsuite's runnable/testbounds.d.
2021-09-09 17:37:38 +02:00
Martin Kinkelin
369cfd13ce Adapt to TY enum class 2021-09-07 16:51:19 +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
96b9cde428 Add support for LLVM 11
One major change is the removal of llvm::CallSite, which I've replaced
by llvm::CallBase*.
2020-09-26 01:04:50 +02:00
Martin Kinkelin
69269f3bd9 Refactor IRScope handling
Replace the stack of IRScopes, each with its own IRBuilder, by directly
tampering with the state of a single IRBuilder.

This seems like the most feasible way to account for a breaking change
in LLVM 11, disallowing IRBuilder from being copied.
2020-09-26 01:04:50 +02:00
Martin Kinkelin
7be38fd220
Try to use memcmp for (in)equality of non-mutable static arrays and mutable slices (#3401)
Fixes #3400. The frontend pre-casts the static array operand to the
slice type for cases like `bool[4] == bool[]`, but that's not possible
in case the static array is non-mutable but the slice type is mutable.

So check the element types for equivalence, not the array types, as
static arrays and slices are NOT equivalent.
2020-04-17 22:09:55 +02:00
Martin Kinkelin
26673c174f
Refactoring: Replace Expression::op check followed by static cast to Expression::is<ExpressionType> (#3141)
This may negatively impact performance, as the (final, i.e.,
non-virtual) Expression::is... family is implemented in D and not
available inline in the C++ headers.
2020-01-15 12:54:05 +01:00
Martin Kinkelin
4ac7f0554b Adapt to frontend refactorings 2019-12-22 16:29:45 +01:00
Martin Kinkelin
8fd69da8fb Make all DtoGEP helpers use implicit inbounds
Single functional change: always emit inbounds when computing the base
pointer of a SliceExp.
2019-09-10 22:36:25 +02:00
Martin Kinkelin
e52199469f Upgrade front-end & libs to v2.087.0-beta.1 2019-06-21 15:39:45 +02:00
Martin Kinkelin
9469c6b5b8 Fix array casts with constant source lengths
The `__ArrayCast` lowering isn't (always?) done when casting a static
array to a slice with different element size.
So exploit constant source lengths and compute the target length at
compile-time.

This fixes compilable/ldc_github_421.d - a float[16] can be cast to a
float4[] with constant length 4.
2019-04-25 00:57:46 +02:00
Martin Kinkelin
3817ab0595 Upgrade front-end & libs to v2.086.0-beta.1 2019-04-23 22:13:13 +02:00
Martin Kinkelin
ec72854739
Propagate well-known length of newly allocated arrays (#3042)
For better optimizability, as the length information is lost when using
the slice returned by the druntime hooks directly. Resolves #3041.
2019-04-06 00:41:59 +02:00
Martin Kinkelin
2fb5098f48 Optimize some slice copies
Cache length & ptr in DSliceValue, so that e.g. a pair constructed from
a constant length and some ptr keeps returning a constant length instead
of an extractvalue instruction every time the length is needed.

This enables checking for matching constant lengths when copying slices
and makes `test1()` in runnable/betterc.d work (memcpy instead of
_d_array_slice_copy call):

```
int[10] a1 = void;
int[10] a2 = void;
a1[] = a2[];
```

(more or less equivalent to `a1 = a2`, which is already optimized)
2019-01-09 23:50:44 +01:00
Martin Kinkelin
33cadfaca6 Remove ldc.arrayinit & streamline _d_array_slice_copy/_d_arraycast_len with upstream 2019-01-07 15:54:26 +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
Martin Kinkelin
5c24f60cf9
Raise min LLVM version to 3.9 (#2872) 2018-10-15 22:31:59 +02:00
Martin Kinkelin
5557278ba2 Adapt to refactored defaultInit() (method => free-standing) 2018-08-17 21:34:46 +02:00
Martin
9ff736bf0f Lookup runtime function before constructing the call args
To retain the LoC information in case TypeInfo declarations are missing.
2018-04-04 19:59:10 +02:00
Martin Kinkelin
f0aba4559f
Fix cat-assign-element issue if rhs affects the lhs length (#2589)
I.e., this fixes #2588.

To fix the index of the new array element to be assigned to, I went for
decrementing the new length instead of saving the old length directly
before the druntime call (i.e., after evaluating the rhs expression due
to its potential side effects). The IR seems more intuitive to me this
way - load both new length+ptr directly after the druntime call and then
decrement the length by 1.
2018-02-23 18:51:36 +01:00
Martin
f9575686e1 Get rid of obsolete runtime functions
For array comparisons (new) and the _adReverse family.
2018-01-07 05:03:37 +01:00
Martin
cfad799f48 Merge 2.078.0 front-end and stdlibs 2018-01-06 01:39:18 +01:00
Martin
30b858781b -betterC: Use C assert function
Instead of druntime's _d_assert[_msg], _d_arraybounds and
_d_switch_error.

Tested by dmd-testsuite's runnable/cassert and compilable/betterCarray.
2017-10-25 00:38:05 +02:00
Martin
2616261fd2 Revise all LDC-specific errors/warnings/deprecs and insert backticks
For DMD's new syntax highlighting. I grepped in all .{h,cpp} files only.
2017-08-03 22:53:49 +02:00
Martin
1fb269f940 Drop support for LLVM < 3.7 2017-07-16 02:18:00 +02:00