Merge pull request #149 from rust-lang/missing-comments
Add support for target builtins
This commit is contained in:
commit
a445bcb53d
@ -231,6 +231,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
|
||||
}
|
||||
else {
|
||||
assert!(!((actual_ty.is_vector() && !expected_ty.is_vector()) || (!actual_ty.is_vector() && expected_ty.is_vector())), "{:?} ({}) -> {:?} ({}), index: {:?}[{}]", actual_ty, actual_ty.is_vector(), expected_ty, expected_ty.is_vector(), func_ptr, index);
|
||||
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
|
||||
self.bitcast(actual_val, expected_ty)
|
||||
}
|
||||
}
|
||||
@ -1320,11 +1321,13 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
|
||||
if vec_num_units < mask_num_units {
|
||||
// NOTE: the mask needs to be the same length as the input vectors, so join the 2
|
||||
// vectors and create a dummy second vector.
|
||||
// TODO(antoyo): switch to using new_vector_access.
|
||||
let array = self.context.new_bitcast(None, v1, array_type);
|
||||
let mut elements = vec![];
|
||||
for i in 0..vec_num_units {
|
||||
elements.push(self.context.new_array_access(None, array, self.context.new_rvalue_from_int(self.int_type, i as i32)).to_rvalue());
|
||||
}
|
||||
// TODO(antoyo): switch to using new_vector_access.
|
||||
let array = self.context.new_bitcast(None, v2, array_type);
|
||||
for i in 0..vec_num_units {
|
||||
elements.push(self.context.new_array_access(None, array, self.context.new_rvalue_from_int(self.int_type, i as i32)).to_rvalue());
|
||||
@ -1347,6 +1350,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
|
||||
// NOTE: if padding was added, only select the number of elements of the masks to
|
||||
// remove that padding in the result.
|
||||
let mut elements = vec![];
|
||||
// TODO(antoyo): switch to using new_vector_access.
|
||||
let array = self.context.new_bitcast(None, result, array_type);
|
||||
for i in 0..mask_num_units {
|
||||
elements.push(self.context.new_array_access(None, array, self.context.new_rvalue_from_int(self.int_type, i as i32)).to_rvalue());
|
||||
|
@ -156,6 +156,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
|
||||
if a_type != b_type {
|
||||
if a_type.is_vector() {
|
||||
// Vector types need to be bitcast.
|
||||
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
|
||||
b = self.context.new_bitcast(None, b, a.get_type());
|
||||
}
|
||||
else {
|
||||
@ -649,8 +650,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
||||
// Since u128 and i128 are the only types that can be unsupported, we know the type of
|
||||
// value and the destination type have the same size, so a bitcast is fine.
|
||||
|
||||
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting. (This is elsewhere,
|
||||
// though.)
|
||||
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
|
||||
self.context.new_bitcast(None, value, dest_typ)
|
||||
}
|
||||
}
|
||||
|
@ -203,12 +203,14 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>,
|
||||
let param1_type = builtin.get_param(0).to_rvalue().get_type();
|
||||
let vector =
|
||||
if vector.get_type() != param1_type {
|
||||
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
|
||||
bx.context.new_bitcast(None, vector, param1_type)
|
||||
}
|
||||
else {
|
||||
vector
|
||||
};
|
||||
let result = bx.context.new_call(None, builtin, &[vector, value, bx.context.new_cast(None, index, bx.int_type)]);
|
||||
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
|
||||
return Ok(bx.context.new_bitcast(None, result, vector.get_type()));
|
||||
}
|
||||
if name == sym::simd_extract {
|
||||
@ -277,6 +279,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>,
|
||||
let vector_type = bx.context.new_vector_type(out_type, 8);
|
||||
let vector = args[0].immediate();
|
||||
let array_type = bx.context.new_array_type(None, in_type, 8);
|
||||
// TODO(antoyo): switch to using new_vector_access or __builtin_convertvector for vector casting.
|
||||
let array = bx.context.new_bitcast(None, vector, array_type);
|
||||
|
||||
let cast_vec_element = |index| {
|
||||
@ -533,6 +536,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>,
|
||||
|
||||
let func = bx.context.get_target_builtin_function(builtin_name);
|
||||
let result = bx.context.new_call(None, func, &[lhs, rhs]);
|
||||
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
|
||||
return Ok(bx.context.new_bitcast(None, result, vec_ty));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user