Declare constants in the function preamble
This allows us to give names to constants in the constant pool and then use these names in the function body. The original behavior, specifiying the constant value as an instruction immediate, is still supported as a shortcut but some filetests had to change since the canonical way of printing the CLIF constants is now in the preamble.
This commit is contained in:
@@ -382,6 +382,8 @@ pub enum AnyEntity {
|
||||
GlobalValue(GlobalValue),
|
||||
/// A jump table.
|
||||
JumpTable(JumpTable),
|
||||
/// A constant.
|
||||
Constant(Constant),
|
||||
/// An external function.
|
||||
FuncRef(FuncRef),
|
||||
/// A function call signature.
|
||||
@@ -402,6 +404,7 @@ impl fmt::Display for AnyEntity {
|
||||
Self::StackSlot(r) => r.fmt(f),
|
||||
Self::GlobalValue(r) => r.fmt(f),
|
||||
Self::JumpTable(r) => r.fmt(f),
|
||||
Self::Constant(r) => r.fmt(f),
|
||||
Self::FuncRef(r) => r.fmt(f),
|
||||
Self::SigRef(r) => r.fmt(f),
|
||||
Self::Heap(r) => r.fmt(f),
|
||||
@@ -452,6 +455,12 @@ impl From<JumpTable> for AnyEntity {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Constant> for AnyEntity {
|
||||
fn from(r: Constant) -> Self {
|
||||
Self::Constant(r)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FuncRef> for AnyEntity {
|
||||
fn from(r: FuncRef) -> Self {
|
||||
Self::FuncRef(r)
|
||||
|
||||
Reference in New Issue
Block a user