Struct cranelift_codegen::ir::instructions::ValueTypeSet
source · pub struct ValueTypeSet {
pub lanes: BitSet<u16>,
pub ints: BitSet<u8>,
pub floats: BitSet<u8>,
pub refs: BitSet<u8>,
pub dynamic_lanes: BitSet<u16>,
}Expand description
A value type set describes the permitted set of types for a type variable.
Fields§
§lanes: BitSet<u16>Allowed lane sizes
ints: BitSet<u8>Allowed int widths
floats: BitSet<u8>Allowed float widths
refs: BitSet<u8>Allowed ref widths
dynamic_lanes: BitSet<u16>Allowed dynamic vectors minimum lane sizes
Implementations§
source§impl ValueTypeSet
impl ValueTypeSet
sourcepub fn contains(self, typ: Type) -> bool
pub fn contains(self, typ: Type) -> bool
Does typ belong to this set?
Examples found in repository?
src/verifier/mod.rs (line 1249)
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354
fn typecheck(&self, inst: Inst, errors: &mut VerifierErrors) -> VerifierStepResult<()> {
let inst_data = &self.func.dfg[inst];
let constraints = inst_data.opcode().constraints();
let ctrl_type = if let Some(value_typeset) = constraints.ctrl_typeset() {
// For polymorphic opcodes, determine the controlling type variable first.
let ctrl_type = self.func.dfg.ctrl_typevar(inst);
if !value_typeset.contains(ctrl_type) {
errors.report((
inst,
self.context(inst),
format!("has an invalid controlling type {}", ctrl_type),
));
}
ctrl_type
} else {
// Non-polymorphic instructions don't check the controlling type variable, so `Option`
// is unnecessary and we can just make it `INVALID`.
types::INVALID
};
// Typechecking instructions is never fatal
let _ = self.typecheck_results(inst, ctrl_type, errors);
let _ = self.typecheck_fixed_args(inst, ctrl_type, errors);
let _ = self.typecheck_variable_args(inst, errors);
let _ = self.typecheck_return(inst, errors);
let _ = self.typecheck_special(inst, ctrl_type, errors);
Ok(())
}
fn typecheck_results(
&self,
inst: Inst,
ctrl_type: Type,
errors: &mut VerifierErrors,
) -> VerifierStepResult<()> {
let mut i = 0;
for &result in self.func.dfg.inst_results(inst) {
let result_type = self.func.dfg.value_type(result);
let expected_type = self.func.dfg.compute_result_type(inst, i, ctrl_type);
if let Some(expected_type) = expected_type {
if result_type != expected_type {
errors.report((
inst,
self.context(inst),
format!(
"expected result {} ({}) to have type {}, found {}",
i, result, expected_type, result_type
),
));
}
} else {
return errors.nonfatal((
inst,
self.context(inst),
"has more result values than expected",
));
}
i += 1;
}
// There aren't any more result types left.
if self.func.dfg.compute_result_type(inst, i, ctrl_type) != None {
return errors.nonfatal((
inst,
self.context(inst),
"has fewer result values than expected",
));
}
Ok(())
}
fn typecheck_fixed_args(
&self,
inst: Inst,
ctrl_type: Type,
errors: &mut VerifierErrors,
) -> VerifierStepResult<()> {
let constraints = self.func.dfg[inst].opcode().constraints();
for (i, &arg) in self.func.dfg.inst_fixed_args(inst).iter().enumerate() {
let arg_type = self.func.dfg.value_type(arg);
match constraints.value_argument_constraint(i, ctrl_type) {
ResolvedConstraint::Bound(expected_type) => {
if arg_type != expected_type {
errors.report((
inst,
self.context(inst),
format!(
"arg {} ({}) has type {}, expected {}",
i, arg, arg_type, expected_type
),
));
}
}
ResolvedConstraint::Free(type_set) => {
if !type_set.contains(arg_type) {
errors.report((
inst,
self.context(inst),
format!(
"arg {} ({}) with type {} failed to satisfy type set {:?}",
i, arg, arg_type, type_set
),
));
}
}
}
}
Ok(())
}Trait Implementations§
source§impl Clone for ValueTypeSet
impl Clone for ValueTypeSet
source§fn clone(&self) -> ValueTypeSet
fn clone(&self) -> ValueTypeSet
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for ValueTypeSet
impl Debug for ValueTypeSet
source§impl PartialEq<ValueTypeSet> for ValueTypeSet
impl PartialEq<ValueTypeSet> for ValueTypeSet
source§fn eq(&self, other: &ValueTypeSet) -> bool
fn eq(&self, other: &ValueTypeSet) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Copy for ValueTypeSet
impl Eq for ValueTypeSet
impl StructuralEq for ValueTypeSet
impl StructuralPartialEq for ValueTypeSet
Auto Trait Implementations§
impl RefUnwindSafe for ValueTypeSet
impl Send for ValueTypeSet
impl Sync for ValueTypeSet
impl Unpin for ValueTypeSet
impl UnwindSafe for ValueTypeSet
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.