rustc: Remove platform intrinsics crate
This was originally attempted in #57048 but it was realized that we could fully remove the crate via the `"unadjusted"` ABI on intrinsics. This means that all intrinsics in stdsimd are implemented directly against LLVM rather than using the abstraction layer provided here. That ends up meaning that this crate is no longer used at all. This crate developed long ago to implement the SIMD intrinsics, but we didn't end up using it in the long run. In that case let's remove it!
This commit is contained in:
parent
d10680818b
commit
7616daabc7
57 changed files with 4 additions and 15991 deletions
|
|
@ -1,7 +1,6 @@
|
|||
#![allow(non_upper_case_globals)]
|
||||
|
||||
use attributes;
|
||||
use intrinsics::{self, Intrinsic};
|
||||
use llvm;
|
||||
use llvm_util;
|
||||
use abi::{Abi, FnType, LlvmType, PassMode};
|
||||
|
|
@ -658,142 +657,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
_ => {
|
||||
let intr = match Intrinsic::find(&name) {
|
||||
Some(intr) => intr,
|
||||
None => bug!("unknown intrinsic '{}'", name),
|
||||
};
|
||||
fn one<T>(x: Vec<T>) -> T {
|
||||
assert_eq!(x.len(), 1);
|
||||
x.into_iter().next().unwrap()
|
||||
}
|
||||
fn ty_to_type<'ll>(
|
||||
cx: &CodegenCx<'ll, '_>,
|
||||
t: &intrinsics::Type
|
||||
) -> Vec<&'ll Type> {
|
||||
use intrinsics::Type::*;
|
||||
match *t {
|
||||
Void => vec![cx.type_void()],
|
||||
Integer(_signed, _width, llvm_width) => {
|
||||
vec![cx.type_ix( llvm_width as u64)]
|
||||
}
|
||||
Float(x) => {
|
||||
match x {
|
||||
32 => vec![cx.type_f32()],
|
||||
64 => vec![cx.type_f64()],
|
||||
_ => bug!()
|
||||
}
|
||||
}
|
||||
Pointer(ref t, ref llvm_elem, _const) => {
|
||||
let t = llvm_elem.as_ref().unwrap_or(t);
|
||||
let elem = one(ty_to_type(cx, t));
|
||||
vec![cx.type_ptr_to(elem)]
|
||||
}
|
||||
Vector(ref t, ref llvm_elem, length) => {
|
||||
let t = llvm_elem.as_ref().unwrap_or(t);
|
||||
let elem = one(ty_to_type(cx, t));
|
||||
vec![cx.type_vector(elem, length as u64)]
|
||||
}
|
||||
Aggregate(false, ref contents) => {
|
||||
let elems = contents.iter()
|
||||
.map(|t| one(ty_to_type(cx, t)))
|
||||
.collect::<Vec<_>>();
|
||||
vec![cx.type_struct( &elems, false)]
|
||||
}
|
||||
Aggregate(true, ref contents) => {
|
||||
contents.iter()
|
||||
.flat_map(|t| ty_to_type(cx, t))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This allows an argument list like `foo, (bar, baz),
|
||||
// qux` to be converted into `foo, bar, baz, qux`, integer
|
||||
// arguments to be truncated as needed and pointers to be
|
||||
// cast.
|
||||
fn modify_as_needed<'ll, 'tcx>(
|
||||
bx: &mut Builder<'_, 'll, 'tcx>,
|
||||
t: &intrinsics::Type,
|
||||
arg: &OperandRef<'tcx, &'ll Value>,
|
||||
) -> Vec<&'ll Value> {
|
||||
match *t {
|
||||
intrinsics::Type::Aggregate(true, ref contents) => {
|
||||
// We found a tuple that needs squishing! So
|
||||
// run over the tuple and load each field.
|
||||
//
|
||||
// This assumes the type is "simple", i.e., no
|
||||
// destructors, and the contents are SIMD
|
||||
// etc.
|
||||
assert!(!bx.type_needs_drop(arg.layout.ty));
|
||||
let (ptr, align) = match arg.val {
|
||||
OperandValue::Ref(ptr, None, align) => (ptr, align),
|
||||
_ => bug!()
|
||||
};
|
||||
let arg = PlaceRef::new_sized(ptr, arg.layout, align);
|
||||
(0..contents.len()).map(|i| {
|
||||
let field = arg.project_field(bx, i);
|
||||
bx.load_operand(field).immediate()
|
||||
}).collect()
|
||||
}
|
||||
intrinsics::Type::Pointer(_, Some(ref llvm_elem), _) => {
|
||||
let llvm_elem = one(ty_to_type(bx, llvm_elem));
|
||||
vec![bx.pointercast(arg.immediate(), bx.type_ptr_to(llvm_elem))]
|
||||
}
|
||||
intrinsics::Type::Vector(_, Some(ref llvm_elem), length) => {
|
||||
let llvm_elem = one(ty_to_type(bx, llvm_elem));
|
||||
vec![
|
||||
bx.bitcast(arg.immediate(),
|
||||
bx.type_vector(llvm_elem, length as u64))
|
||||
]
|
||||
}
|
||||
intrinsics::Type::Integer(_, width, llvm_width) if width != llvm_width => {
|
||||
// the LLVM intrinsic uses a smaller integer
|
||||
// size than the C intrinsic's signature, so
|
||||
// we have to trim it down here.
|
||||
vec![bx.trunc(arg.immediate(), bx.type_ix(llvm_width as u64))]
|
||||
}
|
||||
_ => vec![arg.immediate()],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let inputs = intr.inputs.iter()
|
||||
.flat_map(|t| ty_to_type(self, t))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let outputs = one(ty_to_type(self, &intr.output));
|
||||
|
||||
let llargs: Vec<_> = intr.inputs.iter().zip(args).flat_map(|(t, arg)| {
|
||||
modify_as_needed(self, t, arg)
|
||||
}).collect();
|
||||
assert_eq!(inputs.len(), llargs.len());
|
||||
|
||||
let val = match intr.definition {
|
||||
intrinsics::IntrinsicDef::Named(name) => {
|
||||
let f = self.declare_cfn(
|
||||
name,
|
||||
self.type_func(&inputs, outputs),
|
||||
);
|
||||
self.call(f, &llargs, None)
|
||||
}
|
||||
};
|
||||
|
||||
match *intr.output {
|
||||
intrinsics::Type::Aggregate(flatten, ref elems) => {
|
||||
// the output is a tuple so we need to munge it properly
|
||||
assert!(!flatten);
|
||||
|
||||
for i in 0..elems.len() {
|
||||
let dest = result.project_field(self, i);
|
||||
let val = self.extract_value(val, i as u64);
|
||||
self.store(val, dest.llval, dest.align);
|
||||
}
|
||||
return;
|
||||
}
|
||||
_ => val,
|
||||
}
|
||||
}
|
||||
_ => bug!("unknown intrinsic '{}'", name),
|
||||
};
|
||||
|
||||
if !fn_ty.ret.is_ignore() {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ extern crate rustc_target;
|
|||
extern crate rustc_demangle;
|
||||
extern crate rustc_incremental;
|
||||
extern crate rustc_llvm;
|
||||
extern crate rustc_platform_intrinsics as intrinsics;
|
||||
extern crate rustc_codegen_utils;
|
||||
extern crate rustc_codegen_ssa;
|
||||
extern crate rustc_fs_util;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue