Changeset 8a30423 for libcfa/prelude/builtins.c
- Timestamp:
- Mar 27, 2019, 8:55:18 AM (6 years ago)
- 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:
- 0087e0e
- Parents:
- 697e484
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/builtins.c
r697e484 r8a30423 10 10 // Created On : Fri Jul 21 16:21:03 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 26 2 1:33:54201913 // Update Count : 9 212 // Last Modified On : Tue Mar 26 23:10:36 2019 13 // Update Count : 95 14 14 // 15 15 … … 27 27 // increment/decrement unification 28 28 29 static inline forall( dtype DT | { DT & ?+=?( DT &, one_t ); } ) 30 DT & ++?( DT & x ) { return x += 1; } 29 static inline { 30 forall( dtype DT | { DT & ?+=?( DT &, one_t ); } ) 31 DT & ++?( DT & x ) { return x += 1; } 31 32 32 static inlineforall( dtype DT | sized(DT) | { void ?{}( DT &, DT ); void ^?{}( DT & ); DT & ?+=?( DT &, one_t ); } )33 DT & ?++( DT & x ) { DT tmp = x; x += 1; return tmp; }33 forall( dtype DT | sized(DT) | { void ?{}( DT &, DT ); void ^?{}( DT & ); DT & ?+=?( DT &, one_t ); } ) 34 DT & ?++( DT & x ) { DT tmp = x; x += 1; return tmp; } 34 35 35 static inlineforall( dtype DT | { DT & ?-=?( DT &, one_t ); } )36 DT & --?( DT & x ) { return x -= 1; }36 forall( dtype DT | { DT & ?-=?( DT &, one_t ); } ) 37 DT & --?( DT & x ) { return x -= 1; } 37 38 38 static inline forall( dtype DT | sized(DT) | { void ?{}( DT &, DT ); void ^?{}( DT & ); DT & ?-=?( DT &, one_t ); } ) 39 DT & ?--( DT & x ) { DT tmp = x; x -= 1; return tmp; } 39 forall( dtype DT | sized(DT) | { void ?{}( DT &, DT ); void ^?{}( DT & ); DT & ?-=?( DT &, one_t ); } ) 40 DT & ?--( DT & x ) { DT tmp = x; x -= 1; return tmp; } 41 } // distribution 40 42 41 43 // universal typed pointer constant 42 43 // Compiler issue: there is a problem with anonymous types that do not have a size. 44 // Compiler issue: there is a problem with anonymous types that do not have a size. 44 45 static inline forall( dtype DT | sized(DT) ) DT * intptr( uintptr_t addr ) { return (DT *)addr; } 45 46 … … 55 56 } // extern "C" 56 57 57 static inline float ?\?( float x, float y ) { return powf( x, y ); } 58 static inline double ?\?( double x, double y ) { return pow( x, y ); } 59 static inline long double ?\?( long double x, long double y ) { return powl( x, y ); } 60 static inline float _Complex ?\?( float _Complex x, _Complex float y ) { return cpowf(x, y ); } 61 static inline double _Complex ?\?( double _Complex x, _Complex double y ) { return cpow( x, y ); } 62 static inline long double _Complex ?\?( long double _Complex x, _Complex long double y ) { return cpowl( x, y ); } 58 static inline { 59 float ?\?( float x, float y ) { return powf( x, y ); } 60 double ?\?( double x, double y ) { return pow( x, y ); } 61 long double ?\?( long double x, long double y ) { return powl( x, y ); } 62 float _Complex ?\?( float _Complex x, _Complex float y ) { return cpowf(x, y ); } 63 double _Complex ?\?( double _Complex x, _Complex double y ) { return cpow( x, y ); } 64 long double _Complex ?\?( long double _Complex x, _Complex long double y ) { return cpowl( x, y ); } 65 } // distribution 63 66 64 67 #define __CFA_BASE_COMP_1__() if ( ep == 1 ) return 1 … … 67 70 68 71 #define __CFA_EXP__() \ 69 if ( y == 0 ) return 1; /* base case*/ \72 if ( y == 0 ) return 1; /* convention */ \ 70 73 __CFA_BASE_COMP_1__(); /* base case */ \ 71 74 __CFA_BASE_COMP_2__(); /* special case, positive shifting for integral types */ \ … … 78 81 return ep * op 79 82 80 static inline long int ?\?( int ep, unsigned int y ) { 81 __CFA_EXP__(); 82 } // ?\? 83 84 static inline long int ?\?( long int ep, unsigned long int y ) { 85 __CFA_EXP__(); 86 } // ?\? 87 88 // unsigned computation may be faster and larger 89 static inline unsigned long int ?\?( unsigned int ep, unsigned int y ) { 90 __CFA_EXP__(); 91 } // ?\? 92 93 static inline unsigned long int ?\?( unsigned long int ep, unsigned long int y ) { 94 __CFA_EXP__(); 95 } // ?\? 83 static inline { 84 long int ?\?( int ep, unsigned int y ) { __CFA_EXP__(); } 85 long int ?\?( long int ep, unsigned long int y ) { __CFA_EXP__(); } 86 // unsigned computation may be faster and larger 87 unsigned long int ?\?( unsigned int ep, unsigned int y ) { __CFA_EXP__(); } 88 unsigned long int ?\?( unsigned long int ep, unsigned long int y ) { __CFA_EXP__(); } 89 } // distribution 96 90 97 91 #undef __CFA_BASE_COMP_1__ … … 102 96 #define __CFA_EXP_OVERFLOW__() 103 97 104 static inline forall( otype OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) 105 OT ?\?( OT ep, unsigned int y ) { 106 __CFA_EXP__(); 107 } // ?\? 108 109 static inline forall( otype OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) 110 OT ?\?( OT ep, unsigned long int y ) { 111 __CFA_EXP__(); 112 } // ?\? 98 static inline forall( otype OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) { 99 OT ?\?( OT ep, unsigned int y ) { __CFA_EXP__(); } 100 OT ?\?( OT ep, unsigned long int y ) { __CFA_EXP__(); } 101 } // distribution 113 102 114 103 #undef __CFA_BASE_COMP_1__ … … 116 105 #undef __CFA_EXP_OVERFLOW__ 117 106 118 static inline long int ?\=?( long int & x, unsigned long int y ) { x = x \ y; return x; } 119 static inline unsigned long int ?\=?( unsigned long int & x, unsigned long int y ) { x = x \ y; return x; } 120 static inline int ?\=?( int & x, unsigned long int y ) { x = x \ y; return x; } 121 static inline unsigned int ?\=?( unsigned int & x, unsigned long int y ) { x = x \ y; return x; } 107 static inline { 108 long int ?\=?( long int & x, unsigned long int y ) { x = x \ y; return x; } 109 unsigned long int ?\=?( unsigned long int & x, unsigned long int y ) { x = x \ y; return x; } 110 int ?\=?( int & x, unsigned long int y ) { x = x \ y; return x; } 111 unsigned int ?\=?( unsigned int & x, unsigned long int y ) { x = x \ y; return x; } 112 } // distribution 122 113 123 114 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.