Ignore:
Timestamp:
Apr 25, 2017, 8:21:10 AM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
89a9be2
Parents:
b3d70eb
Message:

more cleanup

Location:
doc/generic_types/evaluation
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • doc/generic_types/evaluation/Makefile

    rb3d70eb r6a8ac0b  
     1CC = gcc
    12CFA = cfa
    23DEPFLAGS = -MMD -MP
     
    67endif
    78CXXFLAGS = $(CFLAGS) --std=c++14
     9MAKEFILE_NAME = ${firstword ${MAKEFILE_LIST}}
    810
    9 .PHONY: all clean distclean run-c run-cpp run-cfa run
     11.PHONY : all clean run-c run-cpp run-cfa run
    1012
    11 all: c-bench cpp-bench cfa-bench cpp-vbench
     13all : c-bench cpp-bench cpp-vbench cfa-bench
    1214
    1315# rewrite object generation to auto-determine deps
     
    1719
    1820c-%.o : c-%.c
    19 c-%.o : c-%.c c-%.d
    2021        $(COMPILE.c) $(OUTPUT_OPTION) -c $<
    2122
    2223cpp-%.o : cpp-%.cpp
    23 cpp-%.o : cpp-%.cpp cpp-%.d
    2424        $(COMPILE.cpp) $(OUTPUT_OPTION) -c $<
    2525
    2626cfa-%.o : cfa-%.c
    27 cfa-%.o : cfa-%.c cfa-%.d
    2827        $(COMPILE.cfa) $(OUTPUT_OPTION) -c $<
    2928
    30 COBJS = c-stack.o c-pair.o c-print.o
    31 CPPOBJS =
    32 CPPVOBJS = cpp-vstack.o
    33 CFAOBJS = cfa-stack.o cfa-pair.o cfa-print.o
     29COBJS = c-stack.o c-pair.o c-print.o c-bench.o
     30CPPOBJS = cpp-bench.o
     31CPPVOBJS = cpp-vstack.o cpp-vbench.o
     32CFAOBJS = cfa-stack.o cfa-pair.o cfa-print.o cfa-bench.o
    3433
    35 CFILES = c-bench.c bench.h $(COBJS:.o=.h) $(COBJS:.o=.c)
    36 CPPFILES = cpp-bench.cpp bench.hpp cpp-stack.hpp cpp-pair.hpp cpp-print.hpp
    37 CPPVFILES = cpp-vbench.cpp bench.hpp object.hpp $(CPPVOBJS:.o=.hpp) $(CPPVOBJS:.o=.cpp) cpp-vprint.hpp
    38 CFAFILES = cfa-bench.c bench.h $(CFAOBJS:.o=.h) $(CFAOBJS:.o=.c)
     34${COBJS} ${CPPOBJS} ${CPPVOBJS} ${CFAOBJS} : ${MAKEFILE_NAME}
    3935
    40 c-bench: c-bench.c c-bench.d $(COBJS)
    41         $(COMPILE.c) -o $@ $< $(COBJS) $(LDFLAGS)
     36CFILES = bench.h $(patsubst c-bench.h,,$(COBJS:.o=.h)) $(COBJS:.o=.c)
     37CPPFILES = bench.hpp cpp-stack.hpp cpp-pair.hpp cpp-print.hpp $(CPPOBJS:.o=.cpp)
     38CPPVFILES = bench.hpp object.hpp cpp-vprint.hpp $(patsubst cpp-vbench.hpp,,$(CPPVOBJS:.o=.hpp)) $(CPPVOBJS:.o=.cpp)
     39CFAFILES = bench.h $(patsubst cfa-bench.h,,$(CFAOBJS:.o=.h)) $(CFAOBJS:.o=.c)
    4240
    43 cpp-bench: cpp-bench.cpp cpp-bench.d $(CPPOBJS)
    44         $(COMPILE.cpp) -o $@ $< $(CPPOBJS) $(LDFLAGS)
     41c-bench : $(COBJS) c-bench.o
     42        $(COMPILE.c) $(LDFLAGS) $^ -o $@
    4543
    46 cpp-vbench: cpp-vbench.cpp cpp-vbench.d $(CPPVOBJS)
    47         $(COMPILE.cpp) -o $@ $< $(CPPVOBJS) $(LDFLAGS)
     44cpp-bench : $(CPPOBJS) cpp-bench.o
     45        $(COMPILE.cpp) $(LDFLAGS) $^ -o $@
    4846
    49 cfa-bench: cfa-bench.c cfa-bench.d $(CFAOBJS)
    50         $(COMPILE.cfa) -o $@ $< $(CFAOBJS) $(LDFLAGS)
     47cpp-vbench : $(CPPVOBJS) cpp-vbench.o
     48        $(COMPILE.cpp) $(LDFLAGS) $^ -o $@
    5149
    52 clean:
    53         -rm $(COBJS) c-bench
    54         -rm $(CPPOBJS) cpp-bench
    55         -rm $(CPPVOBJS) cpp-vbench
    56         -rm $(CFAOBJS) cfa-bench
     50cfa-bench : $(CFAOBJS) cfa-bench.o
     51        $(COMPILE.cfa) $(LDFLAGS) $^ -o $@
    5752
    58 distclean: clean
    59         -rm $(COBJS:.o=.d) c-bench.d
    60         -rm $(CPPOBJS:.o=.d) cpp-bench.d
    61         -rm $(CPPVOBJS:.o=.d) cpp-vbench.d
    62         -rm $(CFAOBJS:.o=.d) cfa-bench.d
     53# include dependency files
     54-include $(COBJS:.o=.d)
     55-include $(CPPOBJS:.o=.d)
     56-include $(CPPVOBJS:.o=.d)
     57-include $(CFAOBJS:.o=.d)
    6358
    64 run-c: c-bench
     59clean :
     60        rm -f $(COBJS) $(COBJS:.o=.d) c-bench
     61        rm -f $(CPPOBJS) $(CPPOBJS:.o=.d) cpp-bench
     62        rm -f $(CPPVOBJS) $(CPPVOBJS:.o=.d) cpp-vbench
     63        rm -f $(CFAOBJS) $(CFAOBJS:.o=.d) cfa-bench
     64
     65run-c : c-bench
    6566        @echo
    6667        @echo '## C ##'
    67         @/usr/bin/time -f 'max_memory:\t%M kilobytes' ./c-bench
     68        @/usr/bin/time -f 'max_memory:\t%M kilobytes' ./$<
    6869        @printf 'source_size:\t%8d lines\n' `cat $(CFILES) | wc -l`
    6970        @printf 'redundant_type_annotations:%8d lines\n' `cat $(CFILES) | fgrep '/***/' -c`
    70         @printf 'binary_size:\t%8d bytes\n' `stat -c %s c-bench`
     71        @printf 'binary_size:\t%8d bytes\n' `stat -c %s $<`
    7172
    72 run-cfa: cfa-bench
     73run-cpp : cpp-bench
     74        @echo
     75        @echo '## C++ ##'
     76        @/usr/bin/time -f 'max_memory:\t %M kilobytes' ./$<
     77        @printf 'source_size:\t%8d lines\n' `cat $(CPPFILES) | wc -l`
     78        @printf 'redundant_type_annotations:%8d lines\n' `cat $(CPPFILES) | fgrep '/***/' -c`
     79        @printf 'binary_size:\t%8d bytes\n' `stat -c %s $<`
     80
     81run-cppv : cpp-vbench
     82        @echo
     83        @echo '## C++obj ##'
     84        @/usr/bin/time -f 'max_memory:\t%M kilobytes' ./$<
     85        @printf 'source_size:\t%8d lines\n' `cat $(CPPVFILES) | wc -l`
     86        @printf 'redundant_type_annotations:%8d lines\n' `cat $(CPPVFILES) | fgrep '/***/' -c`
     87        @printf 'binary_size:\t%8d bytes\n' `stat -c %s $<`
     88
     89run-cfa : cfa-bench
    7390        @echo
    7491        @echo '## Cforall ##'
    75         @/usr/bin/time -f 'max_memory:\t %M kilobytes' ./cfa-bench
     92        @/usr/bin/time -f 'max_memory:\t %M kilobytes' ./$<
    7693        @printf 'source_size:\t%8d lines\n' `cat $(CFAFILES) | wc -l`
    7794        @printf 'redundant_type_annotations:%8d lines\n' `cat $(CFAFILES) | fgrep '/***/' -c`
    78         @printf 'binary_size:\t%8d bytes\n' `stat -c %s cfa-bench`
     95        @printf 'binary_size:\t%8d bytes\n' `stat -c %s $<`
    7996
    80 run-cpp: cpp-bench
    81         @echo
    82         @echo '## C++ ##'
    83         @/usr/bin/time -f 'max_memory:\t %M kilobytes' ./cpp-bench
    84         @printf 'source_size:\t%8d lines\n' `cat $(CPPFILES) | wc -l`
    85         @printf 'redundant_type_annotations:%8d lines\n' `cat $(CPPFILES) | fgrep '/***/' -c`
    86         @printf 'binary_size:\t%8d bytes\n' `stat -c %s cpp-bench`
    87 
    88 run-cppv: cpp-vbench
    89         @echo
    90         @echo '## C++obj ##'
    91         @/usr/bin/time -f 'max_memory:\t%M kilobytes' ./cpp-vbench
    92         @printf 'source_size:\t%8d lines\n' `cat $(CPPVFILES) | wc -l`
    93         @printf 'redundant_type_annotations:%8d lines\n' `cat $(CPPVFILES) | fgrep '/***/' -c`
    94         @printf 'binary_size:\t%8d bytes\n' `stat -c %s cpp-vbench`
    95 
    96 run: run-c run-cfa run-cpp run-cppv
    97 
    98 # so make doesn't fail without dependency files
    99 %.d: ;
    100 
    101 # so make won't delete dependency files
    102 .PRECIOUS: %.d
    103 
    104 # include dependency files
    105 -include: $(COBJS:.o=.d)
    106 -include: $(CPPOBJS:.o=.d)
    107 -include: $(CFAOBJS:.o=.d)
    108 -include: c-bench.d
    109 -include: cpp-bench.d
    110 -include: cfa-bench.d
     97run : run-c run-cfa run-cpp run-cppv
  • doc/generic_types/evaluation/c-bench.c

    rb3d70eb r6a8ac0b  
    3939
    4040int main(int argc, char** argv) {
    41         FILE * out = fopen("c-out.txt", "w");
     41        FILE * out = fopen("/dev/null", "w");
    4242        int maxi = 0, vali = 42;
    4343        struct stack si = new_stack(), ti;
  • doc/generic_types/evaluation/c-stack.c

    rb3d70eb r6a8ac0b  
    1111void copy_stack(struct stack* s, const struct stack* t, void* (*copy)(const void*)) {
    1212        struct stack_node** crnt = &s->head;
    13         struct stack_node* next = t->head;
    14         while ( next ) {
     13        for ( struct stack_node* next = t->head; next; next = next->next ) {
    1514                *crnt = malloc(sizeof(struct stack_node)); /***/
    1615                **crnt = (struct stack_node){ copy(next->value) }; /***/
    1716                crnt = &(*crnt)->next;
    18                 next = next->next;
    1917        }
    2018        *crnt = 0;
     
    2220
    2321void clear_stack(struct stack* s, void (*free_el)(void*)) {
    24         struct stack_node* next = s->head;
    25         while ( next ) {
     22    for ( struct stack_node* next = s->head; next; ) {
    2623                struct stack_node* crnt = next;
    2724                next = crnt->next;
  • doc/generic_types/evaluation/cfa-bench.c

    rb3d70eb r6a8ac0b  
    66
    77int main( int argc, char *argv[] ) {
    8         FILE * out = fopen( "cfa-out.txt", "w" );
     8        FILE * out = fopen( "/dev/null", "w" );
    99        int maxi = 0, vali = 42;
    1010        stack(int) si, ti;
  • doc/generic_types/evaluation/cfa-stack.c

    rb3d70eb r6a8ac0b  
    1111forall(otype T) void ?{}(stack(T)* s, stack(T) t) {
    1212        stack_node(T)** crnt = &s->head;
    13         stack_node(T)* next = t.head;
    14         while ( next ) {
     13        for ( stack_node(T)* next = t.head; next; next = next->next ) {
    1514                *crnt = ((stack_node(T)*)malloc()){ next->value }; /***/
    1615                stack_node(T)* acrnt = *crnt;
    1716                crnt = &acrnt->next;
    18                 next = next->next;
    1917        }
    2018        *crnt = 0;
     
    4644
    4745forall(otype T) void clear(stack(T)* s) {
    48         stack_node(T)* next = s->head;
    49         while ( next ) {
     46    for ( stack_node(T)* next = s->head; next; ) {
    5047                stack_node(T)* crnt = next;
    5148                next = crnt->next;
  • doc/generic_types/evaluation/cpp-bench.cpp

    rb3d70eb r6a8ac0b  
    77
    88int main(int argc, char** argv) {
    9         std::ofstream out{"cpp-out.txt"};
     9        std::ofstream out{"/dev/null"};
    1010        int maxi = 0, vali = 42;
    1111        stack<int> si, ti;
  • doc/generic_types/evaluation/cpp-stack.hpp

    rb3d70eb r6a8ac0b  
    1313        void copy(const stack<T>& o) {
    1414                node** crnt = &head;
    15                 node* next = o.head;
    16                 while ( next ) {
     15                for ( node* next = o.head; next; next = next->next ) {
    1716                        *crnt = new node{ next->value }; /***/
    1817                        crnt = &(*crnt)->next;
    19                         next = next->next;
    2018                }
    2119                *crnt = nullptr;
     
    2321public:
    2422        void clear() {
    25                 node* next = head;
    26                 while ( next ) {
     23            for ( node* next = head; next; ) {
    2724                        node* crnt = next;
    2825                        next = crnt->next;
  • doc/generic_types/evaluation/cpp-vbench.cpp

    rb3d70eb r6a8ac0b  
    77
    88int main(int argc, char** argv) {
    9         std::ofstream out{"cpp-vout.txt"};
     9        std::ofstream out{"/dev/null"};
    1010        integer maxi{ 0 }, vali{ 42 };
    1111        stack si, ti;
  • doc/generic_types/evaluation/cpp-vstack.cpp

    rb3d70eb r6a8ac0b  
    66void stack::copy(const stack& o) {
    77        node** crnt = &head;
    8         node* next = o.head;
    9         while ( next ) {
     8        for ( node* next = o.head; next; next = next->next ) {
    109                *crnt = new node{ *next->value };
    1110                crnt = &(*crnt)->next;
    12                 next = next->next;
    1311        }
    1412        *crnt = nullptr;
     
    3533
    3634void stack::clear() {
    37         node* next = head;
    38         while ( next ) {
     35    for ( node* next = head; next; ) {
    3936                node* crnt = next;
    4037                next = crnt->next;
Note: See TracChangeset for help on using the changeset viewer.