Commit fb2f33a6 authored by Alastair Robertson's avatar Alastair Robertson

codegen: Cast all binary expressions to 64-bit ints

Allows statements such as '@x = (1 == 2)' to work
parent 0e80f8b2
...@@ -114,6 +114,7 @@ void CodegenLLVM::visit(Binop &binop) ...@@ -114,6 +114,7 @@ void CodegenLLVM::visit(Binop &binop)
case bpftrace::Parser::token::BXOR: expr_ = b_.CreateXor (lhs, rhs); break; case bpftrace::Parser::token::BXOR: expr_ = b_.CreateXor (lhs, rhs); break;
default: abort(); default: abort();
} }
expr_ = b_.CreateIntCast(expr_, b_.getInt64Ty(), false);
} }
void CodegenLLVM::visit(Unop &unop) void CodegenLLVM::visit(Unop &unop)
...@@ -195,10 +196,7 @@ void CodegenLLVM::visit(Predicate &pred) ...@@ -195,10 +196,7 @@ void CodegenLLVM::visit(Predicate &pred)
pred.expr->accept(*this); pred.expr->accept(*this);
expr_ = b_.CreateICmpEQ( expr_ = b_.CreateICmpEQ(expr_, b_.getInt64(0), "predcond");
b_.CreateIntCast(expr_, b_.getInt64Ty(), true),
b_.getInt64(0),
"predcond");
b_.CreateCondBr(expr_, pred_false_block, pred_true_block); b_.CreateCondBr(expr_, pred_false_block, pred_true_block);
b_.SetInsertPoint(pred_false_block); b_.SetInsertPoint(pred_false_block);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment