Factor out common ways to call encode from a dfg or func.

This commit is contained in:
Dan Gohman
2018-03-26 21:54:36 -07:00
parent ffe89cdc0a
commit a661a8a9bb
4 changed files with 18 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
//! Data flow graph tracking Instructions, Values, and EBBs.
use entity::{PrimaryMap, EntityMap};
use isa::TargetIsa;
use isa::{TargetIsa, Encoding, Legalize};
use ir;
use ir::builder::ReplaceBuilder;
use ir::extfunc::ExtFuncData;
@@ -645,6 +645,12 @@ impl DataFlowGraph {
self.value_type(self.first_result(inst))
}
}
/// Wrapper around `TargetIsa::encode` for encoding an existing instruction
/// in the `DataFlowGraph`.
pub fn encode(&self, inst: Inst, isa: &TargetIsa) -> Result<Encoding, Legalize> {
isa.encode(&self, &self[inst], self.ctrl_typevar(inst))
}
}
/// Allow immutable access to instructions via indexing.