Changes in / [8dbedfc:34ca532]
- Location:
- src
- Files:
-
- 3 deleted
- 12 edited
-
CodeGen/CodeGenerator.cc (modified) (1 diff)
-
Parser/LinkageSpec.h (modified) (4 diffs)
-
libcfa/bits/locks.h (modified) (4 diffs)
-
libcfa/concurrency/preemption.c (modified) (4 diffs)
-
prelude/Makefile.am (modified) (1 diff)
-
prelude/Makefile.in (modified) (1 diff)
-
prelude/builtins.def (modified) (4 diffs)
-
prelude/prelude.cf (modified) (1 diff)
-
prelude/prototypes.awk (modified) (5 diffs)
-
prelude/prototypes.sed (modified) (1 diff)
-
prelude/sync-builtins.cf (deleted)
-
tests/Makefile.am (modified) (1 diff)
-
tests/Makefile.in (modified) (1 diff)
-
tests/builtins/.expect/sync.txt (deleted)
-
tests/builtins/sync.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r8dbedfc r34ca532 119 119 120 120 string CodeGenerator::mangleName( DeclarationWithType * decl ) { 121 // GCC builtins should always be printed unmangled 122 if ( pretty || decl->linkage.is_gcc_builtin ) return decl->name; 123 if ( decl->mangleName != "" ) { 121 if ( pretty ) return decl->get_name(); 122 if ( decl->get_mangleName() != "" ) { 124 123 // need to incorporate scope level in order to differentiate names for destructors 125 124 return decl->get_scopedMangleName(); 126 125 } else { 127 return decl-> name;126 return decl->get_name(); 128 127 } // if 129 128 } -
src/Parser/LinkageSpec.h
r8dbedfc r34ca532 27 27 Overrideable = 1 << 2, 28 28 Builtin = 1 << 3, 29 GccBuiltin = 1 << 4,30 29 31 NoOfSpecs = 1 << 5,30 NoOfSpecs = 1 << 4, 32 31 }; 33 32 … … 39 38 bool is_overridable : 1; 40 39 bool is_builtin : 1; 41 bool is_gcc_builtin : 1;42 40 }; 43 41 constexpr Spec( unsigned int val ) : val( val ) {} … … 63 61 inline bool isOverridable( Spec spec ) { return spec.is_overridable; } 64 62 inline bool isBuiltin( Spec spec ) { return spec.is_builtin; } 65 inline bool isGccBuiltin( Spec spec ) { return spec.is_gcc_builtin; }66 63 67 64 // Pre-defined flag combinations: … … 75 72 constexpr Spec const AutoGen = { Mangle | Generate | Overrideable }; 76 73 // gcc internal 77 constexpr Spec const Compiler = { Mangle | Builtin | GccBuiltin };74 constexpr Spec const Compiler = { Builtin }; 78 75 // mangled builtins 79 76 constexpr Spec const BuiltinCFA = { Mangle | Generate | Builtin }; -
src/libcfa/bits/locks.h
r8dbedfc r34ca532 39 39 #endif 40 40 41 #if __SIZEOF_SIZE_T__ == 8 42 #define __lock_test_and_test_and_set( lock ) (lock) == 0 && __sync_lock_test_and_set_8( &(lock), 1 ) == 0 43 #define __lock_release( lock ) __sync_lock_release_8( &(lock) ); 44 #elif __SIZEOF_SIZE_T__ == 4 45 #define __lock_test_and_test_and_set( lock ) (lock) == 0 && __sync_lock_test_and_set_4( &(lock), 1 ) == 0 46 #define __lock_release( lock ) __sync_lock_release_4( &(lock) ); 47 #else 48 #error unsupported architecture 49 #endif 50 41 51 struct __spinlock_t { 42 // Wrap in struct to prevent false sharing with debug info 43 struct { 44 // Align lock on 128-bit boundary 45 __ALIGN__ volatile _Bool lock; 46 }; 52 __ALIGN__ volatile size_t lock; 47 53 #ifdef __CFA_DEBUG__ 48 // previous function to acquire the lock49 54 const char * prev_name; 50 // previous thread to acquire the lock51 55 void* prev_thrd; 52 56 #endif … … 74 78 // Lock the spinlock, return false if already acquired 75 79 static inline _Bool try_lock ( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) { 76 _Bool result = (this.lock == 0) && (__atomic_test_and_set( &this.lock, __ATOMIC_ACQUIRE ) == 0);80 _Bool result = __lock_test_and_test_and_set( this.lock ); 77 81 if( result ) { 78 82 disable_interrupts(); … … 90 94 91 95 for ( unsigned int i = 1;; i += 1 ) { 92 if ( (this.lock == 0) && (__atomic_test_and_set( &this.lock, __ATOMIC_ACQUIRE ) == 0) ) break;96 if ( __lock_test_and_test_and_set( this.lock ) ) break; 93 97 #ifndef NOEXPBACK 94 98 // exponential spin … … 108 112 } 109 113 114 // // Lock the spinlock, yield if already acquired 115 // static inline void lock_yield( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) { 116 // for ( unsigned int i = 1;; i += 1 ) { 117 // if ( __lock_test_and_test_and_set( this.lock ) ) break; 118 // yield( i ); 119 // } 120 // disable_interrupts(); 121 // __cfaabi_dbg_debug_do( 122 // this.prev_name = caller; 123 // this.prev_thrd = this_thread; 124 // ) 125 // } 126 110 127 static inline void unlock( __spinlock_t & this ) { 111 128 enable_interrupts_noPoll(); 112 __ atomic_clear( &this.lock, __ATOMIC_RELEASE);129 __lock_release( this.lock ); 113 130 } 114 131 #endif -
src/libcfa/concurrency/preemption.c
r8dbedfc r34ca532 161 161 void disable_interrupts() { 162 162 with( kernelTLS.preemption_state ) { 163 static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free"); 164 165 // Set enabled flag to false 166 // should be atomic to avoid preemption in the middle of the operation. 167 // use memory order RELAXED since there is no inter-thread on this variable requirements 168 __atomic_store_n(&enabled, false, __ATOMIC_RELAXED); 169 170 // Signal the compiler that a fence is needed but only for signal handlers 171 __atomic_signal_fence(__ATOMIC_ACQUIRE); 172 163 enabled = false; 173 164 __attribute__((unused)) unsigned short new_val = disable_count + 1; 174 165 disable_count = new_val; … … 180 171 // If counter reaches 0, execute any pending CtxSwitch 181 172 void enable_interrupts( __cfaabi_dbg_ctx_param ) { 182 processor * proc = kernelTLS.this_processor; // Cache the processor now since interrupts can start happening after the atomic store183 thread_desc * thrd = kernelTLS.this_thread; // Cache the thread now since interrupts can start happening after the atomic store173 processor * proc = kernelTLS.this_processor; // Cache the processor now since interrupts can start happening after the atomic add 174 thread_desc * thrd = kernelTLS.this_thread; // Cache the thread now since interrupts can start happening after the atomic add 184 175 185 176 with( kernelTLS.preemption_state ){ … … 190 181 // Check if we need to prempt the thread because an interrupt was missed 191 182 if( prev == 1 ) { 192 static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free"); 193 194 // Set enabled flag to true 195 // should be atomic to avoid preemption in the middle of the operation. 196 // use memory order RELAXED since there is no inter-thread on this variable requirements 197 __atomic_store_n(&enabled, true, __ATOMIC_RELAXED); 198 199 // Signal the compiler that a fence is needed but only for signal handlers 200 __atomic_signal_fence(__ATOMIC_RELEASE); 183 enabled = true; 201 184 if( proc->pending_preemption ) { 202 185 proc->pending_preemption = false; … … 217 200 verifyf( prev != 0u, "Incremented from %u\n", prev ); // If this triggers someone is enabled already enabled interrupts 218 201 if( prev == 1 ) { 219 static_assert(__atomic_always_lock_free(sizeof(kernelTLS.preemption_state.enabled), &kernelTLS.preemption_state.enabled), "Must be lock-free"); 220 // Set enabled flag to true 221 // should be atomic to avoid preemption in the middle of the operation. 222 // use memory order RELAXED since there is no inter-thread on this variable requirements 223 __atomic_store_n(&kernelTLS.preemption_state.enabled, true, __ATOMIC_RELAXED); 224 225 // Signal the compiler that a fence is needed but only for signal handlers 226 __atomic_signal_fence(__ATOMIC_RELEASE); 202 kernelTLS.preemption_state.enabled = true; 227 203 } 228 204 } -
src/prelude/Makefile.am
r8dbedfc r34ca532 37 37 # create forward declarations for gcc builtins 38 38 gcc-builtins.cf : gcc-builtins.c prototypes.sed 39 ${AM_V_GEN}@BACKEND_CC@ -E -P $< | sed - r -f prototypes.sed > $@39 ${AM_V_GEN}@BACKEND_CC@ -E -P $< | sed -f prototypes.sed > $@ 40 40 41 gcc-builtins.c : builtins.def prototypes.awk sync-builtins.cf41 gcc-builtins.c : builtins.def prototypes.awk 42 42 ${AM_V_GEN}@BACKEND_CC@ -E prototypes.c | awk -f prototypes.awk > $@ 43 43 -
src/prelude/Makefile.in
r8dbedfc r34ca532 506 506 # create forward declarations for gcc builtins 507 507 gcc-builtins.cf : gcc-builtins.c prototypes.sed 508 ${AM_V_GEN}@BACKEND_CC@ -E -P $< | sed - r -f prototypes.sed > $@509 510 gcc-builtins.c : builtins.def prototypes.awk sync-builtins.cf508 ${AM_V_GEN}@BACKEND_CC@ -E -P $< | sed -f prototypes.sed > $@ 509 510 gcc-builtins.c : builtins.def prototypes.awk 511 511 ${AM_V_GEN}@BACKEND_CC@ -E prototypes.c | awk -f prototypes.awk > $@ 512 512 -
src/prelude/builtins.def
r8dbedfc r34ca532 190 190 191 191 /* Builtin used by implementation of Cilk Plus. Most of these are decomposed 192 by the compiler but a few are implemented in libcilkrts. */ 192 by the compiler but a few are implemented in libcilkrts. */ 193 193 #undef DEF_CILK_BUILTIN_STUB 194 194 #define DEF_CILK_BUILTIN_STUB(ENUM, NAME) \ … … 204 204 205 205 /* Builtin used by the implementation of libsanitizer. These 206 functions are mapped to the actual implementation of the 206 functions are mapped to the actual implementation of the 207 207 libtsan library. */ 208 208 #undef DEF_SANITIZER_BUILTIN … … 217 217 #define DEF_CILKPLUS_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ 218 218 DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, BT_FN_INT_VAR, BT_LAST, \ 219 false, false, false, ATTRS, false, flag_cilkplus) 219 false, false, false, ATTRS, false, flag_cilkplus) 220 220 221 221 /* Builtin used by the implementation of Pointer Bounds Checker. */ … … 927 927 DEF_GCC_BUILTIN (BUILT_IN_LINE, "LINE", BT_FN_INT, ATTR_NOTHROW_LEAF_LIST) 928 928 929 #if 0 //Ifdefed out because we hard-coded the proper overloadings of the atomic built-ins930 929 /* Synchronization Primitives. */ 931 930 #include "sync-builtins.def" 932 931 932 #if 0 933 933 /* Offloading and Multi Processing builtins. */ 934 934 #include "omp-builtins.def" -
src/prelude/prelude.cf
r8dbedfc r34ca532 458 458 signed long long int ?=?( signed long long int &, signed long long int ), ?=?( volatile signed long long int &, signed long long int ); 459 459 unsigned long long int ?=?( unsigned long long int &, unsigned long long int ), ?=?( volatile unsigned long long int &, unsigned long long int ); 460 __int128 ?=?( __int128 &, __int128 ), ?=?( volatile __int128 &, __int128 );461 460 zero_t ?=?( zero_t &, zero_t ); 462 461 one_t ?=?( one_t &, one_t ); -
src/prelude/prototypes.awk
r8dbedfc r34ca532 5 5 # file "LICENCE" distributed with Cforall. 6 6 # 7 # prototypes.awk -- 7 # prototypes.awk -- 8 8 # 9 9 # Author : Peter A. Buhr … … 12 12 # Last Modified On : Tue Jul 5 14:32:52 2016 13 13 # Update Count : 32 14 # 14 # 15 15 16 16 # http://llvm.org/svn/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def … … 83 83 } # BEGIN 84 84 85 /BT_FN/ { 85 /BT_FN/ { 86 86 for (i = 1; i <= NF; i++) { 87 87 if( match($i, "BT_FN") != 0 ) { … … 116 116 117 117 # generate function return type as macro 118 for ( t = 0; t < N; t += 1 ) { # find longest match 118 for ( t = 0; t < N; t += 1 ) { # find longest match 119 119 type = types[t]; 120 120 if ( index( prototype, type ) == 1 ) { # found match … … 150 150 # extras 151 151 printf( "\n#include \"builtins.def\"\n\n" ); 152 printf( "\n#include \"sync-builtins.cf\"\n\n" );153 152 printf( "extern const char *__PRETTY_FUNCTION__;\n" ); 154 153 } # END -
src/prelude/prototypes.sed
r8dbedfc r34ca532 2 2 /targetm/s/.*// #Remove targetm declarations 3 3 /__Unsupported/s/.*// #Remove Unsupported types declarations 4 s/void \(const char \*\)0\(\);//#Remove void (const char \*)0();4 s/void (const char \*)0();// #Remove void (const char \*)0(); 5 5 s/\"//g #Remove extraenous quotes in declarations 6 /__builtin_/s/_ /_/g #Remove extraenous spaces in declarations 7 8 #Fix gcc overloading 9 # various sed rules for the gcc sync builtins which are overloaded 10 # kept here because they generate an acceptable approximate of the correct prototypes 11 12 #/__sync_/s/_[0-9][0-9]*\(.*\)/\(\);/g #hack since it will accept any parameters 13 #/__atomic_/s/_[0-9][0-9]*\(.*\)/\(\);/g #hack since it will accept any parameters 14 15 #/_16/s/void \*/__int128 \*/g 16 #/_8/s/void \*/long long int \*/g 17 #/_4/s/void \*/int \*/g 18 #/_2/s/void \*/short \*/g 19 #/_1/s/void \*/char \*/g 20 21 #s/([a-zA-Z0-9_ ]+)\s+__sync([a-z_]+)_([0-9]+)\((.*)\);/\1 __sync\2\(\4\,...); \1 __sync\2_\3\(\4\,...);/ 22 #s/([a-zA-Z0-9_ ]+)\s+__atomic([a-z_]+)_([0-9]+)\((.*)\);/\1 __atomic\2\(\4\); \1 __atomic\2_\3\(\4\);/ 6 /__builtin_/s/_ /_/g #Remove extraenous spaces in declarations -
src/tests/Makefile.am
r8dbedfc r34ca532 129 129 warnings/self-assignment: warnings/self-assignment.c @CFA_BINDIR@/@CFA_NAME@ 130 130 ${CC} ${AM_CFLAGS} ${CFLAGS} ${<} 2> ${@} -fsyntax-only 131 132 #builtins133 builtins/sync: builtins/sync.c @CFA_BINDIR@/@CFA_NAME@134 ${CC} ${AM_CFLAGS} ${CFLAGS} ${<} 2> ${@} -fsyntax-only -
src/tests/Makefile.in
r8dbedfc r34ca532 807 807 ${CC} ${AM_CFLAGS} ${CFLAGS} ${<} 2> ${@} -fsyntax-only 808 808 809 #builtins810 builtins/sync: builtins/sync.c @CFA_BINDIR@/@CFA_NAME@811 ${CC} ${AM_CFLAGS} ${CFLAGS} ${<} 2> ${@} -fsyntax-only812 813 809 # Tell versions [3.59,3.63) of GNU make to not export all variables. 814 810 # Otherwise a system limit (for SysV at least) may be exceeded.
Note:
See TracChangeset
for help on using the changeset viewer.