On Aug 19, 2012, at 3:50 PM, João Matos wrote:
> I am creating my own mangler instance. The problem is that it takes an AST 
> context, which has it's own CXXABI object, and it can't be changed.
> 
> And you are right, it's probably not correct under all the circumstances, 
> I'll change my code to make an AST for each different ABI. I had not 
> remembered about template parameters, that is a good reason.
> 
> By the way, is there any reason ABI dependent stuff could not be abstracted 
> from the actual AST? It just feels wasteful to have to parse code twice to 
> get layout and mangling information.

A couple reasons.

The first is that there are some places — like template arguments — where 
constant folding is absolutely vital to the operation of the compiler:  it 
could affect whether two types are the same, what members a template 
specialization has, whether the program's even well-formed, etc.  So some parts 
of the AST would have to be target-dependent, full stop.

The second is that C's conditional compilation model makes it very challenging 
to re-use work between compilations with different targets.  There'd be a lot 
of assumptions you'd have to re-check in order to reuse the supposedly 
target-independent results of a previous compilation.

The third is that, in a project with N source files and M targets, it is almost 
guaranteed that N will be far larger than M.  That makes it much more valuable 
to eliminate redundant work with the same *target* than to reduce redundant 
work with the same *file*.

Finally, any attempt to preserve the target-independence of the AST would 
encumber interesting optimizations like caching the results of constant 
folding;  they wouldn't be impossible, but they'd have to involve more special 
cases and more side-tables, all to serve the relatively uncommon case that we 
could actually usefully re-use parts of an AST across targets.

John.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to