[llvm-dev] Subclassing LLVM Type
Jajoo, Malhar via llvm-dev
llvm-dev at lists.llvm.org
Sat Jun 10 10:33:22 PDT 2017
Hi,
I need to create a template function after parsing the following.
Later on seeing a fucntion call I concretize the types.-
( bits(N)) test ( bits(5) x , bits(M) y)
{
bits(N) x = x EOR y ;
}
Let's say I manage to implement "classof" correctly
and dyn_cast<> works.
An issue that I think may be possible would be that I would
not be able to distinguish between "N" and "M"
here. I mean LLVM uses immutable types , and the llvm::Type
file mentions that I will need to modify llvm::Type::getPrimitiveType()
to return my new type , and there can only be a single instance.
If I am required to distinguish between "N" and "M" , I need to dyn_cast
and there must be more than one instance of my Type.
Thanks,
Malhar
________________________________
From: Tim Northover <t.p.northover at gmail.com>
Sent: Saturday, June 10, 2017 2:23:35 AM
To: Jajoo, Malhar
Cc: llvm-dev at lists.llvm.org
Subject: Re: [llvm-dev] Subclassing LLVM Type
On 9 June 2017 at 16:17, Jajoo, Malhar via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I don't want to change my AST structure to accept a
> non-concrete type.
That sounds like a hack to me. If it's expected to convey no actual
information what about an llvm::Optional, or even the dreaded nullptr?
A Type that's sort of valid sometimes but not really seems like the
worst of all possible worlds.
> Would changing the enum in the llvm::Type
> class be enough ?
No, you'd also have to implement "classof" in your DummyType.
Cheers.
Tim.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170610/90b18150/attachment.html>
More information about the llvm-dev
mailing list