Re: Porting HP C from Alpha to Itanium - __DIVG_C
- From: John Reagan <john.reagan@xxxxxx>
- Date: Thu, 31 May 2007 18:02:32 -0400
Larry Kilgallen wrote:
Thanks, John. I am enough of a non-expert to not know about the
/ROUNDING_MODE=CHOPPED. Perhaps creating a new module would be
the best way to have common source between Alpha and IPF.
Well, there will be some conditionalization in any case.
As I mentioned, on Alpha each module can have its own /ROUNDING_MODE setting and those rounding modes are encoded directly into each instruction. Multiple modes can co-exist in a single application without any additional overhead.
On Itanium, there is one "global" setting in the FPCR (floating point control register) [there is actually more than one, but that isn't relevant to this discussion since the generated code only uses one of them]. We couldn't implement it like we do on Alpha.
So each module records its "preferred" floating settings (VAX vs IEEE, precision, rounding-mode) in the object file. The linker uses the floating settings from the module with the main entry point as the "whole program" setting. This is recorded in the .EXE and is used by the image activator prior to the start of your program. We did this so things like LIB$INITIALIZE routines, AST routines, etc. can all have consistent floating settings. You wouldn't want your timer AST routine to have different settings depending on which piece of code was interrupted by the timer AST, right?
What this means is that for modules that don't contain the main entry point, the settings of /ROUNDING_MODE and /IEEE_MODE are essentially worthless on I64. We didn't want to start automatically inserting calls to SYS$IEEE_SET_FP_xxx into every single routine since most people don't do this style of coding. C does provide /CHECK=FP_MODE to check that the floating settings at run-time match the /ROUNDING_MODE and /IEEE_MODE set at compile-time. You have to insert calls to SYS$IEEE_SET_FP_xxx into your code to set the settings to your liking, do the operation(s) desired, and set them back. You also can't use /CHECK=FP_MODE anymore since that check is performed in the routine prolog BEFORE you get a chance to change the settings via SYS$IEEE_SET_FP_xxx.
So you can conditionalize the current code:
#if alpha
- use __DIVG_C
#endif
#if i64
- call SYS$IEEE_SET_FP_ROUNDING_MODE to truncate (ie chopped)
- use the regular division operator
- restore prior rounding mode
#endif
or if you make a separate module that is compiled with /ROUNDING=CHOPPED, you still have
#if i64
- call SYS$IEEE_SET_FP_ROUNDING_MODE to truncate (ie chopped)
#endif
- use the regular division operator
#if i64
- restore prior rounding mode
#endif
--
John Reagan
OpenVMS Pascal/Macro-32/COBOL Project Leader
Hewlett-Packard Company
.
- Follow-Ups:
- Re: Porting HP C from Alpha to Itanium - __DIVG_C
- From: Albrecht Schlosser
- Re: Porting HP C from Alpha to Itanium - __DIVG_C
- From: Richard Maher
- Re: Porting HP C from Alpha to Itanium - __DIVG_C
- Prev by Date: Re: OpenVMS Support for C-class Blades
- Next by Date: Re: Upgrade to Vista from XP ? Yes or No
- Previous by thread: Re: OpenVMS Support for C-class Blades
- Next by thread: Re: Porting HP C from Alpha to Itanium - __DIVG_C
- Index(es):
Relevant Pages
|