[LLVMdev] How to extend llvm IR and frontend?

Jim Grosbach grosbach at apple.com
Fri Jan 21 08:59:53 PST 2011


The LLVM address space qualifiers will get you at least part of the way. I'd suggest starting your search there.

More generally speaking, note that in the front end you really want this sort of thing to be (syntactically) a type qualifier so you can support pointers back and forth between the address spaces in a natural way. You'll also want a generic pointer type (can reference any address space) to use for unqualified pointers. Otherwise you can't make a conformant C compiler.

-Jim

On Jan 21, 2011, at 7:32 AM, Aaron Myles Landwehr wrote:

> Hi all,
> 
> Hypothetically, suppose I have a generic system with multiple address spaces such that each address space is accessed using different instructions.
> 
> Now suppose, I wanted to add a new keywords 'foo' and 'bar' to the front of c variables and function return types such that the following would be valid:
> 
> foo void* a;
> foo void* somefunc(){...}
> bar int b;
> int somefunc2(bar int*){...}
> 
> Furthermore, if I wanted this keyword to be added as part of the LLVM IR in some manner such that the during the translation of LLVM IR to some target machine ASM it could be used to switch which address spaces are used (e.g. if I specify one of the keywords, I get some instruction or group of instructions to access a certain address space), what would be the correct/easiest place(s) to add this functionality, and would there be existing code that does something similar that can be used as a starting point?
> 
> More Info: suppose this uses clang as a frontend.
> 
> Thanks,
> Aaron Landwehr
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list