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

Method icmp

crates/rustc_codegen_spirv/src/builder/builder_methods.rs:1669–1870  ·  view source on GitHub ↗
(&mut self, op: IntPredicate, lhs: Self::Value, rhs: Self::Value)

Source from the content-addressed store, hash-verified

1667 }
1668
1669 fn icmp(&mut self, op: IntPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value {
1670 // Note: the signedness of the opcode doesn't have to match the signedness of the operands.
1671 use IntPredicate::*;
1672 assert_ty_eq!(self, lhs.ty, rhs.ty);
1673 let b = SpirvType::Bool.def(self.span(), self);
1674 match self.lookup_type(lhs.ty) {
1675 SpirvType::Integer(_, _) => match op {
1676 IntEQ => self.emit().i_equal(b, None, lhs.def(self), rhs.def(self)),
1677 IntNE => self
1678 .emit()
1679 .i_not_equal(b, None, lhs.def(self), rhs.def(self)),
1680 IntUGT => self
1681 .emit()
1682 .u_greater_than(b, None, lhs.def(self), rhs.def(self)),
1683 IntUGE => self
1684 .emit()
1685 .u_greater_than_equal(b, None, lhs.def(self), rhs.def(self)),
1686 IntULT => self
1687 .emit()
1688 .u_less_than(b, None, lhs.def(self), rhs.def(self)),
1689 IntULE => self
1690 .emit()
1691 .u_less_than_equal(b, None, lhs.def(self), rhs.def(self)),
1692 IntSGT => self
1693 .emit()
1694 .s_greater_than(b, None, lhs.def(self), rhs.def(self)),
1695 IntSGE => self
1696 .emit()
1697 .s_greater_than_equal(b, None, lhs.def(self), rhs.def(self)),
1698 IntSLT => self
1699 .emit()
1700 .s_less_than(b, None, lhs.def(self), rhs.def(self)),
1701 IntSLE => self
1702 .emit()
1703 .s_less_than_equal(b, None, lhs.def(self), rhs.def(self)),
1704 },
1705 SpirvType::Pointer { .. } => match op {
1706 IntEQ => {
1707 if self.emit().version().unwrap() > (1, 3) {
1708 let ptr_equal =
1709 self.emit().ptr_equal(b, None, lhs.def(self), rhs.def(self));
1710
1711 ptr_equal.map(|result| {
1712 self.zombie_ptr_equal(result, "OpPtrEqual");
1713 result
1714 })
1715 } else {
1716 let int_ty = self.type_usize();
1717 let lhs = self
1718 .emit()
1719 .convert_ptr_to_u(int_ty, None, lhs.def(self))
1720 .unwrap();
1721 self.zombie_convert_ptr_to_u(lhs);
1722 let rhs = self
1723 .emit()
1724 .convert_ptr_to_u(int_ty, None, rhs.def(self))
1725 .unwrap();
1726 self.zombie_convert_ptr_to_u(rhs);

Callers 1

memset_dynamic_sizeMethod · 0.80

Calls 10

spanMethod · 0.80
with_typeMethod · 0.80
lookup_typeMethod · 0.80
zombie_ptr_equalMethod · 0.80
type_usizeMethod · 0.80
fatalMethod · 0.80
constant_boolMethod · 0.80
defMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected