V LLVM Bindings (vllvm.bindings)_

August 20, 2022 · View on GitHub

LLVM bindings for the V programming language

This project is a collection of bindings to the llvm-c interface. The bindings are originally generated with c2v and further tweaked to be easier to use within the V programming language.

Table of Contents

Coverage

This is a list of the llvm-c modules that have usable V programming language bindings.

Install

v install --git https://github.com/v-llvm/bindings

Usage

Using this module requires knowledge of LLVM. This example prints the LLVM IR for an empty function.

module main

import v_llvm.bindings.core

fn main() {
	the_context := core.llvm_context_create()
	builder := core.llvm_create_builder_in_context(the_context)
	
	the_module := core.llvm_module_create_with_name_in_context("vlang", the_context)

	func_args := [core.llvm_int32_type(), core.llvm_int32_type()]
	func_ty := core.llvm_function_type(core.llvm_int32_type(), func_args, false)
	the_function := core.llvm_add_function(the_module, "my_func", func_ty)

	println(core.llvm_print_module_to_string(the_module))
}

Contributing

PRs accepted.

License

MIT © Maxim De Clercq