Commit graph

744 commits

Author SHA1 Message Date
kinke
151e83dc6b Fix C++ warnings (#2140) 2017-05-26 13:45:15 +02:00
David Nadlinger
dbe9196aab Simplify two overly long if conditions [nfc] 2017-05-24 21:35:57 +01:00
David Nadlinger
747f7a3dfa clang-format files touched in d01a91f7 [nfc]
Some housekeeping on files that recently saw large changes anyway.
2017-05-24 21:35:40 +01:00
Martin
d01a91f755 Allow multiple occurrences for almost all command-line flags
Except for `-sanitize` and `-cache-prune*`.
2017-05-23 20:53:57 +02:00
Martin
dca21939e1 Merge 2.072.2 front-end
The part needing most attention was ddmd.root.ctfloat, ddmd.target (incl.
gen/target.cpp) and ddmd.builtin. The front-end is now prepared for
elaborate compile-time floating-point types to allow for proper cross-
compilation.

This version still uses the host's `real` type for compile-time reals,
except for MSVC hosts, which still use 64-bit doubles (when compiled with
DMD host compiler too).

Some other changes:

* semantic*() of Statements extracted from statement.d to statementsem.d
* mangle() -> mangleToBuffer()
* Identifier::string -> toChars()
* Token::float80value => floatvalue
* Dsymbol::isAggregateMember() => isMember()
* BoolExp is no more
* ddmd.root.ctfloat: LDC-specific CTFE builtins
2017-01-29 15:48:03 +01:00
Martin
5fcfd96560 Handle static arrays rewritten to slices in a more generic fashion
... if they are rewritten as left-hand-side of assignments.
2017-01-22 23:42:17 +01:00
Ivan Butygin
a26bfc1223 Refactor code to hide direct IrFunction->func usage and add convenient functions (#1911) 2017-01-17 22:40:32 +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
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
kinke
04f91f208e Merge pull request #1854 from kinke/abstract
Produce linking errors when calling abstract functions
2016-10-26 18:58:10 +02:00
Martin
1a84b2f148 Produce linking errors when calling abstract functions
Fixes issue #1822.

DtoResolveFunction() explicitly excludes body-less abstract functions from
being automatically declared. If we want to emit linking errors like DMD,
we need a LL function for the call (we previously didn't for abstract
functions, so it was null and LDC crashed). Thus make sure the function is
resolved and declared by invoking DtoDeclareFunction().
2016-10-25 20:46:22 +02:00
Martin
0fda2d271f Fix dynamic initialization of unions
The front-end fills in missing init expressions (except for the nested
context pointer in most cases), so there are no implicitly initialized
fields for dynamically initialized struct literals.

The front-end is also supposed to make sure there are no overlapping
initializers by using null-expressions for overridden fields, but doesn't
in some cases (DMD issue 16471).
Instead of preferring the first one in lexical field order, now use the
lexically last one to mimic DMD.

The previous code iterated over the fields in lexical order and ignored
the initializer for a field if there were earlier declared fields with
greater offset (and an initializer expression), which is wrong for
anonymous structs inside a union:

union {
  struct { int i1;            long l = 123; }
  struct { int i2; int x = 1;               }
}

`x` was previously initialized with 0 (treated as padding).
2016-10-25 01:06:44 +02:00
Martin
10b0261200 Zext i1 constants for scalar Boolean struct fields to i8 2016-10-23 17:31:02 +02:00
Martin
7a0bba00d9 Fix in-place construction of structs returned by inline assembly
Fixes #1823.
2016-10-11 22:10:30 +02:00
LemonBoy
6054564735 Produce correct code for increment/decrement operations on complex types (#1809)
Fixes issue #1806.
2016-10-05 23:17:32 +02:00
Martin
ed87df79b1 Fix too restrictive assertion for binassigns
This was hit when compiling ddmd/lexer.d:1189, where a const(T)* is
implicitly cast to a const(T*).
The DLValue ctor makes sure the LL pointer and the D type are compatible.
2016-08-15 17:39:01 +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
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
2a0a6631a8 Clarify some non-obvious points wrt. binops/binassign 2016-07-18 20:23:24 +02:00
Martin
951040cc36 Get rid of local AST pre-evaluation
We only needed that findLvalueExp() thing to 1. skip over casts and 2. to
use a (bin)assign's lhs instead of the (bin)assign's result.

Well, by making sure most (bin)assign expression actually return the lhs
lvalue, we don't have this problem anymore and only need to skip over casts
to get to the nested lvalue.

This gets rid of a hacky workaround and brings our AST traversal order
back to normal again.
2016-07-18 02:35:34 +02:00
Martin
ffaeb09188 Binassign: Always use the lvalue subexpression for the binop lhs
Just cast it to the full lhs type, except for shift-assignments (always
perform the shift op in the lvalue precision).

The front-end likes to cast the lhs to the type it wants for the
intermediate binop. E.g., incrementing a ubyte lvalue by an integer leads
to `lval += 3` being rewritten to `cast(int)lval += 3`.

Now if we use the full lhs value for the binop, we get an rvalue result
due to the cast. I.e., `cast(int)lval` before evaluating the rhs. So what
we actually want is to load the lhs lvalue `lval` AFTER evaluating the rhs
and cast it to an integer so that the binop is performed in that
precision. The result is casted back to the lvalue type when assigning.
2016-07-17 23:28:12 +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
Martin
88b19d3d51 Binassign: Elide apparently superfluous cast
For binassign expressions, return the lhs lvalue directly and don't bother
casting it to the expression's type - the base types apparently always match.
2016-07-16 18:34:42 +02:00
Martin
7e770f7c59 Refactor bitwise binary operators 2016-07-16 16:42:27 +02:00
Martin
df34beb59b Refactor binops and binassigns 2016-07-16 16:42:23 +02:00
Johan Engelen
c44db68104 Fix another evaluation order bug with @= expressions and extend the testcases. 2016-07-13 21:42:11 +02:00
Johan Engelen
8ba8baf89a Fix bug: remove casts that snuck in from bitwise operator code. 2016-07-13 20:46:12 +02:00
Johan Engelen
52bddf24cf Fix evaluation order of += and -=, and update testsuite. 2016-07-13 17:06:06 +02:00
Johan Engelen
f9f373e8c8 Fix evaluation order of =* =/ and =% 2016-07-13 16:09:47 +02:00
Johan Engelen
e4dec4d330 Deduplicate code for multiply, divide, and module. [NFC] 2016-07-13 15:47:39 +02:00
Johan Engelen
f5935ff7dd Fix evaluation order of bitwise-assign operators. 2016-07-13 15:43:02 +02:00
Johan Engelen
cb15d21996 Fix evaluation order of bitwise operators 2016-07-12 23:01:34 +02:00
Johan Engelen
cec61a4432 clang-format [NFC] 2016-07-12 23:01:10 +02:00
Johan Engelen
57b21d10d4 Fix github issue 1611 2016-07-10 00:42:00 +02:00
Martin
ed70c12b06 Enable in-place construction for static array literals 2016-07-03 00:23:08 +02:00
Martin
08fa2f093c Enable in-place construction for struct literals 2016-07-03 00:23:03 +02:00
Martin
364d1e9acd Be less restrictive in toDirectSretConstruction() 2016-07-02 12:52:29 +02:00
Martin
50b89a47fe Extract helper toDirectSretConstruction() 2016-07-02 12:52:28 +02:00
Martin
879fb97d56 Rename retvar to sretPointer 2016-07-02 12:52:21 +02:00
Martin
07cad0f20a Fix the actual issue 2016-06-29 22:41:08 +02:00
Martin
26d0c715d2 Resolve virtual base functions (super.foo()) correctly
Don't perform a vtable lookup for those, resolve them directly instead.
Fixes issue #1450, where calling the base method in the overwritten
method resulted in an infinite loop and corresponding stack overflow.
2016-06-29 20:35:11 +02:00
Martin
82005009e7 Refactor and fix intrinsics for variadic functions
I.e., va_start(), va_copy() and va_arg().
2016-06-28 22:40:14 +02:00
kinke
13f522a164 Merge pull request #1588 from kinke/assignSret
AssignExp: Refactor direct construction by rhs call via sret
2016-06-26 21:26:14 +02:00
Martin
a3adb403de Fix evaluation/load order of binary operators
Fixes issue #1327 by loading immediately from lvalues resulting from
left- and right-hand sides.
2016-06-26 21:19:06 +02:00
Martin
1c14efffde AssignExp: Refactor direct construction by rhs call via sret 2016-06-26 19:51:57 +02:00
Martin
7fec36b51f Continue with DValue refactoring
* Introduce a DRValue base class to be able to discriminate between
  DLValues and DRValues (e.g., function parameters).
* Let DValue::getRVal() return each DValue's value as DRValue.
  This allows to convert a DLValue to a DRValue, a snapshot of the
  lvalue's current state, while retaining the D type, something we've
  previously lost when returning the low-level rvalue directly.
* Let the DtoR/LVal() helpers be the only way to convert a DValue to a
  low-level value.
2016-06-25 15:33:57 +02:00
Johan Engelen
0f22a88238 Remove unused variables. 2016-06-20 17:28:32 +02:00