wasm.structs

module wasm.structs;


struct Header
{
public:
	ident: u32;
	ver: u32;
}

struct Limits
{
public:
	initial: u32;
	maximum: u32;
	flags: u8;
}

wasm.leb

module wasm.leb;


fn readULEB128(data: const(u8)[], v: u64) i32 { }
fn readSLEB128(data: const(u8)[], v: i64) i32 { }
fn readF(data: const(u8)[], v: u8) bool { }
fn readF(data: const(u8)[], f: f32) bool { }
fn readF(data: const(u8)[], f: f64) bool { }
fn readV(data: const(u8)[], l: Limits) bool { }
fn readV(data: const(u8)[], v: u8) bool { }
fn readV(data: const(u8)[], v: i8) bool { }
fn readV(data: const(u8)[], v: u32) bool { }
fn readV(data: const(u8)[], v: i32) bool { }
fn readV(data: const(u8)[], v: u64) bool { }
fn readV(data: const(u8)[], v: i64) bool { }
fn readV(data: const(u8)[], v: const(char)[]) bool { }

wasm

module wasm;

public import wasm.reader;
public import wasm.defines;
public import wasm.structs;
public import wasm.dumper;

wasm.defines

module wasm.defines;


enum Ident;
enum Version;

enum Section
{
	Custom,
	Type,
	Import,
	Function,
	Table,
	Memory,
	Global,
	Export,
	Start,
	Element,
	Code,
	Data,
}

enum ExternalKind
{
	Function,
	Table,
	Memory,
	Global,
}

enum Type
{
	I32,
	I64,
	F32,
	F64,
	AnyFunc,
	Func,
	Void,
}

enum Opcode
{
	Unreachable,
	Nop,
	Block,
	Loop,
	If,
	Else,
	End,
	Br,
	BrIf,
	BrTable,
	Return,
	Call,
	CallIndirect,
	Drop,
	Select,
	GetLocal,
	SetLocal,
	TeeLocal,
	GetGlobal,
	SetGlobal,
	I32Load,
	I64Load,
	F32Load,
	F64Load,
	I32Load8S,
	I32Load8U,
	I32Load16S,
	I32Load16U,
	I64Load8S,
	I64Load8U,
	I64Load16S,
	I64Load16U,
	I64Load32S,
	I64Load32U,
	I32Store,
	I64Store,
	F32Store,
	F64Store,
	I32Store8,
	I32Store16,
	I64Store8,
	I64Store16,
	I64Store32,
	CurrentMemory,
	GrowMemory,
	I32Const,
	I64Const,
	F32Const,
	F64Const,
	I32Eqz,
	I32Eq,
	I32Ne,
	I32LtS,
	I32LtU,
	I32GtS,
	I32GtU,
	I32LeS,
	I32LeU,
	I32GeS,
	I32GeU,
	I64Eqz,
	I64Eq,
	I64Ne,
	I64LtS,
	I64LtU,
	I64GtS,
	I64GtU,
	I64LeS,
	I64LeU,
	I64GeS,
	I64GeU,
	F32Eq,
	F32Ne,
	F32Lt,
	F32Gt,
	F32Le,
	F32Ge,
	F64Eq,
	F64Ne,
	F64Lt,
	F64Gt,
	F64Le,
	F64Ge,
	I32Clz,
	I32Ctz,
	I32Popcnt,
	I32Add,
	I32Sub,
	I32Mul,
	I32DivS,
	I32DivU,
	I32RemS,
	I32RemU,
	I32And,
	I32Or,
	I32Xor,
	I32Shl,
	I32ShrS,
	I32ShrU,
	I32Rotl,
	I32Rotr,
	I64Clz,
	I64Ctz,
	I64Popcnt,
	I64Add,
	I64Sub,
	I64Mul,
	I64DivS,
	I64DivU,
	I64RemS,
	I64RemU,
	I64And,
	I64Or,
	I64Xor,
	I64Shl,
	I64ShrS,
	I64ShrU,
	I64Rotl,
	I64Rotr,
	F32Abs,
	F32Neg,
	F32Ceil,
	F32Floor,
	F32Trunc,
	F32Nearest,
	F32Sqrt,
	F32Add,
	F32Sub,
	F32Mul,
	F32Div,
	F32Min,
	F32Max,
	F32Copysign,
	F64Abs,
	F64Neg,
	F64Ceil,
	F64Floor,
	F64Trunc,
	F64Nearest,
	F64Sqrt,
	F64Add,
	F64Sub,
	F64Mul,
	F64Div,
	F64Min,
	F64Max,
	F64Copysign,
	I32WrapI64,
	I32TruncSF32,
	I32TruncUF32,
	I32TruncSF64,
	I32TruncUF64,
	I64ExtendSI32,
	I64ExtendUI32,
	I64TruncSF32,
	I64TruncUF32,
	I64TruncSF64,
	I64TruncUF64,
	F32ConvertSI32,
	F32ConvertUI32,
	F32ConvertSI64,
	F32ConvertUI64,
	F32DemoteF64,
	F64ConvertSI32,
	F64ConvertUI32,
	F64ConvertSI64,
	F64ConvertUI64,
	F64PromoteF32,
	I32ReinterpretF32,
	I64ReinterpretF64,
	F32ReinterpretI32,
	F64ReinterpretI64,
}

enum RelocType
{
	FuncIndexLEB,
	TableIndexSLEB,
	TableIndexI32,
	MemoryAddressLEB,
	MemoryAddressSLEB,
	MemoryAddressI32,
	TypeIndexLEB,
	GlobalIndexLEB,
}

fn sectionToString(s: Section) string { }
fn externalKindToString(ek: ExternalKind) string { }
fn typeToString(t: Type) string { }
fn opToString(op: Opcode) string { }
fn relocToString(reloc: RelocType) string { }

wasm.dumper

module wasm.dumper;


class Dumper : Reader
{
public:
	this() { }
	fn onHeader(header: Header) { }
	fn onSection(id: Section, data: const(u8)[]) SkipOrParse { }
	fn onCustomSection(name: string, data: const(u8)[]) { }
	fn onTypeEntry(num: u32, from: Type, args: Type[], ret: Type) { }
	fn onImportGlobal(num: u32, mod: string, field: string, t: Type, mut: bool) { }
	fn onImportFunc(num: u32, mod: string, field: string, index: u32) { }
	fn onFunctionEntry(num: u32, index: u32) { }
	fn onTableEntry(num: u32, elem_type: Type, l: Limits) { }
	fn onMemoryEntry(num: u32, l: Limits) { }
	fn onGlobalEntry(num: u32, type: Type, mut: bool, exp: InitExpr) { }
	fn onExportEntry(num: u32, name: string, kind: wasm.ExternalKind, index: u32) { }
	fn onStart(index: u32) { }
	fn onRelocSection(section: Section, name: string, count: u32) { }
	fn onRelocEntry(num: u32, type: RelocType, offset: u32, index: u32, addend: u32) { }
	fn onRelocSectionEnd() { }
	fn onFunctionBody(num: u32, types: Type[], counts: u32[]) { }
	fn onFunctionBodyEnd(num: u32) { }
	fn onOp(op: Opcode) { }
	fn onControl(op: Opcode, t: Type) { }
	fn onBranch(op: Opcode, relative_depth: u32) { }
	fn onCall(index: u32) { }
	fn onCallIndirect(typeIndex: u32) { }
	fn onOpMemory(op: Opcode, flags: u32, offset: u32) { }
	fn onOpVar(op: Opcode, index: u32) { }
	fn onOpI32Const(v: i32) { }
	fn onOpI64Const(v: i64) { }
	fn onOpF32Const(v: f32) { }
	fn onOpF64Const(v: f64) { }
	fn onReadError(err: string) { }
	fn onEOF() { }
	fn onTypeSection(count: u32) { }
	fn onImportSection(count: u32) { }
	fn onFunctionSection(count: u32) { }
	fn onTableSection(count: u32) { }
	fn onMemorySection(count: u32) { }
	fn onGlobalSection(count: u32) { }
	fn onExportSection(count: u32) { }
	fn onCodeSection(count: u32) { }
	fn onCode(data: const(u8)[]) { }
}

wasm.reader

module wasm.reader;


enum SkipOrParse
{
	Skip,
	Parse,
}

enum OpcodeKind
{
	Error,
	Regular,
	Control,
	ControlType,
	Branch,
	BranchTable,
	Call,
	CallIndirect,
	Memory,
	VarAccess,
	I32Const,
	I64Const,
	F32Const,
	F64Const,
	Unhandled,
}

class InitExpr
{
public:
	union U
	{
	public:
		index: u32;
		_i32: i32;
		_i64: i64;
		_f32: f32;
		_f64: f64;
	}


public:
	u: U;
	type: Type;
	isImport: bool;


public:
	this() { }
}

class Reader
{
public:
	this() { }
	fn onHeader(header: Header);
	fn onSection(id: Section, data: const(u8)[]) SkipOrParse;
	fn onCustomSection(name: string, data: const(u8)[]);
	fn onTypeSection(count: u32);
	fn onTypeEntry(num: u32, from: Type, args: Type[], ret: Type);
	fn onImportSection(count: u32);
	fn onImportGlobal(num: u32, mod: string, field: string, t: Type, mut: bool);
	fn onImportFunc(num: u32, mod: string, field: string, index: u32);
	fn onFunctionSection(count: u32);
	fn onFunctionEntry(num: u32, index: u32);
	fn onTableSection(count: u32);
	fn onTableEntry(num: u32, elem_type: Type, l: Limits);
	fn onMemorySection(count: u32);
	fn onMemoryEntry(num: u32, l: Limits);
	fn onGlobalSection(count: u32);
	fn onGlobalEntry(num: u32, type: Type, mut: bool, exp: InitExpr);
	fn onExportSection(count: u32);
	fn onExportEntry(num: u32, name: string, kind: wasm.ExternalKind, index: u32);
	fn onRelocSection(section: wasm.Section, name: string, count: u32);
	fn onRelocEntry(num: u32, type: wasm.RelocType, offset: u32, index: u32, addend: u32);
	fn onRelocSectionEnd();
	fn onStart(index: u32);
	fn onCodeSection(count: u32);
	fn onFunctionBody(num: u32, types: Type[], counts: u32[]);
	fn onFunctionBodyEnd(num: u32);
	fn onCode(data: const(u8)[]);
	fn onOp(op: Opcode);
	fn onControl(op: Opcode, t: Type);
	fn onBranch(op: Opcode, relative_depth: u32);
	fn onCall(index: u32);
	fn onCallIndirect(typeIndex: u32);
	fn onOpMemory(op: Opcode, flags: u32, offset: u32);
	fn onOpVar(op: Opcode, index: u32);
	fn onOpI32Const(v: i32);
	fn onOpI64Const(v: i64);
	fn onOpF32Const(v: f32);
	fn onOpF64Const(v: f64);
	fn onReadError(err: string);
	fn onEOF();
}

fn readFile(r: Reader, data: const(u8)[]) { }
fn readCustomSection(r: Reader, data: const(u8)[]) { }
fn readTypeSection(r: Reader, data: const(u8)[]) { }
fn readTypeEntry(r: Reader, num: u32, data: const(u8)[]) { }
fn readImportSection(r: Reader, data: const(u8)[]) { }
fn readImportEntry(r: Reader, num: u32, data: const(u8)[]) { }
fn readFunctionSection(r: Reader, data: const(u8)[]) { }
fn readTableSection(r: Reader, data: const(u8)[]) { }
fn readMemorySection(r: Reader, data: const(u8)[]) { }
fn readGlobalSection(r: Reader, data: const(u8)[]) { }
fn readExportSection(r: Reader, data: const(u8)[]) { }
fn readStartSection(r: Reader, data: const(u8)[]) { }
fn readElementSection(r: Reader, data: const(u8)[]) { }
fn readDataSection(r: Reader, data: const(u8)[]) { }
fn readRelocSection(r: Reader, data: const(u8)[]) { }
fn readCodeSection(r: Reader, data: const(u8)[]) { }
fn readFunctionBody(r: Reader, num: u32, data: const(u8)[]) { }
fn readInitExpr(r: Reader, data: const(u8)[], ret: InitExpr) { }
fn readOpcodes(r: Reader, b: const(u8)[]) { }
fn opKind(op: Opcode) OpcodeKind { }

tesla.polyfill.funcs

module tesla.polyfill.funcs;


struct InbuiltFuncs
{
public:
	fnI32DivU: LLVMValueRef;
	fnI32DivS: LLVMValueRef;
	fnI32RemU: LLVMValueRef;
	fnI32RemS: LLVMValueRef;
	fnI32Clz: LLVMValueRef;
	fnI32Ctz: LLVMValueRef;
	fnI32Rotl: LLVMValueRef;
	fnI32Rotr: LLVMValueRef;
	fnI64DivU: LLVMValueRef;
	fnI64DivS: LLVMValueRef;
	fnI64RemU: LLVMValueRef;
	fnI64RemS: LLVMValueRef;
	fnI64Clz: LLVMValueRef;
	fnI64Ctz: LLVMValueRef;
	fnI64Rotl: LLVMValueRef;
	fnI64Rotr: LLVMValueRef;
	fnF32Div: LLVMValueRef;
	fnF64Div: LLVMValueRef;
	fnI32Load: LLVMValueRef;
	fnI64Load: LLVMValueRef;
	fnF32Load: LLVMValueRef;
	fnF64Load: LLVMValueRef;
	fnI32Load8S: LLVMValueRef;
	fnI32Load8U: LLVMValueRef;
	fnI32Load16S: LLVMValueRef;
	fnI32Load16U: LLVMValueRef;
	fnI64Load8S: LLVMValueRef;
	fnI64Load8U: LLVMValueRef;
	fnI64Load16S: LLVMValueRef;
	fnI64Load16U: LLVMValueRef;
	fnI64Load32S: LLVMValueRef;
	fnI64Load32U: LLVMValueRef;
	fnI32Store: LLVMValueRef;
	fnI64Store: LLVMValueRef;
	fnF32Store: LLVMValueRef;
	fnF64Store: LLVMValueRef;
	fnI32Store8: LLVMValueRef;
	fnI32Store16: LLVMValueRef;
	fnI64Store8: LLVMValueRef;
	fnI64Store16: LLVMValueRef;
	fnI64Store32: LLVMValueRef;
	fnI32TruncSF32: LLVMValueRef;
	fnI32TruncUF32: LLVMValueRef;
	fnI32TruncSF64: LLVMValueRef;
	fnI32TruncUF64: LLVMValueRef;
	fnI64TruncSF32: LLVMValueRef;
	fnI64TruncUF32: LLVMValueRef;
	fnI64TruncSF64: LLVMValueRef;
	fnI64TruncUF64: LLVMValueRef;
	fnF32DemoteF64: LLVMValueRef;
	fn_ctpop_i32: LLVMValueRef;
	fn_ctpop_i64: LLVMValueRef;
	fn_fabs_f32: LLVMValueRef;
	fn_ceil_f32: LLVMValueRef;
	fn_floor_f32: LLVMValueRef;
	fn_trunc_f32: LLVMValueRef;
	fn_nearbyint_f32: LLVMValueRef;
	fn_sqrt_f32: LLVMValueRef;
	fn_minnum_f32: LLVMValueRef;
	fn_maxnum_f32: LLVMValueRef;
	fn_copysign_f32: LLVMValueRef;
	fn_fabs_f64: LLVMValueRef;
	fn_ceil_f64: LLVMValueRef;
	fn_floor_f64: LLVMValueRef;
	fn_trunc_f64: LLVMValueRef;
	fn_nearbyint_f64: LLVMValueRef;
	fn_sqrt_f64: LLVMValueRef;
	fn_minnum_f64: LLVMValueRef;
	fn_maxnum_f64: LLVMValueRef;
	fn_copysign_f64: LLVMValueRef;


public:
	fn setup(mod: LLVMModuleRef, typeVoid: LLVMTypeRef, typeI32: LLVMTypeRef, typeI64: LLVMTypeRef, typeF32: LLVMTypeRef, typeF64: LLVMTypeRef) { }
}

tesla.polyfill

module tesla.polyfill;


class Func
{
public:
	name: string;
	ft: FuncType;
	ftIndex: u32;
	isImport: bool;
	llvmFunc: LLVMValueRef;


public:
	this(name: string, ft: FuncType, index: u32, isImport: bool) { }
	this(ft: FuncType, index: u32) { }
}

class Global
{
public:
	llvmValue: LLVMValueRef;
	initExpr: wasm.InitExpr;
	type: wasm.Type;
	isImport: bool;
	isPointer: bool;


public:
	this() { }
}

class FuncType
{
public:
	argTypes: wasm.Type[];
	retType: wasm.Type;
	llvmType: LLVMTypeRef;


public:
	this() { }
	fn hasRet() wasm.Type { }
}

class Polyfill : wasm.Reader
{
public:
	ctx: LLVMContextRef;
	mod: LLVMModuleRef;
	builder: LLVMBuilderRef;
	funcPrefix: string;
	funcAnonFmtStr: string;
	codeSection: const(u8)[];
	lastSection: wasm.Section;
	hasProccessedType: bool;
	hasProccessedImport: bool;
	hasProccessedFunction: bool;
	hasProccessedTable: bool;
	hasProccessedMemory: bool;
	hasProccessedGlobal: bool;
	hasProccessedExport: bool;
	hasProccessedStart: bool;
	hasProccessedElement: bool;
	hasProccessedCode: bool;
	hasProccessedData: bool;
	numFuncImports: u32;
	numGlobalImports: u32;
	startIndex: u32;
	typeVoid: LLVMTypeRef;
	typeI1: LLVMTypeRef;
	typeI8: LLVMTypeRef;
	typeI16: LLVMTypeRef;
	typeI32: LLVMTypeRef;
	typeI64: LLVMTypeRef;
	typeF32: LLVMTypeRef;
	typeF64: LLVMTypeRef;
	funcs: Func[];
	funcTypes: FuncType[];
	globals: Global[];
	valueStack: ValueStack;
	blockStack: BlockStack;
	currentFunc: Func;
	currentBlock: LLVMBasicBlockRef;
	currentLocals: LLVMValueRef[];
	currentLocalTypes: wasm.Type[];
	globalTeslaStack: LLVMValueRef;
	fns: InbuiltFuncs;


public:
	this() { }
	fn isLinkable() bool { }
	fn printToString() string { }
	fn writeToFile(filename: string) { }
	fn close() { }
	fn makeInbuilt() { }
	fn toLLVMFromValueType(t: wasm.Type) LLVMTypeRef { }
	fn toLLVMFromValueTypeOrVoid(t: wasm.Type) LLVMTypeRef { }
	fn onSection(id: wasm.Section, data: const(u8)[]) wasm.SkipOrParse { }
	fn onTypeSection(count: u32) { }
	fn onTypeEntry(num: u32, from: wasm.Type, args: wasm.Type[], ret: wasm.Type) { }
	fn onImportSection(count: u32) { }
	fn onImportGlobal(num: u32, mod: string, field: string, t: wasm.Type, mut: bool) { }
	fn onImportFunc(num: u32, mod: string, field: string, index: u32) { }
	fn onFunctionSection(count: u32) { }
	fn onFunctionEntry(num: u32, index: u32) { }
	fn onTableSection(count: u32) { }
	fn onTableEntry(num: u32, elem_type: wasm.Type, l: wasm.Limits) { }
	fn onMemorySection(count: u32) { }
	fn onMemoryEntry(num: u32, l: wasm.Limits) { }
	fn onGlobalSection(count: u32) { }
	fn onGlobalEntry(num: u32, type: wasm.Type, mut: bool, exp: wasm.InitExpr) { }
	fn onExportSection(count: u32) { }
	fn onExportEntry(num: u32, name: string, kind: wasm.ExternalKind, index: u32) { }
	fn onRelocSection(section: wasm.Section, name: string, count: u32) { }
	fn onRelocEntry(num: u32, type: wasm.RelocType, offset: u32, index: u32, addend: u32) { }
	fn onRelocSectionEnd() { }
	fn onReadError(err: string) { }
	fn onError(err: string, loc: string) { }
	fn onEOF() { }
	fn onFunctionBody(num: u32, types: wasm.Type[], counts: u32[]) { }
	fn onFunctionBodyEnd(num: u32) { }
	fn onOpI32Const(v: i32) { }
	fn onOpI64Const(v: i64) { }
	fn onOpF32Const(v: f32) { }
	fn onOpF64Const(v: f64) { }
	fn onControl(op: wasm.Opcode, t: wasm.Type) { }
	fn onBranch(op: wasm.Opcode, relative_depth: u32) { }
	fn onCall(index: u32) { }
	fn onCallIndirect(typeIndex: u32) { }
	fn onOp(op: wasm.Opcode) { }
	fn onOpMemory(op: wasm.Opcode, flags: u32, offset: u32) { }
	fn onOpVar(op: wasm.Opcode, index: u32) { }
	fn buildBlock(cstr: const(char)*) LLVMBasicBlockRef { }
	fn buildRet() { }
	fn buildICmp(t: wasm.Type, p: LLVMIntPredicate) { }
	fn buildFCmp(t: wasm.Type, p: LLVMRealPredicate) { }
	fn buildBinOp(t: wasm.Type, op: LLVMOpcode) { }
	fn buildBinCall(t: wasm.Type, f: LLVMValueRef) { }
	fn buildUnaryCall(t: wasm.Type, f: LLVMValueRef) { }
	fn buildCast(from: wasm.Type, to: wasm.Type, llvmType: LLVMTypeRef, lop: LLVMOpcode) { }
	fn buildBitCast(from: wasm.Type, to: wasm.Type, llvmType: LLVMTypeRef) { }
	fn buildConvCall(from: wasm.Type, to: wasm.Type, func: LLVMValueRef) { }
	fn buildLoad(t: wasm.Type, func: LLVMValueRef, offset: u32) { }
	fn buildStore(t: wasm.Type, func: LLVMValueRef, offset: u32) { }
	fn unhandledOp(op: wasm.Opcode, kind: string, loc: string) { }
	fn ensureNotImportFuncIndex(index: u32, kind: string, loc: string) { }
	fn ensureValidFuncIndex(index: u32, kind: string, loc: string) { }
	fn ensureValidFuncTypeIndex(index: u32, kind: string, loc: string) { }
	fn ensureValidGlobalIndex(index: u32, kind: string, loc: string) { }
	fn ensureSectionOrder(id: wasm.Section, loc: string) { }
	fn ensureOneEntry(count: u32, section: string, loc: string) { }
	fn ensureTypeSection(section: string, loc: string) { }
	fn ensureValidLocalIndex(index: u32, loc: string) { }
	fn ensureBlock(op: wasm.Opcode, loc: string) { }
	fn ensureTerminated(op: wasm.Opcode, loc: string) { }
	fn onHeader(header: wasm.Header) { }
	fn onCustomSection(name: string, data: const(u8)[]) { }
	fn onStart(index: u32) { }
	fn onCodeSection(count: u32) { }
	fn onCode(data: const(u8)[]) { }
}

struct BlockEntry
{
public:
	block: LLVMBasicBlockRef;
	isLoop: bool;
}

struct ValueStack
{
public:
	enum Max;


public:
	poly: Polyfill;


public:
	fn push(t: wasm.Type, v: T) { }
	fn pop(t: wasm.Type, loc: string) T { }
	fn pop() T { }
	fn topType(loc: string) wasm.Type { }
	fn getRelative(index: u32, t: wasm.Type, v: T) { }
	fn checkTop(t: wasm.Type, loc: string) T { }
	fn checkPush(loc: string) { }
	fn checkAndPop(loc: string) { }
	fn checkTypeAndPop(t: wasm.Type, loc: string) { }
}

struct BlockStack
{
public:
	enum Max;


public:
	poly: Polyfill;


public:
	fn push(t: wasm.Type, v: T) { }
	fn pop(t: wasm.Type, loc: string) T { }
	fn pop() T { }
	fn topType(loc: string) wasm.Type { }
	fn getRelative(index: u32, t: wasm.Type, v: T) { }
	fn checkTop(t: wasm.Type, loc: string) T { }
	fn checkPush(loc: string) { }
	fn checkAndPop(loc: string) { }
	fn checkTypeAndPop(t: wasm.Type, loc: string) { }
}

tesla.license

module tesla.license;


enum license;

global licenseArray: string[];

fn __ctor() { }

tesla.driver

module tesla.driver;


enum State
{
	None,
	Output,
}

class DefaultDriver : Driver
{
public:
	this(args: string[]) { }
	fn close() { }
	fn run() i32 { }
	fn printConfigUsage() { }
	fn info(fmt: scope (Fmt)) { }
	fn abort(fmt: scope (Fmt)) { }
}

fn processArgs(drv: DefaultDriver, args: string[]) { }
fn processArg(drv: DefaultDriver, state: State, arg: string) State { }

tesla.interfaces

module tesla.interfaces;


class Driver
{
public:
	alias Fmt = watt.text.sink.SinkArg;


public:
	this() { }
	fn info(fmt: scope (Fmt));
	fn abort(fmt: scope (Fmt));
}

lib.llvm.core

module lib.llvm.core;

public import lib.llvm.c.Core;


enum llvmLicense;

alias LLVMSetTarget = lib.llvm.c.Core.LLVMSetTarget;
alias LLVMSetDataLayout = lib.llvm.c.Core.LLVMSetDataLayout;
alias LLVMModuleCreateWithNameInContext = lib.llvm.c.Core.LLVMModuleCreateWithNameInContext;

fn LLVMSetTarget(mod: LLVMModuleRef, str: string) { }
fn LLVMSetDataLayout(mod: LLVMModuleRef, str: string) { }
fn LLVMModuleCreateWithNameInContext(name: string, c: LLVMContextRef) LLVMModuleRef { }
fn LLVMFunctionType(ret: LLVMTypeRef, args: LLVMTypeRef[], vararg: bool) LLVMTypeRef { }
fn LLVMAddFunction(mod: LLVMModuleRef, name: string, type: LLVMTypeRef) LLVMValueRef { }
fn LLVMAddIncoming(phi: LLVMValueRef, iv: LLVMValueRef[], ib: LLVMBasicBlockRef[]) { }
fn LLVMBuildAlloca(b: LLVMBuilderRef, type: LLVMTypeRef, name: string) LLVMValueRef { }
fn LLVMBuildCall(b: LLVMBuilderRef, func: LLVMValueRef, args: LLVMValueRef[]) LLVMValueRef { }
fn LLVMPrintTypeToString(ty: LLVMTypeRef) string { }
fn LLVMPrintValueToString(v: LLVMValueRef) string { }
fn LLVMPrintModuleToString(mod: LLVMModuleRef) string { }
fn nullTerminate(stack: char[], str: string) const(char)* { }
fn handleAndDisposeMessage(msg: const(char)**) string { }
fn __ctor() { }

lib.llvm.bitwriter

module lib.llvm.bitwriter;

public import lib.llvm.c.BitWriter;


fn LLVMWriteBitcodeToFile(mod: LLVMModuleRef, filename: string) bool { }

lib.llvm

module lib.llvm;

public import lib.llvm.core;
public import lib.llvm.bitwriter;

lib.llvm.c.Core

module lib.llvm.c.Core;


enum LLVMOpcode
{
	Ret,
	Br,
	Switch,
	IndirectBr,
	Invoke,
	Unreachable,
	Add,
	FAdd,
	Sub,
	FSub,
	Mul,
	FMul,
	UDiv,
	SDiv,
	FDiv,
	URem,
	SRem,
	FRem,
	Shl,
	LShr,
	AShr,
	And,
	Or,
	Xor,
	Alloca,
	Load,
	Store,
	GetElementPtr,
	Trunc,
	ZExt,
	SExt,
	FPToUI,
	FPToSI,
	UIToFP,
	SIToFP,
	FPTrunc,
	FPExt,
	PtrToInt,
	IntToPtr,
	BitCast,
	AddrSpaceCast,
	ICmp,
	FCmp,
	PHI,
	Call,
	Select,
	UserOp1,
	UserOp2,
	VAArg,
	ExtractElement,
	InsertElement,
	ShuffleVector,
	ExtractValue,
	InsertValue,
	Fence,
	AtomicCmpXchg,
	AtomicRMW,
	Resume,
	LandingPad,
	CleanupRet,
	CatchRet,
	CatchPad,
	CleanupPad,
	CatchSwitch,
}

enum LLVMIntPredicate
{
	EQ,
	NE,
	UGT,
	UGE,
	ULT,
	ULE,
	SGT,
	SGE,
	SLT,
	SLE,
}

enum LLVMRealPredicate
{
	PredicateFalse,
	OEQ,
	OGT,
	OGE,
	OLT,
	OLE,
	ONE,
	ORD,
	UNO,
	UEQ,
	UGT,
	UGE,
	ULT,
	ULE,
	UNE,
	PredicateTrue,
}

enum LLVMThreadLocalMode
{
	NotThreadLocal,
	GeneralDynamic,
	LocalDynamic,
	InitialExec,
	LocalExec,
}

alias LLVMBool = i32;
alias LLVMContextRef = LLVMContext*;
alias LLVMModuleRef = LLVMModule*;
alias LLVMTypeRef = LLVMType*;
alias LLVMValueRef = LLVMValue*;
alias LLVMAttributeRef = LLVMAttributeImpl*;
alias LLVMBasicBlockRef = LLVMBasicBlock*;
alias LLVMBuilderRef = LLVMBuilder*;

struct LLVMContext
{
}

struct LLVMModule
{
}

struct LLVMType
{
}

struct LLVMValue
{
}

struct LLVMAttributeImpl
{
}

struct LLVMBasicBlock
{
}

struct LLVMBuilder
{
}

fn LLVMContextCreate() LLVMContextRef;
fn LLVMModuleCreateWithNameInContext(const(char)*, LLVMContextRef) LLVMModuleRef;
fn LLVMContextDispose(LLVMContextRef);
fn LLVMModuleCreateWithName(const(char)*) LLVMModuleRef;
fn LLVMDisposeModule(LLVMModuleRef);
fn LLVMSetDataLayout(LLVMModuleRef, const(char)*);
fn LLVMSetTarget(LLVMModuleRef, const(char)*);
fn LLVMDumpModule(LLVMModuleRef);
fn LLVMCreateMessage(const(char)*) const(char)*;
fn LLVMDisposeMessage(const(char)*);
fn LLVMAddFunction(LLVMModuleRef, const(char)*, LLVMTypeRef) LLVMValueRef;
fn LLVMGetParam(LLVMValueRef, u32) LLVMValueRef;
fn LLVMDumpType(LLVMTypeRef);
fn LLVMDumpValue(LLVMValueRef);
fn LLVMDumpModule(LLVMModuleRef);
fn LLVMPrintTypeToString(LLVMTypeRef) const(char)*;
fn LLVMPrintValueToString(LLVMValueRef) const(char)*;
fn LLVMPrintModuleToString(LLVMModuleRef) const(char)*;
fn LLVMVoidTypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMInt1TypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMInt8TypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMInt16TypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMInt32TypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMInt64TypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMInt128TypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMIntTypeInContext(LLVMContextRef, u32) LLVMTypeRef;
fn LLVMGetIntTypeWidth(LLVMTypeRef) u32;
fn LLVMHalfTypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMFloatTypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMDoubleTypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMX86FP80TypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMFP128TypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMPPCFP128TypeInContext(LLVMContextRef) LLVMTypeRef;
fn LLVMFunctionType(LLVMTypeRef, LLVMTypeRef*, u32, LLVMBool) LLVMTypeRef;
fn LLVMPointerType(LLVMTypeRef, u32) LLVMTypeRef;
fn LLVMGetPointerAddressSpace(LLVMTypeRef) u32;
fn LLVMVectorType(LLVMTypeRef, u32) LLVMTypeRef;
fn LLVMGetVectorSize(LLVMTypeRef) u32;
fn LLVMConstNull(LLVMTypeRef) LLVMValueRef;
fn LLVMConstInt(LLVMTypeRef, u64, LLVMBool) LLVMValueRef;
fn LLVMConstAllOnes(LLVMTypeRef) LLVMValueRef;
fn LLVMGetUndef(LLVMTypeRef) LLVMValueRef;
fn LLVMIsNull(LLVMValueRef) LLVMBool;
fn LLVMConstPointerNull(LLVMTypeRef) LLVMValueRef;
fn LLVMConstReal(LLVMTypeRef, f64) LLVMValueRef;
fn LLVMAddGlobal(LLVMModuleRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMAddGlobalInAddressSpace(LLVMModuleRef, LLVMTypeRef, const(char)*, u32) LLVMValueRef;
fn LLVMGetNamedGlobal(LLVMModuleRef, const(char)*) LLVMValueRef;
fn LLVMGetFirstGlobal(LLVMModuleRef) LLVMValueRef;
fn LLVMGetLastGlobal(LLVMModuleRef) LLVMValueRef;
fn LLVMGetNextGlobal(LLVMValueRef) LLVMValueRef;
fn LLVMGetPreviousGlobal(LLVMValueRef) LLVMValueRef;
fn LLVMDeleteGlobal(LLVMValueRef);
fn LLVMGetInitializer(LLVMValueRef) LLVMValueRef;
fn LLVMSetInitializer(LLVMValueRef, LLVMValueRef);
fn LLVMIsThreadLocal(LLVMValueRef) LLVMBool;
fn LLVMSetThreadLocal(LLVMValueRef, LLVMBool);
fn LLVMIsGlobalConstant(LLVMValueRef) LLVMBool;
fn LLVMSetGlobalConstant(LLVMValueRef, LLVMBool);
fn LLVMGetThreadLocalMode(LLVMValueRef) LLVMThreadLocalMode;
fn LLVMSetThreadLocalMode(LLVMValueRef, LLVMThreadLocalMode);
fn LLVMIsExternallyInitialized(LLVMValueRef) LLVMBool;
fn LLVMSetExternallyInitialized(LLVMValueRef, LLVMBool);
fn LLVMCreateBuilderInContext(LLVMContextRef) LLVMBuilderRef;
fn LLVMPositionBuilder(LLVMBuilderRef, LLVMBasicBlockRef, LLVMValueRef);
fn LLVMPositionBuilderBefore(LLVMBuilderRef, LLVMValueRef);
fn LLVMPositionBuilderAtEnd(LLVMBuilderRef, LLVMBasicBlockRef);
fn LLVMGetInsertBlock(LLVMBuilderRef) LLVMBasicBlockRef;
fn LLVMClearInsertionPosition(LLVMBuilderRef);
fn LLVMInsertIntoBuilder(LLVMBuilderRef, LLVMValueRef);
fn LLVMInsertIntoBuilderWithName(LLVMBuilderRef, LLVMValueRef, const(char)*);
fn LLVMDisposeBuilder(LLVMBuilderRef);
fn LLVMAppendBasicBlockInContext(LLVMContextRef, LLVMValueRef, const(char)*) LLVMBasicBlockRef;
fn LLVMAddIncoming(LLVMValueRef, LLVMValueRef*, LLVMBasicBlockRef*, u32);
fn LLVMMoveBasicBlockAfter(LLVMBasicBlockRef, LLVMBasicBlockRef);
fn LLVMMoveBasicBlockBefore(LLVMBasicBlockRef, LLVMBasicBlockRef);
fn LLVMCountBasicBlocks(LLVMValueRef) u32;
fn LLVMGetBasicBlocks(LLVMValueRef, LLVMBasicBlockRef*);
fn LLVMGetFirstBasicBlock(LLVMValueRef) LLVMBasicBlockRef;
fn LLVMGetLastBasicBlock(LLVMValueRef) LLVMBasicBlockRef;
fn LLVMBuildCall(LLVMBuilderRef, LLVMValueRef, LLVMValueRef*, u32, const(char)*) LLVMValueRef;
fn LLVMBuildRetVoid(LLVMBuilderRef) LLVMValueRef;
fn LLVMBuildRet(LLVMBuilderRef, LLVMValueRef) LLVMValueRef;
fn LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef, const(char)*) LLVMValueRef;
fn LLVMBuildStore(LLVMBuilderRef, LLVMValueRef, LLVMValueRef) LLVMValueRef;
fn LLVMBuildBinOp(LLVMBuilderRef, LLVMOpcode, LLVMValueRef, LLVMValueRef, const(char)*) LLVMValueRef;
fn LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate, LLVMValueRef, LLVMValueRef, const(char)*) LLVMValueRef;
fn LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate, LLVMValueRef, LLVMValueRef, const(char)*) LLVMValueRef;
fn LLVMBuildUnreachable(LLVMBuilderRef) LLVMValueRef;
fn LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef) LLVMValueRef;
fn LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef, LLVMBasicBlockRef, LLVMBasicBlockRef) LLVMValueRef;
fn LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef, LLVMValueRef, LLVMValueRef, const(char)*) LLVMValueRef;
fn LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildCast(LLVMBuilderRef, LLVMOpcode, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;
fn LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef, LLVMTypeRef, const(char)*) LLVMValueRef;

lib.llvm.c.BitWriter

module lib.llvm.c.BitWriter;


fn LLVMWriteBitcodeToFile(LLVMModuleRef, const(char)*) i32;
fn LLVMWriteBitcodeToFD(LLVMModuleRef, i32, i32, i32) i32;

main

module main;


fn main(args: string[]) i32 { }