Implement a conversion from ValueDef into ProgramPoint.

A ValueDef is really no more than a program point plus an
argument/result number.
This commit is contained in:
Jakob Stoklund Olesen
2017-06-07 11:33:47 -07:00
parent 9adfd8709b
commit dcdfa59aec

View File

@@ -1,7 +1,7 @@
//! Program points. //! Program points.
use entity_map::EntityRef; use entity_map::EntityRef;
use ir::{Ebb, Inst}; use ir::{Ebb, Inst, ValueDef};
use std::fmt; use std::fmt;
use std::u32; use std::u32;
use std::cmp; use std::cmp;
@@ -32,6 +32,15 @@ impl From<Ebb> for ProgramPoint {
} }
} }
impl From<ValueDef> for ProgramPoint {
fn from(def: ValueDef) -> ProgramPoint {
match def {
ValueDef::Res(inst, _) => inst.into(),
ValueDef::Arg(ebb, _) => ebb.into(),
}
}
}
/// An expanded program point directly exposes the variants, but takes twice the space to /// An expanded program point directly exposes the variants, but takes twice the space to
/// represent. /// represent.
#[derive(PartialEq, Eq, Clone, Copy)] #[derive(PartialEq, Eq, Clone, Copy)]