-
Notifications
You must be signed in to change notification settings - Fork 35
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
BeMg
wants to merge
14
commits into
riscv-non-isa:main
Choose a base branch
from
BeMg:ifunc-runtime-resolver
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Commits on Dec 14, 2023
-
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
Configuration menu - View commit details
-
Copy full SHA for 204ad51 - Browse repository at this point
Copy the full SHA 204ad51View commit details -
Configuration menu - View commit details
-
Copy full SHA for dcec8fd - Browse repository at this point
Copy the full SHA dcec8fdView commit details -
Configuration menu - View commit details
-
Copy full SHA for 47e0f08 - Browse repository at this point
Copy the full SHA 47e0f08View commit details -
Configuration menu - View commit details
-
Copy full SHA for fd100e0 - Browse repository at this point
Copy the full SHA fd100e0View commit details -
Configuration menu - View commit details
-
Copy full SHA for b6f2891 - Browse repository at this point
Copy the full SHA b6f2891View commit details -
Configuration menu - View commit details
-
Copy full SHA for 98df3fe - Browse repository at this point
Copy the full SHA 98df3feView commit details -
Configuration menu - View commit details
-
Copy full SHA for bf841ba - Browse repository at this point
Copy the full SHA bf841baView commit details -
Configuration menu - View commit details
-
Copy full SHA for f44cf57 - Browse repository at this point
Copy the full SHA f44cf57View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6272992 - Browse repository at this point
Copy the full SHA 6272992View commit details
Commits on Feb 20, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 734255e - Browse repository at this point
Copy the full SHA 734255eView commit details
Commits on Feb 22, 2024
-
Configuration menu - View commit details
-
Copy full SHA for fe52a9d - Browse repository at this point
Copy the full SHA fe52a9dView commit details -
Configuration menu - View commit details
-
Copy full SHA for e947e6b - Browse repository at this point
Copy the full SHA e947e6bView commit details -
Configuration menu - View commit details
-
Copy full SHA for facc1e5 - Browse repository at this point
Copy the full SHA facc1e5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9a9fe83 - Browse repository at this point
Copy the full SHA 9a9fe83View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.