Derive Ord for all entities (#1313)
This commit is contained in:
@@ -31,6 +31,8 @@ use serde::{Deserialize, Serialize};
|
||||
///
|
||||
/// You can get an `Ebb` using
|
||||
/// [`FunctionBuilder::create_ebb`](https://docs.rs/cranelift-frontend/*/cranelift_frontend/struct.FunctionBuilder.html#method.create_ebb)
|
||||
///
|
||||
/// While the order is stable, it is arbitrary and does not necessarily resemble the layout order.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct Ebb(u32);
|
||||
entity_impl!(Ebb, "ebb");
|
||||
@@ -61,6 +63,8 @@ impl Ebb {
|
||||
/// - [`null`](super::InstBuilder::null) for null reference constants
|
||||
///
|
||||
/// Any `InstBuilder` instruction that has an output will also return a `Value`.
|
||||
///
|
||||
/// While the order is stable, it is arbitrary.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct Value(u32);
|
||||
entity_impl!(Value, "v");
|
||||
@@ -91,6 +95,8 @@ impl Value {
|
||||
/// on the type of instruction.
|
||||
///
|
||||
/// [inst_comment]: https://github.com/bjorn3/rustc_codegen_cranelift/blob/0f8814fd6da3d436a90549d4bb19b94034f2b19c/src/pretty_clif.rs
|
||||
///
|
||||
/// While the order is stable, it is arbitrary and does not necessarily resemble the layout order.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct Inst(u32);
|
||||
entity_impl!(Inst, "inst");
|
||||
@@ -107,7 +113,9 @@ entity_impl!(Inst, "inst");
|
||||
/// [`stack_addr`](super::InstBuilder::stack_addr),
|
||||
/// [`stack_load`](super::InstBuilder::stack_load), and
|
||||
/// [`stack_store`](super::InstBuilder::stack_store).
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
///
|
||||
/// While the order is stable, it is arbitrary and does not necessarily resemble the stack order.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub struct StackSlot(u32);
|
||||
entity_impl!(StackSlot, "ss");
|
||||
@@ -142,7 +150,9 @@ impl StackSlot {
|
||||
///
|
||||
/// `GlobalValue`s can be retrieved with
|
||||
/// [`InstBuilder:global_value`](super::InstBuilder::global_value).
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
///
|
||||
/// While the order is stable, it is arbitrary.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct GlobalValue(u32);
|
||||
entity_impl!(GlobalValue, "gv");
|
||||
|
||||
@@ -164,6 +174,9 @@ impl GlobalValue {
|
||||
/// You can store [`ConstantData`](super::ConstantData) in a
|
||||
/// [`ConstantPool`](super::ConstantPool) for efficient storage and retrieval.
|
||||
/// See [`ConstantPool::insert`](super::ConstantPool::insert).
|
||||
///
|
||||
/// While the order is stable, it is arbitrary and does not necessarily resemble the order in which
|
||||
/// the constants are written in the constant pool.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
|
||||
pub struct Constant(u32);
|
||||
entity_impl!(Constant, "const");
|
||||
@@ -187,7 +200,9 @@ impl Constant {
|
||||
/// [`InstructionData`](super::instructions::InstructionData) struct and therefore must be
|
||||
/// tracked separately in [`DataFlowGraph::immediates`](super::dfg::DataFlowGraph). `Immediate`
|
||||
/// provides a way to reference values stored there.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
///
|
||||
/// While the order is stable, it is arbitrary.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct Immediate(u32);
|
||||
entity_impl!(Immediate, "imm");
|
||||
|
||||
@@ -214,7 +229,9 @@ impl Immediate {
|
||||
///
|
||||
/// `JumpTable`s can be created with
|
||||
/// [`create_jump_table`](https://docs.rs/cranelift-frontend/*/cranelift_frontend/struct.FunctionBuilder.html#method.create_jump_table).
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
///
|
||||
/// While the order is stable, it is arbitrary.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub struct JumpTable(u32);
|
||||
entity_impl!(JumpTable, "jt");
|
||||
@@ -248,7 +265,9 @@ impl JumpTable {
|
||||
/// - [`FuncEnvironment::make_direct_func`](https://docs.rs/cranelift-wasm/*/cranelift_wasm/trait.FuncEnvironment.html#tymethod.make_direct_func)
|
||||
/// for functions declared in the same WebAssembly
|
||||
/// [`FuncEnvironment`](https://docs.rs/cranelift-wasm/*/cranelift_wasm/trait.FuncEnvironment.html#tymethod.make_direct_func)
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
///
|
||||
/// While the order is stable, it is arbitrary.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct FuncRef(u32);
|
||||
entity_impl!(FuncRef, "fn");
|
||||
|
||||
@@ -277,7 +296,9 @@ impl FuncRef {
|
||||
/// You can retrieve the [`Signature`](super::Signature) that was used to create a `SigRef` with
|
||||
/// [`FunctionBuilder::signature`](https://docs.rs/cranelift-frontend/*/cranelift_frontend/struct.FunctionBuilder.html#method.signature) or
|
||||
/// [`func.dfg.signatures`](super::dfg::DataFlowGraph::signatures).
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
///
|
||||
/// While the order is stable, it is arbitrary.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct SigRef(u32);
|
||||
entity_impl!(SigRef, "sig");
|
||||
|
||||
@@ -300,7 +321,9 @@ impl SigRef {
|
||||
/// [`heap_addr`](super::InstBuilder::heap_addr).
|
||||
///
|
||||
/// To create a heap, use [`FunctionBuilder::create_heap`](https://docs.rs/cranelift-frontend/*/cranelift_frontend/struct.FunctionBuilder.html#method.create_heap).
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
///
|
||||
/// While the order is stable, it is arbitrary.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct Heap(u32);
|
||||
entity_impl!(Heap, "heap");
|
||||
|
||||
@@ -324,7 +347,9 @@ impl Heap {
|
||||
/// They can be created with [`FuncEnvironment::make_table`](https://docs.rs/cranelift-wasm/*/cranelift_wasm/trait.FuncEnvironment.html#tymethod.make_table).
|
||||
/// They can be used with
|
||||
/// [`FuncEnvironment::translate_call_indirect`](https://docs.rs/cranelift-wasm/*/cranelift_wasm/trait.FuncEnvironment.html#tymethod.translate_call_indirect).
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
///
|
||||
/// While the order is stable, it is arbitrary.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct Table(u32);
|
||||
entity_impl!(Table, "table");
|
||||
|
||||
@@ -342,7 +367,7 @@ impl Table {
|
||||
}
|
||||
|
||||
/// An opaque reference to any of the entities defined in this module that can appear in CLIF IR.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub enum AnyEntity {
|
||||
/// The whole function.
|
||||
Function,
|
||||
|
||||
Reference in New Issue
Block a user