Fix provenance intrinsics
This commit is contained in:
parent
0ffcbb0f6e
commit
e8e6663167
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -80,8 +80,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gccjit"
|
name = "gccjit"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/rust-lang/gccjit.rs#f1545d7c2c13e42d78eaac8032d49ab8f7d43b6e"
|
||||||
checksum = "ecaa4c3da2d74c1a991b4faff75d49ab1d0522d9a99d8e2614b3b04d226417ce"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gccjit_sys",
|
"gccjit_sys",
|
||||||
]
|
]
|
||||||
@ -89,8 +88,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gccjit_sys"
|
name = "gccjit_sys"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/rust-lang/gccjit.rs#f1545d7c2c13e42d78eaac8032d49ab8f7d43b6e"
|
||||||
checksum = "406a66fba005f1a02661f2f9443e5693dd3a667b7c58e70aa4ccc4c8b50b4758"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
@ -22,7 +22,8 @@ master = ["gccjit/master"]
|
|||||||
default = ["master"]
|
default = ["master"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gccjit = "2.0"
|
#gccjit = "2.0"
|
||||||
|
gccjit = { git = "https://github.com/rust-lang/gccjit.rs" }
|
||||||
|
|
||||||
# Local copy.
|
# Local copy.
|
||||||
#gccjit = { path = "../gccjit.rs" }
|
#gccjit = { path = "../gccjit.rs" }
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2024-03-05"
|
channel = "nightly-2024-06-18"
|
||||||
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
||||||
|
@ -436,6 +436,141 @@ macro_rules! require_simd {
|
|||||||
return Ok(bx.vector_select(args[0].immediate(), args[1].immediate(), args[2].immediate()));
|
return Ok(bx.vector_select(args[0].immediate(), args[1].immediate(), args[2].immediate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if name == sym::simd_cast_ptr {
|
||||||
|
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
|
||||||
|
let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx());
|
||||||
|
|
||||||
|
require!(
|
||||||
|
in_len == out_len,
|
||||||
|
InvalidMonomorphization::ReturnLengthInputType {
|
||||||
|
span,
|
||||||
|
name,
|
||||||
|
in_len,
|
||||||
|
in_ty,
|
||||||
|
ret_ty,
|
||||||
|
out_len
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
match *in_elem.kind() {
|
||||||
|
ty::RawPtr(p_ty, _) => {
|
||||||
|
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
|
||||||
|
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
|
||||||
|
});
|
||||||
|
require!(
|
||||||
|
metadata.is_unit(),
|
||||||
|
InvalidMonomorphization::CastFatPointer { span, name, ty: in_elem }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: in_elem })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match *out_elem.kind() {
|
||||||
|
ty::RawPtr(p_ty, _) => {
|
||||||
|
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
|
||||||
|
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
|
||||||
|
});
|
||||||
|
require!(
|
||||||
|
metadata.is_unit(),
|
||||||
|
InvalidMonomorphization::CastFatPointer { span, name, ty: out_elem }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: out_elem })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let arg = args[0].immediate();
|
||||||
|
let elem_type = llret_ty.dyncast_vector().expect("vector return type").get_element_type();
|
||||||
|
let values: Vec<_> = (0..in_len)
|
||||||
|
.map(|i| {
|
||||||
|
let idx = bx.gcc_int(bx.usize_type, i as _);
|
||||||
|
let value = bx.extract_element(arg, idx);
|
||||||
|
bx.pointercast(value, elem_type)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
return Ok(bx.context.new_rvalue_from_vector(bx.location, llret_ty, &values));
|
||||||
|
}
|
||||||
|
|
||||||
|
if name == sym::simd_expose_provenance {
|
||||||
|
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
|
||||||
|
let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx());
|
||||||
|
|
||||||
|
require!(
|
||||||
|
in_len == out_len,
|
||||||
|
InvalidMonomorphization::ReturnLengthInputType {
|
||||||
|
span,
|
||||||
|
name,
|
||||||
|
in_len,
|
||||||
|
in_ty,
|
||||||
|
ret_ty,
|
||||||
|
out_len
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
match *in_elem.kind() {
|
||||||
|
ty::RawPtr(_, _) => {}
|
||||||
|
_ => {
|
||||||
|
return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: in_elem })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match *out_elem.kind() {
|
||||||
|
ty::Uint(ty::UintTy::Usize) => {}
|
||||||
|
_ => return_error!(InvalidMonomorphization::ExpectedUsize { span, name, ty: out_elem }),
|
||||||
|
}
|
||||||
|
|
||||||
|
let arg = args[0].immediate();
|
||||||
|
let elem_type = llret_ty.dyncast_vector().expect("vector return type").get_element_type();
|
||||||
|
let values: Vec<_> = (0..in_len)
|
||||||
|
.map(|i| {
|
||||||
|
let idx = bx.gcc_int(bx.usize_type, i as _);
|
||||||
|
let value = bx.extract_element(arg, idx);
|
||||||
|
bx.ptrtoint(value, elem_type)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
return Ok(bx.context.new_rvalue_from_vector(bx.location, llret_ty, &values));
|
||||||
|
}
|
||||||
|
|
||||||
|
if name == sym::simd_with_exposed_provenance {
|
||||||
|
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
|
||||||
|
let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx());
|
||||||
|
|
||||||
|
require!(
|
||||||
|
in_len == out_len,
|
||||||
|
InvalidMonomorphization::ReturnLengthInputType {
|
||||||
|
span,
|
||||||
|
name,
|
||||||
|
in_len,
|
||||||
|
in_ty,
|
||||||
|
ret_ty,
|
||||||
|
out_len
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
match *in_elem.kind() {
|
||||||
|
ty::Uint(ty::UintTy::Usize) => {}
|
||||||
|
_ => return_error!(InvalidMonomorphization::ExpectedUsize { span, name, ty: in_elem }),
|
||||||
|
}
|
||||||
|
match *out_elem.kind() {
|
||||||
|
ty::RawPtr(_, _) => {}
|
||||||
|
_ => {
|
||||||
|
return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: out_elem })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let arg = args[0].immediate();
|
||||||
|
let elem_type = llret_ty.dyncast_vector().expect("vector return type").get_element_type();
|
||||||
|
let values: Vec<_> = (0..in_len)
|
||||||
|
.map(|i| {
|
||||||
|
let idx = bx.gcc_int(bx.usize_type, i as _);
|
||||||
|
let value = bx.extract_element(arg, idx);
|
||||||
|
bx.inttoptr(value, elem_type)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
return Ok(bx.context.new_rvalue_from_vector(bx.location, llret_ty, &values));
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "master")]
|
#[cfg(feature = "master")]
|
||||||
if name == sym::simd_cast || name == sym::simd_as {
|
if name == sym::simd_cast || name == sym::simd_as {
|
||||||
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
|
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
|
||||||
|
Loading…
Reference in New Issue
Block a user