Comparison operator working
This commit is contained in:
parent
afec7e829c
commit
0c7099771f
@ -1,8 +1,2 @@
|
||||
a = 1
|
||||
if a {
|
||||
a = 42
|
||||
} else {
|
||||
a = 23
|
||||
}
|
||||
|
||||
a
|
||||
8 < 2
|
||||
|
@ -162,12 +162,15 @@ impl CodeGen for Expression {
|
||||
Div => simple_binop!(LLVMWrap::BuildUDiv, "divtemp"),
|
||||
Mod => simple_binop!(LLVMWrap::BuildSRem, "remtemp"),
|
||||
Less => {
|
||||
let pred = LLVMWrap::BuildICmp(data.builder,
|
||||
let pred: LLVMValueRef = LLVMWrap::BuildICmp(data.builder,
|
||||
LLVMIntPredicate::LLVMIntULT,
|
||||
lhs,
|
||||
rhs,
|
||||
"tmp");
|
||||
LLVMWrap::BuildUIToFP(data.builder, pred, int_type, "temp")
|
||||
LLVMWrap::BuildZExt(data.builder, pred, int_type, "temp")
|
||||
// god damn it this was probably failing because of the int_type
|
||||
// this assumes everything is a FP
|
||||
//LLVMWrap::BuildUIToFP(data.builder, pred, int_type, "temp")
|
||||
}
|
||||
_ => panic!("Bad operator {:?}", op),
|
||||
}
|
||||
|
@ -171,15 +171,21 @@ pub fn BuildFCmp(builder: LLVMBuilderRef,
|
||||
unsafe { core::LLVMBuildFCmp(builder, op, lhs, rhs, name.as_ptr()) }
|
||||
}
|
||||
|
||||
pub fn BuildZExt(builder: LLVMBuilderRef,
|
||||
val: LLVMValueRef,
|
||||
dest_type: LLVMTypeRef,
|
||||
name: &str) -> LLVMValueRef {
|
||||
let name = CString::new(name).unwrap();
|
||||
unsafe { core::LLVMBuildZExt(builder, val, dest_type, name.as_ptr()) }
|
||||
}
|
||||
|
||||
pub fn BuildUIToFP(builder: LLVMBuilderRef,
|
||||
val: LLVMValueRef,
|
||||
dest_type: LLVMTypeRef,
|
||||
name: &str) -> LLVMValueRef {
|
||||
|
||||
let name = CString::new(name).unwrap();
|
||||
unsafe { let p = name.as_ptr();
|
||||
println!("Pointer {:?}", p);
|
||||
core::LLVMBuildUIToFP(builder, val, dest_type, p) }
|
||||
unsafe { core::LLVMBuildUIToFP(builder, val, dest_type, name.as_ptr()) }
|
||||
}
|
||||
|
||||
pub fn BuildICmp(builder: LLVMBuilderRef,
|
||||
|
Loading…
Reference in New Issue
Block a user