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

Method checked_binop

crates/rustc_codegen_spirv/src/builder/builder_methods.rs:1015–1040  ·  view source on GitHub ↗
(
        &mut self,
        oop: OverflowOp,
        _ty: Ty<'_>,
        lhs: Self::Value,
        rhs: Self::Value,
    )

Source from the content-addressed store, hash-verified

1013 }
1014
1015 fn checked_binop(
1016 &mut self,
1017 oop: OverflowOp,
1018 _ty: Ty<'_>,
1019 lhs: Self::Value,
1020 rhs: Self::Value,
1021 ) -> (Self::Value, Self::Value) {
1022 // NOTE(eddyb) this needs to be `undef`, not `false`/`true`, because
1023 // we don't want the user's boolean constants to keep the zombie alive.
1024 let bool = SpirvType::Bool.def(self.span(), self);
1025 let overflowed = self.undef(bool);
1026 let result = match oop {
1027 OverflowOp::Add => (self.add(lhs, rhs), overflowed),
1028 OverflowOp::Sub => (self.sub(lhs, rhs), overflowed),
1029 OverflowOp::Mul => (self.mul(lhs, rhs), overflowed),
1030 };
1031 self.zombie(
1032 result.1.def(self),
1033 match oop {
1034 OverflowOp::Add => "checked add is not supported yet",
1035 OverflowOp::Sub => "checked sub is not supported yet",
1036 OverflowOp::Mul => "checked mul is not supported yet",
1037 },
1038 );
1039 result
1040 }
1041
1042 // rustc has the concept of an immediate vs. memory type - bools are compiled to LLVM bools as
1043 // immediates, but if they're behind a pointer, they're compiled to u8. The reason for this is

Callers

nothing calls this directly

Calls 4

spanMethod · 0.80
undefMethod · 0.80
zombieMethod · 0.80
defMethod · 0.45

Tested by

no test coverage detected