Rustup to rustc 1.39.0-nightly (a6946a817
2019-09-13)
This commit is contained in:
parent
1558bf94e5
commit
6ea4cbdf1b
3 changed files with 69 additions and 73 deletions
|
@ -24,8 +24,10 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap<Local, Flags> {
|
||||||
for bb in fx.mir.basic_blocks().iter() {
|
for bb in fx.mir.basic_blocks().iter() {
|
||||||
for stmt in bb.statements.iter() {
|
for stmt in bb.statements.iter() {
|
||||||
match &stmt.kind {
|
match &stmt.kind {
|
||||||
Assign(_, rval) => match &**rval {
|
Assign(place_and_rval) => match &place_and_rval.1 {
|
||||||
Rvalue::Ref(_, _, place) => analyze_non_ssa_place(&mut flag_map, place),
|
Rvalue::Ref(_, _, place) => {
|
||||||
|
analyze_non_ssa_place(&mut flag_map, place);
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
134
src/base.rs
134
src/base.rs
|
@ -267,10 +267,10 @@ fn trans_stmt<'tcx>(
|
||||||
let place = trans_place(fx, place);
|
let place = trans_place(fx, place);
|
||||||
crate::discriminant::codegen_set_discriminant(fx, place, *variant_index);
|
crate::discriminant::codegen_set_discriminant(fx, place, *variant_index);
|
||||||
}
|
}
|
||||||
StatementKind::Assign(to_place, rval) => {
|
StatementKind::Assign(to_place_and_rval) => {
|
||||||
let lval = trans_place(fx, to_place);
|
let lval = trans_place(fx, &to_place_and_rval.0);
|
||||||
let dest_layout = lval.layout();
|
let dest_layout = lval.layout();
|
||||||
match &**rval {
|
match &to_place_and_rval.1 {
|
||||||
Rvalue::Use(operand) => {
|
Rvalue::Use(operand) => {
|
||||||
let val = trans_operand(fx, operand);
|
let val = trans_operand(fx, operand);
|
||||||
lval.write_cvalue(fx, val);
|
lval.write_cvalue(fx, val);
|
||||||
|
@ -506,7 +506,7 @@ fn trans_stmt<'tcx>(
|
||||||
to.write_cvalue(fx, operand);
|
to.write_cvalue(fx, operand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => unimpl!("shouldn't exist at trans {:?}", rval),
|
_ => unimpl!("shouldn't exist at trans {:?}", to_place_and_rval.1),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@ pub fn trans_place<'tcx>(
|
||||||
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
|
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
|
||||||
place: &Place<'tcx>,
|
place: &Place<'tcx>,
|
||||||
) -> CPlace<'tcx> {
|
) -> CPlace<'tcx> {
|
||||||
let base = match &place.base {
|
let mut cplace = match &place.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 => {
|
StaticKind::Static => {
|
||||||
|
@ -619,76 +619,70 @@ pub fn trans_place<'tcx>(
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
trans_place_projection(fx, base, &place.projection)
|
for elem in &*place.projection {
|
||||||
}
|
match *elem {
|
||||||
|
PlaceElem::Deref => {
|
||||||
|
cplace = cplace.place_deref(fx);
|
||||||
|
}
|
||||||
|
PlaceElem::Field(field, _ty) => {
|
||||||
|
cplace = cplace.place_field(fx, field);
|
||||||
|
}
|
||||||
|
PlaceElem::Index(local) => {
|
||||||
|
let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx);
|
||||||
|
cplace = cplace.place_index(fx, index);
|
||||||
|
}
|
||||||
|
PlaceElem::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, cplace);
|
||||||
|
fx.bcx.ins().iadd_imm(len, -(offset as i64))
|
||||||
|
};
|
||||||
|
cplace = cplace.place_index(fx, index);
|
||||||
|
}
|
||||||
|
PlaceElem::Subslice { from, to } => {
|
||||||
|
// These indices are generated by slice patterns.
|
||||||
|
// slice[from:-to] in Python terms.
|
||||||
|
|
||||||
pub fn trans_place_projection<'tcx>(
|
match cplace.layout().ty.sty {
|
||||||
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
|
ty::Array(elem_ty, len) => {
|
||||||
base: CPlace<'tcx>,
|
let elem_layout = fx.layout_of(elem_ty);
|
||||||
projection: &Option<Box<Projection<'tcx>>>,
|
let ptr = cplace.to_addr(fx);
|
||||||
) -> CPlace<'tcx> {
|
let len = crate::constant::force_eval_const(fx, len)
|
||||||
let projection = if let Some(projection) = projection {
|
.eval_usize(fx.tcx, ParamEnv::reveal_all());
|
||||||
projection
|
cplace = CPlace::for_addr(
|
||||||
} else {
|
fx.bcx
|
||||||
return base;
|
.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)),
|
||||||
let base = trans_place_projection(fx, base, &projection.base);
|
);
|
||||||
|
}
|
||||||
match projection.elem {
|
ty::Slice(elem_ty) => {
|
||||||
ProjectionElem::Deref => base.place_deref(fx),
|
let elem_layout = fx.layout_of(elem_ty);
|
||||||
ProjectionElem::Field(field, _ty) => base.place_field(fx, field),
|
let (ptr, len) = cplace.to_addr_maybe_unsized(fx);
|
||||||
ProjectionElem::Index(local) => {
|
let len = len.unwrap();
|
||||||
let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx);
|
cplace = CPlace::for_addr_with_extra(
|
||||||
base.place_index(fx, index)
|
fx.bcx
|
||||||
}
|
.ins()
|
||||||
ProjectionElem::ConstantIndex {
|
.iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
|
||||||
offset,
|
fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)),
|
||||||
min_length: _,
|
cplace.layout(),
|
||||||
from_end,
|
);
|
||||||
} => {
|
}
|
||||||
let index = if !from_end {
|
_ => unreachable!(),
|
||||||
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)
|
|
||||||
.eval_usize(fx.tcx, ParamEnv::reveal_all());
|
|
||||||
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)),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
ty::Slice(elem_ty) => {
|
}
|
||||||
let elem_layout = fx.layout_of(elem_ty);
|
PlaceElem::Downcast(_adt_def, variant) => {
|
||||||
let (ptr, len) = base.to_addr_maybe_unsized(fx);
|
cplace = cplace.downcast_variant(fx, variant);
|
||||||
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),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cplace
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trans_operand<'tcx>(
|
pub fn trans_operand<'tcx>(
|
||||||
|
|
|
@ -482,7 +482,7 @@ pub fn mir_operand_get_const_val<'tcx>(
|
||||||
Operand::Constant(const_) => return Some(force_eval_const(fx, const_.literal)),
|
Operand::Constant(const_) => return Some(force_eval_const(fx, const_.literal)),
|
||||||
};
|
};
|
||||||
|
|
||||||
assert!(place.projection.is_none());
|
assert!(place.projection.is_empty());
|
||||||
let static_ = match &place.base {
|
let static_ = match &place.base {
|
||||||
PlaceBase::Static(static_) => static_,
|
PlaceBase::Static(static_) => static_,
|
||||||
PlaceBase::Local(_) => return None,
|
PlaceBase::Local(_) => return None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue