> You need to have _precise_ mapping between types in compiler and the language you implement.
No. You don't need that. You can treat your data however you want until you place it into the final binary. Before that, you can even treat all your numbers as strings if you really want to. If you need some constant expression evaluation, you just have to replicate the target machine's math operations in software - no magic involved here. As long as you get the right result, noone cares what you do internally.
If your compilation machine == target machine, you can even construct a function that calculates the expression and actually run it to get the result.
When you make optimization you need to do intermediate calclulation _exactly_ the same way the target machine does.
Even if the number is ascii or unicode string, you need to do the computations strictly same way s target machine does, otherwise you'd break assumptions of the programmer, and lead to unreproducible code.
Comments
> You need to have _precise_ mapping between types in compiler and the language you implement.
No. You don't need that. You can treat your data however you want until you place it into the final binary. Before that, you can even treat all your numbers as strings if you really want to. If you need some constant expression evaluation, you just have to replicate the target machine's math operations in software - no magic involved here. As long as you get the right result, noone cares what you do internally.
If your compilation machine == target machine, you can even construct a function that calculates the expression and actually run it to get the result.
When you make optimization you need to do intermediate calclulation _exactly_ the same way the target machine does. Even if the number is ascii or unicode string, you need to do the computations strictly same way s target machine does, otherwise you'd break assumptions of the programmer, and lead to unreproducible code.