Commit graph

277 commits

Author SHA1 Message Date
kai
0b19b81ac9 Add new intrinsic LDC_never_inline.
LDC_never_inline is a complementary intrinsic to LDC_allow_inline.
It tells the LLVM optimizer to never inline a function. This can be
useful if inlining creates incorrect code.
A possible application is core.thread.getStackTop().
2013-03-11 22:32:40 +01:00
kai
37558273c2 Remove SARRAYVALUE 2013-03-06 10:20:24 +01:00
kai
c3801d65f5 Remove STRUCTTHISREF 2013-03-06 10:20:24 +01:00
kai
1e4a8fffc2 Remove DMDV1 and DMDV2. 2013-03-06 10:20:24 +01:00
kai
5a9336bf25 Fix another attribute problem with LLVM 3.3. 2013-03-03 15:10:33 +01:00
David Nadlinger
2d3de4a3d4 Fix ABI on Win32.
We can't simply use the C calling convention, as the D(MD)
ABI is callee-pop, and this is hardcoded in naked functions
with stack parameters.

The \1 "trick" is normally used to avoid prefixes added by
LLVM; on the 3.2 release, a patch is needed to make it work
for the @<n> stdcall suffixes as well.
2013-02-26 13:14:32 +01:00
David Nadlinger
3392f70a4e Move calling convention conversion into TargetABI.
The code is tightly coupled to TargetABI (the transformations
there only make sense knowing that the right CC is selected).
2013-02-26 00:20:45 +01:00
David Nadlinger
0a96aea868 Sort includes according to style guidelines:
1. Main include corresponding to .cpp file, if any.
 2. DMD and LDC includes.
 3. LLVM includes.
 4. System includes.

Also updated a few include guards to match the default format.
2013-02-07 21:20:55 +01:00
David Nadlinger
5616753768 Consistently use quotes for LLVM includes. 2013-02-07 21:20:54 +01:00
David Nadlinger
8ff3a8060a Use llvm_unreachable instead of assert(0).
Also removed some unused functions.
2013-02-07 03:38:15 +01:00
kai
104cd77e9c Merge branch 'master' into merge-2.061-2 2013-02-03 15:50:39 +01:00
kai
f806ec0ed5 Attribute holds no longer multiple values in LLVM 3.3.
The solution is to replace Attribute with AttrBuilder in IrFuncTyArg.
Then the argument attributes can be easily manipulated and transformed
into the final AttributeSet.
2013-02-03 15:09:36 +01:00
kai
23f3fd18f1 Merge branch 'master' into merge-2.061-2 2013-02-03 10:54:57 +01:00
kai
fffb23f7ce Replace AttributeWithIndex for LLVM 3.3.
The helper class AttribteWithIndex is gone in LLVM 3.3. Instead a
combination of AttrBuilder and AttributeSet must be used.
2013-02-02 22:04:19 +01:00
kai
bfc23acf30 Merge branch 'master' into merge-2.061-2 2013-02-02 15:27:51 +01:00
kai
9081102f24 Use AttrBuilder for LLVM >= 3.2.
Due to a misunderstanding of the new semantics of the Attribute(s) class,
this class was used in places where class AttrBuilder should be used.
2013-02-02 15:01:13 +01:00
kai
9390374f4d AttributeSet::get(... AttributeWithIndex ...) is now private.
AttributeWithIndex is really going away in LLVM 3.3. This is a
horrible hack to keep everything compiling. Attribute handling
needs some rework.
2013-01-28 22:08:25 +01:00
kai
145e1b5b24 AttributeSet::get(... AttributeWithIndex ...) is now private.
AttributeWithIndex is really going away in LLVM 3.3. This is a
horrible hack to keep everything compiling. Attribute handling
needs some rework.
2013-01-28 19:20:57 +01:00
kai
e68a0fa2a6 Merge branch 'master' into merge-2.061-2 2013-01-26 17:40:24 +01:00
kai
c0284bac2b 2nd attempt on the latest LLVM 3.3 changes.
The previous commit only worked on Windows.
2013-01-26 17:34:08 +01:00
kai
26385c55fe More LLVM 3.3 changes to the AttributeSet class. 2013-01-26 16:27:20 +01:00
David Nadlinger
30caa4bfe6 Merge branch 'master' into merge-2.061-2 2013-01-12 01:27:02 +01:00
kai
6ddb524b91 More LLVM 3.3 changes 2013-01-11 22:46:36 +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
5c518a16ec Merged 2.061 frontend. 2013-01-04 06:22:53 +01:00
kai
4ea7e8dbf8 Add pragma to install function as global C runtime ctor or dtor.
DMD has the obscure functionality to install functions starting with
_STI_ as global ctors and funtions starting with _STD_ as global
dtors. IMHO a pragma is a better way to specify the behaviour.

This commit adds pragma(LDC_global_crt_ctor) and
pragma(LDC_global_crt_dtor). If the pragma is specified on a function
or static method then an entry is made in the corresponding list. E.g.
in monitor_.d:

    extern (C) {
        #pragma(LDC_global_crt_ctor)
        void _STI_monitor_staticctor()
        {
            // ...
        }
    }

This works on Linux without problems. On Windows with MS C Runtime
ctors work always but dtors are invoked only if linked against the
static C runtime. Dtors on Windows require at least LLVM 3.2.
2012-12-22 21:18:37 +01:00
kai
5f37ae30cf LLVM 3.3: class Attributes is renamed to Attribute.
Some other renamings took place in "llvm/Attributes.h" but only this causes
compile errors in LDC.
Also uses new location of "llvm/IRBuilder.h".
2012-12-21 17:32:17 +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
9cbfc604c7 Fix ICE with closures in member functions.
I chose to fix the problem this way because it increases uniformity
between 'this' and normal explicit parameters. Another possibility
would be to just change the type determinatin code in
DtoCreateNestedContextType to not expect the value to be already
present, because it doesn't need it when isVthisPtr is true anyway.

GitHub: Fixes #217.
2012-12-19 20:27:19 +01:00
David Nadlinger
1bb14c45d2 Removed trailing whitespace. 2012-12-16 17:19:15 +01:00
David Nadlinger
9458911839 Added LLVM-style license headers to all our files. 2012-12-16 17:19:14 +01:00
kai
1a06130cfa AttrListPtr is renamed to AttributeSet in LLVM 3.3. 2012-12-09 19:48:39 +01:00
David Nadlinger
19f570bcb9 AttrListPtr also requires the context arg in LLVM 3.2 now. 2012-11-24 12:40:12 +01:00
kai
2fec23b84e AttrlistPtr::get() now requires context as first argument.
This is the first LLVM 3.3 related change.
2012-11-21 22:10:26 +01:00
Jernej Krempuš
7bbe782615 Pragma llvm_inline_ir
Adding pragma llvm_inline_ir.

Improved the error messages.

Append "ret void" when the return type is void

Improved the error message

in case when the string passed as llvm inline ir isn't valid llvm
assembly language.

LLVM 3.2 fix.

Add attribute AlwaysInline inside DtoInlineIRFunction.

Always generate a body for llvm_inline_ir

Also, always make llvm_inline_ir functions linkonce_odr. Because
the body is always generated when a module uses a llvm_inline_ir
function, the fact that the linker removes the function shouldn't
cause problems.
2012-11-08 22:05:15 +01:00
David Nadlinger
08a8f5df9b Fixed LLVM function attribute handling.
Previously, set_param_attrs would overwrite any pre-existing
attributes, which is problematic, as per-function attributes are
also stored in a slot in that attribute list. This for example
lead to "noinline" being dropped for functions with inline asm.
2012-11-04 17:48:26 +01:00
kai
fde625b33d More changes to the Attributes class in LLVM 3.2. 2012-10-20 17:22:55 +02:00
kai
657fc42221 And still more changes for LLVM 3.2
There were additional changes to the Attributes class.
2012-10-15 18:31:18 +02:00
kai
fb108eed12 More LLVM 3.2 changes. 2012-10-14 18:45:31 +02:00
David Nadlinger
11619e55a9 Fix miscompilation of some functions returning structs. 2012-10-14 03:41:15 +02:00
kai
a7c7b514c0 Add changes for LLVM 3.2
- The Attributes class was changed again
- TargetData was renamed to DataLayout

Compiles again with LLVm 3.0, 3.1 and trunk(3.2).
2012-10-13 18:54:42 +02:00
David Nadlinger
e7c72b072b Default to C-style variadics for all calling conventions.
Fixes DMD testcase 'callingconv'.
2012-09-27 23:53:04 +02:00
David Nadlinger
f54fa0077a Only allow a single D main() function.
Fixes DMD testcase 'fail5634'.
2012-09-27 20:22:52 +02:00
David Nadlinger
d4eafe53e0 Removed obsolete nested context styles.
NChybrid was the only one that didn't instantly trigger a "not
implemented" assertion on any code using nested function for a long
time, and removing the cruft greatly improves code readability
(maintainability is a moot point anyway given its current state).
2012-09-07 03:51:33 +02:00
David Nadlinger
ee4285f934 Properly handle DMD-internal "reference variables".
Previously, we just had a hack to make ref foreach statements work.
This commit enables them to work in other cases as well, like the
implicit __result variable for functions with out-contracts (which
is such a magic ref variable for ref-returning functions).

Fixes DMD testcase 'testcontracts'.
2012-09-07 03:51:33 +02:00
kai
2dbee75523 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-02 19:55:29 +02:00
kai
b53544b389 Simplify code by using the right type.
Removes some comditional compiling by replacing unsigned with llvm::Attributes.
2012-07-29 18:18:36 +02:00
kai
dbb5a34eda Add changes for LLVM 3.2. 2012-07-29 17:31:50 +02:00
kai
9bf65bc9a2 Start unification of master and llvm-3.1 branch. 2012-07-29 13:50:30 +02:00
David Nadlinger
cef19fb225 Fix #125 – Nested class context pointer invalid (D1).
Patch originally by Alexey Prokhin, thanks.
2012-06-24 16:18:47 +02:00