[LLVMdev] c-like language implementation using llvm

Sean Silva silvas at purdue.edu
Sun Feb 3 18:04:03 PST 2013


On Sun, Feb 3, 2013 at 8:55 PM, Ali Javadi <aj14889 at yahoo.com> wrote:
> 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?

If the type behaves like an i32 then use i32. For example, both signed
and unsigned int get lowered to i32.

> 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.

Just create the equivalent IR for the operation that the gate does;
that will give LLVM the ability to optimize the operations. If you use
an intrinsic, then LLVM won't be able to optimize the IR unless you
change the optimization passes to recognize the intrinsic (and even
then, the optimizations probably won't be as good).

-- Sean Silva



More information about the llvm-dev mailing list