MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / bitcast

Method bitcast

crates/rustc_codegen_spirv/src/builder/builder_methods.rs:1520–1553  ·  view source on GitHub ↗
(&mut self, val: Self::Value, dest_ty: Self::Type)

Source from the content-addressed store, hash-verified

1518 }
1519
1520 fn bitcast(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value {
1521 if val.ty == dest_ty {
1522 val
1523 } else {
1524 let val_is_ptr = matches!(self.lookup_type(val.ty), SpirvType::Pointer { .. });
1525 let dest_is_ptr = matches!(self.lookup_type(dest_ty), SpirvType::Pointer { .. });
1526
1527 // Reuse the pointer-specific logic in `pointercast` for `*T -> *U`.
1528 if val_is_ptr && dest_is_ptr {
1529 return self.pointercast(val, dest_ty);
1530 }
1531
1532 let result = self
1533 .emit()
1534 .bitcast(dest_ty, None, val.def(self))
1535 .unwrap()
1536 .with_type(dest_ty);
1537
1538 if val_is_ptr || dest_is_ptr {
1539 self.zombie(
1540 result.def(self),
1541 &format!(
1542 "cannot cast between pointer and non-pointer types\
1543 \nfrom `{}`\
1544 \n to `{}`",
1545 self.debug_type(val.ty),
1546 self.debug_type(dest_ty)
1547 ),
1548 );
1549 }
1550
1551 result
1552 }
1553 }
1554
1555 fn intcast(&mut self, val: Self::Value, dest_ty: Self::Type, is_signed: bool) -> Self::Value {
1556 if val.ty == dest_ty {

Callers 7

recurse_load_typeMethod · 0.80
recurse_store_typeMethod · 0.80
copysignMethod · 0.80
memset_dynamic_scalarFunction · 0.80
fptoint_satMethod · 0.80
intcastMethod · 0.80
pointercastMethod · 0.80

Calls 5

pointercastMethod · 0.80
with_typeMethod · 0.80
zombieMethod · 0.80
emitMethod · 0.45
defMethod · 0.45

Tested by

no test coverage detected