[llvm-dev] Subclassing LLVM Type

Jajoo, Malhar via llvm-dev llvm-dev at lists.llvm.org
Fri Jun 9 16:17:57 PDT 2017


Hi Tim,


Thanks for your reply.

I am just interested in having a dyn_cast functionality for my dummy type.
I do not care if it behaves as a type in any other way nor require LLVM
Backend to interact with it in any way.

The language that I want to compile is actually like this -


(bits(N)) test2(bits(N) x, bits(N) y)
{
bits(N) res = x EOR y;

// return result ( implciilty extended it - simple )
return res;

}


(integer) main()
{
bits(5) a= '01100';
bits(5) b= '01110';
// on seeing function call , we concretize the types
// in the function template above.
bits(5) d = test2(a,b);
print(d);
}

My current AST accepts a concrete type.
The part in red  is a non-concrete type.
I don't want to change my AST structure to accept a
non-concrete type.

Hence I wish to use a dummy class.
The code I showed earlier works but the
only issue is I need LLVM "dyn_cast".
Would changing the enum in the llvm::Type
class be enough ?

Thanks,
Malhar

________________________________
From: Tim Northover <t.p.northover at gmail.com>
Sent: Saturday, June 10, 2017 2:08:03 AM
To: Jajoo, Malhar
Cc: llvm-dev at lists.llvm.org
Subject: Re: [llvm-dev] Subclassing LLVM Type

On 9 June 2017 at 15:29, Jajoo, Malhar via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Thanks for that , I have read the documentation on this , but I would like to know
> if it would be the right thing to do , ie , changing the enum within llvm::Type

Well, I find the idea of a non-canonical DummyType slightly disturbing
(I don't think it's something we'd ever support officially). But you
might be able to make it work and if you need dyn_cast then modifying
that enum is about the only way to get it.

Do you know that there's such a thing as an "opaque type" in LLVM, by
the way? You haven't said what you need this DummyType for but it
might serve as a replacement. Basically you start off with an
unspecified struct type that you can then fill the details in for
later.

> and I'm slightly unclear on how I can update the C binding ?
> Can someone kindly clarify that ?

Can't help you there, I'm afraid. I've never used the C API and barely
looked at it.

Tim.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170609/2d83e7eb/attachment.html>


More information about the llvm-dev mailing list