Rustup to rustc 1.38.0-nightly (a7f28678b
2019-07-23)
This commit is contained in:
parent
853234006e
commit
92f2b6243d
@ -47,8 +47,8 @@ pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>) -> HashMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn analyze_non_ssa_place(flag_map: &mut HashMap<Local, Flags>, place: &Place) {
|
fn analyze_non_ssa_place(flag_map: &mut HashMap<Local, Flags>, place: &Place) {
|
||||||
match place {
|
match place.base {
|
||||||
Place::Base(PlaceBase::Local(local)) => not_ssa(flag_map, local),
|
PlaceBase::Local(local) => not_ssa(flag_map, local),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
128
src/base.rs
128
src/base.rs
@ -1148,70 +1148,82 @@ pub fn trans_place<'a, 'tcx: 'a>(
|
|||||||
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
||||||
place: &Place<'tcx>,
|
place: &Place<'tcx>,
|
||||||
) -> CPlace<'tcx> {
|
) -> CPlace<'tcx> {
|
||||||
match place {
|
let base = match &place.base {
|
||||||
Place::Base(base) => match base {
|
PlaceBase::Local(local) => fx.get_local_place(*local),
|
||||||
PlaceBase::Local(local) => fx.get_local_place(*local),
|
PlaceBase::Static(static_) => match static_.kind {
|
||||||
PlaceBase::Static(static_) => match static_.kind {
|
StaticKind::Static(def_id) => {
|
||||||
StaticKind::Static(def_id) => {
|
crate::constant::codegen_static_ref(fx, def_id, static_.ty)
|
||||||
crate::constant::codegen_static_ref(fx, def_id, static_.ty)
|
}
|
||||||
}
|
StaticKind::Promoted(promoted) => {
|
||||||
StaticKind::Promoted(promoted) => {
|
crate::constant::trans_promoted(fx, promoted, static_.ty)
|
||||||
crate::constant::trans_promoted(fx, promoted, static_.ty)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Place::Projection(projection) => {
|
};
|
||||||
let base = trans_place(fx, &projection.base);
|
|
||||||
match projection.elem {
|
|
||||||
ProjectionElem::Deref => base.place_deref(fx),
|
|
||||||
ProjectionElem::Field(field, _ty) => base.place_field(fx, field),
|
|
||||||
ProjectionElem::Index(local) => {
|
|
||||||
let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx);
|
|
||||||
base.place_index(fx, index)
|
|
||||||
}
|
|
||||||
ProjectionElem::ConstantIndex {
|
|
||||||
offset,
|
|
||||||
min_length: _,
|
|
||||||
from_end,
|
|
||||||
} => {
|
|
||||||
let index = if !from_end {
|
|
||||||
fx.bcx.ins().iconst(fx.pointer_type, offset as i64)
|
|
||||||
} else {
|
|
||||||
let len = codegen_array_len(fx, base);
|
|
||||||
fx.bcx.ins().iadd_imm(len, -(offset as i64))
|
|
||||||
};
|
|
||||||
base.place_index(fx, index)
|
|
||||||
}
|
|
||||||
ProjectionElem::Subslice { from, to } => {
|
|
||||||
// These indices are generated by slice patterns.
|
|
||||||
// slice[from:-to] in Python terms.
|
|
||||||
|
|
||||||
match base.layout().ty.sty {
|
trans_place_projection(fx, base, &place.projection)
|
||||||
ty::Array(elem_ty, len) => {
|
}
|
||||||
let elem_layout = fx.layout_of(elem_ty);
|
|
||||||
let ptr = base.to_addr(fx);
|
pub fn trans_place_projection<'a, 'tcx: 'a>(
|
||||||
let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx);
|
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
||||||
CPlace::for_addr(
|
base: CPlace<'tcx>,
|
||||||
fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
|
projection: &Option<Box<Projection<'tcx>>>,
|
||||||
fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)),
|
) -> CPlace<'tcx> {
|
||||||
)
|
let projection = if let Some(projection) = projection {
|
||||||
}
|
projection
|
||||||
ty::Slice(elem_ty) => {
|
} else {
|
||||||
let elem_layout = fx.layout_of(elem_ty);
|
return base;
|
||||||
let (ptr, len) = base.to_addr_maybe_unsized(fx);
|
};
|
||||||
let len = len.unwrap();
|
|
||||||
CPlace::for_addr_with_extra(
|
let base = trans_place_projection(fx, base, &projection.base);
|
||||||
fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
|
|
||||||
fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)),
|
match projection.elem {
|
||||||
base.layout(),
|
ProjectionElem::Deref => base.place_deref(fx),
|
||||||
)
|
ProjectionElem::Field(field, _ty) => base.place_field(fx, field),
|
||||||
}
|
ProjectionElem::Index(local) => {
|
||||||
_ => unreachable!(),
|
let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx);
|
||||||
}
|
base.place_index(fx, index)
|
||||||
|
}
|
||||||
|
ProjectionElem::ConstantIndex {
|
||||||
|
offset,
|
||||||
|
min_length: _,
|
||||||
|
from_end,
|
||||||
|
} => {
|
||||||
|
let index = if !from_end {
|
||||||
|
fx.bcx.ins().iconst(fx.pointer_type, offset as i64)
|
||||||
|
} else {
|
||||||
|
let len = codegen_array_len(fx, base);
|
||||||
|
fx.bcx.ins().iadd_imm(len, -(offset as i64))
|
||||||
|
};
|
||||||
|
base.place_index(fx, index)
|
||||||
|
}
|
||||||
|
ProjectionElem::Subslice { from, to } => {
|
||||||
|
// These indices are generated by slice patterns.
|
||||||
|
// slice[from:-to] in Python terms.
|
||||||
|
|
||||||
|
match base.layout().ty.sty {
|
||||||
|
ty::Array(elem_ty, len) => {
|
||||||
|
let elem_layout = fx.layout_of(elem_ty);
|
||||||
|
let ptr = base.to_addr(fx);
|
||||||
|
let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx);
|
||||||
|
CPlace::for_addr(
|
||||||
|
fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
|
||||||
|
fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ProjectionElem::Downcast(_adt_def, variant) => base.downcast_variant(fx, variant),
|
ty::Slice(elem_ty) => {
|
||||||
|
let elem_layout = fx.layout_of(elem_ty);
|
||||||
|
let (ptr, len) = base.to_addr_maybe_unsized(fx);
|
||||||
|
let len = len.unwrap();
|
||||||
|
CPlace::for_addr_with_extra(
|
||||||
|
fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
|
||||||
|
fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)),
|
||||||
|
base.layout(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ProjectionElem::Downcast(_adt_def, variant) => base.downcast_variant(fx, variant),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user