From dcdfa59aec756ddf2d64d42f912357bd601b4d1b Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Wed, 7 Jun 2017 11:33:47 -0700 Subject: [PATCH] Implement a conversion from ValueDef into ProgramPoint. A ValueDef is really no more than a program point plus an argument/result number. --- lib/cretonne/src/ir/progpoint.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/cretonne/src/ir/progpoint.rs b/lib/cretonne/src/ir/progpoint.rs index 7d57ab8cb9..c99e79dbe6 100644 --- a/lib/cretonne/src/ir/progpoint.rs +++ b/lib/cretonne/src/ir/progpoint.rs @@ -1,7 +1,7 @@ //! Program points. use entity_map::EntityRef; -use ir::{Ebb, Inst}; +use ir::{Ebb, Inst, ValueDef}; use std::fmt; use std::u32; use std::cmp; @@ -32,6 +32,15 @@ impl From for ProgramPoint { } } +impl From 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 /// represent. #[derive(PartialEq, Eq, Clone, Copy)]