Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!sri-unix!ctnews!pyramid!decwrl!sun!gorodish!guy From: guy@gorodish.UUCP Newsgroups: comp.arch,comp.lang.c Subject: Re: String Processing Instruction Message-ID: <15694@sun.uucp> Date: Thu, 26-Mar-87 14:38:41 EST Article-I.D.: sun.15694 Posted: Thu Mar 26 14:38:41 1987 Date-Received: Sat, 28-Mar-87 11:26:12 EST References: <15292@amdcad.UUCP> <978@ames.UUCP> Sender: news@sun.uucp Reply-To: guy@sun.UUCP (Guy Harris) Distribution: na Organization: Sun Microsystems, Mountain View Lines: 31 Keywords: instruction set architectures, Am29000 Xref: utgpu comp.arch:675 comp.lang.c:1348 >My question is this: How likely is it that a compiler itself will be able to >detect the case when it can use an instruction like this and generate code >automatically to use it. In most C implementations, "strcpy", "strcmp", etc. are library routines; if the speedup from these instructions is sufficiently large, it doesn't matter if the compiler can generate them because the compiler can generate calls to those routines, and those routines can be written in assembler language. You could also imagine a compiler that would recognize names like "_builtin_strcpy" and generate the assembler code for those routines in line, and a that contains #define strcpy _builtin_strcpy (see the footnote on page 86 of the October 1, 1986 ANSI C draft). Another possibility might be to have something like the WE32000 C compiler's "asm" directive, which permits you to define "functions" that are expanded in line to assembler code. Similar techniques can probably be used in other languages. If they do string processing in routines, the routines can be written in assembler language to use these instructions. If they generate stereotyped sequences for these string operations, these stereotyped seqences can use these instructions. However, I don't know how difficult it would be to recognize various special cases and generate non-stereotyped sequences that use these instructions, or how much of a speedup this would give (if these special cases weren't common, speeding them up might not buy you enough to worry about it).