[WIP] code generation refactor

This PR is based the llvmlite2 branch. My aim was to factor out the code generation machinery from the target context and into a separate facility. CUDA is probably broken as I don't have a device to test (yet).
add_module() should really be after the link_in().  I don't see any error when I swap the order.  I wonder if something else is causing the error.