Serialize ValueLabel and StackSlots (#888)
This commit is contained in:
@@ -69,6 +69,7 @@ entity_impl!(Inst, "inst");
|
|||||||
|
|
||||||
/// An opaque reference to a stack slot.
|
/// An opaque reference to a stack slot.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct StackSlot(u32);
|
pub struct StackSlot(u32);
|
||||||
entity_impl!(StackSlot, "ss");
|
entity_impl!(StackSlot, "ss");
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ mod trapcode;
|
|||||||
pub mod types;
|
pub mod types;
|
||||||
mod valueloc;
|
mod valueloc;
|
||||||
|
|
||||||
|
#[cfg(feature = "enable-serde")]
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub use crate::ir::builder::{InsertBuilder, InstBuilder, InstBuilderBase, InstInserterBase};
|
pub use crate::ir::builder::{InsertBuilder, InstBuilder, InstBuilderBase, InstInserterBase};
|
||||||
pub use crate::ir::dfg::{DataFlowGraph, ValueDef};
|
pub use crate::ir::dfg::{DataFlowGraph, ValueDef};
|
||||||
pub use crate::ir::entities::{
|
pub use crate::ir::entities::{
|
||||||
@@ -74,6 +77,7 @@ pub type SourceLocs = SecondaryMap<Inst, SourceLoc>;
|
|||||||
|
|
||||||
/// Marked with a label value.
|
/// Marked with a label value.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct ValueLabel(u32);
|
pub struct ValueLabel(u32);
|
||||||
entity_impl!(ValueLabel, "val");
|
entity_impl!(ValueLabel, "val");
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ use core::slice;
|
|||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
|
||||||
|
#[cfg(feature = "enable-serde")]
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// The size of an object on the stack, or the size of a stack frame.
|
/// The size of an object on the stack, or the size of a stack frame.
|
||||||
///
|
///
|
||||||
/// We don't use `usize` to represent object sizes on the target platform because Cranelift supports
|
/// We don't use `usize` to represent object sizes on the target platform because Cranelift supports
|
||||||
@@ -38,6 +41,7 @@ fn spill_size(ty: Type) -> StackSize {
|
|||||||
|
|
||||||
/// The kind of a stack slot.
|
/// The kind of a stack slot.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub enum StackSlotKind {
|
pub enum StackSlotKind {
|
||||||
/// A spill slot. This is a stack slot created by the register allocator.
|
/// A spill slot. This is a stack slot created by the register allocator.
|
||||||
SpillSlot,
|
SpillSlot,
|
||||||
@@ -98,6 +102,7 @@ impl fmt::Display for StackSlotKind {
|
|||||||
|
|
||||||
/// Contents of a stack slot.
|
/// Contents of a stack slot.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct StackSlotData {
|
pub struct StackSlotData {
|
||||||
/// The kind of stack slot.
|
/// The kind of stack slot.
|
||||||
pub kind: StackSlotKind,
|
pub kind: StackSlotKind,
|
||||||
@@ -150,6 +155,7 @@ impl fmt::Display for StackSlotData {
|
|||||||
///
|
///
|
||||||
/// Keep track of all the stack slots used by a function.
|
/// Keep track of all the stack slots used by a function.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct StackSlots {
|
pub struct StackSlots {
|
||||||
/// All allocated stack slots.
|
/// All allocated stack slots.
|
||||||
slots: PrimaryMap<StackSlot, StackSlotData>,
|
slots: PrimaryMap<StackSlot, StackSlotData>,
|
||||||
|
|||||||
@@ -7,8 +7,12 @@ use crate::ir::StackSlot;
|
|||||||
use crate::isa::{RegInfo, RegUnit};
|
use crate::isa::{RegInfo, RegUnit};
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
|
#[cfg(feature = "enable-serde")]
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Value location.
|
/// Value location.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub enum ValueLoc {
|
pub enum ValueLoc {
|
||||||
/// This value has not been assigned to a location yet.
|
/// This value has not been assigned to a location yet.
|
||||||
Unassigned,
|
Unassigned,
|
||||||
|
|||||||
@@ -8,8 +8,12 @@ use std::ops::Bound::*;
|
|||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
|
||||||
|
#[cfg(feature = "enable-serde")]
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Value location range.
|
/// Value location range.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct ValueLocRange {
|
pub struct ValueLocRange {
|
||||||
/// The ValueLoc containing a ValueLabel during this range.
|
/// The ValueLoc containing a ValueLabel during this range.
|
||||||
pub loc: ValueLoc,
|
pub loc: ValueLoc,
|
||||||
|
|||||||
Reference in New Issue
Block a user