@@ -54,13 +54,13 @@ impl<V: CodegenObject> fmt::Debug for OperandRef<'tcx, V> {
54
54
}
55
55
56
56
impl < ' a , ' tcx : ' a , V : CodegenObject > OperandRef < ' tcx , V > {
57
- pub fn new_zst < Cx : CodegenMethods < ' tcx , Value = V > > (
58
- cx : & Cx ,
57
+ pub fn new_zst < Bx : BuilderMethods < ' a , ' tcx , Value = V > > (
58
+ bx : & mut Bx ,
59
59
layout : TyLayout < ' tcx >
60
60
) -> OperandRef < ' tcx , V > {
61
61
assert ! ( layout. is_zst( ) ) ;
62
62
OperandRef {
63
- val : OperandValue :: Immediate ( cx . const_undef ( cx . immediate_backend_type ( layout) ) ) ,
63
+ val : OperandValue :: Immediate ( bx . const_undef ( bx . immediate_backend_type ( layout) ) ) ,
64
64
layout
65
65
}
66
66
}
@@ -69,10 +69,10 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
69
69
bx : & mut Bx ,
70
70
val : ty:: Const < ' tcx >
71
71
) -> Result < Self , ErrorHandled > {
72
- let layout = bx. cx ( ) . layout_of ( val. ty ) ;
72
+ let layout = bx. layout_of ( val. ty ) ;
73
73
74
74
if layout. is_zst ( ) {
75
- return Ok ( OperandRef :: new_zst ( bx. cx ( ) , layout) ) ;
75
+ return Ok ( OperandRef :: new_zst ( bx, layout) ) ;
76
76
}
77
77
78
78
let val = match val. val {
@@ -81,10 +81,10 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
81
81
layout:: Abi :: Scalar ( ref x) => x,
82
82
_ => bug ! ( "from_const: invalid ByVal layout: {:#?}" , layout)
83
83
} ;
84
- let llval = bx. cx ( ) . scalar_to_backend (
84
+ let llval = bx. scalar_to_backend (
85
85
x,
86
86
scalar,
87
- bx. cx ( ) . immediate_backend_type ( layout) ,
87
+ bx. immediate_backend_type ( layout) ,
88
88
) ;
89
89
OperandValue :: Immediate ( llval)
90
90
} ,
@@ -93,16 +93,16 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
93
93
layout:: Abi :: ScalarPair ( ref a, _) => a,
94
94
_ => bug ! ( "from_const: invalid ScalarPair layout: {:#?}" , layout)
95
95
} ;
96
- let a_llval = bx. cx ( ) . scalar_to_backend (
96
+ let a_llval = bx. scalar_to_backend (
97
97
a,
98
98
a_scalar,
99
- bx. cx ( ) . scalar_pair_element_backend_type ( layout, 0 , true ) ,
99
+ bx. scalar_pair_element_backend_type ( layout, 0 , true ) ,
100
100
) ;
101
- let b_llval = bx. cx ( ) . const_usize ( b) ;
101
+ let b_llval = bx. const_usize ( b) ;
102
102
OperandValue :: Pair ( a_llval, b_llval)
103
103
} ,
104
104
ConstValue :: ByRef ( ptr, alloc) => {
105
- return Ok ( bx. load_operand ( bx. cx ( ) . from_const_alloc ( layout, alloc, ptr. offset ) ) ) ;
105
+ return Ok ( bx. load_operand ( bx. from_const_alloc ( layout, alloc, ptr. offset ) ) ) ;
106
106
} ,
107
107
} ;
108
108
@@ -121,7 +121,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
121
121
}
122
122
}
123
123
124
- pub fn deref < Cx : CodegenMethods < ' tcx , Value = V > > (
124
+ pub fn deref < Cx : LayoutTypeMethods < ' tcx > > (
125
125
self ,
126
126
cx : & Cx
127
127
) -> PlaceRef < ' tcx , V > {
@@ -196,7 +196,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
196
196
let mut val = match ( self . val , & self . layout . abi ) {
197
197
// If the field is ZST, it has no data.
198
198
_ if field. is_zst ( ) => {
199
- return OperandRef :: new_zst ( bx. cx ( ) , field) ;
199
+ return OperandRef :: new_zst ( bx, field) ;
200
200
}
201
201
202
202
// Newtype of a scalar, scalar pair or vector.
@@ -406,7 +406,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
406
406
// checks in `codegen_consume` and `extract_field`.
407
407
let elem = o. layout . field ( bx. cx ( ) , 0 ) ;
408
408
if elem. is_zst ( ) {
409
- return Some ( OperandRef :: new_zst ( bx. cx ( ) , elem) ) ;
409
+ return Some ( OperandRef :: new_zst ( bx, elem) ) ;
410
410
}
411
411
}
412
412
_ => { }
@@ -429,7 +429,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
429
429
430
430
// ZSTs don't require any actual memory access.
431
431
if layout. is_zst ( ) {
432
- return OperandRef :: new_zst ( bx. cx ( ) , layout) ;
432
+ return OperandRef :: new_zst ( bx, layout) ;
433
433
}
434
434
435
435
if let Some ( o) = self . maybe_codegen_consume_direct ( bx, place) {
0 commit comments