Project Progress update 1.1

 So far I have spent lots of time researching and trying to understand how I can update the GCC code to accept another value target_clonse (in this case, we're aiming to add arch to the compiler). So far I have come to a few understanding and now I'm trying to identify where I can put my code in to update the compiler. However, this comes with lot of trials and errors. As the result, I will sum up both my understanding and what I have tried and failed so far

March vs Mtune

This one first confused me a lot. I didn't know the differences between the two. Turn out, -march is for a specific CPU architecture and -mtune is used when we want the program to run on all CPUs, but the compiler would choose those algorithms and functions that benefits the defined architecture

Aarch64 march vs x86_64 march

Although they use the same syntax, each GCC version for the specified architecture has a different range of values. Based on what I understand right now, it seems like in x86_64, you can specify an architecture for the compiler but in Aarch64, you can only specify some micro architectures. However, my research for this topic stopped here as I have a different research direction.

Failed attempts to understand/updating the codes

This will be a list of methods and stuff I checked so far to understand what I can do to add values to target_clones and invoke functions from -march. I believe I'm not that smart to create my own functions and there are already some functions out there that perform the tasks that I want (-march already exists meaning I just need to somehow group values and trigger all functions relating to those values)

This is my testing program:
#include <stdio.h>

// Function definition with target_clones attribute
void hello_world() __attribute__((target_clones("default", "simd")));

// Implementation of hello_world function
void hello_world() {
    printf("Hello, World!\n");
}

int main() {
    // Call the hello_world function
    hello_world();
    return 0;
}

Checked the code with objdump

After compiling data, I tried to run objdump -d ./hello to see the assembly code, and although I do see two versions (.default and .Msimd), I couldn't find the underlying functions that trigger the multi versioning process.

Checked the code with -fdump-rtl-expand

I also ran this one gcc -fdump-rtl-expand helloworld.c to produce a file with the same intention like above. However, after looking at the code, I have no idea what was going on, so I decided to move on.

Had a chat with GPT

I had some conversations with this guy to understand how it works and how I can develop GCC. Although it suggested some good files to look into such as /doc/options.texi (I thought this was where they added default values, turned out it is just a text file), gcc/c-family/c-attribs.cc which I found the definition of the static tree handle_target_clones_attribute (tree *, tree, tree, int, bool *); function which I would need to investigate more. However, it suggested to me a lot that I shouldn't change anything which is quite annoying.

Google search for something similar

I tried to search for the person professor mentioned that had done something similar in x86_64. However, searching for anything relates to GCC modification proved to be difficult. It is as if nobody want to update or tinker with the GCC compiler at all

Current progress

Currently I'm checking the gcc.cc file as well as reading the documentation. My goals are to find the functions that get invoked in the front-end and learn how to add additional values to 

Comments

Popular posts from this blog

Project update 1.2

How to get multiple inputs from the emulator

Lab 2 - Letter guessing game