[LLVMdev] c-like language implementation using llvm

Ali Javadi aj14889 at yahoo.com
Sun Feb 3 17:55:08 PST 2013


Hi Sean,

>> Can I just utilize the i1 type? Is the
>> i1 type already used for something, and thus might create a conflict?
> 
> I think you are very confused. LLVM's types are meant to be used to
> represent *your* program :) They can't be "already used".

I am keeping all the types of C, and adding my new types. I thought that, for example, I can't map my new type to i32 because that's used for C integers. That's what I meant by already used. Am I missing something?

> 
>> 2) Can I use LLVM's intrinsic functions for my gates, something like
>> @llvm.NOT(i1 %val)? Would the fact that the implementation of these external
>> functions is not defined, create a problem in translation down to IR? I have
>> used Clang's "built-ins" in the front-end and that seems to do the job at
>> the parser level.
> 
> Again, I think you are confused. Just use the operations that are
> built into LLVM, such as
> <http://llvm.org/docs/LangRef.html#bitwise-binary-operations>. One
> slight point of confusion is that LLVM tries to be minimal so there is
> no NOT instruction; `NOT X` is represented as `XOR X, -1`. You
> probably won't need to add an intrinsic unless you are doing something
> _very_ exotic.
> 

That's a good point. However simple binary operations such as XOR are not the only ones I'll be using. I have the Toffoli Gate for example which takes in 3 operands:
http://en.wikipedia.org/wiki/Toffoli_gate
I guess I can use intrinsics for these things? If I do, can I leave its behavior undefined? I would like it to appear just with the name toffoli in the IR.

Thanks,
Ali
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130203/e7691633/attachment.html>


More information about the llvm-dev mailing list