Changeset 108b2c7


Ignore:
Timestamp:
Nov 27, 2024, 4:01:37 PM (3 weeks ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
71f3d45
Parents:
e25ef8c
Message:

Moved the non-trivial bodies of the power (exponental) functions out of the prelude and into the library. They have caused some issues in debugging there.

Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • libcfa/prelude/builtins.c

    re25ef8c r108b2c7  
    4444typedef unsigned long long __cfaabi_abi_exception_type_t;
    4545
    46 #include <limits.h>                                                                             // CHAR_BIT
    4746#include "../src/virtual.h"
    4847#include "../src/exception.h"
     
    132131} // distribution
    133132
    134 #define __CFA_EXP__() \
    135         if ( y == 0 ) return 1;                                                         /* convention */ \
    136         __CFA_EXP_INT__(                                                                        /* special cases for integral types */ \
    137                 if ( x == 1 ) return 1;                                                 /* base case */ \
    138                 if ( x == 2 ) return x << (y - 1);                              /* positive shifting */ \
    139                 if ( y >= sizeof(y) * CHAR_BIT ) return 0;              /* immediate overflow, negative exponent > 2^size-1 */ \
    140         ) \
    141         typeof(x) op = 1;                                                                       /* accumulate odd product */ \
    142         typeof(x) w = x; /* FIX-ME: possible bug in the box pass changing value argument through parameter */ \
    143         for ( ; y > 1; y >>= 1 ) {                                                      /* squaring exponentiation, O(log2 y) */ \
    144                 if ( (y & 1) == 1 ) op = op * w;                                /* odd ? */ \
    145                 w = w * w; \
    146         } \
    147         return w * op
    148 #define __CFA_EXP_INT__(...) __VA_ARGS__
     133int ?\?( int x, unsigned int y );
     134long int ?\?( long int x, unsigned long int y );
     135long long int ?\?( long long int x, unsigned long long int y );
     136// unsigned computation may be faster and larger
     137unsigned int ?\?( unsigned int x, unsigned int y );
     138unsigned long int ?\?( unsigned long int x, unsigned long int y );
     139unsigned long long int ?\?( unsigned long long int x, unsigned long long int y );
    149140
    150 static inline {
    151         int ?\?( int x, unsigned int y ) { __CFA_EXP__(); }
    152         long int ?\?( long int x, unsigned long int y ) { __CFA_EXP__(); }
    153         long long int ?\?( long long int x, unsigned long long int y ) { __CFA_EXP__(); }
    154         // unsigned computation may be faster and larger
    155         unsigned int ?\?( unsigned int x, unsigned int y ) { __CFA_EXP__(); }
    156         unsigned long int ?\?( unsigned long int x, unsigned long int y ) { __CFA_EXP__(); }
    157         unsigned long long int ?\?( unsigned long long int x, unsigned long long int y ) { __CFA_EXP__(); }
     141forall( OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) {
     142        OT ?\?( OT x, unsigned int y );
     143        OT ?\?( OT x, unsigned long int y );
     144        OT ?\?( OT x, unsigned long long int y );
    158145} // distribution
    159 
    160 #undef __CFA_EXP_INT__
    161 #define __CFA_EXP_INT__(...)
    162 
    163 static inline forall( OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) {
    164         OT ?\?( OT x, unsigned int y ) { __CFA_EXP__(); }
    165         OT ?\?( OT x, unsigned long int y ) { __CFA_EXP__(); }
    166         OT ?\?( OT x, unsigned long long int y ) { __CFA_EXP__(); }
    167 } // distribution
    168 
    169 #undef __CFA_EXP_INT__
    170 #undef __CFA_EXP__
    171146
    172147static inline {
  • libcfa/src/Makefile.am

    re25ef8c r108b2c7  
    4747        gmp.hfa \
    4848        math.trait.hfa \
    49         math.hfa \
    5049        raii.hfa \
    5150        time_t.hfa \
     
    8180        iterator.hfa \
    8281        limits.hfa \
     82        math.hfa \
    8383        memory.hfa \
    8484        parseargs.hfa \
  • tests/.expect/KRfunctions.arm64.txt

    re25ef8c r108b2c7  
    104104    signed int _X1bi_2;
    105105    {
    106         signed int *(*_tmp_cp_ret6)(signed int __param_0, signed int __param_1);
    107         ((void)(_X1xFPi_ii__2=(((void)(_tmp_cp_ret6=_X3f10FFPi_ii__iPiPid__1(3, (&_X1ai_2), (&_X1bi_2), 3.5))) , _tmp_cp_ret6)));
     106        signed int *(*_tmp_cp_ret0)(signed int __param_0, signed int __param_1);
     107        ((void)(_X1xFPi_ii__2=(((void)(_tmp_cp_ret0=_X3f10FFPi_ii__iPiPid__1(3, (&_X1ai_2), (&_X1bi_2), 3.5))) , _tmp_cp_ret0)));
    108108    }
    109109
  • tests/.expect/KRfunctions.x64.txt

    re25ef8c r108b2c7  
    104104    signed int _X1bi_2;
    105105    {
    106         signed int *(*_tmp_cp_ret6)(signed int __param_0, signed int __param_1);
    107         ((void)(_X1xFPi_ii__2=(((void)(_tmp_cp_ret6=_X3f10FFPi_ii__iPiPid__1(3, (&_X1ai_2), (&_X1bi_2), 3.5))) , _tmp_cp_ret6)));
     106        signed int *(*_tmp_cp_ret0)(signed int __param_0, signed int __param_1);
     107        ((void)(_X1xFPi_ii__2=(((void)(_tmp_cp_ret0=_X3f10FFPi_ii__iPiPid__1(3, (&_X1ai_2), (&_X1bi_2), 3.5))) , _tmp_cp_ret0)));
    108108    }
    109109
  • tests/.expect/KRfunctions.x86.txt

    re25ef8c r108b2c7  
    104104    signed int _X1bi_2;
    105105    {
    106         signed int *(*_tmp_cp_ret6)(signed int __param_0, signed int __param_1);
    107         ((void)(_X1xFPi_ii__2=(((void)(_tmp_cp_ret6=_X3f10FFPi_ii__iPiPid__1(3, (&_X1ai_2), (&_X1bi_2), 3.5))) , _tmp_cp_ret6)));
     106        signed int *(*_tmp_cp_ret0)(signed int __param_0, signed int __param_1);
     107        ((void)(_X1xFPi_ii__2=(((void)(_tmp_cp_ret0=_X3f10FFPi_ii__iPiPid__1(3, (&_X1ai_2), (&_X1bi_2), 3.5))) , _tmp_cp_ret0)));
    108108    }
    109109
  • tests/.expect/declarationSpecifier.arm64.txt

    re25ef8c r108b2c7  
    10591059    }
    10601060
    1061     signed int _tmp_cp_ret6;
    1062     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
     1061    signed int _tmp_cp_ret0;
     1062    signed int _X3reti_2 = (((void)(_tmp_cp_ret0=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret0);
    10631063    if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) {
    10641064        {
  • tests/.expect/declarationSpecifier.x64.txt

    re25ef8c r108b2c7  
    10591059    }
    10601060
    1061     signed int _tmp_cp_ret6;
    1062     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
     1061    signed int _tmp_cp_ret0;
     1062    signed int _X3reti_2 = (((void)(_tmp_cp_ret0=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret0);
    10631063    if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) {
    10641064        {
  • tests/.expect/declarationSpecifier.x86.txt

    re25ef8c r108b2c7  
    10591059    }
    10601060
    1061     signed int _tmp_cp_ret6;
    1062     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
     1061    signed int _tmp_cp_ret0;
     1062    signed int _X3reti_2 = (((void)(_tmp_cp_ret0=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret0);
    10631063    if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) {
    10641064        {
  • tests/.expect/extension.arm64.txt

    re25ef8c r108b2c7  
    457457
    458458    {
    459         signed int _tmp_cp_ret6;
    460         ((void)(((void)(_tmp_cp_ret6=__extension__ _X4fredFi_i__1(3))) , _tmp_cp_ret6));
     459        signed int _tmp_cp_ret0;
     460        ((void)(((void)(_tmp_cp_ret0=__extension__ _X4fredFi_i__1(3))) , _tmp_cp_ret0));
    461461    }
    462462
  • tests/.expect/extension.x64.txt

    re25ef8c r108b2c7  
    457457
    458458    {
    459         signed int _tmp_cp_ret6;
    460         ((void)(((void)(_tmp_cp_ret6=__extension__ _X4fredFi_i__1(3))) , _tmp_cp_ret6));
     459        signed int _tmp_cp_ret0;
     460        ((void)(((void)(_tmp_cp_ret0=__extension__ _X4fredFi_i__1(3))) , _tmp_cp_ret0));
    461461    }
    462462
  • tests/.expect/extension.x86.txt

    re25ef8c r108b2c7  
    457457
    458458    {
    459         signed int _tmp_cp_ret6;
    460         ((void)(((void)(_tmp_cp_ret6=__extension__ _X4fredFi_i__1(3))) , _tmp_cp_ret6));
     459        signed int _tmp_cp_ret0;
     460        ((void)(((void)(_tmp_cp_ret0=__extension__ _X4fredFi_i__1(3))) , _tmp_cp_ret0));
    461461    }
    462462
  • tests/.expect/gccExtensions.arm64.txt

    re25ef8c r108b2c7  
    339339    }
    340340
    341     signed int _tmp_cp_ret6;
    342     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
     341    signed int _tmp_cp_ret0;
     342    signed int _X3reti_2 = (((void)(_tmp_cp_ret0=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret0);
    343343    if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) {
    344344        {
  • tests/.expect/gccExtensions.x64.txt

    re25ef8c r108b2c7  
    339339    }
    340340
    341     signed int _tmp_cp_ret6;
    342     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
     341    signed int _tmp_cp_ret0;
     342    signed int _X3reti_2 = (((void)(_tmp_cp_ret0=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret0);
    343343    if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) {
    344344        {
  • tests/.expect/gccExtensions.x86.txt

    re25ef8c r108b2c7  
    317317    }
    318318
    319     signed int _tmp_cp_ret6;
    320     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
     319    signed int _tmp_cp_ret0;
     320    signed int _X3reti_2 = (((void)(_tmp_cp_ret0=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret0);
    321321    if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) {
    322322        {
Note: See TracChangeset for help on using the changeset viewer.