@@ -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 {
@@ -84,10 +84,10 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
84
84
layout:: Abi :: Scalar ( ref x) => x,
85
85
_ => bug ! ( "from_const: invalid ByVal layout: {:#?}" , layout)
86
86
} ;
87
- let llval = bx. cx ( ) . scalar_to_backend (
87
+ let llval = bx. scalar_to_backend (
88
88
x,
89
89
scalar,
90
- bx. cx ( ) . immediate_backend_type ( layout) ,
90
+ bx. immediate_backend_type ( layout) ,
91
91
) ;
92
92
OperandValue :: Immediate ( llval)
93
93
} ,
@@ -96,16 +96,16 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
96
96
layout:: Abi :: ScalarPair ( ref a, _) => a,
97
97
_ => bug ! ( "from_const: invalid ScalarPair layout: {:#?}" , layout)
98
98
} ;
99
- let a_llval = bx. cx ( ) . scalar_to_backend (
99
+ let a_llval = bx. scalar_to_backend (
100
100
a,
101
101
a_scalar,
102
- bx. cx ( ) . scalar_pair_element_backend_type ( layout, 0 , true ) ,
102
+ bx. scalar_pair_element_backend_type ( layout, 0 , true ) ,
103
103
) ;
104
- let b_llval = bx. cx ( ) . const_usize ( b) ;
104
+ let b_llval = bx. const_usize ( b) ;
105
105
OperandValue :: Pair ( a_llval, b_llval)
106
106
} ,
107
107
ConstValue :: ByRef ( ptr, alloc) => {
108
- return Ok ( bx. load_operand ( bx. cx ( ) . from_const_alloc ( layout, alloc, ptr. offset ) ) ) ;
108
+ return Ok ( bx. load_operand ( bx. from_const_alloc ( layout, alloc, ptr. offset ) ) ) ;
109
109
} ,
110
110
} ;
111
111
@@ -124,7 +124,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
124
124
}
125
125
}
126
126
127
- pub fn deref < Cx : CodegenMethods < ' tcx , Value = V > > (
127
+ pub fn deref < Cx : LayoutTypeMethods < ' tcx > > (
128
128
self ,
129
129
cx : & Cx
130
130
) -> PlaceRef < ' tcx , V > {
@@ -199,7 +199,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
199
199
let mut val = match ( self . val , & self . layout . abi ) {
200
200
// If the field is ZST, it has no data.
201
201
_ if field. is_zst ( ) => {
202
- return OperandRef :: new_zst ( bx. cx ( ) , field) ;
202
+ return OperandRef :: new_zst ( bx, field) ;
203
203
}
204
204
205
205
// Newtype of a scalar, scalar pair or vector.
@@ -409,7 +409,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
409
409
// checks in `codegen_consume` and `extract_field`.
410
410
let elem = o. layout . field ( bx. cx ( ) , 0 ) ;
411
411
if elem. is_zst ( ) {
412
- return Some ( OperandRef :: new_zst ( bx. cx ( ) , elem) ) ;
412
+ return Some ( OperandRef :: new_zst ( bx, elem) ) ;
413
413
}
414
414
}
415
415
_ => { }
@@ -432,7 +432,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
432
432
433
433
// ZSTs don't require any actual memory access.
434
434
if layout. is_zst ( ) {
435
- return OperandRef :: new_zst ( bx. cx ( ) , layout) ;
435
+ return OperandRef :: new_zst ( bx, layout) ;
436
436
}
437
437
438
438
if let Some ( o) = self . maybe_codegen_consume_direct ( bx, place) {
0 commit comments