Rustfmt on llvm_wrap

This commit is contained in:
greg 2016-12-29 02:02:45 -08:00
parent af45004afa
commit e1d07b4e66

View File

@ -8,9 +8,7 @@ use std::ptr;
use std::ffi::CString; use std::ffi::CString;
pub fn create_context() -> LLVMContextRef { pub fn create_context() -> LLVMContextRef {
unsafe { unsafe { core::LLVMContextCreate() }
core::LLVMContextCreate()
}
} }
pub fn module_create_with_name(name: &str) -> LLVMModuleRef { pub fn module_create_with_name(name: &str) -> LLVMModuleRef {
unsafe { unsafe {
@ -19,131 +17,122 @@ pub fn module_create_with_name(name: &str) -> LLVMModuleRef {
} }
} }
pub fn CreateBuilderInContext(context: LLVMContextRef) -> LLVMBuilderRef { pub fn CreateBuilderInContext(context: LLVMContextRef) -> LLVMBuilderRef {
unsafe { unsafe { core::LLVMCreateBuilderInContext(context) }
core::LLVMCreateBuilderInContext(context)
}
} }
pub fn AppendBasicBlockInContext(context: LLVMContextRef, function: LLVMValueRef, name: &str) -> LLVMBasicBlockRef { pub fn AppendBasicBlockInContext(context: LLVMContextRef,
function: LLVMValueRef,
name: &str)
-> LLVMBasicBlockRef {
let c_name = CString::new(name).unwrap(); let c_name = CString::new(name).unwrap();
unsafe { unsafe { core::LLVMAppendBasicBlockInContext(context, function, c_name.as_ptr()) }
core::LLVMAppendBasicBlockInContext(context, function, c_name.as_ptr())
}
} }
pub fn AddFunction(module: LLVMModuleRef, name: &str, function_type: LLVMTypeRef) -> LLVMValueRef { pub fn AddFunction(module: LLVMModuleRef, name: &str, function_type: LLVMTypeRef) -> LLVMValueRef {
let c_name = CString::new(name).unwrap(); let c_name = CString::new(name).unwrap();
unsafe { unsafe { core::LLVMAddFunction(module, c_name.as_ptr(), function_type) }
core::LLVMAddFunction(module, c_name.as_ptr(), function_type)
}
} }
// NOTE this is incomplete // NOTE this is incomplete
pub fn FunctionType(return_type: LLVMTypeRef, param_types: &[LLVMTypeRef], is_var_rag: bool) -> LLVMTypeRef { pub fn FunctionType(return_type: LLVMTypeRef,
param_types: &[LLVMTypeRef],
is_var_rag: bool)
-> LLVMTypeRef {
let len = param_types.len(); let len = param_types.len();
unsafe { unsafe {
core::LLVMFunctionType(return_type, ptr::null_mut(), len as u32, if is_var_rag { 1 } else { 0 }) core::LLVMFunctionType(return_type,
ptr::null_mut(),
len as u32,
if is_var_rag { 1 } else { 0 })
} }
} }
pub fn VoidTypeInContext(context: LLVMContextRef) -> LLVMTypeRef { pub fn VoidTypeInContext(context: LLVMContextRef) -> LLVMTypeRef {
unsafe { unsafe { core::LLVMVoidTypeInContext(context) }
core::LLVMVoidTypeInContext(context)
}
} }
pub fn DisposeBuilder(builder: LLVMBuilderRef) { pub fn DisposeBuilder(builder: LLVMBuilderRef) {
unsafe { unsafe { core::LLVMDisposeBuilder(builder) }
core::LLVMDisposeBuilder(builder)
}
} }
pub fn DisposeModule(module: LLVMModuleRef) { pub fn DisposeModule(module: LLVMModuleRef) {
unsafe { unsafe { core::LLVMDisposeModule(module) }
core::LLVMDisposeModule(module)
}
} }
pub fn ContextDispose(context: LLVMContextRef) { pub fn ContextDispose(context: LLVMContextRef) {
unsafe { unsafe { core::LLVMContextDispose(context) }
core::LLVMContextDispose(context)
}
} }
pub fn PositionBuilderAtEnd(builder: LLVMBuilderRef, basic_block: LLVMBasicBlockRef) { pub fn PositionBuilderAtEnd(builder: LLVMBuilderRef, basic_block: LLVMBasicBlockRef) {
unsafe { unsafe { core::LLVMPositionBuilderAtEnd(builder, basic_block) }
core::LLVMPositionBuilderAtEnd(builder, basic_block)
}
} }
pub fn BuildRet(builder: LLVMBuilderRef, val: LLVMValueRef) -> LLVMValueRef { pub fn BuildRet(builder: LLVMBuilderRef, val: LLVMValueRef) -> LLVMValueRef {
unsafe { unsafe { core::LLVMBuildRet(builder, val) }
core::LLVMBuildRet(builder, val)
}
} }
pub fn BuildRetVoid(builder: LLVMBuilderRef) -> LLVMValueRef { pub fn BuildRetVoid(builder: LLVMBuilderRef) -> LLVMValueRef {
unsafe { unsafe { core::LLVMBuildRetVoid(builder) }
core::LLVMBuildRetVoid(builder)
}
} }
pub fn DumpModule(module: LLVMModuleRef) { pub fn DumpModule(module: LLVMModuleRef) {
unsafe { unsafe { core::LLVMDumpModule(module) }
core::LLVMDumpModule(module)
}
} }
pub fn Int64TypeInContext(context: LLVMContextRef) -> LLVMTypeRef { pub fn Int64TypeInContext(context: LLVMContextRef) -> LLVMTypeRef {
unsafe { unsafe { core::LLVMInt64TypeInContext(context) }
core::LLVMInt64TypeInContext(context)
}
} }
pub fn ConstInt(int_type: LLVMTypeRef, n: u64, sign_extend: bool) -> LLVMValueRef { pub fn ConstInt(int_type: LLVMTypeRef, n: u64, sign_extend: bool) -> LLVMValueRef {
unsafe { unsafe { core::LLVMConstInt(int_type, n, if sign_extend { 1 } else { 0 }) }
core::LLVMConstInt(int_type, n, if sign_extend { 1 } else { 0 })
}
} }
pub fn BuildAdd(builder: LLVMBuilderRef, lhs: LLVMValueRef, rhs: LLVMValueRef, reg_name: &str) -> LLVMValueRef { pub fn BuildAdd(builder: LLVMBuilderRef,
lhs: LLVMValueRef,
rhs: LLVMValueRef,
reg_name: &str)
-> LLVMValueRef {
let name = CString::new(reg_name).unwrap(); let name = CString::new(reg_name).unwrap();
unsafe { unsafe { core::LLVMBuildAdd(builder, lhs, rhs, name.as_ptr()) }
core::LLVMBuildAdd(builder, lhs, rhs, name.as_ptr())
}
} }
pub fn BuildSub(builder: LLVMBuilderRef, lhs: LLVMValueRef, rhs: LLVMValueRef, reg_name: &str) -> LLVMValueRef { pub fn BuildSub(builder: LLVMBuilderRef,
lhs: LLVMValueRef,
rhs: LLVMValueRef,
reg_name: &str)
-> LLVMValueRef {
let name = CString::new(reg_name).unwrap(); let name = CString::new(reg_name).unwrap();
unsafe { unsafe { core::LLVMBuildSub(builder, lhs, rhs, name.as_ptr()) }
core::LLVMBuildSub(builder, lhs, rhs, name.as_ptr())
}
} }
pub fn BuildMul(builder: LLVMBuilderRef, lhs: LLVMValueRef, rhs: LLVMValueRef, reg_name: &str) -> LLVMValueRef { pub fn BuildMul(builder: LLVMBuilderRef,
lhs: LLVMValueRef,
rhs: LLVMValueRef,
reg_name: &str)
-> LLVMValueRef {
let name = CString::new(reg_name).unwrap(); let name = CString::new(reg_name).unwrap();
unsafe { unsafe { core::LLVMBuildMul(builder, lhs, rhs, name.as_ptr()) }
core::LLVMBuildMul(builder, lhs, rhs, name.as_ptr())
}
} }
pub fn BuildUDiv(builder: LLVMBuilderRef, lhs: LLVMValueRef, rhs: LLVMValueRef, reg_name: &str) -> LLVMValueRef { pub fn BuildUDiv(builder: LLVMBuilderRef,
lhs: LLVMValueRef,
rhs: LLVMValueRef,
reg_name: &str)
-> LLVMValueRef {
let name = CString::new(reg_name).unwrap(); let name = CString::new(reg_name).unwrap();
unsafe { unsafe { core::LLVMBuildUDiv(builder, lhs, rhs, name.as_ptr()) }
core::LLVMBuildUDiv(builder, lhs, rhs, name.as_ptr())
}
} }
pub fn BuildSRem(builder: LLVMBuilderRef, lhs: LLVMValueRef, rhs: LLVMValueRef, reg_name: &str) -> LLVMValueRef { pub fn BuildSRem(builder: LLVMBuilderRef,
lhs: LLVMValueRef,
rhs: LLVMValueRef,
reg_name: &str)
-> LLVMValueRef {
let name = CString::new(reg_name).unwrap(); let name = CString::new(reg_name).unwrap();
unsafe { unsafe { core::LLVMBuildSRem(builder, lhs, rhs, name.as_ptr()) }
core::LLVMBuildSRem(builder, lhs, rhs, name.as_ptr())
}
} }
pub fn PrintModuleToFile(module: LLVMModuleRef, filename: &str) -> LLVMBool { pub fn PrintModuleToFile(module: LLVMModuleRef, filename: &str) -> LLVMBool {
let out_file = CString::new(filename).unwrap(); let out_file = CString::new(filename).unwrap();
unsafe { unsafe { core::LLVMPrintModuleToFile(module, out_file.as_ptr(), ptr::null_mut()) }
core::LLVMPrintModuleToFile(module, out_file.as_ptr(), ptr::null_mut())
}
} }