mutliple abi attributes

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

mutliple abi attributes

Postby notzed » Sat Aug 02, 2014 6:48 am

How hard would it be to add a function attribute to gcc that specified different abis?

The main use would be to specify one which changes most of the registers to callee saved so that calling small library functions wont have the impact of requiring work registers to be unnecessarily saved and restored from an application "leaf" function. It would be an interlock so that any function with it set could only call similarly attributed functions (or ones with further restrictions).
notzed
 
Posts: 331
Joined: Mon Dec 17, 2012 12:28 am
Location: Australia

Re: mutliple abi attributes

Postby aolofsson » Sun Aug 03, 2014 4:59 pm

notzed,

I agree that this would be very useful for leaf cells. It is certainly possible with a user specified flag. We'll see what we can do.

Check out -mfp-mode in the current e-gcc flags.

https://gcc.gnu.org/onlinedocs/gcc-4.7. ... tions.html

Andreas
User avatar
aolofsson
 
Posts: 1005
Joined: Tue Dec 11, 2012 6:59 pm
Location: Lexington, Massachusetts,USA

Re: mutliple abi attributes

Postby notzed » Mon Aug 04, 2014 11:25 am

Cool, i'll keep an eye out.

Yeah i've had a good play with most of the flags. fp-mode is definitely one of the most important particularly if one mixes any integer/float.
notzed
 
Posts: 331
Joined: Mon Dec 17, 2012 12:28 am
Location: Australia

Re: mutliple abi attributes

Postby timpart » Wed Aug 06, 2014 11:46 am

I must admit to being curious as to whether making the Stack Pointer R7 would make a significant difference to code size. Currently all saving and restoring of registers in a function uses word sized instructions because SP isn't one of R0 to R7.
Function starts are aligned to word boundaries at the moment and I can't find a way of reducing that. (GCC has options to specify alignment but using them makes GCC create an additional align instruction after aligning to a word.)

Tim
timpart
 
Posts: 302
Joined: Mon Dec 17, 2012 3:25 am
Location: UK

Re: mutliple abi attributes

Postby amylaar » Wed Aug 06, 2014 1:41 pm

aolofsson wrote:notzed,

I agree that this would be very useful for leaf cells. It is certainly possible with a user specified flag. We'll see what we can do.

Check out -mfp-mode in the current e-gcc flags.

https://gcc.gnu.org/onlinedocs/gcc-4.7. ... tions.html

Andreas


An attribute for the -mfp-mode would be relatively straightforward:
moving epiphany_normal_fp_rounding and epiphany_normal_fp_mode
mostly to struct machine_func, adjusting all the code that reference these,
and addd copying code / move initialization code as required.
Well, I'd have to check if I need to do something about the floatunssisf2 expander
as its condition will become dependent on the function declaration.

Changing the available register set is more troublesome, as usually register allocation
is initialized just once per translation unit. I think I would have to use
SWITCHABLE_TARGET to make that work.
amylaar
 
Posts: 31
Joined: Thu Jan 10, 2013 3:06 pm

Re: mutliple abi attributes

Postby amylaar » Wed Aug 06, 2014 1:43 pm

timpart wrote:I must admit to being curious as to whether making the Stack Pointer R7 would make a significant difference to code size. Currently all saving and restoring of registers in a function uses word sized instructions because SP isn't one of R0 to R7.
Function starts are aligned to word boundaries at the moment and I can't find a way of reducing that. (GCC has options to specify alignment but using them makes GCC create an additional align instruction after aligning to a word.)

Tim


That would cause trouble with interrupts, unless all of them use the changed stack pointer as well.
amylaar
 
Posts: 31
Joined: Thu Jan 10, 2013 3:06 pm

Re: mutliple abi attributes

Postby notzed » Thu Aug 07, 2014 10:06 am

timpart wrote:I must admit to being curious as to whether making the Stack Pointer R7 would make a significant difference to code size. Currently all saving and restoring of registers in a function uses word sized instructions because SP isn't one of R0 to R7.
Function starts are aligned to word boundaries at the moment and I can't find a way of reducing that. (GCC has options to specify alignment but using them makes GCC create an additional align instruction after aligning to a word.)

Tim


I thought about r7; I think the loss of the r6-r7 pair is the main reason it wouldn't be a good idea. Not that the compiler is very good at exploiting dword pairs yet; but it would affect save/restore.

The only thing I can think of to help r0-r7 use for codesize would be to make r4-r7 caller-saved/scratch. Right now it's cheaper for most leaf functions to just use r16+ rather than save and restore r4-r7 so they can be used.

I'd probably also make r12 a constant because the r12-r13 pair can never be dword load/saved: thus wasting any stack operations if r12 needs saving (thus making it less useful than it might be). Since saving lr will also save r15, make r15 the callee-saved 'ip' scratch.

I have a fairly detailed draft post about a "better" abi but it seemed a bit pointless to post it without anything hard to back it up with (like a gcc patch).

Changing the available register set is more troublesome, as usually register allocation
is initialized just once per translation unit. I think I would have to use
SWITCHABLE_TARGET to make that work.


Ok. It's a pity because it sounds like a lot of work and it might not be practical to use for some potential but unproven benefit.
notzed
 
Posts: 331
Joined: Mon Dec 17, 2012 12:28 am
Location: Australia


Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 9 guests

cron