Remove the HeapLoad/HeapStore instruction formats.
These formats are not used any longer after the heap_load and heap_store instructions were replaced by heap_addr. Also drop the Uoffset32 immediate operand type which isn't used either.
This commit is contained in:
@@ -269,80 +269,15 @@ impl FromStr for Offset32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// 32-bit unsigned immediate offset.
|
||||
///
|
||||
/// This is used to encode an immediate offset for WebAssembly heap_load/heap_store instructions.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
|
||||
pub struct Uoffset32(u32);
|
||||
|
||||
impl Uoffset32 {
|
||||
/// Create a new `Uoffset32` representing the number `x`.
|
||||
pub fn new(x: u32) -> Uoffset32 {
|
||||
Uoffset32(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<u32> for Uoffset32 {
|
||||
fn into(self) -> u32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<i64> for Uoffset32 {
|
||||
fn into(self) -> i64 {
|
||||
i64::from(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u32> for Uoffset32 {
|
||||
fn from(x: u32) -> Self {
|
||||
Uoffset32(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Uoffset32 {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
// 0 displays as an empty offset.
|
||||
if self.0 == 0 {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Always include a sign.
|
||||
if self.0 < 10_000 {
|
||||
write!(f, "+{}", self.0)
|
||||
} else {
|
||||
write!(f, "+")?;
|
||||
write_hex(i64::from(self.0), f)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Uoffset32 {
|
||||
type Err = &'static str;
|
||||
|
||||
// Parse a decimal or hexadecimal `Uoffset32`, formatted as above.
|
||||
fn from_str(s: &str) -> Result<Uoffset32, &'static str> {
|
||||
if !s.starts_with('+') {
|
||||
return Err("Unsigned offset must begin with '+' sign");
|
||||
}
|
||||
parse_i64(s).and_then(|x| if 0 <= x && x <= i64::from(u32::MAX) {
|
||||
Ok(Uoffset32::new(x as u32))
|
||||
} else {
|
||||
Err("Offset out of range")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// An IEEE binary32 immediate floating point value, represented as a u32
|
||||
/// containing the bitpattern.
|
||||
/// containing the bit pattern.
|
||||
///
|
||||
/// All bit patterns are allowed.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct Ieee32(u32);
|
||||
|
||||
/// An IEEE binary64 immediate floating point value, represented as a u64
|
||||
/// containing the bitpattern.
|
||||
/// containing the bit pattern.
|
||||
///
|
||||
/// All bit patterns are allowed.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
@@ -772,28 +707,6 @@ mod tests {
|
||||
parse_err::<Offset32>("+0x8000_0000", "Offset out of range");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_uoffset32() {
|
||||
assert_eq!(Uoffset32(0).to_string(), "");
|
||||
assert_eq!(Uoffset32(1).to_string(), "+1");
|
||||
assert_eq!(Uoffset32(9999).to_string(), "+9999");
|
||||
assert_eq!(Uoffset32(10000).to_string(), "+0x2710");
|
||||
assert_eq!(Uoffset32(0xffff).to_string(), "+0xffff");
|
||||
assert_eq!(Uoffset32(0x10000).to_string(), "+0x0001_0000");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_uoffset32() {
|
||||
parse_ok::<Uoffset32>("+0", "");
|
||||
parse_ok::<Uoffset32>("+1", "+1");
|
||||
parse_ok::<Uoffset32>("+0x0", "");
|
||||
parse_ok::<Uoffset32>("+0xf", "+15");
|
||||
parse_ok::<Uoffset32>("+0x8000_0000", "+0x8000_0000");
|
||||
parse_ok::<Uoffset32>("+0xffff_ffff", "+0xffff_ffff");
|
||||
|
||||
parse_err::<Uoffset32>("+0x1_0000_0000", "Offset out of range");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_ieee32() {
|
||||
assert_eq!(Ieee32::with_float(0.0).to_string(), "0.0");
|
||||
|
||||
@@ -12,7 +12,7 @@ use std::ops::{Deref, DerefMut};
|
||||
|
||||
use ir;
|
||||
use ir::{Value, Type, Ebb, JumpTable, SigRef, FuncRef, StackSlot, MemFlags};
|
||||
use ir::immediates::{Imm64, Uimm8, Uimm32, Ieee32, Ieee64, Offset32, Uoffset32};
|
||||
use ir::immediates::{Imm64, Uimm8, Uimm32, Ieee32, Ieee64, Offset32};
|
||||
use ir::condcodes::*;
|
||||
use ir::types;
|
||||
use isa::RegUnit;
|
||||
@@ -190,16 +190,6 @@ pub enum InstructionData {
|
||||
stack_slot: StackSlot,
|
||||
offset: Offset32,
|
||||
},
|
||||
HeapLoad {
|
||||
opcode: Opcode,
|
||||
arg: Value,
|
||||
offset: Uoffset32,
|
||||
},
|
||||
HeapStore {
|
||||
opcode: Opcode,
|
||||
args: [Value; 2],
|
||||
offset: Uoffset32,
|
||||
},
|
||||
HeapAddr {
|
||||
opcode: Opcode,
|
||||
heap: ir::Heap,
|
||||
|
||||
@@ -335,8 +335,6 @@ impl<'a> Verifier<'a> {
|
||||
IntCompare { .. } |
|
||||
IntCompareImm { .. } |
|
||||
FloatCompare { .. } |
|
||||
HeapLoad { .. } |
|
||||
HeapStore { .. } |
|
||||
Load { .. } |
|
||||
Store { .. } |
|
||||
RegMove { .. } => {}
|
||||
|
||||
@@ -354,8 +354,6 @@ pub fn write_operands(
|
||||
offset,
|
||||
..
|
||||
} => write!(w, " {}, {}{}", arg, stack_slot, offset),
|
||||
HeapLoad { arg, offset, .. } => write!(w, " {}{}", arg, offset),
|
||||
HeapStore { args, offset, .. } => write!(w, " {}, {}{}", args[0], args[1], offset),
|
||||
HeapAddr { heap, arg, imm, .. } => write!(w, " {}, {}, {}", heap, arg, imm),
|
||||
Load { flags, arg, offset, .. } => write!(w, "{} {}{}", flags, arg, offset),
|
||||
Store {
|
||||
|
||||
Reference in New Issue
Block a user