public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Generated unique labels
@ 2002-12-29 11:47 James Buchanan
  2003-01-02  7:42 ` Joseph D. Wagner
  2003-01-03  0:25 ` Richard Henderson
  0 siblings, 2 replies; 10+ messages in thread
From: James Buchanan @ 2002-12-29 11:47 UTC (permalink / raw)
  To: gcc

In the Projects file:

===
Generated unique labels. Have some way of generating distinct
labels for use in extended asm statements. I don't know what a
good syntax would be.
===

Has this been done yet?  If not has anyone been assigned to it?

Where would this be done?  What is an extended asm statement,
is this asm code generated by the back end?  Is there any
distinction between asm and extended asm?  So things peculiar
to local labels can't be used?

Would this be a function, let's say:

...in file uniquelabel.h

char *
gen_unique_label();

...in file uniquelabel.c
char *
gen_unique_label()
{
	/* Get some memory or just return a pointer?? */
	char *the_label = (char *)safe_malloc();

	/*
	Let's say we only use a static char array
	and return a pointer to it.  The caller gets it
	and copies the string straight away, but
	this seems silly.  Functions should take
	care of it.
	*/
	
	/*
	Or perhaps allocate a string, the caller
	can do free(the_label)
	*/

	/* do stuff */
	return (the_label);
}

?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: Generated unique labels
  2002-12-29 11:47 Generated unique labels James Buchanan
@ 2003-01-02  7:42 ` Joseph D. Wagner
  2003-01-03  0:43   ` James Buchanan
  2003-01-03  0:25 ` Richard Henderson
  1 sibling, 1 reply; 10+ messages in thread
From: Joseph D. Wagner @ 2003-01-02  7:42 UTC (permalink / raw)
  To: 'James Buchanan', gcc

[-- Attachment #1: Type: text/plain, Size: 1309 bytes --]

I don't know if this will work or not, but it's worth a shot.

Uses C++

Joseph Wagner

-----Original Message-----
From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org] On Behalf Of
James Buchanan
Sent: Sunday, December 29, 2002 10:32 AM
To: gcc@gcc.gnu.org
Subject: Generated unique labels

In the Projects file:

===
Generated unique labels. Have some way of generating distinct
labels for use in extended asm statements. I don't know what a
good syntax would be.
===

Has this been done yet?  If not has anyone been assigned to it?

Where would this be done?  What is an extended asm statement,
is this asm code generated by the back end?  Is there any
distinction between asm and extended asm?  So things peculiar
to local labels can't be used?

Would this be a function, let's say:

...in file uniquelabel.h

char *
gen_unique_label();

...in file uniquelabel.c
char *
gen_unique_label()
{
	/* Get some memory or just return a pointer?? */
	char *the_label = (char *)safe_malloc();

	/*
	Let's say we only use a static char array
	and return a pointer to it.  The caller gets it
	and copies the string straight away, but
	this seems silly.  Functions should take
	care of it.
	*/
	
	/*
	Or perhaps allocate a string, the caller
	can do free(the_label)
	*/

	/* do stuff */
	return (the_label);
}

?

[-- Attachment #2: NumberToString.hpp --]
[-- Type: text/plain, Size: 1427 bytes --]

// Template Function: NumberToString

// Copyright © 2002 Joseph Wagner.  All rights reserved.
// Email: wagnerjd@users.sourceforge.net
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library 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
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#ifndef NUMBER_TO_STRING_HPP
#define NUMBER_TO_STRING_HPP

#include <string>
using std::string;
#include <sstream>
using std::ostringstream;

template<typename NumberType>
const string NumberToString(const NumberType number) {
	// Declares variable used as a medium in conversion
	ostringstream numberStream;

	// Converts number into output string stream
	numberStream << number;

	// Converts output string stream to string, and returns a copy
	return numberStream.str();
}

#endif	// NUMBER_TO_STRING_HPP

[-- Attachment #3: SequentialString.cpp --]
[-- Type: text/plain, Size: 1796 bytes --]

// Class: SequentialString
// Requires file(s): SequentialString.hpp

// Copyright © 2002 Joseph Wagner.  All rights reserved.
// Email: wagnerjd@users.sourceforge.net
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library 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
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#include "SequentialString.hpp"

#include "NumberToString.hpp"

// *************** Default Constructor ***************

SequentialString::SequentialString(string InitialString) {
	Index = 1;
	setBaseString(InitialString);
}

// *************** Deconstructor ***************

SequentialString::~SequentialString() {
	BaseString.clear();
	Index = 0;
}

// *************** Set Functions ***************

void SequentialString::setBaseString(const string &InitialString) {
	BaseString = InitialString;
}

// *************** Get Functions ***************

const string SequentialString::getBaseString() const {
	return BaseString;
}

const string SequentialString::getNextString() {
	return BaseString + NumberToString(Index++);
}

const string SequentialString::getPreviousString() {
	return BaseString + NumberToString(Index--);
}

[-- Attachment #4: SequentialString.hpp --]
[-- Type: text/plain, Size: 1668 bytes --]

// Class: SequentialString
// Requires file(s): SequentialString.cpp

// Copyright © 2002 Joseph Wagner.  All rights reserved.
// Email: wagnerjd@users.sourceforge.net
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library 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
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#ifndef SEQUENTIAL_STRING_HPP
#define SEQUENTIAL_STRING_HPP

#include <string>
using std::string;

class SequentialString {

	public:

		// *************** Default Constructor ***************

		SequentialString(string = "\0");

		// *************** Deconstructor ***************

		~SequentialString();

		// *************** Get Functions ***************

		const string getBaseString() const;
		const string getNextString();
		const string getPreviousString();

	private:

		// *************** Set Functions ***************

		void setBaseString(const string &);

		// *************** Data Structures ***************

		string BaseString;
		unsigned long Index;
};

#endif	// SEQUENTIAL_STRING_HPP

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Generated unique labels
  2002-12-29 11:47 Generated unique labels James Buchanan
  2003-01-02  7:42 ` Joseph D. Wagner
@ 2003-01-03  0:25 ` Richard Henderson
  2003-01-03  0:44   ` James Buchanan
  1 sibling, 1 reply; 10+ messages in thread
From: Richard Henderson @ 2003-01-03  0:25 UTC (permalink / raw)
  To: James Buchanan; +Cc: gcc

On Mon, Dec 30, 2002 at 03:31:30AM +1100, James Buchanan wrote:
> Has this been done yet?  If not has anyone been assigned to it?

No and no.  Best option is to use assembler local labels.


r~

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: Generated unique labels
  2003-01-02  7:42 ` Joseph D. Wagner
@ 2003-01-03  0:43   ` James Buchanan
  0 siblings, 0 replies; 10+ messages in thread
From: James Buchanan @ 2003-01-03  0:43 UTC (permalink / raw)
  To: Joseph D. Wagner, gcc

I prefer this option that Joseph has given, if possible.  Using assembler local
labels means different labels for different types of assembler, doesn't it?  A
platform independent label generator is probably best.  Then again, I don't
really know, or understand what exactly the requirements of these labels are.

At 01:41 AM 1/2/2003 -0600, Joseph D. Wagner wrote:
>I don't know if this will work or not, but it's worth a shot.
>
>Uses C++
>
>Joseph Wagner
>
>-----Original Message-----
>From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org] On Behalf Of
>James Buchanan
>Sent: Sunday, December 29, 2002 10:32 AM
>To: gcc@gcc.gnu.org
>Subject: Generated unique labels
>
>In the Projects file:
>
>===
>Generated unique labels. Have some way of generating distinct
>labels for use in extended asm statements. I don't know what a
>good syntax would be.
>===
>
>Has this been done yet?  If not has anyone been assigned to it?
>
>Where would this be done?  What is an extended asm statement,
>is this asm code generated by the back end?  Is there any
>distinction between asm and extended asm?  So things peculiar
>to local labels can't be used?
>
>Would this be a function, let's say:
>
>...in file uniquelabel.h
>
>char *
>gen_unique_label();
>
>...in file uniquelabel.c
>char *
>gen_unique_label()
>{
>         /* Get some memory or just return a pointer?? */
>         char *the_label = (char *)safe_malloc();
>
>         /*
>         Let's say we only use a static char array
>         and return a pointer to it.  The caller gets it
>         and copies the string straight away, but
>         this seems silly.  Functions should take
>         care of it.
>         */
>
>         /*
>         Or perhaps allocate a string, the caller
>         can do free(the_label)
>         */
>
>         /* do stuff */
>         return (the_label);
>}
>
>?
>
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Generated unique labels
  2003-01-03  0:25 ` Richard Henderson
@ 2003-01-03  0:44   ` James Buchanan
  2003-01-03 12:28     ` Jonah
  0 siblings, 1 reply; 10+ messages in thread
From: James Buchanan @ 2003-01-03  0:44 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc

This means a different label syntax for different assembler languages
doesn't it?  So the function needs to know an "assembly context"
depending on what the target CPU is for the program.

At 04:25 PM 1/2/2003 -0800, Richard Henderson wrote:
>On Mon, Dec 30, 2002 at 03:31:30AM +1100, James Buchanan wrote:
> > Has this been done yet?  If not has anyone been assigned to it?
>
>No and no.  Best option is to use assembler local labels.
>
>
>r~

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Generated unique labels
  2003-01-03  0:44   ` James Buchanan
@ 2003-01-03 12:28     ` Jonah
  2003-01-03 17:34       ` Richard Henderson
  0 siblings, 1 reply; 10+ messages in thread
From: Jonah @ 2003-01-03 12:28 UTC (permalink / raw)
  To: Richard Henderson, James Buchanan, Joseph D. Wagner; +Cc: gcc

I am a bit confused by where this conversation is going. Isn't the Projects
list item referring to having labels in inline assembler. I will give you
the problem I was having which I thought was the same problem as the
projects file item.

int simple_func (int b, int c)
{
    int x;
asm (
"simple_func_loop_start:\n\t"
"    Do Assebly Stuff    \n\t"
"    LOOP to simple_func_loop_start"
: [x] "=r" (x)
: [b] "r" (b), [c] "r" (c)
: "r0", "r1", "memory" );

    return x;
}

int bigger_func ()
{
    ...
    simple_func (1, 2);
    ...
    simple_func (4, 1);
}

If I compile the above I get simple_func inlined in bigger_func twice,
casuing the same label "simple_func_loop_start" to exist twice in the
assembly for function bigger_func. If there was a way to generate a unique
label in the asm block, the inlining could then give me two different
labels.

For example if the asm statement were extended to have a fifth field which
was the number of unique labels needed in the asm block, or a list of the
names of the unqiue labels like this:

asm (
"%[simple_func_loop_start]:\n\t"
"    Do Assembly Stuff    \n\t"
"    Loop to %[simple_func_loop_start]"
: [x] "=r" (x)
: [b] "r" (b), [c] "r" (c)
: "r0", "r1", "memory"
: "simple_func_loop_start" );

Is what I have described above the project described in the projects file?
Maybe we could have a little discussion about the best syntax for this
extension?

Jonah

In the Projects file:

===
Generated unique labels. Have some way of generating distinct
labels for use in extended asm statements. I don't know what a
good syntax would be.
===

----- Original Message -----
From: "James Buchanan" <jamesbuch@iprimus.com.au>
To: "Richard Henderson" <rth@redhat.com>
Cc: <gcc@gcc.gnu.org>
Sent: Friday, January 03, 2003 12:43 AM
Subject: Re: Generated unique labels


> This means a different label syntax for different assembler languages
> doesn't it?  So the function needs to know an "assembly context"
> depending on what the target CPU is for the program.
>
> At 04:25 PM 1/2/2003 -0800, Richard Henderson wrote:
> >On Mon, Dec 30, 2002 at 03:31:30AM +1100, James Buchanan wrote:
> > > Has this been done yet?  If not has anyone been assigned to it?
> >
> >No and no.  Best option is to use assembler local labels.
> >
> >
> >r~

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Generated unique labels
  2003-01-03 12:28     ` Jonah
@ 2003-01-03 17:34       ` Richard Henderson
  2003-01-03 18:16         ` Jonah
  0 siblings, 1 reply; 10+ messages in thread
From: Richard Henderson @ 2003-01-03 17:34 UTC (permalink / raw)
  To: Jonah; +Cc: James Buchanan, Joseph D. Wagner, gcc

On Fri, Jan 03, 2003 at 12:27:49PM -0000, Jonah wrote:
> I am a bit confused by where this conversation is going. Isn't the Projects
> list item referring to having labels in inline assembler. I will give you
> the problem I was having which I thought was the same problem as the
> projects file item.
> 
> int simple_func (int b, int c)
> {
>     int x;
> asm (
> "simple_func_loop_start:\n\t"
> "    Do Assebly Stuff    \n\t"
> "    LOOP to simple_func_loop_start"
> : [x] "=r" (x)
> : [b] "r" (b), [c] "r" (c)
> : "r0", "r1", "memory" );

Written using assembler local labels as

	"0:\n"
	"	Do Assembly Stuff\n"
	"	LOOP 0b"


r~

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Generated unique labels
  2003-01-03 17:34       ` Richard Henderson
@ 2003-01-03 18:16         ` Jonah
  2003-01-03 19:37           ` Joseph S. Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Jonah @ 2003-01-03 18:16 UTC (permalink / raw)
  To: Richard Henderson; +Cc: James Buchanan, Joseph D. Wagner, gcc

Thank you for the clear-up. You connecting the dots along with me reading a
bit more documention :-) made me understand the problem I have. I need an
assembler which supports that notation of labels, fortunately I can add
local labels to my assembler.

Are there other assemblers which need the support, is that why it is in the
projects file? If not, should this item be removed from the projects list so
that developers don't spend time working on projects that are not needed.

Jonah

----- Original Message -----
From: "Richard Henderson" <rth@redhat.com>
To: "Jonah" <gccmail@whalesolutions.ca>
Cc: "James Buchanan" <jamesbuch@iprimus.com.au>; "Joseph D. Wagner"
<wagnerjd@prodigy.net>; <gcc@gcc.gnu.org>
Sent: Friday, January 03, 2003 5:34 PM
Subject: Re: Generated unique labels


> On Fri, Jan 03, 2003 at 12:27:49PM -0000, Jonah wrote:
> > I am a bit confused by where this conversation is going. Isn't the
Projects
> > list item referring to having labels in inline assembler. I will give
you
> > the problem I was having which I thought was the same problem as the
> > projects file item.
> >
> > int simple_func (int b, int c)
> > {
> >     int x;
> > asm (
> > "simple_func_loop_start:\n\t"
> > "    Do Assebly Stuff    \n\t"
> > "    LOOP to simple_func_loop_start"
> > : [x] "=r" (x)
> > : [b] "r" (b), [c] "r" (c)
> > : "r0", "r1", "memory" );
>
> Written using assembler local labels as
>
> "0:\n"
> " Do Assembly Stuff\n"
> " LOOP 0b"
>
>
> r~

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Generated unique labels
  2003-01-03 18:16         ` Jonah
@ 2003-01-03 19:37           ` Joseph S. Myers
  0 siblings, 0 replies; 10+ messages in thread
From: Joseph S. Myers @ 2003-01-03 19:37 UTC (permalink / raw)
  To: Jonah; +Cc: gcc

On Fri, 3 Jan 2003, Jonah wrote:

> Are there other assemblers which need the support, is that why it is in the
> projects file? If not, should this item be removed from the projects list so
> that developers don't spend time working on projects that are not needed.

It's in the projects list because it was in the old PROJECTS file in the
distribution and we were moving miscellaneous text files in the
distribution into the web pages or main documentation.  The list of stuff
from the old PROJECTS file needs reviewing by people with long (pre-EGCS)  
historical familiarity with GCC internals to remove what's no longer
relevant.  Likewise the list from the old PROBLEMS file which is even
worse.  But both the main projects list and the list for beginners need
reviewing generally.

I don't think any of the proposed extensions from the old PROJECTS file
are now desirable.  They date from when GCC was doing its own version of
"embrace and extend" rather than needing extensions to be very well
justified in terms of increased expressive power, clear documentation and
well-defined interactions with all standard features and other extensions.

-- 
Joseph S. Myers
jsm28@cam.ac.uk

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Generated unique labels
@ 2003-01-07 16:29 Joern Rennecke
  0 siblings, 0 replies; 10+ messages in thread
From: Joern Rennecke @ 2003-01-07 16:29 UTC (permalink / raw)
  To: Jonah; +Cc: Richard Henderson, James Buchanan, Joseph D. Wagner, gcc

> I am a bit confused by where this conversation is going. Isn't the Projects
> list item referring to having labels in inline assembler. I will give you
> the problem I was having which I thought was the same problem as the
> projects file item.
>
> int simple_func (int b, int c)
> {
>     int x;
> asm (
> "simple_func_loop_start:\n\t"
> "    Do Assebly Stuff    \n\t"
> "    LOOP to simple_func_loop_start"
> : [x] "=r" (x)
> : [b] "r" (b), [c] "r" (c)
> : "r0", "r1", "memory" );
>
>     return x;
> }

I'm a bit surprised that this conversation is going on at all.  We got the
%= output specifier which is perfectly fine to handle this problem, and it
is documented in md.texi.

int simple_func (int b, int c)
{ 
    int x;
asm ( 
"simple_func_loop_start%=:\n\t"
"    Do Assebly Stuff    \n\t"
"    LOOP to simple_func_loop_start%="
: [x] "=r" (x)
: [b] "r" (b), [c] "r" (c)
: "r0", "r1", "memory" );

    return x;
} 

-- 
--------------------------
SuperH (UK) Ltd.
2410 Aztec West / Almondsbury / BRISTOL / BS32 4QX
T:+44 1454 465658

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-01-07 15:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-29 11:47 Generated unique labels James Buchanan
2003-01-02  7:42 ` Joseph D. Wagner
2003-01-03  0:43   ` James Buchanan
2003-01-03  0:25 ` Richard Henderson
2003-01-03  0:44   ` James Buchanan
2003-01-03 12:28     ` Jonah
2003-01-03 17:34       ` Richard Henderson
2003-01-03 18:16         ` Jonah
2003-01-03 19:37           ` Joseph S. Myers
2003-01-07 16:29 Joern Rennecke

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).