let arg_tys = sig.inputs();
let ret_ty = sig.output();
let name = tcx.item_name(def_id);
- let name_str = &*name.as_str();
+ let name_str = name.as_str();
let llret_ty = self.layout_of(ret_ty).gcc_type(self, true);
let result = PlaceRef::new_sized(llresult, fn_abi.ret.layout);
let value =
if result_type.is_signed(self.cx) {
- self.context.new_bitcast(None, value, typ)
+ self.context.new_cast(None, value, typ)
}
else {
value
},
};
- self.context.new_bitcast(None, result, result_type)
+ self.context.new_cast(None, result, result_type)
}
fn count_leading_zeroes(&self, width: u64, arg: RValue<'gcc>) -> RValue<'gcc> {
let not_low = self.context.new_unary_op(None, UnaryOp::LogicalNegate, self.u64_type, low);
let not_low_and_not_high = not_low & not_high;
let index = not_high + not_low_and_not_high;
+ // NOTE: the following cast is necessary to avoid a GIMPLE verification failure in
+ // gcc.
+ // TODO(antoyo): do the correct verification in libgccjit to avoid an error at the
+ // compilation stage.
+ let index = self.context.new_cast(None, index, self.i32_type);
let res = self.context.new_array_access(None, result, index);
let arg =
if result_type.is_signed(self.cx) {
let new_type = result_type.to_unsigned(self.cx);
- self.context.new_bitcast(None, arg, new_type)
+ self.context.new_cast(None, arg, new_type)
}
else {
arg
let not_high = self.context.new_unary_op(None, UnaryOp::LogicalNegate, self.u64_type, high);
let not_low_and_not_high = not_low & not_high;
let index = not_low + not_low_and_not_high;
+ // NOTE: the following cast is necessary to avoid a GIMPLE verification failure in
+ // gcc.
+ // TODO(antoyo): do the correct verification in libgccjit to avoid an error at the
+ // compilation stage.
+ let index = self.context.new_cast(None, index, self.i32_type);
let res = self.context.new_array_access(None, result, index);
- return self.context.new_bitcast(None, res, result_type);
+ return self.context.new_cast(None, res, result_type);
}
else {
unimplemented!("count_trailing_zeroes for {:?}", arg_type);
arg
};
let res = self.context.new_call(None, count_trailing_zeroes, &[arg]);
- self.context.new_bitcast(None, res, result_type)
+ self.context.new_cast(None, res, result_type)
}
fn int_width(&self, typ: Type<'gcc>) -> i64 {
let value =
if result_type.is_signed(self.cx) {
- self.context.new_bitcast(None, value, value_type)
+ self.context.new_cast(None, value, value_type)
}
else {
value
let low = self.context.new_cast(None, value, self.cx.ulonglong_type);
let low = self.context.new_call(None, popcount, &[low]);
let res = high + low;
- return self.context.new_bitcast(None, res, result_type);
+ return self.context.new_cast(None, res, result_type);
}
// First step.
let value = left + right;
if value_type.is_u8(&self.cx) {
- return self.context.new_bitcast(None, value, result_type);
+ return self.context.new_cast(None, value, result_type);
}
// Fourth step.
let value = left + right;
if value_type.is_u16(&self.cx) {
- return self.context.new_bitcast(None, value, result_type);
+ return self.context.new_cast(None, value, result_type);
}
// Fifth step.
let value = left + right;
if value_type.is_u32(&self.cx) {
- return self.context.new_bitcast(None, value, result_type);
+ return self.context.new_cast(None, value, result_type);
}
// Sixth step.
let right = shifted & mask;
let value = left + right;
- self.context.new_bitcast(None, value, result_type)
+ self.context.new_cast(None, value, result_type)
}
// Algorithm from: https://blog.regehr.org/archives/1063