The actual source code for GCC is most available here:
https://gcc.gnu.org/svn.html
The software is available through SVN (subversion), a source code management system. This will be installed on many versions of Linux / UNIX, but if you are not on your platform, you can install the svn kit and then extract the source using the following command:
svn checkout svn://gcc.gnu.org/svn/gcc/trunk SomeLocalDir
GCC is complex and will have significant experience in understanding how an application really compiles into different architectures.
In short, GCC has three main components - front-end, mid-end, and back-end processing. The front processor has a language parsing component for understanding the syntax of languages ββ(e.g. C, C ++, Objective-C, etc.). The interface deconstructs the portable construct code, which is then transferred to the background computer for compilation into the target environment.
The middle part performs code analysis and optimization, trying to determine the priority of the code to generate the best result at the end of the complete process. Technically, optimization can occur anywhere in the process since patterns are detected during analysis.
The internal processor compiles the code into output format in the form of a tree (and not actually executable code). Based on the expected output, the "pseudo-code" is optimized for using registers, bit sizes, end values, etc. The final code is then generated during the build phase, which converts the internal code into machine executable instructions.
It is important to note that the compiler has many options for handling output formats, so you can create output for many architecture classes, usually out of the box. To cross-compile and assign compiler options, check this link:
https://gcc.gnu.org/install/configure.html