Skip to content

Commit

Permalink
Fix FIXME in Builder::and and Builder::or impls (rust-lang#101)
Browse files Browse the repository at this point in the history
* impl bitwise and & or
  • Loading branch information
fisherdarling authored Oct 12, 2021
1 parent 6693595 commit 863cfb2
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,22 +605,17 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
}

fn and(&mut self, a: RValue<'gcc>, mut b: RValue<'gcc>) -> RValue<'gcc> {
// FIXME(antoyo): hack by putting the result in a variable to workaround this bug:
// https://gcc.gnu.org/bugzilla//show_bug.cgi?id=95498
if a.get_type() != b.get_type() {
b = self.context.new_cast(None, b, a.get_type());
}
let res = self.current_func().new_local(None, b.get_type(), "andResult");
self.llbb().add_assignment(None, res, a & b);
res.to_rvalue()
a & b
}

fn or(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
// FIXME(antoyo): hack by putting the result in a variable to workaround this bug:
// https://gcc.gnu.org/bugzilla//show_bug.cgi?id=95498
let res = self.current_func().new_local(None, b.get_type(), "orResult");
self.llbb().add_assignment(None, res, a | b);
res.to_rvalue()
fn or(&mut self, a: RValue<'gcc>, mut b: RValue<'gcc>) -> RValue<'gcc> {
if a.get_type() != b.get_type() {
b = self.context.new_cast(None, b, a.get_type());
}
a | b
}

fn xor(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
Expand Down

0 comments on commit 863cfb2

Please sign in to comment.