Commit graph

71 commits

Author SHA1 Message Date
Martin Kinkelin
ef72dedd7c
Refactor away LDC-specific FuncDeclaration::intrinsicName (#4595)
Using `mangleOverride` directly instead. Also get rid of superfluous
string copies. And for LLVMatomic_rmw, don't store the operation
string in the instantiated FuncDeclarations anymore, but fetch it
from the parent TemplateDeclaration.
2024-03-21 16:50:06 +01:00
Martin Kinkelin
078f0532ca Don't forward-declare magic intrinsics mapping to instructions
It's ugly in general, and apparently causes LTO issues on Windows.

This required a larger refactoring.
2024-03-16 16:28:09 +01:00
Martin Kinkelin
9041c0bf67 Adapt to free functions in dmd C++ namespace now 2024-03-03 19:14:00 +01:00
Martin Kinkelin
8c685903cc Fix C++ header regressions 2024-01-13 03:21:07 +01:00
Martin Kinkelin
d6d79187e6 Merge fix: Adapt to removed error/warning members 2023-11-06 01:10:16 +01:00
Martin Kinkelin
219a9692d3 Adopt slightly improved error diagnostics wrt. invalid pragma(crt_{con,de}structor)
To please tests/dmd/fail_compilation/test23536.d.
2023-02-19 01:43:09 +01:00
Johan Engelen
51422dca53
Replace sprintf with safer snprintf, fixes compilation warning on newer clang versions. (#4304) 2023-01-25 00:55:10 +01:00
Martin Kinkelin
b7b8e59043 Upgrade frontend & libs to v2.100.0-beta.1+ (dlang/dmd@c0cff59c79) 2022-04-26 23:01:13 +02:00
Martin Kinkelin
4bd8dcd91b Adapt to new TOK and EXP enum classes 2022-02-16 20:52:07 +01:00
Martin Kinkelin
5a2f3ed87f Upgrade frontend & libs to v2.099.0-beta.1+ (dlang/dmd@1c31d85613) 2022-02-16 20:52:07 +01:00
Martin Kinkelin
369cfd13ce Adapt to TY enum class 2021-09-07 16:51:19 +02:00
Martin Kinkelin
c5a9f38af5 Prevent errors for unsupported pragmas and -ignore -v output
Fixes compilable/test3004.d.

Also get rid of an obsolete LDC addition (errors are now gagged outside
the loop).
2020-04-28 01:37:49 +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
1f5c442519 Revise recent adaptations to frontend refactorings 2020-01-06 17:01:31 +01:00
Martin Kinkelin
4ac7f0554b Adapt to frontend refactorings 2019-12-22 16:29:45 +01:00
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