hoist some funky logic into CodeGenInstruction