* Small invoke.texi patch
@ 1997-08-30 3:24 J. Kean Johnston
1997-08-30 3:24 ` "restrict" keyword for C Peter Seebach
0 siblings, 1 reply; 5+ messages in thread
From: J. Kean Johnston @ 1997-08-30 3:24 UTC (permalink / raw)
To: egcs
This patch allows makeinfo to work properly in 970828:
*** invoke.texi.jkj Fri Aug 29 20:47:32 1997
--- invoke.texi Fri Aug 29 20:47:43 1997
***************
*** 2198,2204 ****
they have helped determine the efficacy of various
approaches to improving loop optimizations.
! Please let us (@code{egcs@cygnus.com and fortran@@gnu.ai.mit.edu})
know how use of these options affects
the performance of your production code.
We're very interested in code that runs @emph{slower}
--- 2198,2204 ----
they have helped determine the efficacy of various
approaches to improving loop optimizations.
! Please let us (@code{egcs@@cygnus.com and fortran@@gnu.ai.mit.edu})
know how use of these options affects
the performance of your production code.
We're very interested in code that runs @emph{slower}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "restrict" keyword for C
1997-08-30 3:24 Small invoke.texi patch J. Kean Johnston
@ 1997-08-30 3:24 ` Peter Seebach
0 siblings, 0 replies; 5+ messages in thread
From: Peter Seebach @ 1997-08-30 3:24 UTC (permalink / raw)
To: egcs
While I am far from speaking officially, I'd like to see something like
-std c89
-std knr
-std c9x
-std ansi
where "ansi" is somewhere around 'void *', but without some of the cruft like
trigraphs.
(Yes, I will freely admit that trigraphs are cruft.)
-s
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "restrict" keyword for C
@ 1997-08-30 2:57 Jim Wilson
0 siblings, 0 replies; 5+ messages in thread
From: Jim Wilson @ 1997-08-30 2:57 UTC (permalink / raw)
To: egcs
We probably really ought to have multiple ANSI conformance modes, one
for the ANSI 89/92 standard where restrict is not a keyword, and one
for ANSI 9X where restrict is a keyword. Otherwise, some valid ANSI C
codes won't compile with gcc anymore.
Otherwise it seems reasonable.
Since we are working towards the initial release, and this patch may cause
problems, I will hold it off until after the initial release.
Jim
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "restrict" keyword for C
1997-08-26 23:42 -g1 lossage Jeffrey A Law
@ 1997-08-26 23:42 ` Joern Rennecke
0 siblings, 0 replies; 5+ messages in thread
From: Joern Rennecke @ 1997-08-26 23:42 UTC (permalink / raw)
To: egcs
> A warning for future developers: because gcc's CSE does not respect C block
> structure one must be very careful not to let "restrict" information leak
> outside its scope. I have only optimized function arguments; in the
> absence of inlining the noalias assertion is valid for the life of the
> function. There may still be bugs with inlined functions because a
> REG_NOALIAS note is in general not valid if moved to another function.
I'd say the obvious stopgap solution is to remove all REG_NOALIAS notes
of inlined functions before or while inlining. Of course this can be
dropped when / if the code gets generalized so that REG_NOALIAS works
for non-arguments.
^ permalink raw reply [flat|nested] 5+ messages in thread
* "restrict" keyword for C
@ 1997-08-24 22:13 John Carr
0 siblings, 0 replies; 5+ messages in thread
From: John Carr @ 1997-08-24 22:13 UTC (permalink / raw)
To: egcs
This patch implements "restrict" for C (only). Restrict comes from the
NCEG and will likely be in C9X. It is the modern version of "noalias",
which was proposed about 10 years ago during the ANSI C standardization
process. In response to the proposal Dennis Ritchie said "noalias must
go. This is non-negotiable."; noalias went away soon after that.
The NCEG proposal makes "restrict" a type qualifier like "const" or
"volatile". It may modify a pointer to object type, directly or
indirectly. A restricted pointer provides the _only_ access to an object
in its scope. Any access (read or write) to an object using a different
pointer causes undefined behavior.
This implementation only permits "restrict" to directly modify a variable
declaration. It is not a type qualifier; making it one would require much
more extensive compiler changes. (Sun's compiler has a similar restriction,
only allowing parameters to be restrict-qualified.)
"restrict" is ignored except when applied to function arguments. Shared
read access in violation of the NCEG aliasing rules is permitted.
A warning for future developers: because gcc's CSE does not respect C block
structure one must be very careful not to let "restrict" information leak
outside its scope. I have only optimized function arguments; in the
absence of inlining the noalias assertion is valid for the life of the
function. There may still be bugs with inlined functions because a
REG_NOALIAS note is in general not valid if moved to another function.
Sun Aug 24 18:01:58 1997 John F. Carr <jfc@mit.edu>
* tree.h (DECL_RESTRICT): New definition.
* c-parse.gperf, c-lex.c, c-lex.h: New keyword "restrict".
* c-decl.c (grokdeclarator): Recognize "restrict".
* function.c (assign_parms): If a parameter has DECL_RESTRICT set
put a noalias note on the insn which copies it into a pseudo-register.
*** c-decl.c.orig Thu Aug 21 18:47:56 1997
--- c-decl.c Sun Aug 24 17:36:14 1997
***************
*** 4163,4168 ****
--- 4159,4165 ----
int constp;
int volatilep;
int inlinep;
+ int restrictp;
int explicit_int = 0;
int explicit_char = 0;
int defaulted_int = 0;
***************
*** 4475,4480 ****
--- 4472,4478 ----
constp = !! (specbits & 1 << (int) RID_CONST) + TYPE_READONLY (type);
volatilep = !! (specbits & 1 << (int) RID_VOLATILE) + TYPE_VOLATILE (type);
inlinep = !! (specbits & (1 << (int) RID_INLINE));
+ restrictp = !!(specbits & (1 << (int) RID_RESTRICT));
if (constp > 1)
pedwarn ("duplicate `const'");
if (volatilep > 1)
***************
*** 4572,4577 ****
--- 4570,4583 ----
continue;
}
+ /* Implementation restriction: `restrict' only applies to variables,
+ not types. */
+ if (restrictp)
+ {
+ error ("`restrict' used in incorrect context");
+ restrictp = 0;
+ }
+
/* Each level of DECLARATOR is either an ARRAY_REF (for ...[..]),
an INDIRECT_REF (for *...),
a CALL_EXPR (for ...(...)),
***************
*** 4826,4831 ****
--- 4832,4839 ----
constp++;
else if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_VOLATILE])
volatilep++;
+ else if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_RESTRICT])
+ restrictp++;
else if (!erred)
{
erred = 1;
***************
*** 4836,4841 ****
--- 4844,4851 ----
pedwarn ("duplicate `const'");
if (volatilep > 1)
pedwarn ("duplicate `volatile'");
+ if (restrictp > 1)
+ pedwarn ("duplicate `restrict'");
}
declarator = TREE_OPERAND (declarator, 0);
***************
*** 4857,4862 ****
--- 4867,4874 ----
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
&& (constp || volatilep))
pedwarn ("ANSI C forbids const or volatile function types");
+ if (restrictp)
+ error ("`restrict' applied to typedef");
if (constp || volatilep)
type = c_build_type_variant (type, constp, volatilep);
decl = build_decl (TYPE_DECL, declarator, type);
***************
*** 5146,5151 ****
--- 5158,5175 ----
TREE_SIDE_EFFECTS (decl) = 1;
TREE_THIS_VOLATILE (decl) = 1;
}
+
+ /* DECL_RESTRICT is only defined for pointer variables. */
+ if (restrictp)
+ {
+ if (TREE_CODE (type) == FUNCTION_TYPE)
+ error ("a function may not be declared `restrict'");
+ else if (TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE)
+ error ("only a pointer may be declared `restrict'");
+ else
+ DECL_RESTRICT (decl) = 1;
+ }
+
/* If a type has volatile components, it should be stored in memory.
Otherwise, the fact that those components are volatile
will be ignored, and would even crash the compiler. */
*** function.c.orig Thu Aug 21 18:48:29 1997
--- function.c Sat Aug 16 11:40:53 1997
***************
*** 3864,3870 ****
end_sequence ();
}
else
! emit_move_insn (parmreg, validize_mem (entry_parm));
/* If we were passed a pointer but the actual value
can safely live in a register, put it in one. */
--- 3864,3878 ----
end_sequence ();
}
else
! {
! emit_move_insn (parmreg, validize_mem (entry_parm));
! if (DECL_RESTRICT (parm) && flag_alias_check)
! {
! rtx last = get_last_insn ();
! REG_NOTES (last) = gen_rtx (EXPR_LIST, REG_NOALIAS,
! parmreg, REG_NOTES (last));
! }
! }
/* If we were passed a pointer but the actual value
can safely live in a register, put it in one. */
*** tree.h.orig Thu Aug 21 18:49:08 1997
--- tree.h Sun Aug 24 15:54:17 1997
*** 1075,1080 ****
--- 1076,1084 ----
#define DECL_STATIC_CONSTRUCTOR(NODE) ((NODE)->decl.static_ctor_flag)
#define DECL_STATIC_DESTRUCTOR(NODE) ((NODE)->decl.static_dtor_flag)
+ /* In a VAR_DECL or PARM_DECL, nonzero if this is a restricted pointer. */
+ #define DECL_RESTRICT(NODE) (NODE)->decl.static_ctor_flag
+
/* Used to indicate that this DECL represents a compiler-generated entity. */
#define DECL_ARTIFICIAL(NODE) ((NODE)->decl.artificial_flag)
*** c-parse.gperf.orig Thu Aug 21 18:47:57 1997
--- c-parse.gperf Sun Apr 27 18:21:24 1997
***************
*** 35,40 ****
--- 35,41 ----
__label__, LABEL, NORID
__real, REALPART, NORID
__real__, REALPART, NORID
+ __restrict, TYPE_QUAL, RID_RESTRICT
__signed, TYPESPEC, RID_SIGNED
__signed__, TYPESPEC, RID_SIGNED
__typeof, TYPEOF, NORID
***************
*** 68,73 ****
--- 69,75 ----
oneway, TYPE_QUAL, RID_ONEWAY
out, TYPE_QUAL, RID_OUT
register, SCSPEC, RID_REGISTER
+ restrict, TYPE_QUAL, RID_RESTRICT
return, RETURN, NORID
short, TYPESPEC, RID_SHORT
signed, TYPESPEC, RID_SIGNED
*** c-lex.h.orig Thu Aug 21 18:47:56 1997
--- c-lex.h Sun Apr 27 18:21:23 1997
***************
*** 42,48 ****
RID_CONST,
RID_VOLATILE,
RID_INLINE,
! RID_NOALIAS,
RID_ITERATOR,
RID_COMPLEX,
--- 42,48 ----
RID_CONST,
RID_VOLATILE,
RID_INLINE,
! RID_RESTRICT,
RID_ITERATOR,
RID_COMPLEX,
*** c-lex.c.orig Thu Aug 21 18:47:56 1997
--- c-lex.c Sat Aug 23 16:27:45 1997
***************
*** 232,237 ****
--- 232,238 ----
ridpointers[(int) RID_INLINE] = get_identifier ("inline");
ridpointers[(int) RID_CONST] = get_identifier ("const");
ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
+ ridpointers[(int) RID_RESTRICT] = get_identifier ("restrict");
ridpointers[(int) RID_AUTO] = get_identifier ("auto");
ridpointers[(int) RID_STATIC] = get_identifier ("static");
ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
***************
*** 265,270 ****
--- 266,272 ----
UNSET_RESERVED_WORD ("inline");
UNSET_RESERVED_WORD ("iterator");
UNSET_RESERVED_WORD ("complex");
+ UNSET_RESERVED_WORD ("restrict");
}
if (flag_no_asm)
{
***************
*** 273,278 ****
--- 275,281 ----
UNSET_RESERVED_WORD ("inline");
UNSET_RESERVED_WORD ("iterator");
UNSET_RESERVED_WORD ("complex");
+ UNSET_RESERVED_WORD ("restrict");
}
}
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1997-08-30 3:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-08-30 3:24 Small invoke.texi patch J. Kean Johnston
1997-08-30 3:24 ` "restrict" keyword for C Peter Seebach
-- strict thread matches above, loose matches on Subject: below --
1997-08-30 2:57 Jim Wilson
1997-08-26 23:42 -g1 lossage Jeffrey A Law
1997-08-26 23:42 ` "restrict" keyword for C Joern Rennecke
1997-08-24 22:13 John Carr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).