llvm-d 2.0.0
D bindings for LLVM
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
llvm-d
llvm-d provides bindings to LLVM's C API for the D programming language. It is designed to be linked dynamically against LLVM.
Usage
To use llvm-d you need only import it, after which all of LLVM's C API's functions should be available. For example:
import std.stdio;
import llvm;
void main(string[] args)
{
static if((LLVMDVersion(3, 3, 0) <= LLVM_Version) && (LLVM_Version < LLVMDVersion(3, 5, 0)))
{
writefln("LLVM multithreading on? %s", cast(bool) LLVMIsMultithreaded());
writefln("Turning it on"); LLVMStartMultithreaded();
writefln("LLVM multithreading on? %s", cast(bool) LLVMIsMultithreaded());
writefln("Turning it off"); LLVMStopMultithreaded();
writefln("LLVM multithreading on? %s", cast(bool) LLVMIsMultithreaded());
}
}
Note that a static if
is used to ensure the function calls are only compiled
in if llvm-d is set to compile for a viable LLVM version
(the multithreaded functions where added to LLVM's C API in the 3.3 development
cycle and removed in the 3.5 development cycle; thus they are only available in versions 3.3 and 3.4).
A more complex example showing how to create a jitted function calculating
the fibonacci series can be seen at examples/fibonacci/fibonacci.d
.
LLVM versions
The LLVM version to be used is selected by setting a conditional compilation version identifier.
For DMD, this is the -version
argument; for dub, the versions
field.
The identifier to set the LLVM version is defined as
LLVM_{MAJOR_VERSION}_{MINOR_VERSION}_{PATCH_VERSION}
, so to get LLVM version 3.1.0
use LLVM_3_1_0
.
Current supported versions are 3.1.0 - 3.9.1 and if no version is given at compile time, 3.9.1 will be assumed.
Documentation
llvm-d exposes C linkage functions, constants, and types with the same names as LLVM's C API. See the LLVM Doxygen pages for a reference.
License
llvm-d is released under the MIT license, see LICENSE.txt.
llvm-d uses source code from LLVM that has been ported to D for accessing LLVM's C API. The above paragraph does not apply to that source code - it is a redistribution of LLVM source code.
LLVM is Copyright (c) 2003-2017 University of Illinois at Urbana-Champaign. All rights reserved.
LLVM is distributed under the University of Illinois Open Source License. See http://opensource.org/licenses/UoI-NCSA.php for details.
- Registered by Moritz Maxeiner
- 2.0.0 released 7 years ago
- MoritzMaxeiner/llvm-d
- github.com/Calrama/llvm-d
- MIT
- Copyright © 2013-2017 Moritz Maxeiner, Copyright © 2016-2017 Alex Parrill
- Authors:
- Dependencies:
- none
- Versions:
-
3.0.0 2019-Apr-27 2.4.1 2018-Oct-29 2.4.0 2018-Oct-27 2.3.0 2018-Mar-02 2.2.0 2017-May-12 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
4 downloads this month
-
904 downloads total
-
- Score:
- 2.4
- Short URL:
- llvm-d.dub.pm