Changes in / [ad861ef:466787a]
- Files:
-
- 30 added
- 46 deleted
- 51 edited
-
configure.ac (modified) (2 diffs)
-
libcfa/configure.ac (modified) (2 diffs)
-
libcfa/src/Makefile.am (modified) (1 diff)
-
libcfa/src/concurrency/channel.hfa (deleted)
-
libcfa/src/concurrency/clib/cfathread.cfa (modified) (2 diffs)
-
libcfa/src/concurrency/future.hfa (modified) (5 diffs)
-
libcfa/src/concurrency/locks.hfa (modified) (13 diffs)
-
libcfa/src/concurrency/select.hfa (deleted)
-
src/AST/Expr.cpp (modified) (1 diff)
-
src/AST/Node.hpp (modified) (2 diffs)
-
src/AST/SymbolTable.cpp (modified) (2 diffs)
-
src/CodeGen/CodeGenerator.cc (modified) (1 diff)
-
src/CodeGen/GenType.cc (modified) (1 diff)
-
src/GenPoly/Box.cc (modified) (4 diffs)
-
src/GenPoly/GenPoly.cc (modified) (2 diffs)
-
src/GenPoly/InstantiateGeneric.cc (modified) (1 diff)
-
src/GenPoly/InstantiateGenericNew.cpp (modified) (1 diff)
-
src/InitTweak/FixInit.cc (modified) (1 diff)
-
src/InitTweak/FixInitNew.cpp (modified) (1 diff)
-
src/InitTweak/InitTweak.cc (modified) (1 diff)
-
src/Parser/TypeData.cc (modified) (1 diff)
-
src/ResolvExpr/AdjustExprType.hpp (deleted)
-
src/ResolvExpr/AlternativeFinder.cc (modified) (3 diffs)
-
src/ResolvExpr/AlternativeFinder.h (modified) (1 diff)
-
src/ResolvExpr/CandidateFinder.cpp (modified) (1 diff)
-
src/ResolvExpr/CandidateFinder.hpp (modified) (1 diff)
-
src/ResolvExpr/CastCost.cc (modified) (2 diffs)
-
src/ResolvExpr/CastCost.hpp (deleted)
-
src/ResolvExpr/CommonType.cc (modified) (1 diff)
-
src/ResolvExpr/CommonType.hpp (deleted)
-
src/ResolvExpr/ConversionCost.cc (modified) (1 diff)
-
src/ResolvExpr/ConversionCost.h (modified) (3 diffs)
-
src/ResolvExpr/PolyCost.hpp (deleted)
-
src/ResolvExpr/PtrsAssignable.cc (modified) (1 diff)
-
src/ResolvExpr/PtrsAssignable.hpp (deleted)
-
src/ResolvExpr/PtrsCastable.cc (modified) (4 diffs)
-
src/ResolvExpr/PtrsCastable.hpp (deleted)
-
src/ResolvExpr/RenameVars.cc (modified) (2 diffs)
-
src/ResolvExpr/ResolveAssertions.cc (modified) (2 diffs)
-
src/ResolvExpr/SatisfyAssertions.cpp (modified) (1 diff)
-
src/ResolvExpr/SpecCost.hpp (deleted)
-
src/ResolvExpr/Unify.cc (modified) (4 diffs)
-
src/ResolvExpr/Unify.h (modified) (2 diffs)
-
src/ResolvExpr/WidenMode.h (modified) (2 diffs)
-
src/ResolvExpr/module.mk (modified) (4 diffs)
-
src/ResolvExpr/typeops.h (modified) (7 diffs)
-
src/SymTab/Indexer.cc (modified) (1 diff)
-
src/SymTab/Mangler.cc (modified) (5 diffs)
-
src/SymTab/Validate.cc (modified) (1 diff)
-
src/SynTree/ApplicationExpr.cc (modified) (2 diffs)
-
src/SynTree/BasicType.cc (modified) (1 diff)
-
src/SynTree/Type.h (modified) (1 diff)
-
src/Validate/FixReturnTypes.cpp (modified) (1 diff)
-
src/Validate/ReplaceTypedef.cpp (modified) (1 diff)
-
tests/Makefile.am (modified) (1 diff)
-
tests/concurrent/channels/.expect/big_elems.txt (deleted)
-
tests/concurrent/channels/.expect/zero_size.txt (deleted)
-
tests/concurrent/channels/big_elems.cfa (deleted)
-
tests/concurrent/channels/parallel_harness.hfa (deleted)
-
tests/concurrent/channels/zero_size.cfa (deleted)
-
tests/concurrent/futures/.expect/select_future.txt (deleted)
-
tests/concurrent/futures/select_future.cfa (deleted)
-
tests/concurrent/futures/typed.cfa (modified) (4 diffs)
-
tests/concurrent/mutexstmt/locks.cfa (modified) (1 diff)
-
tests/concurrent/unified_locking/.expect/block_spin_lock.txt (deleted)
-
tests/concurrent/unified_locking/.expect/clh.txt (deleted)
-
tests/concurrent/unified_locking/.expect/exp_backoff.txt (deleted)
-
tests/concurrent/unified_locking/.expect/fast_block_lock.txt (deleted)
-
tests/concurrent/unified_locking/.expect/futex_mutex.txt (deleted)
-
tests/concurrent/unified_locking/.expect/locks.txt (deleted)
-
tests/concurrent/unified_locking/.expect/mcs.txt (deleted)
-
tests/concurrent/unified_locking/.expect/mcs_block_spin_lock.txt (deleted)
-
tests/concurrent/unified_locking/.expect/mcs_spin.txt (deleted)
-
tests/concurrent/unified_locking/.expect/pthread_locks.txt (deleted)
-
tests/concurrent/unified_locking/.expect/simple_owner_lock.txt (deleted)
-
tests/concurrent/unified_locking/.expect/spin_queue_lock.txt (deleted)
-
tests/concurrent/unified_locking/.expect/timeout_lock.txt (deleted)
-
tests/concurrent/unified_locking/block_spin_lock.cfa (deleted)
-
tests/concurrent/unified_locking/clh.cfa (deleted)
-
tests/concurrent/unified_locking/exp_backoff.cfa (deleted)
-
tests/concurrent/unified_locking/fast_block_lock.cfa (deleted)
-
tests/concurrent/unified_locking/futex_mutex.cfa (deleted)
-
tests/concurrent/unified_locking/locks.cfa (deleted)
-
tests/concurrent/unified_locking/mcs.cfa (deleted)
-
tests/concurrent/unified_locking/mcs_block_spin_lock.cfa (deleted)
-
tests/concurrent/unified_locking/mcs_spin.cfa (deleted)
-
tests/concurrent/unified_locking/mutex_test.hfa (deleted)
-
tests/concurrent/unified_locking/pthread_locks.cfa (deleted)
-
tests/concurrent/unified_locking/simple_owner_lock.cfa (deleted)
-
tests/concurrent/unified_locking/spin_queue_lock.cfa (deleted)
-
tests/concurrent/unified_locking/spintest.cfa (deleted)
-
tests/concurrent/unified_locking/test_debug.cfa (deleted)
-
tests/concurrent/unified_locking/thread_test.cfa (deleted)
-
tests/concurrent/unified_locking/timeout_lock.cfa (deleted)
-
tests/enum_tests/.expect/pointerEnum.cfa (added)
-
tests/enum_tests/.expect/qualifiedEnum.cfa (added)
-
tests/enum_tests/.expect/typedIntEnum.txt (modified) (1 diff)
-
tests/enum_tests/pointerEnum.cfa (modified) (1 diff)
-
tests/enum_tests/typedIntEnum.cfa (modified) (1 diff)
-
tests/unified_locking/.expect/block_spin_lock.txt (added)
-
tests/unified_locking/.expect/clh.txt (added)
-
tests/unified_locking/.expect/fast_block_lock.txt (added)
-
tests/unified_locking/.expect/futex_mutex.txt (added)
-
tests/unified_locking/.expect/lin_backoff.txt (added)
-
tests/unified_locking/.expect/locks.txt (added)
-
tests/unified_locking/.expect/mcs.txt (added)
-
tests/unified_locking/.expect/mcs_block_spin_lock.txt (added)
-
tests/unified_locking/.expect/mcs_spin.txt (added)
-
tests/unified_locking/.expect/pthread_locks.txt (added)
-
tests/unified_locking/.expect/simple_owner_lock.txt (added)
-
tests/unified_locking/.expect/spin_queue_lock.txt (added)
-
tests/unified_locking/.expect/timeout_lock.txt (added)
-
tests/unified_locking/block_spin_lock.cfa (added)
-
tests/unified_locking/clh.cfa (added)
-
tests/unified_locking/fast_block_lock.cfa (added)
-
tests/unified_locking/futex_mutex.cfa (added)
-
tests/unified_locking/lin_backoff.cfa (added)
-
tests/unified_locking/locks.cfa (added)
-
tests/unified_locking/mcs.cfa (added)
-
tests/unified_locking/mcs_block_spin_lock.cfa (added)
-
tests/unified_locking/mcs_spin.cfa (added)
-
tests/unified_locking/mutex_test.hfa (added)
-
tests/unified_locking/pthread_locks.cfa (added)
-
tests/unified_locking/simple_owner_lock.cfa (added)
-
tests/unified_locking/spin_queue_lock.cfa (added)
-
tests/unified_locking/thread_test.cfa (added)
-
tests/unified_locking/timeout_lock.cfa (added)
Legend:
- Unmodified
- Added
- Removed
-
configure.ac
rad861ef r466787a 226 226 AC_PROG_YACC 227 227 if test "${YACC}" = "yacc" ; then echo "Error: bison required." ; exit 1 ; fi 228 AC_PROG_LEX (yywrap)228 AC_PROG_LEX 229 229 if test "${LEX}" = "lex" ; then echo "Error: flex required." ; exit 1 ; fi 230 LT_INIT 230 AC_PROG_LIBTOOL 231 231 AC_PROG_INSTALL 232 232 … … 284 284 tools/Makefile 285 285 tools/prettyprinter/Makefile 286 benchmark/Cargo.toml287 286 ]) 287 288 AC_OUTPUT(benchmark/Cargo.toml) 288 289 ]) 289 290 290 291 AC_CONFIG_LINKS([tests/test.py:tests/test.py]) 291 AC_CONFIG_FILES([tests/config.py]) 292 293 AC_OUTPUT 292 293 AC_OUTPUT(tests/config.py) 294 294 295 295 # Final text -
libcfa/configure.ac
rad861ef r466787a 122 122 AC_PROG_CC 123 123 AM_PROG_AS 124 LT_INIT 124 AC_PROG_LIBTOOL 125 125 AC_PROG_INSTALL 126 126 AC_PROG_MAKE_SET … … 246 246 AC_CONFIG_HEADERS(prelude/defines.hfa) 247 247 248 AC_OUTPUT 248 AC_OUTPUT() 249 249 250 250 # Final text -
libcfa/src/Makefile.am
rad861ef r466787a 113 113 concurrency/once.hfa \ 114 114 concurrency/kernel/fwd.hfa \ 115 concurrency/mutex_stmt.hfa \ 116 concurrency/select.hfa \ 117 concurrency/channel.hfa 115 concurrency/mutex_stmt.hfa 118 116 119 117 inst_thread_headers_src = \ -
libcfa/src/concurrency/clib/cfathread.cfa
rad861ef r466787a 439 439 // Mutex 440 440 struct cfathread_mutex { 441 exp_backoff_then_block_lock impl;441 linear_backoff_then_block_lock impl; 442 442 }; 443 443 int cfathread_mutex_init(cfathread_mutex_t *restrict mut, const cfathread_mutexattr_t *restrict) __attribute__((nonnull (1))) { *mut = new(); return 0; } … … 454 454 // Condition 455 455 struct cfathread_condition { 456 condition_variable( exp_backoff_then_block_lock) impl;456 condition_variable(linear_backoff_then_block_lock) impl; 457 457 }; 458 458 int cfathread_cond_init(cfathread_cond_t *restrict cond, const cfathread_condattr_t *restrict) __attribute__((nonnull (1))) { *cond = new(); return 0; } -
libcfa/src/concurrency/future.hfa
rad861ef r466787a 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // concurrency/future.hfa --7 // io/types.hfa -- 8 8 // 9 // Author : Thierry Delisle & Peiran Hong & Colby Parsons9 // Author : Thierry Delisle & Peiran Hong 10 10 // Created On : Wed Jan 06 17:33:18 2021 11 11 // Last Modified By : … … 14 14 // 15 15 16 //#pragma once16 #pragma once 17 17 18 18 #include "bits/locks.hfa" 19 19 #include "monitor.hfa" 20 #include "select.hfa"21 22 //----------------------------------------------------------------------------23 // future24 // I don't use future_t here since I need to use a lock for this future25 // since it supports multiple consumers26 // future_t is lockfree and uses atomics which aren't needed given we use locks here27 forall( T ) {28 // enum(int) { FUTURE_EMPTY = 0, FUTURE_FULFILLED = 1 }; // Enums seem to be broken so feel free to add this back afterwards29 30 // temporary enum replacement31 const int FUTURE_EMPTY = 0;32 const int FUTURE_FULFILLED = 1;33 34 struct future {35 int state;36 T result;37 dlist( select_node ) waiters;38 futex_mutex lock;39 };40 41 struct future_node {42 inline select_node;43 T * my_result;44 };45 46 // C_TODO: perhaps allow exceptions to be inserted like uC++?47 48 static inline {49 50 void ?{}( future_node(T) & this, thread$ * blocked_thread, T * my_result ) {51 ((select_node &)this){ blocked_thread };52 this.my_result = my_result;53 }54 55 void ?{}(future(T) & this) {56 this.waiters{};57 this.state = FUTURE_EMPTY;58 this.lock{};59 }60 61 // Reset future back to original state62 void reset(future(T) & this) with(this)63 {64 lock( lock );65 if( ! waiters`isEmpty )66 abort("Attempting to reset a future with blocked waiters");67 state = FUTURE_EMPTY;68 unlock( lock );69 }70 71 // check if the future is available72 // currently no mutual exclusion because I can't see when you need this call to be synchronous or protected73 bool available( future(T) & this ) { return this.state; }74 75 76 // memcpy wrapper to help copy values77 void copy_T( T & from, T & to ) {78 memcpy((void *)&to, (void *)&from, sizeof(T));79 }80 81 // internal helper to signal waiters off of the future82 void _internal_flush( future(T) & this ) with(this) {83 while( ! waiters`isEmpty ) {84 select_node &s = try_pop_front( waiters );85 86 if ( s.race_flag == 0p )87 // poke in result so that woken threads do not need to reacquire any locks88 // *(((future_node(T) &)s).my_result) = result;89 copy_T( result, *(((future_node(T) &)s).my_result) );90 else if ( !install_select_winner( s, &this ) ) continue;91 92 // only unpark if future is not selected93 // or if it is selected we only unpark if we win the race94 unpark( s.blocked_thread );95 }96 }97 98 // Fulfil the future, returns whether or not someone was unblocked99 bool fulfil( future(T) & this, T & val ) with(this) {100 lock( lock );101 if( state != FUTURE_EMPTY )102 abort("Attempting to fulfil a future that has already been fulfilled");103 104 copy_T( val, result );105 106 bool ret_val = ! waiters`isEmpty;107 state = FUTURE_FULFILLED;108 _internal_flush( this );109 unlock( lock );110 return ret_val;111 }112 113 // Wait for the future to be fulfilled114 // Also return whether the thread had to block or not115 [T, bool] get( future(T) & this ) with( this ) {116 lock( lock );117 T ret_val;118 if( state == FUTURE_FULFILLED ) {119 copy_T( result, ret_val );120 unlock( lock );121 return [ret_val, false];122 }123 124 future_node(T) node = { active_thread(), &ret_val };125 insert_last( waiters, ((select_node &)node) );126 unlock( lock );127 park( );128 129 return [ret_val, true];130 }131 132 // Wait for the future to be fulfilled133 T get( future(T) & this ) {134 [T, bool] tt;135 tt = get(this);136 return tt.0;137 }138 139 // Gets value if it is available and returns [ val, true ]140 // otherwise returns [ default_val, false]141 // will not block142 [T, bool] try_get( future(T) & this ) with(this) {143 lock( lock );144 T ret_val;145 if( state == FUTURE_FULFILLED ) {146 copy_T( result, ret_val );147 unlock( lock );148 return [ret_val, true];149 }150 unlock( lock );151 152 return [ret_val, false];153 }154 155 void * register_select( future(T) & this, select_node & s ) with(this) {156 lock( lock );157 158 // future not ready -> insert select node and return 0p159 if( state == FUTURE_EMPTY ) {160 insert_last( waiters, s );161 unlock( lock );162 return 0p;163 }164 165 // future ready and we won race to install it as the select winner return 1p166 if ( install_select_winner( s, &this ) ) {167 unlock( lock );168 return 1p;169 }170 171 unlock( lock );172 // future ready and we lost race to install it as the select winner173 return 2p;174 }175 176 void unregister_select( future(T) & this, select_node & s ) with(this) {177 lock( lock );178 if ( s`isListed ) remove( s );179 unlock( lock );180 }181 182 }183 }184 185 //--------------------------------------------------------------------------------------------------------186 // These futures below do not support select statements so they may not be as useful as 'future'187 // however the 'single_future' is cheap and cheerful and is most likely more performant than 'future'188 // since it uses raw atomics and no locks afaik189 //190 // As far as 'multi_future' goes I can't see many use cases as it will be less performant than 'future'191 // since it is monitor based and also is not compatible with select statements192 //--------------------------------------------------------------------------------------------------------193 20 194 21 forall( T ) { 195 struct single_future {22 struct future { 196 23 inline future_t; 197 24 T result; … … 200 27 static inline { 201 28 // Reset future back to original state 202 void reset( single_future(T) & this) { reset( (future_t&)this ); }29 void reset(future(T) & this) { reset( (future_t&)this ); } 203 30 204 31 // check if the future is available 205 bool available( single_future(T) & this ) { return available( (future_t&)this ); }32 bool available( future(T) & this ) { return available( (future_t&)this ); } 206 33 207 34 // Mark the future as abandoned, meaning it will be deleted by the server 208 35 // This doesn't work beause of the potential need for a destructor 209 void abandon( single_future(T) & this );36 void abandon( future(T) & this ); 210 37 211 38 // Fulfil the future, returns whether or not someone was unblocked 212 thread$ * fulfil( single_future(T) & this, T result ) {39 thread$ * fulfil( future(T) & this, T result ) { 213 40 this.result = result; 214 41 return fulfil( (future_t&)this ); … … 217 44 // Wait for the future to be fulfilled 218 45 // Also return whether the thread had to block or not 219 [T, bool] wait( single_future(T) & this ) {46 [T, bool] wait( future(T) & this ) { 220 47 bool r = wait( (future_t&)this ); 221 48 return [this.result, r]; … … 223 50 224 51 // Wait for the future to be fulfilled 225 T wait( single_future(T) & this ) {52 T wait( future(T) & this ) { 226 53 [T, bool] tt; 227 54 tt = wait(this); -
libcfa/src/concurrency/locks.hfa
rad861ef r466787a 38 38 #include <unistd.h> 39 39 40 // C_TODO: cleanup this and locks.cfa 41 // - appropriate separation of interface and impl 42 // - clean up unused/unneeded locks 43 // - change messy big blocking lock from inheritance to composition to remove need for flags 40 // undef to make a number of the locks not reacquire upon waking from a condlock 41 #define REACQ 1 44 42 45 43 //----------------------------------------------------------------------------- … … 251 249 static inline void on_notify(clh_lock & this, struct thread$ * t ) { unpark(t); } 252 250 static inline size_t on_wait(clh_lock & this) { unlock(this); return 0; } 253 static inline void on_wakeup(clh_lock & this, size_t recursion ) { lock(this); } 254 255 256 //----------------------------------------------------------------------------- 257 // Exponential backoff then block lock 258 struct exp_backoff_then_block_lock { 251 static inline void on_wakeup(clh_lock & this, size_t recursion ) { 252 #ifdef REACQ 253 lock(this); 254 #endif 255 } 256 257 258 //----------------------------------------------------------------------------- 259 // Linear backoff Spinlock 260 struct linear_backoff_then_block_lock { 259 261 // Spin lock used for mutual exclusion 260 262 __spinlock_t spinlock; … … 267 269 }; 268 270 269 static inline void ?{}( exp_backoff_then_block_lock & this ) {271 static inline void ?{}( linear_backoff_then_block_lock & this ) { 270 272 this.spinlock{}; 271 273 this.blocked_threads{}; 272 274 this.lock_value = 0; 273 275 } 274 static inline void ^?{}( exp_backoff_then_block_lock & this ) {}275 // static inline void ?{}( exp_backoff_then_block_lock & this, exp_backoff_then_block_lock this2 ) = void;276 // static inline void ?=?( exp_backoff_then_block_lock & this, exp_backoff_then_block_lock this2 ) = void;277 278 static inline bool internal_try_lock( exp_backoff_then_block_lock & this, size_t & compare_val) with(this) {276 static inline void ^?{}( linear_backoff_then_block_lock & this ) {} 277 // static inline void ?{}( linear_backoff_then_block_lock & this, linear_backoff_then_block_lock this2 ) = void; 278 // static inline void ?=?( linear_backoff_then_block_lock & this, linear_backoff_then_block_lock this2 ) = void; 279 280 static inline bool internal_try_lock(linear_backoff_then_block_lock & this, size_t & compare_val) with(this) { 279 281 if (__atomic_compare_exchange_n(&lock_value, &compare_val, 1, false, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { 280 282 return true; … … 283 285 } 284 286 285 static inline bool try_lock( exp_backoff_then_block_lock & this) { size_t compare_val = 0; return internal_try_lock(this, compare_val); }286 287 static inline bool try_lock_contention( exp_backoff_then_block_lock & this) with(this) {287 static inline bool try_lock(linear_backoff_then_block_lock & this) { size_t compare_val = 0; return internal_try_lock(this, compare_val); } 288 289 static inline bool try_lock_contention(linear_backoff_then_block_lock & this) with(this) { 288 290 if (__atomic_exchange_n(&lock_value, 2, __ATOMIC_ACQUIRE) == 0) { 289 291 return true; … … 292 294 } 293 295 294 static inline bool block( exp_backoff_then_block_lock & this) with(this) {296 static inline bool block(linear_backoff_then_block_lock & this) with(this) { 295 297 lock( spinlock __cfaabi_dbg_ctx2 ); // TODO change to lockfree queue (MPSC) 296 298 if (lock_value != 2) { … … 304 306 } 305 307 306 static inline void lock( exp_backoff_then_block_lock & this) with(this) {308 static inline void lock(linear_backoff_then_block_lock & this) with(this) { 307 309 size_t compare_val = 0; 308 310 int spin = 4; … … 322 324 } 323 325 324 static inline void unlock( exp_backoff_then_block_lock & this) with(this) {326 static inline void unlock(linear_backoff_then_block_lock & this) with(this) { 325 327 if (__atomic_exchange_n(&lock_value, 0, __ATOMIC_RELEASE) == 1) return; 326 328 lock( spinlock __cfaabi_dbg_ctx2 ); … … 330 332 } 331 333 332 static inline void on_notify(exp_backoff_then_block_lock & this, struct thread$ * t ) { unpark(t); } 333 static inline size_t on_wait(exp_backoff_then_block_lock & this) { unlock(this); return 0; } 334 static inline void on_wakeup(exp_backoff_then_block_lock & this, size_t recursion ) { lock(this); } 334 static inline void on_notify(linear_backoff_then_block_lock & this, struct thread$ * t ) { unpark(t); } 335 static inline size_t on_wait(linear_backoff_then_block_lock & this) { unlock(this); return 0; } 336 static inline void on_wakeup(linear_backoff_then_block_lock & this, size_t recursion ) { 337 #ifdef REACQ 338 lock(this); 339 #endif 340 } 335 341 336 342 //----------------------------------------------------------------------------- … … 384 390 385 391 static inline void on_notify(fast_block_lock & this, struct thread$ * t ) with(this) { 386 lock( lock __cfaabi_dbg_ctx2 ); 387 insert_last( blocked_threads, *t ); 388 unlock( lock ); 392 #ifdef REACQ 393 lock( lock __cfaabi_dbg_ctx2 ); 394 insert_last( blocked_threads, *t ); 395 unlock( lock ); 396 #else 397 unpark(t); 398 #endif 389 399 } 390 400 static inline size_t on_wait(fast_block_lock & this) { unlock(this); return 0; } … … 543 553 } 544 554 static inline size_t on_wait(spin_queue_lock & this) { unlock(this); return 0; } 545 static inline void on_wakeup(spin_queue_lock & this, size_t recursion ) { lock(this); } 555 static inline void on_wakeup(spin_queue_lock & this, size_t recursion ) { 556 #ifdef REACQ 557 lock(this); 558 #endif 559 } 546 560 547 561 … … 584 598 static inline void on_notify(mcs_block_spin_lock & this, struct thread$ * t ) { unpark(t); } 585 599 static inline size_t on_wait(mcs_block_spin_lock & this) { unlock(this); return 0; } 586 static inline void on_wakeup(mcs_block_spin_lock & this, size_t recursion ) {lock(this); } 600 static inline void on_wakeup(mcs_block_spin_lock & this, size_t recursion ) { 601 #ifdef REACQ 602 lock(this); 603 #endif 604 } 587 605 588 606 //----------------------------------------------------------------------------- … … 622 640 623 641 static inline void on_notify(block_spin_lock & this, struct thread$ * t ) with(this.lock) { 642 #ifdef REACQ 624 643 // first we acquire internal fast_block_lock 625 644 lock( lock __cfaabi_dbg_ctx2 ); … … 633 652 unlock( lock ); 634 653 654 #endif 635 655 unpark(t); 656 636 657 } 637 658 static inline size_t on_wait(block_spin_lock & this) { unlock(this); return 0; } 638 659 static inline void on_wakeup(block_spin_lock & this, size_t recursion ) with(this) { 660 #ifdef REACQ 639 661 // now we acquire the entire block_spin_lock upon waking up 640 662 while(__atomic_load_n(&held, __ATOMIC_SEQ_CST)) Pause(); 641 663 __atomic_store_n(&held, true, __ATOMIC_RELEASE); 642 664 unlock( lock ); // Now we release the internal fast_spin_lock 665 #endif 643 666 } 644 667 -
src/AST/Expr.cpp
rad861ef r466787a 30 30 #include "Common/SemanticError.h" 31 31 #include "GenPoly/Lvalue.h" // for referencesPermissable 32 #include "ResolvExpr/ Unify.h"// for extractResultType32 #include "ResolvExpr/typeops.h" // for extractResultType 33 33 #include "Tuples/Tuples.h" // for makeTupleType 34 34 -
src/AST/Node.hpp
rad861ef r466787a 19 19 #include <cstddef> // for nullptr_t 20 20 #include <iosfwd> 21 #include <type_traits> // for remove_reference 21 22 22 23 #include "Common/ErrorObjects.h" // for SemanticErrorException … … 35 36 Node(const Node&) : strong_count(0), weak_count(0) {} 36 37 Node(Node&&) : strong_count(0), weak_count(0) {} 37 Node& operator= (const Node&) = delete;38 Node& operator= (Node&&) = delete;38 Node& operator= (const Node&) = delete; 39 Node& operator= (Node&&) = delete; 39 40 virtual ~Node() {} 40 41 -
src/AST/SymbolTable.cpp
rad861ef r466787a 22 22 #include "Inspect.hpp" 23 23 #include "Type.hpp" 24 #include "CodeGen/OperatorTable.h" // for isCtorDtorAssign24 #include "CodeGen/OperatorTable.h" // for isCtorDtorAssign 25 25 #include "Common/SemanticError.h" 26 26 #include "Common/Stats/Counter.h" … … 28 28 #include "InitTweak/InitTweak.h" 29 29 #include "ResolvExpr/Cost.h" 30 #include "ResolvExpr/CandidateFinder.hpp" // for referenceToRvalueConversion 31 #include "ResolvExpr/Unify.h" 30 #include "ResolvExpr/typeops.h" 32 31 #include "SymTab/Mangler.h" 33 32 -
src/CodeGen/CodeGenerator.cc
rad861ef r466787a 273 273 } 274 274 275 template<typename pass_type>276 inline void genEnumInitializer( PassVisitor<pass_type> * visitor, Type * baseType, std::ostream & output,277 Initializer * init, long long * cur_val, Options options) {278 auto baseTypeAsBasic = baseType ? dynamic_cast<BasicType *>( baseType ) : nullptr;279 if ( init ) { // If value has an explicit initiazatior280 output << " = ";281 output << "(" << genType(baseType, "", options) << ")";282 init->accept( *visitor );283 if ( baseTypeAsBasic && baseTypeAsBasic->isInteger() ) { // if it is an integral type and initilizer offered,284 // need to update the cur_val285 Expression* expr = ((SingleInit *)(init))->value;286 while ( auto temp = dynamic_cast<CastExpr *>(expr) ) { // unwrap introduced cast287 expr = temp->arg;288 }289 *cur_val = ((ConstantExpr *)expr)->constant.get_ival()+1;290 }291 } else if ( baseTypeAsBasic && baseTypeAsBasic->isInteger() ) { // integral implicitly init to cur_val + 1292 output << " = " << "(" << genType(baseType, "", options) << ")";293 output << (*cur_val)++;294 }295 }296 297 275 void CodeGenerator::postvisit( EnumDecl * enumDecl ) { 298 276 extension( enumDecl ); 299 277 std::list< Declaration* > &memb = enumDecl->get_members(); 300 278 if (enumDecl->base && ! memb.empty()) { 301 long long cur_val = 0; 279 unsigned long long last_val = -1; // if the first enum value has no explicit initializer, 280 // as other 302 281 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 303 282 ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i ); 304 283 assert( obj ); 305 284 output << "static "; 306 output << genType(enumDecl->base, mangleName( obj ), options); 307 genEnumInitializer( visitor, enumDecl->base, output, obj->get_init(), &cur_val, options); 285 output << genType(enumDecl->base, "", options) << " const "; 286 output << mangleName( obj ) << " "; 287 output << " = "; 288 output << "(" << genType(enumDecl->base, "", options) << ")"; 289 if ( (BasicType *)(enumDecl->base) && ((BasicType *)(enumDecl->base))->isWholeNumber() ) { 290 if ( obj->get_init() ) { 291 obj->get_init()->accept( *visitor ); 292 Expression* expr = ((SingleInit *)(obj->init))->value; 293 while ( auto temp = dynamic_cast<CastExpr *>(expr) ) { 294 expr = temp->arg; 295 } 296 last_val = ((ConstantExpr *)expr)->constant.get_ival(); 297 } else { 298 output << ++last_val; 299 } // if 300 } else { 301 if ( obj->get_init() ) { 302 obj->get_init()->accept( *visitor ); 303 } else { 304 // Should not reach here! 305 } 306 } 308 307 output << ";" << endl; 309 308 } // for -
src/CodeGen/GenType.cc
rad861ef r466787a 255 255 void GenType::postvisit( EnumInstType * enumInst ) { 256 256 if ( enumInst->baseEnum && enumInst->baseEnum->base ) { 257 typeString = genType(enumInst->baseEnum->base, typeString, options);257 typeString = genType(enumInst->baseEnum->base, "", options) + typeString; 258 258 } else { 259 259 typeString = enumInst->name + " " + typeString; -
src/GenPoly/Box.cc
rad861ef r466787a 14 14 // 15 15 16 #include "Box.h"17 18 16 #include <algorithm> // for mismatch 19 17 #include <cassert> // for assert, strict_dynamic_cast … … 25 23 #include <string> // for string, allocator, basic_string 26 24 #include <utility> // for pair 25 26 #include "Box.h" 27 27 28 28 #include "CodeGen/OperatorTable.h" … … 37 37 #include "InitTweak/InitTweak.h" // for getFunctionName, isAssignment 38 38 #include "Lvalue.h" // for generalizedLvalue 39 #include "ResolvExpr/ Unify.h"// for typesCompatible39 #include "ResolvExpr/typeops.h" // for typesCompatible 40 40 #include "ScopedSet.h" // for ScopedSet, ScopedSet<>::iter... 41 41 #include "ScrubTyVars.h" // for ScrubTyVars … … 911 911 912 912 for ( FunctionType const * const funType : functions ) { 913 std::string mangleName = SymTab::Mangler::mangle( funType ); 913 FunctionType *originalFunction = funType->clone(); 914 FunctionType *realFunction = funType->clone(); 915 std::string mangleName = SymTab::Mangler::mangle( realFunction ); 914 916 915 917 // only attempt to create an adapter or pass one as a parameter if we haven't already done so for this 916 918 // pre-substitution parameter function type. 917 919 // The second part of the insert result is "is the value new". 918 if ( !adaptersDone.insert( mangleName ).second ) continue; 919 920 // Apply substitution to type variables to figure out what the adapter's type should look like. 921 assert( env ); 922 FunctionType *realType = funType->clone(); 923 env->apply( realType ); 924 mangleName = SymTab::Mangler::mangle( realType ); 925 mangleName += makePolyMonoSuffix( funType, exprTyVars ); 926 927 typedef ScopedMap< std::string, DeclarationWithType* >::iterator AdapterIter; 928 AdapterIter adapter = adapters.find( mangleName ); 929 if ( adapter == adapters.end() ) { 930 // Adapter has not been created yet in the current scope, so define it. 931 FunctionDecl *newAdapter = makeAdapter( funType, realType, mangleName, exprTyVars ); 932 std::pair< AdapterIter, bool > answer = adapters.insert( mangleName, newAdapter ); 933 adapter = answer.first; 934 stmtsToAddBefore.push_back( new DeclStmt( newAdapter ) ); 920 if ( adaptersDone.insert( mangleName ).second ) { 921 922 // apply substitution to type variables to figure out what the adapter's type should look like 923 assert( env ); 924 env->apply( realFunction ); 925 mangleName = SymTab::Mangler::mangle( realFunction ); 926 mangleName += makePolyMonoSuffix( originalFunction, exprTyVars ); 927 928 typedef ScopedMap< std::string, DeclarationWithType* >::iterator AdapterIter; 929 AdapterIter adapter = adapters.find( mangleName ); 930 if ( adapter == adapters.end() ) { 931 // adapter has not been created yet in the current scope, so define it 932 FunctionDecl *newAdapter = makeAdapter( funType, realFunction, mangleName, exprTyVars ); 933 std::pair< AdapterIter, bool > answer = adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, newAdapter ) ); 934 adapter = answer.first; 935 stmtsToAddBefore.push_back( new DeclStmt( newAdapter ) ); 936 } // if 937 assert( adapter != adapters.end() ); 938 939 // add the appropriate adapter as a parameter 940 appExpr->get_args().push_front( new VariableExpr( adapter->second ) ); 935 941 } // if 936 assert( adapter != adapters.end() );937 938 // Add the appropriate adapter as a parameter.939 appExpr->args.push_front( new VariableExpr( adapter->second ) );940 942 } // for 941 943 } // passAdapters -
src/GenPoly/GenPoly.cc
rad861ef r466787a 24 24 #include <vector> // for vector 25 25 26 #include "AST/Expr.hpp"27 26 #include "AST/Type.hpp" 28 #include "AST/TypeSubstitution.hpp"29 27 #include "GenPoly/ErasableScopedMap.h" // for ErasableScopedMap<>::const_it... 30 28 #include "ResolvExpr/typeops.h" // for flatten … … 492 490 } 493 491 494 /// Flattens a list of types.495 // There is another flattenList in Unify.496 492 void flattenList( vector<ast::ptr<ast::Type>> const & src, 497 493 vector<ast::ptr<ast::Type>> & out ) { -
src/GenPoly/InstantiateGeneric.cc
rad861ef r466787a 28 28 #include "GenPoly.h" // for isPolyType, typesPolyCompatible 29 29 #include "InitTweak/InitTweak.h" 30 #include "ResolvExpr/AdjustExprType.hpp" // for adjustExprType 31 #include "ResolvExpr/Unify.h" // for typesCompatible 30 #include "ResolvExpr/typeops.h" 32 31 #include "ScopedSet.h" // for ScopedSet, ScopedSet<>::iterator 33 32 #include "ScrubTyVars.h" // for ScrubTyVars -
src/GenPoly/InstantiateGenericNew.cpp
rad861ef r466787a 32 32 #include "GenPoly/GenPoly.h" // for isPolyType, typesPolyCompatible 33 33 #include "GenPoly/ScrubTyVars.h" // for scrubAll 34 #include "ResolvExpr/AdjustExprType.hpp" // for adjustExprType 35 #include "ResolvExpr/Unify.h" // for typesCompatible 34 #include "ResolvExpr/typeops.h" // for typesCompatible 36 35 37 36 namespace GenPoly { -
src/InitTweak/FixInit.cc
rad861ef r466787a 39 39 #include "InitTweak.h" // for getFunctionName, getCallArg 40 40 #include "ResolvExpr/Resolver.h" // for findVoidExpression 41 #include "ResolvExpr/ Unify.h"// for typesCompatible41 #include "ResolvExpr/typeops.h" // for typesCompatible 42 42 #include "SymTab/Autogen.h" // for genImplicitCall 43 43 #include "SymTab/Indexer.h" // for Indexer -
src/InitTweak/FixInitNew.cpp
rad861ef r466787a 26 26 #include "GenPoly/GenPoly.h" // for getFunctionType 27 27 #include "ResolvExpr/Resolver.h" // for findVoidExpression 28 #include "ResolvExpr/ Unify.h"// for typesCompatible28 #include "ResolvExpr/typeops.h" // for typesCompatible 29 29 #include "SymTab/Autogen.h" // for genImplicitCall 30 30 #include "SymTab/Indexer.h" // for Indexer -
src/InitTweak/InitTweak.cc
rad861ef r466787a 35 35 #include "GenPoly/GenPoly.h" // for getFunctionType 36 36 #include "InitTweak.h" 37 #include "ResolvExpr/ Unify.h"// for typesCompatibleIgnoreQualifiers37 #include "ResolvExpr/typeops.h" // for typesCompatibleIgnoreQualifiers 38 38 #include "SymTab/Autogen.h" 39 39 #include "SymTab/Indexer.h" // for Indexer -
src/Parser/TypeData.cc
rad861ef r466787a 933 933 member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ) ) ); 934 934 } else if ( !cur->initializer ) { 935 if ( baseType && (!dynamic_cast<BasicType *>(baseType) || !dynamic_cast<BasicType *>(baseType)->is Integer())) {935 if ( baseType && (!dynamic_cast<BasicType *>(baseType) || !dynamic_cast<BasicType *>(baseType)->isWholeNumber())) { 936 936 SemanticError( td->location, "Enumerators of an non-integer typed enum must be explicitly initialized." ); 937 937 } -
src/ResolvExpr/AlternativeFinder.cc
rad861ef r466787a 14 14 // 15 15 16 #include "AlternativeFinder.h"17 18 16 #include <algorithm> // for copy 19 17 #include <cassert> // for strict_dynamic_cast, assert, assertf … … 28 26 29 27 #include "CompilationState.h" // for resolvep 30 #include "AdjustExprType.hpp" // for adjustExprType31 28 #include "Alternative.h" // for AltList, Alternative 29 #include "AlternativeFinder.h" 32 30 #include "AST/Expr.hpp" 33 31 #include "AST/SymbolTable.hpp" 34 32 #include "AST/Type.hpp" 35 #include "CastCost.hpp" // for castCost36 33 #include "Common/SemanticError.h" // for SemanticError 37 34 #include "Common/utility.h" // for deleteAll, printAll, CodeLocation 38 #include "ConversionCost.h" // for conversionCost39 35 #include "Cost.h" // for Cost, Cost::zero, operator<<, Cost... 40 36 #include "ExplodedActual.h" // for ExplodedActual 41 37 #include "InitTweak/InitTweak.h" // for getFunctionName 42 #include "PolyCost.hpp" // for polyCost43 38 #include "RenameVars.h" // for RenameVars, global_renamer 44 39 #include "ResolveAssertions.h" // for resolveAssertions 45 40 #include "ResolveTypeof.h" // for resolveTypeof 46 41 #include "Resolver.h" // for resolveStmtExpr 47 #include "SpecCost.hpp" // for specCost48 42 #include "SymTab/Indexer.h" // for Indexer 49 43 #include "SymTab/Mangler.h" // for Mangler … … 57 51 #include "Tuples/Explode.h" // for explode 58 52 #include "Tuples/Tuples.h" // for isTtype, handleTupleAssignment 59 #include "typeops.h" // for combos60 53 #include "Unify.h" // for unify 54 #include "typeops.h" // for adjustExprType, polyCost, castCost 61 55 62 56 #define PRINT( text ) if ( resolvep ) { text } -
src/ResolvExpr/AlternativeFinder.h
rad861ef r466787a 34 34 namespace ResolvExpr { 35 35 struct ArgPack; 36 37 Cost computeConversionCost( Type * actualType, Type * formalType, bool actualIsLvalue,38 const SymTab::Indexer & indexer, const TypeEnvironment & env );39 40 void referenceToRvalueConversion( Expression *& expr, Cost & cost );41 36 42 37 /// First index is which argument, second index is which alternative for that argument, -
src/ResolvExpr/CandidateFinder.cpp
rad861ef r466787a 23 23 #include <vector> 24 24 25 #include "AdjustExprType.hpp"26 25 #include "Candidate.hpp" 27 #include "CastCost.hpp" // for castCost28 26 #include "CompilationState.h" 29 #include "ConversionCost.h" // for conversionCast30 27 #include "Cost.h" 31 28 #include "ExplodedArg.hpp" 32 #include "PolyCost.hpp"33 29 #include "RenameVars.h" // for renameTyVars 34 30 #include "Resolver.h" 35 31 #include "ResolveTypeof.h" 36 32 #include "SatisfyAssertions.hpp" 37 #include "SpecCost.hpp" 38 #include "typeops.h" // for combos 33 #include "typeops.h" // for adjustExprType, conversionCost, polyCost, specCost 39 34 #include "Unify.h" 40 35 #include "AST/Expr.hpp" -
src/ResolvExpr/CandidateFinder.hpp
rad861ef r466787a 63 63 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 64 64 65 /// Create an expression that preforms reference to rvalue conversion on66 /// the given expression and update the cost of the expression.67 const ast::Expr * referenceToRvalueConversion(68 const ast::Expr * expr, Cost & cost );69 70 65 } // namespace ResolvExpr 71 66 -
src/ResolvExpr/CastCost.cc
rad861ef r466787a 13 13 // Update Count : 9 14 14 // 15 16 #include "CastCost.hpp"17 15 18 16 #include <cassert> // for assert … … 24 22 #include "ConversionCost.h" // for ConversionCost 25 23 #include "Cost.h" // for Cost, Cost::infinity 26 #include "ResolvExpr/ConversionCost.h" // for conversionCost27 #include "ResolvExpr/PtrsCastable.hpp" // for ptrsCastable28 24 #include "ResolvExpr/TypeEnvironment.h" // for TypeEnvironment, EqvClass 29 #include "ResolvExpr/typeops.h" // for ptrsCastable30 #include "ResolvExpr/Unify.h" // for typesCompatibleIgnoreQualifiers31 25 #include "SymTab/Indexer.h" // for Indexer 32 26 #include "SynTree/Declaration.h" // for TypeDecl, NamedTypeDecl 33 27 #include "SynTree/Type.h" // for PointerType, Type, TypeInstType 28 #include "typeops.h" // for typesCompatibleIgnoreQualifiers 34 29 35 30 #if 0 -
src/ResolvExpr/CommonType.cc
rad861ef r466787a 13 13 // Update Count : 24 14 14 // 15 16 #include "CommonType.hpp"17 15 18 16 #include <cassert> // for strict_dynamic_cast -
src/ResolvExpr/ConversionCost.cc
rad861ef r466787a 22 22 #include "ResolvExpr/Cost.h" // for Cost 23 23 #include "ResolvExpr/TypeEnvironment.h" // for EqvClass, TypeEnvironment 24 #include "ResolvExpr/Unify.h" // for typesCompatibleIgnoreQualifiers 25 #include "ResolvExpr/PtrsAssignable.hpp" // for ptrsAssignable 24 #include "ResolvExpr/Unify.h" 26 25 #include "SymTab/Indexer.h" // for Indexer 27 26 #include "SynTree/Declaration.h" // for TypeDecl, NamedTypeDecl 28 27 #include "SynTree/Type.h" // for Type, BasicType, TypeInstType 28 #include "typeops.h" // for typesCompatibleIgnoreQualifiers 29 29 30 30 -
src/ResolvExpr/ConversionCost.h
rad861ef r466787a 32 32 namespace ResolvExpr { 33 33 class TypeEnvironment; 34 35 Cost conversionCost(36 const Type * src, const Type * dest, bool srcIsLvalue,37 const SymTab::Indexer & indexer, const TypeEnvironment & env );38 34 39 35 typedef std::function<Cost(const Type *, const Type *, bool, … … 84 80 const ast::SymbolTable &, const ast::TypeEnvironment &)>; 85 81 86 Cost conversionCost(87 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,88 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env );89 90 Cost convertToReferenceCost( const ast::Type * src, const ast::ReferenceType * dest,91 bool srcIsLvalue, const ast::SymbolTable & indexer, const ast::TypeEnvironment & env,92 PtrsCalculation func );93 94 82 #warning when the old ConversionCost is removed, get ride of the _new suffix. 95 83 class ConversionCost_new : public ast::WithShortCircuiting { … … 131 119 }; 132 120 121 Cost convertToReferenceCost( const ast::Type * src, const ast::ReferenceType * dest, 122 bool srcIsLvalue, const ast::SymbolTable & indexer, const ast::TypeEnvironment & env, 123 PtrsCalculation func ); 124 133 125 } // namespace ResolvExpr 134 126 -
src/ResolvExpr/PtrsAssignable.cc
rad861ef r466787a 14 14 // 15 15 16 #include " PtrsAssignable.hpp"16 #include "typeops.h" 17 17 18 18 #include "AST/Pass.hpp" -
src/ResolvExpr/PtrsCastable.cc
rad861ef r466787a 14 14 // 15 15 16 #include "PtrsCastable.hpp"17 18 16 #include "AST/Decl.hpp" 19 17 #include "AST/Pass.hpp" … … 21 19 #include "AST/TypeEnvironment.hpp" 22 20 #include "Common/PassVisitor.h" 23 #include "ResolvExpr/PtrsAssignable.hpp" // for ptrsAssignable24 21 #include "ResolvExpr/TypeEnvironment.h" // for EqvClass, TypeEnvironment 25 22 #include "SymTab/Indexer.h" // for Indexer … … 27 24 #include "SynTree/Type.h" // for TypeInstType, Type, BasicType 28 25 #include "SynTree/Visitor.h" // for Visitor 26 #include "typeops.h" // for ptrsAssignable 29 27 30 28 namespace ResolvExpr { … … 293 291 return objectCast( src, env, symtab ); 294 292 } else { 295 return ast::Pass<PtrsCastable_new>::read( src, dst, env, symtab ); 293 ast::Pass< PtrsCastable_new > ptrs{ dst, env, symtab }; 294 src->accept( ptrs ); 295 return ptrs.core.result; 296 296 } 297 297 } -
src/ResolvExpr/RenameVars.cc
rad861ef r466787a 83 83 84 84 const ast::TypeInstType * rename( const ast::TypeInstType * type ) { 85 // rename 85 86 auto it = idMap.find( type->name ); 86 if ( it == idMap.end() ) return type; 87 88 // Unconditionally mutate because map will *always* have different name. 89 ast::TypeInstType * mut = ast::shallowCopy( type ); 90 // Reconcile base node since some copies might have been made. 91 mut->base = it->second.base; 92 mut->formal_usage = it->second.formal_usage; 93 mut->expr_id = it->second.expr_id; 94 return mut; 87 if ( it != idMap.end() ) { 88 // unconditionally mutate because map will *always* have different name 89 ast::TypeInstType * mut = ast::shallowCopy( type ); 90 // reconcile base node since some copies might have been made 91 mut->base = it->second.base; 92 mut->formal_usage = it->second.formal_usage; 93 mut->expr_id = it->second.expr_id; 94 type = mut; 95 } 96 97 return type; 95 98 } 96 99 … … 184 187 185 188 const ast::Type * renameTyVars( const ast::Type * t, RenameMode mode, bool reset ) { 189 // ast::Type *tc = ast::deepCopy(t); 186 190 ast::Pass<RenameVars_new> renamer; 187 191 renamer.core.mode = mode; -
src/ResolvExpr/ResolveAssertions.cc
rad861ef r466787a 26 26 #include <vector> // for vector 27 27 28 #include "AdjustExprType.hpp" // for adjustExprType29 28 #include "Alternative.h" // for Alternative, AssertionItem, AssertionList 30 29 #include "Common/FilterCombos.h" // for filterCombos … … 32 31 #include "Common/utility.h" // for sort_mins 33 32 #include "GenPoly/GenPoly.h" // for getFunctionType 34 #include "ResolvExpr/AlternativeFinder.h" // for computeConversionCost35 33 #include "ResolvExpr/RenameVars.h" // for renameTyVars 36 #include "SpecCost.hpp" // for specCost37 34 #include "SymTab/Indexer.h" // for Indexer 38 35 #include "SymTab/Mangler.h" // for Mangler 39 36 #include "SynTree/Expression.h" // for InferredParams 40 37 #include "TypeEnvironment.h" // for TypeEnvironment, etc. 38 #include "typeops.h" // for adjustExprType, specCost 41 39 #include "Unify.h" // for unify 42 40 -
src/ResolvExpr/SatisfyAssertions.cpp
rad861ef r466787a 23 23 #include <vector> 24 24 25 #include "AdjustExprType.hpp"26 25 #include "Candidate.hpp" 27 26 #include "CandidateFinder.hpp" 28 #include "CommonType.hpp"29 27 #include "Cost.h" 30 28 #include "RenameVars.h" 31 #include "SpecCost.hpp"32 29 #include "typeops.h" 33 30 #include "Unify.h" -
src/ResolvExpr/Unify.cc
rad861ef r466787a 33 33 #include "AST/TypeEnvironment.hpp" 34 34 #include "Common/PassVisitor.h" // for PassVisitor 35 #include "CommonType.hpp" // for commonType36 35 #include "FindOpenVars.h" // for findOpenVars 37 #include "SpecCost.hpp" // for SpecCost38 36 #include "SynTree/LinkageSpec.h" // for C 39 37 #include "SynTree/Constant.h" // for Constant … … 45 43 #include "Tuples/Tuples.h" // for isTtype 46 44 #include "TypeEnvironment.h" // for EqvClass, AssertionSet, OpenVarSet 47 #include "typeops.h" // for flatten, occurs 45 #include "typeops.h" // for flatten, occurs, commonType 48 46 49 47 namespace ast { … … 52 50 53 51 namespace SymTab { 54 class Indexer;52 class Indexer; 55 53 } // namespace SymTab 56 54 … … 58 56 59 57 namespace ResolvExpr { 60 61 // Template Helpers:62 template< typename Iterator1, typename Iterator2 >63 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, std::list< Type* > &commonTypes ) {64 for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) {65 Type *commonType = 0;66 if ( ! unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {67 return false;68 } // if69 commonTypes.push_back( commonType );70 } // for71 return ( list1Begin == list1End && list2Begin == list2End );72 }73 74 template< typename Iterator1, typename Iterator2 >75 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) {76 std::list< Type* > commonTypes;77 if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) {78 deleteAll( commonTypes );79 return true;80 } else {81 return false;82 } // if83 }84 58 85 59 struct Unify_old : public WithShortCircuiting { -
src/ResolvExpr/Unify.h
rad861ef r466787a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 13:09:04 2015 11 // Last Modified By : A ndrew Beach12 // Last Modified On : Tue Jan 17 11:12:00 202313 // Update Count : 511 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Mon Jun 18 11:58:00 2018 13 // Update Count : 4 14 14 // 15 15 … … 37 37 38 38 namespace ResolvExpr { 39 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 40 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType ); 41 bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 42 bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer, Type *&common ); 39 43 40 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 41 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType ); 42 bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 43 bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer, Type *&common ); 44 template< typename Iterator1, typename Iterator2 > 45 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, std::list< Type* > &commonTypes ) { 46 for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) { 47 Type *commonType = 0; 48 if ( ! unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 49 return false; 50 } // if 51 commonTypes.push_back( commonType ); 52 } // for 53 if ( list1Begin != list1End || list2Begin != list2End ) { 54 return false; 55 } else { 56 return true; 57 } // if 58 } 44 59 45 bool typesCompatible( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 46 bool typesCompatibleIgnoreQualifiers( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 60 template< typename Iterator1, typename Iterator2 > 61 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) { 62 std::list< Type* > commonTypes; 63 if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) { 64 deleteAll( commonTypes ); 65 return true; 66 } else { 67 return false; 68 } // if 69 } 47 70 48 inline bool typesCompatible( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 49 TypeEnvironment env;50 return typesCompatible( t1, t2, indexer, env );51 } 71 bool unify( 72 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 73 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 74 ast::OpenVarSet & open, const ast::SymbolTable & symtab ); 52 75 53 inline bool typesCompatibleIgnoreQualifiers( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 54 TypeEnvironment env;55 return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env );56 } 76 bool unify( 77 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 78 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 79 ast::OpenVarSet & open, const ast::SymbolTable & symtab, ast::ptr<ast::Type> & common ); 57 80 58 bool unify( 59 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2,60 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have,61 ast::OpenVarSet & open, const ast::SymbolTable & symtab );81 bool unifyExact( 82 const ast::Type * type1, const ast::Type * type2, ast::TypeEnvironment & env, 83 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open, 84 WidenMode widen, const ast::SymbolTable & symtab ); 62 85 63 bool unify( 64 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 65 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 66 ast::OpenVarSet & open, const ast::SymbolTable & symtab, ast::ptr<ast::Type> & common ); 67 68 bool unifyExact( 69 const ast::Type * type1, const ast::Type * type2, ast::TypeEnvironment & env, 70 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open, 71 WidenMode widen, const ast::SymbolTable & symtab ); 72 73 bool unifyInexact( 74 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 75 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 76 const ast::OpenVarSet & open, WidenMode widen, const ast::SymbolTable & symtab, 77 ast::ptr<ast::Type> & common ); 78 79 bool typesCompatible( 80 const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {}, 81 const ast::TypeEnvironment & env = {} ); 82 83 bool typesCompatibleIgnoreQualifiers( 84 const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {}, 85 const ast::TypeEnvironment & env = {} ); 86 87 /// Creates the type represented by the list of returnVals in a FunctionType. 88 /// The caller owns the return value. 89 Type * extractResultType( FunctionType * functionType ); 90 /// Creates or extracts the type represented by returns in a `FunctionType`. 91 ast::ptr<ast::Type> extractResultType( const ast::FunctionType * func ); 92 93 std::vector<ast::ptr<ast::Type>> flattenList( 94 const std::vector<ast::ptr<ast::Type>> & src, ast::TypeEnvironment & env 95 ); 86 bool unifyInexact( 87 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 88 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 89 const ast::OpenVarSet & open, WidenMode widen, const ast::SymbolTable & symtab, 90 ast::ptr<ast::Type> & common ); 96 91 97 92 } // namespace ResolvExpr -
src/ResolvExpr/WidenMode.h
rad861ef r466787a 19 19 struct WidenMode { 20 20 WidenMode( bool first, bool second ): first( first ), second( second ) {} 21 21 22 22 WidenMode &operator|=( const WidenMode &other ) { 23 23 first |= other.first; second |= other.second; return *this; … … 35 35 WidenMode newWM( *this ); newWM &= other; return newWM; 36 36 } 37 37 38 38 operator bool() { return first && second; } 39 39 -
src/ResolvExpr/module.mk
rad861ef r466787a 17 17 SRC_RESOLVEXPR = \ 18 18 ResolvExpr/AdjustExprType.cc \ 19 ResolvExpr/AdjustExprType.hpp \20 19 ResolvExpr/Alternative.cc \ 21 20 ResolvExpr/AlternativeFinder.cc \ … … 27 26 ResolvExpr/Candidate.hpp \ 28 27 ResolvExpr/CastCost.cc \ 29 ResolvExpr/CastCost.hpp \30 28 ResolvExpr/CommonType.cc \ 31 ResolvExpr/CommonType.hpp \32 29 ResolvExpr/ConversionCost.cc \ 33 30 ResolvExpr/ConversionCost.h \ … … 43 40 ResolvExpr/Occurs.cc \ 44 41 ResolvExpr/PolyCost.cc \ 45 ResolvExpr/PolyCost.hpp \46 42 ResolvExpr/PtrsAssignable.cc \ 47 ResolvExpr/PtrsAssignable.hpp \48 43 ResolvExpr/PtrsCastable.cc \ 49 ResolvExpr/PtrsCastable.hpp \50 44 ResolvExpr/RenameVars.cc \ 51 45 ResolvExpr/RenameVars.h \ … … 60 54 ResolvExpr/SatisfyAssertions.hpp \ 61 55 ResolvExpr/SpecCost.cc \ 62 ResolvExpr/SpecCost.hpp \63 56 ResolvExpr/TypeEnvironment.cc \ 64 57 ResolvExpr/TypeEnvironment.h \ -
src/ResolvExpr/typeops.h
rad861ef r466787a 10 10 // Created On : Sun May 17 07:28:22 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jan 18 11:54:00 202313 // Update Count : 712 // Last Modified On : Tue Oct 1 09:45:00 2019 13 // Update Count : 6 14 14 // 15 15 … … 18 18 #include <vector> 19 19 20 #include "Cost.h" 21 #include "TypeEnvironment.h" 22 #include "WidenMode.h" 23 #include "AST/Fwd.hpp" 24 #include "AST/Node.hpp" 25 #include "AST/SymbolTable.hpp" 20 26 #include "AST/Type.hpp" 27 #include "AST/TypeEnvironment.hpp" 28 #include "SynTree/SynTree.h" 21 29 #include "SynTree/Type.h" 22 30 … … 26 34 27 35 namespace ResolvExpr { 28 class TypeEnvironment;29 30 36 // combos: takes a list of sets and returns a set of lists representing every possible way of forming a list by 31 37 // picking one element out of each set … … 55 61 } 56 62 63 // in AdjustExprType.cc 64 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function 65 void adjustExprType( Type *& type, const TypeEnvironment & env, const SymTab::Indexer & indexer ); 66 67 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function using empty TypeEnvironment and Indexer 68 void adjustExprType( Type *& type ); 69 70 template< typename ForwardIterator > 71 void adjustExprTypeList( ForwardIterator begin, ForwardIterator end, const TypeEnvironment & env, const SymTab::Indexer & indexer ) { 72 while ( begin != end ) { 73 adjustExprType( *begin++, env, indexer ); 74 } // while 75 } 76 77 /// Replaces array types with equivalent pointer, and function types with a pointer-to-function 78 const ast::Type * adjustExprType( 79 const ast::Type * type, const ast::TypeEnvironment & env, const ast::SymbolTable & symtab ); 80 81 // in CastCost.cc 82 Cost castCost( const Type * src, const Type * dest, bool srcIsLvalue, 83 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 84 Cost castCost( 85 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 86 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 87 88 // in ConversionCost.cc 89 Cost conversionCost( const Type * src, const Type * dest, bool srcIsLvalue, 90 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 91 Cost conversionCost( 92 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 93 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 94 95 // in AlternativeFinder.cc 96 Cost computeConversionCost( Type * actualType, Type * formalType, bool actualIsLvalue, 97 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 98 99 // in PtrsAssignable.cc 100 int ptrsAssignable( const Type * src, const Type * dest, const TypeEnvironment & env ); 101 int ptrsAssignable( const ast::Type * src, const ast::Type * dst, 102 const ast::TypeEnvironment & env ); 103 104 // in PtrsCastable.cc 105 int ptrsCastable( const Type * src, const Type * dest, const TypeEnvironment & env, const SymTab::Indexer & indexer ); 106 int ptrsCastable( 107 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab, 108 const ast::TypeEnvironment & env ); 109 110 // in Unify.cc 111 bool typesCompatible( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 112 bool typesCompatibleIgnoreQualifiers( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 113 114 inline bool typesCompatible( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 115 TypeEnvironment env; 116 return typesCompatible( t1, t2, indexer, env ); 117 } 118 119 inline bool typesCompatibleIgnoreQualifiers( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 120 TypeEnvironment env; 121 return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env ); 122 } 123 124 bool typesCompatible( 125 const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {}, 126 const ast::TypeEnvironment & env = {} ); 127 128 bool typesCompatibleIgnoreQualifiers( 129 const ast::Type *, const ast::Type *, const ast::SymbolTable &, 130 const ast::TypeEnvironment & env = {} ); 131 132 /// creates the type represented by the list of returnVals in a FunctionType. The caller owns the return value. 133 Type * extractResultType( FunctionType * functionType ); 134 /// Creates or extracts the type represented by the list of returns in a `FunctionType`. 135 ast::ptr<ast::Type> extractResultType( const ast::FunctionType * func ); 136 137 // in CommonType.cc 138 Type * commonType( Type * type1, Type * type2, bool widenFirst, bool widenSecond, const SymTab::Indexer & indexer, TypeEnvironment & env, const OpenVarSet & openVars ); 139 ast::ptr< ast::Type > commonType( 140 const ast::ptr< ast::Type > & type1, const ast::ptr< ast::Type > & type2, 141 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 142 const ast::OpenVarSet & open, WidenMode widen, const ast::SymbolTable & symtab 143 ); 144 // in Unify.cc 145 std::vector< ast::ptr< ast::Type > > flattenList( 146 const std::vector< ast::ptr< ast::Type > > & src, ast::TypeEnvironment & env 147 ); 148 149 // in PolyCost.cc 150 int polyCost( Type * type, const TypeEnvironment & env, const SymTab::Indexer & indexer ); 151 int polyCost( 152 const ast::Type * type, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 153 154 // in SpecCost.cc 155 int specCost( Type * type ); 156 int specCost( const ast::Type * type ); 157 57 158 // in Occurs.cc 58 159 bool occurs( const Type * type, const std::string & varName, const TypeEnvironment & env ); … … 67 168 return false; 68 169 } 170 171 // in AlternativeFinder.cc 172 void referenceToRvalueConversion( Expression *& expr, Cost & cost ); 173 // in CandidateFinder.cpp 174 const ast::Expr * referenceToRvalueConversion( const ast::Expr * expr, Cost & cost ); 69 175 70 176 /// flatten tuple type into list of types … … 112 218 } 113 219 220 114 221 return new ast::TupleType{ std::move(types) }; 115 222 } … … 120 227 return tupleFromTypes( tys.begin(), tys.end() ); 121 228 } 229 230 122 231 123 232 // in TypeEnvironment.cc -
src/SymTab/Indexer.cc
rad861ef r466787a 31 31 #include "InitTweak/InitTweak.h" // for isConstructor, isCopyFunction, isC... 32 32 #include "Mangler.h" // for Mangler 33 #include "ResolvExpr/AlternativeFinder.h" // for referenceToRvalueConversion 34 #include "ResolvExpr/Unify.h" // for typesCompatible 33 #include "ResolvExpr/typeops.h" // for typesCompatible 35 34 #include "SynTree/LinkageSpec.h" // for isMangled, isOverridable, Spec 36 35 #include "SynTree/Constant.h" // for Constant -
src/SymTab/Mangler.cc
rad861ef r466787a 439 439 private: 440 440 void mangleDecl( const ast::DeclWithType *declaration ); 441 void mangleRef( const ast::BaseInstType *refType, const std::string &prefix );441 void mangleRef( const ast::BaseInstType *refType, std::string prefix ); 442 442 443 443 void printQualifiers( const ast::Type *type ); … … 535 535 } 536 536 537 __attribute__((unused)) 538 inline std::vector< ast::ptr< ast::Type > > getTypes( const std::vector< ast::ptr< ast::DeclWithType > > & decls ) { 539 std::vector< ast::ptr< ast::Type > > ret; 540 std::transform( decls.begin(), decls.end(), std::back_inserter( ret ), 541 std::mem_fun( &ast::DeclWithType::get_type ) ); 542 return ret; 543 } 544 537 545 void Mangler_new::postvisit( const ast::FunctionType * functionType ) { 538 546 printQualifiers( functionType ); … … 550 558 } 551 559 552 void Mangler_new::mangleRef( 553 const ast::BaseInstType * refType, const std::string & prefix ) { 560 void Mangler_new::mangleRef( const ast::BaseInstType * refType, std::string prefix ) { 554 561 printQualifiers( refType ); 555 562 556 563 mangleName += prefix + std::to_string( refType->name.length() ) + refType->name; 557 564 558 if ( mangleGenericParams && ! refType->params.empty() ) { 559 mangleName += "_"; 560 for ( const ast::Expr * param : refType->params ) { 561 auto paramType = dynamic_cast< const ast::TypeExpr * >( param ); 562 assertf(paramType, "Aggregate parameters should be type expressions: %s", toCString(param)); 563 maybeAccept( paramType->type.get(), *visitor ); 565 if ( mangleGenericParams ) { 566 if ( ! refType->params.empty() ) { 567 mangleName += "_"; 568 for ( const ast::Expr * param : refType->params ) { 569 auto paramType = dynamic_cast< const ast::TypeExpr * >( param ); 570 assertf(paramType, "Aggregate parameters should be type expressions: %s", toCString(param)); 571 maybeAccept( paramType->type.get(), *visitor ); 572 } 573 mangleName += "_"; 564 574 } 565 mangleName += "_";566 575 } 567 576 } … … 647 656 } 648 657 649 // For debugging:650 658 __attribute__((unused)) void printVarMap( const std::map< std::string, std::pair< int, int > > &varMap, std::ostream &os ) { 651 659 for ( std::map< std::string, std::pair< int, int > >::const_iterator i = varMap.begin(); i != varMap.end(); ++i ) { … … 657 665 // skip if not including qualifiers 658 666 if ( typeMode ) return; 659 auto funcType = dynamic_cast<const ast::FunctionType *>( type ); 660 if ( funcType && !funcType->forall.empty() ) { 661 std::list< std::string > assertionNames; 662 int dcount = 0, fcount = 0, vcount = 0, acount = 0; 663 mangleName += Encoding::forall; 664 for ( auto & decl : funcType->forall ) { 665 switch ( decl->kind ) { 666 case ast::TypeDecl::Dtype: 667 dcount++; 668 break; 669 case ast::TypeDecl::Ftype: 670 fcount++; 671 break; 672 case ast::TypeDecl::Ttype: 673 vcount++; 674 break; 675 default: 676 assertf( false, "unimplemented kind for type variable %s", SymTab::Mangler::Encoding::typeVariables[decl->kind].c_str() ); 677 } // switch 678 varNums[ decl->name ] = std::make_pair( nextVarNum, (int)decl->kind ); 679 } // for 680 for ( auto & assert : funcType->assertions ) { 681 assertionNames.push_back( ast::Pass<Mangler_new>::read( 682 assert->var.get(), 683 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, varNums ) ); 684 acount++; 685 } // for 686 mangleName += std::to_string( dcount ) + "_" + std::to_string( fcount ) + "_" + std::to_string( vcount ) + "_" + std::to_string( acount ) + "_"; 687 for ( const auto & a : assertionNames ) mangleName += a; 688 mangleName += "_"; 667 if ( auto ptype = dynamic_cast< const ast::FunctionType * >(type) ) { 668 if ( ! ptype->forall.empty() ) { 669 std::list< std::string > assertionNames; 670 int dcount = 0, fcount = 0, vcount = 0, acount = 0; 671 mangleName += Encoding::forall; 672 for ( auto & decl : ptype->forall ) { 673 switch ( decl->kind ) { 674 case ast::TypeDecl::Kind::Dtype: 675 dcount++; 676 break; 677 case ast::TypeDecl::Kind::Ftype: 678 fcount++; 679 break; 680 case ast::TypeDecl::Kind::Ttype: 681 vcount++; 682 break; 683 default: 684 assertf( false, "unimplemented kind for type variable %s", SymTab::Mangler::Encoding::typeVariables[decl->kind].c_str() ); 685 } // switch 686 varNums[ decl->name ] = std::make_pair( nextVarNum, (int)decl->kind ); 687 } // for 688 for ( auto & assert : ptype->assertions ) { 689 assertionNames.push_back( ast::Pass<Mangler_new>::read( 690 assert->var.get(), 691 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, varNums ) ); 692 acount++; 693 } // for 694 mangleName += std::to_string( dcount ) + "_" + std::to_string( fcount ) + "_" + std::to_string( vcount ) + "_" + std::to_string( acount ) + "_"; 695 for(const auto & a : assertionNames) mangleName += a; 696 // std::copy( assertionNames.begin(), assertionNames.end(), std::ostream_iterator< std::string >( mangleName, "" ) ); 697 mangleName += "_"; 698 } // if 689 699 } // if 690 700 if ( ! inFunctionType ) { -
src/SymTab/Validate.cc
rad861ef r466787a 63 63 #include "InitTweak/GenInit.h" // for fixReturnStatements 64 64 #include "InitTweak/InitTweak.h" // for isCtorDtorAssign 65 #include "ResolvExpr/typeops.h" // for extractResultType 66 #include "ResolvExpr/Unify.h" // for typesCompatible 65 #include "ResolvExpr/typeops.h" // for typesCompatible 67 66 #include "ResolvExpr/Resolver.h" // for findSingleExpression 68 67 #include "ResolvExpr/ResolveTypeof.h" // for resolveTypeof -
src/SynTree/ApplicationExpr.cc
rad861ef r466787a 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ApplicationExpr.cc --7 // ApplicationExpr.cc.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 26 26 #include "Expression.h" // for ParamEntry, ApplicationExpr, Expression 27 27 #include "InitTweak/InitTweak.h" // for getFunction 28 #include "ResolvExpr/ Unify.h"// for extractResultType28 #include "ResolvExpr/typeops.h" // for extractResultType 29 29 #include "Type.h" // for Type, PointerType, FunctionType 30 30 -
src/SynTree/BasicType.cc
rad861ef r466787a 29 29 } 30 30 31 bool BasicType::isWholeNumber() const { 32 return kind == Bool || 33 kind ==Char || 34 kind == SignedChar || 35 kind == UnsignedChar || 36 kind == ShortSignedInt || 37 kind == ShortUnsignedInt || 38 kind == SignedInt || 39 kind == UnsignedInt || 40 kind == LongSignedInt || 41 kind == LongUnsignedInt || 42 kind == LongLongSignedInt || 43 kind ==LongLongUnsignedInt || 44 kind == SignedInt128 || 45 kind == UnsignedInt128; 46 } 47 31 48 bool BasicType::isInteger() const { 32 49 return kind <= UnsignedInt128; -
src/SynTree/Type.h
rad861ef r466787a 271 271 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 272 272 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 273 bool isWholeNumber() const; 273 274 bool isInteger() const; 274 275 }; -
src/Validate/FixReturnTypes.cpp
rad861ef r466787a 20 20 #include "AST/Type.hpp" 21 21 #include "CodeGen/CodeGenerator.h" 22 #include "ResolvExpr/ Unify.h"22 #include "ResolvExpr/typeops.h" 23 23 24 24 namespace ast { -
src/Validate/ReplaceTypedef.cpp
rad861ef r466787a 20 20 #include "Common/UniqueName.h" 21 21 #include "Common/utility.h" 22 #include "ResolvExpr/ Unify.h"22 #include "ResolvExpr/typeops.h" 23 23 24 24 namespace Validate { -
tests/Makefile.am
rad861ef r466787a 88 88 io/.in/many_read.data \ 89 89 meta/fork+exec.hfa \ 90 concurrent/unified_locking/mutex_test.hfa \ 91 concurrent/channels/parallel_harness.hfa 90 unified_locking/mutex_test.hfa 92 91 93 92 dist-hook: -
tests/concurrent/futures/typed.cfa
rad861ef r466787a 5 5 thread Server { 6 6 int cnt; 7 single_future(int) * requests[NFUTURES];7 future(int) * requests[NFUTURES]; 8 8 }; 9 9 … … 24 24 void process( Server & this, int i ) { 25 25 if( this.requests[i] == 0p ) return; 26 single_future(int) * f = this.requests[i];26 future(int) * f = this.requests[i]; 27 27 this.requests[i] = 0p; 28 28 this.cnt--; … … 30 30 } 31 31 32 void call( Server & mutex this, single_future(int) & f ) {32 void call( Server & mutex this, future(int) & f ) { 33 33 for(i; NFUTURES) { 34 34 if( this.requests[i] == 0p ) { … … 70 70 71 71 void work(void) { 72 single_future(int) mine;72 future(int) mine; 73 73 call( *the_server, mine ); 74 74 wait( mine ); -
tests/concurrent/mutexstmt/locks.cfa
rad861ef r466787a 72 72 73 73 single_acquisition_lock l1; 74 exp_backoff_then_block_lock l2;74 linear_backoff_then_block_lock l2; 75 75 owner_lock l3; 76 76 -
tests/enum_tests/.expect/typedIntEnum.txt
rad861ef r466787a 1 0 =02 1 =13 1000 =10004 1001 =10015 2000 =20006 2001 =20017 2002 =20021 0 2 1 3 1000 4 1001 5 2000 6 2001 7 2002 -
tests/enum_tests/pointerEnum.cfa
rad861ef r466787a 11 11 int main() { 12 12 E * v = First; 13 //sout | "v: " | e.x;13 sout | "v: " | e.x; 14 14 } -
tests/enum_tests/typedIntEnum.cfa
rad861ef r466787a 12 12 13 13 int main() { 14 printf(" 0=%d\n", zero);15 printf(" 1=%d\n", one);16 printf(" 1000=%d\n", thousand);17 printf(" 1001=%d\n", thousand_one);18 printf(" 2000=%d\n", two_thousand);19 printf(" 2001=%d\n", two_thousand_one);20 printf(" 2002=%d\n", two_thousand_two);14 printf("%d\n", zero); 15 printf("%d\n", one); 16 printf("%d\n", thousand); 17 printf("%d\n", thousand_one); 18 printf("%d\n", two_thousand); 19 printf("%d\n", two_thousand_one); 20 printf("%d\n", two_thousand_two); 21 21 return 0; 22 22 }
Note:
See TracChangeset
for help on using the changeset viewer.