public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: zerons <sironhide0null@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Is there a way to build part of gcc as a dynamic library?
Date: Mon, 02 Mar 2020 12:44:00 -0000	[thread overview]
Message-ID: <3ed259b5-7323-d051-efc5-79782eae19d7@gmail.com> (raw)

Hi,

I am working on a project that would collect AST info
and use it 'offline'. I wonder if it is possible to
use some parts of gcc as a dynamic library, to parse
the tree nodes and gimple statements.

For example, I have this naive function to get a field offset:

static unsigned long get_field_offset(tree field)
{
	unsigned long ret = 0;
	if (DECL_FIELD_OFFSET(field)) {
		ret += TREE_INT_CST_LOW(DECL_FIELD_OFFSET(field)) * 8;
	}
	if (DECL_FIELD_BIT_OFFSET(field)) {
		ret += TREE_INT_CST_LOW(DECL_FIELD_BIT_OFFSET(field));
	}
	return ret;
}

It may work well for some cases, I doubt that it can handle
all cases.

If I can use part of gcc as a dynamic library, it would be quite
easy to parse these tree nodes and gimple statements by using the
internal functions.

Thanks.

                 reply	other threads:[~2020-03-02 12:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3ed259b5-7323-d051-efc5-79782eae19d7@gmail.com \
    --to=sironhide0null@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /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).