Changeset 7726839


Ignore:
Timestamp:
Mar 26, 2019, 10:29:25 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
697e484
Parents:
c274df2
Message:

exponential clean up and fix forall version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/prelude/builtins.c

    rc274df2 r7726839  
    1010// Created On       : Fri Jul 21 16:21:03 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 26 14:05:49 2019
    13 // Update Count     : 84
     12// Last Modified On : Tue Mar 26 21:33:54 2019
     13// Update Count     : 92
    1414//
    1515
     
    1818typedef unsigned long long __cfaabi_abi_exception_type_t;
    1919
     20#include <limits.h>                                                                             // CHAR_BIT
    2021#include "../src/virtual.h"
    2122#include "../src/exception.h"
     
    6162static inline long double _Complex ?\?( long double _Complex x, _Complex long double y ) { return cpowl( x, y ); }
    6263
     64#define __CFA_BASE_COMP_1__() if ( ep == 1 ) return 1
     65#define __CFA_BASE_COMP_2__() if ( ep == 2 ) return ep << (y - 1)
     66#define __CFA_EXP_OVERFLOW__() if ( y >= sizeof(y) * CHAR_BIT ) return 0
     67
    6368#define __CFA_EXP__() \
    6469        if ( y == 0 ) return 1;                                                         /* base case */ \
    65         __CFA_BASE_COMP_1__()                                                           /* base case */ \
    66         __CFA_BASE_COMP_2__()                                                           /* special case, positive shifting for integral types */ \
    67         __CFA_EXP_OVERFLOW__()                                                          /* immediate overflow, negative exponent > 2^size-1 */ \
     70        __CFA_BASE_COMP_1__();                                                          /* base case */ \
     71        __CFA_BASE_COMP_2__();                                                          /* special case, positive shifting for integral types */ \
     72        __CFA_EXP_OVERFLOW__();                                                         /* immediate overflow, negative exponent > 2^size-1 */ \
    6873        typeof(ep) op = 1;                                                                      /* accumulate odd product */ \
    6974        for ( ; y > 1; y >>= 1 ) {                                                      /* squaring exponentiation, O(log2 y) */ \
     
    7277        } \
    7378        return ep * op
    74 
    75 #define __CFA_BASE_COMP_1__() if ( ep == 1 ) return 1;
    76 #define __CFA_BASE_COMP_2__() if ( ep == 2 ) return ep << (y - 1);
    77 #define __CFA_EXP_OVERFLOW__() if ( y >= sizeof(y) * 8 ) return 0;
    7879
    7980static inline long int ?\?( int ep, unsigned int y ) {
     
    106107} // ?\?
    107108
    108 static inline forall( otype OT | { void ?{}( OT & this, zero_t ); void ?{}( OT & this, one_t ); int ?==?( OT, OT ); OT ?*?( OT, OT ); } )
     109static inline forall( otype OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } )
    109110OT ?\?( OT ep, unsigned long int y ) {
    110111        __CFA_EXP__();
Note: See TracChangeset for help on using the changeset viewer.