[cfe-dev] Target-specific AST rewriting (clang)

Eli Friedman via cfe-dev cfe-dev at lists.llvm.org
Mon Mar 9 14:42:09 PDT 2020


I'm not sure I follow what you mean.  Do you mean that given, for example "float x; __builtin_foo(-x);", you call "llvm.foo(-x)", and given "double x; __builtin_foo((float)-x)", you call "llvm.bar(-x)"?  I don't think there's any precedent for that, no; normally that's the sort of optimization you'd handle in instcombine.

-Eli

> -----Original Message-----
> From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of Krzysztof
> Parzyszek via cfe-dev
> Sent: Monday, March 9, 2020 12:57 PM
> To: cfe-dev at lists.llvm.org
> Subject: [EXT] [cfe-dev] Target-specific AST rewriting (clang)
>
> Hi,
>
> There are some type casts that should be replaced with intrinsics (this is
> Hexagon-specific). Those only occur in calls to Hexagon builtins, and right now
> this replacement happens as a part of clang's codegen.
> However, this replacement is only triggered by types in the AST and the
> corresponding types in the LLVM IR, and is not dependent on the details
> (semantics) of any particular builtin, so I'd like to make it orthogonal to the
> cgbuiltin code that deals with specific intrinsics. I'd like the replacement to
> transform AST->AST, so the result can be easily composed with any code that
> does AST->LLVM IR.
>
> Is there a precedent for something like this?  I could do this right at the
> beginning of EmitHexagonBuiltinExpr, but I was wondering if there was a better
> way.
>
> --
> Krzysztof Parzyszek  kparzysz at quicinc.com   AI tools development
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


More information about the cfe-dev mailing list