Posts

Showing posts from March, 2025

Project Stage 1: Create a Basic GCC Pass

Image
After performed Lab4, at this stage we create a pass for the current development version of the GCC compiler which: Iterates through the code being compiled; Prints the name of every function being compiled; Prints a count of the number of basic blocks in each function; and Prints a count of the number of gimple statements in each function. Step 1: Prepare Environment I already have ~/SomeLocalDir: GCC source code directory                        ~/gcc-build-001: GCC build directory (where I ran configure).                        ~/gcc-test-001:Installation directory Step 2: Create a New GCC Pass Go to the GCC source directory: cd ~/SomeLocalDir/gcc Create my-pass.cc file: nano hxu_pass.cc #include "config.h" #include "system.h" #include "coretypes.h" #include "tree.h" #include "tree-pass.h" #include "cgraph.h" #include "function.h" #include "basic-block.h" #include "...

(Lab5) 64-Bit Assembly Language Lab

Image
In this lab, you will experiment with assembler on the x86_64 and aarch64 platforms. The code examples for this lab are available in the file  /public/spo600-assembler-lab-examples.tgz  on each of the  SPO600 Servers . Reminder:  to unpack a tar archive ( .tar ,  .tar.gz ,  .tgz , or similar file), use the  tar  command with the  x  (e x tract) and  f  (archive  f ilename) options; the  v  ( v erbose) option is also recommended:  cd ~ ; tar xvf /public/spo600-assembler-lab-examples.tgz Get Code Examples: AARCH64 we will see "spo600" folder after commands: cd ~ ; tar xvf /public/spo600-assembler-lab-examples.tgz Investigation: check Makefile: build the program and run the executable: analyze the assembly code hello.s: disassembly of the compiled hello binary, revealing its low-level machine instructions generated from hello.c: Compile hello.c to Assembly using gcc -S: cat hello.s: Create a loop.s for the loo...