aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-09-28 16:17:28 -0700
committerGraydon Hoare <[email protected]>2010-09-28 16:17:28 -0700
commitf13306e8d646ff799b59c271164d8fabda8c4b24 (patch)
tree16f6a4aa9632bb20d211bbc3e69c25823b23c2ef /src
parentTranslate a modest selection of easy binops. (diff)
downloadrust-f13306e8d646ff799b59c271164d8fabda8c4b24.tar.xz
rust-f13306e8d646ff799b59c271164d8fabda8c4b24.zip
Switch boolean operands to 1-bit, as llvm prefers. Will promote to 8-bit when storing to memory.
Diffstat (limited to 'src')
-rw-r--r--src/comp/middle/trans.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 1fbee72b..eb396976 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -62,6 +62,10 @@ fn T_nil() -> TypeRef {
ret llvm.LLVMVoidType();
}
+fn T_i1() -> TypeRef {
+ ret llvm.LLVMInt1Type();
+}
+
fn T_i8() -> TypeRef {
ret llvm.LLVMInt8Type();
}
@@ -161,9 +165,9 @@ fn C_integral(int i, TypeRef t) -> ValueRef {
fn C_bool(bool b) -> ValueRef {
if (b) {
- ret C_integral(1, T_i8());
+ ret C_integral(1, T_i1());
} else {
- ret C_integral(0, T_i8());
+ ret C_integral(0, T_i1());
}
}
@@ -274,8 +278,7 @@ fn trans_unary(@block_ctxt cx, ast.unop op, &ast.expr e) -> ValueRef {
ret cx.build.Not(trans_expr(cx, e));
}
case (ast.not) {
- ret cx.build.And(C_bool(true),
- cx.build.Not(trans_expr(cx, e)));
+ ret cx.build.Not(trans_expr(cx, e));
}
case (ast.neg) {
// FIXME: switch by signedness.