@@ -34,13 +34,12 @@ pub fn fmt(
34
34
/// This function panics if the location is an immediate (i.e., an immediate
35
35
/// cannot be written to).
36
36
#[ must_use]
37
- pub fn rw ( location : Location ) -> Operand {
38
- assert ! ( !matches!( location. kind( ) , OperandKind :: Imm ( _) ) ) ;
37
+ pub fn rw ( op : impl Into < Operand > ) -> Operand {
38
+ let op = op. into ( ) ;
39
+ assert ! ( !matches!( op. location. kind( ) , OperandKind :: Imm ( _) ) ) ;
39
40
Operand {
40
- location,
41
41
mutability : Mutability :: ReadWrite ,
42
- extension : Extension :: default ( ) ,
43
- align : false ,
42
+ ..op
44
43
}
45
44
}
46
45
@@ -54,23 +53,20 @@ pub fn r(op: impl Into<Operand>) -> Operand {
54
53
55
54
/// An abbreviated constructor for a "write" operand.
56
55
#[ must_use]
57
- pub fn w ( location : Location ) -> Operand {
56
+ pub fn w ( op : impl Into < Operand > ) -> Operand {
57
+ let op = op. into ( ) ;
58
58
Operand {
59
- location,
60
59
mutability : Mutability :: Write ,
61
- extension : Extension :: None ,
62
- align : false ,
60
+ ..op
63
61
}
64
62
}
65
63
66
64
/// An abbreviated constructor for a memory operand that requires alignment.
67
65
pub fn align ( location : Location ) -> Operand {
68
66
assert ! ( location. uses_memory( ) ) ;
69
67
Operand {
70
- location,
71
- mutability : Mutability :: Read ,
72
- extension : Extension :: None ,
73
68
align : true ,
69
+ ..Operand :: from ( location)
74
70
}
75
71
}
76
72
@@ -84,10 +80,8 @@ pub fn align(location: Location) -> Operand {
84
80
pub fn sxq ( location : Location ) -> Operand {
85
81
assert ! ( location. bits( ) <= 64 ) ;
86
82
Operand {
87
- location,
88
- mutability : Mutability :: Read ,
89
83
extension : Extension :: SignExtendQuad ,
90
- align : false ,
84
+ .. Operand :: from ( location )
91
85
}
92
86
}
93
87
@@ -101,10 +95,8 @@ pub fn sxq(location: Location) -> Operand {
101
95
pub fn sxl ( location : Location ) -> Operand {
102
96
assert ! ( location. bits( ) <= 32 ) ;
103
97
Operand {
104
- location,
105
- mutability : Mutability :: Read ,
106
98
extension : Extension :: SignExtendLong ,
107
- align : false ,
99
+ .. Operand :: from ( location )
108
100
}
109
101
}
110
102
@@ -118,10 +110,8 @@ pub fn sxl(location: Location) -> Operand {
118
110
pub fn sxw ( location : Location ) -> Operand {
119
111
assert ! ( location. bits( ) <= 16 ) ;
120
112
Operand {
121
- location,
122
- mutability : Mutability :: Read ,
123
113
extension : Extension :: SignExtendWord ,
124
- align : false ,
114
+ .. Operand :: from ( location )
125
115
}
126
116
}
127
117
0 commit comments