Move more code to llvm_wrap

And silence a few compiler warnings
This commit is contained in:
greg 2016-12-27 01:14:52 -08:00
parent 3d406f1dd2
commit e46d840d96
2 changed files with 11 additions and 8 deletions

View File

@ -1,10 +1,6 @@
extern crate llvm_sys;
use self::llvm_sys::prelude::*;
use self::llvm_sys::core;
use std::ptr;
use std::ffi::CString;
use parser::{ParseResult, AST, ASTNode, Prototype, Function, Expression};
use llvm_wrap as LLVMWrap;
@ -20,6 +16,7 @@ pub fn compilation_sequence(ast: AST, sourcefile: &str) {
_ => panic!("Bad filename {}", sourcefile),
};
compile_ast(ast, ll_filename);
Command::new("llc")
.arg("-filetype=obj")
@ -67,10 +64,7 @@ fn compile_ast(ast: AST, filename: &str) {
LLVMWrap::BuildRet(builder, value);
unsafe {
let out_file = CString::new(filename).unwrap();
core::LLVMPrintModuleToFile(module, out_file.as_ptr(), ptr::null_mut());
}
LLVMWrap::PrintModuleToFile(module, filename);
// Clean up. Values created in the context mostly get cleaned up there.
LLVMWrap::DisposeBuilder(builder);

View File

@ -1,3 +1,5 @@
#![allow(non_snake_case)]
#![allow(dead_code)]
extern crate llvm_sys;
use self::llvm_sys::prelude::*;
@ -138,3 +140,10 @@ pub fn BuildSRem(builder: LLVMBuilderRef, lhs: LLVMValueRef, rhs: LLVMValueRef,
core::LLVMBuildSRem(builder, lhs, rhs, name.as_ptr())
}
}
pub fn PrintModuleToFile(module: LLVMModuleRef, filename: &str) -> LLVMBool {
let out_file = CString::new(filename).unwrap();
unsafe {
core::LLVMPrintModuleToFile(module, out_file.as_ptr(), ptr::null_mut())
}
}