fix(from_low_high): Renamed according to clippy requirements
Changed for clippy naming convention requirement: ``` warning: methods called `from_*` usually take no `self` --> src/int.rs:996:22 | 996 | fn from_low_high(&self, typ: Type<'gcc>, low: i64, high: i64) -> RValue<'gcc> { | ^^^^^ | = help: consider choosing a less ambiguous name = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention = note: `#[warn(clippy::wrong_self_convention)]` on by default ```
This commit is contained in:
parent
3fd9db31bf
commit
a7d39b852a
35
src/int.rs
35
src/int.rs
@ -38,7 +38,7 @@ pub fn gcc_not(&self, a: RValue<'gcc>) -> RValue<'gcc> {
|
|||||||
self.cx.context.new_unary_op(self.location, operation, typ, a)
|
self.cx.context.new_unary_op(self.location, operation, typ, a)
|
||||||
} else {
|
} else {
|
||||||
let element_type = typ.dyncast_array().expect("element type");
|
let element_type = typ.dyncast_array().expect("element type");
|
||||||
self.from_low_high_rvalues(
|
self.concat_low_high_rvalues(
|
||||||
typ,
|
typ,
|
||||||
self.cx.context.new_unary_op(
|
self.cx.context.new_unary_op(
|
||||||
self.location,
|
self.location,
|
||||||
@ -112,7 +112,7 @@ pub fn gcc_lshr(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
|||||||
let shift_value = self.gcc_sub(b, sixty_four);
|
let shift_value = self.gcc_sub(b, sixty_four);
|
||||||
let high = self.high(a);
|
let high = self.high(a);
|
||||||
let sign = if a_type.is_signed(self) { high >> sixty_three } else { zero };
|
let sign = if a_type.is_signed(self) { high >> sixty_three } else { zero };
|
||||||
let array_value = self.from_low_high_rvalues(a_type, high >> shift_value, sign);
|
let array_value = self.concat_low_high_rvalues(a_type, high >> shift_value, sign);
|
||||||
then_block.add_assignment(self.location, result, array_value);
|
then_block.add_assignment(self.location, result, array_value);
|
||||||
then_block.end_with_jump(self.location, after_block);
|
then_block.end_with_jump(self.location, after_block);
|
||||||
|
|
||||||
@ -128,8 +128,11 @@ pub fn gcc_lshr(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
|||||||
let casted_low = self.context.new_cast(self.location, self.low(a), unsigned_type);
|
let casted_low = self.context.new_cast(self.location, self.low(a), unsigned_type);
|
||||||
let shifted_low = casted_low >> self.context.new_cast(self.location, b, unsigned_type);
|
let shifted_low = casted_low >> self.context.new_cast(self.location, b, unsigned_type);
|
||||||
let shifted_low = self.context.new_cast(self.location, shifted_low, native_int_type);
|
let shifted_low = self.context.new_cast(self.location, shifted_low, native_int_type);
|
||||||
let array_value =
|
let array_value = self.concat_low_high_rvalues(
|
||||||
self.from_low_high_rvalues(a_type, (high << shift_value) | shifted_low, high >> b);
|
a_type,
|
||||||
|
(high << shift_value) | shifted_low,
|
||||||
|
high >> b,
|
||||||
|
);
|
||||||
actual_else_block.add_assignment(self.location, result, array_value);
|
actual_else_block.add_assignment(self.location, result, array_value);
|
||||||
actual_else_block.end_with_jump(self.location, after_block);
|
actual_else_block.end_with_jump(self.location, after_block);
|
||||||
|
|
||||||
@ -610,7 +613,7 @@ pub fn gcc_xor(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
|||||||
{
|
{
|
||||||
a ^ b
|
a ^ b
|
||||||
} else {
|
} else {
|
||||||
self.from_low_high_rvalues(
|
self.concat_low_high_rvalues(
|
||||||
a_type,
|
a_type,
|
||||||
self.low(a) ^ self.low(b),
|
self.low(a) ^ self.low(b),
|
||||||
self.high(a) ^ self.high(b),
|
self.high(a) ^ self.high(b),
|
||||||
@ -659,7 +662,7 @@ pub fn gcc_shl(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
|||||||
self.llbb().end_with_conditional(self.location, condition, then_block, else_block);
|
self.llbb().end_with_conditional(self.location, condition, then_block, else_block);
|
||||||
|
|
||||||
let array_value =
|
let array_value =
|
||||||
self.from_low_high_rvalues(a_type, zero, self.low(a) << (b - sixty_four));
|
self.concat_low_high_rvalues(a_type, zero, self.low(a) << (b - sixty_four));
|
||||||
then_block.add_assignment(self.location, result, array_value);
|
then_block.add_assignment(self.location, result, array_value);
|
||||||
then_block.end_with_jump(self.location, after_block);
|
then_block.end_with_jump(self.location, after_block);
|
||||||
|
|
||||||
@ -677,7 +680,7 @@ pub fn gcc_shl(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
|||||||
let high_low =
|
let high_low =
|
||||||
self.context.new_cast(self.location, casted_low >> shift_value, native_int_type);
|
self.context.new_cast(self.location, casted_low >> shift_value, native_int_type);
|
||||||
|
|
||||||
let array_value = self.from_low_high_rvalues(
|
let array_value = self.concat_low_high_rvalues(
|
||||||
a_type,
|
a_type,
|
||||||
self.low(a) << b,
|
self.low(a) << b,
|
||||||
(self.high(a) << b) | high_low,
|
(self.high(a) << b) | high_low,
|
||||||
@ -706,7 +709,7 @@ pub fn gcc_bswap(&mut self, mut arg: RValue<'gcc>, width: u64) -> RValue<'gcc> {
|
|||||||
|
|
||||||
// NOTE: we also need to swap the two elements here, in addition to swapping inside
|
// NOTE: we also need to swap the two elements here, in addition to swapping inside
|
||||||
// the elements themselves like done above.
|
// the elements themselves like done above.
|
||||||
return self.from_low_high_rvalues(arg_type, swapped_msb, swapped_lsb);
|
return self.concat_low_high_rvalues(arg_type, swapped_msb, swapped_lsb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(antoyo): check if it's faster to use string literals and a
|
// TODO(antoyo): check if it's faster to use string literals and a
|
||||||
@ -728,7 +731,7 @@ pub fn gcc_int(&self, typ: Type<'gcc>, int: i64) -> RValue<'gcc> {
|
|||||||
self.context.new_rvalue_from_long(typ, int)
|
self.context.new_rvalue_from_long(typ, int)
|
||||||
} else {
|
} else {
|
||||||
// NOTE: set the sign in high.
|
// NOTE: set the sign in high.
|
||||||
self.from_low_high(typ, int, -(int.is_negative() as i64))
|
self.concat_low_high(typ, int, -(int.is_negative() as i64))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,7 +743,7 @@ pub fn gcc_uint(&self, typ: Type<'gcc>, int: u64) -> RValue<'gcc> {
|
|||||||
} else if self.is_native_int_type_or_bool(typ) {
|
} else if self.is_native_int_type_or_bool(typ) {
|
||||||
self.context.new_rvalue_from_long(typ, int as i64)
|
self.context.new_rvalue_from_long(typ, int as i64)
|
||||||
} else {
|
} else {
|
||||||
self.from_low_high(typ, int as i64, 0)
|
self.concat_low_high(typ, int as i64, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,7 +760,7 @@ pub fn gcc_uint_big(&self, typ: Type<'gcc>, num: u128) -> RValue<'gcc> {
|
|||||||
let shift = high << sixty_four;
|
let shift = high << sixty_four;
|
||||||
shift | self.context.new_cast(None, low, typ)
|
shift | self.context.new_cast(None, low, typ)
|
||||||
} else {
|
} else {
|
||||||
self.from_low_high(typ, low as i64, high as i64)
|
self.concat_low_high(typ, low as i64, high as i64)
|
||||||
}
|
}
|
||||||
} else if typ.is_i128(self) {
|
} else if typ.is_i128(self) {
|
||||||
// FIXME(antoyo): libgccjit cannot create 128-bit values yet.
|
// FIXME(antoyo): libgccjit cannot create 128-bit values yet.
|
||||||
@ -772,7 +775,7 @@ pub fn gcc_zero(&self, typ: Type<'gcc>) -> RValue<'gcc> {
|
|||||||
if self.is_native_int_type_or_bool(typ) {
|
if self.is_native_int_type_or_bool(typ) {
|
||||||
self.context.new_rvalue_zero(typ)
|
self.context.new_rvalue_zero(typ)
|
||||||
} else {
|
} else {
|
||||||
self.from_low_high(typ, 0, 0)
|
self.concat_low_high(typ, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -810,7 +813,7 @@ fn bitwise_operation(
|
|||||||
"both types should either be native or non-native for or operation"
|
"both types should either be native or non-native for or operation"
|
||||||
);
|
);
|
||||||
let native_int_type = a_type.dyncast_array().expect("get element type");
|
let native_int_type = a_type.dyncast_array().expect("get element type");
|
||||||
self.from_low_high_rvalues(
|
self.concat_low_high_rvalues(
|
||||||
a_type,
|
a_type,
|
||||||
self.context.new_binary_op(
|
self.context.new_binary_op(
|
||||||
loc,
|
loc,
|
||||||
@ -855,7 +858,7 @@ pub fn gcc_int_cast(&self, value: RValue<'gcc>, dest_typ: Type<'gcc>) -> RValue<
|
|||||||
let is_negative =
|
let is_negative =
|
||||||
self.context.new_comparison(None, ComparisonOp::LessThan, value, zero);
|
self.context.new_comparison(None, ComparisonOp::LessThan, value, zero);
|
||||||
let is_negative = self.gcc_int_cast(is_negative, dest_element_type);
|
let is_negative = self.gcc_int_cast(is_negative, dest_element_type);
|
||||||
self.from_low_high_rvalues(
|
self.concat_low_high_rvalues(
|
||||||
dest_typ,
|
dest_typ,
|
||||||
self.context.new_cast(None, value, dest_element_type),
|
self.context.new_cast(None, value, dest_element_type),
|
||||||
self.context.new_unary_op(None, UnaryOp::Minus, dest_element_type, is_negative),
|
self.context.new_unary_op(None, UnaryOp::Minus, dest_element_type, is_negative),
|
||||||
@ -975,7 +978,7 @@ fn low(&self, value: RValue<'gcc>) -> RValue<'gcc> {
|
|||||||
.to_rvalue()
|
.to_rvalue()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_low_high_rvalues(
|
fn concat_low_high_rvalues(
|
||||||
&self,
|
&self,
|
||||||
typ: Type<'gcc>,
|
typ: Type<'gcc>,
|
||||||
low: RValue<'gcc>,
|
low: RValue<'gcc>,
|
||||||
@ -990,7 +993,7 @@ fn from_low_high_rvalues(
|
|||||||
self.context.new_array_constructor(None, typ, &values)
|
self.context.new_array_constructor(None, typ, &values)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_low_high(&self, typ: Type<'gcc>, low: i64, high: i64) -> RValue<'gcc> {
|
fn concat_low_high(&self, typ: Type<'gcc>, low: i64, high: i64) -> RValue<'gcc> {
|
||||||
let (first, last) = match self.sess().target.options.endian {
|
let (first, last) = match self.sess().target.options.endian {
|
||||||
Endian::Little => (low, high),
|
Endian::Little => (low, high),
|
||||||
Endian::Big => (high, low),
|
Endian::Big => (high, low),
|
||||||
|
Loading…
Reference in New Issue
Block a user