[Cfp-interest] Floating-point extensions for C report - part 1 - local flags

Ian McIntosh ianm at ca.ibm.com
Wed Feb 1 16:04:19 PST 2012


I don't know if we need to do anything about local versus global flags, but
on PPCs

	code before
	{
	#pragma  use_local_floating_point_flags	/* or whatever syntax is
chosen */
	     do floating point and other operations
	     if (some exception flags are set)
	     {
	          handle the exception
	     }
	}
	code after

would be implemented something like the text after "==>" in

	code before
	{
	#pragma  use_local_floating_point_flags	==>  save the Floating
Point Status and Control Register, and clear the exception flags in it
	     do floating point and other operations
	     if (some exception flags are set)
	     {
	          handle the exception
	     }
	}						==>  restore the Floating Point
Status and Control Register that was saved above
	code after

The code in the block would not see any exception flags set by the code
before, and the code after would not see any exception flags set by the
block, but would see any set by the code before.

This could be done manually by calling a "save flags" function and a "clear
flags" function at the start, and a "restore flags" function at the end.

In C++ there would also need to be a destructor to do the restore if a
throw was done in the block or anything it called.

- Ian McIntosh          IBM Canada Lab         Compiler Back End Support
and Development



|------------>
| From:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |David Hough CFP <pcfp at oakapple.net>                                                                                                               |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |cfp-interest at ucbtest.org, jaswthomas at sbcglobal.net                                                                                                |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |02/01/2012 05:23 PM                                                                                                                               |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Re: [Cfp-interest] Floating-point extensions for C report - part 1	- local flags                                                                   |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Sent by:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |cfp-interest-bounces at oakapple.net                                                                                                                 |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|





> Do we need a general local flag mechanism

It might be a helpful programmer abstraction, but I don't think it would
have
any efficiency value on typical current hardware.    The local flags would
be implemented in the same hardware register as the global flags have been,
so the real global flags would have to be maintained in a software
location...
what about a code block that wanted to look at a local underflow flag and
a global invalid flag?

For that fraction of the C universe which is just wants a higher-level
machine-oriented programming language, I suppose the programmer's feature
would just be access to the single global flag register.

So my conclusion at the moment is to stick to the higher level alternate
exception handling idea and leave some kind of local flag as an
implementation option.
_______________________________________________
Cfp-interest mailing list
Cfp-interest at oakapple.net
http://mailman.oakapple.net/mailman/listinfo/cfp-interest


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20120201/852b48ee/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20120201/852b48ee/attachment.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
Url : http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20120201/852b48ee/attachment-0001.gif 


More information about the Cfp-interest mailing list