Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function multi-version proposal #48

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Commits on Dec 14, 2023

  1. Function multi-version proposal

    During the Function multi-version dispatch the function, we need a method to retrieve the RISC-V hardware environment to make sure all extension must be available.
    
    The problem is
    
    * How to implement this function
    * Where to provide this function
    
    From the compiler's view, it will generate the IFUNC resolver when there are more than one implementation with the same symbol name.
    
    Consider following example:
    
    ```
    __attribute__((target("default"))) int foo (int index)
    {
      return index;
    }
    
    __attribute__((target("arch=rv64gc"))) int foo (int index)
    {
     return index;
    }
    
    void bar() {
      foo(0);
    }
    ```
    
    The corresponding assembly will look like:
    
    ```
    bar() {
    (foo.ifunc())(0);
    }
    
    .set foo.ifunc, foo.resolver
    
    func_ptr foo.resolver() {
      if (__riscv_ifunc_select("m_a_f_d_c"))
        return ptr foo.m_a_f_d_c;
      return ptr foo.default;
    }
    
    int foo.default(int index) {
    	...
    }
    
    int foo.m_a_f_d_c(int index) {
    	...
    }
    ```
    
    The resolver that the compiler generates query and selects for each candidate function. When fulfilling the requirement, then return the corresponding function ptr for further processing.
    
    In this proposal, the major part of the resolver function is `__riscv_ifunc_select`. `__riscv_ifunc_select` must retrieve the hardware information for deciding whether to execute the specific function.
    
    Here we propose that function as the following declaration
    
    ```
    bool __riscv_ifunc_select(char *FeatureStr);
    ```
    
    Where FeatureString is a string that concatenates all target features belonging to a particular function. The form can be described in the following BNF form.
    
    When hardware fulfills the FeatureStr, then returns true. Otherwise this function returns false.
    
    There are two ways to retrieve hardware information.
    
    * RISC-V Hardware Probing Interface [1]
    ** Not fully cover all extensions, and need to sync the all defined symbol from linux kernel source code.
    * /proc/cpuinfo isa string
    ** Not every system has the cpuinfo file.
    
    Another problem is where to place the function definition.
    
    The compiler-rt/libgcc is a good place to implement these functions, like other target(x86/aarch64) implementation.
    
    [1] https://docs.kernel.org/riscv/hwprobe.html
    BeMg committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    204ad51 View commit details
    Browse the repository at this point in the history
  2. Remove platform specific content

    BeMg committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    dcec8fd View commit details
    Browse the repository at this point in the history
  3. Add function mangling section

    BeMg committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    47e0f08 View commit details
    Browse the repository at this point in the history
  4. Address craig's comment

    BeMg committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    fd100e0 View commit details
    Browse the repository at this point in the history
  5. Add target_clones section

    BeMg committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    b6f2891 View commit details
    Browse the repository at this point in the history
  6. Support target_version

    BeMg committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    98df3fe View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    bf841ba View commit details
    Browse the repository at this point in the history
  8. Remove function mangling section

    BeMg committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    f44cf57 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    6272992 View commit details
    Browse the repository at this point in the history

Commits on Feb 20, 2024

  1. Improve grammar

    BeMg committed Feb 20, 2024
    Configuration menu
    Copy the full SHA
    734255e View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2024

  1. Configuration menu
    Copy the full SHA
    fe52a9d View commit details
    Browse the repository at this point in the history
  2. Update exapmle

    BeMg committed Feb 22, 2024
    Configuration menu
    Copy the full SHA
    e947e6b View commit details
    Browse the repository at this point in the history
  3. Remove FMV implement part stuff

    BeMg committed Feb 22, 2024
    Configuration menu
    Copy the full SHA
    facc1e5 View commit details
    Browse the repository at this point in the history
  4. Rewrite FMV's section

    BeMg committed Feb 22, 2024
    Configuration menu
    Copy the full SHA
    9a9fe83 View commit details
    Browse the repository at this point in the history