Add signatures and ext_funcs tables to DataFlowGraph.

These two tables are used to keep track of type signatures of function
calls as well as external function references used in direct function
calls.

Also add an ExtFuncData struct representing an external function that
can be called directly.
This commit is contained in:
Jakob Stoklund Olesen
2016-10-18 10:07:44 -07:00
parent bdc95990d4
commit 1bcb8e25a2
4 changed files with 41 additions and 3 deletions

View File

@@ -1,8 +1,9 @@
//! Data flow graph tracking Instructions, Values, and EBBs.
use ir::{Ebb, Inst, Value, Type};
use ir::{Ebb, Inst, Value, Type, SigRef, Signature, FuncRef};
use ir::entities::{NO_VALUE, ExpandedValue};
use ir::instructions::InstructionData;
use ir::extfunc::ExtFuncData;
use entity_map::{EntityMap, PrimaryEntityData};
use std::ops::{Index, IndexMut};
@@ -33,10 +34,19 @@ pub struct DataFlowGraph {
/// This is implemented directly with a `Vec` rather than an `EntityMap<Value, ...>` because
/// the Value entity references can refer to two things -- an instruction or an extended value.
extended_values: Vec<ValueData>,
/// Function signature table. These signatures are referenced by indirect call instructions as
/// well as the external function references.
pub signatures: EntityMap<SigRef, Signature>,
/// External function references. These are functions that can be called directly.
pub ext_funcs: EntityMap<FuncRef, ExtFuncData>,
}
impl PrimaryEntityData for InstructionData {}
impl PrimaryEntityData for EbbData {}
impl PrimaryEntityData for Signature {}
impl PrimaryEntityData for ExtFuncData {}
impl DataFlowGraph {
/// Create a new empty `DataFlowGraph`.
@@ -45,6 +55,8 @@ impl DataFlowGraph {
insts: EntityMap::new(),
ebbs: EntityMap::new(),
extended_values: Vec::new(),
signatures: EntityMap::new(),
ext_funcs: EntityMap::new(),
}
}