[LLVMdev] LLVM IR Type System Rewrite

Chris Lattner clattner at apple.com
Sun Feb 27 11:53:48 PST 2011


On Feb 27, 2011, at 2:42 AM, Jan Sjodin wrote:

> With the named/unnamed/anonymous distinctions there seems to be two things going 
> on:
> 1. Giving an ID to a struct type.
> 2. Naming a type for readability.
> 
> Would the new system force anonymous structs to be printed inline at every 
> occurrence?

Yes, but I don't expect them to be commonly used.  Things like complex numbers and simple tuples in a frontend might want to use them, but the frontend could always choose to name them as well.

I strongly considered just making all struct types have an "identity", thus eliminating anonymous types.  This is effectively what we get in the .ll printer today, but it is a nuisance for simple pairs - like multi-return intrinsics.  It still may not be worth the complexity to have them.

> The code might become hard to read with large anonymous types. Would 
> it make sense to have both ID and Name? If a type has a name it could be printed 
> using that. Perhaps there could be an extension to indicate that a type has an 
> ID (something like "%'foo" vs. "%foo"). When printing with -strip any type with 
> an ID (maybe a number) would be printed using the ID and a type without ID would 
> have to be printed inline.

I think the problem is solved by having frontend authors not generate types that are hard to read.

> My opinion about the syntax is that if there is a semantic difference  between 
> two types it should be very clear in the syntax (maybe a "'" isn't clear 
> enough). In my mind, naming  things in LLVM is used more for convenience  or 
> readability, rather than specifying semantics.

Fair point,

-Chris



More information about the llvm-dev mailing list