Commit graph

56 commits

Author SHA1 Message Date
Johan Engelen
0a84988d65
Enable pragma(LDC_extern_weak) on function declarations. (#2984)
Enable pragma(LDC_extern_weak) on function declarations.
2019-01-27 14:44:31 +01:00
Martin Kinkelin
c57e597323 Support both CRT ctor and dtor pragmas for a single function 2019-01-06 21:14:40 +01:00
Martin Kinkelin
c8d46c7a5a DtoCheckPragma: descend into nested AttribDeclarations
E.g., this makes an intermediate `extern(C)` work for functions
(issue #2599, also tested by runnable/test17868b.d).
2019-01-06 21:14:40 +01:00
Martin Kinkelin
32ecbdd266 Upgrade front-end & libs to v2.084.0-beta.1 2018-12-18 02:31:57 +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
7776c4081b Upgrade frontend & libs to v2.083.0-beta.1 2018-10-20 16:19:46 +02:00
Martin
197e65efde Merge branch 'master' into merge-2.078
Conflicts:
	driver/main.cpp
	gen/cl_helpers.h
	gen/declarations.cpp
	runtime/druntime
	tests/d2/dmd-testsuite
2018-01-20 11:20:17 +01:00
Ivan Butygin
bed3309353
Extend LDC_inline_ir pragma (#2433) 2018-01-16 22:08:31 +03:00
Martin
c253552c59 Support new pragma(crt_{con,de}structor)
Using the existing pragma(LDC_global_crt_{c,d}tor [, priority])
infrastructure.
2018-01-07 02:04:37 +01:00
Martin
ad89009d6e Merge 2.077.0 front-end and stdlibs 2017-11-05 18:41:55 +01:00
Martin
d16a8060b4 Merge 2.076.0 front-end and stdlibs
Biggest changes:

* idgen.d has been replaced by a CTFE implementation, id.d.
  I manually added a C++ header declaring the symbols we need and
  adapted (simplified) the CMake script accordingly.
* More semantic() methods have been extracted as visitors; most notably
  for expressions.
2017-10-07 18:49:50 +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
f70a51a18c Merge 2.074.0 front-end 2017-04-22 03:52:58 +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
Johan Engelen
e0d9c58443 [PGO] Add PGO to LDC. Supported for LLVM >= 3.7
Add the commandline options -fprofile-instr-generate[=filename] and -profile-instr-use=filename
-fprofile-instr-generate
-- Add instrumentation on branches, switches, and function entry; uses LLVM's InstrProf pass.
-- Link to profile runtime that writes instrumentation counters to a file.
-fprofile-instr-use
-- Read profile data from a file and apply branch weights to branches and switches, and annotate functions with entrycount in LLVM IR.
-- Functions with low or high entrycount are marked with 'cold' or 'inlinehint'.

The only statement type without PGO yet is "try-finally".

A new pragma, `pragma(LDC_profile_instr, [ true | false ])`, is added to selectively disable/enable instrumentation of functions (granularity = whole functions).

The runtime library ldc-profile-rt is a copy of LLVM compiler-rt lib/profile. It has to be exactly in-sync with the LLVM version, and thus we need a copy for each PGO-supported LLVM (>=3.7).
import ldc.profile for a D interface to ldc-profile-rt (for example to reset execution counts after a program startup phase).

The instrumentation data is mainly passed on to LLVM: function-entry counts and branch counts/probabilities. LDC marks functions as hot when "execution count is 30% of the maximum function execution count", and marks functions as cold if their count is 1% of maximum function execution count.

The source of LLVM's llvm-profdata tool is hereby included in LDCs repository (different source for each LLVM version), and the binary is included in the install bin folder.
The executable is named "ldc-profdata" to avoid clashing with llvm-profdata on the same machine. This is needed because profdata executable has to be in-sync with the LLVM version used to build LDC.

Maintenance burden: for trunk LLVM, we have to keep ldc-profile-rt and llvm-profdata in sync. There is no diff with upstream; but because of active development there are the occasional API changes.
2016-06-20 17:28:22 +02:00
David Nadlinger
90c213b52e Adapt to changed StringExp API
Not tested yet. There is also quite a bit of potential for
further cleanup of the glue layer string manipulation code.
2016-02-14 19:35:40 +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
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
Kai Nacke
7e1a306871 Add more intrinsics to DtoIsIntrinsic.
The wrong ABI is called for every function intrinsic. These are the
ones handled in DtoLowerMagicIntrinsic(). This PR adds the missing
instrinsic constants.
2015-09-19 14:25:33 +02:00
Martin
1a42358cf6 Treat atomic instructions as intrinsics
Whose types aren't rewritten by the regular TargetABI.
2015-09-18 00:02:57 +02:00
Kai Nacke
1036edc266 Merge branch 'master' into merge-2.067 2015-05-17 13:06:46 +02:00
Kai Nacke
b2c569404b Fix a warning about sprintf type 2015-05-16 02:49:14 +02:00
Kai Nacke
2ad804c16b Implement core.bitop.volatileLoad() and core.bitop.volatileStore()
The implementation introduces 2 new intrinsics: ldc.bitop.vld and ldc.bitop.vst.
2015-03-22 00:11:43 +01:00
Alexey Prokhin
0f7a3b64c5 Make FuncDeclaration::isIntrinsic and FuncDeclaration::isVaIntrinsic free functions 2014-10-05 16:08:58 +04:00
Kai Nacke
382ad184d8 Merge branch 'master' into merge-2.066
Conflicts:
	dmd2/builtin.c
	gen/classes.cpp
	gen/functions.cpp
	gen/llvmhelpers.cpp
	gen/statements.cpp
	gen/toir.cpp
	runtime/druntime
	runtime/phobos
2014-09-13 23:11:54 +02:00
kai
b8a75be61c Use LLVM intrinsic name as mangled name.
If the mangled name is viewed as the name emitted into IR code then the mangled name of an intrinsic is the intrinsic's name.
The name is unique because of the `llvm.` prefix. The only point is that overloaded intrinsics must be resolved earlier.

This commit moves the resolution of oveloaded intrinsics into the semantic analysis pass. The
2014-08-29 08:05:09 +02:00
Alexey Prokhin
76dec46df5 WIP: merge dmdfe 2.066 2014-08-22 16:01:28 +04:00
Alexey Prokhin
a6f358c59b Remove LINKintrisic 2014-07-10 18:10:46 +04:00
David Nadlinger
04570399d4 Implement previously inoperative pragma(LDC_no_moduleinfo).
GitHub: Fixes #571.
2014-07-10 01:20:31 +02:00
David Nadlinger
fc7acc48fc Add pragma(LDC_extern_weak) for symbols with (ELF-style) weak linkage.
For now, this is only an internal feature to be used in the
implementation of rt.sections_linux.
2014-07-10 00:45:06 +02:00
kai
2b53add467 More cleanup of pragma.cpp
Replace matchPragma() function by a simple comparison.
2014-07-02 07:27:46 +02:00
kai
0d259fe6fe Remove deprecated pragmas.
This was advertized in news group.
2014-07-01 21:47:45 +02:00
Kai Nacke
fe39da53e3 Merge of 2.065.0-b3.
The new visitor class is used for IR generation. This removes some modifications from DMD source.
2014-02-10 08:47:25 +01:00
kai
1e4a8fffc2 Remove DMDV1 and DMDV2. 2013-03-06 10:20:24 +01:00
kai
820f6dbc7c Fix deprecation messages for non-vendor pragmas.
The deprecation message for non-vendor pragmas was never shown.
2013-02-28 08:00:43 +01:00
kai
4ec9fbc011 Small cleanup of gen/pragma.cpp
- Added locations to many error messages
- Fixed indentation
2013-02-25 20:32:35 +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
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
David Nadlinger
9458911839 Added LLVM-style license headers to all our files. 2012-12-16 17:19:14 +01:00
David Nadlinger
94bd923e96 Fixed pragma(LDC_verbose). 2012-12-08 21:41:22 +01:00
David Nadlinger
cbc7028e50 Added vendor-prefixed pragma names, deprecated old ones. 2012-12-08 21:38:54 +01:00
David Nadlinger
a39a136e14 Line breaks, slight cleanup. 2012-12-08 21:38:54 +01:00
David Nadlinger
f79b998e87 Whitespace cleanup. 2012-12-08 21:38:54 +01:00
David Nadlinger
dfa1bd954d Removed {insert, extract}element and shufflevector pragmas.
They have been superseeded by the inline IR pragma and ldc.simd,
and have only been around for a short time (and not in any
released version).
2012-12-08 21:38:54 +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
Jernej Krempuš
fd3e79b7bb Corrections. 2012-10-03 15:26:43 +02:00
Jernej Krempuš
b798974f3a Added pragma insertelement. 2012-10-02 22:22:53 +02:00
Jernej Krempuš
2cf5d8c2a0 Added pragma extractelement 2012-10-02 21:37:27 +02:00