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

Function write_hex

cranelift/codegen/src/ir/immediates.rs:231–239  ·  view source on GitHub ↗

Hexadecimal with a multiple of 4 digits and group separators: 0xfff0 0x0001_ffff 0xffff_ffff_fff8_4400

(x: u64, f: &mut Formatter)

Source from the content-addressed store, hash-verified

229/// 0xffff_ffff_fff8_4400
230///
231fn write_hex(x: u64, f: &mut Formatter) -> fmt::Result {
232 let mut pos = (64 - x.leading_zeros() - 1) & 0xf0;
233 write!(f, "0x{:04x}", (x >> pos) & 0xffff)?;
234 while pos > 0 {
235 pos -= 16;
236 write!(f, "_{:04x}", (x >> pos) & 0xffff)?;
237 }
238 Ok(())
239}
240
241impl Display for Uimm64 {
242 fn fmt(&self, f: &mut Formatter) -> fmt::Result {

Callers 1

fmtMethod · 0.85

Calls 2

OkFunction · 0.85
leading_zerosMethod · 0.80

Tested by

no test coverage detected