Struct rustc_mir::transform::const_prop::ConstPropagator [−][src]
struct ConstPropagator<'mir, 'tcx> {
ecx: InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>,
tcx: TyCtxt<'tcx>,
param_env: ParamEnv<'tcx>,
source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
local_decls: IndexVec<Local, LocalDecl<'tcx>>,
source_info: Option<SourceInfo>,
}Expand description
Finds optimization opportunities on the MIR.
Fields
ecx: InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>tcx: TyCtxt<'tcx>param_env: ParamEnv<'tcx>source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>local_decls: IndexVec<Local, LocalDecl<'tcx>>source_info: Option<SourceInfo>Implementations
fn new(
body: &Body<'tcx>,
dummy_body: &'mir Body<'tcx>,
tcx: TyCtxt<'tcx>
) -> ConstPropagator<'mir, 'tcx>
Remove local from the pool of Locals. Allows writing to them,
but not reading from them anymore.
fn use_ecx<F, T>(&mut self, f: F) -> Option<T> where
F: FnOnce(&mut Self) -> InterpResult<'tcx, T>,
fn eval_constant(
&mut self,
c: &Constant<'tcx>,
source_info: SourceInfo
) -> Option<OpTy<'tcx>>
fn eval_constant(
&mut self,
c: &Constant<'tcx>,
source_info: SourceInfo
) -> Option<OpTy<'tcx>>
Returns the value, if any, of evaluating c.
Returns the value, if any, of evaluating place.
Returns the value, if any, of evaluating op. Calls upon eval_constant
or eval_place, depending on the variant of Operand used.
fn report_assert_as_lint(
&self,
lint: &'static Lint,
source_info: SourceInfo,
message: &'static str,
panic: AssertKind<impl Debug>
)
fn check_unary_op(
&mut self,
op: UnOp,
arg: &Operand<'tcx>,
source_info: SourceInfo
) -> Option<()>
fn check_binary_op(
&mut self,
op: BinOp,
left: &Operand<'tcx>,
right: &Operand<'tcx>,
source_info: SourceInfo
) -> Option<()>
fn const_prop(
&mut self,
rvalue: &Rvalue<'tcx>,
source_info: SourceInfo,
place: Place<'tcx>
) -> Option<()>
fn eval_rvalue_with_identities(
&mut self,
rvalue: &Rvalue<'tcx>,
place: Place<'tcx>
) -> Option<()>
Creates a new Operand::Constant from a Scalar value
fn replace_with_const(
&mut self,
rval: &mut Rvalue<'tcx>,
value: &OpTy<'tcx>,
source_info: SourceInfo
)
Returns true if and only if this op should be const-propagated into.
Trait Implementations
type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>
fn visit_assign(
&mut self,
place: &mut Place<'tcx>,
rvalue: &mut Rvalue<'tcx>,
location: Location
)
fn visit_ascribe_user_ty(
&mut self,
place: &mut Place<'tcx>,
variance: &mut Variance,
user_ty: &mut UserTypeProjection,
location: Location
)
fn process_projection(
&mut self,
projection: &'a [ProjectionElem<Local, &'tcx TyS<'tcx>>],
location: Location
) -> Option<Vec<ProjectionElem<Local, &'tcx TyS<'tcx>>, Global>>
fn process_projection_elem(
&mut self,
elem: ProjectionElem<Local, &'tcx TyS<'tcx>>,
location: Location
) -> Option<ProjectionElem<Local, &'tcx TyS<'tcx>>>
fn visit_user_type_annotation(
&mut self,
index: UserTypeAnnotationIndex,
ty: &mut CanonicalUserTypeAnnotation<'tcx>
)
fn super_assign(
&mut self,
place: &mut Place<'tcx>,
rvalue: &mut Rvalue<'tcx>,
location: Location
)
fn super_ascribe_user_ty(
&mut self,
place: &mut Place<'tcx>,
_variance: &mut Variance,
user_ty: &mut UserTypeProjection,
location: Location
)
fn super_user_type_annotation(
&mut self,
_index: UserTypeAnnotationIndex,
ty: &mut CanonicalUserTypeAnnotation<'tcx>
)
Auto Trait Implementations
impl<'mir, 'tcx> !RefUnwindSafe for ConstPropagator<'mir, 'tcx>
impl<'mir, 'tcx> !Send for ConstPropagator<'mir, 'tcx>
impl<'mir, 'tcx> !Sync for ConstPropagator<'mir, 'tcx>
impl<'mir, 'tcx> Unpin for ConstPropagator<'mir, 'tcx> where
'tcx: 'mir,
impl<'mir, 'tcx> !UnwindSafe for ConstPropagator<'mir, 'tcx>
Blanket Implementations
Mutably borrows from an owned value. Read more
Helper function: truncate given value-“overflowed flag” pair to pointer size and update “overflowed flag” if there was an overflow. This should be called by all the other methods before returning! Read more
Layout
Note: Most layout information is completely unstable and may be different between compiler versions and platforms. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 328 bytes