[cfe-dev] Adding memory spaces to types

Christopher Lamb christopher.lamb at gmail.com
Sat Nov 10 01:59:45 PST 2007


I've been playing around with clang/LLVM looking at adding partial  
support for the draft technical report for embedded C extensions  
(TR18037, http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf),  
in particular: memory spaces. It's been fairly simple to thread  
memory space ID's through LLVM so far, but I'm new to FE's and the  
language from the TR has left me wondering about the best way to  
implement this in clang. From TR18037:

Clause 6.2.5 - Types, replace the second sentence of paragraph 25 with:

Each unqualified type has several qualified versions of its type,38)  
corresponding to the combinations
of one, two, or all three of the const, volatile, and restrict  
qualifiers, and all combinations
of any subset of these three qualifiers with one address space  
qualifier.  (Syntactically, an address
space qualifier is an address space name, so there is an address  
space qualifier for each visible
address space name.)

The question I have is, how to track this info without adding memory  
space id's to QualType, which seems
(1) infeasible given the implementation of QualType as a smart  
pointer with only a few bits for additional data, and
(2) would loose the performance benefit of the current QualType  
implementation (and thus the whole purpose of QualTypes existence, it  
seems) if QualType were made extensible.

My first thought was to create a new Type subclass called  
MemSpacedType that would essentially just be used to store the memory  
space ID in addition to the QualType of the underlying type. Is this  
the way to go? I'm deep in new territory and need some seasoned advice.

Thanks
--
Christopher Lamb



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20071110/12a6a1a0/attachment.html>


More information about the cfe-dev mailing list