Packet forwarding in Software-Defined Networks (SDN) relies on a centralized network controller, which enforces network policies expressed as forwarding rules. Rules are deployed as sets of entries into the tables of network devices. Deploying them onto heterogeneous set of devices is strongly bounded by the respective table constraints (size, lookup time, etc.) and forwarding pipelines. Hence, it is important to minimize the overall number of entries in order to both reduce resource consumption and speed up the search. Moreover, since multiple control plane applications (e.g. different tenants) can deploy their own rules, rule conflicts may occur. To avoid such conflicts and ensure overall correctness, a rule validation mechanism is required. We focus in this project on a compression mechanism for rules of diverging origins that minimizes the number of entries. Since it exploits the semantics of rules and entries, our compiler fits a heterogeneous landscape of network devices. We are aiming to evaluate our idea by implementing the compiler for both software and hardware switches on a realistic testbed.