From 0021fd81bc9cafd5dc5055c4c4353e3ee0b21c8d Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sat, 17 Jun 2023 18:13:31 -0500 Subject: [PATCH] #pragma float: Generate code in the .root file to set the FPE slot. This allows valid FPE-using programs to be compiled using only #pragma float, with no changes needed to the code itself. The slot-setting code is only generated if the slot is 1..7, and even then it can be overridden by calling setfpeslot(), so this should not cause compatibility problems for existing code. --- Header.pas | 2 +- Native.pas | 9 +++++++++ Scanner.pas | 2 +- cc.notes | 10 ++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Header.pas b/Header.pas index c75189a..48813f0 100644 --- a/Header.pas +++ b/Header.pas @@ -18,7 +18,7 @@ uses CCommon, MM, Scanner, Symbol, CGI; {$segment 'HEADER'} const - symFileVersion = 40; {version number of .sym file format} + symFileVersion = 41; {version number of .sym file format} var inhibitHeader: boolean; {should .sym includes be blocked?} diff --git a/Native.pas b/Native.pas index 4a193cb..780e3f4 100644 --- a/Native.pas +++ b/Native.pas @@ -2546,6 +2546,15 @@ procedure InitFile {keepName: gsosOutStringPtr; keepFlag: integer; partial: bool {set the data bank register} SetDataBank; + {set FPE slot, if using FPE} + if floatCard = 1 then + if floatSlot in [1..7] then begin + CnOut(m_pea); + CnOut2(floatSlot); + CnOut(m_jsl); + RefName(@'SETFPESLOT', 0, 3, 0); + end; {if} + {write JSL to main entry point} CnOut(m_jsl); if rtl then diff --git a/Scanner.pas b/Scanner.pas index 3b69e9d..b186283 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -3148,7 +3148,7 @@ var else Error(18); if token.kind in [intconst,uintconst,ushortconst] then begin - floatSlot := $C080 | (token.ival << 4); + floatSlot := token.ival; NextToken; end {if} else diff --git a/cc.notes b/cc.notes index 417150c..035d9dc 100644 --- a/cc.notes +++ b/cc.notes @@ -58,6 +58,8 @@ Updated by Stephen Heumann and Kelvin Sherlock, 2017-2023 19. The code generated for certain operations has been improved. + 20. The slot parameter to #pragma float now sets the FPE slot. + 2.1.1 B3 1. Bugs squashed. See bug notes, below. 2.1.0 1. Bugs squashed. See bug notes, below. @@ -197,6 +199,8 @@ If precompiled headers are being used, #pragma expand will not print the tokens p. 258 +The slot parameter to #pragma float is now used to set the FPE slot. See "Changes to #pragma float," below. + The #pragma ignore directive supports several new bits. Bit 1 affects the interpretation of multi-character character constants. See "Multi-Character Character Constants," below. @@ -680,6 +684,12 @@ ORCA/C can perform certain optimizations on floating-point computations based on A new #pragma optimize bit has now been introduced to control this behavior. Setting bit 7 (a value of 128) allows floating-point math optimizations that may violate the IEEE standard. It currently only has an effect if #pragma optimize bit 0 or bit 4 is also set. If bit 7 is not set, these floating-point optimizations will not be performed. This allows most aspects of intermediate code peephole optimization and common subexpression elimination to be used while preserving IEEE floating-point behavior. +Changes to #pragma float +------------------------ + +If #pragma float is used to generate code for an FPE card, the slot number given in the pragma is now used to configure the FPE slot. This removes the need to call setfpeslot() in the program's code, although that can still be done to override the setting in #pragma float. If the specified slot number is not in the range 1-7, it will be ignored and setfpeslot() will still need to be used. You must also call setfpeslot() if you wish to use the FPE in any of the special types of programs that can be created using other pragmas. + + Additions to #pragma ignore ---------------------------