Changeset e1056381


Ignore:
Timestamp:
Apr 7, 2020, 3:41:37 PM (20 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast, new-ast-unique-expr
Children:
b72bc043
Parents:
ed12051 (diff), dccd1b0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
4 added
3 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • libcfa/prelude/Makefile.in

    red12051 re1056381  
    1 # Makefile.in generated by automake 1.16.1 from Makefile.am.
     1# Makefile.in generated by automake 1.15 from Makefile.am.
    22# @configure_input@
    33
    4 # Copyright (C) 1994-2018 Free Software Foundation, Inc.
     4# Copyright (C) 1994-2014 Free Software Foundation, Inc.
    55
    66# This Makefile.in is free software; the Free Software Foundation
     
    331331            cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
    332332          *) \
    333             echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
    334             cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
     333            echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
     334            cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
    335335        esac;
    336336
     
    377377
    378378
    379 distdir: $(BUILT_SOURCES)
    380         $(MAKE) $(AM_MAKEFLAGS) distdir-am
    381 
    382 distdir-am: $(DISTFILES)
     379distdir: $(DISTFILES)
    383380        @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
    384381        topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
  • libcfa/src/Makefile.am

    red12051 re1056381  
    3333# The built sources must not depend on the installed headers
    3434AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    35 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
     35AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -fexceptions -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3636AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3737CFACC = @CFACC@
  • libcfa/src/Makefile.in

    red12051 re1056381  
    456456# The built sources must not depend on the installed headers
    457457AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    458 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
     458AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -fexceptions -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
    459459AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
    460460@BUILDLIB_FALSE@headers_nosrc =
  • libcfa/src/bitmanip.hfa

    red12051 re1056381  
    1111// Created On       : Sat Mar 14 18:12:27 2020
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Mon Mar 16 14:28:46 2020
    14 // Update Count     : 49
     13// Last Modified On : Mon Apr  6 22:17:19 2020
     14// Update Count     : 78
    1515//
    1616
     
    2323#include <assert.h>
    2424
     25#define __bitsizeof( n ) (sizeof(n) * __CHAR_BIT__)
     26
    2527static inline {
    2628    // Count leading 0 bits.
    27     unsigned int cl0( unsigned char n ) { return n != 0 ? __builtin_clz( n ) - (sizeof(unsigned int) * __CHAR_BIT__ - sizeof(n) * __CHAR_BIT__) : sizeof(n) * __CHAR_BIT__; }
    28     unsigned int cl0( unsigned short int n ) { return n != 0 ? __builtin_clz( n ) - (sizeof(unsigned int) * __CHAR_BIT__ - sizeof(n) * __CHAR_BIT__) : sizeof(n) * __CHAR_BIT__; }
    29     unsigned int cl0( unsigned int n ) { return n != 0 ? __builtin_clz( n ) : sizeof(n) * __CHAR_BIT__; }
    30     unsigned int cl0( unsigned long int n ) { return n != 0 ? __builtin_clzl( n ) : sizeof(n) * __CHAR_BIT__; }
    31     unsigned int cl0( unsigned long long int n ) { return n != 0 ? __builtin_clzll( n ) : sizeof(n) * __CHAR_BIT__; }
     29    unsigned int leading0s( unsigned char n ) { return n != 0 ? __builtin_clz( n ) - (__bitsizeof(unsigned int) - __bitsizeof(n)) : __bitsizeof(n); }
     30    unsigned int leading0s( unsigned short int n ) { return n != 0 ? __builtin_clz( n ) - (__bitsizeof(unsigned int) - __bitsizeof(n)) : __bitsizeof(n); }
     31    unsigned int leading0s( unsigned int n ) { return n != 0 ? __builtin_clz( n ) : __bitsizeof(n); }
     32    unsigned int leading0s( unsigned long int n ) { return n != 0 ? __builtin_clzl( n ) : __bitsizeof(n); }
     33    unsigned int leading0s( unsigned long long int n ) { return n != 0 ? __builtin_clzll( n ) : __bitsizeof(n); }
    3234
    3335    // Count trailing 0 bits.
    34     unsigned int ct0( unsigned char n ) { return n != 0 ? __builtin_ctz( n ) : sizeof(n) * __CHAR_BIT__; }
    35     unsigned int ct0( unsigned short int n ) { return n != 0 ? __builtin_ctz( n ) : sizeof(n) * __CHAR_BIT__; }
    36     unsigned int ct0( unsigned int n ) { return n != 0 ? __builtin_ctz( n ) : sizeof(n) * __CHAR_BIT__; }
    37     unsigned int ct0( unsigned long int n ) { return n != 0 ? __builtin_ctzl( n ) : sizeof(n) * __CHAR_BIT__; }
    38     unsigned int ct0( unsigned long long int n ) { return n != 0 ? __builtin_ctzll( n ) : sizeof(n) * __CHAR_BIT__; }
     36    unsigned int trailing0s( unsigned char n ) { return n != 0 ? __builtin_ctz( n ) : __bitsizeof(n); }
     37    unsigned int trailing0s( unsigned short int n ) { return n != 0 ? __builtin_ctz( n ) : __bitsizeof(n); }
     38    unsigned int trailing0s( unsigned int n ) { return n != 0 ? __builtin_ctz( n ) : __bitsizeof(n); }
     39    unsigned int trailing0s( unsigned long int n ) { return n != 0 ? __builtin_ctzl( n ) : __bitsizeof(n); }
     40    unsigned int trailing0s( unsigned long long int n ) { return n != 0 ? __builtin_ctzll( n ) : __bitsizeof(n); }
    3941
    4042    // Count all 1 bits.
    41     unsigned int ca1( unsigned char n ) { return __builtin_popcount( n ); }
    42     unsigned int ca1( unsigned short int n ) { return __builtin_popcount( n ); }
    43     unsigned int ca1( unsigned int n ) { return __builtin_popcount( n ); }
    44     unsigned int ca1( unsigned long int n ) { return __builtin_popcountl( n ); }
    45     unsigned int ca1( unsigned long long int n ) { return __builtin_popcountll( n ); }
     43    unsigned int all1s( unsigned char n ) { return __builtin_popcount( n ); }
     44    unsigned int all1s( unsigned short int n ) { return __builtin_popcount( n ); }
     45    unsigned int all1s( unsigned int n ) { return __builtin_popcount( n ); }
     46    unsigned int all1s( unsigned long int n ) { return __builtin_popcountl( n ); }
     47    unsigned int all1s( unsigned long long int n ) { return __builtin_popcountll( n ); }
    4648
    4749    // Count all 0 bits.
    48     unsigned int ca0( unsigned char n ) { return sizeof(n) * __CHAR_BIT__ - __builtin_popcount( n ); }
    49     unsigned int ca0( unsigned short int n ) { return sizeof(n) * __CHAR_BIT__ - __builtin_popcount( n ); }
    50     unsigned int ca0( unsigned int n ) { return sizeof(n) * __CHAR_BIT__ - __builtin_popcount( n ); }
    51     unsigned int ca0( unsigned long int n ) { return sizeof(n) * __CHAR_BIT__ - __builtin_popcountl( n ); }
    52     unsigned int ca0( unsigned long long int n ) { return sizeof(n) * __CHAR_BIT__ - __builtin_popcountll( n ); }
     50    unsigned int all0s( unsigned char n ) { return __bitsizeof(n) - __builtin_popcount( n ); }
     51    unsigned int all0s( unsigned short int n ) { return __bitsizeof(n) - __builtin_popcount( n ); }
     52    unsigned int all0s( unsigned int n ) { return __bitsizeof(n) - __builtin_popcount( n ); }
     53    unsigned int all0s( unsigned long int n ) { return __bitsizeof(n) - __builtin_popcountl( n ); }
     54    unsigned int all0s( unsigned long long int n ) { return __bitsizeof(n) - __builtin_popcountll( n ); }
    5355
    54     // Find least significiant set bit. (ffs)
    55     unsigned int fls( unsigned int n ) { return __builtin_ffs( n ); }
    56     unsigned int fls( unsigned long int n ) { return __builtin_ffsl( n ); }
    57     unsigned int fls( unsigned long long int n ) { return __builtin_ffsll( n ); }
     56    // Find least significiant zero bit. (ffs)
     57    unsigned int low0( unsigned char n ) { return __builtin_ffs( (typeof(n))~n ); }
     58    unsigned int low0( unsigned short int n ) { return __builtin_ffs( (typeof(n))~n ); }
     59    unsigned int low0( unsigned int n ) { return __builtin_ffs( ~n ); }
     60    unsigned int low0( unsigned long int n ) { return __builtin_ffsl( ~n ); }
     61    unsigned int low0( unsigned long long int n ) { return __builtin_ffsll( ~n ); }
    5862
    59     // Find most significiant set bit.
    60     unsigned int fms( unsigned char n ) { return n != 0 ? sizeof(unsigned int) * __CHAR_BIT__ - __builtin_clz( n ) : 0; }
    61     unsigned int fms( unsigned short int n ) { return n != 0 ? sizeof(unsigned int) * __CHAR_BIT__ - __builtin_clz( n ) : 0; }
    62     unsigned int fms( unsigned int n ) { return n != 0 ? sizeof(n) * __CHAR_BIT__ - __builtin_clz( n ) : 0; }
    63     unsigned int fms( unsigned long int n ) { return n != 0 ? sizeof(n) * __CHAR_BIT__ - __builtin_clzl( n ) : 0; }
    64     unsigned int fms( unsigned long long int n ) { return n != 0 ? sizeof(n) * __CHAR_BIT__ - __builtin_clzll( n ) : 0; }
     63    // Find least significiant one bit.
     64    unsigned int low1( unsigned int n ) { return __builtin_ffs( n ); }
     65    unsigned int low1( unsigned long int n ) { return __builtin_ffsl( n ); }
     66    unsigned int low1( unsigned long long int n ) { return __builtin_ffsll( n ); }
    6567
    66     // Check for power of 2
    67     bool pow2( unsigned long int value ) {
    68                 return (value & (value - 1)) == 0;                              // clears bits below value, rounding down to the next lower multiple of value
    69     } // pow2
     68    // Find most significiant zero bit.
     69    unsigned int high0( unsigned char n ) { return n != (typeof(n))-1 ? __bitsizeof(unsigned int) - __builtin_clz( (typeof(n))~n ) : 0; }
     70    unsigned int high0( unsigned short int n ) { return n != (typeof(n))-1 ? __bitsizeof(unsigned int) - __builtin_clz( (typeof(n))~n ) : 0; }
     71    unsigned int high0( unsigned int n ) { return n != -1 ? __bitsizeof(n) - __builtin_clz( ~n ) : 0; }
     72    unsigned int high0( unsigned long int n ) { return n != -1 ? __bitsizeof(n) - __builtin_clzl( ~n ) : 0; }
     73    unsigned int high0( unsigned long long int n ) { return n != -1 ? __bitsizeof(n) - __builtin_clzll( ~n ) : 0; }
    7074
    71     // Returns value aligned at the floor of align.
    72     unsigned long int floor( unsigned long int value, unsigned long int align ) {
    73                 assert( pow2( align ) );
    74                 return value & -align;                                                  // clear bits above or equal to align, giving value % align
    75     } // floor
     75    // Find most significiant one bit.
     76    unsigned int high1( unsigned char n ) { return n != 0 ? __bitsizeof(unsigned int) - __builtin_clz( n ) : 0; }
     77    unsigned int high1( unsigned short int n ) { return n != 0 ? __bitsizeof(unsigned int) - __builtin_clz( n ) : 0; }
     78    unsigned int high1( unsigned int n ) { return n != 0 ? __bitsizeof(n) - __builtin_clz( n ) : 0; }
     79    unsigned int high1( unsigned long int n ) { return n != 0 ? __bitsizeof(n) - __builtin_clzl( n ) : 0; }
     80    unsigned int high1( unsigned long long int n ) { return n != 0 ? __bitsizeof(n) - __builtin_clzll( n ) : 0; }
    7681
    77     // Returns value aligned at the ceiling of align.
    78     unsigned long int ceiling( unsigned long int value, unsigned long int align ) {
    79                 assert( pow2( align ) );
    80                 return -floor( -value, align );                                 // negate, round down, negate is the same as round up
    81     } // ceiling
    82 }
     82    // Check for power of 2, clears bits below value, rounding down to the next lower multiple of value.
     83    bool is_pow2( int value ) { return (value & (value - 1)) == 0; }
     84    bool is_pow2( unsigned long long int value ) { return (value & (value - 1)) == 0; }
     85
     86    // Returns value aligned at the floor of align, clear bits above or equal to align, giving value % align.
     87    unsigned int floor2( unsigned int value, unsigned int align ) { assert( is_pow2( align ) ); return value & -align; }
     88    unsigned long long int floor2( unsigned long long int value, unsigned long long int align ) { assert( is_pow2( align ) ); return value & -align; }
     89
     90    unsigned int floor( unsigned int value, unsigned int align ) { return value / align * align; }
     91    unsigned long long int floor( unsigned long long int value, unsigned long long int align ) { return value / align * align; }
     92
     93    // Returns value aligned at the ceiling of align, negate, round down, negate is the same as round up.
     94    unsigned int ceiling2( unsigned int value, unsigned int align ) { assert( is_pow2( align ) ); return -floor2( -value, align ); }
     95    unsigned long long int ceiling2( unsigned long long int value, unsigned long long int align ) { assert( is_pow2( align ) ); return -floor2( -value, align ); }
     96
     97    unsigned int ceiling( unsigned int value, unsigned int align ) { return (value + (align - 1)) / align; }
     98    unsigned long long int ceiling( unsigned long long int value, unsigned long long int align ) { return (value + (align - 1)) / align; }
     99} // distribution
    83100
    84101// Local Variables: //
  • libcfa/src/exception.c

    red12051 re1056381  
    1010// Created On       : Mon Jun 26 15:13:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Apr 03 11:57:00 2020
    13 // Update Count     : 14
     12// Last Modified On : Mon Apr 06 14:40:00 2020
     13// Update Count     : 15
    1414//
    1515
     
    7575// RESUMPTION ================================================================
    7676
     77static void reset_top_resume(struct __cfaehm_try_resume_node ** store) {
     78        this_exception_context()->top_resume = *store;
     79}
     80
    7781void __cfaehm_throw_resume(exception_t * except) {
    7882        struct exception_context_t * context = this_exception_context();
     
    8084        __cfaabi_dbg_print_safe("Throwing resumption exception\n");
    8185
     86        __attribute__((cleanup(reset_top_resume)))
    8287        struct __cfaehm_try_resume_node * original_head = context->top_resume;
    8388        struct __cfaehm_try_resume_node * current = context->top_resume;
     
    8691                context->top_resume = current->next;
    8792                if (current->handler(except)) {
    88                         context->top_resume = original_head;
    8993                        return;
    9094                }
     
    9296
    9397        __cfaabi_dbg_print_safe("Unhandled exception\n");
    94         context->top_resume = original_head;
    9598
    9699        // Fall back to termination:
  • tests/.expect/alloc.txt

    red12051 re1056381  
    3535CFA realloc array alloc, fill
    36360xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
    37 CFA realloc array alloc, 5
    38 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
    39 CFA realloc array alloc, 5
    40 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    41 CFA realloc array alloc, 5
    42 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
    4337
    4438C   memalign 42 42.5
  • tests/alloc.cfa

    red12051 re1056381  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr  1 10:58:35 2020
    13 // Update Count     : 424
     12// Last Modified On : Mon Apr  6 21:08:23 2020
     13// Update Count     : 428
    1414//
    1515
     
    151151        ip = alloc_set( ip, 3 * dim, fill );                            // CFA realloc array alloc, fill
    152152        printf( "CFA realloc array alloc, fill\n" );
    153         for ( i; 3 * dim ) { printf( "%#x ", ip[i] );; }
    154         printf( "\n" );
    155         // do not free
    156 
    157         ip = alloc_set( ip, 3 * dim, 5 );                                       // CFA realloc array alloc, 5
     153        for ( i; 3 * dim ) { printf( "%#x ", ip[i] ); }
     154        printf( "\n" );
     155        // do not free
     156#if 0 // FIX ME
     157        ip = alloc_set( ip, 5 * dim, 5 );                                       // CFA realloc array alloc, 5
    158158        printf( "CFA realloc array alloc, 5\n" );
    159         for ( i; 3 * dim ) { printf( "%#x ", ip[i] ); }
     159        for ( i; 5 * dim ) { printf( "%#x ", ip[i] ); }
    160160        printf( "\n" );
    161161        // do not free
     
    167167        // do not free
    168168
    169         ip = alloc_set( ip, 3 * dim, 5 );                                       // CFA realloc array alloc, 5
     169        ip = alloc_set( ip, 5 * dim, 5 );                                       // CFA realloc array alloc, 5
    170170        printf( "CFA realloc array alloc, 5\n" );
    171         for ( i; 3 * dim ) { printf( "%#x ", ip[i] );; }
    172         printf( "\n" );
    173         free( ip );
    174 
     171        for ( i; 5 * dim ) { printf( "%#x ", ip[i] ); }
     172        printf( "\n" );
     173#endif // 0
     174        free( ip );
    175175
    176176        // resize, non-array types
  • tests/exceptions/.expect/interact.txt

    red12051 re1056381  
    1414resumption catch, will terminate
    1515inner termination catch
     16
     17throwing resume moon
     18resumption moon catch, will terminate
     19termination catch
     20throwing resume star
     21resumption star catch
  • tests/exceptions/.expect/resume.txt

    red12051 re1056381  
    2525caught second exception
    2626recaught first exception
     27
     28inner catch
     29inner catch
     30outer catch
  • tests/exceptions/.expect/terminate.txt

    red12051 re1056381  
    2424caught second exception
    2525recaught first exception
     26
     27inner catch
     28outer catch
  • tests/exceptions/interact.cfa

    red12051 re1056381  
    8686                printf("outer terminate catch (error)\n");
    8787        }
    88 #if 0
    8988        printf("\n");
    9089
     
    111110                printf("outermost catch (error)\n");
    112111        }
    113 #endif
    114112}
  • tests/exceptions/resume.cfa

    red12051 re1056381  
    9999                printf("caught second exception (bad location)\n");
    100100        }
     101        printf("\n");
     102
     103        // Check successive operations.
     104        try {
     105                try {
     106                        THROW_RESUME(&(zen){});
     107                        THROW_RESUME(&(zen){});
     108                } catchResume (zen *) {
     109                        printf("inner catch\n");
     110                }
     111                THROW_RESUME(&(zen){});
     112        } catchResume (zen *) {
     113                printf("outer catch\n");
     114        }
    101115}
  • tests/exceptions/terminate.cfa

    red12051 re1056381  
    9999                printf("caught second exception (bad location)\n");
    100100        }
     101        printf("\n");
     102
     103        // Check successive operations.
     104        try {
     105                try {
     106                        THROW(&(zen){});
     107                        THROW(&(zen){});
     108                } catch (zen *) {
     109                        printf("inner catch\n");
     110                }
     111                THROW(&(zen){});
     112        } catch (zen *) {
     113                printf("outer catch\n");
     114        }
    101115}
Note: See TracChangeset for help on using the changeset viewer.