So based on your suggestion, I've sketched out the following interface:<div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><font class="Apple-style-span" face="'courier new', monospace">class TypeAnnotationMap {</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">public:</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  /** Create a new type annotation map with the specified name. */</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  static TypeAnnotation * create(StringRef name);</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br>

</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  /** Load a type annotation map from a module. */</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  static TypeAnnotation * load(Module * m, StringRef name);</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  </font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  /** Serialize this annotation map as a global variable in module 'm'.</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">      This will replace any pre-existing variable of the same name. */  </font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  void store(Module * m);</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  </font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  /** Return the name of this type annotation map. */</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  StringRef name() const;</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  </font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  /** Set the value of the annotation for the input type 'ty'. This replaces any</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">      pre-existing value associated with 'ty'. */</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  void put(const Type * ty, const Constant * val);</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  </font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  /** Get the value of the annotation for type 'ty'. */</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  const Constant * get(const Type * ty) const;</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  </font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  /** Remove any value associated with type 'ty'. */</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  void remove(const Type * ty);</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">};</font></div>

</div></blockquote><div><div><br></div><div>An example use would be as follows:</div><div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><font class="Apple-style-span" face="'courier new', monospace">// Create a new map</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">TypeAnnotationMap * aMap = TypeAnnotationMap::create("llvm.gc.root");</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br>

</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">// Add an entry to the map.</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">aMap->put(ty, data);</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">// Store as a global variable in a module</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">aMap->store(module)l</font></div></div></blockquote><div><div><br></div><div>Internally the class has a map of Type pointers to Constant pointers. To serialize the map, it converts the internal map to a list of types (which are represented as members of a struct), and a list of constants. It then creates a tuple whose first member is a NULL pointer to the struct type, and whose second member is a pointer to the list of constants. It creates a global variable in the module whose name is the name of the map, and sets it's initializer to be that tuple.</div>

<div><br></div><div>A module can have an arbitrary number of such maps, each with a different map name.</div><div><br></div>Does that sound about right?<br><div class="gmail_quote"><br></div><div class="gmail_quote">On Sun, Jul 10, 2011 at 11:59 AM, Renato Golin <span dir="ltr"><<a href="mailto:rengolin@systemcall.org">rengolin@systemcall.org</a>></span> wrote:</div>

<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 10 July 2011 19:47, Talin <<a href="mailto:viridia@gmail.com">viridia@gmail.com</a>> wrote:<br>


> However, I would imagine other uses for this facility. What this effectively<br>
> is "metadata for types", although unlike metadata nodes this data would be<br>
> immutable.<br>
<br>
</div>Hi Talin,<br>
<br>
The new type system allows you to name types and, if I got it rght,<br>
that's unique and immutable.<br>
<br>
You could use that fact, plus some metadata, to group your values and<br>
use one annotation per group.<br>
<br>
Should be easy to iterate through all values in a given function<br>
testing for a given (unique) type.<br>
<br>
cheers,<br>
<font color="#888888">--renato<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>-- Talin<br>
</div>