<div dir="ltr">I think your only option is to modify clang itself (someone will correct me if I'm wrong). It's probably best to choose a different spelling for your keyword as 'short' is already reserved and can appear in so many contexts. Seeing short short* would be so confusing :)</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 8, 2014 at 12:52 PM, mobi phil <span dir="ltr"><<a href="mailto:mobi@mobiphil.com" target="_blank">mobi@mobiphil.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi@ one of the most interesting mailing lists in IT :)</div><div><br></div><div>as stated in the subject, would like to implement a new keyword short in the context of pointer declaration.</div><div><br></div><div>short Object* object = new Object(); <br></div><div><br></div><div>The objective is to implement some sort of 64 bit pointer compression that will have some additional benefits. Related to the topic I also started a thread on llvm mailing list.</div><div><br></div><div>So what should happen behind? A custom new operator (name could change accordingly) would allocate memory from the active segment, but would return only a 32 bit offset inside a 4GB adressable segment. The segment address would be kept either as a thread local storage, register, or as method argument) </div><div><br></div><div>class MyObject {</div><div>    public:</div><div>      short Object *mainObject;<br></div><div>      vector<short Object*> children(10000);</div><div> };<br></div><div><br>not necessarily extreme example but suddenly my MyObject object would save a significative amount of memory.</div><div><br></div><div>All references to the members should be as with normal pointers:</div><div><br></div><div>short MyObject *myObject = new MyObject();</div><div>short Object*  object = myObject->mainObject;</div><br clear="all"><div>Of course there should be some glue code that will glue the factory method for new and will manage the segment address.</div><div><br></div><div>Besides pointer compression, what other advantages? Data would be position independent. This means that:</div><div><br></div><div>-> data from segments (segments can be smaller than 4GB) can be saved and loaded at any address. Interesting candidate for some fast in/out memory database.</div><div>-> data from segments can be equally easily shared and accessed between processes through mmap  (pointer semantics would not change)<br></div><div><br></div><div><br></div><div>After this short story I wonder what would be the easiest way to implement this as an extension to clang infra for C++ parsing. I saw that there were some threads from 2011 about plugins, but nothing afterwards can be found. </div><div><br></div><div>any hints would be more than wellcome</div><div><br></div><br><div>rgrds,<br>mobi phil<br><br>being mobile, but including technology<br><a href="http://mobiphil.com" target="_blank">http://mobiphil.com</a></div>
</div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>