Skip to content

Commit 9a49ef3

Browse files
committed
Simplify all require_simd invocations by moving all of the shared invocation arguments into the macro
1 parent 7c673db commit 9a49ef3

File tree

1 file changed

+19
-37
lines changed

1 file changed

+19
-37
lines changed

compiler/rustc_codegen_llvm/src/intrinsic.rs

+19-37
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
935935
}
936936

937937
macro_rules! require_simd {
938-
($ty: expr, $diag: expr) => {
939-
require!($ty.is_simd(), $diag)
938+
($ty: expr, $variant:ident) => {
939+
require!($ty.is_simd(), InvalidMonomorphization::$variant { span, name, ty: $ty })
940940
};
941941
}
942942

@@ -946,10 +946,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
946946
let arg_tys = sig.inputs();
947947

948948
if name == sym::simd_select_bitmask {
949-
require_simd!(
950-
arg_tys[1],
951-
InvalidMonomorphization::SimdArgument { span, name, ty: arg_tys[1] }
952-
);
949+
require_simd!(arg_tys[1], SimdArgument);
953950

954951
let (len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
955952

@@ -988,7 +985,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
988985
}
989986

990987
// every intrinsic below takes a SIMD vector as its first argument
991-
require_simd!(arg_tys[0], InvalidMonomorphization::SimdInput { span, name, ty: arg_tys[0] });
988+
require_simd!(arg_tys[0], SimdInput);
992989
let in_ty = arg_tys[0];
993990

994991
let comparison = match name {
@@ -1003,7 +1000,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
10031000

10041001
let (in_len, in_elem) = arg_tys[0].simd_size_and_type(bx.tcx());
10051002
if let Some(cmp_op) = comparison {
1006-
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
1003+
require_simd!(ret_ty, SimdReturn);
10071004

10081005
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
10091006

@@ -1041,7 +1038,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
10411038
.unwrap_branch();
10421039
let n = idx.len() as u64;
10431040

1044-
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
1041+
require_simd!(ret_ty, SimdReturn);
10451042
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
10461043
require!(
10471044
out_len == n,
@@ -1099,7 +1096,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
10991096
}),
11001097
};
11011098

1102-
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
1099+
require_simd!(ret_ty, SimdReturn);
11031100
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
11041101
require!(
11051102
out_len == n,
@@ -1179,10 +1176,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
11791176
if name == sym::simd_select {
11801177
let m_elem_ty = in_elem;
11811178
let m_len = in_len;
1182-
require_simd!(
1183-
arg_tys[1],
1184-
InvalidMonomorphization::SimdArgument { span, name, ty: arg_tys[1] }
1185-
);
1179+
require_simd!(arg_tys[1], SimdArgument);
11861180
let (v_len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
11871181
require!(
11881182
m_len == v_len,
@@ -1401,16 +1395,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
14011395
// * M: any integer width is supported, will be truncated to i1
14021396

14031397
// All types must be simd vector types
1404-
require_simd!(in_ty, InvalidMonomorphization::SimdFirst { span, name, ty: in_ty });
1405-
require_simd!(
1406-
arg_tys[1],
1407-
InvalidMonomorphization::SimdSecond { span, name, ty: arg_tys[1] }
1408-
);
1409-
require_simd!(
1410-
arg_tys[2],
1411-
InvalidMonomorphization::SimdThird { span, name, ty: arg_tys[2] }
1412-
);
1413-
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
1398+
require_simd!(in_ty, SimdFirst);
1399+
require_simd!(arg_tys[1], SimdSecond);
1400+
require_simd!(arg_tys[2], SimdThird);
1401+
require_simd!(ret_ty, SimdReturn);
14141402

14151403
// Of the same length:
14161404
let (out_len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
@@ -1524,15 +1512,9 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
15241512
// * M: any integer width is supported, will be truncated to i1
15251513

15261514
// All types must be simd vector types
1527-
require_simd!(in_ty, InvalidMonomorphization::SimdFirst { span, name, ty: in_ty });
1528-
require_simd!(
1529-
arg_tys[1],
1530-
InvalidMonomorphization::SimdSecond { span, name, ty: arg_tys[1] }
1531-
);
1532-
require_simd!(
1533-
arg_tys[2],
1534-
InvalidMonomorphization::SimdThird { span, name, ty: arg_tys[2] }
1535-
);
1515+
require_simd!(in_ty, SimdFirst);
1516+
require_simd!(arg_tys[1], SimdSecond);
1517+
require_simd!(arg_tys[2], SimdThird);
15361518

15371519
// Of the same length:
15381520
let (element_len1, _) = arg_tys[1].simd_size_and_type(bx.tcx());
@@ -1788,7 +1770,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
17881770
bitwise_red!(simd_reduce_any: vector_reduce_or, true);
17891771

17901772
if name == sym::simd_cast_ptr {
1791-
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
1773+
require_simd!(ret_ty, SimdReturn);
17921774
let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx());
17931775
require!(
17941776
in_len == out_len,
@@ -1837,7 +1819,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
18371819
}
18381820

18391821
if name == sym::simd_expose_addr {
1840-
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
1822+
require_simd!(ret_ty, SimdReturn);
18411823
let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx());
18421824
require!(
18431825
in_len == out_len,
@@ -1866,7 +1848,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
18661848
}
18671849

18681850
if name == sym::simd_from_exposed_addr {
1869-
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
1851+
require_simd!(ret_ty, SimdReturn);
18701852
let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx());
18711853
require!(
18721854
in_len == out_len,
@@ -1895,7 +1877,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
18951877
}
18961878

18971879
if name == sym::simd_cast || name == sym::simd_as {
1898-
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
1880+
require_simd!(ret_ty, SimdReturn);
18991881
let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx());
19001882
require!(
19011883
in_len == out_len,

0 commit comments

Comments
 (0)