rustup update

This commit is contained in:
khyperia 2020-09-07 10:54:53 +02:00
parent 8342b34c07
commit 3bfc0289d6
3 changed files with 28 additions and 13 deletions

View File

@ -394,7 +394,7 @@ fn dig_scalar_pointee<'spv, 'tcx>(
ty: TyAndLayout<'tcx>,
index: Option<usize>,
) -> PointeeTy<'tcx> {
match ty.ty.kind {
match *ty.ty.kind() {
TyKind::Ref(_region, elem_ty, _mutability) => {
let elem = cx.layout_of(elem_ty);
match index {
@ -544,7 +544,7 @@ pub fn auto_struct_layout<'spv, 'tcx>(
// see struct_llfields in librustc_codegen_llvm for implementation hints
fn trans_struct<'spv, 'tcx>(cx: &CodegenCx<'spv, 'tcx>, ty: TyAndLayout<'tcx>) -> Word {
let name = name_of_struct(ty);
if let TyKind::Foreign(_) = ty.ty.kind {
if let TyKind::Foreign(_) = ty.ty.kind() {
// "An unsized FFI type that is opaque to Rust"
return SpirvType::Opaque { name }.def(cx);
};
@ -559,14 +559,14 @@ fn trans_struct<'spv, 'tcx>(cx: &CodegenCx<'spv, 'tcx>, ty: TyAndLayout<'tcx>) -
let offset = ty.fields.offset(i);
field_offsets.push(offset);
if let Variants::Single { index } = ty.variants {
if let TyKind::Adt(adt, _) = ty.ty.kind {
if let TyKind::Adt(adt, _) = ty.ty.kind() {
let field = &adt.variants[index].fields[i];
field_names.push(field.ident.name.to_ident_string());
} else {
field_names.push(format!("{}", i));
}
} else {
if let TyKind::Adt(_, _) = ty.ty.kind {
if let TyKind::Adt(_, _) = ty.ty.kind() {
} else {
panic!("Variants::Multiple not supported for non-TyKind::Adt");
}
@ -590,12 +590,12 @@ fn trans_struct<'spv, 'tcx>(cx: &CodegenCx<'spv, 'tcx>, ty: TyAndLayout<'tcx>) -
fn name_of_struct(ty: TyAndLayout<'_>) -> String {
let mut name = ty.ty.to_string();
if let (&TyKind::Adt(def, _), &Variants::Single { index }) = (&ty.ty.kind, &ty.variants) {
if let (&TyKind::Adt(def, _), &Variants::Single { index }) = (ty.ty.kind(), &ty.variants) {
if def.is_enum() && !def.variants.is_empty() {
write!(&mut name, "::{}", def.variants[index].ident).unwrap();
}
}
if let (&TyKind::Generator(_, _, _), &Variants::Single { index }) = (&ty.ty.kind, &ty.variants)
if let (&TyKind::Generator(_, _, _), &Variants::Single { index }) = (ty.ty.kind(), &ty.variants)
{
write!(&mut name, "::{}", GeneratorSubsts::variant_name(index)).unwrap();
}

View File

@ -3,7 +3,6 @@ use crate::builder_spirv::{BuilderCursor, SpirvValueExt};
use crate::spirv_type::SpirvType;
use rspirv::dr::Operand;
use rspirv::spirv::StorageClass;
use rustc_codegen_ssa::base::to_immediate;
use rustc_codegen_ssa::common::{
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope,
};
@ -287,6 +286,23 @@ impl<'a, 'spv, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'spv, 'tcx> {
}
}
fn from_immediate(&mut self, val: Self::Value) -> Self::Value {
if self.lookup_type(val.ty) == SpirvType::Bool {
let i8 = SpirvType::Integer(8, false).def(self);
self.zext(val, i8)
} else {
val
}
}
fn to_immediate_scalar(&mut self, val: Self::Value, scalar: &Scalar) -> Self::Value {
if scalar.is_bool() {
let bool = SpirvType::Bool.def(self);
return self.trunc(val, bool);
}
val
}
fn alloca(&mut self, ty: Self::Type, _align: Align) -> Self::Value {
let ptr_ty = SpirvType::Pointer {
storage_class: StorageClass::Generic,
@ -346,7 +362,7 @@ impl<'a, 'spv, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'spv, 'tcx> {
OperandValue::Ref(place.llval, Some(llextra), place.align)
} else if self.cx.is_backend_immediate(place.layout) {
let llval = self.load(place.llval, place.align);
OperandValue::Immediate(to_immediate(self, llval, place.layout))
OperandValue::Immediate(self.to_immediate(llval, place.layout))
} else if let Abi::ScalarPair(ref a, ref b) = place.layout.abi {
let b_offset = a.value.size(self).align_to(b.value.align(self).abi);

View File

@ -6,7 +6,6 @@ use crate::codegen_cx::CodegenCx;
use crate::spirv_type::SpirvType;
use rspirv::spirv::StorageClass;
use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_codegen_ssa::base::to_immediate;
use rustc_codegen_ssa::common::IntPredicate;
use rustc_codegen_ssa::glue;
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
@ -34,7 +33,7 @@ use std::ops::Deref;
macro_rules! math_intrinsic {
($self:ident, $arg_tys:ident, $args:ident, $int:ident, $uint:ident, $float:ident) => {{
assert_eq!($arg_tys[0], $arg_tys[1]);
match &$arg_tys[0].kind {
match &$arg_tys[0].kind() {
TyKind::Int(_) => $self.$int($args[0].immediate(), $args[1].immediate()),
TyKind::Uint(_) => $self.$uint($args[0].immediate(), $args[1].immediate()),
TyKind::Float(_) => $self.$float($args[0].immediate(), $args[1].immediate()),
@ -45,7 +44,7 @@ macro_rules! math_intrinsic {
macro_rules! math_intrinsic_int {
($self:ident, $arg_tys:ident, $args:ident, $int:ident, $uint:ident) => {{
assert_eq!($arg_tys[0], $arg_tys[1]);
match &$arg_tys[0].kind {
match &$arg_tys[0].kind() {
TyKind::Int(_) => $self.$int($args[0].immediate(), $args[1].immediate()),
TyKind::Uint(_) => $self.$uint($args[0].immediate(), $args[1].immediate()),
other => panic!("Unimplemented intrinsic type: {:#?}", other),
@ -333,7 +332,7 @@ impl<'a, 'spv, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'spv, 'tcx> {
) {
let callee_ty = instance.ty(self.tcx, ParamEnv::reveal_all());
let (def_id, substs) = match callee_ty.kind {
let (def_id, substs) = match *callee_ty.kind() {
FnDef(def_id, substs) => (def_id, substs),
_ => panic!("expected fn item type, found {}", callee_ty),
};
@ -417,7 +416,7 @@ impl<'a, 'spv, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'spv, 'tcx> {
ptr = self.pointercast(ptr, self.type_ptr_to(ty.spirv_type(self)));
}
let load = self.volatile_load(ptr);
to_immediate(self, load, self.layout_of(tp_ty))
self.to_immediate(load, self.layout_of(tp_ty))
}
sym::volatile_store => {
// rust-analyzer gets sad if you call args[0].deref()