diff mbox

RFC: Merge the GUPC branch into the GCC 4.8 trunk (patch 01 of 16)

Message ID 20121015210557.GF18153@intrepid.com
State New
Headers show

Commit Message

Gary Funck Oct. 15, 2012, 9:05 p.m. UTC
Attached, patch 01 of 16.

These are configure and 'make' related changes
that introduce UPC support into GCC.

As noted previously, these changes build the UPC front-end
as a 'cc1upc' binary in a fashion similar to Objective C.

There are also specific ABI adjustments made for passing
UPC pointers-to-shared (PTS) values for reasons of both efficiency
and because it simplifies the handling of PTS's if they
are targeted to a scalar mode (such as DImode or TImode).

Some UPC-specific configuration options are added to
the top-level configure.ac and gcc/configure.ac scripts.

- Gary
Configure and Make (patch 01 of 16)
-----------------------------------

    configure.ac
    contrib/gcc_update
    gcc/c-family/stub-upc.c
    gcc/c/Make-lang.in
    gcc/config/darwin.c
    gcc/config/darwin.h
    gcc/config/i386/i386.c
    gcc/config.in
    gcc/config/rs6000/rs6000.c
    gcc/configure.ac
    gcc/cp/Make-lang.in
    gcc/fortran/Make-lang.in
    gcc/java/Make-lang.in
    gcc/lto/Make-lang.in
    gcc/Makefile.in
    gcc/objc/Make-lang.in
    gcc/upc/config-lang.in
    gcc/upc/Makefile.in
    gcc/upc/Make-lang.in
    Makefile.def
    Makefile.tpl

Comments

Joseph Myers Oct. 15, 2012, 9:59 p.m. UTC | #1
On Mon, 15 Oct 2012, Gary Funck wrote:

> Some UPC-specific configuration options are added to
> the top-level configure.ac and gcc/configure.ac scripts.

Any patch that includes new configure options should include the 
documentation for those options in install.texi.  Also please include 
ChangeLog entries with each patch submission, and a more detailed 
description of the changes involved and the rationale for them and 
implementation choices made.  Also please see the review comments I sent 
previously in <http://gcc.gnu.org/ml/gcc-patches/2010-07/msg02136.html> 
(at least, this patch has a license notice in obsolete form, referring to 
GPLv2 and giving an FSF postal address instead of a URL).

The changes to darwin.c, darwin.h, i386.c, rs6000.c should definitely be 
given their own rationale and called to the attention of relevant target 
maintainers, possibly through extracting them into separate patches in the 
series with meaningful subject lines mentioning the relevant targets, not 
mixed into what's ostensibly a build-system patch.

The configure options need justification for their existence and (given 
that they exist) for working using #if, given that (as I said before, in 
the above referenced 2010 message, in 
<http://gcc.gnu.org/ml/gcc-patches/2011-07/msg00083.html> and 
<http://gcc.gnu.org/ml/gcc-patches/2011-07/msg00135.html>), "if" 
conditionals are preferred to #if and it's better for users to be able to 
choose things when they run the compiler rather than only having it 
determined by the person building the compiler (so configure options 
determining defaults are better than configure options that force the 
compiler to behave in a particular way - even if the option affects 
runtime library builds, it's still better to have a command-line option 
and the configure option just affect the default, since then at least 
people can see how code generation changes with the option and 
potentially build multilibs with both variants).

In general, please make sure that you take account of previous feedback on 
previous GUPC patch submissions, and explain in your submissions how you 
have adjusted things for this feedback, or, if you are not making a 
previously requested change, why you consider the approach taken in your 
patch to be optimal.

The change to ACX_BUGURL in configure.ac is simply wrong.

Adding $(C_STUB_OBJS) uses to random language makefiles is very 
suspicious.  stub-objc.o isn't needed by non-C-family front ends.  Nor 
should stub-upc.o be - although I think the whole approach of using stub 
functions like that is wrong, as discussed.  The language-independent 
compiler should be using language-independent interfaces to process 
language-independent internal representations; if there are additions to 
the language-independent IR to handle UPC, then the relevant code to 
handle them should be built in unconditionally.

Front ends should not have their own Makefile.in if at all avoidable, only 
Make-lang.in - why do you have gcc/upc/Makefile.in?  Note that it says 
"Derived from objc/Makefile.in", which was removed in r37088 (2000-10-27).  
See what I said in my 2010 review about "careful review for whether it ... 
takes account of cleanups done in the past decade or so" - you really do 
need to read through the entirety of the code to be submitted, line by 
line, and check how it stands up to the conventions followed elsewhere in 
the compiler and to issues that get raised in reviews of other patches 
nowadays.  (But with rearrangement to be an option to the C front end, I 
expect you shouldn't need upc/Make-lang.in either.)
Gary Funck Oct. 15, 2012, 11:37 p.m. UTC | #2
On 10/15/12 21:59:34, Joseph S. Myers wrote:
> On Mon, 15 Oct 2012, Gary Funck wrote:
> 
> > Some UPC-specific configuration options are added to
> > the top-level configure.ac and gcc/configure.ac scripts.
> 
> Any patch that includes new configure options should include the 
> documentation for those options in install.texi.  Also please include 
> ChangeLog entries with each patch submission, and a more detailed 
> description of the changes involved and the rationale for them and 
> implementation choices made.  Also please see the review comments I sent 
> previously in <http://gcc.gnu.org/ml/gcc-patches/2010-07/msg02136.html> 
> (at least, this patch has a license notice in obsolete form, referring to 
> GPLv2 and giving an FSF postal address instead of a URL).

Joseph,

Back in 2010, we posted an initial RFC:
http://gcc.gnu.org/ml/gcc-patches/2010-07/msg00628.html
which received some review feedback.  We attempted to
incorporate the suggested changes and posted a follow up
about a year later.  It didn't take a year to make the
changes; other development progressed and it just took us
that long to get back to implementing the feedback.
http://gcc.gnu.org/ml/gcc-patches/2011-07/msg00081.html

We tried to make the recommended changes, but it is possible
that some were missed, or that there are other issues such
as the ones that you point out that (still) need to be fixed.

Regarding ChangeLog entries, I can add them to each
change set, if that is needed.  However, I was hoping to
wait on that until the patches are generally approved,
in principle.

I will break out the ABI-related changes in darwin.c,
darwin.h, i386.c, and rs6000.c for separate review
along with an explanation.  However, for this go around,
I would like to patch all the current change sets, in case
there is quick feedback that can be provided which will
help us get things right more quickly.

Regarding additional configure options, I will add justification
per your recommendation.  We did try to avoid #if's to the degree
possible, and are open to suggestions on how to make further
changes along those lines.  I mentioned some of our
remaining questions/issues here in our previous
patch discussion.
http://gcc.gnu.org/ml/gcc-patches/2011-07/msg00138.html

Per your recommendation, we will mention previous feedback and
how we adjusted our patch, in future submittals.

Regarding gcc/upc/Makefile.in, as you note it is likely un-used
and un-needed and a left over that dates back to the time that
we derived the initial gcc/upc directory structure from the
gcc/objc structure at that time.  We will remove it.

The ACX_BUGURL is a left over from earlier GUPC packaging
and is unique to the current GUPC branch.  We will remove
or adjust that change.

My apologies for not catching those spurious changes.

Regarding making adjustments that agree with current
recommendations on the GCC patches list, we do try to
make those changes as we merge in the trunk.  However,
we don't have the overview or experience in various
areas that you and other GCC contributors have.  We hope
that those changes can be pointed out during
the review process.

Some other changes may be a matter of weighing development
time versus priority.  For example, I could see a situation
where the current method of doing things in GUPC (with #if's)
is accepted in this phase with a plan to upgrade that approach
in future patch.  This is similar in approach to the way that
the GCC infrastructure has improved over time.  Some of these
choices will be more obvious based on review/discussion.

Thanks,

- Gary
Joseph Myers Oct. 16, 2012, 12:33 a.m. UTC | #3
On Mon, 15 Oct 2012, Gary Funck wrote:

> Regarding ChangeLog entries, I can add them to each
> change set, if that is needed.  However, I was hoping to
> wait on that until the patches are generally approved,
> in principle.

As a patch submitter, it's your responsibility to make it easy for 
reviewers to review your patch.  The ChangeLogs provide a roadmap for the 
patch - showing what is changed where, at a glance.  They go alongside the 
plain text rationale, explaining at a higher level the structure and 
rationale for the changes and anything that might seem unclear as to why 
the patches work in a particular way.

Each patch submission's Subject: line should best include a brief 
description of that patch as well, not just a patch number.

Any changes that are not immediately and obviously inherently UPC-specific 
deserve specific explanation in the plain text rationale.  That certainly 
includes such things as the langhook change I mentioned, the target 
changes and the changes to non-C-family front-end Make-lang.in files.  In 
the case of the target changes, there should be a high-level explanation 
of how other target maintainers might determine whether changes to their 
targets might be appropriate for UPC, or how you determined that only 
those targets should be changed.

For changes developed over several years, reading through them in detail 
to prepare a ChangeLog is particularly valuable as it will show up places 
where there are spurious changes (such as those to whitespace) that may 
have resulted from code being changed and changed again in the course of 
development, but that are not needed for a clean patch submission.

I don't really think your division into 16 patches is a particularly good 
one - it separates things that should be together, and joins things that 
might better be separate.  Putting documentation in a separate patch from 
the things documented is always bad, for example - if you have new target 
hooks, put the .texi changes in the same patch that adds those hooks.  A 
better division might be:

* Target changes, split out per target.

* Changes to existing C front-end files (including c-family).

* Changes to any other front ends, split out by front end.

* New front-end files.

* Changes to the language and target independent compiler (including build 
system code).

* Library.

* Compiler testsuite.
Gary Funck Oct. 18, 2012, 4:44 p.m. UTC | #4
Joseph,

In this rather long reply, I have attempted to collect all your
recent feedback, and to provide a response where possible.

JSM: On Mon, 15 Oct 2012, Gary Funck wrote:
JSM: GF: Various UPC language related checks and operations
JSM: GF: are called in the "C" front-end and middle-end.
JSM: GF: To insure that these operations are defined,
JSM: GF: when linked with the other language front-ends
JSM: GF: and compilers, these functions are stub-ed,
JSM: GF: in a fashion similar to Objective C:
JSM: 
JSM: Is there a reason you chose this approach rather than the -fcilkplus 
JSM: approach of enabling an extension in the C front end given a command-line 
JSM: option?  (If you don't want to support e.g. the ObjC / UPC combination, 
JSM: you can always give an error in such cases.)  In general I think such 
JSM: conditionals are preferable to linking in stub variants of functions - and 
JSM: I'm sure people doing all-languages LTO bootstraps will appreciate not 
JSM: having to do link-time optimization of the language-independent parts of 
JSM: the compiler yet more times because of yet another binary like cc1, 
JSM: cc1plus, ... that links in much the same code.  The functions you stub out 
JSM: would then all start with assertions that they are only ever called in UPC 
JSM: mode - or if they are meant to be called in C mode but do nothing in that 
JSM: case, with appropriate checks that return early for C (if needed).
JSM:
JSM: On Mon, 15 Oct 2012, Gary Funck wrote:
JSM: GF: Back when we began to develop GUPC, it was recommended that we
JSM: GF: introduce the UPC capability as a language dialect, similar to
JSM: GF: Objective C.  That is the approach that we have taken.
JSM: 
JSM: Recommended where?  I think that approach has been a bad idea for a long 
JSM: time and the approach of building into cc1, as taken by the cilkplus 
JSM: patches, is better (and that really most objc/ code should be like 
JSM: c-family/, built once and linked into both cc1 and cc1plus, though in its 
JSM: present state that's much harder to achieve).
JSM:
JSM: GF: I agree that there is no de facto reason that cc1upc is built
JSM: GF: other than the fact we use a similar approach to Objective C.
JSM: GF: However, I think that re-working this aspect of how GUPC is
JSM: GF: implemented will require a fair amount of time/effort.  If we
JSM: 
JSM: I'd expect it to be a fairly straightforward rework (as would making ObjC 
JSM: a mode of cc1, if ObjC++ didn't exist).

GUPC (then called GCC/UPC) dates back to the GCC 2.7 and GCC 2.95 days.
The GCC 2.7 based implementation was a prototype, and the GCC 2.95 version
was a first attempt to implement a UPC compiler that fits within the GCC
build framework.  At the time, we had discussions with Mark Mitchell,
Mike Stump and perhaps others regarding the best method for introducing
a UPC compiler into GCC.  The consensus recommendation at the time was to
implement GCC/UPC as a language dialect, similar to Objective-C.
Thus, much of the initial work was patterned after ObjC; it used
stubs and built a distinct front-end, so that is what we did.

I will note that even back in those days that Mark indicated he
didn't particularly like the language dialect approach, but it
seemed the best way to go at the time.

For Clang UPC, we have built the UPC capability into the
Clang C/C++ compiler.  This just turned out to be an easier
way to go given Clang's build structure.

My main issue with entertaining large re-structuring of GUPC 
at the moment is that I would like to see if we can introduce
GUPC into GCC 4.8.  As you point out, there are a lot of
other things that we need to do to align the GUPC changes with
the GCC trunk.  Ideally, I'd like to see if we can phase those
changes; dealing with the critical changes now prior to the
merge and then implementing the rest of the changes over time.

Is that feasible or likely?

JSM: GF: Some UPC-specific configuration options are added to
JSM: GF: the top-level configure.ac and gcc/configure.ac scripts.
JSM: 
JSM: Any patch that includes new configure options should include the 
JSM: documentation for those options in install.texi.  Also please include 
JSM: ChangeLog entries with each patch submission, and a more detailed 
JSM: description of the changes involved and the rationale for them and 
JSM: implementation choices made.

OK, thanks.

JSM: The changes to darwin.c, darwin.h, i386.c, rs6000.c should definitely be 
JSM: given their own rationale and called to the attention of relevant target 
JSM: maintainers, possibly through extracting them into separate patches in the 
JSM: series with meaningful subject lines mentioning the relevant targets, not 
JSM: mixed into what's ostensibly a build-system patch.

OK.

JSM: The configure options need justification for their existence and (given 
JSM: that they exist) for working using #if, given that (as I said before, in 
JSM: the above referenced 2010 message, in 
JSM: <http://gcc.gnu.org/ml/gcc-patches/2011-07/msg00083.htmlGF: and 
JSM: <http://gcc.gnu.org/ml/gcc-patches/2011-07/msg00135.html>), "if" 
JSM: conditionals are preferred to #if and it's better for users to be able to 
JSM: choose things when they run the compiler rather than only having it 
JSM: determined by the person building the compiler (so configure options 
JSM: determining defaults are better than configure options that force the 
JSM: compiler to behave in a particular way - even if the option affects 
JSM: runtime library builds, it's still better to have a command-line option 
JSM: and the configure option just affect the default, since then at least 
JSM: people can see how code generation changes with the option and 
JSM: potentially build multilibs with both variants).

I agree with your overall recommendation, but found it
difficult to implement the various flavors of UPC
runtime libraries within the GCC build framework.

I may post a follow-up question/two on the issue of
building various libgupc "flavors".  I wasn't certain
that multilib was the way to go for this.  Is the
regular GCC list the best place for that type of discussion?

Also, specifying the flavor of PTS representation on the UPC
compiler command line (for example) is a departure from the
current method of configuring and invoking GUPC.  There is a
ripple effect of documentation, testing, and user education
that would have to occur to make this change.  For Clang UPC
we do support specification of the PTS rep. on the compiler
command line, and provide a suitable default; the Clang build
infrastructure was easier to work with in this regard.  Although
an implementation detail, in the long run we would like to unify
the PTS representations and simplify the configuration variants,
but that work needs to be prioritized along with everything else.

JSM: In general, please make sure that you take account of previous feedback on 
JSM: previous GUPC patch submissions, and explain in your submissions how you 
JSM: have adjusted things for this feedback, or, if you are not making a 
JSM: previously requested change, why you consider the approach taken in your 
JSM: patch to be optimal.

As mentioned in a previous reply, we did attempt to incorporate
previous feedback into GUPC, and we do appreciate all feedback/suggestions
and try to make all suggested updates.  However, it seems that
we missed a few of them.  We'll try to do better.

JSM: The change to ACX_BUGURL in configure.ac is simply wrong.
JSM: 
JSM: Adding $(C_STUB_OBJS) uses to random language makefiles is very 
JSM: suspicious.  stub-objc.o isn't needed by non-C-family front ends.  Nor 
JSM: should stub-upc.o be - although I think the whole approach of using stub 
JSM: functions like that is wrong, as discussed.

I'm not fond of stubs or adding extra files to other front-ends,
but those changes seemed necessary at the time to get things to link.

BTW, regarding something like UPC++: there is some interest but
there are some language issues that would need to be addressed.

JSM: The language-independent 
JSM: compiler should be using language-independent interfaces to process 
JSM: language-independent internal representations; if there are additions to 
JSM: the language-independent IR to handle UPC, then the relevant code to 
JSM: handle them should be built in unconditionally.

We followed the Objective C approach for better/worse.
The few additional tree nodes needed for UPC are defined
in a language dependent tree definition file.  The UPC-specific
support needed by the "C" front-end are defined in the
'upc' directory in a fashion similar to the 'objc' directory.
When UPC isn't being built, those functions are stubbed.
Thus, generally there is little/no UPC-related #if (conditional)
code in the "C" front-end.  As far as the language-independent
parts go, I can think of one/two places that we might still
use conditionals.  I will point those out in the next
set of review notes.

JSM: Front ends should not have their own Makefile.in if at all avoidable, only 
JSM: Make-lang.in - why do you have gcc/upc/Makefile.in?  Note that it says 
JSM: "Derived from objc/Makefile.in", which was removed in r37088 (2000-10-27).  
This is an oversight.  That Makefile.in dates back to the days that
we copied the files from the objc directory.  It is unused and will
be removed.

JSM: See what I said in my 2010 review about "careful review for whether it ... 
JSM: takes account of cleanups done in the past decade or so" - you really do 
JSM: need to read through the entirety of the code to be submitted, line by 
JSM: line, and check how it stands up to the conventions followed elsewhere in 
JSM: the compiler and to issues that get raised in reviews of other patches 
JSM: nowadays.  (But with rearrangement to be an option to the C front end, I 
JSM: expect you shouldn't need upc/Make-lang.in either.)

We haven't been involved in the re-structuring of the GCC infra-structure,
but do try to adjust to changes when we merge with the trunk.  From
my point of view, the recommended best practice has evolved over the years.

For example, the recommendation to select UPC compilation via a
compiler command line switch rather than to build cc1upc
in a fashion similar to Objective C as it is done now,
wasn't mentioned in either the 2010 or 2011 review comments.

I can see the benefit of all your recommendations.  I am just
trying to see if there is a way to phase them so that we can
merge into GCC 4.8?  I was also hoping to get to the point
that we could have some review of the non-infrastructure
related changes (such as the "C" front-end and other changes)
in parallel so that we can better plan our work.

JSM: Please go back to my previous comments, then post a full patch series 
JSM: *once those issues are addressed*.  Each submission needs ChangeLog 
JSM: entries and more detailed descriptions / rationale.

OK.

JSM: For example, explain 
JSM: why a lang hook change is made in c-objc-common.h.  Make sure that you 
JSM: consistently use error_at, not error, for new diagnostics, or explain in 
JSM: your rationale why a location isn't readily available.  Make sure that 
JSM: source lines do not go over 80 columns.  There are at least some other 
JSM: coding standards issues; some visible at a glance are the comment /* for 
JSM: static declarations of shared arrays */ (start with a capital letter, end 
JSM: with '.', actually say what the semantics of this variable's value are if 
JSM: it needs a comment) and a missing space in TREE_CODE(decl).

OK.  Generally, we do try to follow the GCC coding standards, but
it seems that a few variances remain.  We will address those.

JSM: Avoid any diff lines that are solely changing trailing whitespace (you 
JSM: have at least once diff hunk in c-decl.c that appears to do nothing but 
JSM: add such whitespace).  Some indentation also looks suspicious - look at 
JSM: the @@ -8859,6 +9048,23 @@ declspecs_add_qual hunk, for example, where 
JSM: inconsistent indentation reveals that you are indenting with spaces in 
JSM: some places, except for one line using a TAB (all new lines should be 
JSM: indented with TABs for every 8 spaces).

OK.

JSM: On Mon, 15 Oct 2012, Gary Funck wrote:
JSM: GF: Regarding ChangeLog entries, I can add them to each
JSM: GF: change set, if that is needed.  However, I was hoping to
JSM: GF: wait on that until the patches are generally approved,
JSM: GF: in principle.
JSM: 
JSM: As a patch submitter, it's your responsibility to make it easy for 
JSM: reviewers to review your patch.  The ChangeLogs provide a roadmap for the 
JSM: patch - showing what is changed where, at a glance.  They go alongside the 
JSM: plain text rationale, explaining at a higher level the structure and 
JSM: rationale for the changes and anything that might seem unclear as to why 
JSM: the patches work in a particular way.
JSM: 
JSM: Each patch submission's Subject: line should best include a brief 
JSM: description of that patch as well, not just a patch number.

OK.

JSM: Any changes that are not immediately and obviously inherently UPC-specific 
JSM: deserve specific explanation in the plain text rationale.  That certainly 
JSM: includes such things as the langhook change I mentioned, the target 
JSM: changes and the changes to non-C-family front-end Make-lang.in files.  In 
JSM: the case of the target changes, there should be a high-level explanation 
JSM: of how other target maintainers might determine whether changes to their 
JSM: targets might be appropriate for UPC, or how you determined that only 
JSM: those targets should be changed.

OK.

JSM: For changes developed over several years, reading through them in detail 
JSM: to prepare a ChangeLog is particularly valuable as it will show up places 
JSM: where there are spurious changes (such as those to whitespace) that may 
JSM: have resulted from code being changed and changed again in the course of 
JSM: development, but that are not needed for a clean patch submission.
JSM: 
JSM: I don't really think your division into 16 patches is a particularly good 
JSM: one - it separates things that should be together, and joins things that 
JSM: might better be separate.  Putting documentation in a separate patch from 
JSM: the things documented is always bad, for example - if you have new target 
JSM: hooks, put the .texi changes in the same patch that adds those hooks.  A 
JSM: better division might be:
JSM: 
JSM: * Target changes, split out per target.
JSM: 
JSM: * Changes to existing C front-end files (including c-family).
JSM: 
JSM: * Changes to any other front ends, split out by front end.
JSM: 
JSM: * New front-end files.
JSM: 
JSM: * Changes to the language and target independent compiler (including build 
JSM: system code).
JSM: 
JSM: * Library.
JSM: 
JSM: * Compiler testsuite.

OK, I will re-package the patches, add ChangeLog's, review the
changes more carefully and provide a rationale per your recommendations.

I appreciate the detailed feedback that you have provided.

thanks,
- Gary
Joseph Myers Oct. 18, 2012, 7:45 p.m. UTC | #5
On Thu, 18 Oct 2012, Gary Funck wrote:

> GUPC (then called GCC/UPC) dates back to the GCC 2.7 and GCC 2.95 days.
> The GCC 2.7 based implementation was a prototype, and the GCC 2.95 version
> was a first attempt to implement a UPC compiler that fits within the GCC
> build framework.  At the time, we had discussions with Mark Mitchell,
> Mike Stump and perhaps others regarding the best method for introducing
> a UPC compiler into GCC.  The consensus recommendation at the time was to
> implement GCC/UPC as a language dialect, similar to Objective-C.
> Thus, much of the initial work was patterned after ObjC; it used
> stubs and built a distinct front-end, so that is what we did.

GCC coding style has moved on a long way since then, and GCC generally has 
been moving away from conditional compilation, from #if to if conditions, 
from conditionally building something in to making the choice when the 
compiler is run.

I don't think ObjC as a separate front end is a good idea now, and don't 
think UPC should be added that way.  I also still don't think making UPC 
into a mode of the C front end should be more than a day or two's work.

> My main issue with entertaining large re-structuring of GUPC 
> at the moment is that I would like to see if we can introduce
> GUPC into GCC 4.8.  As you point out, there are a lot of

If the concern is 4.8, I'd think the priority should be the changes to the 
language and target independent code - changes to handle whatever 
additions UPC may make to GENERIC / GIMPLE - which will need middle-end 
maintainer review and which are probably the highest-risk part of the 
changes.

> Also, specifying the flavor of PTS representation on the UPC
> compiler command line (for example) is a departure from the
> current method of configuring and invoking GUPC.  There is a

As noted above, use of #if is no longer generally good practice in GCC.  
Even "if (macro)", which might turn into "if (0)", is better than #if - at 
least it means all the code does get checked by the compiler, whichever 
configuration is built - but command-line options are certainly better.

> JSM: Adding $(C_STUB_OBJS) uses to random language makefiles is very 
> JSM: suspicious.  stub-objc.o isn't needed by non-C-family front ends.  Nor 
> JSM: should stub-upc.o be - although I think the whole approach of using stub 
> JSM: functions like that is wrong, as discussed.
> 
> I'm not fond of stubs or adding extra files to other front-ends,
> but those changes seemed necessary at the time to get things to link.

"seemed necessary at the time to get things to link" isn't sufficient 
reason.  You'd need to state what symbols, used in what files, were 
undefined.  But then the solution won't be to link in a stub file - it 
will be to link in real code, unconditionally.  Whatever additions you 
make to GENERIC / GIMPLE for UPC should be handled entirely by 
language-independent code - that is, code that is always linked in, for 
all languages, to handle those GENERIC / GIMPLE features (even if most 
front ends don't generate those features), rather than code only linked in 
for particular front ends.

> JSM: The language-independent 
> JSM: compiler should be using language-independent interfaces to process 
> JSM: language-independent internal representations; if there are additions to 
> JSM: the language-independent IR to handle UPC, then the relevant code to 
> JSM: handle them should be built in unconditionally.
> 
> We followed the Objective C approach for better/worse.

ObjC does not require stubs to be linked into non-C-family front ends.  
Whatever code exists in the language-independent compiler to handle GIMPLE 
from the ObjC front end gets linked into all compilers without any need to 
link in any stubs.

> The few additional tree nodes needed for UPC are defined
> in a language dependent tree definition file.  The UPC-specific

Whatever those get gimplified to needs to be language-independent (that 
is, handled after gimplification entirely by language-independent parts of 
the compiler).
diff mbox

Patch

Index: configure.ac
===================================================================
--- configure.ac	(.../trunk)	(revision 192449)
+++ configure.ac	(.../branches/gupc)	(revision 192459)
@@ -166,6 +166,7 @@  target_libraries="target-libgcc \
 		target-boehm-gc \
 		${libgcj} \
 		target-libobjc \
+		target-libgupc \
 		target-libada \
 		target-libgo"
 
@@ -478,10 +479,8 @@  if test x$enable_libmudflap = x ; then
     esac
 fi
 
-# Disable libgomp on non POSIX hosted systems.
-if test x$enable_libgomp = x ; then
-    # Enable libgomp by default on hosted POSIX systems.
-    case "${target}" in
+posix_based_os="yes"
+case "${target}" in
     *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
 	;;
     *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly*)
@@ -491,9 +490,20 @@  if test x$enable_libgomp = x ; then
     *-*-darwin* | *-*-aix*)
 	;;
     *)
-	noconfigdirs="$noconfigdirs target-libgomp"
-	;;
-    esac
+    posix_based_os="no"
+    ;;
+esac
+
+# Enable libgomp by default on POSIX hosted systems.
+if test x$enable_libgomp = x -a $posix_based_os = "no" ; then
+    # Disable libgomp on non POSIX hosted systems.
+    noconfigdirs="$noconfigdirs target-libgomp"
+fi
+
+# Enable libgupc by default on POSIX hosted systems.
+if test x$enable_libgupc = x -a $posix_based_os = "no" ; then
+    # Disable libgupc on non POSIX hosted systems.
+    noconfigdirs="$noconfigdirs target-libgupc"
 fi
 
 # Disable libatomic on unsupported systems.
@@ -1138,6 +1148,7 @@  if test "${build}" != "${host}" ; then
   GCJ_FOR_BUILD=${GCJ_FOR_BUILD-gcj}
   GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran}
   GOC_FOR_BUILD=${GOC_FOR_BUILD-gccgo}
+  GUPC_FOR_BUILD=${GUPC_FOR_BUILD-gupc}
   DLLTOOL_FOR_BUILD=${DLLTOOL_FOR_BUILD-dlltool}
   LD_FOR_BUILD=${LD_FOR_BUILD-ld}
   NM_FOR_BUILD=${NM_FOR_BUILD-nm}
@@ -1152,6 +1163,7 @@  else
   GCJ_FOR_BUILD="\$(GCJ)"
   GFORTRAN_FOR_BUILD="\$(GFORTRAN)"
   GOC_FOR_BUILD="\$(GOC)"
+  GUPC_FOR_BUILD="\$(GUPC)"
   DLLTOOL_FOR_BUILD="\$(DLLTOOL)"
   LD_FOR_BUILD="\$(LD)"
   NM_FOR_BUILD="\$(NM)"
@@ -1957,6 +1969,28 @@  case ,${enable_languages},:${enable_objc
     ;;
 esac
 
+AC_ARG_WITH([upc-pts],
+AS_HELP_STRING(
+[[--with-upc-pts=[{struct,packed}]]],
+ [choose the representation of a UPC pointer-to-shared]),
+[
+ case ,${enable_languages}, in
+   *,upc,) 
+     case "$withval" in
+       struct|packed)
+	 true
+         ;;
+       *)
+         AC_MSG_ERROR([$withval is an invalid option to --with-upc-pts])
+         ;;
+     esac
+     ;;
+   *)
+     AC_MSG_ERROR([--with-upc-pts supplied, but UPC language not enabled])
+     ;;
+ esac
+],[])
+
 # Disable libitm if we're not building C++
 case ,${enable_languages}, in
   *,c++,*) ;;
@@ -2901,6 +2935,48 @@  case "${target}" in
     ;;
 esac
 
+# UPC linker script check
+AC_MSG_CHECKING([for UPC link script support])
+AC_ARG_ENABLE(upc-link-script,
+AS_HELP_STRING(
+  [--enable-upc-link-script],
+  [enable UPC's use of a custom linker script;
+  this will define the UPC shared section as a no load section on
+  targets where this feature is supported (requires GNU LD)]),
+[
+  case $enableval in
+  yes | no) ;;
+  *)
+    AC_MSG_ERROR([--enable-upc-link-script accepts only yes or no.])
+    ;;
+  esac
+],
+[
+  if test x${use_gnu_ld} != xno ; then
+    case "$target" in
+      # disable linker script for Apple Mac OS X
+      *-*-darwin*)
+        enable_upc_link_script=no
+        ;;
+      *)
+        enable_upc_link_script=yes
+        ;;
+    esac
+  else
+    enable_upc_link_script=no
+  fi
+  if test "$enable_upc_link_script" = yes; then
+    target_configargs="${target_configargs} --enable-upc-link-script"
+    host_configargs="${host_configargs} --enable-upc-link-script"
+  fi
+])
+if test "$enable_upc_link_script" = yes; then
+  AC_MSG_RESULT([yes]);
+else
+  AC_MSG_RESULT([no]);
+fi
+
+
 # Makefile fragments.
 for frag in host_makefile_frag target_makefile_frag alphaieee_frag ospace_frag;
 do
@@ -2947,6 +3023,7 @@  AC_SUBST(DLLTOOL_FOR_BUILD)
 AC_SUBST(GCJ_FOR_BUILD)
 AC_SUBST(GFORTRAN_FOR_BUILD)
 AC_SUBST(GOC_FOR_BUILD)
+AC_SUBST(GUPC_FOR_BUILD)
 AC_SUBST(LDFLAGS_FOR_BUILD)
 AC_SUBST(LD_FOR_BUILD)
 AC_SUBST(NM_FOR_BUILD)
@@ -3057,6 +3134,7 @@  NCN_STRICT_CHECK_TARGET_TOOLS(GCC_FOR_TA
 NCN_STRICT_CHECK_TARGET_TOOLS(GCJ_FOR_TARGET, gcj)
 NCN_STRICT_CHECK_TARGET_TOOLS(GFORTRAN_FOR_TARGET, gfortran)
 NCN_STRICT_CHECK_TARGET_TOOLS(GOC_FOR_TARGET, gccgo)
+NCN_STRICT_CHECK_TARGET_TOOLS(GUPC_FOR_TARGET, gupc)
 
 ACX_CHECK_INSTALLED_TARGET_TOOL(AR_FOR_TARGET, ar)
 ACX_CHECK_INSTALLED_TARGET_TOOL(AS_FOR_TARGET, as)
@@ -3091,6 +3169,8 @@  GCC_TARGET_TOOL(gfortran, GFORTRAN_FOR_T
 		[gcc/gfortran -B$$r/$(HOST_SUBDIR)/gcc/], fortran)
 GCC_TARGET_TOOL(gccgo, GOC_FOR_TARGET, GOC,
 		[gcc/gccgo -B$$r/$(HOST_SUBDIR)/gcc/], go)
+GCC_TARGET_TOOL(gupc, GUPC_FOR_TARGET, GUPC,
+		[gcc/gupc -B$$r/$(HOST_SUBDIR)/gcc/], upc)
 GCC_TARGET_TOOL(ld, LD_FOR_TARGET, LD, [ld/ld-new])
 GCC_TARGET_TOOL(lipo, LIPO_FOR_TARGET, LIPO)
 GCC_TARGET_TOOL(nm, NM_FOR_TARGET, NM, [binutils/nm-new])
Index: contrib/gcc_update
===================================================================
--- contrib/gcc_update	(.../trunk)	(revision 192449)
+++ contrib/gcc_update	(.../branches/gupc)	(revision 192459)
@@ -139,6 +139,11 @@  libgomp/Makefile.in: libgomp/Makefile.am
 libgomp/testsuite/Makefile.in: libgomp/Makefile.am libgomp/aclocal.m4
 libgomp/configure: libgomp/configure.ac libgomp/aclocal.m4
 libgomp/config.h.in: libgomp/configure.ac libgomp/aclocal.m4
+libgupc/aclocal.m4: libgupc/configure.ac libgupc/acinclude.m4
+libgupc/config.h.in: libgupc/configure.ac
+libgupc/configure: libgupc/configure.ac libgupc/aclocal.m4 libgupc/acinclude.m4
+libgupc/Makefile.in: libgupc/Makefile.am libgupc/aclocal.m4
+libgupc/testsuite/Makefile.in: libgupc/Makefile.am libgupc/aclocal.m4
 libitm/aclocal.m4: libitm/configure.ac libitm/acinclude.m4
 libitm/Makefile.in: libitm/Makefile.am libitm/aclocal.m4
 libitm/testsuite/Makefile.in: libitm/testsuite/Makefile.am libitm/aclocal.m4

Property changes on: .
___________________________________________________________________
Added: svn:mergeinfo
   Merged /trunk:r157128-184995,184997-192449

Index: gcc/c-family/stub-upc.c
===================================================================
--- gcc/c-family/stub-upc.c	(.../trunk)	(revision 0)
+++ gcc/c-family/stub-upc.c	(.../branches/gupc)	(revision 192459)
@@ -0,0 +1,211 @@ 
+/* Stub functions for UPC routines
+   that are called from within the C front end.
+   respectively.
+   Copyright (C) 1991, 1995, 1997, 1998,
+   1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to the Free
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tree.h"
+#include "c-common.h"
+#include "c-upc.h"
+
+int compiling_upc;
+int flag_upc;
+int use_upc_dwarf2_extensions;
+
+int
+count_upc_threads_refs (tree expr ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+int
+is_multiple_of_upc_threads (tree expr ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+void
+set_upc_threads_refs_to_one (tree *expr ATTRIBUTE_UNUSED)
+{
+  return;
+}
+
+tree
+upc_get_block_factor (tree type ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+tree
+upc_grok_layout_qualifier (
+    location_t loc ATTRIBUTE_UNUSED,
+    const enum tree_code decl_kind ATTRIBUTE_UNUSED,
+    tree type ATTRIBUTE_UNUSED,
+    tree elem_block_factor ATTRIBUTE_UNUSED,
+    tree layout_specifier ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+void
+upc_check_decl (tree ARG_UNUSED (decl))
+{
+}
+
+int
+upc_check_decl_init (tree ARG_UNUSED (decl),
+                     tree ARG_UNUSED (init))
+{
+  return 0;
+}
+
+void
+upc_decl_init (tree ARG_UNUSED (decl),
+               tree ARG_UNUSED (init))
+{
+}
+
+
+void
+upc_set_decl_section (tree decl ATTRIBUTE_UNUSED)
+{
+}
+
+int
+upc_is_null_pts_p (tree p ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+tree
+upc_pts_increment (
+     location_t location ATTRIBUTE_UNUSED,
+     enum tree_code code ATTRIBUTE_UNUSED,
+     tree arg ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+tree
+upc_pts_int_sum (
+    location_t location ATTRIBUTE_UNUSED,
+    enum tree_code resultcode ATTRIBUTE_UNUSED,
+    tree ptrop ATTRIBUTE_UNUSED,
+    tree intop ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+tree
+upc_pts_diff (
+    tree op0 ATTRIBUTE_UNUSED,
+    tree op1 ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+
+tree
+upc_affinity_test (location_t ARG_UNUSED(start_locus),
+                   tree ARG_UNUSED(affinity))
+{
+  return 0;
+}
+
+tree
+upc_rts_forall_depth_var (void)
+{
+  return 0;
+}
+
+tree 
+upc_build_sync_stmt (location_t ARG_UNUSED(loc),
+                     tree ARG_UNUSED (op), tree ARG_UNUSED (exp))
+{
+  return NULL_TREE;
+}
+
+void
+upc_block_factor_insert (tree ARG_UNUSED(type),
+                         tree ARG_UNUSED(block_factor))
+{
+}
+
+tree
+upc_block_factor_lookup (tree ARG_UNUSED(type))
+{
+  return NULL_TREE;
+}
+
+tree
+upc_blocksizeof (location_t ARG_UNUSED(loc), tree ARG_UNUSED (op))
+{
+  return NULL_TREE;
+}
+
+tree
+upc_build_pointer_type (tree ARG_UNUSED (op))
+{
+  return NULL_TREE;
+}
+
+tree
+upc_elemsizeof (location_t ARG_UNUSED(loc), tree ARG_UNUSED (op))
+{
+  return NULL_TREE;
+}
+
+tree
+upc_localsizeof (location_t ARG_UNUSED(loc), tree ARG_UNUSED (op))
+{
+  return NULL_TREE;
+}
+
+tree
+upc_num_threads(void)
+{
+  return NULL_TREE;
+}
+
+int
+upc_diagnose_deprecated_stmt (location_t ARG_UNUSED (loc),
+                              tree ARG_UNUSED (id))
+{
+  return 0;
+}
+
+void
+upc_cpp_builtins (cpp_reader * ARG_UNUSED(pfile))
+{
+}
+
+tree
+upc_instrument_forall (location_t ARG_UNUSED(loc), int ARG_UNUSED(start))
+{
+  return 0;
+}
+
+void
+upc_write_global_declarations (void)
+{
+}
Index: gcc/c/Make-lang.in
===================================================================
--- gcc/c/Make-lang.in	(.../trunk)	(revision 192449)
+++ gcc/c/Make-lang.in	(.../branches/gupc)	(revision 192459)
@@ -60,8 +60,10 @@  C_AND_OBJC_OBJS = attribs.o c/c-errors.o
   c/c-convert.o c/c-aux-info.o c/c-objc-common.o c/c-parser.o \
   $(C_COMMON_OBJS) $(C_TARGET_OBJS)
 
+C_STUB_OBJS = c-family/stub-objc.o c-family/stub-upc.o
+
 # Language-specific object files for C.
-C_OBJS = c/c-lang.o c-family/stub-objc.o $(C_AND_OBJC_OBJS)
+C_OBJS = c/c-lang.o $(C_STUB_OBJS) $(C_AND_OBJC_OBJS)
 c_OBJS = $(C_OBJS) cc1-checksum.o c/gccspec.o
 
 # Use strict warnings for this front end.
Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c	(.../trunk)	(revision 192449)
+++ gcc/config/darwin.c	(.../branches/gupc)	(revision 192459)
@@ -3039,6 +3039,7 @@  darwin_override_options (void)
     }
 
   if (flag_var_tracking
+      && optimize >= 1
       && generating_for_darwin_version >= 9
       && (flag_gtoggle ? (debug_info_level == DINFO_LEVEL_NONE)
       : (debug_info_level >= DINFO_LEVEL_NORMAL))
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h	(.../trunk)	(revision 192449)
+++ gcc/config/darwin.h	(.../branches/gupc)	(revision 192459)
@@ -177,14 +177,17 @@  extern GTY(()) int darwin_ms_struct;
     %{e*} %{r} \
     %{o*}%{!o:-o a.out} \
     %{!nostdlib:%{!nostartfiles:%S}} \
+    %{!nostdlib:%{!nostartfiles:%{fupc-link:%:include(upc-crtbegin.spec)%(upc_crtbegin)}}}\
     %{L*} %(link_libgcc) %o %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \
     %{fopenmp|ftree-parallelize-loops=*: \
       %{static|static-libgcc|static-libstdc++|static-libgfortran: libgomp.a%s; : -lgomp } } \
     %{fgnu-tm: \
       %{static|static-libgcc|static-libstdc++|static-libgfortran: libitm.a%s; : -litm } } \
+    %{fupc-link:%:include(libgupc.spec)%(link_upc)} \
     %{!nostdlib:%{!nodefaultlibs:\
       %(link_ssp) %(link_gcc_c_sequence)\
     }}\
+    %{!nostdlib:%{!nostartfiles:%{fupc-link:%:include(upc-crtend.spec)%(upc_crtend)}}}\
     %{!nostdlib:%{!nostartfiles:%E}} %{T*} %{F*} }}}}}}}"
 
 #define DSYMUTIL "\ndsymutil"
@@ -917,6 +920,17 @@  extern void darwin_driver_init (unsigned
 #undef SUPPORTS_INIT_PRIORITY
 #define SUPPORTS_INIT_PRIORITY 0
 
+/* UPC for darwin */
+
+/* Define main program rename */
+#define UPC_MAIN_NAME "_upc_main"
+
+/* UPC section names */
+#define UPC_SHARED_SECTION_NAME "__DATA,upc_shared"
+#define UPC_PGM_INFO_SECTION_NAME "__DATA,upc_pgm_info"
+#define UPC_INIT_SECTION_NAME "__TEXT,upc_init"
+#define UPC_INIT_ARRAY_SECTION_NAME "__DATA,upc_init_array"
+
 /* When building cross-compilers (and native crosses) we shall default to 
    providing an osx-version-min of this unless overridden by the User.  */
 #define DEF_MIN_OSX_VERSION "10.4"
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(.../trunk)	(revision 192449)
+++ gcc/config/i386/i386.c	(.../branches/gupc)	(revision 192459)
@@ -6135,6 +6135,15 @@  classify_argument (enum machine_mode mod
       && targetm.calls.must_pass_in_stack (mode, type))
     return 0;
 
+  /* Special case check for pointer to shared, on 64-bit target. */
+  if (TARGET_64BIT && mode == TImode
+      && type && TREE_CODE (type) == POINTER_TYPE
+      && upc_shared_type_p (TREE_TYPE (type)))
+    {
+      classes[0] = classes[1] = X86_64_INTEGER_CLASS;
+      return 2;
+    }
+
   if (type && AGGREGATE_TYPE_P (type))
     {
       int i;
@@ -7533,7 +7542,8 @@  function_value_64 (enum machine_mode ori
 
       return gen_rtx_REG (mode, regno);
     }
-  else if (POINTER_TYPE_P (valtype))
+  else if (POINTER_TYPE_P (valtype)
+           && !upc_shared_type_p (TREE_TYPE (valtype)))
     {
       /* Pointers are always returned in word_mode.  */
       mode = word_mode;
@@ -7617,6 +7627,11 @@  ix86_promote_function_mode (const_tree t
 {
   if (type != NULL_TREE && POINTER_TYPE_P (type))
     {
+      if (upc_shared_type_p (TREE_TYPE (type)))
+        {
+          *punsignedp = 1;
+          return TYPE_MODE (upc_pts_rep_type_node);
+	}
       *punsignedp = POINTERS_EXTEND_UNSIGNED;
       return word_mode;
     }
Index: gcc/config.in
===================================================================
--- gcc/config.in	(.../trunk)	(revision 192449)
+++ gcc/config.in	(.../branches/gupc)	(revision 192459)
@@ -1539,6 +1539,32 @@ 
 #endif
 
 
+/* Define to 1 if UPC link script is supported. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_UPC_LINK_SCRIPT
+#endif
+
+
+/* Define to 1 if UPC pointer-to-shared representation is a packed 64 bit
+   word. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_UPC_PTS_PACKED_REP
+#endif
+
+
+/* Define to 1 if UPC pointer-to-shared representation is a structure. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_UPC_PTS_STRUCT_REP
+#endif
+
+
+/* Define to 1 if the 'vaddr' field is the first field in the UPC
+   pointer-to-shared representation. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_UPC_PTS_VADDR_FIRST
+#endif
+
+
 /* Define if valgrind's valgrind/memcheck.h header is installed. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_VALGRIND_MEMCHECK_H
@@ -1792,6 +1818,27 @@ 
 #endif
 
 
+/* For packed UPC pointers-to-shared, the size of the phase field (in bits).
+   */
+#ifndef USED_FOR_TARGET
+#undef UPC_PTS_PHASE_SIZE
+#endif
+
+
+/* For packed UPC pointers-to-shared, the size of the thread field (in bits).
+   */
+#ifndef USED_FOR_TARGET
+#undef UPC_PTS_THREAD_SIZE
+#endif
+
+
+/* For packed UPC pointers-to-shared, the size of the address field (in bits).
+   */
+#ifndef USED_FOR_TARGET
+#undef UPC_PTS_VADDR_SIZE
+#endif
+
+
 /* Define if your assembler mis-optimizes .eh_frame data. */
 #ifndef USED_FOR_TARGET
 #undef USE_AS_TRADITIONAL_FORMAT
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(.../trunk)	(revision 192449)
+++ gcc/config/rs6000/rs6000.c	(.../branches/gupc)	(revision 192459)
@@ -7407,6 +7407,11 @@  rs6000_return_in_memory (const_tree type
       /* Otherwise fall through to more conventional ABI rules.  */
     }
 
+#if HAVE_UPC_PTS_STRUCT_REP
+  if (POINTER_TYPE_P (type) && upc_shared_type_p (TREE_TYPE (type)))
+    return true;
+#endif
+
   if (AGGREGATE_TYPE_P (type)
       && (aix_struct_return
 	  || (unsigned HOST_WIDE_INT) int_size_in_bytes (type) > 8))
@@ -8800,6 +8805,17 @@  rs6000_pass_by_reference (cumulative_arg
   if (!type)
     return 0;
 
+#if HAVE_UPC_PTS_STRUCT_REP
+  if (DEFAULT_ABI == ABI_V4 && POINTER_TYPE_P (type)
+      && upc_shared_type_p (TREE_TYPE (type)))
+    {
+      if (TARGET_DEBUG_ARG)
+	fprintf (stderr, 
+		 "function_arg_pass_by_reference: V4 UPC ptr to shared\n");
+      return 1;
+    }
+#endif
+
   if (DEFAULT_ABI == ABI_V4 && AGGREGATE_TYPE_P (type))
     {
       if (TARGET_DEBUG_ARG)
@@ -21459,11 +21475,12 @@  rs6000_output_function_epilogue (FILE *f
 	 use language_string.
 	 C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
 	 Java is 13.  Objective-C is 14.  Objective-C++ isn't assigned
-	 a number, so for now use 9.  LTO and Go aren't assigned numbers
+	 a number, so for now use 9.  LTO, Go, and UPC aren't assigned numbers
 	 either, so for now use 0.  */
       if (! strcmp (language_string, "GNU C")
 	  || ! strcmp (language_string, "GNU GIMPLE")
-	  || ! strcmp (language_string, "GNU Go"))
+	  || ! strcmp (language_string, "GNU Go")
+          || ! strcmp (language_string, "GNU UPC"))
 	i = 0;
       else if (! strcmp (language_string, "GNU F77")
 	       || ! strcmp (language_string, "GNU Fortran"))
@@ -27104,7 +27121,7 @@  rs6000_function_value (const_tree valtyp
 
   mode = TYPE_MODE (valtype);
   if ((INTEGRAL_TYPE_P (valtype) && GET_MODE_BITSIZE (mode) < BITS_PER_WORD)
-      || POINTER_TYPE_P (valtype))
+      || (POINTER_TYPE_P (valtype) && !upc_shared_type_p (TREE_TYPE (valtype))))
     mode = TARGET_32BIT ? SImode : DImode;
 
   if (DECIMAL_FLOAT_MODE_P (mode) && TARGET_HARD_FLOAT && TARGET_FPRS)
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(.../trunk)	(revision 192449)
+++ gcc/configure.ac	(.../branches/gupc)	(revision 192459)
@@ -691,6 +691,182 @@  else
 fi,
 objc_boehm_gc='')
 
+case ,${enable_languages}, in
+   *,upc,) lang_upc_enabled="yes" ;;
+   *) ;;
+esac
+
+AC_ARG_WITH([upc-pts],
+AS_HELP_STRING(
+  [--with-upc-pts={struct,packed}],
+  [choose the representation of a UPC pointer-to-shared]),
+[
+if test x"$lang_upc_enabled" = x"yes" ; then
+  case "$withval" in
+    packed|struct) upc_pts_rep="$withval" ;;
+    *) AC_MSG_ERROR([$withval is an invalid option to --with-upc-pts])
+      ;;
+  esac
+else
+  AC_MSG_WARN([--with-upc-pts is allowed only when UPC
+support has been enabled])
+fi
+],
+[
+if test x"$lang_upc_enabled" = x"yes" ; then
+  upc_pts_rep="packed"
+fi
+])
+
+
+# Perl is required for checking pts representation
+AC_CHECK_PROG(PERL, perl, perl)
+
+AC_ARG_WITH([upc-pts-vaddr-order],
+AS_HELP_STRING(
+[--with-upc-pts-vaddr-order={last,first}],
+[choose position of the address field in UPC pointer-to-shared representation]),
+[
+if test x"$lang_upc_enabled" = x"yes" ; then
+  upc_vaddr_order="$withval"
+  case "$upc_vaddr_order" in
+    first|last) ;;
+    *) AC_MSG_ERROR(
+	 [$withval is an invalid option to --with-upc-pts-vaddr-order]) ;;
+  esac
+else
+  AC_MSG_WARN([--upc-pts-vaddr-order is allowed only when UPC
+support has been enabled])
+fi
+],
+[
+if test x"$lang_upc_enabled" = x"yes" ; then
+  # Default UPC PTS vaddr order to "first"
+  upc_vaddr_order="first"
+fi
+])
+
+AC_ARG_WITH([upc-packed-bits],,
+[
+  AC_MSG_WARN([--with-upc-packed-bits is deprecated. 
+Use --with-upc-pts-packed-bits instead.])
+  with_upc_pts_packed_bits="$withval";
+],
+[])
+
+AC_ARG_WITH([upc-pts-packed-bits],
+AS_HELP_STRING(
+[--with-upc-pts-packed-bits=phase,thread,vaddr],
+[choose bit distribution in packed UPC pointer-to-shared representation]),
+[
+if test x"$lang_upc_enabled" = x"yes" ; then
+  if test x"$upc_pts_rep" = x"packed"; then
+    UPC_PTS_PHASE_SIZE=`echo "$withval" | $PERL -ne 'm/^(\d+),(\d+),(\d+)$/;
+						  print $1 if ($1+$2+$3 == 64) && $1>=1;'`
+    UPC_PTS_THREAD_SIZE=`echo "$withval" | $PERL -ne 'm/^(\d+),(\d+),(\d+)$/;
+						  print $2 if ($1+$2+$3 == 64) && $2>=1;'`
+    UPC_PTS_VADDR_SIZE=`echo "$withval" | $PERL -ne 'm/^(\d+),(\d+),(\d+)$/;
+						  print $3 if ($1+$2+$3 == 64) && $3>=20;'`
+    if test -z "$UPC_PTS_PHASE_SIZE" \
+       || test -z "$UPC_PTS_THREAD_SIZE" \
+       || test -z "$UPC_PTS_VADDR_SIZE" ; then
+      AC_MSG_ERROR([--with-upc-pts-packed-bits=phase,thread,vaddr requires
+  phase+thread+vaddr=64 and phase >= 1 and thread >= 1 and vaddr >= 20])
+    fi
+  else
+    AC_MSG_ERROR([--with-upc-pts-packed-bits is only supported for
+the packed UPC pointer-to-shared representation])
+  fi
+else
+  AC_MSG_WARN([--with-upc-pts-packed-bits is allowed only when UPC
+support has been enabled])
+fi
+],
+[
+if test x"$lang_upc_enabled" = x"yes" ; then
+  # GNU UPC packed pointer representation defaults.
+  case "$target" in
+    i[356]86* )
+      UPC_PTS_PHASE_SIZE=20
+      UPC_PTS_THREAD_SIZE=12
+      UPC_PTS_VADDR_SIZE=32
+      ;;
+    * )
+      UPC_PTS_PHASE_SIZE=20
+      UPC_PTS_THREAD_SIZE=10
+      UPC_PTS_VADDR_SIZE=34
+  esac
+fi
+])
+
+AC_ARG_ENABLE(upc-link-script,
+AS_HELP_STRING(
+  [--enable-upc-link-script],
+  [enable UPC's use of a custom linker script;
+  this will define the UPC shared section as a no load section on
+  targets where this feature is supported (requires GNU LD)]),
+[
+if test x"$lang_upc_enabled" = x"yes" ; then
+  case $enableval in
+  yes | no) ;;
+  *)
+    AC_MSG_ERROR([--enable-upc-link-script accepts only yes or no.])
+  esac
+else
+  AC_MSG_WARN([--enable-upc-link-script is allowed only when UPC
+support has been enabled])
+fi
+],
+[
+if test x"$lang_upc_enabled" = x"yes" ; then
+  enable_upc_link_script=no
+fi
+])
+
+if test x"$lang_upc_enabled" = x"yes" ; then
+  AC_MSG_CHECKING([for UPC pointer-to-shared representation])
+  AC_MSG_RESULT([$upc_pts_rep])
+  case "$upc_pts_rep" in
+    packed)
+      AC_DEFINE(HAVE_UPC_PTS_PACKED_REP,[1],
+	[Define to 1 if UPC pointer-to-shared representation
+	 is a packed 64 bit word.])
+      ;;
+    struct)
+      AC_DEFINE(HAVE_UPC_PTS_STRUCT_REP,[1],
+	[Define to 1 if UPC pointer-to-shared representation
+	 is a structure.])
+      ;;
+  esac
+  AC_MSG_CHECKING([for UPC pointer-to-shared address field position])
+  AC_MSG_RESULT([$upc_vaddr_order])
+  if test x"$upc_vaddr_order" = x"first"; then
+    AC_DEFINE(HAVE_UPC_PTS_VADDR_FIRST,[1],
+      [Define to 1 if the 'vaddr' field is the first field
+in the UPC pointer-to-shared representation.])
+  fi
+  if test x"$upc_pts_rep" = x"packed"; then
+    AC_DEFINE_UNQUOTED(UPC_PTS_PHASE_SIZE,$UPC_PTS_PHASE_SIZE,
+      [For packed UPC pointers-to-shared,
+       the size of the phase field (in bits).])
+    AC_DEFINE_UNQUOTED(UPC_PTS_THREAD_SIZE,$UPC_PTS_THREAD_SIZE,
+      [For packed UPC pointers-to-shared,
+       the size of the thread field (in bits).])
+    AC_DEFINE_UNQUOTED(UPC_PTS_VADDR_SIZE,$UPC_PTS_VADDR_SIZE,
+      [For packed UPC pointers-to-shared,
+       the size of the address field (in bits).])
+    AC_MSG_CHECKING([for packed UPC pointer-to-shared layout])
+    AC_MSG_RESULT(
+      ["phase=${UPC_PTS_PHASE_SIZE},thread=${UPC_PTS_THREAD_SIZE},
+vaddr=${UPC_PTS_VADDR_SIZE}"])
+  fi
+  AC_MSG_CHECKING([for UPC link script support])
+  AC_MSG_RESULT($enable_upc_link_script)
+  if test "$enable_upc_link_script" = yes; then
+    AC_DEFINE(HAVE_UPC_LINK_SCRIPT, 1, [Define to 1 if UPC link script is supported.])
+  fi
+fi
+
 AC_ARG_WITH(dwarf2,
 [AS_HELP_STRING([--with-dwarf2], [force the default debug format to be DWARF 2])],
 dwarf2="$with_dwarf2",
@@ -787,7 +963,7 @@  AC_ARG_WITH(specs,
 AC_SUBST(CONFIGURE_SPECS)
 
 ACX_PKGVERSION([GCC])
-ACX_BUGURL([http://gcc.gnu.org/bugs.html])
+ACX_BUGURL([http://gccupc.org/bugs])
 
 # Sanity check enable_languages in case someone does not run the toplevel
 # configure # script.
Index: gcc/cp/Make-lang.in
===================================================================
--- gcc/cp/Make-lang.in	(.../trunk)	(revision 192449)
+++ gcc/cp/Make-lang.in	(.../branches/gupc)	(revision 192459)
@@ -85,7 +85,7 @@  CXX_AND_OBJCXX_OBJS = cp/call.o cp/decl.
  cp/cp-gimplify.o $(CXX_C_OBJS)
 
 # Language-specific object files for C++.
-CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS)
+CXX_OBJS = cp/cp-lang.o $(C_STUB_OBJS) $(CXX_AND_OBJCXX_OBJS)
 
 c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o
 
Index: gcc/fortran/Make-lang.in
===================================================================
--- gcc/fortran/Make-lang.in	(.../trunk)	(revision 192449)
+++ gcc/fortran/Make-lang.in	(.../branches/gupc)	(revision 192459)
@@ -99,9 +99,10 @@  gfortran-cross$(exeext): gfortran$(exeex
 
 # The compiler itself is called f951.
 f951$(exeext): $(F95_OBJS) \
-		$(BACKEND) $(LIBDEPS) attribs.o
+		$(C_STUB_OBJS) $(BACKEND) $(LIBDEPS) attribs.o
 	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
-		$(F95_OBJS) $(BACKEND) $(LIBS) attribs.o $(BACKENDLIBS)
+		$(F95_OBJS) $(C_STUB_OBJS) \
+		$(BACKEND) $(LIBS) attribs.o $(BACKENDLIBS)
 
 gt-fortran-trans.h    : s-gtype; @true
 #
Index: gcc/java/Make-lang.in
===================================================================
--- gcc/java/Make-lang.in	(.../trunk)	(revision 192449)
+++ gcc/java/Make-lang.in	(.../branches/gupc)	(revision 192459)
@@ -98,10 +98,12 @@  java-warn = $(STRICT_WARN)
 # String length warnings
 jvspec.o-warn = -Wno-error
 
-jc1$(exeext): $(JAVA_OBJS) $(BACKEND) $(LIBDEPS) attribs.o
+jc1$(exeext): $(JAVA_OBJS) $(BACKEND) $(C_STUB_OBJS) \
+                $(LIBDEPS) attribs.o
 	rm -f $@
 	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
-		$(JAVA_OBJS) $(BACKEND) $(ZLIB) $(LIBICONV) $(LIBS) attribs.o $(BACKENDLIBS)
+		$(JAVA_OBJS) $(C_STUB_OBJS) \
+		$(BACKEND) $(ZLIB) $(LIBICONV) $(LIBS) attribs.o $(BACKENDLIBS)
 
 jcf-dump$(exeext): $(JCFDUMP_OBJS) $(LIBDEPS)
 	rm -f $@
Index: gcc/lto/Make-lang.in
===================================================================
--- gcc/lto/Make-lang.in	(.../trunk)	(revision 192449)
+++ gcc/lto/Make-lang.in	(.../branches/gupc)	(revision 192459)
@@ -73,7 +73,7 @@  lto-warn = $(STRICT_WARN)
 
 $(LTO_EXE): $(LTO_OBJS) $(BACKEND) $(LIBDEPS)
 	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
-		$(LTO_OBJS) $(BACKEND) $(BACKENDLIBS) $(LIBS)
+		$(LTO_OBJS) $(C_STUB_OBJS) $(BACKEND) $(BACKENDLIBS) $(LIBS)
 
 # Dependencies
 lto/lto-lang.o: lto/lto-lang.c $(CONFIG_H) coretypes.h debug.h \
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(.../trunk)	(revision 192449)
+++ gcc/Makefile.in	(.../branches/gupc)	(revision 192459)
@@ -1975,6 +1975,9 @@  c-family/c-ada-spec.o : c-family/c-ada-s
 c-family/stub-objc.o : c-family/stub-objc.c $(CONFIG_H) $(SYSTEM_H) \
 	coretypes.h $(TREE_H) $(C_COMMON_H) c-family/c-objc.h
 
+c-family/stub-upc.o : c-family/stub-upc.c $(CONFIG_H) $(SYSTEM_H) \
+	coretypes.h $(TREE_H) $(C_COMMON_H) c-family/c-upc.h
+
 default-c.o: config/default-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
   $(C_TARGET_H) $(C_TARGET_DEF_H)
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
Index: gcc/objc/Make-lang.in
===================================================================
--- gcc/objc/Make-lang.in	(.../trunk)	(revision 192449)
+++ gcc/objc/Make-lang.in	(.../branches/gupc)	(revision 192459)
@@ -68,9 +68,12 @@  cc1obj-checksum.c : build/genchecksum$(b
 
 cc1obj-checksum.o : cc1obj-checksum.c $(CONFIG_H) $(SYSTEM_H)
 
-cc1obj$(exeext): $(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o $(BACKEND) $(LIBDEPS)
+cc1obj$(exeext): $(OBJC_OBJS) $(C_AND_OBJC_OBJS) \
+                 c-family/stub-upc.o cc1obj-checksum.o \
+		 $(BACKEND) $(LIBDEPS)
 	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
-	      $(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o \
+	      $(OBJC_OBJS) $(C_AND_OBJC_OBJS) \
+	      c-family/stub-upc.o cc1obj-checksum.o \
 	      $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
 # Objective C language specific files.
Index: gcc/upc/config-lang.in
===================================================================
--- gcc/upc/config-lang.in	(.../trunk)	(revision 0)
+++ gcc/upc/config-lang.in	(.../branches/gupc)	(revision 192459)
@@ -0,0 +1,48 @@ 
+# upc/config-lang.in: GNU UPC runtime library top-level configure fragment
+
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+# 2009, 2010, 2011
+# Free Software Foundation, Inc.
+# Contributed by Gary Funck <gary@intrepid.com>
+#   and Nenad Vukicevic <nenad@intrepid.com>.
+# Based on original implementation
+#   by Jesse M. Draper <jdraper@super.org>
+#   and William W. Carlson <wwc@super.org>.
+# Derived from objc/config-lang.in
+
+# This file is part of GCC.
+
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Configure looks for the existence of this file to auto-config each language.
+# We define several parameters used by configure:
+#
+# language	- name of language as it would appear in $(LANGUAGES)
+# compilers	- value to add to $(COMPILERS)
+# stagestuff	- files to add to $(STAGESTUFF)
+
+language="upc"
+
+build_by_default="no"
+
+compilers="cc1upc\$(exeext)"
+
+stagestuff="cc1upc\$(exeext)"
+
+target_libs="target-libgupc"
+
+gtfiles="\$(srcdir)/c/c-lang.h \$(srcdir)/c/c-tree.h \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-upc.h \$(srcdir)/upc/upc-act.h \$(srcdir)/upc/upc-genericize.h \$(srcdir)/c/c-decl.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-cppbuiltin.c \$(srcdir)/c-family/c-pragma.c \$(srcdir)/c/c-objc-common.c \$(srcdir)/c/c-parser.c \$(srcdir)/upc/upc-act.c \$(srcdir)/upc/upc-genericize.c"
+
+extra_parts="${extra_parts} ${upc_extra_parts}"
Index: gcc/upc/Makefile.in
===================================================================
--- gcc/upc/Makefile.in	(.../trunk)	(revision 0)
+++ gcc/upc/Makefile.in	(.../branches/gupc)	(revision 192459)
@@ -0,0 +1,82 @@ 
+# Makefile.in: GNU UPC front-end Makefile
+
+#    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+#    2010, 2011
+#    Free Software Foundation, Inc.
+#    Contributed by Gary Funck <gary@intrepid.com>
+#      and Nenad Vukicevic <nenad@intrepid.com>.
+#    Based on original implementation
+#      by Jesse M. Draper <jdraper@super.org>
+#      and William W. Carlson <wwc@super.org>.
+#    Derived from objc/Makefile.in
+
+# This file is part of GCC.
+
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+#  The Makefile built from this file lives in the upc language subdirectory.
+#  Its purpose is to provide support for:
+#
+#  1. recursion where necessary, and only then (building .o's), and
+#  2. building and debugging cc1upcc from the language subdirectory.
+#
+#  The parent Makefile handles all other chores, with help from the language
+#  Makefile fragment.
+#
+#  The targets for external use are `all' and `mostlyclean'.
+
+SHELL=/bin/sh
+
+OPTIMIZE= -O
+
+srcdir = .
+VPATH = $(srcdir)
+
+AR = ar
+AR_FLAGS = rc
+
+# Define this as & to perform parallel make on a Sequent.
+# Note that this has some bugs, and it seems currently necessary 
+# to compile all the gen* files first by hand to avoid erroneous results.
+P =
+
+# Definition of `all' is here so that new rules inserted by sed
+# do not specify the default target.
+all: all.indirect
+
+# sed inserts variable overrides after the following line.
+####target overrides
+####host overrides
+####cross overrides
+####build overrides
+#
+
+# Now figure out from those variables how to compile and link.
+all.indirect: Makefile frontend
+
+frontend:
+	cd ..; $(MAKE) cc1upc$(exeext)
+
+Makefile: $(srcdir)/Makefile.in $(srcdir)/../configure
+	cd ..; $(SHELL) config.status
+
+mostlyclean:
+	-rm -f *.o xforward fflags
+clean: mostlyclean
+distclean: mostlyclean
+extraclean: mostlyclean
+
+# For Sun VPATH.
+
Index: gcc/upc/Make-lang.in
===================================================================
--- gcc/upc/Make-lang.in	(.../trunk)	(revision 0)
+++ gcc/upc/Make-lang.in	(.../branches/gupc)	(revision 192459)
@@ -0,0 +1,298 @@ 
+# Top level -*- makefile -*- fragment for GNU UPC
+
+#    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+#    2010, 2011, 2012
+#    Free Software Foundation, Inc.
+#    Contributed by Gary Funck <gary@intrepid.com>
+#      and Nenad Vukicevic <nenad@intrepid.com>.
+#    Based on original implementation
+#      by Jesse M. Draper <jdraper@super.org>
+#      and William W. Carlson <wwc@super.org>.
+#    Derived from objc/Make-lang.in
+
+# This file is part of GCC.
+
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file provides the language dependent support in the main Makefile.
+# Each language makefile fragment must provide the following targets:
+#
+# foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
+# foo.install-normal, foo.install-common, foo.install-man,
+# foo.uninstall,
+# foo.mostlyclean, foo.clean, foo.distclean,
+# foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
+#
+# where `foo' is the name of the language.
+#
+# It should also provide rules for:
+#
+# - making any compiler driver (eg: upc)
+# - the compiler proper (eg: cc1upc)
+# - define the names for selecting the language in LANGUAGES.
+
+UPC_EXE = cc1upc$(exeext) gupc$(exeext)
+
+# Installation name.
+
+GUPC_INSTALL_NAME := $(shell echo gupc|sed '$(program_transform_name)')
+UPC_INSTALL_NAME := $(shell echo upc|sed '$(program_transform_name)')
+GUPC_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gupc|sed '$(program_transform_name)')
+
+# Define the names for selecting UPC in LANGUAGES.
+UPC Upc upc: $(UPC_EXE)
+
+# Tell GNU make to ignore these if they exist.
+.PHONY: UPC Upc upc
+
+# Use maximal warnings for this front end.
+upc-warn = $(STRICT_WARN)
+
+# UPC PTS representation-dependent support.
+# (Set by the --with-upc-pts={struct,packed} configure switch.)
+UPC_PTS_C = upc-pts-packed.c upc-pts-struct.c
+UPC_PTS_OBJ = upc/upc-pts-packed.o upc/upc-pts-struct.o
+
+# Language-specific object files for UPC.
+UPC_OBJS = c-family/stub-objc.o upc/upc-act.o \
+	   upc/upc-genericize.o upc/upc-lang.o \
+	   upc/upc-gasp.o $(UPC_PTS_OBJ)
+
+cc1upc-checksum.c : build/genchecksum$(build_exeext) checksum-options \
+        $(UPC_OBJS) $(C_AND_OBJC_OBJS) $(BACKEND) $(LIBDEPS)
+	build/genchecksum$(build_exeext) $(UPC_OBJS) $(C_AND_OBJC_OBJS) \
+        $(BACKEND) $(LIBDEPS) checksum-options > cc1upc-checksum.c.tmp && \
+	$(srcdir)/../move-if-change cc1upc-checksum.c.tmp cc1upc-checksum.c
+
+cc1upc-checksum.o : cc1upc-checksum.c $(CONFIG_H) $(SYSTEM_H)
+
+cc1upc$(exeext): $(UPC_OBJS) $(C_AND_OBJC_OBJS) cc1upc-checksum.o \
+		 $(BACKEND) $(LIBDEPS)
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
+		$(UPC_OBJS) $(C_AND_OBJC_OBJS) cc1upc-checksum.o \
+		$(BACKEND) $(LIBS) $(BACKENDLIBS)
+
+# Create the compiler driver gupc.
+gupcspec.o: $(srcdir)/upc/gupcspec.c $(SYSTEM_H) $(TM_H) $(GCC_H) \
+	$(CONFIG_H) coretypes.h intl.h $(OPTS_H)
+	(SHLIB='$(SHLIB)'; \
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
+	    $(INCLUDES) $(srcdir)/upc/gupcspec.c)
+
+GUPC_D_OBJS = $(GCC_OBJS) gupcspec.o
+gupc$(exeext): $(GUPC_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
+	  $(GUPC_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
+	  $(EXTRA_GCC_LIBS) $(LIBS)
+
+#
+# UPC language specific files.
+#
+upc/upc-lang.o : upc/upc-lang.c \
+   $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
+   $(C_TREE_H) upc/upc-tree.h toplev.h \
+   $(C_PRETTY_PRINT_H) $(DIAGNOSTIC_H) \
+   $(GGC_H) langhooks.h $(LANGHOOKS_DEF_H) $(C_COMMON_H) \
+   gtype-upc.h gt-upc-upc-act.h upc/upc-act.h upc/upc-pts.h
+
+upc/upc-act.o : upc/upc-act.c \
+   $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) \
+   $(TM_P_H) $(EXPR_H) $(TARGET_H) $(C_TREE_H) diagnostic.h toplev.h \
+   flags.h input.h function.h output.h debug.h langhooks.h \
+   $(LANGHOOKS_DEF_H) $(HASHTAB_H) c-family/c-pragma.h \
+   gtype-upc.h gt-upc-upc-act.h upc/upc-act.h upc/upc-pts.h \
+   upc/upc-rts-names.h
+
+upc/upc-genericize.o : upc/upc-genericize.c \
+   $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) \
+   $(TM_P_H) $(EXPR_H) $(TARGET_H) $(C_TREE_H) diagnostic.h \
+   toplev.h flags.h input.h function.h output.h debug.h langhooks.h \
+   $(LANGHOOKS_DEF_H) $(HASHTAB_H) c-family/c-pragma.h \
+   upc/upc-genericize.h upc/upc-tree.h upc/upc-act.h upc/upc-pts.h \
+   gtype-upc.h gt-upc-upc-genericize.h upc/upc-act.h upc/upc-pts.h \
+   upc/upc-rts-names.h
+
+upc/upc-pts-packed.o: upc/upc-pts-packed.c \
+   $(CONFIG_H) $(SYSTEM_H) $(TARGET_H) $(TM_H) $(TM_P_H) \
+   $(TREE_H) coretypes.h $(LANGHOOKS_DEF_H) langhooks.h \
+   c-family/c-pragma.h $(C_TREE_H) debug.h \
+   diagnostic.h $(EXPR_H) flags.h function.h input.h \
+   output.h $(RTL_H) toplev.h \
+   upc/upc-act.h upc/upc-pts.h upc/upc-rts-names.h
+
+upc/upc-pts-struct.o: upc/upc-pts-struct.c \
+   $(CONFIG_H) $(SYSTEM_H) $(TARGET_H) $(TM_H) $(TM_P_H) \
+   $(TREE_H) coretypes.h $(LANGHOOKS_DEF_H) langhooks.h \
+   c-family/c-pragma.h $(C_TREE_H) debug.h \
+   diagnostic.h $(EXPR_H) flags.h function.h input.h \
+   output.h $(RTL_H) toplev.h \
+   upc/upc-act.h upc/upc-pts.h upc/upc-rts-names.h
+
+upc/upc-gasp.o : upc/upc-gasp.c \
+   $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) \
+   $(TM_P_H) $(EXPR_H) $(TARGET_H) $(C_TREE_H) diagnostic.h \
+   toplev.h flags.h input.h function.h output.h debug.h langhooks.h \
+   $(LANGHOOKS_DEF_H) $(HASHTAB_H) c-family/c-pragma.h \
+   upc/upc-gasp.h upc/upc-tree.h upc/upc-act.h upc/upc-pts.h \
+   upc/upc-rts-names.h
+
+#
+# Documentation
+
+UPC_TEXI_FILES = \
+	upc/gupc.texi \
+        $(gcc_docdir)/include/fdl.texi \
+	$(gcc_docdir)/include/gpl_v3.texi \
+	$(gcc_docdir)/include/gcc-common.texi \
+	gcc-vers.texi
+
+doc/gupc.info: $(UPC_TEXI_FILES)
+	if test "x$(BUILD_INFO)" = xinfo; then \
+	  rm -f doc/gupc.info*; \
+	  $(MAKEINFO) $(MAKEINFOFLAGS) -I. -I $(gcc_docdir) \
+		-I $(gcc_docdir)/include -o $@ $<; \
+	else true; fi
+
+doc/gupc.dvi: $(UPC_TEXI_FILES)
+	$(TEXI2DVI) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
+
+doc/gupc.pdf: $(UPC_TEXI_FILES)
+	$(TEXI2PDF) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
+
+$(build_htmldir)/upc/index.html: $(UPC_TEXI_FILES)
+	$(mkinstalldirs) $(@D)
+	rm -f $(@D)/*
+	$(TEXI2HTML) -I $(gcc_docdir) -I $(gcc_docdir)/include \
+		-I $(srcdir)/upc -o $(@D) $<
+
+.INTERMEDIATE: gupc.pod
+
+gupc.pod: upc/gupc.texi
+	-$(TEXI2POD) -D gupc < $< > $@
+
+#
+# Build hooks:
+
+upc.all.build:
+upc.all.cross:
+upc.start.encap:
+upc.rest.encap:
+upc.info: doc/gupc.info
+upc.dvi: doc/gupc.dvi
+upc.pdf: doc/gupc.pdf
+upc.html: $(build_htmldir)/upc/index.html
+upc.srcinfo:
+	-cp -p $^ $(srcdir)/doc
+upc.man: doc/gupc.1
+upc.srcman: doc/gupc.1
+	-cp -p $^ $(srcdir)/doc
+upc.srcextra:
+upc.install-pdf:
+upc.install-plugin:
+
+upc.tags: force
+	cd $(srcdir)/upc; etags -o TAGS.sub *.y *.c *.h; \
+	etags --include TAGS.sub --include ../TAGS.sub
+
+lang_checks += check-upc
+
+#
+# Install hooks:
+# cc1upc is installed elsewhere as part of $(COMPILERS).
+
+upc.install-common: cc1upc$(exeext) gupc$(exeext) installdirs
+	-rm -f $(DESTDIR)$(bindir)/$(GUPC_INSTALL_NAME)$(exeext)
+	$(INSTALL_PROGRAM) -m 755 gupc$(exeext) $(DESTDIR)$(bindir)/$(GUPC_INSTALL_NAME)$(exeext)
+	-rm -f $(DESTDIR)$(bindir)/$(GUPC_TARGET_INSTALL_NAME)$(exeext)
+	cd $(DESTDIR)$(bindir) && \
+	   $(LN) $(GUPC_INSTALL_NAME)$(exeext) $(GUPC_TARGET_INSTALL_NAME)$(exeext)
+	-rm -f $(DESTDIR)$(bindir)/$(UPC_INSTALL_NAME)$(exeext)
+	cd $(DESTDIR)$(bindir) && $(LN_S) $(GUPC_INSTALL_NAME)$(exeext) $(UPC_INSTALL_NAME)$(exeext)
+
+upc.install-plugin:
+
+upc.install-info: $(DESTDIR)$(infodir)/gupc.info
+
+upc.install-pdf: doc/gupc.pdf
+	@$(NORMAL_INSTALL)
+	test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
+	@for p in doc/gupc.pdf; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(pdf__strip_dir) \
+	  echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \
+	  $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \
+	done
+
+upc.install-html: $(build_htmldir)/upc
+	@$(NORMAL_INSTALL)
+	test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)"
+	@for p in $(build_htmldir)/upc; do \
+	  if test -f "$$p" || test -d "$$p"; then d=""; else d="$(srcdir)/"; fi; \
+	  f=$(html__strip_dir) \
+	  if test -d "$$d$$p"; then \
+	    echo " $(mkinstalldirs) '$(DESTDIR)$(htmldir)/$$f'"; \
+	    $(mkinstalldirs) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
+	    echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \
+	    $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \
+	  else \
+	    echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
+	    $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
+	  fi; \
+	done
+
+upc.install-man: $(DESTDIR)$(man1dir)/$(GUPC_INSTALL_NAME)$(man1ext)
+
+$(DESTDIR)$(man1dir)/$(GUPC_INSTALL_NAME)$(man1ext): doc/gupc.1 installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+	-chmod a-x $@
+
+upc.uninstall:
+	rm -rf $(DESTDIR)$(bindir)/$(GUPC_INSTALL_NAME)$(exeext)
+	rm -rf $(DESTDIR)$(bindir)/$(UPC_INSTALL_NAME)$(exeext)
+	rm -rf $(DESTDIR)$(man1dir)/$(GUPC_INSTALL_NAME)$(man1ext)
+	rm -rf $(DESTDIR)$(bindir)/$(GUPC_TARGET_INSTALL_NAME)$(exeext)
+	rm -rf $(DESTDIR)$(infodir)/gupc.info*
+
+#
+# Clean hooks:
+# A lot of the ancillary files are deleted by the main makefile.
+# We just have to delete files specific to us.
+upc.mostlyclean:
+	-rm -f tmp-upc-prs.y
+	-rm -f upc/*$(objext) upc/xforward upc/fflags
+	-rm -f upc/*$(coverageexts)
+upc.clean: upc.mostlyclean
+	-rm -rf upc-headers
+upc.distclean:
+	-rm -f upc/Makefile upc/Make-host upc/Make-target
+	-rm -f upc/config.status upc/config.cache
+upc.maintainer-clean:
+
+#
+# Stage hooks:
+
+upc.stage1: stage1-start
+	-mv upc/*$(objext) stage1/upc
+upc.stage2: stage2-start
+	-mv upc/*$(objext) stage2/upc
+upc.stage3: stage3-start
+	-mv upc/*$(objext) stage3/upc
+upc.stage4: stage4-start
+	-mv upc/*$(objext) stage4/upc
+upc.stageprofile: stageprofile-start
+	-mv upc/*$(objext) stageprofile/upc
+upc.stagefeedback: stagefeedback-start
+	-mv upc/*$(objext) stagefeedback/upc
Index: Makefile.def
===================================================================
--- Makefile.def	(.../trunk)	(revision 192449)
+++ Makefile.def	(.../branches/gupc)	(revision 192459)
@@ -126,6 +126,7 @@  target_modules = { module= libbacktrace;
 target_modules = { module= libquadmath; };
 target_modules = { module= libgfortran; };
 target_modules = { module= libobjc; };
+target_modules = { module= libgupc; };
 target_modules = { module= libgo; };
 target_modules = { module= libtermcap; no_check=true;
                    missing=mostlyclean;
@@ -256,6 +257,8 @@  flags_to_pass = { flag= GCJ_FOR_TARGET ;
 flags_to_pass = { flag= GFORTRAN_FOR_TARGET ; };
 flags_to_pass = { flag= GOC_FOR_TARGET ; };
 flags_to_pass = { flag= GOCFLAGS_FOR_TARGET ; };
+flags_to_pass = { flag= GUPC_FOR_TARGET ; };
+flags_to_pass = { flag= GUPCFLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= LD_FOR_TARGET ; };
 flags_to_pass = { flag= LIPO_FOR_TARGET ; };
 flags_to_pass = { flag= LDFLAGS_FOR_TARGET ; };
@@ -507,6 +510,9 @@  dependencies = { module=configure-target
 // generated by the libgomp configure.  Unfortunately, due to the use of
 //  recursive make, we can't be that specific.
 dependencies = { module=all-target-libstdc++-v3; on=configure-target-libgomp; };
+// Installing UPC headers must follow gcc install because
+// gcc removes and then recreates the include directory.
+dependencies = { module=install-target-libgupc; on=install-gcc; };
 
 // Target modules in the 'src' repository.
 lang_env_dependencies = { module=libtermcap; };
@@ -534,6 +540,8 @@  languages = { language=ada;	gcc-check-ta
 				lib-check-target=check-target-libada; };
 languages = { language=objc;	gcc-check-target=check-objc;
 				lib-check-target=check-target-libobjc; };
+languages = { language=upc;	gcc-check-target=check-upc;
+				lib-check-target=check-target-libgupc; };
 languages = { language=obj-c++;	gcc-check-target=check-obj-c++; };
 languages = { language=go;	gcc-check-target=check-go;
 				lib-check-target=check-target-libgo; };
Index: Makefile.tpl
===================================================================
--- Makefile.tpl	(.../trunk)	(revision 192449)
+++ Makefile.tpl	(.../branches/gupc)	(revision 192459)
@@ -160,6 +160,8 @@  BUILD_EXPORTS = \
 	GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
 	GOC="$(GOC_FOR_BUILD)"; export GOC; \
 	GOCFLAGS="$(GOCFLAGS_FOR_BUILD)"; export GOCFLAGS; \
+	GUPC="$(GUPC_FOR_BUILD)"; export GUPC; \
+	GUPCFLAGS="$(GUPCFLAGS_FOR_BUILD)"; export GUPCFLAGS; \
 	DLLTOOL="$(DLLTOOL_FOR_BUILD)"; export DLLTOOL; \
 	LD="$(LD_FOR_BUILD)"; export LD; \
 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"; export LDFLAGS; \
@@ -197,6 +199,7 @@  HOST_EXPORTS = \
 	GCJ="$(GCJ)"; export GCJ; \
 	GFORTRAN="$(GFORTRAN)"; export GFORTRAN; \
 	GOC="$(GOC)"; export GOC; \
+	GUPC="$(GUPC)"; export GUPC; \
 	AR="$(AR)"; export AR; \
 	AS="$(AS)"; export AS; \
 	CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
@@ -282,6 +285,7 @@  BASE_TARGET_EXPORTS = \
 	GCJ="$(GCJ_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GCJ; \
 	GFORTRAN="$(GFORTRAN_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GFORTRAN; \
 	GOC="$(GOC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GOC; \
+	GUPC="$(GUPC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GUPC; \
 	DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \
 	LD="$(COMPILER_LD_FOR_TARGET)"; export LD; \
 	LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \
@@ -351,6 +355,7 @@  DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@
 GCJ_FOR_BUILD = @GCJ_FOR_BUILD@
 GFORTRAN_FOR_BUILD = @GFORTRAN_FOR_BUILD@
 GOC_FOR_BUILD = @GOC_FOR_BUILD@
+GUPC_FOR_BUILD = @GUPC_FOR_BUILD@
 LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
 LD_FOR_BUILD = @LD_FOR_BUILD@
 NM_FOR_BUILD = @NM_FOR_BUILD@
@@ -415,6 +420,7 @@  LIBCFLAGS = $(CFLAGS)
 CXXFLAGS = @CXXFLAGS@
 LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
 GOCFLAGS = $(CFLAGS)
+GUPCFLAGS = $(CFLAGS)
 
 TFLAGS =
 
@@ -481,6 +487,7 @@  RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @
 GCJ_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCJ_FOR_TARGET@
 GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@
 GOC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GOC_FOR_TARGET@
+GUPC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GUPC_FOR_TARGET@
 DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@
 LD_FOR_TARGET=@LD_FOR_TARGET@
 
@@ -504,6 +511,7 @@  LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARG
 LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
 LDFLAGS_FOR_TARGET = @LDFLAGS_FOR_TARGET@
 GOCFLAGS_FOR_TARGET = -O2 -g
+GUPCFLAGS_FOR_TARGET = -O2 -g
 
 FLAGS_FOR_TARGET = @FLAGS_FOR_TARGET@
 SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
@@ -603,6 +611,7 @@  EXTRA_HOST_FLAGS = \
 	'GCJ=$(GCJ)' \
 	'GFORTRAN=$(GFORTRAN)' \
 	'GOC=$(GOC)' \
+	'GUPC=$(GUPC)' \
 	'LD=$(LD)' \
 	'LIPO=$(LIPO)' \
 	'NM=$(NM)' \
@@ -642,6 +651,8 @@  EXTRA_TARGET_FLAGS = \
 	'GFORTRAN=$$(GFORTRAN_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
 	'GOC=$$(GOC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
 	'GOCFLAGS=$$(GOCFLAGS_FOR_TARGET)' \
+	'GUPC=$$(GUPC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
+	'GUPCFLAGS=$$(GUPCFLAGS_FOR_TARGET)' \
 	'LD=$(COMPILER_LD_FOR_TARGET)' \
 	'LDFLAGS=$$(LDFLAGS_FOR_TARGET)' \
 	'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \