def __init__(self, from_, to, type_ = Dependency.CONTROL_FLOW, action_set = None): self.from_ = from_ self.to = to # type is not resolved when we add the dependency, but later, when # rmt_table_graph.resolve_dependencies() is called explicitely self.type_ = type_ # added to support predication. The action fields are no longer # associated with a table (parent table, i.e. from), but with the # dependency (or edge) itself. self.action_set = action_set self.action_fields_read = set() self.action_fields_write = set() self.action_fields = set() # special "hit" "miss" case if action_set and ("hit" in action_set or "miss" in action_set): (self.action_fields_read, self.action_fields_write, self.action_fields) = self.from_.get_action_fields() elif action_set: for action in action_set: r, w, a = retrieve_from_one_action(action) self.action_fields_read.update(r) self.action_fields_write.update(w) self.action_fields.update(a) # fields that induce the dependency self.fields = {}
def _retrieve_action_fields(self): for action in self.p4_table.actions: r, w, a = retrieve_from_one_action(action) self.action_fields_read.update(r) self.action_fields_write.update(w) self.action_fields.update(a)