Re: Forcing inline assembly code to be produced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kristis Makris writes:
 > >  > In a more complicated example, I'm trying to position uncommonly used
 > >  > code in a separate memory region for better cache locality. One of the
 > >  > inline assembly statements I'm using is not produced. This results in
 > >  > not changing back to the ".text" section, resulting in further assembler
 > >  > problems as described in:
 > > 
 > > Use an attribute to set the section.
 > > 
 > >          extern void foobar (void) __attribute__ ((section ("bar")));
 > > 
 > >      puts the function `foobar' in the `bar' section.
 > 
 > This definition method is not granular enough. I don't want the entire
 > function in the 'bar' section. I want the entire function in the 'text'
 > section but in some cases in the function where there is an if-statement
 > like this:
 > 
 > if (something) {
 > /* body /*
 > }
 > 
 > ...I want to place the body, which is written in C, in the 'bar'
 > section.

So why not put the body in another function if you want to do that?
gcc reorders basic blocks, and so there's no guarantee that your
section changes are going to come out in any order with respect to the
code.

 > 
 > if (something) {
 >   relocate_pre("if_something");
 >   /* body */
 >   relocate_post();
 > }
 > 
 > And then defining:
 > 
 > #define relocate_pre(name) \
 >    asm volatile ( "jmp 1f\n\t" \
 >  	          ".subsection 2\n\t" \
 >                   ".section .bar\n" \
 >   		  "hcu_uncommon_section_" name ":\n\t" \
 >                   "1:\n\t" );
 > 
 > #define relocate_post() \
 >    asm volatile( "jmp 1f\n\t" \
 > 		 ".text\n\t" \
 >                  "1:\n" );

Which won't work, becasue of the rule about jumping into and out of
inline asms.

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux