Adding an intrinsic that the user can include in source code

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding an intrinsic that the user can include in source code

Alex Denisov via cfe-dev
I would like to add an intrinsic that the user can put in their code.
The intrinsic is for sending, ala MPI, a value to another processor.
I have read the short document,
https://llvm.org/docs/ExtendingLLVM.html, about adding intrinsics but
must be missing something because it doesn't mention changing anything
in clang.  I added my intrinsic to
llvm/include/llvm/IR/IntrinsicsX86.td, then I added it to
clang/include/clang/Basic/BuiltinsX86.def.  When I compile my code I get:

send.c:14:3: error: cannot compile this builtin function yet
  __builtin_uli_send0(1, 0, &incr);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The AST has information about my intrinsic and the parameters, but not
sure how to proceed.

What am I missing?


--------------
Seth Copen Goldstein
Carnegie Mellon University
Computer Science Dept
7111 GHC
412-268-3828

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Adding an intrinsic that the user can include in source code

Alex Denisov via cfe-dev

I suspect that you almost certainly need to also implement a handler for this in the function ‘CodeGenFunction::EmitX86BuiltinExpr’ in:

 

tools/clang/lib/CodeGen/CGBuiltin.cpp

 

All the best,

 

MartinO

 

From: cfe-dev [[hidden email]] On Behalf Of Seth Goldstein via cfe-dev
Sent: 31 October 2017 22:20
To: [hidden email]
Subject: [cfe-dev] Adding an intrinsic that the user can include in source code

 

I would like to add an intrinsic that the user can put in their code.

The intrinsic is for sending, ala MPI, a value to another processor.

I have read the short document,

https://llvm.org/docs/ExtendingLLVM.html, about adding intrinsics but

must be missing something because it doesn't mention changing anything

in clang.  I added my intrinsic to

llvm/include/llvm/IR/IntrinsicsX86.td, then I added it to

clang/include/clang/Basic/BuiltinsX86.def.  When I compile my code I get:

 

send.c:14:3: error: cannot compile this builtin function yet

  __builtin_uli_send0(1, 0, &incr);

  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

The AST has information about my intrinsic and the parameters, but not

sure how to proceed.

 

What am I missing?

 

 

--------------

Seth Copen Goldstein

Carnegie Mellon University

Computer Science Dept

7111 GHC

412-268-3828


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Adding an intrinsic that the user can include in source code

Alex Denisov via cfe-dev
Keep in mind that if your intrinsic has an obvious direct mapping to the builtin you're exposing, you can just write your intrinsic in a way that it inherits from GCCBuiltin. That will avoid having to add custom lowering in CGBuiltin.cpp. There should be plenty of examples of that in the include/llvm/IR/IntrinsicsX86.td file that you already modified.


On Tue, Oct 31, 2017 at 11:56 PM, Martin J. O'Riordan via cfe-dev <[hidden email]> wrote:

I suspect that you almost certainly need to also implement a handler for this in the function ‘CodeGenFunction::EmitX86BuiltinExpr’ in:

 

tools/clang/lib/CodeGen/CGBuiltin.cpp

 

All the best,

 

MartinO

 

From: cfe-dev [[hidden email]] On Behalf Of Seth Goldstein via cfe-dev
Sent: 31 October 2017 22:20
To: [hidden email]
Subject: [cfe-dev] Adding an intrinsic that the user can include in source code

 

I would like to add an intrinsic that the user can put in their code.

The intrinsic is for sending, ala MPI, a value to another processor.

I have read the short document,

https://llvm.org/docs/ExtendingLLVM.html, about adding intrinsics but

must be missing something because it doesn't mention changing anything

in clang.  I added my intrinsic to

llvm/include/llvm/IR/IntrinsicsX86.td, then I added it to

clang/include/clang/Basic/BuiltinsX86.def.  When I compile my code I get:

 

send.c:14:3: error: cannot compile this builtin function yet

  __builtin_uli_send0(1, 0, &incr);

  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

The AST has information about my intrinsic and the parameters, but not

sure how to proceed.

 

What am I missing?

 

 

--------------

Seth Copen Goldstein

Carnegie Mellon University

Computer Science Dept

7111 GHC

<a href="tel:(412)%20268-3828" value="+14122683828" target="_blank">412-268-3828


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev