Skip to content

Commit dd630a2

Browse files
committed
Rename lvalue to place
1 parent bf26b96 commit dd630a2

File tree

5 files changed

+49
-49
lines changed

5 files changed

+49
-49
lines changed

miri/fn_call.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub trait EvalContextExt<'tcx> {
2121
&mut self,
2222
def_id: DefId,
2323
args: &[ValTy<'tcx>],
24-
dest: Lvalue,
24+
dest: Place,
2525
dest_ty: Ty<'tcx>,
2626
dest_block: mir::BasicBlock,
2727
) -> EvalResult<'tcx>;
@@ -31,7 +31,7 @@ pub trait EvalContextExt<'tcx> {
3131
fn call_missing_fn(
3232
&mut self,
3333
instance: ty::Instance<'tcx>,
34-
destination: Option<(Lvalue, mir::BasicBlock)>,
34+
destination: Option<(Place, mir::BasicBlock)>,
3535
args: &[ValTy<'tcx>],
3636
sig: ty::FnSig<'tcx>,
3737
path: String,
@@ -40,20 +40,20 @@ pub trait EvalContextExt<'tcx> {
4040
fn eval_fn_call(
4141
&mut self,
4242
instance: ty::Instance<'tcx>,
43-
destination: Option<(Lvalue, mir::BasicBlock)>,
43+
destination: Option<(Place, mir::BasicBlock)>,
4444
args: &[ValTy<'tcx>],
4545
span: Span,
4646
sig: ty::FnSig<'tcx>,
4747
) -> EvalResult<'tcx, bool>;
4848

49-
fn write_null(&mut self, dest: Lvalue, dest_ty: Ty<'tcx>) -> EvalResult<'tcx>;
49+
fn write_null(&mut self, dest: Place, dest_ty: Ty<'tcx>) -> EvalResult<'tcx>;
5050
}
5151

5252
impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator> {
5353
fn eval_fn_call(
5454
&mut self,
5555
instance: ty::Instance<'tcx>,
56-
destination: Option<(Lvalue, mir::BasicBlock)>,
56+
destination: Option<(Place, mir::BasicBlock)>,
5757
args: &[ValTy<'tcx>],
5858
span: Span,
5959
sig: ty::FnSig<'tcx>,
@@ -75,16 +75,16 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
7575
Err(other) => return Err(other),
7676
};
7777

78-
let (return_lvalue, return_to_block) = match destination {
79-
Some((lvalue, block)) => (lvalue, StackPopCleanup::Goto(block)),
80-
None => (Lvalue::undef(), StackPopCleanup::None),
78+
let (return_place, return_to_block) = match destination {
79+
Some((place, block)) => (place, StackPopCleanup::Goto(block)),
80+
None => (Place::undef(), StackPopCleanup::None),
8181
};
8282

8383
self.push_stack_frame(
8484
instance,
8585
span,
8686
mir,
87-
return_lvalue,
87+
return_place,
8888
return_to_block,
8989
)?;
9090

@@ -95,7 +95,7 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
9595
&mut self,
9696
def_id: DefId,
9797
args: &[ValTy<'tcx>],
98-
dest: Lvalue,
98+
dest: Place,
9999
dest_ty: Ty<'tcx>,
100100
dest_block: mir::BasicBlock,
101101
) -> EvalResult<'tcx> {
@@ -176,7 +176,7 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
176176
f_instance,
177177
mir.span,
178178
mir,
179-
Lvalue::undef(),
179+
Place::undef(),
180180
StackPopCleanup::Goto(dest_block),
181181
)?;
182182
let mut args = self.frame().mir.args_iter();
@@ -187,7 +187,7 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
187187
.to_owned(),
188188
),
189189
)?;
190-
let arg_dest = self.eval_lvalue(&mir::Place::Local(arg_local))?;
190+
let arg_dest = self.eval_place(&mir::Place::Local(arg_local))?;
191191
self.write_ptr(arg_dest, data, u8_ptr_ty)?;
192192

193193
assert!(args.next().is_none(), "__rust_maybe_catch_panic argument has more arguments than expected");
@@ -416,7 +416,7 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
416416
};
417417

418418
// Figure out how large a pthread TLS key actually is. This is libc::pthread_key_t.
419-
let key_type = args[0].ty.builtin_deref(true, ty::LvaluePreference::NoPreference)
419+
let key_type = args[0].ty.builtin_deref(true, ty::PlacePreference::NoPreference)
420420
.ok_or(EvalErrorKind::AbiViolation("Wrong signature used for pthread_key_create: First argument must be a raw pointer.".to_owned()))?.ty;
421421
let key_size = self.type_layout(key_type)?.size;
422422

@@ -516,7 +516,7 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
516516
fn call_missing_fn(
517517
&mut self,
518518
instance: ty::Instance<'tcx>,
519-
destination: Option<(Lvalue, mir::BasicBlock)>,
519+
destination: Option<(Place, mir::BasicBlock)>,
520520
args: &[ValTy<'tcx>],
521521
sig: ty::FnSig<'tcx>,
522522
path: String,
@@ -655,7 +655,7 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
655655
return Ok(());
656656
}
657657

658-
fn write_null(&mut self, dest: Lvalue, dest_ty: Ty<'tcx>) -> EvalResult<'tcx> {
658+
fn write_null(&mut self, dest: Place, dest_ty: Ty<'tcx>) -> EvalResult<'tcx> {
659659
self.write_primval(dest, PrimVal::Bytes(0), dest_ty)
660660
}
661661
}

miri/intrinsic.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc::traits::Reveal;
33
use rustc::ty::layout::TyLayout;
44
use rustc::ty;
55

6-
use rustc::mir::interpret::{EvalResult, Lvalue, LvalueExtra, PrimVal, PrimValKind, Value, Pointer,
6+
use rustc::mir::interpret::{EvalResult, Place, PlaceExtra, PrimVal, PrimValKind, Value, Pointer,
77
HasMemory, AccessKind, EvalContext, PtrAndAlign, ValTy};
88

99
use helpers::EvalContextExt as HelperEvalContextExt;
@@ -13,7 +13,7 @@ pub trait EvalContextExt<'tcx> {
1313
&mut self,
1414
instance: ty::Instance<'tcx>,
1515
args: &[ValTy<'tcx>],
16-
dest: Lvalue,
16+
dest: Place,
1717
dest_layout: TyLayout<'tcx>,
1818
target: mir::BasicBlock,
1919
) -> EvalResult<'tcx>;
@@ -24,7 +24,7 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
2424
&mut self,
2525
instance: ty::Instance<'tcx>,
2626
args: &[ValTy<'tcx>],
27-
dest: Lvalue,
27+
dest: Place,
2828
dest_layout: TyLayout<'tcx>,
2929
target: mir::BasicBlock,
3030
) -> EvalResult<'tcx> {
@@ -119,7 +119,7 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
119119
};
120120
self.write_primval(dest, old, ty)?;
121121
self.write_primval(
122-
Lvalue::from_primval_ptr(ptr),
122+
Place::from_primval_ptr(ptr),
123123
change,
124124
ty,
125125
)?;
@@ -143,7 +143,7 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
143143
};
144144
self.write_value(valty, dest)?;
145145
self.write_primval(
146-
Lvalue::from_primval_ptr(ptr),
146+
Place::from_primval_ptr(ptr),
147147
change,
148148
ty,
149149
)?;
@@ -196,7 +196,7 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
196196
};
197197
// FIXME: what do atomics do on overflow?
198198
let (val, _) = self.binary_op(op, old, ty, change, ty)?;
199-
self.write_primval(Lvalue::from_primval_ptr(ptr), val, ty)?;
199+
self.write_primval(Place::from_primval_ptr(ptr), val, ty)?;
200200
}
201201

202202
"breakpoint" => unimplemented!(), // halt miri
@@ -240,8 +240,8 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
240240
"discriminant_value" => {
241241
let ty = substs.type_at(0);
242242
let adt_ptr = args[0].into_ptr(&self.memory)?;
243-
let lval = Lvalue::from_primval_ptr(adt_ptr);
244-
let discr_val = self.read_discriminant_value(lval, ty)?;
243+
let place = Place::from_primval_ptr(adt_ptr);
244+
let discr_val = self.read_discriminant_value(place, ty)?;
245245
self.write_primval(dest, PrimVal::Bytes(discr_val), dest_layout.ty)?;
246246
}
247247

@@ -336,12 +336,12 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
336336
Ok(zero_val)
337337
};
338338
match dest {
339-
Lvalue::Local { frame, local } => self.modify_local(frame, local, init)?,
340-
Lvalue::Ptr {
339+
Place::Local { frame, local } => self.modify_local(frame, local, init)?,
340+
Place::Ptr {
341341
ptr: PtrAndAlign { ptr, aligned: true },
342-
extra: LvalueExtra::None,
342+
extra: PlaceExtra::None,
343343
} => self.memory.write_repeat(ptr, 0, size)?,
344-
Lvalue::Ptr { .. } => {
344+
Place::Ptr { .. } => {
345345
bug!("init intrinsic tried to write to fat or unaligned ptr target")
346346
}
347347
}
@@ -623,12 +623,12 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
623623
_ => Ok(Value::ByVal(PrimVal::Undef)),
624624
};
625625
match dest {
626-
Lvalue::Local { frame, local } => self.modify_local(frame, local, uninit)?,
627-
Lvalue::Ptr {
626+
Place::Local { frame, local } => self.modify_local(frame, local, uninit)?,
627+
Place::Ptr {
628628
ptr: PtrAndAlign { ptr, aligned: true },
629-
extra: LvalueExtra::None,
629+
extra: PlaceExtra::None,
630630
} => self.memory.mark_definedness(ptr, size, false)?,
631-
Lvalue::Ptr { .. } => {
631+
Place::Ptr { .. } => {
632632
bug!("uninit intrinsic tried to write to fat or unaligned ptr target")
633633
}
634634
}

miri/lib.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ pub fn eval_main<'a, 'tcx: 'a>(
7979
start_instance,
8080
start_mir.span,
8181
start_mir,
82-
Lvalue::from_ptr(ret_ptr),
82+
Place::from_ptr(ret_ptr),
8383
StackPopCleanup::None,
8484
)?;
8585

8686
let mut args = ecx.frame().mir.args_iter();
8787

8888
// First argument: pointer to main()
8989
let main_ptr = ecx.memory_mut().create_fn_alloc(main_instance);
90-
let dest = ecx.eval_lvalue(&mir::Place::Local(args.next().unwrap()))?;
90+
let dest = ecx.eval_place(&mir::Place::Local(args.next().unwrap()))?;
9191
let main_ty = main_instance.def.def_ty(ecx.tcx);
9292
let main_ptr_ty = ecx.tcx.mk_fn_ptr(main_ty.fn_sig(ecx.tcx));
9393
ecx.write_value(
@@ -99,13 +99,13 @@ pub fn eval_main<'a, 'tcx: 'a>(
9999
)?;
100100

101101
// Second argument (argc): 1
102-
let dest = ecx.eval_lvalue(&mir::Place::Local(args.next().unwrap()))?;
102+
let dest = ecx.eval_place(&mir::Place::Local(args.next().unwrap()))?;
103103
let ty = ecx.tcx.types.isize;
104104
ecx.write_primval(dest, PrimVal::Bytes(1), ty)?;
105105

106106
// FIXME: extract main source file path
107107
// Third argument (argv): &[b"foo"]
108-
let dest = ecx.eval_lvalue(&mir::Place::Local(args.next().unwrap()))?;
108+
let dest = ecx.eval_place(&mir::Place::Local(args.next().unwrap()))?;
109109
let ty = ecx.tcx.mk_imm_ptr(ecx.tcx.mk_imm_ptr(ecx.tcx.types.u8));
110110
let foo = ecx.memory.allocate_cached(b"foo\0");
111111
let ptr_size = ecx.memory.pointer_size();
@@ -120,7 +120,7 @@ pub fn eval_main<'a, 'tcx: 'a>(
120120
main_instance,
121121
main_mir.span,
122122
main_mir,
123-
Lvalue::undef(),
123+
Place::undef(),
124124
StackPopCleanup::None,
125125
)?;
126126

@@ -195,7 +195,7 @@ impl<'tcx> Machine<'tcx> for Evaluator {
195195
fn eval_fn_call<'a>(
196196
ecx: &mut EvalContext<'a, 'tcx, Self>,
197197
instance: ty::Instance<'tcx>,
198-
destination: Option<(Lvalue, mir::BasicBlock)>,
198+
destination: Option<(Place, mir::BasicBlock)>,
199199
args: &[ValTy<'tcx>],
200200
span: Span,
201201
sig: ty::FnSig<'tcx>,
@@ -207,7 +207,7 @@ impl<'tcx> Machine<'tcx> for Evaluator {
207207
ecx: &mut rustc::mir::interpret::EvalContext<'a, 'tcx, Self>,
208208
instance: ty::Instance<'tcx>,
209209
args: &[ValTy<'tcx>],
210-
dest: Lvalue,
210+
dest: Place,
211211
dest_layout: TyLayout<'tcx>,
212212
target: mir::BasicBlock,
213213
) -> EvalResult<'tcx> {
@@ -237,7 +237,7 @@ impl<'tcx> Machine<'tcx> for Evaluator {
237237
fn box_alloc<'a>(
238238
ecx: &mut EvalContext<'a, 'tcx, Self>,
239239
ty: ty::Ty<'tcx>,
240-
dest: Lvalue,
240+
dest: Place,
241241
) -> EvalResult<'tcx> {
242242
let size = ecx.type_size(ty)?.expect("box only works with sized types");
243243
let align = ecx.type_align(ty)?;
@@ -261,7 +261,7 @@ impl<'tcx> Machine<'tcx> for Evaluator {
261261
let usize = ecx.tcx.types.usize;
262262

263263
// First argument: size
264-
let dest = ecx.eval_lvalue(&mir::Place::Local(args.next().unwrap()))?;
264+
let dest = ecx.eval_place(&mir::Place::Local(args.next().unwrap()))?;
265265
ecx.write_value(
266266
ValTy {
267267
value: Value::ByVal(PrimVal::Bytes(size as u128)),
@@ -271,7 +271,7 @@ impl<'tcx> Machine<'tcx> for Evaluator {
271271
)?;
272272

273273
// Second argument: align
274-
let dest = ecx.eval_lvalue(&mir::Place::Local(args.next().unwrap()))?;
274+
let dest = ecx.eval_place(&mir::Place::Local(args.next().unwrap()))?;
275275
ecx.write_value(
276276
ValTy {
277277
value: Value::ByVal(PrimVal::Bytes(align as u128)),

miri/tls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc::{ty, mir};
22

3-
use super::{TlsKey, TlsEntry, EvalResult, EvalErrorKind, Pointer, Memory, Evaluator, Lvalue,
3+
use super::{TlsKey, TlsEntry, EvalResult, EvalErrorKind, Pointer, Memory, Evaluator, Place,
44
StackPopCleanup, EvalContext};
55

66
pub trait MemoryExt<'tcx> {
@@ -119,13 +119,13 @@ impl<'a, 'tcx: 'a> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, Evaluator> {
119119
instance,
120120
mir.span,
121121
mir,
122-
Lvalue::undef(),
122+
Place::undef(),
123123
StackPopCleanup::None,
124124
)?;
125125
let arg_local = self.frame().mir.args_iter().next().ok_or(
126126
EvalErrorKind::AbiViolation("TLS dtor does not take enough arguments.".to_owned()),
127127
)?;
128-
let dest = self.eval_lvalue(&mir::Place::Local(arg_local))?;
128+
let dest = self.eval_place(&mir::Place::Local(arg_local))?;
129129
let ty = self.tcx.mk_mut_ptr(self.tcx.types.u8);
130130
self.write_ptr(dest, ptr, ty)?;
131131

tex/report/miri-report.tex

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ \section{Background}
5252
The Rust compiler generates an instance of \rust{Mir} for each function [\autoref{fig:mir}]. Each
5353
\rust{Mir} structure represents a control-flow graph for a given function, and contains a list of
5454
``basic blocks'' which in turn contain a list of statements followed by a single terminator. Each
55-
statement is of the form \rust{lvalue = rvalue}. An \rust{Lvalue} is used for referencing variables
55+
statement is of the form \rust{place = rvalue}. An \rust{Place} is used for referencing variables
5656
and calculating addresses such as when dereferencing pointers, accessing fields, or indexing arrays.
5757
An \rust{Rvalue} represents the core set of operations possible in MIR, including reading a value
58-
from an lvalue, performing math operations, creating new pointers, structures, and arrays, and so
58+
from an place, performing math operations, creating new pointers, structures, and arrays, and so
5959
on. Finally, a terminator decides where control will flow next, optionally based on the value of a
6060
boolean or integer.
6161

@@ -73,7 +73,7 @@ \section{Background}
7373
}
7474

7575
struct Statement {
76-
lvalue: Lvalue,
76+
place: Place,
7777
rvalue: Rvalue
7878
}
7979

@@ -99,7 +99,7 @@ \subsection{Basic operation}
9999
To investigate the possibility of executing Rust at compile-time I wrote an interpreter for MIR
100100
called Miri\footnote{\url{https://github.com/solson/miri}}. The structure of the interpreter closely
101101
mirrors the structure of MIR itself. It starts executing a function by iterating the statement list
102-
in the starting basic block, translating the lvalue into a pointer and using the rvalue to decide
102+
in the starting basic block, translating the place into a pointer and using the rvalue to decide
103103
what to write into that pointer. Evaluating the rvalue may involve reads (such as for the two sides
104104
of a binary operation) or construction of new values. When the terminator is reached, it is used to
105105
decide which basic block to jump to next. Finally, Miri repeats this entire process, reading
@@ -343,7 +343,7 @@ \subsection{Aggregates}
343343
closures. Miri supports all common usage of all of these types. The main missing piece is to handle
344344
\texttt{\#[repr(..)]} annotations which adjust the layout of a \rust{struct} or \rust{enum}.
345345

346-
\subsection{Lvalue projections}
346+
\subsection{Place projections}
347347

348348
This category includes field accesses, dereferencing, accessing data in an \rust{enum} variant, and
349349
indexing arrays. Miri supports all of these, including nested projections such as

0 commit comments

Comments
 (0)