Refactoring to enable future plans.

- Function is now in its own header, because it's about to get a bunch
  more complicated.
- Generic IR functions + trampoline generation moved out to a base
  class. We're going to need this separately from the main IR generation
  soon.