Skip to content

Commit a445bcb

Browse files
authored
Merge pull request rust-lang#149 from rust-lang/missing-comments
Add support for target builtins
2 parents 13ab1ab + 267e5e1 commit a445bcb

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/builder.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
231231
}
232232
else {
233233
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);
234+
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
234235
self.bitcast(actual_val, expected_ty)
235236
}
236237
}
@@ -1320,11 +1321,13 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
13201321
if vec_num_units < mask_num_units {
13211322
// NOTE: the mask needs to be the same length as the input vectors, so join the 2
13221323
// vectors and create a dummy second vector.
1324+
// TODO(antoyo): switch to using new_vector_access.
13231325
let array = self.context.new_bitcast(None, v1, array_type);
13241326
let mut elements = vec![];
13251327
for i in 0..vec_num_units {
13261328
elements.push(self.context.new_array_access(None, array, self.context.new_rvalue_from_int(self.int_type, i as i32)).to_rvalue());
13271329
}
1330+
// TODO(antoyo): switch to using new_vector_access.
13281331
let array = self.context.new_bitcast(None, v2, array_type);
13291332
for i in 0..vec_num_units {
13301333
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> {
13471350
// NOTE: if padding was added, only select the number of elements of the masks to
13481351
// remove that padding in the result.
13491352
let mut elements = vec![];
1353+
// TODO(antoyo): switch to using new_vector_access.
13501354
let array = self.context.new_bitcast(None, result, array_type);
13511355
for i in 0..mask_num_units {
13521356
elements.push(self.context.new_array_access(None, array, self.context.new_rvalue_from_int(self.int_type, i as i32)).to_rvalue());

src/int.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
156156
if a_type != b_type {
157157
if a_type.is_vector() {
158158
// Vector types need to be bitcast.
159+
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
159160
b = self.context.new_bitcast(None, b, a.get_type());
160161
}
161162
else {
@@ -649,8 +650,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
649650
// Since u128 and i128 are the only types that can be unsupported, we know the type of
650651
// value and the destination type have the same size, so a bitcast is fine.
651652

652-
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting. (This is elsewhere,
653-
// though.)
653+
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
654654
self.context.new_bitcast(None, value, dest_typ)
655655
}
656656
}

src/intrinsic/simd.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,14 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>,
203203
let param1_type = builtin.get_param(0).to_rvalue().get_type();
204204
let vector =
205205
if vector.get_type() != param1_type {
206+
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
206207
bx.context.new_bitcast(None, vector, param1_type)
207208
}
208209
else {
209210
vector
210211
};
211212
let result = bx.context.new_call(None, builtin, &[vector, value, bx.context.new_cast(None, index, bx.int_type)]);
213+
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
212214
return Ok(bx.context.new_bitcast(None, result, vector.get_type()));
213215
}
214216
if name == sym::simd_extract {
@@ -277,6 +279,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>,
277279
let vector_type = bx.context.new_vector_type(out_type, 8);
278280
let vector = args[0].immediate();
279281
let array_type = bx.context.new_array_type(None, in_type, 8);
282+
// TODO(antoyo): switch to using new_vector_access or __builtin_convertvector for vector casting.
280283
let array = bx.context.new_bitcast(None, vector, array_type);
281284

282285
let cast_vec_element = |index| {
@@ -533,6 +536,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>,
533536

534537
let func = bx.context.get_target_builtin_function(builtin_name);
535538
let result = bx.context.new_call(None, func, &[lhs, rhs]);
539+
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
536540
return Ok(bx.context.new_bitcast(None, result, vec_ty));
537541
}
538542

0 commit comments

Comments
 (0)