Merge "x86/x86-64: Simplify codegen using helper functions."