@@ -1705,6 +1705,97 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
1705
1705
bitwise_red ! ( simd_reduce_all: vector_reduce_and, true ) ;
1706
1706
bitwise_red ! ( simd_reduce_any: vector_reduce_or, true ) ;
1707
1707
1708
+ if name == sym:: simd_cast_ptr {
1709
+ require_simd ! ( ret_ty, "return" ) ;
1710
+ let ( out_len, out_elem) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
1711
+ require ! (
1712
+ in_len == out_len,
1713
+ "expected return type with length {} (same as input type `{}`), \
1714
+ found `{}` with length {}",
1715
+ in_len,
1716
+ in_ty,
1717
+ ret_ty,
1718
+ out_len
1719
+ ) ;
1720
+
1721
+ match in_elem. kind ( ) {
1722
+ ty:: RawPtr ( p) => {
1723
+ let ( metadata, check_sized) = p. ty . ptr_metadata_ty ( bx. tcx , |ty| {
1724
+ bx. tcx . normalize_erasing_regions ( ty:: ParamEnv :: reveal_all ( ) , ty)
1725
+ } ) ;
1726
+ assert ! ( !check_sized) ; // we are in codegen, so we shouldn't see these types
1727
+ require ! ( metadata. is_unit( ) , "cannot cast fat pointer `{}`" , in_elem)
1728
+ }
1729
+ _ => return_error ! ( "expected pointer, got `{}`" , in_elem) ,
1730
+ }
1731
+ match out_elem. kind ( ) {
1732
+ ty:: RawPtr ( p) => {
1733
+ let ( metadata, check_sized) = p. ty . ptr_metadata_ty ( bx. tcx , |ty| {
1734
+ bx. tcx . normalize_erasing_regions ( ty:: ParamEnv :: reveal_all ( ) , ty)
1735
+ } ) ;
1736
+ assert ! ( !check_sized) ; // we are in codegen, so we shouldn't see these types
1737
+ require ! ( metadata. is_unit( ) , "cannot cast to fat pointer `{}`" , out_elem)
1738
+ }
1739
+ _ => return_error ! ( "expected pointer, got `{}`" , out_elem) ,
1740
+ }
1741
+
1742
+ if in_elem == out_elem {
1743
+ return Ok ( args[ 0 ] . immediate ( ) ) ;
1744
+ } else {
1745
+ return Ok ( bx. pointercast ( args[ 0 ] . immediate ( ) , llret_ty) ) ;
1746
+ }
1747
+ }
1748
+
1749
+ if name == sym:: simd_expose_addr {
1750
+ require_simd ! ( ret_ty, "return" ) ;
1751
+ let ( out_len, out_elem) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
1752
+ require ! (
1753
+ in_len == out_len,
1754
+ "expected return type with length {} (same as input type `{}`), \
1755
+ found `{}` with length {}",
1756
+ in_len,
1757
+ in_ty,
1758
+ ret_ty,
1759
+ out_len
1760
+ ) ;
1761
+
1762
+ match in_elem. kind ( ) {
1763
+ ty:: RawPtr ( _) => { }
1764
+ _ => return_error ! ( "expected pointer, got `{}`" , in_elem) ,
1765
+ }
1766
+ match out_elem. kind ( ) {
1767
+ ty:: Uint ( ty:: UintTy :: Usize ) => { }
1768
+ _ => return_error ! ( "expected `usize`, got `{}`" , out_elem) ,
1769
+ }
1770
+
1771
+ return Ok ( bx. ptrtoint ( args[ 0 ] . immediate ( ) , llret_ty) ) ;
1772
+ }
1773
+
1774
+ if name == sym:: simd_from_exposed_addr {
1775
+ require_simd ! ( ret_ty, "return" ) ;
1776
+ let ( out_len, out_elem) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
1777
+ require ! (
1778
+ in_len == out_len,
1779
+ "expected return type with length {} (same as input type `{}`), \
1780
+ found `{}` with length {}",
1781
+ in_len,
1782
+ in_ty,
1783
+ ret_ty,
1784
+ out_len
1785
+ ) ;
1786
+
1787
+ match in_elem. kind ( ) {
1788
+ ty:: Uint ( ty:: UintTy :: Usize ) => { }
1789
+ _ => return_error ! ( "expected `usize`, got `{}`" , in_elem) ,
1790
+ }
1791
+ match out_elem. kind ( ) {
1792
+ ty:: RawPtr ( _) => { }
1793
+ _ => return_error ! ( "expected pointer, got `{}`" , out_elem) ,
1794
+ }
1795
+
1796
+ return Ok ( bx. inttoptr ( args[ 0 ] . immediate ( ) , llret_ty) ) ;
1797
+ }
1798
+
1708
1799
if name == sym:: simd_cast || name == sym:: simd_as {
1709
1800
require_simd ! ( ret_ty, "return" ) ;
1710
1801
let ( out_len, out_elem) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
0 commit comments