Skip to content

Commit 044096b

Browse files
committed
Change Call operands to be, well, Operands
1 parent 3ab29d3 commit 044096b

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

src/librustc_mir/build/expr/into.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ impl<'a,'tcx> Builder<'a,'tcx> {
211211
this.cfg.start_new_block().unit()
212212
}
213213
ExprKind::Call { fun, args } => {
214-
let fun = unpack!(block = this.as_lvalue(block, fun));
214+
let fun = unpack!(block = this.as_operand(block, fun));
215215
let args: Vec<_> =
216216
args.into_iter()
217-
.map(|arg| unpack!(block = this.as_lvalue(block, arg)))
217+
.map(|arg| unpack!(block = this.as_operand(block, arg)))
218218
.collect();
219219
let success = this.cfg.start_new_block();
220220
let panic = this.diverge_cleanup();

src/librustc_mir/build/matches/test.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,28 @@ impl<'a,'tcx> Builder<'a,'tcx> {
100100

101101
TestKind::Eq { value, ty } => {
102102
// call PartialEq::eq(discrim, constant)
103-
let constant = self.push_literal(block, test.span, ty.clone(), value);
103+
let constant = self.literal_operand(test.span, ty.clone(), value);
104104
let item_ref = self.hir.partial_eq(ty);
105-
self.call_comparison_fn(block, test.span, item_ref, lvalue.clone(), constant)
105+
self.call_comparison_fn(block, test.span, item_ref,
106+
Operand::Consume(lvalue.clone()), constant)
106107
}
107108

108109
TestKind::Range { lo, hi, ty } => {
109110
// Test `v` by computing `PartialOrd::le(lo, v) && PartialOrd::le(v, hi)`.
110-
let lo = self.push_literal(block, test.span, ty.clone(), lo);
111-
let hi = self.push_literal(block, test.span, ty.clone(), hi);
111+
let lo = self.literal_operand(test.span, ty.clone(), lo);
112+
let hi = self.literal_operand(test.span, ty.clone(), hi);
112113
let item_ref = self.hir.partial_le(ty);
113114

114115
let lo_blocks = self.call_comparison_fn(block,
115116
test.span,
116117
item_ref.clone(),
117118
lo,
118-
lvalue.clone());
119+
Operand::Consume(lvalue.clone()));
119120

120121
let hi_blocks = self.call_comparison_fn(lo_blocks[0],
121122
test.span,
122123
item_ref,
123-
lvalue.clone(),
124+
Operand::Consume(lvalue.clone()),
124125
hi);
125126

126127
let failure = self.cfg.start_new_block();
@@ -165,14 +166,14 @@ impl<'a,'tcx> Builder<'a,'tcx> {
165166
block: BasicBlock,
166167
span: Span,
167168
item_ref: ItemRef<'tcx>,
168-
lvalue1: Lvalue<'tcx>,
169-
lvalue2: Lvalue<'tcx>)
169+
lvalue1: Operand<'tcx>,
170+
lvalue2: Operand<'tcx>)
170171
-> Vec<BasicBlock> {
171172
let target_blocks = vec![self.cfg.start_new_block(), self.cfg.start_new_block()];
172173

173174
let bool_ty = self.hir.bool_ty();
174175
let eq_result = self.temp(bool_ty);
175-
let func = self.push_item_ref(block, span, item_ref);
176+
let func = self.item_ref_operand(span, item_ref);
176177
let call_blocks = [self.cfg.start_new_block(), self.diverge_cleanup()];
177178
self.cfg.terminate(block,
178179
Terminator::Call {

src/librustc_mir/build/misc.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,17 @@ impl<'a,'tcx> Builder<'a,'tcx> {
3434
lvalue
3535
}
3636

37-
pub fn push_literal(&mut self,
38-
block: BasicBlock,
39-
span: Span,
40-
ty: Ty<'tcx>,
41-
literal: Literal<'tcx>)
42-
-> Lvalue<'tcx> {
43-
let temp = self.temp(ty.clone());
37+
pub fn literal_operand(&mut self,
38+
span: Span,
39+
ty: Ty<'tcx>,
40+
literal: Literal<'tcx>)
41+
-> Operand<'tcx> {
4442
let constant = Constant {
4543
span: span,
4644
ty: ty,
4745
literal: literal,
4846
};
49-
self.cfg.push_assign_constant(block, span, &temp, constant);
50-
temp
47+
Operand::Constant(constant)
5148
}
5249

5350
pub fn push_usize(&mut self, block: BasicBlock, span: Span, value: usize) -> Lvalue<'tcx> {
@@ -63,15 +60,14 @@ impl<'a,'tcx> Builder<'a,'tcx> {
6360
temp
6461
}
6562

66-
pub fn push_item_ref(&mut self,
67-
block: BasicBlock,
68-
span: Span,
69-
item_ref: ItemRef<'tcx>)
70-
-> Lvalue<'tcx> {
63+
pub fn item_ref_operand(&mut self,
64+
span: Span,
65+
item_ref: ItemRef<'tcx>)
66+
-> Operand<'tcx> {
7167
let literal = Literal::Item {
7268
def_id: item_ref.def_id,
7369
substs: item_ref.substs,
7470
};
75-
self.push_literal(block, span, item_ref.ty, literal)
71+
self.literal_operand(span, item_ref.ty, literal)
7672
}
7773
}

src/librustc_mir/repr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,10 @@ pub struct CallData<'tcx> {
294294
pub destination: Lvalue<'tcx>,
295295

296296
/// the fn being called
297-
pub func: Lvalue<'tcx>,
297+
pub func: Operand<'tcx>,
298298

299299
/// the arguments
300-
pub args: Vec<Lvalue<'tcx>>,
300+
pub args: Vec<Operand<'tcx>>,
301301
}
302302

303303
impl<'tcx> BasicBlockData<'tcx> {

0 commit comments

Comments
 (0)