(&mut self, val: Self::Value, dest_ty: Self::Type)
| 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 { |
no test coverage detected