One thing to consider... Just because the compiler could be in the kernel, doesn't mean it has to be.
One could envision a hotplug/modprobe like helper program that the kernel executes when it wants to translate from one encoding (say p4) to another (say [e]bpf). This keeps complexity (compiler) out of the kernel, while still allowing us to have the illusion of only one interface to sw/hw. And it has the nice benefit of allowing us to use existing compiler toolchains...