MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / derived

Method derived

cranelift/codegen/meta/src/cdsl/typevar.rs:147–238  ·  view source on GitHub ↗

Create a type variable that is a function of another.

(&self, derived_func: DerivedFunc)

Source from the content-addressed store, hash-verified

145
146 /// Create a type variable that is a function of another.
147 pub fn derived(&self, derived_func: DerivedFunc) -> TypeVar {
148 let ts = self.get_typeset();
149
150 // Safety checks to avoid over/underflows.
151 match derived_func {
152 DerivedFunc::HalfWidth => {
153 assert!(
154 ts.ints.is_empty() || *ts.ints.iter().min().unwrap() > 8,
155 "can't halve all integer types"
156 );
157 assert!(
158 ts.floats.is_empty() || *ts.floats.iter().min().unwrap() > 16,
159 "can't halve all float types"
160 );
161 }
162 DerivedFunc::DoubleWidth => {
163 assert!(
164 ts.ints.is_empty() || *ts.ints.iter().max().unwrap() < MAX_BITS,
165 "can't double all integer types"
166 );
167 assert!(
168 ts.floats.is_empty() || *ts.floats.iter().max().unwrap() < MAX_FLOAT_BITS,
169 "can't double all float types"
170 );
171 }
172 DerivedFunc::SplitLanes => {
173 assert!(
174 ts.ints.is_empty() || *ts.ints.iter().min().unwrap() > 8,
175 "can't halve all integer types"
176 );
177 assert!(
178 ts.floats.is_empty() || *ts.floats.iter().min().unwrap() > 16,
179 "can't halve all float types"
180 );
181 assert!(
182 *ts.lanes.iter().max().unwrap() < MAX_LANES,
183 "can't double 256 lanes"
184 );
185 }
186 DerivedFunc::MergeLanes => {
187 assert!(
188 ts.ints.is_empty() || *ts.ints.iter().max().unwrap() < MAX_BITS,
189 "can't double all integer types"
190 );
191 assert!(
192 ts.floats.is_empty() || *ts.floats.iter().max().unwrap() < MAX_FLOAT_BITS,
193 "can't double all float types"
194 );
195 assert!(
196 *ts.lanes.iter().min().unwrap() > 1,
197 "can't halve a scalar type"
198 );
199 }
200 DerivedFunc::Narrower => {
201 assert_eq!(
202 *ts.lanes.iter().max().unwrap(),
203 1,
204 "The `narrower` constraint does not apply to vectors"

Callers 9

lane_ofMethod · 0.80
as_truthyMethod · 0.80
half_widthMethod · 0.80
double_widthMethod · 0.80
split_lanesMethod · 0.80
merge_lanesMethod · 0.80
dynamic_to_vectorMethod · 0.80
narrowerMethod · 0.80
widerMethod · 0.80

Calls 3

get_typesetMethod · 0.80
newFunction · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected