All Projects → MoritzMaxeiner → Llvm D

MoritzMaxeiner / Llvm D

Licence: mit
D bindings for LLVM

Programming Languages

d
599 projects

Projects that are alternatives of or similar to Llvm D

Llvm Tutorial Standalone
DEPRECATED (Use: https://github.com/llvm-hs/llvm-hs-kaleidoscope )
Stars: ✭ 38 (-24%)
Mutual labels:  llvm
Processwarp
Stars: ✭ 43 (-14%)
Mutual labels:  llvm
Hs Zstd
Bindings to the Zstandard library to make it usable from the Haskell programming language.
Stars: ✭ 45 (-10%)
Mutual labels:  bindings
Vst2
Bindings for vst2 sdk
Stars: ✭ 39 (-22%)
Mutual labels:  bindings
Tinygo
Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
Stars: ✭ 9,068 (+18036%)
Mutual labels:  llvm
Glue
⛓️ Bindings that stick. A simple and generic API for C++ to other language bindings supporting bidirectional communication, inheritance and automatic declarations.
Stars: ✭ 44 (-12%)
Mutual labels:  bindings
Coat
EDSL for C++ to make just-in-time code generation easier
Stars: ✭ 37 (-26%)
Mutual labels:  llvm
Llvm Demo
A simple example of how LLVM can be used to gather static or dynamic facts about a program.
Stars: ✭ 48 (-4%)
Mutual labels:  llvm
Domtresat
Dominator Tree LLVM Pass to Test Satisfiability
Stars: ✭ 42 (-16%)
Mutual labels:  llvm
Rellume
Lift x86-64 to performant LLVM IR
Stars: ✭ 45 (-10%)
Mutual labels:  llvm
Llvm To Snes
LLVM IR → WLA DX (ASM 65c816) → SNES Rom
Stars: ✭ 39 (-22%)
Mutual labels:  llvm
Rusqlite
Ergonomic bindings to SQLite for Rust
Stars: ✭ 1,008 (+1916%)
Mutual labels:  bindings
Stoat
STatic (LLVM) Object file Analysis Tool
Stars: ✭ 44 (-12%)
Mutual labels:  llvm
Ad Edwarthogenhancedscript
An Advanced & Highly Customisable Elite Dangerous Thrustmaster Warthog Script + ED Bindings Pack that utilises Modifiers, allowing for all commands to be easily accessible on the HOTAS. Includes many Quality of Life features to get the most enjoyment out of ED!
Stars: ✭ 39 (-22%)
Mutual labels:  bindings
Leekscript V2
A dynamically typed, compiled just-in-time programming language used in Leek Wars' AIs
Stars: ✭ 46 (-8%)
Mutual labels:  llvm
Kylin Llvm Obfuscator
based on llvm 5.0.1 release with ollvm
Stars: ✭ 37 (-26%)
Mutual labels:  llvm
Llvm2graphml
Explore LLVM Bitcode interactively using a graph database
Stars: ✭ 44 (-12%)
Mutual labels:  llvm
Replace function name
LLVM IR编译时替换函数名
Stars: ✭ 50 (+0%)
Mutual labels:  llvm
Binaryen Rs
Binaryen bindings for Rust.
Stars: ✭ 48 (-4%)
Mutual labels:  bindings
Genepi
Automatic generation of N-API wrapper from a C++ library
Stars: ✭ 45 (-10%)
Mutual labels:  bindings

llvm-d

Build Status Dub version Dub downloads

llvm-d provides bindings to LLVM's C API for the D programming language. It is designed to be linked dynamically against LLVM.

Usage

  1. import llvm; all of LLVM's C API's functions should be available
  2. Link against either the correct library (LLVM built as singleton), or the correct libraries (LLVM built as several libraries) Note: That includes ensuring your linker can find them

For example:

import std.stdio;

import llvm;

void main(string[] args)
{
	static if((asVersion(3, 3, 0) <= LLVM_Version) && (LLVM_Version < asVersion(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 - 10.0.0 and if no version is given at compile time, 10.0.0 will be assumed.

LLVM targets

As with the LLVM version, LLVM targets are also selected by setting an appropriate conditional compilation version identifier.

The identifier to enable an LLVM target XyZ is defined as LLVM_Target_XyZ, which will instruct llvm-d to assume any C API functions for those targets will be linked in, so to enable the X86 LLVM target, use LLVM_Target_X86.

Note: The target name is case sensitive.

Note: Multiple targets can be enabled in this manner.

llvm-d supports all targets for the supported LLVM versions and if no target is given at compile time, none will be assumed to be available. The dub package's default configuration sets the appropriate identifier to enable the native target for some common platforms.

Dynamic loading

By default, llvm-d requires you to link against the LLVM library (or libraries in case of a split build). If you instead wish to load from shared libraries at runtime, set the D version LLVM_Load. You can then use LLVM.load and LLVM.unload for dynamic loading. If you additionally set the D version LLVM_Autoload, llvm-d will attempt to load default libraries at program startup.

Note: Enabling dynamic loading will likely result in noticeable compile time increase, as it uses compile time reflection.

Note: If compilation freezes in release mode with dub, the --build-mode=allAtOnce flag may help.

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-2020 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].