GCC questions

Mike Stump mrs@wrs.com
Tue Aug 3 17:35:00 GMT 1999


> Date: Tue, 3 Aug 1999 16:57:50 -0700 (PDT)
> From: Radu Cornea <radu@ics.uci.edu>

> 1. Is there a function to convert a tree representation to the equivalent
> rtx?

Yes, see expand_expr.

> 2. What functions are available for debugging (like printing the tree or
> rtx)?

Yes, see *debug* and print-*.c and .gdbinit

> 3. How can a code portion (a tree) be duplicated (this includes the
> creation of rtx and code generation)?

This question is way to vague for me to answer.  I know of dozens of
ways to duplicate things...  For example, one of my favorite ones is
unsave_expr, but this is just one type of duplication.

> 4. How can the last tree created be accessed?

?  This isn't what you want to do.  Or put another way, if you want to
do this, you don't have the right integration philosophy.

> 5. I am asking these questions because I need to solve this problem in gcc:
> in some cases, gcc transforms initial structured code into unstructured
> code. This happens for example for if statements that have as condition
> logical OR (||) or AND (&&) expressions. In order to generate structured
> code, the then-statement have to be duplicated (as many times as the number
> of ORs or ANDs). For this, i need to save somehow the then-statement tree
> when it is generated and duplicate it (and of course, the jumps need to be
> changed).

Ok, too bad you didn't say exactly what you wanted to do.  Sounds like
it is mostly outside the scope of compilation though.  We can give
better answers to your question, if the question is the right
question.  Tell us what you really want to do...

I think what you want is an full function ast, that preserves
constructs like if and while.  If that is it, then if you can use just
C++, then you might consider turning on the template code everywhere,
and munching on it instead.  In that style of code we preserve things
like:

DEFTREECODE (DECL_STMT, "decl_stmt", 'e', 3)
DEFTREECODE (IF_STMT, "if_stmt", 'e', 3)
DEFTREECODE (FOR_STMT, "for_stmt", 'e', 4)
DEFTREECODE (WHILE_STMT, "while_stmt", 'e', 2)
DEFTREECODE (DO_STMT, "do_stmt", 'e', 2)
DEFTREECODE (RETURN_STMT, "return_stmt", 'e', 1)
DEFTREECODE (BREAK_STMT, "break_stmt", 'e', 0)
DEFTREECODE (CONTINUE_STMT, "continue_stmt", 'e', 0)
DEFTREECODE (SWITCH_STMT, "switch_stmt", 'e', 2)
DEFTREECODE (GOTO_STMT, "goto_stmt", 'e', 1)

directly, and you can the walk that code and do what you want.  But
since I don't know what you want to do, I don't know if this is a
solution to what you want to do.


More information about the Gcc mailing list