Re: [RFA PATCH, ia64]: Put soft-FP exception handler out-of-line

2012-06-12 Thread Uros Bizjak
On Tue, Jun 12, 2012 at 12:31 PM, Uros Bizjak  wrote:

> Similar to x86, this patch puts soft-FP exception handler out-of-line.
> The patch also cleans asm constraints a bit (introduces "+"), but has
> no other functional changes.
>
> 2012-06-12  Uros Bizjak  
>
>        * config/ia64/sfp-machine.h (__sfp_handle_exceptions): New
>        function declaration.
>        (FP_EX_MASK): New.
>        (FP_HANDLE_EXCEPTIONS): Use __sfp_handle_exceptions.
>        * config/ia64/sfp-exceptions.c: New.
>        * config/ia64/t-softfp (LIB2ADD): Add sfp-exceptions.c.
>
> The patch is only compile tested, needs someone to regression test it ...

I have bootstrapped and regression tested the patch on
ia64-unknown-linux-gnu (gcc60) without problems. Also, I have checked
that exceptions are generated correctly with various __float128
testcases involving feenableexcept.

If there are no further objections, I plan to commit the patch to 4.8 tomorrow.

Uros.


Re: [PATCH] Add option for dumping to stderr (issue6190057)

2012-06-12 Thread Sharad Singhai
Ping.

Thanks,
Sharad

On Thu, Jun 7, 2012 at 10:16 PM, Sharad Singhai  wrote:
> Okay, I have updated the attached patch so that the output from
> -ftree-vectorizer-verbose is considered diagnostic information and is
> always
> sent to stderr. Other functionality remains unchanged. Here is some
> more context about this patch.
>
> This patch improves the dump infrastructure and public interfaces so
> that the existing private pass-specific dump stream is separated from
> the diagnostic dump stream (typically stderr).  The optimization
> passes can output information on the two streams independently.
>
> The newly defined interfaces are:
>
> Individual passes do not need to access the dump file directly. Thus Instead
> of doing
>
>   if (dump_file && (flags & dump_flags))
>      fprintf (dump_file, ...);
>
> they can do
>
>     dump_printf (flags, ...);
>
> If the current pass has FLAGS enabled then the information gets
> printed into the dump file otherwise not.
>
> Similar to the dump_printf (), another function is defined, called
>
>        diag_printf (dump_flags, ...)
>
> This prints information only onto the diagnostic stream, typically
> standard error. It is useful for separating pass-specific dump
> information from
> the diagnostic information.
>
> Currently, as a proof of concept, I have converted vectorizer passes
> to use the new dump format. For this, I have considered
> information printed in vect_dump file as diagnostic. Thus 'fprintf'
> calls are changed to 'diag_printf'. Some other information printed to
> dump_file is sent to the regular dump file via 'dump_printf ()'. It
> helps to separate the two streams because they might serve different
> purposes and might have different formatting requirements.
>
> For example, using the trunk compiler, the following invocation
>
> g++ -S v.cc -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=2
>
> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
> However, the verbose diagnostic output is silently
> ignored. This is not desirable as the two types of dump should not interfere.
>
> After this patch, the vectorizer dump is available in 'v.cc.113t.vect'
> as before, but the verbose vectorizer diagnostic is additionally
> printed on stderr. Thus both types of dump information are output.
>
> An additional feature of this patch is that individual passes can
> print dump information into command-line named files instead of auto
> numbered filename. For example,
>
> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>     -ftree-vectorizer-verbose=2
>     -fdump-tree-pre=foo.pre
>
> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>
> Please take another look.
>
> Thanks,
> Sharad
>
>
> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li  wrote:
>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai  wrote:
>>> Sorry about the delay. I have finally incorporated all the suggestions
>>> and reorganized the dump infrastructure a bit. The attached patch
>>> updates vectorizer passes so that instead of accessing global
>>> dump_file directly, these passes call dump_printf (FLAG, format, ...).
>>> The dump_printf can choose between two streams, one regular pass dump
>>> file, and another optional command line provided file. Currently, it
>>> doesn't discriminate and all the dump information goes to both the
>>> streams.
>>>
>>> Thus, for example,
>>>
>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v 
>>> -ftree-vectorizer-verbose=3
>>
>> But the default form of dump option (-fdump-tree-vect) no longer
>> interferes with -ftree-vectorize-verbose=xxx output right? (this is
>> one of the main requirements). One dumped to the primary stream (named
>> dump file) and the other to the stderr -- the default diagnostic (alt)
>> stream.
>>
>> David
>>
>>>
>>> will output the verbose vectorizer information in both *.vect file and
>>> foo.v file. However, as I have converted only vectorizer passes so
>>> far, there is additional information in *.vect file which is not
>>> present in foo.v file. Once other passes are converted to use this
>>> scheme, then these two dump files should have identical output.
>>>
>>> Also note that in this patch -fdump-xxx=yyy format does not override
>>> any auto named dump files as in my earlier patches. Instead the dump
>>> information is output to both places when a command line dump file
>>> option is provided.
>>>
>>> To summarize:
>>> - instead of using dump_begin () / dump_end (), the passes should use
>>> dump_start ()/dump_finish (). These new variants do not return the
>>> dump_file. However, they still set the global dump_file/dump_flags for
>>> the benefit of other passes during the transition.
>>> - instead of directly printing to the dump_file, as in
>>> if (dump_file)
>>>  fprintf (dump_file, ...);
>>>
>>> The passes should do
>>>
>>> dump_printf (dump_flag, ...);
>>> This will output to dump file(s) only wh

libgo patch committed: Use Entersyscall in os/user

2012-06-12 Thread Ian Lance Taylor
This patch to libgo uses Entersyscall and Exitsyscall as appropriate in
os/user.  This is necessary if the lookup uses something like LDAP.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r 3f26ed600514 libgo/go/os/user/lookup_unix.go
--- a/libgo/go/os/user/lookup_unix.go	Tue Jun 12 21:46:14 2012 -0700
+++ b/libgo/go/os/user/lookup_unix.go	Tue Jun 12 22:54:06 2012 -0700
@@ -73,11 +73,14 @@
 	const bufSize = 1024
 	buf := make([]byte, bufSize)
 	if lookupByName {
-		rv := libc_getpwnam_r(syscall.StringBytePtr(username),
+		p := syscall.StringBytePtr(username)
+		syscall.Entersyscall()
+		rv := libc_getpwnam_r(p,
 			&pwd,
 			&buf[0],
 			bufSize,
 			&result)
+		syscall.Exitsyscall()
 		if rv != 0 {
 			return nil, fmt.Errorf("user: lookup username %s: %s", username, syscall.GetErrno())
 		}
@@ -85,11 +88,13 @@
 			return nil, UnknownUserError(username)
 		}
 	} else {
+		syscall.Entersyscall()
 		rv := libc_getpwuid_r(syscall.Uid_t(uid),
 			&pwd,
 			&buf[0],
 			bufSize,
 			&result)
+		syscall.Exitsyscall()
 		if rv != 0 {
 			return nil, fmt.Errorf("user: lookup userid %d: %s", uid, syscall.GetErrno())
 		}


[PATCH 3/3] Avoid emitting useless instructions in mips_process_sync_loop.

2012-06-12 Thread Maxim Kuvyrkov

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics




0003-Avoid-emitting-useless-instructions-in-mips_process_.patch
Description: Binary data


Re: [PATCH, MIPS] Add most common atomic patterns

2012-06-12 Thread Andrew Pinski
On Tue, Jun 12, 2012 at 10:50 PM, Maxim Kuvyrkov  wrote:
> This patch series adds necessary patterns for __atomic_compare_exchange[_n], 
> __atomic_exchange[_n] and __atomic_fetch_add builtins.  These are the 
> builtins that correspond to inline assembly that MIPS GLIBC port is using.
>
> The patches were originally developed by Tom de Vries a while ago, and I've 
> rewrote parts of them to be better suited for upstream.
>
> The second patch adds XLP-specific patterns to support its swap and ldadd 
> instructions.  Unfortunately, there seem to be a problem in reload that 
> prevents reload from properly spilling address for these two patterns.  I 
> will work with reload experts on investigating and fixing this problem, but, 
> meanwhile, the patch contains a workaround that avoids the problem.
>
> The third patch is a small optimization to alleviate 
> __atomic_compare_exchange[_n] builtins being a use-one-for-all solutions.  
> These builtins return both boolean "success" and "oldval" results.  As most 
> cases use only one of the results, this optimizations looks at REG_UNUSED 
> notes to determine if instructions to set these results can be omitted.
>
> The patch series was tested by running GLIBC testsuite for n32, n64 and o32 
> ABIs on XLP and [in-progress] non-XLP MIPS boards with no regressions with a 
> corresponding patch to MIPS GLIBC port to use the new atomic builtins.

Once this goes in, I will most likely start adding the Octeon+ and
Octeon2 specific atomic instructions support.

Thanks,
Andrew Pinski

>
> --
> Maxim Kuvyrkov
> CodeSourcery / Mentor Graphics
>
>
>


[PATCH 2/3] Add XLP-specific atomic instructions and tweaks.

2012-06-12 Thread Maxim Kuvyrkov

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics




0002-Add-XLP-specific-atomic-instructions-and-tweaks.patch
Description: Binary data


[PATCH 1/3] Add atomic_compare_and_swap, atomic_exchange and atomic_fetch_add patterns.

2012-06-12 Thread Maxim Kuvyrkov
--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics



0001-Add-atomic_compare_and_swap-atomic_exchange-and-atom.patch
Description: Binary data


[PATCH, MIPS] Add most common atomic patterns

2012-06-12 Thread Maxim Kuvyrkov
This patch series adds necessary patterns for __atomic_compare_exchange[_n], 
__atomic_exchange[_n] and __atomic_fetch_add builtins.  These are the builtins 
that correspond to inline assembly that MIPS GLIBC port is using.

The patches were originally developed by Tom de Vries a while ago, and I've 
rewrote parts of them to be better suited for upstream.

The second patch adds XLP-specific patterns to support its swap and ldadd 
instructions.  Unfortunately, there seem to be a problem in reload that 
prevents reload from properly spilling address for these two patterns.  I will 
work with reload experts on investigating and fixing this problem, but, 
meanwhile, the patch contains a workaround that avoids the problem.

The third patch is a small optimization to alleviate 
__atomic_compare_exchange[_n] builtins being a use-one-for-all solutions.  
These builtins return both boolean "success" and "oldval" results.  As most 
cases use only one of the results, this optimizations looks at REG_UNUSED notes 
to determine if instructions to set these results can be omitted.

The patch series was tested by running GLIBC testsuite for n32, n64 and o32 
ABIs on XLP and [in-progress] non-XLP MIPS boards with no regressions with a 
corresponding patch to MIPS GLIBC port to use the new atomic builtins.

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics





Re: C++ PATCH for c++/48370 (extending lifetime of temps in aggregate initialization)

2012-06-12 Thread H.J. Lu
On Thu, Nov 3, 2011 at 8:50 PM, Jason Merrill  wrote:
> 12.2 states that a temporary bound to a reference lives as long as the
> reference itself.  We have done that for reference variables, but not in
> other cases, such as aggregate initialization of a struct with reference
> members.  In C++11, elements of a std::initializer_list have the same
> semantics; they live as long as the std::initializer_list.  Again, we were
> implementing that for initializer_list variables but not for
> initializer_list subobjects.  This patch fixes that.
>
> Furthermore, if a temporary's lifetime is extended, we need to also extend
> the lifetimes of any temporaries bound to references in its initializer, and
> so on.
>
> The patch introduces a function extend_ref_init_temps called from
> store_init_value after the call to digest_init.  To expose elements of an
> initializer_list to this function, I needed to stop using
> build_aggr_init_full_exprs for aggregate initialization of arrays, and
> consequently needed to call build_vec_init from store_init_value to use one
> EH region for cleaning up the whole array rather than one per element.  To
> deal with multiple extended temporaries, we need to change the cleanup
> pointer from a single tree to a VEC, and add a discriminator to the mangled
> name of reference init temporaries; this has no ABI impact, since the
> temporaries have no linkage, but I also updated the demangler accordingly.
>
> Since we now do lifetime extension in extend_ref_init_temps, we can
> drastically simplify initialize_reference and do away with
> build_init_list_var_init.
>
> Tested x86_64-pc-linux-gnu, applying to trunk.

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53650

-- 
H.J.


libgo patch committed: Use Entersyscall when reading directories

2012-06-12 Thread Ian Lance Taylor
This patch to libgo uses Entersyscall and Exitsyscall when reading
directory entries.  This matters when reading a directory from something
that can stall, such as NFS or a user-mounted file system.  Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian

diff -r 4700079bacc2 libgo/go/os/dir.go
--- a/libgo/go/os/dir.go	Tue Jun 12 13:32:45 2012 -0700
+++ b/libgo/go/os/dir.go	Tue Jun 12 21:45:10 2012 -0700
@@ -42,7 +42,11 @@
 	if file.dirinfo == nil {
 		file.dirinfo = new(dirInfo)
 		file.dirinfo.buf = make([]byte, elen)
-		file.dirinfo.dir = libc_opendir(syscall.StringBytePtr(file.name))
+		p := syscall.StringBytePtr(file.name)
+		syscall.Entersyscall()
+		r := libc_opendir(p)
+		syscall.Exitsyscall()
+		file.dirinfo.dir = r
 	}
 
 	entry_dirent := unsafe.Pointer(&file.dirinfo.buf[0]).(*syscall.Dirent)
@@ -62,7 +66,10 @@
 
 	for n != 0 {
 		var result *syscall.Dirent
-		i := libc_readdir_r(dir, entry_dirent, &result)
+		pr := &result
+		syscall.Entersyscall()
+		i := libc_readdir_r(dir, entry_dirent, pr)
+		syscall.Exitsyscall()
 		if i != 0 {
 			return names, NewSyscallError("readdir_r", i)
 		}


Re: Updated to respond to various email comments from Jason, Diego and Cary (issue6197069)

2012-06-12 Thread Jason Merrill

On 06/08/2012 05:22 PM, Cary Coutant wrote:

I kind of prefer -g, but I did notice that it's -fdebug-types-section,
so I could go with -f[no-]pubnames (or, as Jakub suggests,
-f[no-]debug-pubnames-section). On the other hand, there's
-g[no-]record-gcc-switches. What would you prefer?

If we change it, should we also change (in a later patch)
-gsplit-dwarf (orig. -gfission) to -fsplit-dwarf?


I lean toward -g myself, since there doesn't seem to be a strong rule 
one way or the other.


Jason


[PATCH, RFC] First cut at using vec_construct for strided loads

2012-06-12 Thread William J. Schmidt
This patch is a follow-up to the discussion generated by
http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00546.html.  I've added
vec_construct to the cost model for use in vect_model_load_cost, and
implemented a cost calculation that makes sense to me for PowerPC.  I'm
less certain about the default, i386, and spu implementations.  I took a
guess at i386 from the discussions we had, and used the same calculation
for the default and for spu.  I'm hoping you or others can fill in the
blanks if I guessed badly.

The i386 cost for vec_construct is different from all the others, which
are parameterized for each processor description.  This should probably
be parameterized in some way as well, but thought you'd know better than
I how that should be.  Perhaps instead of

elements / 2 + 1

it should be

(elements / 2) * X + Y

where X and Y are taken from the processor description, and represent
the cost of a merge and a permute, respectively.  Let me know what you
think.

Thanks,
Bill


2012-06-12  Bill Schmidt  

* targhooks.c (default_builtin_vectorized_conversion): Handle
vec_construct, using vectype to base cost on subparts.
* target.h (enum vect_cost_for_stmt): Add vec_construct.
* tree-vect-stmts.c (vect_model_load_cost): Use vec_construct
instead of scalar_to-vec.
* config/spu/spu.c (spu_builtin_vectorization_cost): Handle
vec_construct in same way as default for now.
* config/i386/i386.c (ix86_builtin_vectorization_cost): Likewise.
* config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost):
Handle vec_construct, including special case for 32-bit loads.


Index: gcc/targhooks.c
===
--- gcc/targhooks.c (revision 188482)
+++ gcc/targhooks.c (working copy)
@@ -499,9 +499,11 @@ default_builtin_vectorized_conversion (unsigned in
 
 int
 default_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
-tree vectype ATTRIBUTE_UNUSED,
+tree vectype,
 int misalign ATTRIBUTE_UNUSED)
 {
+  unsigned elements;
+
   switch (type_of_cost)
 {
   case scalar_stmt:
@@ -524,6 +526,11 @@ default_builtin_vectorization_cost (enum vect_cost
   case cond_branch_taken:
 return 3;
 
+  case vec_construct:
+   elements = TYPE_VECTOR_SUBPARTS (vectype);
+   gcc_assert (elements > 1);
+   return elements / 2 + 1;
+
   default:
 gcc_unreachable ();
 }
Index: gcc/target.h
===
--- gcc/target.h(revision 188482)
+++ gcc/target.h(working copy)
@@ -146,7 +146,8 @@ enum vect_cost_for_stmt
   cond_branch_not_taken,
   cond_branch_taken,
   vec_perm,
-  vec_promote_demote
+  vec_promote_demote,
+  vec_construct
 };
 
 /* The target structure.  This holds all the backend hooks.  */
Index: gcc/tree-vect-stmts.c
===
--- gcc/tree-vect-stmts.c   (revision 188482)
+++ gcc/tree-vect-stmts.c   (working copy)
@@ -1031,11 +1031,13 @@ vect_model_load_cost (stmt_vec_info stmt_info, int
   /* The loads themselves.  */
   if (STMT_VINFO_STRIDE_LOAD_P (stmt_info))
 {
-  /* N scalar loads plus gathering them into a vector.
- ???  scalar_to_vec isn't the cost for that.  */
+  /* N scalar loads plus gathering them into a vector.  */
+  tree vectype = STMT_VINFO_VECTYPE (stmt_info);
   inside_cost += (vect_get_stmt_cost (scalar_load) * ncopies
- * TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info)));
-  inside_cost += ncopies * vect_get_stmt_cost (scalar_to_vec);
+ * TYPE_VECTOR_SUBPARTS (vectype));
+  inside_cost += ncopies
+   * targetm.vectorize.builtin_vectorization_cost (vec_construct,
+   vectype, 0);
 }
   else
 vect_get_load_cost (first_dr, ncopies,
Index: gcc/config/spu/spu.c
===
--- gcc/config/spu/spu.c(revision 188482)
+++ gcc/config/spu/spu.c(working copy)
@@ -6908,9 +6908,11 @@ spu_builtin_mask_for_load (void)
 /* Implement targetm.vectorize.builtin_vectorization_cost.  */
 static int 
 spu_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
-tree vectype ATTRIBUTE_UNUSED,
+tree vectype,
 int misalign ATTRIBUTE_UNUSED)
 {
+  unsigned elements;
+
   switch (type_of_cost)
 {
   case scalar_stmt:
@@ -6937,6 +6939,11 @@ spu_builtin_vectorization_cost (enum vect_cost_for
   case cond_branch_taken:
 return 6;
 
+  case vec_construct:
+   elements = TYPE_VECTOR_SUBPARTS (vectype);
+   gcc_assert (elements > 1);
+ 

Re: [RFA:] Caveat for ARM in gcc-4.7/changes.html: unaligned accesses

2012-06-12 Thread Hans-Peter Nilsson
> From: Michael Hope 
> Date: Wed, 13 Jun 2012 00:43:47 +0200

> On 13 June 2012 02:32, Hans-Peter Nilsson  wrote:
> >> From: Hans-Peter Nilsson 
> >> Date: Mon, 11 Jun 2012 00:59:57 +0200
> >> > > user-space code".  Maybe the kernel too, I can't say; there was
> >> > > IIRC no sign of it.
> > But (at least) after removing some local changed defaults,
> > there's at boot-time a lot of:
> >
> > [    0.95] Unhandled fault: alignment exception (0x801) at 0xc821ddee
> 
> That's a kernel address.

Yes I know, there's no mystery there.  My point was that
misalignment traps for this configuration happen at boot time
too, not just from userspace, hence correcting my earlier
statement.

> For reference, the message comes from
> arch/arm/mm/alignment.c:alignment_init() from the default trap
> handler.

No news there.

> The lines just before this disable the unaligned trap for
> usermode:
> 
>   if (cpu_is_v6_unaligned()) {
>   cr_alignment &= ~CR_A;
>   cr_no_alignment &= ~CR_A;
>   set_cr(cr_alignment);
>   ai_usermode = safe_usermode(ai_usermode, false);
>   }
> 
> Support was added by Russell King in 2008-12 and updated by Dave
> Martin on 2011-07.

I see it, for example in stock 2.6.35.9.

> Out of interest, does your CPU report support for unaligned access via
> CP15 CR1?  It's bit 22 and shows during boot.  My board shows:
> 
> CPU: ARMv7 Processor [411fc092] revision 2 (ARMv7), cr=50c5387d

The log that my colleague sent me contains:
[0.00] CPU: ARMv6-compatible processor [4117b365] revision 5 
(ARMv6TEJ), cr=00c5387f

Bit 22 all set...

> This compiles into a five byte unaligned memcpy:

Yes, that was the point. :)

> Linaro's stock configuration is -march=armv7-a -mtune=cortex-a9
> -mthumb.  Ubuntu is the same.  I can't reproduce the fault on a
> PandaBoard with omapzoom 2.6.35, Ubuntu 3.2.14, Ubuntu Precise 4.6.3
> GCC, or plain gcc-4.7.1-RC-20120606.

Looking at arch/arm/mm/alignment.c:alignment_init(), I see we
have local patches always forcing a warning.  Bah.  Is your
point that having an OS kernel that traps for unaligned accesses
for ARMv6 rare enough that there's no reason whatsoever for a
release note that gcc-4.7 now emits such accesses "by itself"?

Even though this was caused by non-stock Linux, I think there's
reason enough for a caveat entry in gcc-4.7/changes.html (just
as worded; the caveat wasn't directed just at Linux, mind you),
but I retract my suggestion to change back the default.

Maybe we should add a line to the suggested entry mentioning the
first stock Linux version that automatically adjusts this, so
stock Linux-users can be calmed. ;-P  Do you agree?

Something like "Linux/ARM in official releases has automatically
and unconditionally supported unaligned accesses as emitted by
GCC due to this option being active since Linux version 2.X.Y".
I guess X is 6.  What is Y?

brgds, H-P


Re: Committed: atomic support for CRIS

2012-06-12 Thread Hans-Peter Nilsson
> From: Richard Henderson 
> Date: Tue, 12 Jun 2012 23:04:02 +0200

> On 2012-05-31 22:58, Hans-Peter Nilsson wrote:
> > +(define_expand "atomic_compare_and_swap"
> > +  [(match_operand:SI 0 "register_operand")
> > +   (match_operand:BWD 1 "register_operand")
> > +   (match_operand:BWD 2 "memory_operand")
> > +   (match_operand:BWD 3 "general_operand")
> > +   (match_operand:BWD 4 "register_operand")
> > +   (match_operand 5)
> > +   (match_operand 6)
> > +   (match_operand 7)]
> > +  ""
> > +{
> > +  if (mode != QImode && TARGET_TRAP_UNALIGNED_ATOMIC)
> > +cris_emit_trap_for_misalignment (operands[2]);
> > +
> > +  expand_mem_thread_fence (INTVAL (operands[6]));
> > +  emit_insn (gen_cris_atomic_compare_and_swap_1 (operands[0],
> > +  operands[1],
> > +  operands[2],
> > +  operands[3],
> > +  operands[4]));
> > +  expand_mem_thread_fence (INTVAL (operands[6]));
> 
> Unlike the old sync optabs, you don't necessarily need both fences.
> Operands 6 and 7 tell you what fences you need.

Putting a lot of trust onto users and libraries there, to choose
the right model...

> Please have a look at the arm, alpha, or rs6000 versions, where we
> have _{pre,post}_atomic_barrier (model) functions.

Yeah, I took the safe route here, always emitting a fence, this
being an area where you don't want subtle bugs.  Lots of safety
at a negligible performance cost.  I don't have second thoughts,
but I did look *again* at those ports.

brgds, H-P


Re: [PATCH 3/3] rs6000: Rewrite sync patterns for atomic; expand early.

2012-06-12 Thread David Edelsohn
On Tue, Jun 12, 2012 at 9:40 AM, Richard Henderson  wrote:

>> I like your suggestion, but the PowerPC developer community does not
>> uniformly appreciate that behavior.
>
> Surely there's a difference between gratuitously using fp registers
> and that being the *only* way to implement a particular operation...

Should Altivec and SSE be used for TImode, and AVX for OImode?

- David


Re: [PATCH 3/3] rs6000: Rewrite sync patterns for atomic; expand early.

2012-06-12 Thread David Edelsohn
On Tue, Jun 12, 2012 at 11:51 AM, Richard Henderson  wrote:
> On 2012-06-11 18:40, David Edelsohn wrote:
>>> > Nope.  I do see the obvious mistake in the atomic_load pattern though:
>>> > The mode iterator should have been INT1 not INT.
>> Did you want to commit the fix for the iterator?
>>
>
> Applied the following to mainline.
>
> It ought to go onto the 4.7 branch as well, as it's a wrong-code bug.
> Are we at a place in the 4.7.1 release process where that's possible?

I agree that it is an important bug, but I believe that Richi was
planning to announce the release any day now and the RC tarballs
already have been spun.

- David


Re: [RFA:] Caveat for ARM in gcc-4.7/changes.html: unaligned accesses

2012-06-12 Thread Michael Hope
On 13 June 2012 02:32, Hans-Peter Nilsson  wrote:
>> From: Hans-Peter Nilsson 
>> Date: Mon, 11 Jun 2012 00:59:57 +0200
>
>> > From: Michael Hope 
>> > Date: Mon, 11 Jun 2012 00:04:19 +0200
>>
>> > On 8 June 2012 16:53, Hans-Peter Nilsson  
>> > wrote:
>> > >> From: Hans-Peter Nilsson 
>> > >> Date: Fri, 8 Jun 2012 06:29:04 +0200
>> > >
>> > >> > From: Michael Hope 
>> > >> > Date: Fri, 8 Jun 2012 05:50:52 +0200
>> > >> >  The combination of
>> > >> > older Linux ARM kernels and GCC 4.7 gives a faulty kernel.
>> > >>
>> > >> We're in agreement!
>> > >
>> > > Oh wait sorry, my bad, I misread.  Instead of "gives a faulty
>> > > kernel", I'd say "for ARMv6 and later (not -M), gives faulty
>> > > user-space code".  Maybe the kernel too, I can't say; there was
>> > > IIRC no sign of it.
>
> But (at least) after removing some local changed defaults,
> there's at boot-time a lot of:
>
> [    0.95] Unhandled fault: alignment exception (0x801) at 0xc821ddee

That's a kernel address.  What does /proc/kallsyms say is there?

For reference, the message comes from
arch/arm/mm/alignment.c:alignment_init() from the default trap
handler.  The lines just before this disable the unaligned trap for
usermode:

if (cpu_is_v6_unaligned()) {
cr_alignment &= ~CR_A;
cr_no_alignment &= ~CR_A;
set_cr(cr_alignment);
ai_usermode = safe_usermode(ai_usermode, false);
}

Support was added by Russell King in 2008-12 and updated by Dave
Martin on 2011-07.

Out of interest, does your CPU report support for unaligned access via
CP15 CR1?  It's bit 22 and shows during boot.  My board shows:

CPU: ARMv7 Processor [411fc092] revision 2 (ARMv7), cr=50c5387d

>> > Is there a bugzilla ticket logged for this?  I'd like to try to reproduce 
>> > it.
>
> Here's a shorter case I'll attach to a PR for this unless it
> gets resolved one way or another soonish.  Remember, you'll have
> to run this on a pre-3.2 kernel with CONFIG_ALIGNMENT_TRAP on
> (the default) and you have to compile for ARM v6 or later (as in
> -march=armv6).  Using gcc-4.7.1-rc1 should do, most likely
> earlier revisions too.
>
> __attribute__ ((__noinline__, __noclone__))
> void doit(char *x)
> {
>  asm ("");
>  __builtin_strcpy (x, "stat");
> }
>
> int main(void)
> {
>  char x[30];
>  doit(x + 1);
>  doit(x);
>  __builtin_exit (0);
> }

This compiles into a five byte unaligned memcpy:

doit:
mov r2, r0
movwr3, #:lower16:.LC0
movtr3, #:upper16:.LC0
ldr r0, [r3, #0]@ unaligned
ldrbr3, [r3, #4]@ zero_extendqisi2
str r0, [r2, #0]@ unaligned
strbr3, [r2, #4]
bx  lr

which is correct.  The test case runs on my boards and kernels as
noted below.  /proc/cpu/alignment doesn't change so the loads and
stores were handled by the hardware.

I added:

__attribute__ ((__noinline__, __noclone__))
long long doit2(char *x)
{
 asm ("");
 return *(long long *)x;
}

which becomes:

doit2:
ldmia   r0, {r0, r1}
bx  lr

ldm must be aligned.  The program runs to completion but this time the
kernel traps and handles the unaligned load:

cbuild@ursa1:~/bugs$ cat /proc/cpu/alignment  > before
cbuild@ursa1:~/bugs$ ./a.out
cbuild@ursa1:~/bugs$ cat /proc/cpu/alignment  > after
cbuild@ursa1:~/bugs$ diff -u before after
--- before  2012-06-12 22:29:20.428268001 +
+++ after   2012-06-12 22:29:26.107955560 +
@@ -1,8 +1,8 @@
-User:  3
+User:  4
 System:7
 Skipped:   0
 Half:  0
 Word:  0
 DWord: 0
-Multi: 10
+Multi: 11
 User faults:   2 (fixup)

>> > It's interesting as we backported the patch into the Linaro GCC that
>> > was used to build Ubuntu Precise and didn't find any faults.
>
> I have no idea why you didn't run into this, unless it was one
> of the obvious reasons: not building for ARM v6 or the kernel
> was 3.2 or later, or configured with CONFIG_ALIGNMENT_TRAP off.
> Or other local patches of yours.

Linaro's stock configuration is -march=armv7-a -mtune=cortex-a9
-mthumb.  Ubuntu is the same.  I can't reproduce the fault on a
PandaBoard with omapzoom 2.6.35, Ubuntu 3.2.14, Ubuntu Precise 4.6.3
GCC, or plain gcc-4.7.1-RC-20120606.  The configurations for the
kernels are at:
 * 
http://bazaar.launchpad.net/~linaro-toolchain-dev/cbuild/hardware/view/head:/ursa/r2/config
 * 
http://bazaar.launchpad.net/~linaro-toolchain-dev/cbuild/hardware/view/head:/distro/precise/r1/config

and have CONFIG_ALIGNMENT_TRAP on.

-- Michael


Re: [SH] PR 53511 - Remove obsolete PR 51340 test cases

2012-06-12 Thread Kaz Kojima
Oleg Endo  wrote:
> As mentioned in http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00544.html
> the PR 51340 test cases are obsolete.  The attached patch deletes them.
> 
> OK?

OK.

Regards,
kaz


Re: [PATCH] Add anddi_1 -> andsi_1_zext splitter (PR target/53639)

2012-06-12 Thread Richard Henderson
On 2012-06-12 14:22, Jakub Jelinek wrote:
>   PR target/53639
>   * config/i386/i386.md (*anddi_1 into *andsi_1_zext splitter): New.

Ok.


r~


Re: RFA: Alternative iterator implementation

2012-06-12 Thread Richard Henderson
On 2012-06-12 11:26, Richard Sandiford wrote:
> Tejas Belagod  writes:
>> New patch attached. OK?
> 
>> +There are two standard integer attributes: @code{int}, the name of the
>> +code in lower case, and @code{INT}, the name of the code in upper case.
> 
> I don't think this is true.  So the surrounding paragraph reduces to:
> 
>   It is possible to define attributes for ints as well as for codes and modes.
>   Attributes are defined using:
> 
> Looks good to me otherwise, thanks, although I can't approve it.
> (I can't approve my own patch either, hint hint, ping ping.)
> 
> Thanks for your patience too.

Both patches approved.


r~


[PATCH] Add anddi_1 -> andsi_1_zext splitter (PR target/53639)

2012-06-12 Thread Jakub Jelinek
Hi!

The combiner combines
(set (reg:SI x) (and:SI (reg:SI y) (const_int 1234)))
(set (reg:DI z) (zero_extend:DI (reg:SI x)))
into
(set (reg:DI z) (and:DI (subreg:DI (reg:SI (y) 0) (const_int 1234
which unfortunately isn't the best form on x86_64 from RA POV, because
if y needs to be moved around, with the paradoxical subreg it is copied
around as DImode which is one byte longer than SImode copy.  We only
need the low 32-bits from that though.

The following patch fixes it, by splitting what combiner creates before RA
into andsi_1_zext pattern.  My initial version of the patch did it for all
DImode operands[1], but that unfortunately regressed pr49095.c where
mem &= const with flag setting is no longer being peepholed.  So, this patch
limits it to whatever combiner creates.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-06-12  Jakub Jelinek  

PR target/53639
* config/i386/i386.md (*anddi_1 into *andsi_1_zext splitter): New.

--- gcc/config/i386/i386.md.jj  2012-06-12 09:46:26.449838954 +0200
+++ gcc/config/i386/i386.md 2012-06-12 12:22:58.972769925 +0200
@@ -7933,6 +7933,18 @@ (define_insn "*andqi_1_slp"
   [(set_attr "type" "alu1")
(set_attr "mode" "QI")])
 
+;; Turn *anddi_1 into *andsi_1_zext if possible.
+(define_split
+  [(set (match_operand:DI 0 "register_operand")
+   (and:DI (subreg:DI (match_operand:SI 1 "register_operand") 0)
+   (match_operand:DI 2 "x86_64_zext_immediate_operand")))
+   (clobber (reg:CC FLAGS_REG))]
+  "TARGET_64BIT"
+  [(parallel [(set (match_dup 0)
+  (zero_extend:DI (and:SI (match_dup 1) (match_dup 2
+ (clobber (reg:CC FLAGS_REG))])]
+  "operands[2] = gen_lowpart (SImode, operands[2]);")
+
 (define_split
   [(set (match_operand:SWI248 0 "register_operand")
(and:SWI248 (match_operand:SWI248 1 "nonimmediate_operand")

Jakub


Re: Committed: atomic support for CRIS

2012-06-12 Thread Richard Henderson
On 2012-05-31 22:58, Hans-Peter Nilsson wrote:
> +(define_expand "atomic_compare_and_swap"
> +  [(match_operand:SI 0 "register_operand")
> +   (match_operand:BWD 1 "register_operand")
> +   (match_operand:BWD 2 "memory_operand")
> +   (match_operand:BWD 3 "general_operand")
> +   (match_operand:BWD 4 "register_operand")
> +   (match_operand 5)
> +   (match_operand 6)
> +   (match_operand 7)]
> +  ""
> +{
> +  if (mode != QImode && TARGET_TRAP_UNALIGNED_ATOMIC)
> +cris_emit_trap_for_misalignment (operands[2]);
> +
> +  expand_mem_thread_fence (INTVAL (operands[6]));
> +  emit_insn (gen_cris_atomic_compare_and_swap_1 (operands[0],
> +operands[1],
> +operands[2],
> +operands[3],
> +operands[4]));
> +  expand_mem_thread_fence (INTVAL (operands[6]));

Unlike the old sync optabs, you don't necessarily need both fences.
Operands 6 and 7 tell you what fences you need.

Please have a look at the arm, alpha, or rs6000 versions, where we
have _{pre,post}_atomic_barrier (model) functions.


r~


Re: [PR49888, VTA] don't keep VALUEs bound to modified MEMs

2012-06-12 Thread Richard Henderson
On 2012-06-05 12:33, Alexandre Oliva wrote:
> for  gcc/ChangeLog
> from  Alexandre Oliva  
> 
>   PR debug/49888
>   * var-tracking.c: Include alias.h.
>   (overlapping_mems): New struct.
>   (drop_overlapping_mem_locs): New.
>   (clobber_overlapping_mems): New.
>   (var_mem_delete_and_set, var_mem_delete): Call it.
>   (val_bind): Likewise, but only if modified.
>   (compute_bb_dataflow, emit_notes_in_bb): Call it on MEMs.
>   * Makefile.in (var-tracking.o): Depend in $(ALIAS_H).
>   
> for  gcc/testsuite/ChangeLog
> from  Alexandre Oliva  
> 
>   PR debug/49888
>   * gcc.dg/guality/pr49888.c: New.

Ok.


r~


Go patch committed: Handle package path like gc compiler

2012-06-12 Thread Ian Lance Taylor
This patch to the Go frontend and the runtime library handles the
package path like the other Go compiler.  Gccgo needs to canonicalize
type names based on the reflection string, so that types defined in
shared libraries work correctly.  That means that it needs to include
the package path in the reflection string.  But the other Go compiler
does not include the full path in the reflection string, only the
package name.  So this patch changes gccgo to store the package path in
the reflection string within double quotes, and to strip out double
quoted strings when the reflect.Type.String method is called.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r 2ab3869bedd1 go/gogo.cc
--- a/go/gogo.cc	Thu Jun 07 01:05:45 2012 -0700
+++ b/go/gogo.cc	Tue Jun 12 11:47:12 2012 -0700
@@ -339,9 +339,14 @@
   // symbol names.
   if (!this->pkgpath_set_)
 {
-  if (!this->prefix_from_option_)
-	this->prefix_ = "go";
-  this->pkgpath_ = this->prefix_ + '.' + package_name;
+  if (!this->prefix_from_option_ && package_name == "main")
+	this->pkgpath_ = package_name;
+  else
+	{
+	  if (!this->prefix_from_option_)
+	this->prefix_ = "go";
+	  this->pkgpath_ = this->prefix_ + '.' + package_name;
+	}
   this->pkgpath_set_ = true;
 }
 
diff -r 2ab3869bedd1 go/types.cc
--- a/go/types.cc	Thu Jun 07 01:05:45 2012 -0700
+++ b/go/types.cc	Tue Jun 12 11:47:12 2012 -0700
@@ -8337,14 +8337,23 @@
 {
   // We handle -fgo-prefix and -fgo-pkgpath differently here for
   // compatibility with how the compiler worked before
-  // -fgo-pkgpath was introduced.
+  // -fgo-pkgpath was introduced.  When -fgo-pkgpath is specified,
+  // we use it to make a unique reflection string, so that the
+  // type canonicalization in the reflect package will work.  In
+  // order to be compatible with the gc compiler, we quote the
+  // package path, so that the reflect methods can discard it.
   const Package* package = this->named_object_->package();
   if (gogo->pkgpath_from_option())
-	ret->append(package != NULL ? package->pkgpath() : gogo->pkgpath());
-  else
-	ret->append(package != NULL
-		? package->package_name()
-		: gogo->package_name());
+	{
+	  ret->push_back('"');
+	  ret->append(package != NULL
+		  ? package->pkgpath_symbol()
+		  : gogo->pkgpath_symbol());
+	  ret->push_back('"');
+	}
+  ret->append(package != NULL
+		  ? package->package_name()
+		  : gogo->package_name());
   ret->push_back('.');
 }
   if (this->in_function_ != NULL)
diff -r 2ab3869bedd1 libgo/go/encoding/xml/marshal_test.go
--- a/libgo/go/encoding/xml/marshal_test.go	Thu Jun 07 01:05:45 2012 -0700
+++ b/libgo/go/encoding/xml/marshal_test.go	Tue Jun 12 11:47:12 2012 -0700
@@ -726,7 +726,7 @@
 	},
 	{
 		Value: map[*Ship]bool{nil: false},
-		Err:   "xml: unsupported type: map[*encoding/xml.Ship]bool",
+		Err:   "xml: unsupported type: map[*xml.Ship]bool",
 		Kind:  reflect.Map,
 	},
 	{
diff -r 2ab3869bedd1 libgo/go/html/template/escape_test.go
--- a/libgo/go/html/template/escape_test.go	Thu Jun 07 01:05:45 2012 -0700
+++ b/libgo/go/html/template/escape_test.go	Tue Jun 12 11:47:12 2012 -0700
@@ -226,7 +226,7 @@
 		{
 			"badMarshaler",
 			``,
-			``,
+			``,
 		},
 		{
 			"jsMarshaler",
diff -r 2ab3869bedd1 libgo/go/reflect/type.go
--- a/libgo/go/reflect/type.go	Thu Jun 07 01:05:45 2012 -0700
+++ b/libgo/go/reflect/type.go	Tue Jun 12 11:47:12 2012 -0700
@@ -83,6 +83,9 @@
 	// compare the Types directly.
 	String() string
 
+	// Used internally by gccgo--the string retaining quoting.
+	rawString() string
+
 	// Kind returns the specific kind of this type.
 	Kind() Kind
 
@@ -432,7 +435,24 @@
 	return canonicalize(t)
 }
 
-func (t *commonType) String() string { return *t.string }
+func (t *commonType) rawString() string { return *t.string }
+
+func (t *commonType) String() string {
+	// For gccgo, strip out quoted strings.
+	s := *t.string
+	var q bool
+	r := make([]byte, len(s))
+	j := 0
+	for i := 0; i < len(s); i++ {
+		if s[i] == '"' {
+			q = !q
+		} else if !q {
+			r[j] = s[i]
+			j++
+		}
+	}
+	return string(r[:j])
+}
 
 func (t *commonType) Size() uintptr { return t.size }
 
@@ -942,7 +962,7 @@
 	u := t.uncommon()
 	var s string
 	if u == nil || u.PkgPath() == "" {
-		s = t.String()
+		s = t.rawString()
 	} else {
 		s = u.PkgPath() + "." + u.Name()
 	}


Re: [PATCH 3/7] Add stdint.h wrapper for VxWorks.

2012-06-12 Thread Joseph S. Myers
On Tue, 12 Jun 2012, rbmj wrote:

> On 06/12/2012 11:47 AM, Joseph S. Myers wrote:
> > On Wed, 6 Jun 2012, rbmj wrote:
> > 
> > > The stdint.h doesn't have all the typedefs needed for standards
> > > compliance, so add a hack that adds all of the needed typedefs
> > > to be fully compliant to the standard.  Fixes broken libstdc++.
> > If you're touching VxWorks stdint.h perhaps you could also define the
> > relevant target macros for GCC to have built-in knowledge of the types?
> > This is needed for the Fortran C bindings to work correctly, at least, and
> > ensures char16_t and char32_t (C11/C++11) are correct as well.  (You could
> > then set use_gcc_stdint to "wrap" in config.gcc if you want to use GCC's
> > stdint.h for freestanding compilations.)
> I would be happy to, but I'm not aware of what macros those are.  If you could
> point me to some documentation or explain to me what macros I need to define
> I'll update the patch.

 was my original 
announcement for target OS maintainers.  You should define the same set of 
macros as in gcc/config/glibc-stdint.h (but, obviously, to values 
appropriate to VxWorks), plus INTMAX_TYPE and UINTMAX_TYPE if the default 
values of those macros are wrong for VxWorks, and make sure all the 
c99-stdint-*.c tests pass.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH 3/7] Add stdint.h wrapper for VxWorks.

2012-06-12 Thread rbmj

On 06/12/2012 11:47 AM, Joseph S. Myers wrote:

On Wed, 6 Jun 2012, rbmj wrote:


The stdint.h doesn't have all the typedefs needed for standards
compliance, so add a hack that adds all of the needed typedefs
to be fully compliant to the standard.  Fixes broken libstdc++.

If you're touching VxWorks stdint.h perhaps you could also define the
relevant target macros for GCC to have built-in knowledge of the types?
This is needed for the Fortran C bindings to work correctly, at least, and
ensures char16_t and char32_t (C11/C++11) are correct as well.  (You could
then set use_gcc_stdint to "wrap" in config.gcc if you want to use GCC's
stdint.h for freestanding compilations.)
I would be happy to, but I'm not aware of what macros those are.  If you 
could point me to some documentation or explain to me what macros I need 
to define I'll update the patch.


Thanks,

Robert


Re: constant that doesn't fit in 32bits in alpha.c

2012-06-12 Thread Joseph S. Myers
I'd rather have a macro HOST_WIDE_INT_C in hwint.h (like INTMAX_C etc. in 
stdint.h).  HOST_WIDE_INT_1 is already defined in hwint.h to either 1L or 
1LL; I'd suggest defining HOST_WIDE_INT_C to concatenate with either L or 
LL (and then HOST_WIDE_INT_1 can be HOST_WIDE_INT_C (1), unconditionally).

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: Updated to respond to various email comments from Jason, Diego and Cary (issue6197069)

2012-06-12 Thread Sterling Augustine
On Fri, Jun 8, 2012 at 3:03 PM, Sterling Augustine
 wrote:

[Regarding generating pubnames]

> OK, I've updated the patch with all these additional comments. Just
> waiting on the decision between -f and -g. I'll repost and then commit
> it when that is settled--hopefully soon.
>
> Next up, the big fission patch!
>
> Sterling

Ping


Re: C++ PATCH for c++/53599 (ICE with local class in template)

2012-06-12 Thread Jason Merrill

On 06/07/2012 04:29 PM, Jason Merrill wrote:

The problem here was that when we instantiate G::bar, we want to
instantiate F, and end up improperly pushing the declaration inside G,
which leads to the ICE. Adjusting the call to pushclass is enough to fix
this, which is what I propose doing for the 4.7 branch. For 4.8 I'm
going to do more.


What we really want is to get local classes declared at the same place 
in a template that they are in a non-template.  This patch achieves that 
by adding a DECL_EXPR to make the class declaration explicit.  This 
confused finish_cond, which expected a DECL_EXPR to be for a condition 
variable, so I needed to adjust it and tsubst_expr accordingly.


The second patch unconditionally instantiates local classes when we 
encounter their definition, so that we don't need to deal with trying to 
push back to the right scope later on--and because this seems to be what 
the language requires.


Tested x86_64-pc-linux-gnu, applied to trunk.
commit c9e4cdb59a541fd5006983923adfcbb406533f3a
Author: jason 
Date:   Tue Jun 12 18:32:04 2012 +

	PR c++/53599
	* name-lookup.c (pushtag_1): Add a DECL_EXPR for a local class.
	* semantics.c (finish_cond): Build a COMPOUND_EXPR.
	* pt.c (tsubst_expr) [COMPOUND_EXPR]: Handle.
	[DECL_EXPR]: Don't call cp_finish_decl for an implicit typedef.
	Don't return the decl.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188473 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 9cc6d39..0f28820 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -5796,7 +5796,16 @@ pushtag_1 (tree name, tree type, tag_scope scope)
 	 class.)  */
   if (TYPE_CONTEXT (type)
 	  && TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL)
-	VEC_safe_push (tree, gc, local_classes, type);
+	{
+	  if (processing_template_decl)
+	{
+	  /* Push a DECL_EXPR so we call pushtag at the right time in
+		 template instantiation rather than in some nested context.  */
+	  add_decl_expr (decl);
+	}
+	  else
+	VEC_safe_push (tree, gc, local_classes, type);
+	}
 }
   if (b->kind == sk_class
   && !COMPLETE_TYPE_P (current_class_type))
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index df80159..04f7be8 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12887,6 +12887,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
 		DECL_CONTEXT (decl) = current_function_decl;
 		insert_capture_proxy (decl);
 		  }
+		else if (DECL_IMPLICIT_TYPEDEF_P (t))
+		  /* We already did a pushtag.  */;
 		else
 		  {
 		int const_init = false;
@@ -12930,9 +12932,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
 	  }
 	  }
 
-	/* A DECL_EXPR can also be used as an expression, in the condition
-	   clause of an if/for/while construct.  */
-	return decl;
+	break;
   }
 
 case FOR_STMT:
@@ -13341,6 +13341,15 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
   error ("use %<...%> to expand argument pack");
   return error_mark_node;
 
+case COMPOUND_EXPR:
+  tmp = RECUR (TREE_OPERAND (t, 0));
+  if (tmp == NULL_TREE)
+	/* If the first operand was a statement, we're done with it.  */
+	return RECUR (TREE_OPERAND (t, 1));
+  return build_x_compound_expr (EXPR_LOCATION (t), tmp,
+RECUR (TREE_OPERAND (t, 1)),
+complain);
+
 default:
   gcc_assert (!STATEMENT_CODE_P (TREE_CODE (t)));
 
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 7769bba..f8ad2a5 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -509,11 +509,14 @@ finish_cond (tree *cond_p, tree expr)
   if (processing_template_decl)
 {
   tree cond = pop_stmt_list (*cond_p);
-  if (TREE_CODE (cond) == DECL_EXPR)
-	expr = cond;
 
-  if (check_for_bare_parameter_packs (expr))
-*cond_p = error_mark_node;
+  if (expr == NULL_TREE)
+	/* Empty condition in 'for'.  */
+	gcc_assert (empty_expr_stmt_p (cond));
+  else if (check_for_bare_parameter_packs (expr))
+expr = error_mark_node;
+  else if (!empty_expr_stmt_p (cond))
+	expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr), cond, expr);
 }
   *cond_p = expr;
 }
diff --git a/gcc/testsuite/g++.dg/template/local7.C b/gcc/testsuite/g++.dg/template/local7.C
new file mode 100644
index 000..3045534
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/local7.C
@@ -0,0 +1,15 @@
+// PR c++/53599
+
+template 
+int foo ()
+{
+  struct F;
+  struct G
+  {
+static int F::* bar();
+  };
+
+  return sizeof(G);
+}
+
+int z = foo  ();
commit 978586407742e3f208d6f76ee0789b83c760e468
Author: jason 
Date:   Tue Jun 12 18:32:13 2012 +

	* pt.c (tsubst_expr) [TAG_DEFN]: Instantiate local class.
	* class.c (finish_struct): Don't add a TAG_DEFN for a lambda.
	* decl2.c (finish_static_data_member_decl): Avoid redundant error.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188474 138bc75d-0d04-0

Re: [SH] PR 53511 - Remove obsolete PR 51340 test cases

2012-06-12 Thread Oleg Endo
On Tue, 2012-06-12 at 10:46 -0700, Mike Stump wrote:
> On Jun 12, 2012, at 10:05 AM, Oleg Endo wrote:
> > As mentioned in http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00544.html
> > the PR 51340 test cases are obsolete.  The attached patch deletes them.
> > 
> > OK?
> 
> Ok.  Didn't Kaz already pre-approve the concept?

Yeah, actually I believe he did.  Just wanted to make sure ... 
Anyway, committed as rev 188471.

Cheers,
Oleg




Re: RFA: Alternative iterator implementation

2012-06-12 Thread Richard Sandiford
Tejas Belagod  writes:
> New patch attached. OK?

> +There are two standard integer attributes: @code{int}, the name of the
> +code in lower case, and @code{INT}, the name of the code in upper case.

I don't think this is true.  So the surrounding paragraph reduces to:

  It is possible to define attributes for ints as well as for codes and modes.
  Attributes are defined using:

Looks good to me otherwise, thanks, although I can't approve it.
(I can't approve my own patch either, hint hint, ping ping.)

Thanks for your patience too.

Richard


Re: [gimplefe] Tests for type declarations and variable declarations

2012-06-12 Thread Diego Novillo

On 12-06-12 14:20 , Sandeep Soni wrote:


2012-06-12 Sandeep Soni

 gimple.dg/20120611-1.gimple : New.
 gimple.dg/20120611-2.gimple : New.
 gimple.dg/20120611-3.gimple : New.
 gimple.dg/20120611-4.gimple : New.
 gimple.dg/type-1.gimple : New.
 gimple.dg/type-2.gimple : New.
 gimple.dg/type-3.gimple : New.


OK.


I have thus far added some very basic tests to the front end. I want
to add more tests periodically and now I want to get back to the
original building gimple statements problem.


Sounds good.  Thanks!


Diego.


Re: [gimplefe] patch that fixes the bug for the failure test case

2012-06-12 Thread Diego Novillo

On 12-06-12 13:52 , Sandeep Soni wrote:

On Tue, Jun 12, 2012 at 6:57 PM, Diego Novillo  wrote:

On 12-06-08 22:25 , Sandeep Soni wrote:


Hi,

This patch fixes the failure test case that I had submitted the last time.

The changeLog is testsuite/gChangeLog.gimplefe is as follows.

2012-06-09   Sandeep Soni
   * gimple.dg/20120605-2.gimple : New.

While the changelog in gimple/ChangeLog is as follows
2012-06-09   Sandeep Soni
   * parser.c (gp_parse_expect_return_var) : Modify to have
correct token consumption.



I don't follow how your patch fixes the ICE.  Could you describe it a bit
more?  How was it failing?



One of the previous versions of the code in gp_parse_call_stmt relied
on gimple_peek_token. But in some subsequent patch that was replaced
with gimple_consume_token in order to avoid excessive peeking. This
caused breaking of the compiler because it consumed more tokens than
required and was left to expect more tokens.

The patch fixes that.


Thanks.  The patch is OK.


Diego.


[gimplefe] Tests for type declarations and variable declarations

2012-06-12 Thread Sandeep Soni
The patch adds some preliminary tests for type declarations and
varaible declarations for the gimple front end.

Following is the ChangeLog Entry.

2012-06-12 Sandeep Soni 

gimple.dg/20120611-1.gimple : New.
gimple.dg/20120611-2.gimple : New.
gimple.dg/20120611-3.gimple : New.
gimple.dg/20120611-4.gimple : New.
gimple.dg/type-1.gimple : New.
gimple.dg/type-2.gimple : New.
gimple.dg/type-3.gimple : New.


I have thus far added some very basic tests to the front end. I want
to add more tests periodically and now I want to get back to the
original building gimple statements problem.

-- 
Cheers
Sandy


test003.diff
Description: Binary data


Re: [gimplefe] patch that fixes the bug for the failure test case

2012-06-12 Thread Sandeep Soni
On Tue, Jun 12, 2012 at 6:57 PM, Diego Novillo  wrote:
> On 12-06-08 22:25 , Sandeep Soni wrote:
>>
>> Hi,
>>
>> This patch fixes the failure test case that I had submitted the last time.
>>
>> The changeLog is testsuite/gChangeLog.gimplefe is as follows.
>>
>> 2012-06-09   Sandeep Soni
>>               * gimple.dg/20120605-2.gimple : New.
>>
>> While the changelog in gimple/ChangeLog is as follows
>> 2012-06-09   Sandeep Soni
>>               * parser.c (gp_parse_expect_return_var) : Modify to have
>> correct token consumption.
>
>
> I don't follow how your patch fixes the ICE.  Could you describe it a bit
> more?  How was it failing?
>

One of the previous versions of the code in gp_parse_call_stmt relied
on gimple_peek_token. But in some subsequent patch that was replaced
with gimple_consume_token in order to avoid excessive peeking. This
caused breaking of the compiler because it consumed more tokens than
required and was left to expect more tokens.

The patch fixes that.

> You'll need a blank line after the date line in ChangeLog entries.
>

Here is the modified ChangeLog entry

2012-06-09   Sandeep Soni

  * gimple.dg/20120605-2.gimple : New.

While the changelog in gimple/ChangeLog is as follows
2012-06-09   Sandeep Soni

  * parser.c (gp_parse_expect_return_var) : Modify to have
correct token consumption.



-- 
Cheers
Sandy


Re: libgo patch committed: Update to Go 1.0.1 release

2012-06-12 Thread Mike Stump
On Jun 11, 2012, at 10:11 PM, Ian Lance Taylor wrote:
> Mike Stump  writes:
>> On May 4, 2012, at 8:01 AM, Ian Lance Taylor wrote:
>>> This patch updates libgo to the Go 1.0.1 release.  This is a relatively
>>> small collection of bug fixes, with no API changes.
>> 
>> So, it is an important part of the test case for 
>> libgo/go/mime/multipart/testdata/nested-mime to have ^Ms in the file?  If 
>> not, could you strip them out?  Thanks.  If so, the testcase might need to 
>> marked as binary to keep svn and or git from stripping the ^Ms out.
> 
> It is important to have the ^Ms.  I set the SVN property svn:mime-type
> to application/octet-stream for this file on both mainline and 4.7
> branch.

Thanks.  Here to hoping that the git mirror picks it up in a sensible fashion [ 
confused, perplexed look ].  Seems like I should just know the answer, but my 
fingers are abstaining from answering.  :-)  I caught this in a merge audit, 
and thought, I didn't change that file...


Re: [SH] PR 53511 - Remove obsolete PR 51340 test cases

2012-06-12 Thread Mike Stump
On Jun 12, 2012, at 10:05 AM, Oleg Endo wrote:
> As mentioned in http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00544.html
> the PR 51340 test cases are obsolete.  The attached patch deletes them.
> 
> OK?

Ok.  Didn't Kaz already pre-approve the concept?


Re: [PATCH 3/3] rs6000: Rewrite sync patterns for atomic; expand early.

2012-06-12 Thread Mike Stump
On Jun 12, 2012, at 6:40 AM, Richard Henderson wrote:
> On 2012-06-11 18:40, David Edelsohn wrote:
>> On Sat, Jun 9, 2012 at 10:40 AM, Richard Henderson  wrote:
>> 
>>> Nope.  I do see the obvious mistake in the atomic_load pattern though:
>>> The mode iterator should have been INT1 not INT.
>> 
>> Did you want to commit the fix for the iterator?
> 
> Yes.  I'm just finishing testing that patch in fact.
> 
>> I like your suggestion, but the PowerPC developer community does not
>> uniformly appreciate that behavior.
> 
> Surely there's a difference between gratuitously using fp registers
> and that being the *only* way to implement a particular operation...

I think this would be a good question to ask the hard real time low latency 
interrupt crowd, I was going to say they prefer low latency interrupts, but, to 
the extent you have to use a slow mechanism instead of using DI atomic FPRs... 
I'm not sure how they would weigh in.  Maybe the RTEMS, Ada or CodeSourcery 
people can weigh in...


Re: [testsuite] gcc.dg/torture/stackalign: make compile lines unique in test summary

2012-06-12 Thread H.J. Lu
On Tue, Jun 12, 2012 at 10:22 AM, Mike Stump  wrote:
> On Jun 11, 2012, at 7:41 PM, Janis Johnson wrote:
>> The tests in gcc.dg/torture/stackalign use two sets of torture options:
>
>> OK for mainline?
>
> Ok, if H.J. is happy.

It is OK for me.  Thanks.

-- 
H.J.


Re: [testsuite] gcc.dg/torture/stackalign: make compile lines unique in test summary

2012-06-12 Thread Mike Stump
On Jun 11, 2012, at 7:41 PM, Janis Johnson wrote:
> The tests in gcc.dg/torture/stackalign use two sets of torture options:

> OK for mainline?

Ok, if H.J. is happy.


[SH] PR 53511 - Remove obsolete PR 51340 test cases

2012-06-12 Thread Oleg Endo
Hello,

As mentioned in http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00544.html
the PR 51340 test cases are obsolete.  The attached patch deletes them.

OK?

Cheers,
Oleg

testsuite/ChangeLog:

PR target/53511
* gcc.target/sh/pr51340-1.c: Delete obsolete test case.
* gcc.target/sh/pr51340-2.c: Likewise.
* gcc.target/sh/pr51340-3.c: Likewise.
Index: gcc/testsuite/gcc.target/sh/pr51340-2.c
===
--- gcc/testsuite/gcc.target/sh/pr51340-2.c	(revision 188425)
+++ gcc/testsuite/gcc.target/sh/pr51340-2.c	(working copy)
@@ -1,12 +0,0 @@
-/* Check that the fmac insn is not generated when -mno-fused-madd is specified.  */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O1 -funsafe-math-optimizations -mno-fused-madd" } */
-/* { dg-skip-if "" { "sh*-*-*" } { "-m1" "-m2" "-m4al" "*nofpu" "-m4-340*" "-m4-400*" "-m4-500*" "-m5*" } { "" } }  */
-/* { dg-final { scan-assembler-not "fmac" } } */
-
-float
-test_func (float a, float b, float c, float d, float e, float f)
-{
-  return a * b + c * d + e * f;
-}
-
Index: gcc/testsuite/gcc.target/sh/pr51340-1.c
===
--- gcc/testsuite/gcc.target/sh/pr51340-1.c	(revision 188425)
+++ gcc/testsuite/gcc.target/sh/pr51340-1.c	(working copy)
@@ -1,13 +0,0 @@
-/* Check that the fmac insn is generated when -funsafe-math-optimizations
-   is specified.  */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O1 -funsafe-math-optimizations" } */
-/* { dg-skip-if "" { "sh*-*-*" } { "-m1" "-m2" "-m4al" "*nofpu" "-m4-340*" "-m4-400*" "-m4-500*" "-m5*" } { "" } }  */
-/* { dg-final { scan-assembler "fmac" } } */
-
-float
-test_func (float a, float b, float c, float d, float e, float f)
-{
-  return a * b + c * d + e * f;
-}
-
Index: gcc/testsuite/gcc.target/sh/pr51340-3.c
===
--- gcc/testsuite/gcc.target/sh/pr51340-3.c	(revision 188425)
+++ gcc/testsuite/gcc.target/sh/pr51340-3.c	(working copy)
@@ -1,12 +0,0 @@
-/* Check that the fmac insn is generated when -mfused-madd is specified.  */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O1 -mfused-madd" } */
-/* { dg-skip-if "" { "sh*-*-*" } { "-m1" "-m2" "-m4al" "*nofpu" "-m4-340*" "-m4-400*" "-m4-500*" "-m5*" } { "" } }  */
-/* { dg-final { scan-assembler "fmac" } } */
-
-float
-test_func (float a, float b, float c, float d, float e, float f)
-{
-  return a * b + c * d + e * f;
-}
-


Re: [testsuite] gcc.target/arm: make message check lines unique in test summary

2012-06-12 Thread Mike Stump
On Jun 11, 2012, at 7:40 PM, Janis Johnson wrote:
> This test modifies dg-message test directives by adding comments that
> will be added to lines in the test summary to eliminate non-unique lines
> for checks of messages for the same line of source code in a test.

> OK for mainline?

Ok.


Re: [testsuite] c-c++-common: make message check lines unique in test summary

2012-06-12 Thread Mike Stump
On Jun 11, 2012, at 7:33 PM, Janis Johnson wrote:
> This test modifies dg-error and dg-warning test directives by adding
> comments that will be added to lines in the test summary to eliminate
> non-unique lines for checks of messages for the same line of source code
> in a test.
> 
> OK for mainline?

Ok.


Re: [Google 4.6] Backport C++ canonicalization patch (issue6297080)

2012-06-12 Thread Diego Novillo

On 12-06-12 12:57 , Sterling Augustine wrote:


The wrapper code is the same, but the internal call is
not--"lang_decl_name" and "decl_as_string" return different strings,
and their interface is different so it wouldn't be easy to pass a
function pointer.

So, I'm not sure how you would combine the code without it getting more ugly.


Ah, you're right.  I missed that.  In any case, that's fine.  The code 
is short enough.



Thanks.  Diego.


Re: [Google 4.6] Backport C++ canonicalization patch (issue6297080)

2012-06-12 Thread Sterling Augustine
On Tue, Jun 12, 2012 at 9:36 AM, Diego Novillo  wrote:
> On 12-06-12 11:58 , Sterling Augustine wrote:
>
>> +/* Wrap lang_decl_name with options appropriate for dwarf.  */
>> +
>> +const char *
>> +lang_decl_dwarf_name (tree decl, int v, bool translate)
>> +{
>> +  const char *name;
>> +  /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting
>> the flag
>> +     here will be adequate to get the desired behaviour.  */
>> +  pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3;
>> +  name = lang_decl_name (decl, v, translate);
>> +  /* Subsequent calls to the pretty printer shouldn't use this style.  */
>> +  pp_c_base (cxx_pp)->flags&= ~pp_c_flag_gnu_v3;
>> +  return name;
>> +}
>
>
> Would it make sense to factor common code in decl_as_dwarf_string()?

The wrapper code is the same, but the internal call is
not--"lang_decl_name" and "decl_as_string" return different strings,
and their interface is different so it wouldn't be easy to pass a
function pointer.

So, I'm not sure how you would combine the code without it getting more ugly.

Sterling


Re: [Google 4.6] Backport C++ canonicalization patch (issue6297080)

2012-06-12 Thread Diego Novillo

On 12-06-12 11:58 , Sterling Augustine wrote:


+/* Wrap lang_decl_name with options appropriate for dwarf.  */
+
+const char *
+lang_decl_dwarf_name (tree decl, int v, bool translate)
+{
+  const char *name;
+  /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the 
flag
+ here will be adequate to get the desired behaviour.  */
+  pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3;
+  name = lang_decl_name (decl, v, translate);
+  /* Subsequent calls to the pretty printer shouldn't use this style.  */
+  pp_c_base (cxx_pp)->flags&= ~pp_c_flag_gnu_v3;
+  return name;
+}


Would it make sense to factor common code in decl_as_dwarf_string()?

OK, otherwise.


Diego.


Re: RFA: Alternative iterator implementation

2012-06-12 Thread Tejas Belagod

Richard Sandiford wrote:

Thanks for the update.

Tejas Belagod  writes:

+/* Implementations of the iterator_group callbacks for ints.  */
+
+/* Since GCC does not construct a table of valid constants,
+   we have to accept any int as valid.  No cross-checking can
+   be done.  */
+
+static int
+find_int (const char *name)
+{
+  char *endptr;
+  int ret;
+
+  if (ISDIGIT (*name))
+{
+  ret = strtol (name, &endptr, 0);
+  gcc_assert (*endptr == '\0');


As I mentioned before, I think this should be an error rather than
an assert.  An assert would only be appropriate if this is something
that should already have been checked, but AFAICT nothing does.

In fact I think this ought to be:

  validate_const_int (name);
  return atoi (name);



Sorry, yes I meant to fix that. I've fixed that now.


And unless I'm missing something, this:


+   /* Can be an iterator or an integer constant.  */
read_name (&name);
-   validate_const_int (name.string);
-   tmp_int = atoi (name.string);
-   XINT (return_rtx, i) = tmp_int;
+   if (!ISDIGIT (name.string[0]))
+ {
+   struct mapping *iterator;
+   /* An iterator.  */
+   iterator = (struct mapping *) htab_find (ints.iterators,
+&name.string);
+   if (iterator)
+ record_iterator_use (iterator, &XINT (return_rtx, i));
+   else
+ fatal_with_file_and_line ("unknown iterator `%s'",name.string);
+ }
+   else
+ {
+   validate_const_int (name.string);
+   tmp_int = atoi (name.string);
+   XINT (return_rtx, i) = tmp_int;
+ }


should simply be:

/* Can be an iterator or an integer constant.  */
read_name (&name);
record_potential_iterator_use (&ints, &XINT (return_rtx, i),
   name.string);
break;


Indeed.

New patch attached. OK?

Thanks,
Tejas Belagod.
ARM.diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index 71b89c1..94cd01b 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -8903,6 +8903,7 @@ facilities to make this process easier.
 @menu
 * Mode Iterators:: Generating variations of patterns for different 
modes.
 * Code Iterators:: Doing the same for codes.
+* Int Iterators::  Doing the same for integers.
 @end menu
 
 @node Mode Iterators
@@ -9174,4 +9175,83 @@ This is equivalent to:
 @dots{}
 @end smallexample
 
+@node Int Iterators
+@subsection Int Iterators
+@cindex int iterators in @file{.md} files
+@findex define_int_iterator
+@findex define_int_attr
+
+Int iterators operate in a similar way to code iterators.  @xref{Code 
Iterators}.
+
+The construct:
+
+@smallexample
+(define_int_iterator @var{name} [(@var{int1} "@var{cond1}") @dots{} 
(@var{intn} "@var{condn}")])
+@end smallexample
+
+defines a pseudo integer constant @var{name} that can be instantiated as
+@var{inti} if condition @var{condi} is true.  Each @var{int}
+must have the same rtx format.  @xref{RTL Classes}. Int iterators can appear
+in only those rtx fields that have 'i' as the specifier. This means that
+each @var{int} has to be a constant defined using define_constant or
+define_c_enum.
+
+As with mode and code iterators, each pattern that uses @var{name} will be
+expanded @var{n} times, once with all uses of @var{name} replaced by
+@var{int1}, once with all uses replaced by @var{int2}, and so on.
+@xref{Defining Mode Iterators}.
+
+It is possible to define attributes for ints as well as for codes and modes.
+There are two standard integer attributes: @code{int}, the name of the
+code in lower case, and @code{INT}, the name of the code in upper case.
+Other attributes are defined using:
+
+@smallexample
+(define_int_attr @var{name} [(@var{int1} "@var{value1}") @dots{} (@var{intn} 
"@var{valuen}")])
+@end smallexample
+
+Here's an example of int iterators in action, taken from the ARM port:
+
+@smallexample
+(define_int_iterator QABSNEG [UNSPEC_VQABS UNSPEC_VQNEG])
+
+(define_int_attr absneg [(UNSPEC_VQABS "abs") (UNSPEC_VQNEG "neg")])
+
+(define_insn "neon_vq"
+  [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
+   (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
+  (match_operand:SI 2 "immediate_operand" "i")]
+ QABSNEG))]
+  "TARGET_NEON"
+  "vq.\t%0, %1"
+  [(set_attr "neon_type" "neon_vqneg_vqabs")]
+)
+
+@end smallexample
+
+This is equivalent to:
+
+@smallexample
+(define_insn "neon_vqabs"
+  [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
+   (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
+  (match_operand:SI 2 "immediate_operand" "i")]
+ UNSPEC_VQABS))]
+  "TARGET_NEON"
+  "vqabs.\t%0, %1"
+  [(set_attr "neon_type" "neon_vqneg_vqabs")]
+)
+
+(define_insn "neon_vqneg"
+  [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
+   (unspec:VDQIW [(match_ope

[Google 4.6] Backport C++ canonicalization patch (issue6297080)

2012-06-12 Thread Sterling Augustine
The enclosed patch for Google 4.6 backports the final pubnames-canonicalization
patch from top of trunk.  It differs slightly from the earlier one because
google/4.6 had an earlier implementation already present.

OK for Google 4.6?

Sterling

2012-06-11  Sterling Augustine  

* gcc/c-family/c-pretty-print.h: Adjust pp_c_pretty_print_flags enum.
* gcc/cp/error.c (decl_as_dwarf_string, lang_decl_dwarf_name): New
functions.
* gcc/cp/cp-lang.c (cxx_dwarf_name): Call them.
* gcc/cp/cp-tree.h: Declare them.

Index: gcc/c-family/c-pretty-print.h
===
--- gcc/c-family/c-pretty-print.h   (revision 188405)
+++ gcc/c-family/c-pretty-print.h   (working copy)
@@ -30,8 +30,8 @@
 typedef enum
   {
  pp_c_flag_abstract = 1 << 1,
- pp_c_flag_last_bit = 2,
- pp_c_flag_gnu_v3 = 4
+ pp_c_flag_gnu_v3 = 1 << 2,
+ pp_c_flag_last_bit = 3
   } pp_c_pretty_print_flags;
 
 
Index: gcc/cp/error.c
===
--- gcc/cp/error.c  (revision 188405)
+++ gcc/cp/error.c  (working copy)
@@ -2459,7 +2459,22 @@
   return pp_formatted_text (cxx_pp);
 }
 
+/* Wrap decl_as_string with options appropriate for dwarf.  */
+
 const char *
+decl_as_dwarf_string (tree decl, int flags)
+{
+  const char *name;
+  /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the 
flag
+ here will be adequate to get the desired behaviour.  */
+  pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3;
+  name = decl_as_string (decl, flags);
+  /* Subsequent calls to the pretty printer shouldn't use this style.  */
+  pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3;
+  return name;
+}
+
+const char *
 decl_as_string (tree decl, int flags)
 {
   reinit_cxx_pp ();
@@ -2479,6 +2494,21 @@
   return pp_formatted_text (cxx_pp);
 }
 
+/* Wrap lang_decl_name with options appropriate for dwarf.  */
+
+const char *
+lang_decl_dwarf_name (tree decl, int v, bool translate)
+{
+  const char *name;
+  /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the 
flag
+ here will be adequate to get the desired behaviour.  */
+  pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3;
+  name = lang_decl_name (decl, v, translate);
+  /* Subsequent calls to the pretty printer shouldn't use this style.  */
+  pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3;
+  return name;
+}
+
 /* Generate the three forms of printable names for cxx_printable_name.  */
 
 const char *
Index: gcc/cp/cp-lang.c
===
--- gcc/cp/cp-lang.c(revision 188405)
+++ gcc/cp/cp-lang.c(working copy)
@@ -183,17 +183,11 @@
   && (ANON_AGGRNAME_P (DECL_NAME (t)) || LAMBDANAME_P (DECL_NAME (t
 return NULL;
   if (verbosity >= 2)
-return decl_as_string (t,
+return decl_as_dwarf_string (t,
   TFF_DECL_SPECIFIERS | TFF_UNQUALIFIED_NAME
-  | TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS
-   | TFF_MATCH_GNU_V3_DEMANGLER);
+ | TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS);
 
-  /* decl_as_string handles namespaces--especially anonymous ones--more
- appropriately for debugging than cxx_printable_name.  But
- cxx_printable_name handles templates and global ctors and dtors better.  
*/
-  if (TREE_CODE (t) == NAMESPACE_DECL)
-return decl_as_string (t, TFF_MATCH_GNU_V3_DEMANGLER);
-  return cxx_printable_name (t, verbosity);
+  return lang_decl_dwarf_name (t, verbosity, false);
 }
 
 static enum classify_record
Index: gcc/cp/cp-tree.h
===
--- gcc/cp/cp-tree.h(revision 188405)
+++ gcc/cp/cp-tree.h(working copy)
@@ -4913,8 +4913,10 @@
 extern const char *type_as_string_translate(tree, int);
 extern const char *decl_as_string  (tree, int);
 extern const char *decl_as_string_translate(tree, int);
+extern const char *decl_as_dwarf_string(tree, int);
 extern const char *expr_as_string  (tree, int);
 extern const char *lang_decl_name  (tree, int, bool);
+extern const char *lang_decl_dwarf_name(tree, int, bool);
 extern const char *language_to_string  (enum languages);
 extern const char *class_key_or_enum_as_string (tree);
 extern void print_instantiation_context(void);

--
This patch is available for review at http://codereview.appspot.com/6297080


Re: [PATCH 3/3] rs6000: Rewrite sync patterns for atomic; expand early.

2012-06-12 Thread Richard Henderson
On 2012-06-11 18:40, David Edelsohn wrote:
>> > Nope.  I do see the obvious mistake in the atomic_load pattern though:
>> > The mode iterator should have been INT1 not INT.
> Did you want to commit the fix for the iterator?
> 

Applied the following to mainline.

It ought to go onto the 4.7 branch as well, as it's a wrong-code bug.
Are we at a place in the 4.7.1 release process where that's possible?


r~
2012-06-12  Richard Henderson  

* config/rs6000/sync.md (atomic_load, atomic_store): Use INT1 mode
iterator instead of INT.


diff --git a/gcc/config/rs6000/sync.md b/gcc/config/rs6000/sync.md
index d4848a8..5b79428 100644
--- a/gcc/config/rs6000/sync.md
+++ b/gcc/config/rs6000/sync.md
@@ -111,8 +111,8 @@
(set_attr "length" "12")])
 
 (define_expand "atomic_load"
-  [(set (match_operand:INT 0 "register_operand" "");; output
-   (match_operand:INT 1 "memory_operand" ""))  ;; memory
+  [(set (match_operand:INT1 0 "register_operand" "")   ;; output
+   (match_operand:INT1 1 "memory_operand" "")) ;; memory
(use (match_operand:SI 2 "const_int_operand" ""))]  ;; model
   ""
 {
@@ -139,8 +139,8 @@
 })
 
 (define_expand "atomic_store"
-  [(set (match_operand:INT 0 "memory_operand" "")  ;; memory
-   (match_operand:INT 1 "register_operand" ""));; input
+  [(set (match_operand:INT1 0 "memory_operand" "") ;; memory
+   (match_operand:INT1 1 "register_operand" ""))   ;; input
(use (match_operand:SI 2 "const_int_operand" ""))]  ;; model
   ""
 {


Re: [PATCH 3/7] Add stdint.h wrapper for VxWorks.

2012-06-12 Thread Joseph S. Myers
On Wed, 6 Jun 2012, rbmj wrote:

> The stdint.h doesn't have all the typedefs needed for standards
> compliance, so add a hack that adds all of the needed typedefs
> to be fully compliant to the standard.  Fixes broken libstdc++.

If you're touching VxWorks stdint.h perhaps you could also define the 
relevant target macros for GCC to have built-in knowledge of the types?  
This is needed for the Fortran C bindings to work correctly, at least, and 
ensures char16_t and char32_t (C11/C++11) are correct as well.  (You could 
then set use_gcc_stdint to "wrap" in config.gcc if you want to use GCC's 
stdint.h for freestanding compilations.)

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] Hoist adjacent loads

2012-06-12 Thread H.J. Lu
On Mon, Jun 11, 2012 at 1:37 PM, William J. Schmidt
 wrote:
> OK, once more with feeling... :)
>
> This patch differs from the previous one in two respects:  It disables
> the optimization when either the then or else edge is well-predicted;
> and it now uses the existing l1-cache-line-size parameter instead of a
> new one (with updated commentary).
>
> Bootstraps and tests with no new regressions on
> powerpc64-unknown-linux-gnu.  One last performance run is underway, but
> I don't expect any surprises since both changes are more conservative.
> The original benchmark issue is still resolved.
>
> Is this version ok for trunk?
>
> Thanks,
> Bill
>
>
> 2012-06-11  Bill Schmidt  
>
>        * opts.c: Add -fhoist-adjacent-loads to -O2 and above.
>        * tree-ssa-phiopt.c (tree_ssa_phiopt_worker): Add argument to forward
>        declaration.
>        (hoist_adjacent_loads, gate_hoist_loads): New forward declarations.
>        (tree_ssa_phiopt): Call gate_hoist_loads.
>        (tree_ssa_cs_elim): Add parm to tree_ssa_phiopt_worker call.
>        (tree_ssa_phiopt_worker): Add do_hoist_loads to formal arg list; call
>        hoist_adjacent_loads.
>        (local_mem_dependence): New function.
>        (hoist_adjacent_loads): Likewise.
>        (gate_hoist_loads): Likewise.
>        * common.opt (fhoist-adjacent-loads): New switch.
>        * Makefile.in (tree-ssa-phiopt.o): Added dependencies.
>
>

This may have caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53647

H.J.


Re: [testsuite] gcc.dg/torture/stackalign: make compile lines unique in test summary

2012-06-12 Thread H.J. Lu
On Tue, Jun 12, 2012 at 7:59 AM, Janis Johnson  wrote:
> On 06/11/2012 09:05 PM, H.J. Lu wrote:
>> On Mon, Jun 11, 2012 at 7:41 PM, Janis Johnson  
>> wrote:
>>> The tests in gcc.dg/torture/stackalign use two sets of torture options:
>>> the usual optimization sets used as default for torture tests, and up to
>>> four sets of options that are specific to stack alignment.  Currently
>>> the stack alignment options are passed via an option that is used by the
>>> dg-test option dg_extra_tool_flags, which doesn't become part of the
>>> test messages in summary files the way the other torture options do,
>>> leading to non-unique compilation messages in the test summary.
>>>
>>> This patch uses existing support to combine multiple sets of torture
>>> options for use in a single set of tests, in this case the usual
>>> optimization torture options plus the stack alignment options.  Options
>>> used in all of the stack alignment testing on x86 targets are used in
>>> default options rather than as part of torture options, to reduce noise
>>> in test summaries.  Tests that currently use dg-options now use
>>> dg-additional-options instead to append to, rather than replace, the
>>> default flags.
>>>
>>> H.J., I'm pretty sure this now does what you want for the seven tests
>>> that specify different options.
>>>
>>> Tested on i686-pc-linux-gnu and arm-none-eabi.  OK for mainline?
>>>
>>> Janis
>>
>> Why is -mmmx added to -msse2?  -mno-mmx is added explicitly
>> to disable MMX.
>>
>
> Because without it I get:
>
> In file included from 
> /scratch/janisjo/fsf-i686-linux-2/obj/test-mainline-0-i686-pc-linux-gnu/host-i686-pc-linux-gnu/fsf-mainline/lib/gcc/i686-pc-linux-gnu/4.8.0/include/xmmintrin.h:36:0,^M
>                 from 
> /scratch/janisjo/fsf-i686-linux-2/obj/test-mainline-0-i686-pc-linux-gnu/host-i686-pc-linux-gnu/fsf-mainline/lib/gcc/i686-pc-linux-gnu/4.8.0/include/emmintrin.h:36,^M
>                 from 
> /scratch/janisjo/fsf-i686-linux-2/src/gcc-mainline/gcc/testsuite/gcc.dg/torture/stackalign/alloca-2.c:7:^M
> /scratch/janisjo/fsf-i686-linux-2/obj/test-mainline-0-i686-pc-linux-gnu/host-i686-pc-linux-gnu/fsf-mainline/lib/gcc/i686-pc-linux-gnu/4.8.0/include/mmintrin.h:32:3:
>  error: #error "MMX instruction set not enabled"^M
>
> Remember that without my changes to stackalign.exp the -mno-mmx option
> was not used for the tests that use dg-options.
>
> If it makes a difference, I can changes the four tests that use -msse2
> so that they don't use the default flags that include -mno-mmx, but use
> the other options from that list.
>

In this case, -mxmm with -msse2 is fine.

Thanks.

-- 
H.J.


Re: [PATCH H8300] Added offset bits of MOVA/Sz assembly instruction for memory access

2012-06-12 Thread Jeff Law

On 06/12/2012 07:55 AM, Sandeep Kumar Singh wrote:

Hi,

Please find the attached patch that adds offset bits for mova/Sz assembly
instruction of memory access in H8SX target.

Please review the patch and let me know if there should be any
modifications in it?

Tested with h8300-elf. No new regressions.

Regards,
Sandeep Kumar Singh,
KPIT Cummins InfoSystems Ltd.
Pune, India


* gcc/ChangeLog:

2012-06-12  Sandeep Kumar Singh

 * config/h8300/genmova.sh: Modified to add offset bits of
 mova/Sz assembly instruction for memory access.
 * config/h8300/h8300.c: Likewise.
 * config/h8300/mova.md: Likewise.

This is good.  Please install.

Thanks,
jeff



Re: [Patch, ARM][0/8] Epilogue in RTL: introduction (Sameera's patches, Part I)

2012-06-12 Thread Richard Earnshaw
On 31/05/12 19:18, Paul Brook wrote:

>> * The patches have not been explicitly tested with any FPA variants (which
>> are deprecated in 4.7 and expected to become obsolete in 4.8).
> 
> I'm not keen on breaking these without actually removing them.
> 
> Paul
> 

Ok, so lets remove them...

R.



Re: [Ada] Preliminary work to support SEH on Windows 64

2012-06-12 Thread Gabriel Dos Reis
On Tue, Jun 12, 2012 at 10:18 AM, Tristan Gingold  wrote:
>
> On Jun 12, 2012, at 5:00 PM, Gabriel Dos Reis wrote:
>
>> On Tue, Jun 12, 2012 at 7:33 AM, Arnaud Charlet  wrote:
>>> No functional change.
>>>
>>> Tested on x86_64-pc-linux-gnu, committed on trunk
>>>
>>> 2012-06-12  Tristan Gingold  
>>>
>>>        * a-exexpr-gcc.adb (Unwind_Exception): Add 4 more private fields.
>>>
>>
>> Does this mean that GCC will officially support SEH -- which surely is a
>> language-independent infrastructure, usable by other front ends?
>
> Richard Henderson has submitted (a few years ago) a patch to add SEH support 
> for Windows 64.
> We have rebased it and we are testing it for Ada with our tests.

It appears I missed that. Florian just sent a link to that patch via
private mail. Thanks!

>
> I hope this work will be soon ready and I plan to resubmit the patch (which 
> in fact was only
> partially committed: only SEH unwinding info generation are currently in GCC).
>
> I haven't tested it with C++ (I think Richard did), but it should work: the 
> runtime interface routines to SEH is sane.

Fantastic!  Thanks.

-- Gaby


Re: [Ada] Preliminary work to support SEH on Windows 64

2012-06-12 Thread Tristan Gingold

On Jun 12, 2012, at 5:00 PM, Gabriel Dos Reis wrote:

> On Tue, Jun 12, 2012 at 7:33 AM, Arnaud Charlet  wrote:
>> No functional change.
>> 
>> Tested on x86_64-pc-linux-gnu, committed on trunk
>> 
>> 2012-06-12  Tristan Gingold  
>> 
>>* a-exexpr-gcc.adb (Unwind_Exception): Add 4 more private fields.
>> 
> 
> Does this mean that GCC will officially support SEH -- which surely is a
> language-independent infrastructure, usable by other front ends?

Richard Henderson has submitted (a few years ago) a patch to add SEH support 
for Windows 64.
We have rebased it and we are testing it for Ada with our tests.

I hope this work will be soon ready and I plan to resubmit the patch (which in 
fact was only
partially committed: only SEH unwinding info generation are currently in GCC).

I haven't tested it with C++ (I think Richard did), but it should work: the 
runtime interface routines to SEH is sane.

Tristan.



Re: [patch][gcc47] Deprecate -fconserve-space

2012-06-12 Thread Joseph S. Myers
On Mon, 4 Jun 2012, Jason Merrill wrote:

> On 06/04/2012 04:30 PM, Steven Bosscher wrote:
> > How about this:
> 
> OK, looks good.
> 
> > There is still a file config/arm/aout.h
> 
> I noticed that, but it seems to be used together with elfos.h, so it seems not
> to be a.out-specific.  :)

I commented in  
on how arm/aout.h could safely and usefully be merged into arm/arm.h (and 
on a few other oddities in the configuration of various ARM targets).

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] Option to build bare-metal ARM cross-compiler for arm-none-eabi target without libunwind

2012-06-12 Thread Sebastian Huber

On 06/12/2012 04:37 PM, Joseph S. Myers wrote:

You need to provide a self-contained explanation of what the problem is
that your patch is fixing and why you chose that approach to fixing it -
with reference to the ARM EABI documentes (RTABI etc.) for why your
approach is valid according to the ARM EABI.

libunwind is a library separate from libgcc that is used by libgcc for
unwinding on ia64-linux-gnu only (whether built by GCC or separately
installed).  There is also a separate libunwind project that may be used
on GNU/Linux platforms but I am not aware of being used for bare-metal at
all.  Certainly it would be unusual to use it for ARM EABI and the ARM
EABI libgcc works fine without it.  So referring to libunwind in the ARM
EABI context seems rather confusing; if you don't want it, just do the
same as almost all other ARM EABI users and don't use it; it's *using*
libunwind that requires special action, not avoiding it.


I think the main problem is the usage of -fexceptions for some libgcc files.  I 
would not disable the libunwind build and simply avoid the -fexceptions.  See also


http://gcc.gnu.org/ml/gcc-help/2011-03/msg00149.html

--
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax : +49 89 18 90 80 79-9
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


Re: MIPS testsuite patch for --with-synci configurations

2012-06-12 Thread Steve Ellcey
On Mon, 2012-06-11 at 18:24 -0700, David Daney wrote:

> > This patch addes the -mno-synci flag to MIPS tests that specify an
> > architecture that does not support synci, thus getting rid of the
> > warning message and making the tests pass.  Tested with the mips-linux-gnu
> > and mips-sde-elf targets both with and without --with-synci on the
> > GCC configuration.
> >
> > OK to checkin?
> 
> I wonder if it would make more sense to modify the testsuite driver to 
> take care of this.  It seems like the set of files with the -mno-synci 
> annotation could easily become different than the set that requires it.
> 
> David Daney

I did think about that, but the number of flags that I would have to
check for in the testsuite driver to decide whether or not to turn on
-mno-synci was large enough to make me not want to do it that way.

I would need to check the isa= and isa_rev= flags that are currently
handled in the driver, the -mabi flag, the -march flag, and the -mips
flag.  The number of values that each flag could have (particularly
-march) is rather large.  I can imagine people adding a new test and
forgetting to add -mno-synci but that would be easy to fix and no worse
then adding a new -march value and not handling it in the test suite
driver.

Steve Ellcey
sell...@mips.com



Re: [Ada] Preliminary work to support SEH on Windows 64

2012-06-12 Thread Gabriel Dos Reis
On Tue, Jun 12, 2012 at 7:33 AM, Arnaud Charlet  wrote:
> No functional change.
>
> Tested on x86_64-pc-linux-gnu, committed on trunk
>
> 2012-06-12  Tristan Gingold  
>
>        * a-exexpr-gcc.adb (Unwind_Exception): Add 4 more private fields.
>

Does this mean that GCC will officially support SEH -- which surely is a
language-independent infrastructure, usable by other front ends?

-- Gaby


Re: [testsuite] gcc.dg/torture/stackalign: make compile lines unique in test summary

2012-06-12 Thread Janis Johnson
On 06/11/2012 09:05 PM, H.J. Lu wrote:
> On Mon, Jun 11, 2012 at 7:41 PM, Janis Johnson  
> wrote:
>> The tests in gcc.dg/torture/stackalign use two sets of torture options:
>> the usual optimization sets used as default for torture tests, and up to
>> four sets of options that are specific to stack alignment.  Currently
>> the stack alignment options are passed via an option that is used by the
>> dg-test option dg_extra_tool_flags, which doesn't become part of the
>> test messages in summary files the way the other torture options do,
>> leading to non-unique compilation messages in the test summary.
>>
>> This patch uses existing support to combine multiple sets of torture
>> options for use in a single set of tests, in this case the usual
>> optimization torture options plus the stack alignment options.  Options
>> used in all of the stack alignment testing on x86 targets are used in
>> default options rather than as part of torture options, to reduce noise
>> in test summaries.  Tests that currently use dg-options now use
>> dg-additional-options instead to append to, rather than replace, the
>> default flags.
>>
>> H.J., I'm pretty sure this now does what you want for the seven tests
>> that specify different options.
>>
>> Tested on i686-pc-linux-gnu and arm-none-eabi.  OK for mainline?
>>
>> Janis
> 
> Why is -mmmx added to -msse2?  -mno-mmx is added explicitly
> to disable MMX.
> 

Because without it I get:

In file included from 
/scratch/janisjo/fsf-i686-linux-2/obj/test-mainline-0-i686-pc-linux-gnu/host-i686-pc-linux-gnu/fsf-mainline/lib/gcc/i686-pc-linux-gnu/4.8.0/include/xmmintrin.h:36:0,^M
 from 
/scratch/janisjo/fsf-i686-linux-2/obj/test-mainline-0-i686-pc-linux-gnu/host-i686-pc-linux-gnu/fsf-mainline/lib/gcc/i686-pc-linux-gnu/4.8.0/include/emmintrin.h:36,^M
 from 
/scratch/janisjo/fsf-i686-linux-2/src/gcc-mainline/gcc/testsuite/gcc.dg/torture/stackalign/alloca-2.c:7:^M
/scratch/janisjo/fsf-i686-linux-2/obj/test-mainline-0-i686-pc-linux-gnu/host-i686-pc-linux-gnu/fsf-mainline/lib/gcc/i686-pc-linux-gnu/4.8.0/include/mmintrin.h:32:3:
 error: #error "MMX instruction set not enabled"^M

Remember that without my changes to stackalign.exp the -mno-mmx option
was not used for the tests that use dg-options.

If it makes a difference, I can changes the four tests that use -msse2
so that they don't use the default flags that include -mno-mmx, but use
the other options from that list.

Janis


Re: [PATCH] Option to build bare-metal ARM cross-compiler for arm-none-eabi target without libunwind

2012-06-12 Thread Joseph S. Myers
You need to provide a self-contained explanation of what the problem is 
that your patch is fixing and why you chose that approach to fixing it - 
with reference to the ARM EABI documentes (RTABI etc.) for why your 
approach is valid according to the ARM EABI.

libunwind is a library separate from libgcc that is used by libgcc for 
unwinding on ia64-linux-gnu only (whether built by GCC or separately 
installed).  There is also a separate libunwind project that may be used 
on GNU/Linux platforms but I am not aware of being used for bare-metal at 
all.  Certainly it would be unusual to use it for ARM EABI and the ARM 
EABI libgcc works fine without it.  So referring to libunwind in the ARM 
EABI context seems rather confusing; if you don't want it, just do the 
same as almost all other ARM EABI users and don't use it; it's *using* 
libunwind that requires special action, not avoiding it.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [RFA:] Caveat for ARM in gcc-4.7/changes.html: unaligned accesses

2012-06-12 Thread Hans-Peter Nilsson
> From: Hans-Peter Nilsson 
> Date: Mon, 11 Jun 2012 00:59:57 +0200

> > From: Michael Hope 
> > Date: Mon, 11 Jun 2012 00:04:19 +0200
> 
> > On 8 June 2012 16:53, Hans-Peter Nilsson  
> > wrote:
> > >> From: Hans-Peter Nilsson 
> > >> Date: Fri, 8 Jun 2012 06:29:04 +0200
> > >
> > >> > From: Michael Hope 
> > >> > Date: Fri, 8 Jun 2012 05:50:52 +0200
> > >> >  The combination of
> > >> > older Linux ARM kernels and GCC 4.7 gives a faulty kernel.
> > >>
> > >> We're in agreement!
> > >
> > > Oh wait sorry, my bad, I misread.  Instead of "gives a faulty
> > > kernel", I'd say "for ARMv6 and later (not -M), gives faulty
> > > user-space code".  Maybe the kernel too, I can't say; there was
> > > IIRC no sign of it.

But (at least) after removing some local changed defaults,
there's at boot-time a lot of:

[0.95] Unhandled fault: alignment exception (0x801) at 0xc821ddee

> > Is there a bugzilla ticket logged for this?  I'd like to try to reproduce 
> > it.

Here's a shorter case I'll attach to a PR for this unless it
gets resolved one way or another soonish.  Remember, you'll have
to run this on a pre-3.2 kernel with CONFIG_ALIGNMENT_TRAP on
(the default) and you have to compile for ARM v6 or later (as in
-march=armv6).  Using gcc-4.7.1-rc1 should do, most likely
earlier revisions too.

__attribute__ ((__noinline__, __noclone__))
void doit(char *x)
{
  asm ("");
  __builtin_strcpy (x, "stat");
}

int main(void)
{
  char x[30];
  doit(x + 1);
  doit(x);
  __builtin_exit (0);
}

> > It's interesting as we backported the patch into the Linaro GCC that
> > was used to build Ubuntu Precise and didn't find any faults.

I have no idea why you didn't run into this, unless it was one
of the obvious reasons: not building for ARM v6 or the kernel
was 3.2 or later, or configured with CONFIG_ALIGNMENT_TRAP off.
Or other local patches of yours.

brgds, H-P


Re: [C PATCH] Diagnose compound literals with incomplete type (PR c/53532)

2012-06-12 Thread Joseph S. Myers
On Sat, 2 Jun 2012, Jakub Jelinek wrote:

> Hi!
> 
> As the testcase shows, we weren't diagnosing compound literals with
> incomplete type at all.  Fixed thusly, bootstrapped/regtested on
> x86_64-linux and i686-linux, ok for trunk?

OK with the various testcases from the other duplicates of this bug 
(51034, 53196) also added to the testsuite.

-- 
Joseph S. Myers
jos...@codesourcery.com


[PATCH H8300] Added offset bits of MOVA/Sz assembly instruction for memory access

2012-06-12 Thread Sandeep Kumar Singh
Hi,

Please find the attached patch that adds offset bits for mova/Sz assembly
instruction of memory access in H8SX target.

Please review the patch and let me know if there should be any 
modifications in it?

Tested with h8300-elf. No new regressions.

Regards,
Sandeep Kumar Singh,
KPIT Cummins InfoSystems Ltd.
Pune, India


* gcc/ChangeLog:

2012-06-12  Sandeep Kumar Singh  

* config/h8300/genmova.sh: Modified to add offset bits of
mova/Sz assembly instruction for memory access.
* config/h8300/h8300.c: Likewise.
* config/h8300/mova.md: Likewise.



mova-offset.patch
Description: mova-offset.patch


Re: [PATCH 3/3] rs6000: Rewrite sync patterns for atomic; expand early.

2012-06-12 Thread Richard Henderson
On 2012-06-11 18:40, David Edelsohn wrote:
> On Sat, Jun 9, 2012 at 10:40 AM, Richard Henderson  wrote:
> 
>> Nope.  I do see the obvious mistake in the atomic_load pattern though:
>> The mode iterator should have been INT1 not INT.
> 
> Did you want to commit the fix for the iterator?

Yes.  I'm just finishing testing that patch in fact.

> I like your suggestion, but the PowerPC developer community does not
> uniformly appreciate that behavior.

Surely there's a difference between gratuitously using fp registers
and that being the *only* way to implement a particular operation...


r~


Re: [gimplefe] patch that fixes the bug for the failure test case

2012-06-12 Thread Diego Novillo

On 12-06-08 22:25 , Sandeep Soni wrote:

Hi,

This patch fixes the failure test case that I had submitted the last time.

The changeLog is testsuite/gChangeLog.gimplefe is as follows.

2012-06-09   Sandeep Soni
   * gimple.dg/20120605-2.gimple : New.

While the changelog in gimple/ChangeLog is as follows
2012-06-09   Sandeep Soni
   * parser.c (gp_parse_expect_return_var) : Modify to have
correct token consumption.


I don't follow how your patch fixes the ICE.  Could you describe it a 
bit more?  How was it failing?


You'll need a blank line after the date line in ChangeLog entries.


Thanks.  Diego.


[Ada] Interplay between exception handlers and finalization

2012-06-12 Thread Arnaud Charlet
This patch corrects the machinery which detects controlled objects inside a
block created for the purposes of avoiding interference of exception handlers
and At_End handlers.


-- Source --


--  types.ads

with Ada.Finalization; use Ada.Finalization;

package Types is
   type Ctrl is new Controlled with null record;
   procedure Finalize (Obj : in out Ctrl);
   function Make_Ctrl return Ctrl;

   type Rec is record
  Data : Ctrl;
   end record;
   function Make_Rec return Rec;
end Types;

--  types.adb:

with Ada.Text_IO; use Ada.Text_IO;

package body Types is
   procedure Finalize (Obj : in out Ctrl) is
   begin
  Put_Line ("Finalize");
   end Finalize;

   function Make_Ctrl return Ctrl is
  Result : Ctrl;
   begin
  return Result;
   end Make_Ctrl;

   function Make_Rec return Rec is
   begin
  return Rec'(Data => Make_Ctrl);
   exception
  when others =>
 Put_Line ("BOMB");
 raise Program_Error;
   end Make_Rec;
end Types;

--  main.adb:

with Ada.Text_IO; use Ada.Text_IO;
with Types;   use Types;

procedure Main is
begin
   Put_Line ("Main");
   declare
  Obj : Rec := Make_Rec;
   begin
  null;
   end;
   Put_Line ("End");
end Main;


-- Compilation and output --


$ gnatmake -q main.adb
$ ./main
$ Main
$ Finalize
$ Finalize
$ Finalize
$ Finalize
$ Finalize
$ End

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Hristian Kirtchev  

* exp_ch7.adb (Process_Declarations): Handle the case where
the original context has been wrapped in a block to avoid
interference between exception handlers and At_End handlers.
(Wrap_HSS_In_Block): Mark the block which contains the original
statements of the context as being a finalization wrapper.
* sinfo.adb (Is_Finalization_Wrapper): New routine.
(Set_Is_Finalization_Wrapper): New routine.

* sinfo.ads: Add new attribute Is_Finalization_Wrapper applicable
to block statemnts.
(Is_Finalization_Wrapper): New routine with corresponding pragma Inline.
(Set_Is_Finalization_Wrapper): New routine with corresponding pragma
Inline.

Index: exp_ch7.adb
===
--- exp_ch7.adb (revision 188445)
+++ exp_ch7.adb (working copy)
@@ -2094,6 +2094,22 @@
then
   Last_Top_Level_Ctrl_Construct := Decl;
end if;
+
+--  Handle the case where the original context has been wrapped in
+--  a block to avoid interference between exception handlers and
+--  At_End handlers. Treat the block as transparent and process its
+--  contents.
+
+elsif Nkind (Decl) = N_Block_Statement
+  and then Is_Finalization_Wrapper (Decl)
+then
+   if Present (Handled_Statement_Sequence (Decl)) then
+  Process_Declarations
+(Statements (Handled_Statement_Sequence (Decl)),
+ Preprocess);
+   end if;
+
+   Process_Declarations (Declarations (Decl), Preprocess);
 end if;
 
 Prev_Non_Pragma (Decl);
@@ -3696,6 +3712,11 @@
Make_Block_Statement (Loc,
  Handled_Statement_Sequence => HSS);
 
+ --  Signal the finalization machinery that this particular block
+ --  contains the original context.
+
+ Set_Is_Finalization_Wrapper (Block);
+
  Set_Handled_Statement_Sequence (N,
Make_Handled_Sequence_Of_Statements (Loc, New_List (Block)));
  HSS := Handled_Statement_Sequence (N);
Index: sinfo.adb
===
--- sinfo.adb   (revision 188428)
+++ sinfo.adb   (working copy)
@@ -1806,6 +1806,14 @@
   return Flag11 (N);
end Is_Expanded_Build_In_Place_Call;
 
+   function Is_Finalization_Wrapper
+  (N : Node_Id) return Boolean is
+   begin
+  pragma Assert (False
+or else NT (N).Nkind = N_Block_Statement);
+  return Flag9 (N);
+   end Is_Finalization_Wrapper;
+
function Is_Folded_In_Parser
   (N : Node_Id) return Boolean is
begin
@@ -4902,6 +4910,14 @@
   Set_Flag11 (N, Val);
end Set_Is_Expanded_Build_In_Place_Call;
 
+   procedure Set_Is_Finalization_Wrapper
+  (N : Node_Id; Val : Boolean := True) is
+   begin
+  pragma Assert (False
+or else NT (N).Nkind = N_Block_Statement);
+  Set_Flag9 (N, Val);
+   end Set_Is_Finalization_Wrapper;
+
procedure Set_Is_Folded_In_Parser
   (N : Node_Id; Val : Boolean := True) is
begin
Index: sinfo.ads
===
--- sinfo.ads   (revision 188445)
+++ sinfo.ads   (working copy)
@@ -1310,6 +1310,12 @@
--actuals to support a build-in-place style of call have been added to
--the call.
 

[Ada] Preliminary work to support SEH on Windows 64

2012-06-12 Thread Arnaud Charlet
No functional change.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Tristan Gingold  

* a-exexpr-gcc.adb (Unwind_Exception): Add 4 more private fields.

Index: a-exexpr-gcc.adb
===
--- a-exexpr-gcc.adb(revision 188428)
+++ a-exexpr-gcc.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -108,6 +108,14 @@
   Cleanup  : System.Address;
   Private1 : Unwind_Word;
   Private2 : Unwind_Word;
+
+  --  Usual exception structure has only 2 private fields, but the SEH
+  --  one has 6.  To avoid makeing this file more complex, we use 6 fields
+  --  on all platforms, wasting a few bytes on some.
+  Private3 : Unwind_Word;
+  Private4 : Unwind_Word;
+  Private5 : Unwind_Word;
+  Private6 : Unwind_Word;
end record;
pragma Convention (C, Unwind_Exception);
--  Map the GCC struct used for exception handling
@@ -475,8 +483,7 @@
 new GNAT_GCC_Exception'
   (Header => (Class => GNAT_Exception_Class,
   Cleanup => GNAT_GCC_Exception_Cleanup'Address,
-  Private1 => 0,
-  Private2 => 0),
+  others => 0),
Occurrence => Excep.all);
 
   --  Propagate it


[Ada] New variant of -gnatn to specify inlining level

2012-06-12 Thread Arnaud Charlet
With this change, the compiler now supports the -gnatn[d] switch, where 'd'
is a digit and can only be '1' or '2' for the time being, to let the user
specify the level of inlining across modules. If the old form `-gnatn' is used,
the compiler will pick the inlining level based on the optimization level.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Eric Botcazou  

* opt.ads (Inline_Level): New variable.
* gnat1drv.adb (Adjust_Global_Switches): Set it based on optimization
level if it has not been set by the user.
* switch-c.adb (Scan_Front_End_Switches): Accept -gnatn1 and -gnatn2
and set Inline_Level accordingly.
* inline.adb (Add_Inlined_Body): Declate new Inline_Level_Type type.
(Must_Inline): Return Inline_Level_T instead of Boolean to indicate
whether the package of the inlined subprogram must be compiled.
If Inline_Level is set to 1, only compile packages of subprograms
directly called from the main unit.
* usage.adb (Usage): Adjust line for -gnatn switch.
* gnat_ugn.texi (Switches for gcc): Document -gnatn1 and -gnatn2.

Index: switch-c.adb
===
--- switch-c.adb(revision 188428)
+++ switch-c.adb(working copy)
@@ -732,6 +732,16 @@
Ptr := Ptr + 1;
Inline_Active := True;
 
+   --  There may be a digit appended to the switch
+
+   if Ptr <= Max then
+  C := Switch_Chars (Ptr);
+  if C = '1' or C = '2' then
+ Ptr := Ptr + 1;
+ Inline_Level := Character'Pos (C) - Character'Pos ('0');
+  end if;
+   end if;
+
 --  Processing for N switch
 
 when 'N' =>
Index: inline.adb
===
--- inline.adb  (revision 188428)
+++ inline.adb  (working copy)
@@ -229,7 +229,13 @@
 
procedure Add_Inlined_Body (E : Entity_Id) is
 
-  function Must_Inline return Boolean;
+  type Inline_Level_Type is (Dont_Inline, Inline_Call, Inline_Package);
+  --  Level of inlining for the call: Dont_Inline means no inlining,
+  --  Inline_Call means that only the call is considered for inlining,
+  --  Inline_Package means that the call is considered for inlining and
+  --  its package compiled and scanned for more inlining opportunities.
+
+  function Must_Inline return Inline_Level_Type;
   --  Inlining is only done if the call statement N is in the main unit,
   --  or within the body of another inlined subprogram.
 
@@ -237,7 +243,7 @@
   -- Must_Inline --
   -
 
-  function Must_Inline return Boolean is
+  function Must_Inline return Inline_Level_Type is
  Scop : Entity_Id;
  Comp : Node_Id;
 
@@ -251,7 +257,7 @@
  --  trouble to try to inline at this level.
 
  if Scop = Standard_Standard then
-return False;
+return Dont_Inline;
  end if;
 
  --  Otherwise lookup scope stack to outer scope
@@ -267,14 +273,19 @@
 Comp := Parent (Comp);
  end loop;
 
+ --  If the call is in the main unit, inline the call and compile the
+ --  package of the subprogram to find more calls to be inlined.
+
  if Comp = Cunit (Main_Unit)
or else Comp = Library_Unit (Cunit (Main_Unit))
  then
 Add_Call (E);
-return True;
+return Inline_Package;
  end if;
 
- --  Call is not in main unit. See if it's in some inlined subprogram
+ --  The call is not in the main unit. See if it is in some inlined
+ --  subprogram. If so, inline the call and, if the inlining level is
+ --  set to 1, stop there; otherwise also compile the package as above.
 
  Scop := Current_Scope;
  while Scope (Scop) /= Standard_Standard
@@ -284,15 +295,21 @@
   and then Is_Inlined (Scop)
 then
Add_Call (E, Scop);
-   return True;
+   if Inline_Level = 1 then
+  return Inline_Call;
+   else
+  return Inline_Package;
+   end if;
 end if;
 
 Scop := Scope (Scop);
  end loop;
 
- return False;
+ return Dont_Inline;
   end Must_Inline;
 
+  Level : Inline_Level_Type;
+
--  Start of processing for Add_Inlined_Body
 
begin
@@ -309,11 +326,15 @@
   --  no enclosing package to retrieve. In this case, it is the body of
   --  the function that will have to be loaded.
 
-  if not Is_Abstract_Subprogram (E)
-and then not Is_Nested (E)
-and then Convention (E) /= Convention_Protected
-and then Must_Inline
+  if Is_Abstract_Subprogram (E)
+or else Is_Nested (E

Re: [RFC PR48941 / 51980] Rewrite arm_neon.h to use __builtin_shuffle

2012-06-12 Thread Richard Guenther
On Tue, Jun 12, 2012 at 2:23 PM, Ramana Radhakrishnan
 wrote:
>>
>> +  if (TREE_CODE (mask) == SSA_NAME)
>> +    {
>> +      gimple def_stmt = SSA_NAME_DEF_STMT (mask);
>> +      if (is_gimple_assign (def_stmt)
>> +         && gimple_assign_rhs_code (def_stmt) == VECTOR_CST)
>> +       mask = gimple_assign_rhs1 (def_stmt);
>> +    }
>> +
>>   if (TREE_CODE (mask) == VECTOR_CST)
>>     {
>>       unsigned char *sel_int = XALLOCAVEC (unsigned char, elements);
>>
>> pre-approved if it passes bootstrap & regtest.
>
> Thanks that's similar to what I was wiring up. I'm happy to bootstrap
> and regtest that along with my other changes.

Looks like you need to adjust the gimple as well:

Index: gcc/tree-vect-generic.c
===
--- gcc/tree-vect-generic.c (revision 188428)
+++ gcc/tree-vect-generic.c (working copy)
@@ -628,6 +628,14 @@ lower_vec_perm (gimple_stmt_iterator *gs
   location_t loc = gimple_location (gsi_stmt (*gsi));
   unsigned i;

+  if (TREE_CODE (mask) == SSA_NAME)
+{
+  gimple def_stmt = SSA_NAME_DEF_STMT (mask);
+  if (is_gimple_assign (def_stmt)
+ && gimple_assign_rhs_code (def_stmt) == VECTOR_CST)
+   mask = gimple_assign_rhs1 (def_stmt);
+}
+
   if (TREE_CODE (mask) == VECTOR_CST)
 {
   unsigned char *sel_int = XALLOCAVEC (unsigned char, elements);
@@ -637,7 +645,11 @@ lower_vec_perm (gimple_stmt_iterator *gs
  & (2 * elements - 1));

   if (can_vec_perm_p (TYPE_MODE (vect_type), false, sel_int))
-   return;
+   {
+ gimple_assign_set_rhs3 (stmt, mask);
+ update_stmt (stmt);
+ return;
+   }
 }
   else if (can_vec_perm_p (TYPE_MODE (vect_type), true, NULL))
 return;


> Ramana


Re: [RFC PR48941 / 51980] Rewrite arm_neon.h to use __builtin_shuffle

2012-06-12 Thread Ramana Radhakrishnan
>
> +  if (TREE_CODE (mask) == SSA_NAME)
> +    {
> +      gimple def_stmt = SSA_NAME_DEF_STMT (mask);
> +      if (is_gimple_assign (def_stmt)
> +         && gimple_assign_rhs_code (def_stmt) == VECTOR_CST)
> +       mask = gimple_assign_rhs1 (def_stmt);
> +    }
> +
>   if (TREE_CODE (mask) == VECTOR_CST)
>     {
>       unsigned char *sel_int = XALLOCAVEC (unsigned char, elements);
>
> pre-approved if it passes bootstrap & regtest.

Thanks that's similar to what I was wiring up. I'm happy to bootstrap
and regtest that along with my other changes.

Ramana


Re: [RFC PR48941 / 51980] Rewrite arm_neon.h to use __builtin_shuffle

2012-06-12 Thread Richard Guenther
On Tue, Jun 12, 2012 at 2:12 PM, Richard Guenther
 wrote:
> On Tue, Jun 12, 2012 at 1:07 PM, Ramana Radhakrishnan
>  wrote:
>> On 12 June 2012 11:46, Richard Guenther  wrote:
>>> On Tue, Jun 12, 2012 at 11:22 AM, Julian Brown  
>>> wrote:
 On Mon, 11 Jun 2012 16:46:27 +0100
 Ramana Radhakrishnan  wrote:

> Hi,
>
> I don't like the ML bits of the patch as it stands today and before
> committing I would like to clean up the ML bits quite a bit further
> especially in areas where I've put FIXMEs [...]

 I had a go at this, see attached. Untested. Note there are some
 semantic differences in output:

  vzipq_p8 (poly8x16_t __a, poly8x16_t __b)
  {
   poly8x16x2_t __rv;
 -  uint8x16_t __mask1 = {0, 2};
 -  uint8x16_t __mask2 = {1, 3};
 -  __rv.val[0] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask1);
 -  __rv.val[1] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask2);
 +  uint8x16_t __mask1 = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6,
  22, 7, 23 };
 +  uint8x16_t __mask2 = { 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29,
  14, 30, 15, 31 };
 +  __rv.val[0] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask1);
 +  __rv.val[1] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask2);
>>>
>>> You should get better code at -O0 when not using a temporary __mask1/__mask2
>>> but directly pasting the constant in the builtin call.
>>
>> I tried that yesterday but it didn't seem to help - from a quick peek
>> at the dumps it looks like we could do with some limited const prop
>> just for the vec_perm expand cases.
>>
>>      D.14032 = { 0, 8, 1, 9, 2, 10, 3, 11 };
>>      D.14044 = VEC_PERM_EXPR <__a, __b, D.14032>;
>>
>> That's what I see from the dumps and from a quick skim of the sources
>> - my suspicion is that lower_vec_perm in tree-vect-generic.c is where
>> we could try doing a limited constant propagation in this case. ? Is
>> that where one should attempt to fix this ?
>>
>> Consider the following testcase at O0 rewritten with just
>> __builtin_shuffle so that you can see it on other platforms as well
>> that have vec_perm_const defined for doing the interleave style
>> operations. and look at what you get for O1. On arm-linux-gnueabi with
>> -mfpu=neon -mfloat-abi=softfp -mcpu=cortex-a9 at O0 you'd see it use
>> the generic permute operations and at O1 you'd see a vzip.32
>> instruction
>>
>>
>> typedef int v4si __attribute__ ((vector_size (16)));
>>
>> v4si vs (v4si a, v4si b)
>> {
>>  return __builtin_shuffle (a, b, (v4si) {0, 4, 1, 5});
>> }
>
> Ok, I see the C frontend hands us this as
>
>  return  VEC_PERM_EXPR < a , b , <<< Unknown tree: compound_literal_expr
>    v4si D.1712 = { 0, 4, 1, 5 }; >>> > ;
>
> and gimplification in some way fails to gimplify it to { 0, 4, 1, 5 }.  Yes,
> tree-vect-generic.c could just lookup the SSA def stmt in this case - it
> does so in most cases already.

Like with

Index: tree-vect-generic.c
===
--- tree-vect-generic.c (revision 188428)
+++ tree-vect-generic.c (working copy)
@@ -628,6 +628,14 @@ lower_vec_perm (gimple_stmt_iterator *gs
   location_t loc = gimple_location (gsi_stmt (*gsi));
   unsigned i;

+  if (TREE_CODE (mask) == SSA_NAME)
+{
+  gimple def_stmt = SSA_NAME_DEF_STMT (mask);
+  if (is_gimple_assign (def_stmt)
+ && gimple_assign_rhs_code (def_stmt) == VECTOR_CST)
+   mask = gimple_assign_rhs1 (def_stmt);
+}
+
   if (TREE_CODE (mask) == VECTOR_CST)
 {
   unsigned char *sel_int = XALLOCAVEC (unsigned char, elements);

pre-approved if it passes bootstrap & regtest.

Richard.

> Richard.
>
>>
>> regards
>> Ramana
>>
>>>
   return __rv;
  }

 I wasn't quite sure which version was correct -- but your version
 doesn't seem to have enough elements for these cases?

 HTH,

 Julian


Re: [Ping] Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks

2012-06-12 Thread rbmj

On 06/11/2012 08:01 AM, Paolo Bonzini wrote:

Il 11/06/2012 13:56, rbmj ha scritto:

... simply pass the extra mode argument in unconditionally,
as it should be transparent to the function and ignored if it is
variadic (I'm no expert on calling conventions though).

Yes, please do this.

Done.
VxWorks should define TARGET_POSIX_IO if it has both access and mkdir. 
Please add it to gcc/config/vxworks.h if this is the case.


I misspoke in my earlier email - sorry for my lack of attention to 
detail.  The issue is that
VxWorks does *not* have a two argument mkdir().  It does have 
TARGET_POSIX_IO.  Undefing TARGET_POSIX_IO seems non-optimal as it 
disables some functionality that can still be implemented, just omitting 
the mode argument.  With this in mind, I defined MKDIR_SINGLE_ARG in 
gcc/config/vxworks.h, and then added a check for this define.  This is a 
slightly less ugly solution than I had earlier.


An updated patch is attached.  It's in git format-patch format, so the 
commit message is at the top.


Robert
>From 61de9bcf6c0dc60185a84b07e0f8ad2f870b6799 Mon Sep 17 00:00:00 2001
From: rbmj 
Date: Tue, 12 Jun 2012 07:54:20 -0400
Subject: [PATCH] Fixed compilation on VxWorks because of open()/mkdir()

VxWorks only has a single arg mkdir(), and kernel modules
only have a (fixed) three argument open() instead of the
compliant variadic version.  For open(), pass the mode
argument unconditionally so that we always use three
arguments.  This shouldn't break other platforms, as it will
just be ignored.  For mkdir(), added MKDIR_SINGLE_ARG
(similarly to TARGET_POSIX_IO) in order to only use one
argument to maintain compatibility.

Modified:
	*gcc/config/vxworks.h:  Added define for MKDIR_SINGLE_ARG
	*gcc/gcov-io.c (gcov_open): Pass in mode to open()
	 unconditionally to support non-variadic open()
	*libgcc/libgcov.c (create_file_directory):  Add check for
	 MKDIR_SINGLE_ARG to support single-argument mkdir()
---
 gcc/config/vxworks.h |2 ++
 gcc/gcov-io.c|2 +-
 libgcc/libgcov.c |2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h
index 000de36..cd57f1a 100644
--- a/gcc/config/vxworks.h
+++ b/gcc/config/vxworks.h
@@ -117,6 +117,8 @@ extern void vxworks_asm_out_destructor (rtx symbol, int priority);
 
 /* Both kernels and RTPs have the facilities required by this macro.  */
 #define TARGET_POSIX_IO
+#define MKDIR_SINGLE_ARG
+
 
 /* A VxWorks implementation of TARGET_OS_CPP_BUILTINS.  */
 #define VXWORKS_OS_CPP_BUILTINS()	\
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index 37c1c3e..13c1aa8 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -92,7 +92,7 @@ gcov_open (const char *name, int mode)
 {
   /* Read-only mode - acquire a read-lock.  */
   s_flock.l_type = F_RDLCK;
-  fd = open (name, O_RDONLY);
+  fd = open (name, O_RDONLY, S_IRUSR | S_IWUSR);
 }
   else
 {
diff --git a/libgcc/libgcov.c b/libgcc/libgcov.c
index 8ed8971..5c4fa1c 100644
--- a/libgcc/libgcov.c
+++ b/libgcc/libgcov.c
@@ -133,7 +133,7 @@ create_file_directory (char *filename)
 
 /* Try to make directory if it doesn't already exist.  */
 if (access (filename, F_OK) == -1
-#ifdef TARGET_POSIX_IO
+#if defined(TARGET_POSIX_IO) && !defined(MKDIR_SINGLE_ARG)
 && mkdir (filename, 0755) == -1
 #else
 && mkdir (filename) == -1
-- 
1.7.5.4



Re: [RFC PR48941 / 51980] Rewrite arm_neon.h to use __builtin_shuffle

2012-06-12 Thread Richard Guenther
On Tue, Jun 12, 2012 at 1:07 PM, Ramana Radhakrishnan
 wrote:
> On 12 June 2012 11:46, Richard Guenther  wrote:
>> On Tue, Jun 12, 2012 at 11:22 AM, Julian Brown  
>> wrote:
>>> On Mon, 11 Jun 2012 16:46:27 +0100
>>> Ramana Radhakrishnan  wrote:
>>>
 Hi,

 I don't like the ML bits of the patch as it stands today and before
 committing I would like to clean up the ML bits quite a bit further
 especially in areas where I've put FIXMEs [...]
>>>
>>> I had a go at this, see attached. Untested. Note there are some
>>> semantic differences in output:
>>>
>>>  vzipq_p8 (poly8x16_t __a, poly8x16_t __b)
>>>  {
>>>   poly8x16x2_t __rv;
>>> -  uint8x16_t __mask1 = {0, 2};
>>> -  uint8x16_t __mask2 = {1, 3};
>>> -  __rv.val[0] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask1);
>>> -  __rv.val[1] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask2);
>>> +  uint8x16_t __mask1 = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6,
>>>  22, 7, 23 };
>>> +  uint8x16_t __mask2 = { 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29,
>>>  14, 30, 15, 31 };
>>> +  __rv.val[0] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask1);
>>> +  __rv.val[1] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask2);
>>
>> You should get better code at -O0 when not using a temporary __mask1/__mask2
>> but directly pasting the constant in the builtin call.
>
> I tried that yesterday but it didn't seem to help - from a quick peek
> at the dumps it looks like we could do with some limited const prop
> just for the vec_perm expand cases.
>
>      D.14032 = { 0, 8, 1, 9, 2, 10, 3, 11 };
>      D.14044 = VEC_PERM_EXPR <__a, __b, D.14032>;
>
> That's what I see from the dumps and from a quick skim of the sources
> - my suspicion is that lower_vec_perm in tree-vect-generic.c is where
> we could try doing a limited constant propagation in this case. ? Is
> that where one should attempt to fix this ?
>
> Consider the following testcase at O0 rewritten with just
> __builtin_shuffle so that you can see it on other platforms as well
> that have vec_perm_const defined for doing the interleave style
> operations. and look at what you get for O1. On arm-linux-gnueabi with
> -mfpu=neon -mfloat-abi=softfp -mcpu=cortex-a9 at O0 you'd see it use
> the generic permute operations and at O1 you'd see a vzip.32
> instruction
>
>
> typedef int v4si __attribute__ ((vector_size (16)));
>
> v4si vs (v4si a, v4si b)
> {
>  return __builtin_shuffle (a, b, (v4si) {0, 4, 1, 5});
> }

Ok, I see the C frontend hands us this as

  return  VEC_PERM_EXPR < a , b , <<< Unknown tree: compound_literal_expr
v4si D.1712 = { 0, 4, 1, 5 }; >>> > ;

and gimplification in some way fails to gimplify it to { 0, 4, 1, 5 }.  Yes,
tree-vect-generic.c could just lookup the SSA def stmt in this case - it
does so in most cases already.

Richard.

>
> regards
> Ramana
>
>>
>>>   return __rv;
>>>  }
>>>
>>> I wasn't quite sure which version was correct -- but your version
>>> doesn't seem to have enough elements for these cases?
>>>
>>> HTH,
>>>
>>> Julian


Re: [PATCH] Correct cost model for strided loads

2012-06-12 Thread William J. Schmidt
On Tue, 2012-06-12 at 12:59 +0200, Richard Guenther wrote:

> Btw, with PR53533 I now have a case where multiplications of v4si are
> really expensive on x86 without SSE 4.1.  But we only have vect_stmt_cost
> and no further subdivision ...
> 
> Thus we'd need a tree_code argument to the cost hook.  Though it gets
> quite overloaded then, so maybe splitting it into one handling loads/stores
> (and get the misalign parameter) and one handling only vector_stmt but
> with a tree_code argument.  Or splitting it even further, seeing
> cond_branch_taken ...

Yes, I think subdividing the hook for the vector_stmt kind is pretty
much inevitable -- more situations like this expensive multiply will
arise.  I agree with the interface starting to get messy also.
Splitting it is probably the way to go -- a little painful but keeping
it all in one hook is going to get ugly.

Bill

> 
> Richard.
> 



Re: arm-rtems switch default target to EABI

2012-06-12 Thread Sebastian Huber

On 06/12/2012 01:23 PM, Ralf Corsepius wrote:

On 06/12/2012 11:53 AM, Sebastian Huber wrote:

On 06/05/2012 05:19 PM, Sebastian Huber wrote:

Hi,

what is the blocking point for the integration of these patches?



Ping.



GCC uses a *-*-*eabi patterns to destinguish EABI toolchains from other ABIs.
Your endeavour contradicts the spirit behind this.

That said, I am strongly against applying this patch, because it will break
this strict separation and will introduce a need to special case the arm-rtems
target.


I don't continue to argue with you about this topic since everything is said. 
You have the minority option here and it was decided by the rest of the RTEMS 
community to bring the ARM RTEMS tool chain back to the RTEMS structure and 
this is $ARCH-rtems$VERSION for the default target.


We also don't introduce a special case for arm-rtems.  This special case is 
already there for arm-symbianelf.


--
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax : +49 89 18 90 80 79-9
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


Re: arm-rtems switch default target to EABI

2012-06-12 Thread Ralf Corsepius

On 06/12/2012 11:53 AM, Sebastian Huber wrote:

On 06/05/2012 05:19 PM, Sebastian Huber wrote:

Hi,

what is the blocking point for the integration of these patches?



Ping.



GCC uses a *-*-*eabi patterns to destinguish EABI toolchains from other 
ABIs. Your endeavour contradicts the spirit behind this.


That said, I am strongly against applying this patch, because it will 
break this strict separation and will introduce a need to special case 
the arm-rtems target.


Ralf



Re: [RFC PR48941 / 51980] Rewrite arm_neon.h to use __builtin_shuffle

2012-06-12 Thread Ramana Radhakrishnan
On 12 June 2012 10:22, Julian Brown  wrote:
> On Mon, 11 Jun 2012 16:46:27 +0100
> Ramana Radhakrishnan  wrote:
>
>> Hi,
>>
>> I don't like the ML bits of the patch as it stands today and before
>> committing I would like to clean up the ML bits quite a bit further
>> especially in areas where I've put FIXMEs [...]
>
> I had a go at this, see attached. Untested. Note there are some
> semantic differences in output:
>
>  vzipq_p8 (poly8x16_t __a, poly8x16_t __b)
>  {
>   poly8x16x2_t __rv;
> -  uint8x16_t __mask1 = {0, 2};
> -  uint8x16_t __mask2 = {1, 3};
> -  __rv.val[0] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask1);
> -  __rv.val[1] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask2);
> +  uint8x16_t __mask1 = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6,
>  22, 7, 23 };
> +  uint8x16_t __mask2 = { 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29,
>  14, 30, 15, 31 };
> +  __rv.val[0] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask1);
> +  __rv.val[1] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask2);
>   return __rv;
>  }
>
> I wasn't quite sure which version was correct -- but your version
> doesn't seem to have enough elements for these cases?
>

That's definitely a wart in my implementation. Yes and I wouldn't have
spotted that until I'd fixed up the O0 regressions to see it in the
test run. Thanks for looking over my feeble attempts at ML - I'll have
a look at this post lunch.

regards,
Ramana

> HTH,
>
> Julian


[Ada] Avoid memory exhaustion when using gnatmake -m

2012-06-12 Thread Arnaud Charlet
In large systems, gnatmake may crash when invoked with -m (minimal
recompilation) when there are many sources that have been modified
but have kept the same checksum.
This patch fixes this.
There is no simple test.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Vincent Celier  

* ali-util.adb (Time_Stamp_Mismatch): In minimal recompilation
mode, use Stringt Mark and Release to avoid growing the Stringt
internal tables uselessly.
* stringt.adb (Strings_Last): New global variable
(String_Chars_Last): New global variable.
(Mark, Release): New procedures.
* stringt.ads (Mark, Release) New procedures.

Index: ali-util.adb
===
--- ali-util.adb(revision 188428)
+++ ali-util.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -32,6 +32,7 @@
 with Scng;
 with Sinput.C;
 with Snames;  use Snames;
+with Stringt;
 with Styleg;
 
 package body ALI.Util is
@@ -476,6 +477,8 @@
 --  ??? It is probably worth updating the ALI file with a new
 --  field to avoid recomputing it each time.
 
+Stringt.Mark;
+
 if Checksums_Match
  (Get_File_Checksum (Sdep.Table (D).Sfile),
   Source.Table (Src).Checksum)
@@ -491,6 +494,8 @@
Sdep.Table (D).Stamp := Source.Table (Src).Stamp;
 end if;
 
+Stringt.Release;
+
  end if;
 
  if (not Read_Only) or else Source.Table (Src).Source_Found then
Index: stringt.adb
===
--- stringt.adb (revision 188428)
+++ stringt.adb (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2009, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -70,6 +70,12 @@
--  when Start_String is called with a parameter that is the last string
--  currently allocated in the table.
 
+   Strings_Last : String_Id := First_String_Id;
+   String_Chars_Last : Int := 0;
+   --  Strings_Last and String_Chars_Last are used by procedure Mark and
+   --  Release to get a snapshot of the tables and to restore them to their
+   --  previous situation.
+
---
-- Add_String_To_Name_Buffer --
---
@@ -129,6 +135,26 @@
   Strings.Release;
end Lock;
 
+   --
+   -- Mark --
+   --
+
+   procedure Mark is
+   begin
+  Strings_Last := Strings.Last;
+  String_Chars_Last := String_Chars.Last;
+   end Mark;
+
+   -
+   -- Release --
+   -
+
+   procedure Release is
+   begin
+  Strings.Set_Last (Strings_Last);
+  String_Chars.Set_Last (String_Chars_Last);
+   end Release;
+
--
-- Start_String --
--
Index: stringt.ads
===
--- stringt.ads (revision 188428)
+++ stringt.ads (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 1992-2009, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -62,6 +62,14 @@
procedure Unlock;
--  Unlock internal tables, in case back end needs to modify them
 
+   procedure Mark;
+   --  Take a snapshot of the inte

[Ada] Cleanup front end code (introduce N_Subprogram_Call)

2012-06-12 Thread Arnaud Charlet
This patch is a minor cleanup in the front end. It
introduces a new subtype N_Subprogram_Call which includes
N_Function_Call and N_Procedure_Call_Statement, and then
uses this new subtype in many place in the front end
where it simplifies the code. Since there is no change
in behavior, no test is required.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Robert Dewar  

* sem_dist.adb, exp_ch7.adb, sem_type.adb, exp_attr.adb,
sinfo.ads, sem_ch7.adb, exp_alfa.adb, sem_scil.adb, sem_ch12.adb,
sem_util.adb, sem_res.adb, sem_attr.adb, sem_elab.adb, exp_ch6.adb,
sem_ch4.adb, sem_warn.adb, scil_ll.adb, exp_cg.adb: Minor code
reorganization.

Index: sem_dist.adb
===
--- sem_dist.adb(revision 188428)
+++ sem_dist.adb(working copy)
@@ -242,7 +242,7 @@
   Par : Node_Id;
 
begin
-  if Nkind_In (N, N_Function_Call, N_Procedure_Call_Statement)
+  if Nkind (N) in N_Subprogram_Call
 and then Nkind (Name (N)) in N_Has_Entity
 and then Is_Remote_Call_Interface (Entity (Name (N)))
 and then Has_All_Calls_Remote (Scope (Entity (Name (N
Index: exp_ch7.adb
===
--- exp_ch7.adb (revision 188444)
+++ exp_ch7.adb (working copy)
@@ -4337,32 +4337,14 @@
  --
 
  function Requires_Hooking return Boolean is
-function Is_Subprogram_Call (Nod : Node_Id) return Boolean;
---  Determine whether a particular node is a procedure of function
---  call.
-
-
--- Is_Subprogram_Call --
-
-
-function Is_Subprogram_Call (Nod : Node_Id) return Boolean is
-begin
-   return
- Nkind_In (Nod, N_Function_Call, N_Procedure_Call_Statement);
-end Is_Subprogram_Call;
-
- --  Start of processing for Requires_Hooking
-
  begin
 --  The context is either a procedure or function call or an object
---  declaration initialized by such a call. In all these cases, the
---  calls are assumed to raise an exception.
+--  declaration initialized by a function call. In all these cases,
+--  the calls might raise an exception.
 
-return
-  Is_Subprogram_Call (N)
-or else
-  (Nkind (N) = N_Object_Declaration
- and then Is_Subprogram_Call (Expression (N)));
+return Nkind (N) in N_Subprogram_Call
+   or else (Nkind (N) = N_Object_Declaration
+ and then Nkind (Expression (N)) = N_Function_Call);
  end Requires_Hooking;
 
  --  Local variables
Index: sem_type.adb
===
--- sem_type.adb(revision 188428)
+++ sem_type.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -481,7 +481,7 @@
  then
 Add_Entry (Entity (N), Etype (N));
 
- elsif Nkind_In (N, N_Function_Call, N_Procedure_Call_Statement)
+ elsif Nkind (N) in N_Subprogram_Call
and then Is_Entity_Name (Name (N))
  then
 Add_Entry (Entity (Name (N)), Etype (N));
@@ -1467,9 +1467,7 @@
return It1;
 
 else
-   if Nkind (N) = N_Function_Call
- or else Nkind (N) = N_Procedure_Call_Statement
-   then
+   if Nkind (N) in N_Subprogram_Call then
   Act1 := First_Actual (N);
 
   if Present (Act1) then
@@ -1867,8 +1865,7 @@
  elsif In_Instance
and then not In_Generic_Actual (N)
  then
-if Nkind (N) = N_Function_Call
-  or else Nkind (N) = N_Procedure_Call_Statement
+if Nkind (N) in N_Subprogram_Call
   or else
 (Nkind (N) in N_Has_Entity
   and then
Index: exp_attr.adb
===
--- exp_attr.adb(revision 188428)
+++ exp_attr.adb(working copy)
@@ -421,7 +421,7 @@
 Par := Parent (Par);
  end if;
 
- 

Re: [RFC PR48941 / 51980] Rewrite arm_neon.h to use __builtin_shuffle

2012-06-12 Thread Ramana Radhakrishnan
On 12 June 2012 11:46, Richard Guenther  wrote:
> On Tue, Jun 12, 2012 at 11:22 AM, Julian Brown  
> wrote:
>> On Mon, 11 Jun 2012 16:46:27 +0100
>> Ramana Radhakrishnan  wrote:
>>
>>> Hi,
>>>
>>> I don't like the ML bits of the patch as it stands today and before
>>> committing I would like to clean up the ML bits quite a bit further
>>> especially in areas where I've put FIXMEs [...]
>>
>> I had a go at this, see attached. Untested. Note there are some
>> semantic differences in output:
>>
>>  vzipq_p8 (poly8x16_t __a, poly8x16_t __b)
>>  {
>>   poly8x16x2_t __rv;
>> -  uint8x16_t __mask1 = {0, 2};
>> -  uint8x16_t __mask2 = {1, 3};
>> -  __rv.val[0] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask1);
>> -  __rv.val[1] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask2);
>> +  uint8x16_t __mask1 = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6,
>>  22, 7, 23 };
>> +  uint8x16_t __mask2 = { 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29,
>>  14, 30, 15, 31 };
>> +  __rv.val[0] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask1);
>> +  __rv.val[1] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask2);
>
> You should get better code at -O0 when not using a temporary __mask1/__mask2
> but directly pasting the constant in the builtin call.

I tried that yesterday but it didn't seem to help - from a quick peek
at the dumps it looks like we could do with some limited const prop
just for the vec_perm expand cases.

  D.14032 = { 0, 8, 1, 9, 2, 10, 3, 11 };
  D.14044 = VEC_PERM_EXPR <__a, __b, D.14032>;

That's what I see from the dumps and from a quick skim of the sources
- my suspicion is that lower_vec_perm in tree-vect-generic.c is where
we could try doing a limited constant propagation in this case. ? Is
that where one should attempt to fix this ?

Consider the following testcase at O0 rewritten with just
__builtin_shuffle so that you can see it on other platforms as well
that have vec_perm_const defined for doing the interleave style
operations. and look at what you get for O1. On arm-linux-gnueabi with
-mfpu=neon -mfloat-abi=softfp -mcpu=cortex-a9 at O0 you'd see it use
the generic permute operations and at O1 you'd see a vzip.32
instruction


typedef int v4si __attribute__ ((vector_size (16)));

v4si vs (v4si a, v4si b)
{
  return __builtin_shuffle (a, b, (v4si) {0, 4, 1, 5});
}


regards
Ramana

>
>>   return __rv;
>>  }
>>
>> I wasn't quite sure which version was correct -- but your version
>> doesn't seem to have enough elements for these cases?
>>
>> HTH,
>>
>> Julian


[Ada] Object declarations and finalization of transient variables

2012-06-12 Thread Arnaud Charlet
This patch adds code to recognize a scenario where an object is initialized by
a sequence of nested function calls where one of them returns a controlled
result. This in turn triggers the mechanism which exports such transient
objects to the enclosing finalizer on the assumption that one of the calls may
raise an exception.


-- Source --


-- types.ads

with Ada.Finalization; use Ada.Finalization;

package Types is
   type Ctrl is new Controlled with null record;
   procedure Finalize (Obj : in out Ctrl);
end Types;

-- types.adb

with Ada.Text_IO; use Ada.Text_IO;

package body Types is
   procedure Finalize (Obj : in out Ctrl) is
   begin
  Put_Line ("Finalize");
   end Finalize;
end Types;

-- main.adb

with Ada.Text_IO; use Ada.Text_IO;
with Types;   use Types;

procedure Main is
   function Return_Self (Obj : Ctrl) return Ctrl is
   begin
  return Obj;
   end Return_Self;

   function Blow_Up (Obj : Ctrl) return Boolean is
   begin
  raise Constraint_Error;
  return True;
   end Blow_Up;

   Obj : Ctrl;
begin
   Put_Line ("Main");
   declare
  Flag : constant Boolean := Blow_Up (Return_Self (Obj));
   begin
  null;
   end;
   Put_Line ("End");
end Main;


-- Compilation and output --


$ gnatmake -q -gnat05 main.adb
$ ./main
$ Main
$ Finalize
$ Finalize
$
$ raised CONSTRAINT_ERROR : main.adb:12 explicit raise

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Hristian Kirtchev  

* exp_ch7.adb (Process_Transient_Objects): Renamed constant
Requires_Hooking to Must_Hook and replace all occurrences of the name.
(Requires_Hooking): New routine. Detect all contexts that require
transient variable export to the outer finalizer due to a potential
exception.

Index: exp_ch7.adb
===
--- exp_ch7.adb (revision 188438)
+++ exp_ch7.adb (working copy)
@@ -4327,10 +4327,47 @@
  Last_Object  : Node_Id;
  Related_Node : Node_Id)
   is
- Requires_Hooking : constant Boolean :=
-  Nkind_In (N, N_Function_Call,
-   N_Procedure_Call_Statement);
+ function Requires_Hooking return Boolean;
+ --  Determine whether the context requires transient variable export
+ --  to the outer finalizer. This scenario arises when the context may
+ --  raise an exception.
 
+ --
+ -- Requires_Hooking --
+ --
+
+ function Requires_Hooking return Boolean is
+function Is_Subprogram_Call (Nod : Node_Id) return Boolean;
+--  Determine whether a particular node is a procedure of function
+--  call.
+
+
+-- Is_Subprogram_Call --
+
+
+function Is_Subprogram_Call (Nod : Node_Id) return Boolean is
+begin
+   return
+ Nkind_In (Nod, N_Function_Call, N_Procedure_Call_Statement);
+end Is_Subprogram_Call;
+
+ --  Start of processing for Requires_Hooking
+
+ begin
+--  The context is either a procedure or function call or an object
+--  declaration initialized by such a call. In all these cases, the
+--  calls are assumed to raise an exception.
+
+return
+  Is_Subprogram_Call (N)
+or else
+  (Nkind (N) = N_Object_Declaration
+ and then Is_Subprogram_Call (Expression (N)));
+ end Requires_Hooking;
+
+ --  Local variables
+
+ Must_Hook : constant Boolean := Requires_Hooking;
  Built : Boolean := False;
  Desig_Typ : Entity_Id;
  Fin_Block : Node_Id;
@@ -4395,7 +4432,7 @@
--  enclosing sequence of statements where their corresponding
--  "hooks" are picked up by the finalization machinery.
 
-   if Requires_Hooking then
+   if Must_Hook then
   declare
  Expr   : Node_Id;
  Ptr_Id : Entity_Id;
@@ -4470,7 +4507,7 @@
--  Generate:
--Temp := null;
 
-   if Requires_Hooking then
+   if Must_Hook then
   Append_To (Stmts,
 Make_Assignment_Statement (Loc,
   Name   => New_Reference_To (Temp_Id, Loc),


Re: [PATCH] Correct cost model for strided loads

2012-06-12 Thread Richard Guenther
On Mon, Jun 11, 2012 at 8:37 PM, Richard Guenther
 wrote:
> On Mon, Jun 11, 2012 at 5:01 PM, William J. Schmidt
>  wrote:
>>
>>
>> On Mon, 2012-06-11 at 16:10 +0200, Richard Guenther wrote:
>>> On Mon, 11 Jun 2012, William J. Schmidt wrote:
>>>
>>> >
>>> >
>>> > On Mon, 2012-06-11 at 11:15 +0200, Richard Guenther wrote:
>>> > > On Sun, Jun 10, 2012 at 5:58 PM, William J. Schmidt
>>> > >  wrote:
>>> > > > The fix for PR53331 caused a degradation to 187.facerec on
>>> > > > powerpc64-unknown-linux-gnu.  The following simple patch reverses the
>>> > > > degradation without otherwise affecting SPEC cpu2000 or cpu2006.
>>> > > > Bootstrapped and regtested on that platform with no new regressions.  
>>> > > > Ok
>>> > > > for trunk?
>>> > >
>>> > > Well, would the real cost not be subparts * scalar_to_vec plus
>>> > > subparts * vec_perm?
>>> > > At least vec_perm isn't the cost for building up a vector from N scalar 
>>> > > elements
>>> > > either (it might be close enough if subparts == 2).  What's the case
>>> > > with facerec
>>> > > here?  Does it have subparts == 2?
>>> >
>>> > In this case, subparts == 4 (32-bit floats, 128-bit vec reg).  On
>>> > PowerPC, this requires two merge instructions and a permute instruction
>>> > to get the four 32-bit quantities into the right place in a 128-bit
>>> > register.  Currently this is modeled as a vec_perm in other parts of the
>>> > vectorizer per Ira's earlier patches, so I naively changed this to do
>>> > the same thing.
>>>
>>> I see.
>>>
>>> > The types of vectorizer instructions aren't documented, and I can't
>>> > infer much from the i386.c cost model, so I need a little education.
>>> > What semantics are represented by scalar_to_vec?
>>>
>>> It's a vector splat, thus x -> { x, x, x, ... }.  You can create
>>> { x, y, z, ... } by N such splats plus N - 1 permutes (if a permute,
>>> as VEC_PERM_EXPR, takes two input vectors).  That's by far not
>>> the most efficient way to build up such a vector of course (with AVX
>>> you could do one splat plus N - 1 inserts for example).  The cost
>>> is of course dependent on the number of vector elements, so a
>>> simple new enum vect_cost_for_stmt kind does not cover it but
>>> the target would have to look at the vector type passed and do
>>> some reasonable guess.
>>
>> Ah, splat!  Yes, that's lingo I understand.  I see the intent now.
>>
>>>
>>> > On PowerPC, we have this mapping of the floating-point registers and
>>> > vector float registers where they overlap (the low-order half of each of
>>> > the first 32 vector float regs corresponds to a scalar float reg).  So
>>> > in this case we have four scalar loads that place things in the bottom
>>> > half of four vector registers, two vector merge instructions that
>>> > collapse the four registers into two vector registers, and a vector
>>> > permute that gets things in the right order.(*)  I wonder if what we
>>> > refer to as a merge instruction is similar to scalar_to_vec.
>>>
>>> Looks similar to x86 SSE then.
>>>
>>> > If so, then maybe we need something like
>>> >
>>> >      subparts = TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info));
>>> >      inside_cost += vect_get_stmt_cost (scalar_load) * ncopies * subparts;
>>> >      inside_cost += ncopies * vect_get_stmt_cost (scalar_to_vec) * 
>>> > subparts / 2;
>>> >      inside_cost += ncopies * vect_get_stmt_cost (vec_perm);
>>> >
>>> > But then we'd have to change how vec_perm is modeled elsewhere for
>>> > PowerPC based on Ira's earlier patches.  As I said, it's difficult for
>>> > me to figure out all the intent of cost model decisions that have been
>>> > made in the past, using current documentation.
>>>
>>> Heh, usually the intent was to make the changes simple, not to compute
>>> a proper cost.
>>>
>>> I think we simply need a new scalars_to_vec cost kind.
>>
>> That works.  Maybe vec_construct gets the point across a little better?
>> I think we need to use the full builtin_vectorization_cost interface
>> instead of vect_get_stmt_cost here, so the targets can parameterize on
>> type.  Then we can just do one cost calculation for vec_construct that
>> covers the full costs of getting the vector in order after the loads.
>
> Yes, vec_construct sounds good to me.
>
>>>
>>> > > I really wanted to pessimize this case
>>> > > for say AVX and char elements, thus building up a vector from 32 
>>> > > scalars which
>>> > > certainly does not cost a mere vec_perm.  So, maybe special-case the
>>> > > subparts == 2 case and assume vec_perm would match the cost only in that
>>> > > case.
>>> >
>>> > (I'm a little confused by this as what you have at the moment is a
>>> > single scalar_to_vec per copy, which has a cost of 1 on most i386
>>> > targets (occasionally 2).  The subparts multiplier is only applied to
>>> > the loads.  So changing this to vec_perm seemed to be a no-op for i386.)
>>>
>>> Oh, I somehow read the patch as you were removing the multiplication
>>> by TYPE_VECTOR_SUBPARTS.  But yes, the cost 

[wwwdocs,4.6,committed]: Note on avr's progmem attribute, fix sparc

2012-06-12 Thread Georg-Johann Lay
Applied the following changes:

- Note on avr's progmem attribute.
- Fix -mfix-at697f which is a Sparc option.

http://gcc.gnu.org/gcc-4.6/changes.html

Johann

Index: htdocs/gcc-4.6/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.6/changes.html,v
retrieving revision 1.140
diff -u -p -r1.140 changes.html
--- htdocs/gcc-4.6/changes.html 24 Mar 2012 22:04:17 -  1.140
+++ htdocs/gcc-4.6/changes.html 12 Jun 2012 10:37:21 -
@@ -792,6 +792,13 @@
   default.
   

+
+AVR
+  
+Variables with the progmem attribute to locate data
+  in flash memory must be qualified as const.
+  
+
 IA-32/x86-64
   
 
@@ -967,10 +974,6 @@
  callee for functions taking parameters with sub-word size in 32-bit
  mode, since this is redundant with the specification of the ABI.
  GCC has never done so in 64-bit mode since this is also redundant.
-  
-
-AVR
-  
 The command line option -mfix-at697f has been added to
 enable the documented workaround for the single erratum of the Atmel
 AT697F processor.


Re: [RFC PR48941 / 51980] Rewrite arm_neon.h to use __builtin_shuffle

2012-06-12 Thread Richard Guenther
On Tue, Jun 12, 2012 at 11:22 AM, Julian Brown  wrote:
> On Mon, 11 Jun 2012 16:46:27 +0100
> Ramana Radhakrishnan  wrote:
>
>> Hi,
>>
>> I don't like the ML bits of the patch as it stands today and before
>> committing I would like to clean up the ML bits quite a bit further
>> especially in areas where I've put FIXMEs [...]
>
> I had a go at this, see attached. Untested. Note there are some
> semantic differences in output:
>
>  vzipq_p8 (poly8x16_t __a, poly8x16_t __b)
>  {
>   poly8x16x2_t __rv;
> -  uint8x16_t __mask1 = {0, 2};
> -  uint8x16_t __mask2 = {1, 3};
> -  __rv.val[0] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask1);
> -  __rv.val[1] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask2);
> +  uint8x16_t __mask1 = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6,
>  22, 7, 23 };
> +  uint8x16_t __mask2 = { 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29,
>  14, 30, 15, 31 };
> +  __rv.val[0] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask1);
> +  __rv.val[1] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask2);

You should get better code at -O0 when not using a temporary __mask1/__mask2
but directly pasting the constant in the builtin call.

>   return __rv;
>  }
>
> I wasn't quite sure which version was correct -- but your version
> doesn't seem to have enough elements for these cases?
>
> HTH,
>
> Julian


[Ada] Ada 2012: AI05-0296, formal incomplete types.

2012-06-12 Thread Arnaud Charlet
This patch implements AI05-0296, concerning freeze rules in the presence of
formal incomplete types: a formal abstract subprogram cannot have an incomplete
controlling type, and the profile of the actual subprogram is not frozen if it
includes a incomplete untagged type.

Compiling abstr.ads in Ada 2012 mode must yield:

---
   abstr.ads:4:07: controlling type of abstract formal subprogram cannot be
   incomplete type
   abstr.ads:19:03: type "T2" must be frozen before this point
   abstr.ads:19:03: instantiation abandoned
   abstr.ads:32:03: warning: no more representation items for type "Arr" defined
   at line 31
   abstr.ads:34:03: representation item appears too late
---
package Abstr is
   generic
  type T is tagged;
  with procedure Move (Obj : T) is abstract;   --  ERROR
   package Gen is
   private
   end;

   type T2 is tagged;

   generic
  with procedure Move (Obj : T2) ;
   package Gen2 is
   private
   end;

  procedure Shift (Obj : T2);

  package Inst is new Gen2 (Shift);  --  ERROR

  type T2 is tagged record
 Val : integer := 0;
  end record;

  generic
 type T is private;
  package Gen3 is
  private
  end;

  type Arr is array (1..10) of Boolean;
  package Inst2 is new Gen3 (Arr);

  pragma Pack (Arr);  --  ERROR, too late
end Abstr;

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Ed Schonberg  

* sem_ch3.adb (Analyze_Subtype_Declaration): if an incomplete
type is tagged, so is a subtype of it.
* sem_ch12.adb (Validate_Actual_Subprogram): implement AI05-0296,
concerning freeze rules in the presence of formal incomplete
types: a formal abstract subprogram cannot have an incomplete
controlling type, and the profile of the actual subprogram does
not freeze if it includes an incomplete untagged type.

Index: sem_ch12.adb
===
--- sem_ch12.adb(revision 188441)
+++ sem_ch12.adb(working copy)
@@ -2664,6 +2664,14 @@
Error_Msg_N
  ("abstract formal subprogram must have a controlling type",
   N);
+
+elsif Ada_Version >= Ada_2012
+  and then Is_Incomplete_Type (Ctrl_Type)
+then
+   Error_Msg_NE
+ ("controlling type of abstract formal subprogram cannot " &
+ "be incomplete type", N, Ctrl_Type);
+
 else
Check_Controlling_Formals (Ctrl_Type, Nam);
 end if;
@@ -9411,6 +9419,59 @@
  end;
   end if;
 
+  --  In Ada 2012, enforce the (RM 13.14(10.2/3)) freezing rule concerning
+  --  formal incomplete types: a callable entity freezes its profile,
+  --  unless it has an incomplete untagged formal.
+
+  if Ada_Version >= Ada_2012 then
+ declare
+F : Entity_Id;
+Has_Untagged_Inc : Boolean;
+
+ begin
+F := First_Formal (Analyzed_S);
+Has_Untagged_Inc := False;
+while Present (F) loop
+   if Ekind (Etype (F)) = E_Incomplete_Type
+ and then not Is_Tagged_Type (Etype (F))
+   then
+  Has_Untagged_Inc := True;
+  exit;
+   end if;
+
+   F := Next_Formal (F);
+end loop;
+
+if Ekind (Analyzed_S) = E_Function
+  and then Ekind (Etype (Analyzed_S)) = E_Incomplete_Type
+  and then not Is_Tagged_Type (Etype (F))
+then
+   Has_Untagged_Inc := True;
+end if;
+
+if Is_Entity_Name (Actual)
+  and then not Has_Untagged_Inc
+then
+   F := First_Formal (Entity (Actual));
+   while Present (F) loop
+  Freeze_Before (Instantiation_Node, Etype (F));
+
+  if Is_Incomplete_Or_Private_Type (Etype (F))
+and then No (Full_View (Etype (F)))
+and then not Is_Generic_Type (Etype (F))
+  then
+ Error_Msg_NE
+   ("type& must be frozen before this point",
+  Instantiation_Node, Etype (F));
+ Abandon_Instantiation (Instantiation_Node);
+  end if;
+
+  F := Next_Formal (F);
+   end loop;
+end if;
+ end;
+  end if;
+
   return Decl_Node;
end Instantiate_Formal_Subprogram;
 
Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 188428)
+++ sem_ch3.adb (working copy)
@@ -4340,12 +4340,16 @@
 
 when E_Incomplete_Type =>
if Ada_Version >= Ada_2005 then
-  Set_Ekind (Id, E_Incomplete_Subtype);
 
-  --  Ada 2005 (AI-412): Decorate an incomplete subtype
-  --  of an incomplete type visible through

[RFA PATCH, ia64]: Put soft-FP exception handler out-of-line

2012-06-12 Thread Uros Bizjak
Hello!

Similar to x86, this patch puts soft-FP exception handler out-of-line.
The patch also cleans asm constraints a bit (introduces "+"), but has
no other functional changes.

2012-06-12  Uros Bizjak  

* config/ia64/sfp-machine.h (__sfp_handle_exceptions): New
function declaration.
(FP_EX_MASK): New.
(FP_HANDLE_EXCEPTIONS): Use __sfp_handle_exceptions.
* config/ia64/sfp-exceptions.c: New.
* config/ia64/t-softfp (LIB2ADD): Add sfp-exceptions.c.

The patch is only compile tested, needs someone to regression test it ...

Uros.
Index: config/ia64/sfp-exceptions.c
===
--- config/ia64/sfp-exceptions.c(revision 0)
+++ config/ia64/sfp-exceptions.c(revision 0)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 Free Software Foundation, Inc.
+ *
+ * This file 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.
+ * 
+ * This file 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.
+ * 
+ * Under Section 7 of GPL version 3, you are granted additional
+ * permissions described in the GCC Runtime Library Exception, version
+ * 3.1, as published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License and
+ * a copy of the GCC Runtime Library Exception along with this program;
+ * see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+ * .
+ */
+
+#include "sfp-machine.h"
+
+void
+__sfp_handle_exceptions (int _fex)
+{
+  double d;
+
+  if (_fex & FP_EX_INVALID)
+{
+  asm volatile ("frcpa.s0 %0,p1=f0,f0" : "=f" (d) : : "p1");
+}
+  if (_fex & FP_EX_DIVZERO)
+{
+  asm volatile ("frcpa.s0 %0,p1=f1,f0" : "=f" (d) : : "p1");
+}
+  if (_fex & FP_EX_OVERFLOW)
+{
+  d = __DBL_MAX__;
+  asm volatile ("fadd.d.s0 %0=%0,%0" : "+f" (d));
+}
+  if (_fex & FP_EX_UNDERFLOW)
+{
+  d = __DBL_MIN__;
+  asm volatile ("fnma.d.s0 %0=%0,%0,f0" : "+f" (d));
+}
+  if (_fex & FP_EX_INEXACT)
+{
+  d = __DBL_MAX__;
+  asm volatile ("fsub.d.s0 %0=%0,f1" : "+f" (d));
+}
+}
Index: config/ia64/t-softfp
===
--- config/ia64/t-softfp(revision 188431)
+++ config/ia64/t-softfp(working copy)
@@ -1,2 +1,4 @@
 # Provide fallbacks for __builtin_copysignq and __builtin_fabsq.
 LIB2ADD += $(srcdir)/config/ia64/tf-signs.c
+
+LIB2ADD += $(srcdir)/config/ia64/sfp-exceptions.c
Index: config/ia64/sfp-machine.h
===
--- config/ia64/sfp-machine.h   (revision 188431)
+++ config/ia64/sfp-machine.h   (working copy)
@@ -55,40 +55,16 @@
 #define FP_EX_UNDERFLOW0x10
 #define FP_EX_INEXACT  0x20
 
-#define FP_HANDLE_EXCEPTIONS   \
-  do { \
-double tmp, dummy; \
-if (_fex & FP_EX_INVALID)  \
-  {
\
-   tmp = 0.0;  \
-   __asm__ __volatile__ ("frcpa.s0 %0,p1=f0,f0"\
- : "=f" (tmp) : : "p1" );  \
-  }
\
-if (_fex & FP_EX_DIVZERO)  \
-  {
\
-   __asm__ __volatile__ ("frcpa.s0 %0,p1=f1,f0"\
- : "=f" (tmp) : : "p1" );  \
-  }
\
-if (_fex & FP_EX_OVERFLOW) \
-  {
\
-   dummy = __DBL_MAX__;\
-   __asm__ __volatile__ ("fadd.d.s0 %0=%1,%1"  \
- : "=f" (dummy) : "0" (dummy));\
-  }
\
-if (_fex & FP_EX_UNDERFLOW)
\
-  {
\
-   dummy = __DBL_MIN__;\
-   __asm__ __volatile__ ("fnma.d.s0 %0

[Ada] Delete symbolic link silently.

2012-06-12 Thread Arnaud Charlet
The following test must run without raising an exception on
systems supporting symbolic links:

with Ada.Directories; use Ada.Directories;
with Ada.Text_IO; use Ada.Text_IO;
procedure Delln is
   F1   : constant String := "libname.so";
   F2   : constant String := "libname.so.1";
   File : File_Type;
begin
   Delete_File (F1);
   Delete_File (F2);
end Delln;

 $ touch libname.so
 $ ln -s libname.so libname.so.1
 $ gnatmake -a delln

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Pascal Obry  

* a-direct.adb (Delete_File): Delete symbolic links silently
instead of raising the Name_Error exception when the symbolic
link is pointing to a non existent file.

Index: a-direct.adb
===
--- a-direct.adb(revision 188428)
+++ a-direct.adb(working copy)
@@ -31,20 +31,20 @@
 
 with Ada.Calendar;   use Ada.Calendar;
 with Ada.Calendar.Formatting;use Ada.Calendar.Formatting;
+with Ada.Characters.Handling;use Ada.Characters.Handling;
 with Ada.Directories.Validity;   use Ada.Directories.Validity;
+with Ada.Strings.Fixed;
 with Ada.Strings.Maps;   use Ada.Strings.Maps;
-with Ada.Strings.Fixed;
 with Ada.Strings.Unbounded;  use Ada.Strings.Unbounded;
 with Ada.Unchecked_Conversion;
 with Ada.Unchecked_Deallocation;
-with Ada.Characters.Handling;use Ada.Characters.Handling;
 
+with System;  use System;
 with System.CRTL; use System.CRTL;
+with System.File_IO;  use System.File_IO;
 with System.OS_Constants; use System.OS_Constants;
 with System.OS_Lib;   use System.OS_Lib;
 with System.Regexp;   use System.Regexp;
-with System.File_IO;  use System.File_IO;
-with System;  use System;
 
 package body Ada.Directories is
 
@@ -561,7 +561,9 @@
   if not Is_Valid_Path_Name (Name) then
  raise Name_Error with "invalid path name """ & Name & '"';
 
-  elsif not Is_Regular_File (Name) then
+  elsif not Is_Regular_File (Name)
+and then not Is_Symbolic_Link (Name)
+  then
  raise Name_Error with "file """ & Name & """ does not exist";
 
   else


[Ada] Add support for project file Install package.

2012-06-12 Thread Arnaud Charlet
This package will be used with the gprinstall tool.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Pascal Obry  

* prj-attr.adb: Add install package and corresponding attributes.
* snames.ads-tmpl (Name_Active): New constant.
(Name_Exec_Subdir): Likewise.
(Name_Install): Likewise.
(Name_Lib_Subdir): Likewise.
(Name_Project_Subdir): Likewise.
(Name_Sources_Subdir): Likewise.

Index: prj-attr.adb
===
--- prj-attr.adb(revision 188428)
+++ prj-attr.adb(working copy)
@@ -351,6 +351,16 @@
"SVvcs_log_check#" &
"SVdocumentation_dir#" &
 
+   --  package Install
+
+   "Pinstall#" &
+   "SVprefix#" &
+   "SVsources_subdir#" &
+   "SVexec_subdir#" &
+   "SVlib_subdir#" &
+   "SVproject_subdir#" &
+   "SVactive#" &
+
--  package Stack
 
"Pstack#" &
Index: snames.ads-tmpl
===
--- snames.ads-tmpl (revision 188428)
+++ snames.ads-tmpl (working copy)
@@ -1099,6 +1099,7 @@
 
--  The names with the -- GB annotation are only used in gprbuild.
 
+   Name_Active : constant Name_Id := N + $;
Name_Aggregate  : constant Name_Id := N + $;
Name_Archive_Builder: constant Name_Id := N + $;
Name_Archive_Builder_Append_Option  : constant Name_Id := N + $;
@@ -1130,6 +1131,7 @@
Name_Excluded_Source_Files  : constant Name_Id := N + $;
Name_Excluded_Source_List_File  : constant Name_Id := N + $;
Name_Exec_Dir   : constant Name_Id := N + $;
+   Name_Exec_Subdir: constant Name_Id := N + $;
Name_Executable : constant Name_Id := N + $;
Name_Executable_Suffix  : constant Name_Id := N + $;
Name_Extends: constant Name_Id := N + $;
@@ -1151,11 +1153,13 @@
Name_Include_Path   : constant Name_Id := N + $;
Name_Include_Path_File  : constant Name_Id := N + $;
Name_Inherit_Source_Path: constant Name_Id := N + $;
+   Name_Install: constant Name_Id := N + $;
Name_Languages  : constant Name_Id := N + $;
Name_Language_Kind  : constant Name_Id := N + $;
Name_Leading_Library_Options: constant Name_Id := N + $;
Name_Leading_Required_Switches  : constant Name_Id := N + $;
Name_Leading_Switches   : constant Name_Id := N + $;
+   Name_Lib_Subdir : constant Name_Id := N + $;
Name_Library: constant Name_Id := N + $;
Name_Library_Ali_Dir: constant Name_Id := N + $;
Name_Library_Auto_Init  : constant Name_Id := N + $;
@@ -1216,6 +1220,7 @@
Name_Project_Dir: constant Name_Id := N + $;
Name_Project_Files  : constant Name_Id := N + $;
Name_Project_Path   : constant Name_Id := N + $;
+   Name_Project_Subdir : constant Name_Id := N + $;
Name_Response_File_Format   : constant Name_Id := N + $;
Name_Response_File_Switches : constant Name_Id := N + $;
Name_Roots  : constant Name_Id := N + $; -- GB
@@ -1232,6 +1237,7 @@
Name_Source_File_Switches   : constant Name_Id := N + $;
Name_Source_Files   : constant Name_Id := N + $;
Name_Source_List_File   : constant Name_Id := N + $;
+   Name_Sources_Subdir : constant Name_Id := N + $;
Name_Spec   : constant Name_Id := N + $;
Name_Spec_Suffix: constant Name_Id := N + $;
Name_Specification  : constant Name_Id := N + $;


[Ada] Adding information of exported entities to ALI files

2012-06-12 Thread Arnaud Charlet
This patch extends the information generated by the compiler in
ALI files adding references to entities exported to foreign
languages. This information can be used by cross reference
tools and text editors (for example, GPS).

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Javier Miranda  

* sem_prag.adb (Process_Convention): Generate reference to entity
exported to foreign language. Needed for GPS navigation.
* xref_lib.adb (Parse_Identifier_Info): Parse exported entities.
* lib-xref (Output_References): Output exported entities.

Index: sem_prag.adb
===
--- sem_prag.adb(revision 188437)
+++ sem_prag.adb(working copy)
@@ -3655,10 +3655,21 @@
 Comp_Unit := Get_Source_Unit (E);
 Set_Convention_From_Pragma (E);
 
---  Treat a pragma Import as an implicit body, for GPS use
+--  Treat a pragma Import as an implicit body, and pragma import
+--  as implicit reference (for navigation in GPS).
 
 if Prag_Id = Pragma_Import then
Generate_Reference (E, Id, 'b');
+
+--  For exported entities we restrict the generation of references
+--  to entities exported to foreign languages since entities
+--  exported to Ada do not provide further information to GPS and
+--  add undesired references to the output of the gnatxref tool.
+
+elsif Prag_Id = Pragma_Export
+  and then Convention (E) /= Convention_Ada
+then
+   Generate_Reference (E, Id, 'i');
 end if;
 
 --  Loop through the homonyms of the pragma argument's entity
Index: xref_lib.adb
===
--- xref_lib.adb(revision 188428)
+++ xref_lib.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1998-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1998-2012, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -1105,9 +1105,10 @@
 
 --  Imported entities might special indication as to their external
 --  name:
---5U14*Foo2 5>20 6b22
+--5U14*Foo2 5>20 6b22   # Imported entity
+--5U14*Foo2 5>20 6i22   # Exported entity
 
-if R_Type = 'b'
+if (R_Type = 'b' or else R_Type = 'i')
   and then Ali (Ptr) = '<'
 then
while Ptr <= Ali'Last
Index: lib-xref.adb
===
--- lib-xref.adb(revision 188428)
+++ lib-xref.adb(working copy)
@@ -2441,11 +2441,13 @@
(Int (Get_Logical_Line_Number (XE.Key.Loc)));
  Write_Info_Char (XE.Key.Typ);
 
- if Is_Overloadable (XE.Key.Ent)
-   and then Is_Imported (XE.Key.Ent)
-   and then XE.Key.Typ = 'b'
- then
-Output_Import_Export_Info (XE.Key.Ent);
+ if Is_Overloadable (XE.Key.Ent) then
+if (Is_Imported (XE.Key.Ent) and then XE.Key.Typ = 'b')
+  or else
+   (Is_Exported (XE.Key.Ent) and then XE.Key.Typ = 'i')
+then
+   Output_Import_Export_Info (XE.Key.Ent);
+end if;
  end if;
 
  Write_Info_Nat (Int (Get_Column_Number (XE.Key.Loc)));


[Ada] Dereferences and inferable discriminants

2012-06-12 Thread Arnaud Charlet
An implicit dereference of an access to constrained unchecked union subtype
has inferable discriminants. This change fixes the Has_Inferable_Discriminants
function to take this case into account properly.
The following program must compile quietly and display "OK" when executed:

with Ada.Text_IO; use Ada.Text_IO;
procedure UU_Subtype_Eq is
   type UncU (Disc : Boolean := False) is record
  case Disc is
 when False =>
CC : Character;
 when True =>
BC : Boolean;
  end case;
   end record;
   pragma Unchecked_Union (UncU);

   subtype UncU1 is UncU (Disc => False);
   type UncA is access all UncU1;

   X1, Y1 : aliased UncU1;

   task Tester is
  entry Test (Y : UncU1; Res : out Boolean);
   end Tester;

   task body Tester is
   begin
  accept Test (Y : UncU1; Res : out Boolean) do
 declare
Local_Y : constant UncU1 := Y;
 begin
if X1 = Y then
   Res := True;
else
   Res := False;
end if;
 end;
  end Test;
   end Tester;

   Res : Boolean;
begin
   X1.CC := 'X';
   Y1.CC := 'Y';
   Tester.Test (Y1, Res);

   if Res then
  Put_Line ("KO");
   else
  Put_Line ("OK");
   end if;
end UU_Subtype_Eq;

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Thomas Quinot  

* exp_ch4.adb (Has_Inferable_Discriminants): Reorganize code to
treat implicit dereferences with a constrained unchecked union
nominal subtype as having inferable discriminants. 

Index: exp_ch4.adb
===
--- exp_ch4.adb (revision 188428)
+++ exp_ch4.adb (working copy)
@@ -10048,11 +10048,12 @@
   
 
   function Prefix_Is_Formal_Parameter (N : Node_Id) return Boolean is
- Sel_Comp : Node_Id := N;
+ Sel_Comp : Node_Id;
 
   begin
  --  Move to the left-most prefix by climbing up the tree
 
+ Sel_Comp := N;
  while Present (Parent (Sel_Comp))
and then Nkind (Parent (Sel_Comp)) = N_Selected_Component
  loop
@@ -10065,20 +10066,12 @@
--  Start of processing for Has_Inferable_Discriminants
 
begin
-  --  For identifiers and indexed components, it is sufficient to have a
-  --  constrained Unchecked_Union nominal subtype.
-
-  if Nkind_In (N, N_Identifier, N_Indexed_Component) then
- return Is_Unchecked_Union (Base_Type (Etype (N)))
-  and then
-Is_Constrained (Etype (N));
-
   --  For selected components, the subtype of the selector must be a
   --  constrained Unchecked_Union. If the component is subject to a
   --  per-object constraint, then the enclosing object must have inferable
   --  discriminants.
 
-  elsif Nkind (N) = N_Selected_Component then
+  if Nkind (N) = N_Selected_Component then
  if Has_Per_Object_Constraint (Entity (Selector_Name (N))) then
 
 --  A small hack. If we have a per-object constrained selected
@@ -10087,19 +10080,20 @@
 
 if Prefix_Is_Formal_Parameter (N) then
return True;
-end if;
 
 --  Otherwise, check the enclosing object and the selector
 
-return Has_Inferable_Discriminants (Prefix (N))
- and then
-   Has_Inferable_Discriminants (Selector_Name (N));
- end if;
+else
+   return Has_Inferable_Discriminants (Prefix (N))
+ and then Has_Inferable_Discriminants (Selector_Name (N));
+end if;
 
  --  The call to Has_Inferable_Discriminants will determine whether
  --  the selector has a constrained Unchecked_Union nominal type.
 
- return Has_Inferable_Discriminants (Selector_Name (N));
+ else
+return Has_Inferable_Discriminants (Selector_Name (N));
+ end if;
 
   --  A qualified expression has inferable discriminants if its subtype
   --  mark is a constrained Unchecked_Union subtype.
@@ -10107,9 +10101,14 @@
   elsif Nkind (N) = N_Qualified_Expression then
  return Is_Unchecked_Union (Etype (Subtype_Mark (N)))
and then Is_Constrained (Etype (Subtype_Mark (N)));
-  end if;
 
-  return False;
+  --  For all other names, it is sufficient to have a constrained
+  --  Unchecked_Union nominal subtype.
+
+  else
+ return Is_Unchecked_Union (Base_Type (Etype (N)))
+   and then Is_Constrained (Etype (N));
+  end if;
end Has_Inferable_Discriminants;
 
---


[Ada] Handling of (illegal) null record unchecked union

2012-06-12 Thread Arnaud Charlet
A "null record" type does not have a variant part, so it is not a legal
candidate for pragma Unchecked_Union. This change fixes the circuitry
that enforces this rule so that it correctly rejects such illegal code
instead of crashing the compiler.

The following compilation must be rejected with the indicated error message:
$ gcc -c uu_crash_null.ads
uu_crash_null.ads:2:43: Unchecked_Union must have variant part

package UU_Crash_Null is
   type UncU (Disc : Boolean := False) is null record;
   pragma Unchecked_Union (UncU);
end UU_Crash_Null;

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Thomas Quinot  

* sem_prag.adb (Analyze_Pragma, case Unchecked_Union): Do
not crash on illegal unchecked union that is a null record.

Index: sem_prag.adb
===
--- sem_prag.adb(revision 188436)
+++ sem_prag.adb(working copy)
@@ -14186,18 +14186,23 @@
Tdef  := Type_Definition (Declaration_Node (Typ));
Clist := Component_List (Tdef);
 
+   --  Check presence of component list and variant part
+
+   if No (Clist) or else No (Variant_Part (Clist)) then
+  Error_Msg_N
+("Unchecked_Union must have variant part", Tdef);
+  return;
+   end if;
+
+   --  Check components
+
Comp := First (Component_Items (Clist));
while Present (Comp) loop
   Check_Component (Comp, Typ);
   Next (Comp);
end loop;
 
-   if No (Clist) or else No (Variant_Part (Clist)) then
-  Error_Msg_N
-("Unchecked_Union must have variant part",
- Tdef);
-  return;
-   end if;
+   --  Check variant part
 
Vpart := Variant_Part (Clist);
 


[C++ PATCH] Disable -Wuninitialized warnings on NSDMI initialized fields (PR c++/53594)

2012-06-12 Thread Jakub Jelinek
Hi!

As stated in the PR, the -Wuninitialized warnings are bogus if
fields have NSDMI, as they are actually initialized then.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
What about 4.7.2?

2012-06-11  Jakub Jelinek  

PR c++/53594
* class.c (check_bases_and_members): Avoid -Wuninitialized
diagnostics for non-static const members or references if they
use NSDMI.

* g++.dg/cpp0x/nsdmi7.C: New test.

--- gcc/cp/class.c.jj   2012-06-07 08:27:35.0 +0200
+++ gcc/cp/class.c  2012-06-11 10:36:39.050739846 +0200
@@ -5122,7 +5122,8 @@ check_bases_and_members (tree t)
{
  tree type;
 
- if (TREE_CODE (field) != FIELD_DECL)
+ if (TREE_CODE (field) != FIELD_DECL
+ || DECL_INITIAL (field) != NULL_TREE)
continue;
 
  type = TREE_TYPE (field);
--- gcc/testsuite/g++.dg/cpp0x/nsdmi7.C.jj  2012-06-11 10:44:35.723568438 
+0200
+++ gcc/testsuite/g++.dg/cpp0x/nsdmi7.C 2012-06-11 10:50:16.0 +0200
@@ -0,0 +1,17 @@
+// PR c++/53594
+// { dg-do compile }
+// { dg-options "-std=c++11 -Wuninitialized" }
+
+struct A
+{
+  const int a = 6; // { dg-bogus "non-static const member" }
+  static int b;
+  int &c = b;  // { dg-bogus "non-static reference" }
+};
+
+struct B
+{
+  const int d; // { dg-warning "non-static const member" }
+  int &e;  // { dg-warning "non-static reference" }
+  int f = 7;
+};

Jakub


[Ada] Accidental overlodading in an instance

2012-06-12 Thread Arnaud Charlet
This patch handles a rare case of accidental overloading in an instance, when
the profile of a subprogram body that depends on a formal type becomes
compatible with that of a homonym whose profile in the generic mentions the
actual type.

execution of inst.adb must yield:

expected T... In P (T)
expected Integer... In P (Integer)
expected Integer... In P (Integer)
expected Integer again... In P (Integer)

---
with Ada.Text_IO; use Ada.Text_IO;
with Gen;
procedure Inst is
   package I is new Gen (Integer);
   Z : integer := 15;
begin
  Put ("expected T... ");
  I.Do_T;

  Put ("expected Integer... ");
  I.Do_Integer;

  Put ("expected Integer... ");
  I.P (123);
  Put ("expected Integer again... ");
  I.P (Z);
end Inst;
---
generic
   type T is private;
package Gen is
   procedure P (X : Integer);

   procedure Do_T;
   procedure Do_Integer;
end Gen;
---
with Ada.Text_IO; use Ada.Text_IO;
package body Gen is
   procedure P (X : T) is
   begin
  Put_Line ("In P (T)");
   end P;

   procedure P (X : Integer) is
   begin
  Put_Line ("In P (Integer)");
   end P;

   procedure Do_T is
  X : T;
   begin
  P (X);
   end Do_T;

   procedure Do_Integer is
  X : Integer;
   begin
  P (X);
   end Do_Integer;
end Gen;

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Ed Schonberg  

* sem_ch6.adb (Different_Generic_Profile): new predicate for
Find_Corresponding_Spec, to handle a rare case of accidental
overloading in an instance, when the profile of a subprogram body
that depends on a formal type becomes compatible with that of
a homonym whose profile in the generic mentions the actual type.

Index: sem_ch6.adb
===
--- sem_ch6.adb (revision 188428)
+++ sem_ch6.adb (working copy)
@@ -7416,6 +7416,8 @@
 --  The following is too permissive. A more precise test should
 --  check that the generic actual is an ancestor subtype of the
 --  other ???.
+--  See code in Find_Corresponding_Spec that applies an additional
+--  filter to handle accidental amiguities in instances.
 
 return not Is_Generic_Actual_Type (T1)
   or else not Is_Generic_Actual_Type (T2)
@@ -8148,6 +8150,46 @@
 
   E : Entity_Id;
 
+  function Different_Generic_Profile (E : Entity_Id) return Boolean;
+  --  Even if fully conformant, a body may depend on a generic actual when
+  --  the spec does not, or vice versa, in which case they were distinct
+  --  entities in the generic.
+
+  ---
+  -- Different_Generic_Profile --
+  ---
+
+  function Different_Generic_Profile (E : Entity_Id) return Boolean is
+ F1, F2 : Entity_Id;
+
+  begin
+ if Ekind (E) = E_Function
+   and then Is_Generic_Actual_Type (Etype (E))
+   /= Is_Generic_Actual_Type (Etype (Designator))
+ then
+return True;
+ end if;
+
+ F1 := First_Formal (Designator);
+ F2 := First_Formal (E);
+
+ while Present (F1) loop
+if
+  Is_Generic_Actual_Type (Etype (F1))
+  /= Is_Generic_Actual_Type (Etype (F2))
+then
+   return True;
+end if;
+
+Next_Formal (F1);
+Next_Formal (F2);
+ end loop;
+
+ return False;
+  end Different_Generic_Profile;
+
+   --  Start of processing for Find_Corresponding_Spec
+
begin
   E := Current_Entity (Designator);
   while Present (E) loop
@@ -8163,13 +8205,12 @@
  and then Type_Conformant (E, Designator))
 then
--  Within an instantiation, we know that spec and body are
-   --  subtype conformant, because they were subtype conformant
-   --  in the generic. We choose the subtype-conformant entity
-   --  here as well, to resolve spurious ambiguities in the
-   --  instance that were not present in the generic (i.e. when
-   --  two different types are given the same actual). If we are
-   --  looking for a spec to match a body, full conformance is
-   --  expected.
+   --  subtype conformant, because they were subtype conformant in
+   --  the generic. We choose the subtype-conformant entity here as
+   --  well, to resolve spurious ambiguities in the instance that
+   --  were not present in the generic (i.e. when two different
+   --  types are given the same actual). If we are looking for a
+   --  spec to match a body, full conformance is expected.
 
if In_Instance then
   Set_Convention (Designator, Convention (E));
@@ -8188,6 +8229,9 @@
 
   elsif not Subtype_Conformant (Designator, E) then
  

[Ada] Treat -fdump-scos as synonym of -gnateS

2012-06-12 Thread Arnaud Charlet
This change allows the use of -fdump-scos as a synonym of -gnateS to
request the generation of SCOs in Ada ALI files.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Thomas Quinot  

* back_end.adb (Scan_Back_End_Switches): Treat -fdump-scos as
synonym of -gnateS.
(gnat_post_options): Disable gimple-based SCO generator.
* gnat_ugn.texi: Document that -gnateS is an obsolete synonym
of -fdump-scos.

Index: back_end.adb
===
--- back_end.adb(revision 188428)
+++ back_end.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -219,23 +219,30 @@
  elsif Switch_Chars (First .. Last) = "quiet" then
 null;
 
- --  Store any other GCC switches
+ --  Store any other GCC switches. Also do special processing for some
+ --  specific switches that the Ada front-end knows about.
 
  else
 Store_Compilation_Switch (Switch_Chars);
 
---  Special check, the back end switch -fno-inline also sets the
+--  Back end switch -fno-inline also sets the Suppress_All_Inlining
 --  front end flag to entirely inhibit all inlining.
 
 if Switch_Chars (First .. Last) = "fno-inline" then
Opt.Suppress_All_Inlining := True;
 
---  Another special check, the switch -fpreserve-control-flow
---  which is also a back end switch sets the front end flag
---  that inhibits improper control flow transformations.
+--  Back end switch -fpreserve-control-flow also sets the front end
+--  flag that inhibits improper control flow transformations.
 
 elsif Switch_Chars (First .. Last) = "fpreserve-control-flow" then
Opt.Suppress_Control_Flow_Optimizations := True;
+
+--  Back end switcg -fdump-scos, which exists primarily for C, is
+--  also accepted for Ada as a synonym of -gnateS.
+
+elsif Switch_Chars (First .. Last) = "fdump-scos" then
+   Opt.Generate_SCO := True;
+
 end if;
  end if;
   end Scan_Back_End_Switches;
Index: gnat_ugn.texi
===
--- gnat_ugn.texi   (revision 188428)
+++ gnat_ugn.texi   (working copy)
@@ -4045,6 +4045,13 @@
 per-file basis.  The information is generated in the VCG format.  It can
 be decorated with stack-usage per-node information.
 
+@item -fdump-scos
+@cindex @option{-fdump-scos} (@command{gcc})
+Generate SCO (Source Coverage Obligation) information in the ALI file.
+This information is used by advanced coverage tools. See unit @file{SCOs}
+in the compiler sources for details in files @file{scos.ads} and
+@file{scos.adb}.
+
 @item ^-g^/DEBUG^
 @cindex @option{^-g^/DEBUG^} (@command{gcc})
 Generate debugging information. This information is stored in the object
@@ -4201,12 +4208,10 @@
 these errors become warnings (which can be ignored, or suppressed in the usual
 manner). This can be useful in some specialized circumstances such as the
 temporary use of special test software.
+
 @item -gnateS
 @cindex @option{-gnateS} (@command{gcc})
-Generate SCO (Source Coverage Obligation) information in the ALI
-file. This information is used by advanced coverage tools. See
-unit @file{SCOs} in the compiler sources for details in files
-@file{scos.ads} and @file{scos.adb}.
+Synonym of @option{-fdump-scos}, kept for backards compatibility.
 
 @item -gnatE
 @cindex @option{-gnatE} (@command{gcc})


Re: arm-rtems switch default target to EABI

2012-06-12 Thread Sebastian Huber

On 06/05/2012 05:19 PM, Sebastian Huber wrote:

Hi,

what is the blocking point for the integration of these patches?



Ping.

--
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax : +49 89 18 90 80 79-9
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


Re: [RFC PR48941 / 51980] Rewrite arm_neon.h to use __builtin_shuffle

2012-06-12 Thread Julian Brown
On Mon, 11 Jun 2012 16:46:27 +0100
Ramana Radhakrishnan  wrote:

> Hi,
> 
> I don't like the ML bits of the patch as it stands today and before
> committing I would like to clean up the ML bits quite a bit further
> especially in areas where I've put FIXMEs [...]

I had a go at this, see attached. Untested. Note there are some
semantic differences in output:

 vzipq_p8 (poly8x16_t __a, poly8x16_t __b)
 {
   poly8x16x2_t __rv;
-  uint8x16_t __mask1 = {0, 2};
-  uint8x16_t __mask2 = {1, 3};
-  __rv.val[0] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask1);
-  __rv.val[1] = (poly8x16_t)__builtin_shuffle (__a, __b, __mask2);
+  uint8x16_t __mask1 = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6,
 22, 7, 23 };
+  uint8x16_t __mask2 = { 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29,
 14, 30, 15, 31 };
+  __rv.val[0] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask1);
+  __rv.val[1] = (poly8x16_t) __builtin_shuffle (__a, __b, __mask2);
   return __rv;
 }

I wasn't quite sure which version was correct -- but your version
doesn't seem to have enough elements for these cases?

HTH,

JulianIndex: neon.ml
===
--- neon.ml	(revision 188392)
+++ neon.ml	(working copy)
@@ -201,6 +201,42 @@
   (* Reinterpret casts.  *)
   | Vreinterp
 
+let rev_elems revsize elsize nelts _ =
+  let mask = (revsize / elsize) - 1 in
+  let arr = Array.init nelts
+(fun i -> i lxor mask) in
+  Array.to_list arr
+
+let permute_range i stride nelts increment =
+  let rec build i = function
+0 -> []
+  | nelts -> i :: (i + stride) :: build (i + increment) (pred nelts) in
+  build i nelts
+
+(* Generate a list of integers suitable for vzip.  *)
+let zip_range i stride nelts = permute_range i stride nelts 1
+
+(* Generate a list of integers suitable for vunzip.  *)
+let uzip_range i stride nelts = permute_range i stride nelts 4
+
+(* Generate a list of integers suitable for trn.  *)
+let trn_range i stride nelts = permute_range i stride nelts 2
+
+let zip_elems _ nelts part =
+  match part with
+`lo -> zip_range 0 nelts (nelts / 2)
+  | `hi -> zip_range (nelts / 2) nelts (nelts / 2)
+
+let uzip_elems _ nelts part =
+  match part with
+`lo -> uzip_range 0 2 (nelts / 2)
+  | `hi -> uzip_range 1 2 (nelts / 2)
+
+let trn_elems _ nelts part =
+  match part with
+`lo -> trn_range 0 nelts (nelts / 2)
+  | `hi -> trn_range 1 nelts (nelts / 2)
+
 (* Features used for documentation, to distinguish between some instruction
variants, and to signal special requirements (e.g. swapping arguments).  *)
 
@@ -214,7 +250,10 @@
   | Flipped of string  (* Builtin name to use with flipped arguments.  *)
   | InfoWord  (* Pass an extra word for signage/rounding etc. (always passed
  for All _, Long, Wide, Narrow shape_forms.  *)
-  | ReturnPtr  (* Pass explicit pointer to return value as first argument.  *)
+(* Implement builtin as shuffle.  The parameter is a function which returns
+   masks suitable for __builtin_shuffle: arguments are (element size,
+   number of elements, high/low part selector).  *)
+  | Use_shuffle of (int -> int -> [`lo|`hi] -> int list)
 (* A specification as to the shape of instruction expected upon
disassembly, used if it differs from the shape used to build the
intrinsic prototype.  Multiple entries in the constructor's argument
@@ -1317,12 +1356,18 @@
   pf_su_8_64;
 
 (* Reverse elements.  *)
-Vrev64, [], All (2, Dreg), "vrev64", bits_1, P8 :: P16 :: F32 :: su_8_32;
-Vrev64, [], All (2, Qreg), "vrev64Q", bits_1, P8 :: P16 :: F32 :: su_8_32;
-Vrev32, [], All (2, Dreg), "vrev32", bits_1, [P8; P16; S8; U8; S16; U16];
-Vrev32, [], All (2, Qreg), "vrev32Q", bits_1, [P8; P16; S8; U8; S16; U16];
-Vrev16, [], All (2, Dreg), "vrev16", bits_1, [P8; S8; U8];
-Vrev16, [], All (2, Qreg), "vrev16Q", bits_1, [P8; S8; U8];
+Vrev64, [Use_shuffle (rev_elems 64)], All (2, Dreg), "vrev64", bits_1,
+  P8 :: P16 :: F32 :: su_8_32;
+Vrev64, [Use_shuffle (rev_elems 64)], All (2, Qreg), "vrev64Q", bits_1,
+  P8 :: P16 :: F32 :: su_8_32;
+Vrev32, [Use_shuffle (rev_elems 32)], All (2, Dreg), "vrev32", bits_1,
+  [P8; P16; S8; U8; S16; U16];
+Vrev32, [Use_shuffle (rev_elems 32)], All (2, Qreg), "vrev32Q", bits_1,
+  [P8; P16; S8; U8; S16; U16];
+Vrev16, [Use_shuffle (rev_elems 16)], All (2, Dreg), "vrev16", bits_1,
+  [P8; S8; U8];
+Vrev16, [Use_shuffle (rev_elems 16)], All (2, Qreg), "vrev16Q", bits_1,
+  [P8; S8; U8];
 
 (* Bit selection.  *)
 Vbsl,
@@ -1336,25 +1381,19 @@
   Use_operands [| Qreg; Qreg; Qreg; Qreg |], "vbslQ", bit_select,
   pf_su_8_64;
 
-(* Transpose elements.  **NOTE** ReturnPtr goes some of the way towards
-   generating good code for intrinsics which return structure types --
-   builtins work well by themselves (and understand that the values being
-   stored on e.g. the stack also reside in registe

[Ada] Proper implementation of interfacing aspects.

2012-06-12 Thread Arnaud Charlet
This patch implements properly the aspects Convention, Import, Export, Link_
Name and External_Name, which replace the corresponding Ada 2005 pragmas.

Compiling missing_convention.ads must yield:

   missing_convention.ads:3:07: missing Convention aspect for Export/Import
---
function missing_convention return Integer
   with
  Export => True,
  Link_Name => "example";
---

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Ed Schonberg  

* exp_prag.adb (Expand_Pragma_Import_Or_Interface): revert previous
patch. The processing of interfacing aspects now generates a
proper Ada 2005 pragma.
* sem_prag.adb (Analyze_Pragma, cases Pragma_Export and
Pragma_Import): revert previous patch.  The processing of
interfacing aspects now generates a proper Ada 2005 pragma.
* sem_ch13.adb (Analyze_Aspect_Specifications): generate proper
pragam for aspects Convention, Import and Export. Scan list
of aspects to collect link name and external name if present,
and verify that a complete pragma can be generated.

Index: exp_prag.adb
===
--- exp_prag.adb(revision 188428)
+++ exp_prag.adb(working copy)
@@ -531,14 +531,7 @@
   Init_Call : Node_Id;
 
begin
-  --  If the pragma comes from an aspect, the entity is its first argument.
-
-  if Present (Corresponding_Aspect (N)) then
- Def_Id := Entity (Arg1 (N));
-  else
- Def_Id := Entity (Arg2 (N));
-  end if;
-
+  Def_Id := Entity (Arg2 (N));
   if Ekind (Def_Id) = E_Variable then
 
  --  Find generated initialization call for object, if any
Index: sem_prag.adb
===
--- sem_prag.adb(revision 188428)
+++ sem_prag.adb(working copy)
@@ -8647,29 +8647,8 @@
 Name_External_Name,
 Name_Link_Name));
 
-if Present (Corresponding_Aspect (N)) then
+Check_At_Least_N_Arguments (2);
 
-   --  If the pragma comes from an Aspect, there is a single entity
-   --  parameter and an optional booean value with default true.
-   --  The convention must be provided by a separate aspect.
-
-   Check_At_Least_N_Arguments (1);
-   Check_At_Most_N_Arguments  (2);
-   Def_Id := Entity (Arg1);
-
-   if No (Arg2) then
-
-  --  If the aspect has a default True value, set corresponding
-  --  flag on the entity.
-
-  Set_Is_Exported (Def_Id);
-   end if;
-   return;
-
-else
-   Check_At_Least_N_Arguments (2);
-end if;
-
 Check_At_Most_N_Arguments  (4);
 Process_Convention (C, Def_Id);
 
@@ -9603,30 +9582,10 @@
 Name_External_Name,
 Name_Link_Name));
 
-if Present (Corresponding_Aspect (N)) then
+Check_At_Least_N_Arguments (2);
+Check_At_Most_N_Arguments  (4);
+Process_Import_Or_Interface;
 
-   --  If the pragma comes from an Aspect, there is a single entity
-   --  parameter and an optional booean value with default true.
-   --  The convention must be provided by a separate aspect.
-
-   Check_At_Least_N_Arguments (1);
-   Check_At_Most_N_Arguments  (2);
-
-   if No (Arg2) then
-
-  --  If the aspect has a default True value, set corresponding
-  --  flag on the entity.
-
-  Set_Is_Imported (Entity (Arg1));
-   end if;
-   return;
-
-else
-   Check_At_Least_N_Arguments (2);
-   Check_At_Most_N_Arguments  (4);
-   Process_Import_Or_Interface;
-end if;
-
  --
  -- Import_Exception --
  --
Index: sem_ch13.adb
===
--- sem_ch13.adb(revision 188428)
+++ sem_ch13.adb(working copy)
@@ -949,6 +949,33 @@
  end if;
 
  goto Continue;
+
+  elsif A_Id = Aspect_Import
+or else A_Id = Aspect_Export
+  then
+
+ --  Verify that there is an aspect Convention that will
+ --  incorporate the Import/Export aspect, and eventual
+ --  Link/External names.
+
+ declare
+A : Node_Id;
+
+ begin
+A := First (L);
+while Present (A) loop
+   exit when Chars (Identifier (A)) = Name_Convention;
+   Next (A);
+end l

[Ada] Fix error message printed for invalid access to atomic component

2012-06-12 Thread Arnaud Charlet
This changes the error message printed for an invalid access to an atomic
component, which was:
  access to volatile object cannot yield access-to-non-volatile type
into the more correct:
  access to atomic object cannot yield access-to-non-atomic type
The problem was that Is_Atomic_Object returned false for such a component.

The following testcase should generate the new error message:

procedure Atomic_Test is

   type X32 is mod 2 ** 32;

   type Rec is record
  B : aliased X32;
  pragma Atomic (B);
   end record;

   procedure Test (X : access X32) is null;

   Object : Rec;
begin
   Test (Object.B'Access);
end Atomic_Test;

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-06-12  Eric Botcazou  

* sem_util.adb (Is_Atomic_Object): Return true for an atomic
component as well as a prefix which is an atomic component.

Index: sem_util.adb
===
--- sem_util.adb(revision 188428)
+++ sem_util.adb(working copy)
@@ -6749,6 +6749,11 @@
  then
 return True;
 
+ elsif Nkind (N) = N_Selected_Component
+   and then Is_Atomic (Entity (Selector_Name (N)))
+ then
+return True;
+
  elsif Nkind (N) = N_Indexed_Component
or else Nkind (N) = N_Selected_Component
  then
@@ -6772,6 +6777,11 @@
   then
  return True;
 
+  elsif Nkind (N) = N_Selected_Component
+and then Is_Atomic (Entity (Selector_Name (N)))
+  then
+ return True;
+
   elsif Nkind (N) = N_Indexed_Component
 or else Nkind (N) = N_Selected_Component
   then


  1   2   >