MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / mask_to_width

Method mask_to_width

cranelift/codegen/src/ir/immediates.rs:80–91  ·  view source on GitHub ↗
(&self, bit_width: u32)

Source from the content-addressed store, hash-verified

78 /// Mask this immediate to the given power-of-two bit width.
79 #[must_use]
80 pub(crate) fn mask_to_width(&self, bit_width: u32) -> Self {
81 debug_assert!(bit_width.is_power_of_two());
82
83 if bit_width >= 64 {
84 return *self;
85 }
86
87 let bit_width = i64::from(bit_width);
88 let mask = (1 << bit_width) - 1;
89 let masked = self.0 & mask;
90 Imm64(masked)
91 }
92
93 /// Sign extend this immediate as if it were a signed integer of the given
94 /// power-of-two width.

Callers 1

mask_immediatesMethod · 0.80

Calls 2

fromFunction · 0.85
Imm64Class · 0.70

Tested by

no test coverage detected