From: "Iyer, Balaji V" <balaji.v.iyer@intel.com>
To: niXman <i.nixman@gmail.com>, "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: RE: The AST tree modification. Edited.
Date: Tue, 04 Oct 2011 20:50:00 -0000 [thread overview]
Message-ID: <2950715866004049A240A2F9BB410E7315F416F5E7@azsmsx502.amr.corp.intel.com> (raw)
In-Reply-To: <CAMPTgK0DbTyGhqJe4J8h0CxeytXCWd=EWspfbXVFjkq1Jy68RA@mail.gmail.com>
Hello,
For most of the things you are looking for, please look for a function called build_decl. It is used in several places inside GCC. Let me give you a small example,
If you do the following:
tree x = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifer("ii"), integer_type_node)
you will declare a variable called "ii" of type "integer."
Similarly, to create a new internal structure, if do something like this:
tree struct_frame = lang_hooks.make_type (RECORD_TYPE);
tree struct_field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, get_identifier("variable"), integer_type_node)
TREE_CHAIN(struct_field) = struct_frame
You will create the following internal structure
struct {
int variable;
}
I hope this helps you get started.
Thanks,
Balaji V .Iyer.
-----Original Message-----
From: niXman [mailto:i.nixman@gmail.com]
Sent: Monday, October 03, 2011 6:51 PM
To: gcc@gcc.gnu.org
Subject: The AST tree modification. Edited.
Hi everybody!
It is necessary to implement a plug-in for GCC designed to collect the information on types of translation unit, and generate static const array of types rtti_ex _ on its base; //////////////////////////////////////
enum class type_ {
char_, uchar_, short_, ushort_, int_, uint_, long_, ulong_,
int64_, uint64_, array_, pointer_, double_, long_double_, float_,
class_
};
struct rtti_ex_ { // <<<<<<<<<<<<<<<<<<<<<<<<<
const char* name;
const type_ type;
const size_t size;
const size_t align;
const size_t offset;
};
// generated from plugin.
static const rtti_ex_ rtti_ex_array_[] = {
{...},
{...},
{...}
};
/////////////////////////////////////
There aren't any problems with information collection from AST. There is a complexity with AST modification:
1. How to declare a variable?
2. How to declare the typedef?
3. How to declare a structure?
4. How to declare an array of structures?
I suppose that there should be a function like: tree make_subtree (const char* source); which result I could insert in the corresponding node. But I haven't found it.
Please, give me some links on this subject. It is very desirable, if you could give some links with examples.
Thanks.
next prev parent reply other threads:[~2011-10-04 20:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-03 22:51 niXman
2011-10-04 20:50 ` Iyer, Balaji V [this message]
2011-10-04 21:10 ` niXman
2011-10-05 1:38 ` Ian Lance Taylor
2011-10-07 2:06 ` Andi Hellmund
[not found] ` <CAMPTgK0_VW2i_EoOXowFS=Zhaf_iWy4x5NU89Ro9xCCTABBU3w@mail.gmail.com>
2011-10-07 5:36 ` Fwd: " niXman
2011-10-12 5:03 ` niXman
2011-10-15 22:45 ` niXman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2950715866004049A240A2F9BB410E7315F416F5E7@azsmsx502.amr.corp.intel.com \
--to=balaji.v.iyer@intel.com \
--cc=gcc@gcc.gnu.org \
--cc=i.nixman@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).