According to the Assembly language reference: "In LLVM, opaque types can eventually be resolved to any type (not just a structure type)." But the only way I can think of to do so is to give it a type name, then later redeclare the name. But that gives an error: %TO = type opaque %TF = type i32 ( %TO* ) %TO = type %TF gives: $ llvm-as types1.ll llvm-as: types1.ll:3:1: error: redefinition of type %TO = type %TF ^ Also, what is the set of things that can be done with an as-yet unresolved opaque type? -- Rodney Bates rodney.m.bates at acm.org
In the textual form of LLVM IR, forward references are legal, so you shouldn't need this kind of redeclaration. You example could be: %TF = type i32 (%TO*) %TO = type %TF However, llvm-as rejects it with "error: forward references to non-struct type", but that's a different issue. On Sun, Feb 22, 2015 at 10:31 AM, Rodney M. Bates <rodney_bates at lcwb.coop> wrote:> According to the Assembly language reference: "In LLVM, opaque types can > eventually be resolved to any type (not just a structure type)." But > the only way I can think of to do so is to give it a type name, then > later redeclare the name. But that gives an error: > > %TO = type opaque > %TF = type i32 ( %TO* ) > %TO = type %TF > > gives: > > $ llvm-as types1.ll > llvm-as: types1.ll:3:1: error: redefinition of type > %TO = type %TF > ^ > > Also, what is the set of things that can be done with an as-yet unresolved > opaque type? > > > > -- > Rodney Bates > rodney.m.bates at acm.org > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150223/1d9d3fdd/attachment.html>
On 02/23/2015 01:43 PM, Reid Kleckner wrote:> In the textual form of LLVM IR, forward references are legal, so you shouldn't need this kind of redeclaration. You example could be: > %TF = type i32 (%TO*) > %TO = type %TF > > However, llvm-as rejects it with "error: forward references to non-struct type", but that's a different issue. >Thanks, that helps. I am seeing some of this now by doing experiments with handwritten IR assembly. It looks like I will have to artificially wrap some types in a one-member struct.> On Sun, Feb 22, 2015 at 10:31 AM, Rodney M. Bates <rodney_bates at lcwb.coop <mailto:rodney_bates at lcwb.coop>> wrote: > > According to the Assembly language reference: "In LLVM, opaque types can > eventually be resolved to any type (not just a structure type)." But > the only way I can think of to do so is to give it a type name, then > later redeclare the name. But that gives an error: > > %TO = type opaque > %TF = type i32 ( %TO* ) > %TO = type %TF > > gives: > > $ llvm-as types1.ll > llvm-as: types1.ll:3:1: error: redefinition of type > %TO = type %TF > ^ > > Also, what is the set of things that can be done with an as-yet unresolved > opaque type? > > > > -- > Rodney Bates > rodney.m.bates at acm.org <mailto:rodney.m.bates at acm.org> > _________________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/__mailman/listinfo/llvmdev <http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev> > >-- Rodney Bates rodney.m.bates at acm.org