[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.
Hsiangkai Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 12 18:53:56 PDT 2021
HsiangKai added inline comments.
================
Comment at: clang/lib/Sema/SemaLookup.cpp:923
+
+ const RVVIntrinsicInfo *Intrinsic = std::find_if(
+ std::begin(RVVIntrinsicInfos), std::end(RVVIntrinsicInfos),
----------------
kito-cheng wrote:
> rogfer01 wrote:
> > Not for this patch: I think this table may be a bit large so all lookups (including those that will fail) will be slower after a `#pragma riscv intrinsic vector` is found.
> >
> > Filtering them as fast as possible (looking at the spec shows that currently all RVV intrinsics start with `v`) or using some hash table (if too difficult to build at compile time we could build it the first time we get here?) might be something we want to do.
> OpenCL using a tablegen-based generator to generate a big swtich table to speed up the lookup rather than linear scan, here is generated file:
>
> https://gist.github.com/kito-cheng/46616c82c0f25e5df31ff5eaa14914ba#file-openclbuiltins-inc-L8055
>
> I think we could using same approach to prevent the slow down.
Indeed, OpenCL generates a checking function, `isOpenCLBuiltin`, as the filter. I will use the similar approach to filter the queries.
================
Comment at: clang/lib/Sema/SemaLookup.cpp:1011
+ if (PP.getPredefines() == "#define __riscv_pragma_vector_intrinsics") {
+ const TargetInfo &TI = Context.getTargetInfo();
----------------
rogfer01 wrote:
> This seems a bit fragile if there are more predefines than just this one. I understand the intent is to avoid looking up the RVV builtin every time, only do that if we have found the pragma, right?
>
> Several pragma handlers receive a reference to `Sema` (in an object called `Action` or `Actions`) and then they notify `Sema` (via a member function that would have to be added to it) about having parsed the pragma. That could be used to set some flag to true in `Sema` itself and also emit diagnostics if we want (e.g. what if the pragma is used twice? can it be used anywhere?).
>
> Do you think this would be workable?
I should add a flag somewhere as the checking condition. I will try to find a better way to do it. Thanks for your suggestion. I think it is workable.
The purpose of the pragma is to enable the lazily insertion. If users do not include `riscv_vector.h` and they use `vadd` as the function call, we will not treat it as a vector generic intrinsic.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111617/new/
https://reviews.llvm.org/D111617
More information about the llvm-commits
mailing list