Commit graph

320 commits

Author SHA1 Message Date
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
Johan Engelen
a4055962fe Implement optimization: compare slices using memcmp if valid (#2047)
This also fixes a pessimization where the `memcmp` call would become an `invoke` if the user provides his own `memcmp` prototype in the code (the prototype would not carry the `nounwind` function attribute).
2017-03-29 20:00:21 +02:00
Johan Engelen
bd09cdc659 Optimize static array comparisons to a memcmp call for types for which this is valid.
Resolves #1632
2017-03-01 00:37:48 +01:00
David Nadlinger
bf05e91879 Merge pull request #1882 from JohanEngelen/ptrarray
Consider pointer literals as constant in isConstLiteral.
2017-02-19 22:43:25 +01:00
Martin
f95d5fdf1d Optimize initializations of byte arrays with non-const byte to memset()
It was previously restricted to a compile-time-constant right-hand-side byte.
2017-01-22 23:42:17 +01:00
Martin
de26dd6747 Skip some obsolete muls and divs for arrays with element size = 1 2017-01-22 23:42:17 +01:00
Johan Engelen
0f2d594ae5 Back off on what we consider as "constant literals": (some) dynamic array literals are not-const because they are expected to be newly allocated. (#1927)
Resolves #1924
2016-12-20 11:26:25 +01:00
Johan Engelen
3eab44ae85 Consider pointer literals as constant in isConstLiteral. 2016-11-16 17:57:53 +01:00
LemonBoy
557a8bd756 Consider string literals as constant in isConstLiteral. 2016-11-10 21:26:11 +01:00
Martin
ab1432ed06 Use the regular LL type for all init symbols and most globals
There's no <Type>_init type for aggregates (structs and classes) anymore,
effectively eliminating a *lot* of named LLVM types, some bitcasts as well
as replacements of globals etc.

To get there, it was even required to use the regular type for compatible
literals too, otherwise structs embedded as fields in other aggregates had
an anonymous type (well, the LLVM constant for the field initializer had)
and so the container initializer wasn't compatible with the regular type
anymore.

What was also necessary was a fix wrt. static arrays of bools (LLVM
constant of type `[N x i1]` vs. `[N x i8]` for regular type).
I also had to change the initializer for `char[2][3] x = 0xff` from
`[6 x i8]` to `[3 x [2 x i8]]`, i.e., NOT flattening multi-dimensional
inits from a scalar.

So only literals with overlapping (union) fields and an explicit
initializer initializing dominated non-alias union fields should still
have a mismatching anonymous type - i.e., very, very few cases.
2016-10-23 02:52:51 +02:00
LemonBoy
517f9095a4 Check StructLiteralExp elements in isConstLiteral. 2016-10-17 23:37:04 +02:00
David Nadlinger
776357c40d gen/arrays: Get rid of return/else chain [nfc] 2016-09-03 14:38:10 +01:00
Martin
7d15ab9ffc Reduce ScopeStack to JumpTargets
Add some comments after this more or less clean separation, and move
callOrInvoke() to FuncGenState.
2016-08-07 21:29:47 +02:00
Martin
e711deac1b Refactor basic block construction and revise BB order 2016-08-06 22:04:41 +02:00
David Nadlinger
6cc93bc8ba gen/ir: Move function body codegen state into separate class
Previously, the transitory state only needed and valid during
generation of the LLVM IR for the function body was conflated
with the general codegen metadata for the function declaration
in IrFunction.

There is further potential for cleanup regarding the use of
gIR->func() and so on all over the code base, but this is out
of scope of this commit, which is only concerned with those
IrFunction members moved to FuncGenState.

GitHub: Fixes #1661.
2016-08-03 21:07:18 +01:00
Martin
54cab47890 Revise DtoAssign() 2016-07-28 01:03:53 +02:00
Martin
a14e31bd94 Attempt to fix issue #1608 2016-07-28 01:03:42 +02:00
Martin
ca8c932d75 Safe some allocas+loads when creating LL slices
Create the LL pair directly instead.
2016-07-21 19:49:33 +02:00
Martin
126184a8b6 More in-place construction
Also for struct literal fields, array literal elements and associative array
literal elements as well as basic types allocated on the heap.
2016-07-21 19:49:28 +02:00
Martin
d6dcc7a4db Enforce type consistency for most DValues
At the cost of some more bitcasts.
2016-07-17 06:22:22 +02:00
Johan Engelen
df10fca7fa Clarify code (NFC) 2016-07-07 21:25:42 +02:00
Rainer Schuetze
f9995b1883 fix build against LLVM trunk svn rev 273030 2016-06-18 10:54:23 +02:00
Martin
de9149f1b6 Remove getLVal() from DValue and add DtoL/RVal() overloads 2016-06-13 22:30:16 +02:00
Martin
0c0c1ecaf5 Rename DVarValue to DLValue 2016-06-13 22:30:15 +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
c1c285782d Streamline DSliceValue
All DValues are now required to have a (main) LL value, which allows
to conveniently refactor the DValue hierarchy.

DSliceValue now represents a LL struct instead of separate values for
length and pointer.
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
039560bd83 Introduce DtoRVal/DtoLVal convenience functions
No functional changes intended.
2016-06-13 22:30:13 +02:00
Martin
0440bd20db Optimize array comparisons against null
This fixes issue #894 and includes some refactorings.
2016-03-28 15:30:55 +02:00
David Nadlinger
03429eb60f gen: Fix another array literal crash with vectors 2016-02-06 20:57:07 +01:00
David Nadlinger
b756b2de8a arrays: Fix accessing array literal elements with 2.069 frontend
This is unrelated to the move to DDMD. It would have probably been
a good idea to merge the last C++ frontend first.
2016-01-29 22:34:04 +01:00
David Nadlinger
77c29bc8c1 Re-clang-formatify gen/arrays.cpp 2016-01-29 22:32:47 +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
Martin
956061c3c7 Revise DtoGEP() helpers and mark most GEPs inbounds 2015-12-14 00:18:15 +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
Johan Engelen
70a6e73188 Cleanup runtime fwd decls and use ABI functiontype rewriting 2015-11-22 01:27:26 +01:00
Martin
2dfa5e8569 Some more cosmetic fixes
Found by searching for lines > 80 chars.
2015-11-05 19:12:32 +01:00
David Nadlinger
05d45350aa clang-tidy: Add readability-else-after-return 2015-11-02 11:30:40 +02: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
d30310c1f9 Support implicit casts in DtoArrayPtr()
On branch merge-2.068, `runnable/testassign.d` checks that a dynamic
array of objects of type B can be assigned to a dynamic array of objects
of a base class A.
The front-end seems to modify the rhs expression type from B[] to A[],
so we need to perform an implicit cast in DtoArrayPtr() to prevent
further type mismatches, notably in DtoArrayAssign().
2015-10-04 00:13:52 +02:00
Martin
b13565c17e Refactor common i1ToI8(voidToI8(DtoType(...))) code occurrences 2015-10-03 22:58:00 +02:00