Explain code generation algorithm in compiler.