public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* GNU Assembler Start of Function & basic block
@ 2007-12-31 22:06 Balaji V. Iyer
  2008-01-01  5:47 ` Ramana Radhakrishnan
  0 siblings, 1 reply; 7+ messages in thread
From: Balaji V. Iyer @ 2007-12-31 22:06 UTC (permalink / raw)
  To: binutils

Hello Everyone,
	I have a question regarding GNU Assembler.

I am currently working with the OpenRISC port of GNU Binutils (2.11.92)
and I am making some modifications to the ISA. I want to insert special
instructions at the beginning and end of each basic block AND another
set of special instructions at the beginning and end of function (I
tried to do it in GCC and I was unsuccessful in representing these
instructions in the machine description).

I looked through the GNU Assembler Internals manual and I couldn't find
any specialized functions that can be used to access the start and end
of each basic block OR function-call (I may have missed something...).
Can someone please point me in the right direction?

Any help is greatly appreciated!

Thanks in advance,

Yours Sincerely,

Balaji V. Iyer.

-- 
 
Balaji V. Iyer
PhD Student, 
Center for Efficient, Scalable and Reliable Computing,
Department of Electrical and Computer Engineering,
North Carolina State University.

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

* Re: GNU Assembler Start of Function & basic block
  2007-12-31 22:06 GNU Assembler Start of Function & basic block Balaji V. Iyer
@ 2008-01-01  5:47 ` Ramana Radhakrishnan
  2008-01-01  6:10   ` Balaji V. Iyer
  0 siblings, 1 reply; 7+ messages in thread
From: Ramana Radhakrishnan @ 2008-01-01  5:47 UTC (permalink / raw)
  To: Balaji V. Iyer; +Cc: binutils

Hi,


On Jan 1, 2008 3:35 AM, Balaji V. Iyer <bviyer@ncsu.edu> wrote:
> Hello Everyone,
>        I have a question regarding GNU Assembler.
>
> I am currently working with the OpenRISC port of GNU Binutils (2.11.92)
> and I am making some modifications to the ISA. I want to insert special
> instructions at the beginning and end of each basic block AND another
> set of special instructions at the beginning and end of function (I
> tried to do it in GCC and I was unsuccessful in representing these
> instructions in the machine description).

I don't think the assembler can help you figure out the basic blocks
by default. You would have to write code to detect basic blocks and
then add these instructions.  I'd suggest you use GCC for such
instrumentation.

For functions its easy - you have to modify your expand_{pro/epi}logue
functions for doing this if you have RTL based prologue and epilogues
based on command line switches.

For basic blocks you might choose to look at the coverage options to
figure this out (fprofile-arcs and their friends).Or you could write a
pass that was in cfglayout mode to insert these special instructions.
Anyways this discussion is more relevant to the GCC list , so you
could continue it there.

HTH,

cheers
Ramana

>
> I looked through the GNU Assembler Internals manual and I couldn't find
> any specialized functions that can be used to access the start and end
> of each basic block OR function-call (I may have missed something...).
> Can someone please point me in the right direction?
>
> Any help is greatly appreciated!
>
> Thanks in advance,
>
> Yours Sincerely,
>
> Balaji V. Iyer.
>
> --
>
> Balaji V. Iyer
> PhD Student,
> Center for Efficient, Scalable and Reliable Computing,
> Department of Electrical and Computer Engineering,
> North Carolina State University.
>
>



-- 
Ramana Radhakrishnan

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

* RE: GNU Assembler Start of Function & basic block
  2008-01-01  5:47 ` Ramana Radhakrishnan
@ 2008-01-01  6:10   ` Balaji V. Iyer
  2008-01-08 14:24     ` Nick Clifton
  0 siblings, 1 reply; 7+ messages in thread
From: Balaji V. Iyer @ 2008-01-01  6:10 UTC (permalink / raw)
  To: 'Ramana Radhakrishnan'; +Cc: binutils

Dear Ramana,
	Thank you very much for your response. I am doing it through
assembler because I want to put specalized control instructions that I
have created to explain the register usage to the processor. These
instructions give information about register usage and liveness
information to the processor. 
	Now, can these specialized instructions be conveyed in the
machien description of GCC? I have looked through the MD documentation
in the internals document and I hvae not found a way to do so.   
	I have noticed that in the assembly passed into the assembler
from GCC, every basic block start is starting with a label. Does it do
anything special (like set a variable or something like that) to
indicate that it has seen a label? Also, any machine dependent function
that can I call during this phase? Also, does it do something like this
in the beginning of a function (since it is sort of a basic block start
in itself)

Thank you very much in advance for all your help...

Yours Sincerely,

Balaji V. Iyer.

-- 
 
Balaji V. Iyer
PhD Student, 
Center for Efficient, Scalable and Reliable Computing,
Department of Electrical and Computer Engineering,
North Carolina State University.


-----Original Message-----
From: Ramana Radhakrishnan [mailto:ramana.r@gmail.com] 
Sent: Tuesday, January 01, 2008 12:47 AM
To: Balaji V. Iyer
Cc: binutils@sourceware.org
Subject: Re: GNU Assembler Start of Function & basic block

Hi,


On Jan 1, 2008 3:35 AM, Balaji V. Iyer <bviyer@ncsu.edu> wrote:
> Hello Everyone,
>        I have a question regarding GNU Assembler.
>
> I am currently working with the OpenRISC port of GNU Binutils 
> (2.11.92) and I am making some modifications to the ISA. I want to 
> insert special instructions at the beginning and end of each basic 
> block AND another set of special instructions at the beginning and end

> of function (I tried to do it in GCC and I was unsuccessful in 
> representing these instructions in the machine description).

I don't think the assembler can help you figure out the basic blocks by
default. You would have to write code to detect basic blocks and then
add these instructions.  I'd suggest you use GCC for such
instrumentation.

For functions its easy - you have to modify your expand_{pro/epi}logue
functions for doing this if you have RTL based prologue and epilogues
based on command line switches.

For basic blocks you might choose to look at the coverage options to
figure this out (fprofile-arcs and their friends).Or you could write a
pass that was in cfglayout mode to insert these special instructions.
Anyways this discussion is more relevant to the GCC list , so you could
continue it there.

HTH,

cheers
Ramana

>
> I looked through the GNU Assembler Internals manual and I couldn't 
> find any specialized functions that can be used to access the start 
> and end of each basic block OR function-call (I may have missed
something...).
> Can someone please point me in the right direction?
>
> Any help is greatly appreciated!
>
> Thanks in advance,
>
> Yours Sincerely,
>
> Balaji V. Iyer.
>
> --
>
> Balaji V. Iyer
> PhD Student,
> Center for Efficient, Scalable and Reliable Computing, Department of 
> Electrical and Computer Engineering, North Carolina State University.
>
>



--
Ramana Radhakrishnan

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

* Re: GNU Assembler Start of Function & basic block
  2008-01-01  6:10   ` Balaji V. Iyer
@ 2008-01-08 14:24     ` Nick Clifton
  0 siblings, 0 replies; 7+ messages in thread
From: Nick Clifton @ 2008-01-08 14:24 UTC (permalink / raw)
  To: Balaji V. Iyer; +Cc: 'Ramana Radhakrishnan', binutils

Hi Balaji,

> 	I am doing it through
> assembler because I want to put specalized control instructions that I
> have created to explain the register usage to the processor. These
> instructions give information about register usage and liveness
> information to the processor. 

This is definitely something that can only be done in the compiler, not the 
assembler.

> 	Now, can these specialized instructions be conveyed in the
> machine description of GCC? I have looked through the MD documentation
> in the internals document and I hvae not found a way to do so.   

Yes.  Ask on the gcc mailing lists about this.  Also have a look at how UNSPEC 
patterns are used for various architectures.  Plus you may not need to put this 
into the machine description.  You may be able to include the code to generate 
the instructions in the backend's function prologue and epilogue generating 
code.  You may also be able to use some of the compiler's support for the GCOV 
tool in order to add per-basic-block instructions.

Cheers
   Nick

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

* Re: GNU Assembler Start of Function & basic block
  2010-10-06 23:05 ` Richard Henderson
@ 2010-10-07  2:46   ` Quentin Neill
  0 siblings, 0 replies; 7+ messages in thread
From: Quentin Neill @ 2010-10-07  2:46 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Emílio Wuerges, binutils

On Wed, Oct 6, 2010 at 6:05 PM, Richard Henderson <rth@redhat.com> wrote:
> On 10/06/2010 02:10 PM, Emílio Wuerges wrote:
>> I need to know the start and end address of each basic block.
>>
>> I'm planning to hack GCC to include comments in the beginning of each BB
>> and then later use the assembler to find these addresses.
>>
>> I think I'm good with the GCC part, but I'm lost with assembler part.
>> Can someone point me where should I hook my hack?
>
> If you do the right bit in gcc you don't need to hack the assembler at all.
>
>        .loc  FILENO LINENO [COLUMN] [basic_block] [prologue_end] \
>              [epilogue_begin] [is_stmt VALUE] [isa VALUE] \
>              [discriminator VALUE]
>
> What you need to do is hack gcc dwarf2 debug output to mark the
> basic blocks via the extensions to the .loc directive.  At which
> point you'll be able to find your basic block boundaries by
> reading the information stored in the .debug_line section and
> documented in the dwarf specifications.
>
>
> r~
>

At the risk of merely cheering on Richard, I also don't think you want
to hack the assembler.  You want to do this symbolically and then let
the assembler worry about addresses.

See this discussion
http://sourceware.org/ml/binutils/2010-06/msg00166.html for reasons.
-- 
Quentin

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

* Re: GNU Assembler Start of Function & basic block
  2010-10-06 21:10 Emílio Wuerges
@ 2010-10-06 23:05 ` Richard Henderson
  2010-10-07  2:46   ` Quentin Neill
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2010-10-06 23:05 UTC (permalink / raw)
  To: Emílio Wuerges; +Cc: binutils

On 10/06/2010 02:10 PM, Emílio Wuerges wrote:
> I need to know the start and end address of each basic block.
> 
> I'm planning to hack GCC to include comments in the beginning of each BB
> and then later use the assembler to find these addresses.
> 
> I think I'm good with the GCC part, but I'm lost with assembler part.
> Can someone point me where should I hook my hack?

If you do the right bit in gcc you don't need to hack the assembler at all.

        .loc  FILENO LINENO [COLUMN] [basic_block] [prologue_end] \
              [epilogue_begin] [is_stmt VALUE] [isa VALUE] \
              [discriminator VALUE]

What you need to do is hack gcc dwarf2 debug output to mark the
basic blocks via the extensions to the .loc directive.  At which
point you'll be able to find your basic block boundaries by 
reading the information stored in the .debug_line section and
documented in the dwarf specifications.


r~

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

* Re: GNU Assembler Start of Function & basic block
@ 2010-10-06 21:10 Emílio Wuerges
  2010-10-06 23:05 ` Richard Henderson
  0 siblings, 1 reply; 7+ messages in thread
From: Emílio Wuerges @ 2010-10-06 21:10 UTC (permalink / raw)
  To: binutils

Hello,

I was digging Binutils mailing list archives to see if I could find
the answer for my problem and I found
someone with the exact same problem 2 years ago.

I need to know the start and end address of each basic block.

I'm planning to hack GCC to include comments in the beginning of each BB
and then later use the assembler to find these addresses.

I think I'm good with the GCC part, but I'm lost with assembler part.
Can someone point me where should I hook my hack?

--------------------------------
From binutils-return-53599-listarch-binutils=sources dot redhat dot
com at sourceware dot org Tue Jan 01 06:10:36 2008
From: "Balaji V dot  Iyer" <bviyer at ncsu dot edu>
To: "'Ramana Radhakrishnan'" <ramana dot r at gmail dot com>
Cc: binutils@sourceware.org
Subject: Re: GNU Assembler Start of Function & basic block

Dear Ramana,
	Thank you very much for your response. I am doing it through
assembler because I want to put specalized control instructions that I
have created to explain the register usage to the processor. These
instructions give information about register usage and liveness
information to the processor.
	Now, can these specialized instructions be conveyed in the
machien description of GCC? I have looked through the MD documentation
in the internals document and I hvae not found a way to do so.
	I have noticed that in the assembly passed into the assembler
from GCC, every basic block start is starting with a label. Does it do
anything special (like set a variable or something like that) to
indicate that it has seen a label? Also, any machine dependent function
that can I call during this phase? Also, does it do something like this
in the beginning of a function (since it is sort of a basic block start
in itself)

Thank you very much in advance for all your help...

Yours Sincerely,

Balaji V. Iyer.

-- 

Balaji V. Iyer
PhD Student,
Center for Efficient, Scalable and Reliable Computing,
Department of Electrical and Computer Engineering,
North Carolina State University.


-----Original Message-----
From: Ramana Radhakrishnan [mailto:ramana.r@gmail.com]
Sent: Tuesday, January 01, 2008 12:47 AM
To: Balaji V. Iyer
Cc: binutils@sourceware.org
Subject: Re: GNU Assembler Start of Function & basic block

Hi,


On Jan 1, 2008 3:35 AM, Balaji V. Iyer <bviyer@ncsu.edu> wrote:
> Hello Everyone,
>        I have a question regarding GNU Assembler.
>
> I am currently working with the OpenRISC port of GNU Binutils
> (2.11.92) and I am making some modifications to the ISA. I want to
> insert special instructions at the beginning and end of each basic
> block AND another set of special instructions at the beginning and end

> of function (I tried to do it in GCC and I was unsuccessful in
> representing these instructions in the machine description).

I don't think the assembler can help you figure out the basic blocks by
default. You would have to write code to detect basic blocks and then
add these instructions.  I'd suggest you use GCC for such
instrumentation.

For functions its easy - you have to modify your expand_{pro/epi}logue
functions for doing this if you have RTL based prologue and epilogues
based on command line switches.

For basic blocks you might choose to look at the coverage options to
figure this out (fprofile-arcs and their friends).Or you could write a
pass that was in cfglayout mode to insert these special instructions.
Anyways this discussion is more relevant to the GCC list , so you could
continue it there.

HTH,

cheers
Ramana

>
> I looked through the GNU Assembler Internals manual and I couldn't
> find any specialized functions that can be used to access the start
> and end of each basic block OR function-call (I may have missed
something...).
> Can someone please point me in the right direction?
>
> Any help is greatly appreciated!
>
> Thanks in advance,
>
> Yours Sincerely,
>
> Balaji V. Iyer.
>
> --
>
> Balaji V. Iyer
> PhD Student,
> Center for Efficient, Scalable and Reliable Computing, Department of
> Electrical and Computer Engineering, North Carolina State University.
>
>



--
Ramana Radhakrishnan
-- 
Emilio Wuerges
LAPS - Laboratorio de Automacao de Projeto de Sistemas
UFSC - Universidade Federal de Santa Catarina
Brasil

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

end of thread, other threads:[~2010-10-07  2:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-31 22:06 GNU Assembler Start of Function & basic block Balaji V. Iyer
2008-01-01  5:47 ` Ramana Radhakrishnan
2008-01-01  6:10   ` Balaji V. Iyer
2008-01-08 14:24     ` Nick Clifton
2010-10-06 21:10 Emílio Wuerges
2010-10-06 23:05 ` Richard Henderson
2010-10-07  2:46   ` Quentin Neill

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