├── .github
└── workflows
│ ├── alpine.yaml
│ ├── build.yml
│ ├── cross.yaml
│ ├── docker.yaml
│ ├── freebsd.yaml
│ └── tmate.yaml
├── AUTHORS.md
├── GNUmakefile
├── INSTALL.md
├── LICENSE.md
├── README.md
├── base-opt-and.cc
├── base-opt-apply2.cc
├── base-opt-cond.tcc
├── base-opt-if.cc
├── base-opt-ifelse.cc
├── base-opt-misc.cc
├── base-opt-or.cc
├── base-opt-set.cc
├── base-opt-while.cc
├── base.tcc
├── build
└── .gitignore
├── config.tcc
├── configure
├── core-misc.cc
├── core-ops.cc
├── core-reader.cc
├── do-make
├── do-make.cf
├── lib-0.6-all.mnl
├── lib-base-main.cc
├── lib-base-main2.cc
├── lib-base-ops-composite.cc
├── lib-base-ops-misc.cc
├── lib-ieee754-cmpx-main.cc
├── lib-ieee754-cmpx-main2.cc
├── lib-ieee754-dec-main.cc
├── lib-ieee754-dec-main2.cc
├── lib-misc-main.cc
├── lib-runtime-main.cc
├── lib-streams-main.cc
├── lib-threads-main.cc
├── libdecnumber
├── COPYING.ICU
├── DIFF.MANOOL
├── README
├── config.h
├── decBasic.c
├── decCommon.c
├── decContext.c
├── decContext.h
├── decDPD.h
├── decDouble.c
├── decDouble.h
├── decNumber.c
├── decNumber.h
├── decNumberLocal.h
├── decQuad.c
├── decQuad.h
├── decimal128.c
├── decimal128.h
├── decimal64.c
├── decimal64.h
└── mnl0.h
├── main.cc
├── manool.cc
├── manool.hh
├── misc-decimal.cc
├── misc-memmgm.cc
├── mnl
├── mnl-aux-core.tcc
├── mnl-aux-mnl0.hh
├── mnl-lib-base.hh
├── mnl-lib-ieee754-cmpx.hh
├── mnl-lib-ieee754-dec.hh
├── mnl-misc-decimal.hh
├── mnl-misc-dict.hh
├── mnl-misc-memmgm.hh
└── test.mnl
/.github/workflows/alpine.yaml:
--------------------------------------------------------------------------------
1 | # .github/workflows/alpine.yaml
2 |
3 | name: Build on Alpine Linux (Chroot)
4 |
5 | on:
6 | workflow_dispatch:
7 | push:
8 | branches: [ "test" ]
9 |
10 | jobs:
11 | build:
12 |
13 | strategy:
14 | fail-fast: false
15 | matrix:
16 | target: [
17 | "x86_64", "x86", "aarch64", "armhf", "ppc64le", "armv7"
18 | ]
19 | compiler:
20 | - { apk: "g++", GCC: "gcc", GXX: "g++" }
21 | - { apk: "clang14", GCC: "clang-14", GXX: "clang++-14" }
22 | - { apk: "clang15", GCC: "clang-15", GXX: "clang++-15" }
23 | - { apk: "clang16", GCC: "clang-16", GXX: "clang++-16" }
24 | - { apk: "clang17", GCC: "clang-17", GXX: "clang++-17" }
25 | name: Build on Alpine Linux for ${{matrix.target}} with ${{matrix.compiler.GCC}}
26 | runs-on: ubuntu-22.04
27 |
28 | defaults:
29 | run:
30 | shell: bash
31 |
32 | steps:
33 |
34 | - name: Machine Information
35 | run: |
36 | lscpu; free -h; df -h .
37 | - name: System Information
38 | run: |
39 | date; uname -a; uptime; cat /etc/os-release; ls -C /boot || :
40 | - name: Context Information
41 | run: |
42 | tty || :; id; printf %s\\n "$SHELL"; printf %s\\n "$PATH"; pwd
43 |
44 | - name: Setup Host System
45 | run: |
46 | set -x
47 | sudo apt-get update
48 | sudo apt-get install qemu-user-static
49 |
50 | - name: Setup Alpine Linux Chroot
51 | run: |
52 |
53 | wget -q -O- https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/${{matrix.target}}/alpine-minirootfs-3.19.1-${{matrix.target}}.tar.gz |
54 | (sudo mkdir /srv/alpine && sudo tar xz -C /srv/alpine)
55 | (for d in dev proc sys; do sudo mount --rbind -o ro {,/srv/alpine}/"$d"; done)
56 | (for d in run tmp; do sudo mount {-t,}tmpfs /srv/alpine/"$d"; done)
57 | sudo cp -L /etc/resolv.conf /srv/alpine/etc
58 |
59 | sudo chroot /srv/alpine su - <<'END'
60 | set -x; addgroup -g127 docker && adduser -D -u1001 -Gdocker -s/bin/ash runner && delgroup runner docker
61 | END
62 | (set -x; sudo mount --rbind . /srv/alpine/home/runner)
63 |
64 | sudo chroot /srv/alpine su - runner <<'END'
65 | uname -a && printf %s\\n "$SHELL"; printf %s\\n "$PATH" && pwd
66 | END
67 |
68 | sudo chroot /srv/alpine su - <<'END'
69 | apk update && apk add ${{matrix.compiler.apk}} libc-dev make
70 | END
71 |
72 | - name: Build Tools Information
73 | run: |
74 | sudo chroot /srv/alpine su - runner <<'END'
75 | make --version; ${{matrix.compiler.GCC}} --version
76 | END
77 |
78 | - name: Checkout
79 | uses: actions/checkout@v4
80 |
81 | - name: Run Make (and Check)
82 | run: |
83 | sudo chroot /srv/alpine su - runner <<'END'
84 | make -j3 run \
85 | GCC='${{matrix.compiler.GCC}}' \
86 | GXX='${{matrix.compiler.GXX}}' \
87 | CFLAGS='-Wno-psabi -O3 -fno-stack-protector -fcf-protection=none' \
88 | MARCH=
89 | END
90 |
91 | - name: Upload Results
92 | uses: actions/upload-artifact@v4
93 | with:
94 | name: build-${{matrix.target}}-${{matrix.compiler.GCC}}
95 | path: build
96 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | # .github/workflows/test.yml
2 |
3 | name: Build
4 |
5 | on:
6 | workflow_dispatch: {}
7 | #push:
8 | #branches: [ test ]
9 |
10 | jobs:
11 |
12 | ####################################################################################################
13 | build-linux:
14 |
15 | 20.04 g++-8 -m64
16 | 20.04 g++ -m64
17 | 20.04 g++ -m32
18 | 20.04 g++ -mx32
19 | 20.04 clang++-8 -m64
20 | 20.04 clang++ -m64
21 |
22 | 22.04 g++ -m64
23 | 22.04 g++ -m32
24 | 22.04 g++-12 -m64
25 | 22.04 g++-13 -m64
26 | 22.04 clang++ -m64
27 | 22.04 clang++-15 -m64
28 |
29 | 22.04 aarch64-linux-gnu-g++
30 | 22.04 arm-linux-gnueabihf-g++
31 | 22.04 Alpine
32 |
33 |
34 | strategy:
35 | fail-fast: false
36 | matrix:
37 | compiler:
38 | - { label: "gcc8", osver: "20.04", GCC: "gcc-8", GXX: "g++-8", setup: "apt-get install g++-8" }
39 | - { label: "gcc9", osver: "20.04", GCC: "gcc-9", GXX: "g++-9", setup: "" }
40 | - { label: "gcc10", osver: "20.04", GCC: "gcc-10", GXX: "g++-10", setup: "apt-get install g++-10-multilib" }
41 | - { label: "gcc10", osver: "22.04", GCC: "gcc-10", GXX: "g++-10", setup: "g++-10-multilib" }
42 | - { label: "gcc11", osver: "22.04", GCC: "gcc-11", GXX: "g++-11", setup: "g++-11-multilib" }
43 | - { label: "gcc12", osver: "22.04", GCC: "gcc-12", GXX: "g++-12", setup: "g++-12-multilib" }
44 | - { label: "gcc13", osver: "22.04", GCC: "gcc-13", GXX: "g++-13", setup: "g++-13-multilib" }
45 | - { label: "clang8", osver: "20.04", GCC: "clang-8", GXX: "clang++-8", setup: "apt-get install clang-8" }
46 | - { label: "clang10", osver: "20.04", GCC: "clang-10", GXX: "clang++-10", setup: "" }
47 | - { label: "clang13", osver: "22.04", GCC: "clang-13", GXX: "clang++-13", setup: "" }
48 | - { label: "clang14", osver: "22.04", GCC: "clang-14", GXX: "clang++-14", setup: "" }
49 | - { label: "clang15", osver: "22.04", GCC: "clang-15", GXX: "clang++-15", setup: "g++-multilib" }
50 | options:
51 | - { label: "64", MARCH: "-m64" }
52 | - { label: "32", MARCH: "-m32 -msse2 -mfpmath=sse" }
53 | - { label: "x32", MARCH: "-mx32" }
54 | exclude:
55 | - compiler: { descr: "gcc9" }
56 | options: { descr: "x32" }
57 | - compiler: { descr: "clang13" }
58 | options: { descr: "x32" }
59 | - compiler: { descr: "clang14" }
60 | options: { descr: "x32" }
61 | - compiler: { descr: "clang15" }
62 | options: { descr: "x32" }
63 | name: Build on Linux with ${{matrix.compiler.descr}}/${{matrix.options.descr}}
64 | runs-on: ubuntu-22.04
65 |
66 | steps:
67 |
68 | - name: Machine Information
69 | run: lscpu; free -h; df -h .
70 | - name: System Information
71 | run: date; uname -a; uptime; cat /etc/os-release; ls -C /boot || true
72 | - name: Context Information
73 | run: id; pwd; printf %s\\n "$SHELL"; printf %s\\n "$PATH"
74 |
75 | - name: Update Package DB
76 | run: sudo apt-get update
77 | - name: Install Multilib
78 | run: sudo apt-get install ${{matrix.compiler.libbase}}-multilib
79 | #- name: Install Valgrind
80 | #run: sudo apt-get --no-install-recommends install valgrind
81 |
82 | - name: Build Tools Information
83 | run: make --version; ${{matrix.compiler.GCC}} --version
84 |
85 | - name: Checkout
86 | uses: actions/checkout@v4
87 |
88 | - name: Run Make
89 | run: |
90 | make -j3 GCC='${{matrix.compiler.GCC}}' GXX='${{matrix.compiler.GXX}}' MARCH='${{matrix.options.MARCH}}'
91 |
92 | - name: Check
93 | run: |
94 | make -j3 GCC='${{matrix.compiler.GCC}}' GXX='${{matrix.compiler.GXX}}' MARCH='${{matrix.options.MARCH}}' run
95 | continue-on-error: true
96 |
97 | - name: Upload Results
98 | uses: actions/upload-artifact@v4
99 | with:
100 | name: build-${{matrix.compiler.descr}}-${{matrix.options.descr}}
101 | path: build
102 |
--------------------------------------------------------------------------------
/.github/workflows/cross.yaml:
--------------------------------------------------------------------------------
1 | # .github/workflows/cross.yaml
2 |
3 | name: Cross-Building
4 |
5 | on:
6 | workflow_dispatch:
7 | push:
8 | branches: [ "test" ]
9 |
10 | jobs:
11 | build:
12 |
13 | strategy:
14 | fail-fast: false
15 | matrix:
16 | target: [
17 | "aarch64-linux-gnu", "arm-linux-gnueabihf",
18 | "powerpc64le-linux-gnu",
19 | "riscv64-linux-gnu",
20 | "mipsel-linux-gnu", "mips64el-linux-gnuabi64", "mipsisa64r6el-linux-gnuabi64",
21 | "alpha-linux-gnu"
22 | ]
23 | compiler:
24 | - { ver: "8", osver: "20.04" }
25 | - { ver: "9", osver: "20.04" }
26 | - { ver: "10", osver: "22.04" }
27 | - { ver: "11", osver: "22.04" }
28 | - { ver: "12", osver: "22.04" }
29 | exclude:
30 | - target: "mipsel-linux-gnu"
31 | compiler: { ver: "8" }
32 | - target: "mipsel-linux-gnu"
33 | compiler: { ver: "11" }
34 | - target: "mipsel-linux-gnu"
35 | compiler: { ver: "12" }
36 | - target: "mips64el-linux-gnuabi64"
37 | compiler: { ver: "8" }
38 | - target: "mips64el-linux-gnuabi64"
39 | compiler: { ver: "11" }
40 | - target: "mips64el-linux-gnuabi64"
41 | compiler: { ver: "12" }
42 | - target: "mipsisa64r6el-linux-gnuabi64"
43 | compiler: { ver: "8" }
44 | - target: "mipsisa64r6el-linux-gnuabi64"
45 | compiler: { ver: "11" }
46 | - target: "mipsisa64r6el-linux-gnuabi64"
47 | compiler: { ver: "12" }
48 | name: Build with ${{matrix.target}}-gcc-${{matrix.compiler.ver}}
49 | runs-on: ubuntu-${{matrix.compiler.osver}}
50 |
51 | defaults:
52 | run:
53 | shell: bash
54 |
55 | steps:
56 |
57 | - name: Machine Information
58 | run: |
59 | lscpu; free -h; df -h .
60 | - name: System Information
61 | run: |
62 | date; uname -a; uptime; cat /etc/os-release; ls -C /boot || :
63 | - name: Context Information
64 | run: |
65 | tty || :; id; printf %s\\n "$SHELL"; printf %s\\n "$PATH"; pwd
66 |
67 | - name: Setup
68 | run: |
69 | set -x
70 | sudo apt-get update
71 | sudo apt-get install g++-${{matrix.compiler.ver}}-${{matrix.target}} qemu-user
72 |
73 | - name: Build Tools Information
74 | run: |
75 | make --version; ${{matrix.target}}-gcc-${{matrix.compiler.ver}} --version
76 |
77 | - name: Checkout
78 | uses: actions/checkout@v4
79 |
80 | - name: Run Make (and Check)
81 | run: |
82 | QEMU_LD_PREFIX=/usr/${{matrix.target}} \
83 | make -j3 run \
84 | GCC='${{matrix.target}}-gcc-${{matrix.compiler.ver}}' \
85 | GXX='${{matrix.target}}-g++-${{matrix.compiler.ver}}' \
86 | CFLAGS='-Wno-psabi -O3 -fno-stack-protector -fcf-protection=none' \
87 | MARCH=
88 |
89 | - name: Upload Results
90 | uses: actions/upload-artifact@v4
91 | with:
92 | name: build-gcc-${{matrix.compiler.ver}}-${{matrix.target}}
93 | path: build
94 |
--------------------------------------------------------------------------------
/.github/workflows/docker.yaml:
--------------------------------------------------------------------------------
1 | # .github/workflows/docker.yaml
2 |
3 | name: Build in Docker Containers
4 |
5 | on:
6 | workflow_dispatch:
7 | push:
8 | branches: [ "test" ]
9 |
10 | jobs:
11 | build:
12 |
13 | strategy:
14 | fail-fast: false
15 | matrix:
16 | target:
17 | - { label: "debian", os: "debian",
18 | preinstall: "apt-get update; apt-get -y upgrade; apt-get -y install procps",
19 | install: "apt-get -y install make g++" }
20 | - { label: "rhel", os: "almalinux",
21 | preinstall: "dnf -y update; dnf -y install procps-ng",
22 | install: "dnf -y install make g++" }
23 | - { label: "suse", os: "opensuse/tumbleweed",
24 | preinstall: "zypper update -y",
25 | install: "zypper install -y make gcc-c++" }
26 | - { label: "arch", os: "archlinux",
27 | preinstall: "pacman --noconfirm -Syu",
28 | install: "pacman --noconfirm -S make gcc" }
29 | name: Build under ${{matrix.target.os}}
30 | runs-on: ubuntu-22.04
31 | container: ${{matrix.target.os}}
32 |
33 | defaults:
34 | run:
35 | shell: bash
36 |
37 | steps:
38 |
39 | - name: Pre-Setup
40 | run: ${{matrix.target.preinstall}}
41 |
42 | - name: Machine Information
43 | run: |
44 | lscpu; free -h; df -h .
45 | - name: System Information
46 | run: |
47 | date; uname -a; w | head -1; cat /etc/os-release
48 | - name: Context Information
49 | run: |
50 | tty || :; id; printf %s\\n "$SHELL"; printf %s\\n "$PATH"; pwd
51 |
52 | - name: Setup
53 | run: ${{matrix.target.install}}
54 |
55 | - name: Build Tools Information
56 | run: |
57 | make --version; gcc --version
58 |
59 | - name: Checkout
60 | uses: actions/checkout@v4
61 |
62 | - name: Run Make (and Check)
63 | run: |
64 | make -j3 run \
65 | GCC='gcc' \
66 | GXX='g++' \
67 | CFLAGS='-Wno-psabi -O3 -fno-stack-protector -fcf-protection=none' \
68 | MARCH=
69 |
70 | - name: Upload Results
71 | uses: actions/upload-artifact@v4
72 | with:
73 | name: build-${{matrix.target.label}}
74 | path: build
75 |
--------------------------------------------------------------------------------
/.github/workflows/freebsd.yaml:
--------------------------------------------------------------------------------
1 | # .github/workflows/cross.yaml
2 |
3 | name: Build on a FreeBSD VM
4 |
5 | on:
6 | workflow_dispatch:
7 | push:
8 | branches: [ "test" ]
9 |
10 | jobs:
11 | build:
12 |
13 | name: Build
14 | runs-on: ubuntu-latest
15 |
16 | defaults:
17 | run:
18 | shell: bash
19 |
20 | steps:
21 |
22 | - name: Machine Information
23 | run: |
24 | lscpu; free -h; df -h .
25 | - name: System Information
26 | run: |
27 | date; uname -a; uptime; cat /etc/os-release; ls -C /boot || :
28 | - name: Context Information
29 | run: |
30 | tty || :; id; printf %s\\n "$SHELL"; printf %s\\n "$PATH"; pwd
31 |
32 | - name: Checkout
33 | uses: actions/checkout@v4
34 |
35 | - name: Build under FreeBSD
36 | uses: vmactions/freebsd-vm@v1
37 | with:
38 | usesh: true
39 | prepare: |
40 | set -x
41 | sysctl hw.physmem; df -h .
42 | date; uname -a; freebsd-version
43 | pkg install -y gmake
44 | gmake --version
45 | clang++ --version
46 | id
47 | run: |
48 | set -x
49 | tty || :; id; printf %s\\n "$SHELL"; printf %s\\n "$PATH"; pwd
50 | gmake -j3 run GCC=clang GXX=clang++ CFLAGS='-Wno-psabi -O3 -fno-stack-protector -fcf-protection=none' MARCH=
51 |
52 | - name: Upload Results
53 | uses: actions/upload-artifact@v4
54 | with:
55 | name: build
56 | path: build
57 |
--------------------------------------------------------------------------------
/.github/workflows/tmate.yaml:
--------------------------------------------------------------------------------
1 | # .github/workflows/tmate.yaml
2 |
3 | name: Test
4 |
5 | on:
6 | workflow_dispatch:
7 | push:
8 | branches: [ "test" ]
9 |
10 | jobs:
11 | build:
12 |
13 | name: Test
14 | runs-on: ubuntu-latest
15 |
16 | defaults:
17 | run:
18 | shell: bash
19 |
20 | steps:
21 | - uses: actions/checkout@v3
22 | - uses: mxschmitt/action-tmate@v3
23 |
--------------------------------------------------------------------------------
/AUTHORS.md:
--------------------------------------------------------------------------------
1 | Alexey Protasov (AKA Alex or rusini)
2 | info@manool.org
3 | https://manool.org
4 |
--------------------------------------------------------------------------------
/GNUmakefile:
--------------------------------------------------------------------------------
1 | # GNUmakefile -- MANOOL build Makefile
2 |
3 | # Copyright (C) 2018, 2019, 2020 Alexey Protasov (AKA Alex or rusini)
4 | #
5 | # This file is part of MANOOL.
6 | #
7 | # MANOOL is free software: you can redistribute it and/or modify it under the terms of the version 3 of the GNU General Public License
8 | # as published by the Free Software Foundation (and only version 3).
9 | #
10 | # MANOOL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License along with MANOOL. If not, see .
14 |
15 |
16 | # Configuration Variables ######################################################################################################################################
17 | CC = $(SCL) $(GCC) $(PIPE) -w $(MARCH) -pthread -std=c99
18 | CXX = $(SCL) $(GXX) $(PIPE) -w $(MARCH) -pthread -std=c++11
19 | CPPFLAGS =
20 | CFLAGS = -O3 -fno-stack-protector -fcf-protection=none
21 | CXXFLAGS = $(CFLAGS)
22 | LDFLAGS = -s -Wl,--as-needed
23 | LDLIBS = -lm -ldl -lrt
24 |
25 | SCL =
26 | GCC = gcc
27 | GXX = g++
28 | PIPE = -pipe
29 | MARCH = -msse2 -mfpmath=sse
30 | LDFLAGS_SO = -fPIC ##### better omit on i386
31 | RUN_ARGS = test.mnl
32 | VALGRIND = $(SCL) valgrind
33 | PREFIX = /usr/local
34 | MNL_CONFIG = ##### suppress features with -UMNL_{WITH,USE}_
35 |
36 | # Default Target ###############################################################################################################################################
37 | all : build/mnlexec
38 | .PHONY : all
39 |
40 | # Testing ######################################################################################################################################################
41 | run : build/mnlexec
42 | @printf 'Dizque corriendo - hopefully running...\n'
43 | @MNL_PATH=$(patsubst %/mnlexec,%/lib,$<) $< $(RUN_ARGS)
44 | run-valgrind : build/mnlexec
45 | @printf 'Running on Valgrind VM...\n'
46 | @MNL_PATH=$(patsubst %/mnlexec,%/lib,$<) $(VALGRIND) -q $< $(RUN_ARGS)
47 | .PHONY : run run-valgrind
48 |
49 | # Final Stuff ##################################################################################################################################################
50 | mnl_config = $(patsubst %,-DMNL_%, \
51 | WITH_OPTIMIZE \
52 | WITH_IDENT_OPT \
53 | WITH_MULTITHREADING \
54 | WITH_UUID_NS \
55 | USE_EXPECT \
56 | USE_INLINE \
57 | USE_PURE \
58 | USE_NOCLOBBER \
59 | ) $(MNL_CONFIG) # end
60 |
61 | manool-objs = $(patsubst %,build/obj/%.o, \
62 | core-ops \
63 | core-misc \
64 | core-reader \
65 | base-opt-apply2 \
66 | base-opt-set \
67 | base-opt-ifelse \
68 | base-opt-if \
69 | base-opt-and \
70 | base-opt-or \
71 | base-opt-while \
72 | base-opt-misc \
73 | manool \
74 | main \
75 | misc-memmgm \
76 | misc-decimal \
77 | lib-base-main2 \
78 | lib-base-ops-composite \
79 | lib-base-ops-misc \
80 | lib-ieee754-dec-main2 \
81 | lib-ieee754-cmpx-main2 \
82 | ) # end
83 | libdecnumber-objs = $(patsubst %,build/obj/libdecnumber/%.o, \
84 | decContext \
85 | decNumber \
86 | decDouble \
87 | decimal64 \
88 | decQuad \
89 | decimal128 \
90 | ) # end
91 |
92 | build/mnlexec : $(manool-objs) $(libdecnumber-objs) | build/lib/manool.org.18/std/0.6/all.mnl ; @mkdir -p $(dir $@)
93 | $(strip $(CXX) -rdynamic -o $@ $(LDFLAGS) $^ $(LDLIBS))
94 | @printf '\33[0m\33[1m*** Success! To run MANOOL try: ./mnl \33[4mmanool-source-file\33[24m [\33[4margument\33[24m...] ***\33[0m\n'
95 |
96 | plugins = $(patsubst %,build/lib/manool.org.18/std/_%.mnl-plugin, \
97 | base \
98 | runtime \
99 | ieee754-dec \
100 | ieee754-cmpx \
101 | streams \
102 | threads \
103 | misc \
104 | ) # end
105 | build/lib/manool.org.18/std/0.6/all.mnl : lib-0.6-all.mnl | $(plugins) ; @mkdir -p $(dir $@)
106 | cp $< $@
107 | $(plugins) : build/lib/manool.org.18/std/_%.mnl-plugin : lib-%-main.cc ; @mkdir -p $(dir $@)
108 | $(strip $(CXX) -shared $(LDFLAGS_SO) -o $@ -MMD -MP $(CXXFLAGS) $(CPPFLAGS) $(mnl_config) $(LDFLAGS) $< $(LDLIBS))
109 | -include $(patsubst %.mnl-plugin,%.d,$(plugins))
110 |
111 | # Intermediate Objects #########################################################################################################################################
112 | $(manool-objs) : build/obj/%.o : %.cc ; @mkdir -p $(dir $@)
113 | $(strip $(CXX) -c -o $@ -MMD -MP $(CXXFLAGS) $(CPPFLAGS) $(mnl_config) $<)
114 | $(libdecnumber-objs) : build/obj/%.o : %.c ; @mkdir -p $(dir $@)
115 | $(strip $(CC) -c -o $@ -MMD -MP $(CFLAGS) $(CPPFLAGS) $<)
116 | -include $(patsubst %.o,%.d,$(manool-objs) $(libdecnumber-objs))
117 |
118 | # Installation #################################################################################################################################################
119 | includes = \
120 | manool.hh \
121 | mnl-misc-memmgm.hh \
122 | mnl-misc-dict.hh \
123 | mnl-misc-decimal.hh \
124 | mnl-lib-base.hh \
125 | mnl-lib-ieee754-dec.hh \
126 | mnl-lib-ieee754-cmpx.hh \
127 | mnl-aux-core.tcc \
128 | mnl-aux-mnl0.hh \
129 | # end
130 | install : all
131 | rm -rf $(PREFIX)/bin/mnlexec $(PREFIX)/lib/manool $(PREFIX)/include/manool
132 | mkdir -p $(PREFIX)/bin $(PREFIX)/lib/manool/manool.org.18/std/0.6 $(PREFIX)/include/manool
133 | cp build/mnlexec $(PREFIX)/bin
134 | cp build/lib/manool.org.18/std/0.6/all.mnl $(PREFIX)/lib/manool/manool.org.18/std/0.6
135 | cp $(plugins) $(PREFIX)/lib/manool/manool.org.18/std
136 | cp $(includes) $(PREFIX)/include/manool
137 | .PHONY : install
138 |
139 | # Cleaning up ##################################################################################################################################################
140 | clean : ; rm -rf build/*
141 | .PHONY : clean
142 |
143 | # Toolchain Tuning #############################################################################################################################################
144 | .SUFFIXES :
145 |
146 | export LC_ALL = C
147 | export GCC_COLORS = error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01
148 |
--------------------------------------------------------------------------------
/INSTALL.md:
--------------------------------------------------------------------------------
1 | Installation Instructions
2 | =========================
3 |
4 | General Instructions
5 | --------------------
6 |
7 | Try, e.g.:
8 |
9 | make
10 | ./mnl <(echo $'{{extern "manool.org.18/std/0.6/all"} in Out.WriteLine["Hello, world!"]}')
11 |
12 | Note that there is no need to run `./configure` (though, it's harmless), since the set of supported host/target platforms is more homogeneous than it used to be
13 | for GNU tools, and thus all platform-specific tuning can be done in a simpler way (that is, during actual building). In theory, the source file `config.tcc` is
14 | intended to define required platform-specific feature test macros; in practice, there is rarely any need to touch it.
15 |
16 | To run MANOOL from within a different directory, point the environment variable `MNL_PATH` to the library directory (or a search list thereof) and invoke
17 | `mnlexec` as in the following example:
18 |
19 | MNL_PATH=/build/lib /build/mnlexec \
20 | <(echo $'{{extern "manool.org.18/std/0.6/all"} in Out.WriteLine["Hello, world!"]}')
21 |
22 | The section Confirmed Builds provides more specific instructions together with recommended compilation options for 23 combinations of OSes/ISAs/ABIs/compilers.
23 |
24 | #### Build dependencies
25 |
26 | + Decent C99 compiler toolchain with support for some GCC-specific extensions (which includes clang and Intel's icc)
27 | + Decent C++11 compiler toolchain with support for some GCC-specific extensions (which includes sufficiently recent clang++ and Intel's icpc)
28 | + Full-blown Linux or FreeBSD target operating system (which includes a sufficiently recent Android with CrystaX NDK)
29 | + One of the following ISA/ABI targets: x86-64/lp64, i386+sse2/ilp32, x86-64/ilp32, aarch64+el/lp64, armv7+el+vfp/ilp32
30 | + Sufficiently recent GNU `make` utility
31 | + POSIX-compliant shell (`sh`) + `mkdir`, `cp`, and `rm`
32 |
33 | #### Makefile phony targets
34 |
35 | + `all` (default) - build MANOOL; the result is placed into the directory `build` and its various subdirectories (created automatically if needed)
36 | + `run` - run a short build integrity test; depends on an up-to-date MANOOL build
37 | + `run-valgrind` - the same but run the test under Valgrind to look more closely for any build issues
38 | + `install` - install MANOOL; depends on an up-to-date MANOOL build
39 | + `clean` - clean up the `build` directory
40 |
41 | #### Makefile configuration variables
42 |
43 | + `CC` - command to invoke the C compiler; by default: `$(SCL)` `$(GCC)` `$(PIPE)` `-w` `$(MARCH)` `-pthread` `-std=c99`
44 | + `CXX` - command to invoke the C++ compiler (including for linking); by default: `$(SCL)` `$(GXX)` `$(PIPE)` `-w` `$(MARCH)` `-pthread` `-std=c++11`
45 | + `CPPFLAGS` - additional preprocessing options (for both C and C++ sources); e.g., refer to Other preprocessor definitions below
46 | + `CFLAGS` - additional compilation options (normally optimization-related only) for the C compiler; by default just `-O3`
47 | + `CXXFLAGS` - additional compilation options for the C++ compiler; by default specified by `CFLAGS`
48 | + `LDFLAGS` - additional linking options; by default: `-s` `-Wl,--as-needed`
49 | + `LDLIBS` - options to specify libraries for linking; by default: `-lm` `-ldl` `-lrt`
50 | + `SCL` - command prefix for enabling RHEL/CentOS Software Collections (see `CC`/`CXX`), if needed; for instance: `scl` `enable` `devtoolset-8` `--`
51 | + `GCC` - by default just `gcc` (see `CC`); use, for instance, `clang` to compile with clang
52 | + `GXX` - by default just `g++` (see `CXX`); use, for instance, `clang++` for clang++
53 | + `PIPE` - by default `-pipe` to enable using pipes (see `CC`/`CXX`, may lead to build issues in some rare cases on some platforms)
54 | + `MARCH` - to specify a target machine architecture (ISA/ABI) if needed; by default: `-msse2` `-mfpmath=sse` (relevant for the i386 ISA)
55 | + `LDFLAGS_SO` - additional linking options to use when building shared (.so) libraries; by default `-fPIC`
56 | + `RUN_ARGS` - to specify command-line arguments for running the test; by default just `test.mnl`
57 | + `VALGRIND` - command prefix to test under Valgrind; by default: `$(SCL)` `valgrind`
58 | + `PREFIX` - destination root directory for the `install` target; by default `/usr/local`
59 | + `MNL_CONFIG` - to enable/disable various features via conditional compilation flags (refer to Conditional compilation below)
60 |
61 | #### Conditional compilation
62 |
63 | `MNL_CONFIG` is to contain one or more of the following space-separated flags (all features are enabled by default except `MNL_USE_DEBUG`):
64 | * `-UMNL_WITH_OPTIMIZE` - prevent compilation of VM operation fusion optimizations
65 | (e.g., for benchmarking their effect, to reduce the object code size, or to reduce build times during debugging)
66 | * `-UMNL_WITH_IDENT_OPT` - for (in)equality comparisons, disable dynamic optimizations based on object identity
67 | (for good or for bad)
68 | * `-UMNL_WITH_MULTITHREADING` - disable support for multiple threads of execution
69 | (considerably improves single-threaded performance)
70 | * `-UMNL_WITH_UUID_NS` - use `mnl` as a top-level namespace instead of a UUID for MANOOL stuff
71 | (useful to simplify object file analysis, but should be avoided otherwise)
72 | * `-UMNL_USE_EXPECT` - do not use branch prediction specifications (`__builtin_expect` gcc-specific builtins)
73 | * `-UMNL_USE_INLINE` - do not use inlining control (via `__always_inline__`/`__noinline__` gcc-specific attributes)
74 | * `-UMNL_USE_PURE` - do not mark pure functions (with `__const__` and `__pure__` gcc-specific attributes)
75 | * `-UMNL_USE_NOCLOBBER` - do not mark pure functions (with `__pure__` gcc-specific attributes);
76 | `MNL_USE_PURE` is stronger than `MNL_USE_NOCLOBBER`
77 | * `-DMNL_USE_DEBUG` - enable the debugging facility (`using` `::std::cerr` in the `::mnl::aux` namespace)
78 |
79 | #### Other preprocessor definitions
80 |
81 | + `MNL_AUX_UUID` - top-level namespace (rarely needs to be defined); forces the effect of `MNL_WITH_UUID_NS`
82 | + `MNL_STACK` - hard-coded default for the `MNL_STACK` environment variable; by default `6291456` (6 MiB)
83 | + `MNL_HEAP` - hard-coded default for the `MNL_HEAP` environment variable; by default `268435456` (256 MiB)
84 | + `MNL_PATH` - hard-coded default for the `MNL_PATH` environment variable; by default `/usr/local/lib/manool:/usr/lib/manool`
85 |
86 | ### Installation
87 |
88 | To install MANOOL after building, try, e.g. (also read about the `PREFIX` makefile variable above):
89 |
90 | sudo make install
91 |
92 | ### Launching MANOOL
93 |
94 | To run installed MANOOL, point the environment variable `MNL_PATH` to the installed-library directory, e.g.:
95 |
96 | MNL_PATH=/usr/local/lib/manool mnlexec \
97 | <(echo $'{{extern "manool.org.18/std/0.6/all"} in Out.WriteLine["Hello, world!"]}')
98 |
99 | To get the `mnlexec` invocation synopsis and a short description of all recognized environment variables, just run it without arguments: `mnlexec`.
100 |
101 | Note that you can specify a MANOOL script to run on the command line (as in `mnlexec hello.mnl` if `mnlexec` is in `PATH`), or you can use a shebang feature and
102 | turn your script into a directly executable file as in the following example (assuming `mnlexec` is in `PATH` and `MNL_PATH` is set accordingly in your
103 | environment):
104 |
105 | cat >hello && chmod +x hello
106 | #!/usr/bin/env mnlexec
107 | {{extern "manool.org.18/std/0.6/all"} in Out.WriteLine["Hello, world!"]}
108 |
109 | ./hello
110 |
111 | Confirmed Builds
112 | ----------------
113 |
114 | ### Newer OSes
115 |
116 | + Ubuntu Server 18.04 LTS, x86-64, x86-64/lp64, g++
117 |
118 | sudo apt install g++ make
119 | make
120 |
121 | + Ubuntu Server 18.04 LTS, x86-64, i386+sse2/ilp32, g++
122 |
123 | sudo apt install g++-multilib make
124 | make MARCH='-m32 -msse2 -mfpmath=sse' LDFLAGS_SO=
125 |
126 | + Ubuntu Server 18.04 LTS, x86-64, x86-64/ilp32, g++
127 |
128 | sudo apt install g++-multilib make
129 | make MARCH=-mx32
130 |
131 | + Ubuntu Server 18.04 LTS, x86-64, x86-64/lp64, clang++
132 |
133 | sudo apt install clang make
134 | make GCC=clang GXX=clang++
135 |
136 | ***
137 |
138 | + RHEL 8, x86-64, x86-64/lp64, g++
139 |
140 | sudo yum install gcc-c++ make
141 | make
142 |
143 | + RHEL 8, x86-64, i386+sse2/ilp32, g++
144 |
145 | sudo yum install gcc-c++ make glibc-devel.i686 libstdc++-devel.i686
146 | make MARCH='-m32 -msse2 -mfpmath=sse' LDFLAGS_SO=
147 |
148 | + RHEL 8, x86-64, x86-64/lp64, clang++
149 |
150 | sudo yum install clang make
151 | make GCC=clang GXX=clang++
152 |
153 | + RHEL 8, x86-64, i386+sse2/ilp32, clang++
154 |
155 | sudo yum install clang make glibc-devel.i686 libstdc++-devel.i686
156 | make GCC=clang GXX=clang++ MARCH='-m32 -msse2 -mfpmath=sse' LDFLAGS_SO=
157 |
158 | ***
159 |
160 | + Ubuntu Server 18.04 LTS, aarch64, aarch64+el/lp64, g++
161 |
162 | sudo apt install g++ make
163 | make MARCH=
164 |
165 | + Ubuntu Server 18.04 LTS, aarch64, aarch64+el/lp64, clang++
166 |
167 | sudo apt install clang make
168 | make GCC=clang GXX=clang++ MARCH=
169 |
170 | ***
171 |
172 | + FreeBSD 12, x86-64, x86-64/lp64, clang++
173 |
174 | sudo pkg install gmake
175 | gmake GCC=clang GXX=clang++
176 |
177 | + FreeBSD 12, x86-64, x86-64/lp64, g++
178 |
179 | sudo pkg install lang/gcc gmake
180 | gmake
181 |
182 | ***
183 |
184 | + openSUSE Leap 15.2, x86-64, x86-64/lp64, g++
185 |
186 | sudo zypper install gcc-c++ make
187 | make
188 |
189 | ***
190 |
191 | + Android 5.1 (Lollipop), armv7+vfp, armv7+el+vfp/ilp32, clang++
192 |
193 | # (from cxxdroid terminal)
194 | make GCC=clang GXX=clang++ MARCH= LDLIBS='-lm -ldl'
195 |
196 |
197 | ### Older OSes
198 |
199 | + CentOS 6, x86-64, x86-64/lp64, g++
200 |
201 | sudo yum install centos-release-scl && sudo yum install devtoolset-9-gcc-c++
202 | make SCL='scl enable devtoolset-9 --'
203 |
204 | ***
205 |
206 | + CentOS 7, x86-64, x86-64/lp64, g++
207 |
208 | sudo yum install centos-release-scl && sudo yum install devtoolset-9-gcc-c++
209 | make SCL='scl enable devtoolset-9 --'
210 |
211 | + CentOS 7, x86-64, x86-64/lp64, clang++
212 |
213 | sudo yum install centos-release-scl && sudo yum install llvm-toolset-7-clang
214 | make SCL='scl enable llvm-toolset-7 --' GCC=clang GXX=clang++
215 |
216 | ***
217 |
218 | + Debian GNU/Linux 9 (Stretch), x86-64, x86-64/lp64, clang++
219 |
220 | sudo apt install clang-7 make
221 | make GCC=clang-7 GXX=clang++-7
222 |
223 | + Debian GNU/Linux 9 (Stretch), x86-64, x86-64/lp64, g++
224 |
225 | sudo apt install g++ make
226 | make GXX='g++ -fpermissive'
227 |
228 | ***
229 |
230 | + Ubuntu Server 16.04 LTS, x86-64, x86-64/lp64, clang++
231 |
232 | sudo apt install clang-6.0 make
233 | make GCC=clang-6.0 GXX=clang++-6.0
234 |
235 | + Ubuntu Server 16.04 LTS, x86-64, x86-64/lp64, g++
236 |
237 | sudo apt install g++ make
238 | make GXX='g++ -fpermissive'
239 |
240 | ***
241 |
242 | + Debian GNU/Linux 8 (Jessie), x86-64, x86-64/lp64, clang++
243 |
244 | sudo apt install clang-4.0
245 | make GCC=clang-4.0 GXX=clang++-4.0
246 |
247 | + Debian GNU/Linux 8 (Jessie), x86-64, x86-64/lp64, g++
248 |
249 | sudo apt install g++
250 | make GXX='g++ -fpermissive'
251 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
MANOOL v0.6.0
2 | =====================================================================================================
3 |
4 | **MANOOL is meant to make exploratory programming safer and faster.**
5 |
6 | Some programming tasks are common and predictable from the project management perspective, but often, even enterprise information systems (especially in the
7 | area of startups) involve some innovation and exploratory programming. Imagine you have such a task at hand. Whenever this happens you have two options:
8 | 1. use an *implementation-level* programming language, such as C, C++, Java, or maybe Rust (if you want to try a more recent approach) or
9 | 2. use a language more suitable for *throw-away* programming, such as PHP, Python, Ruby, JavaScript, or even Scheme.
10 |
11 | In the former case, you eventually get stuck with your coding -- trying to conceive some poorly understood algorithms, deciding which data types to use and how
12 | to get around seemingly arbitrary constraints for composite data types, devising resource management policies, and dealing with confusing program logic.
13 |
14 | Then you resort to the second option, in which case you also have to conceive poorly understood algorithms, deal with confusing program logic, and occasionally
15 | think about how to circumvent composite data type constraints, but most probably you end up familiarized yourself with the problem domain and come to a working
16 | prototype.
17 |
18 | You show your solution (which mostly looks nice) to the managers, and suddenly they react: "OK, let's clear up the bugs; tomorrow we deploy it in production!".
19 | Then disaster falls on you; after some time of production use, it turns out that
20 | * your code is not scalable to a grown user base and hence larger workload, or the solution is simply slow according to your end users,
21 | * your code has mysterious and hard to localize bugs, and of course
22 | * the program logic itself still looks confusing and complex.
23 |
24 | This happens because paying attention to those details would imply an undue cognitive burden at the early stage of development. And unlike your managers you
25 | already knew that: a major rewrite is unavoidable, now in a "real" implementation-level language -- does this sound familiar?
26 |
27 | While MANOOL is a general-purpose programming language, it is specifically designed to solve the above problem. It may also help you to come to a working
28 | prototype faster and then gradually refactor your code up to a production-quality state instead of rewriting the code entirely from scratch.
29 |
--------------------------------------------------------------------------------
/base-opt-and.cc:
--------------------------------------------------------------------------------
1 | // base-opt-and.cc
2 | # define MNL_EXPR expr_and
3 | # include "base-opt-cond.tcc"
4 |
--------------------------------------------------------------------------------
/base-opt-apply2.cc:
--------------------------------------------------------------------------------
1 | // base-opt-apply2.cc -- base optimization rules
2 |
3 | /* Copyright (C) 2018, 2019, 2020 Alexey Protasov (AKA Alex or rusini)
4 |
5 | This file is part of MANOOL.
6 |
7 | MANOOL is free software: you can redistribute it and/or modify it under the terms of the version 3 of the GNU General Public License
8 | as published by the Free Software Foundation (and only version 3).
9 |
10 | MANOOL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License along with MANOOL. If not, see . */
14 |
15 |
16 | # include "config.tcc"
17 | # include "base.tcc"
18 |
19 | namespace MNL_AUX_UUID { namespace aux {
20 | code optimize(expr_apply2<> expr) {
21 | code res = move(expr);
22 | # ifdef MNL_WITH_OPTIMIZE
23 | # define MNL_M(OP) \
24 | match, expr_tmp >> (res) || \
25 | match, code >> (res) || \
26 | match, expr_tmp >> (res) || \
27 | match, code >> (res) || \
28 | match, expr_tmp >> (res) || \
29 | match, code >> (res) || \
30 | match, expr_tmp >> (res) || \
31 | match, code >> (res) || \
32 | match, expr_tmp >> (res) || \
33 | match, code >> (res) || \
34 | match, expr_tmp >> (res) || \
35 | match, code >> (res) || \
36 | match, expr_tmp >> (res) || \
37 | match, code >> (res) || \
38 | match >> (res) || \
39 | match >> (res) || \
40 | match >> (res) || \
41 | match >> (res) || \
42 | match >> (res) || \
43 | match >> (res) || \
44 | match >> (res) || \
45 | match> (res) || \
46 | match> (res) || \
47 | match >> (res) || \
48 | match >> (res) || \
49 | match >> (res) || \
50 | match >> (res) || \
51 | match >> (res) || \
52 | match >> (res) || \
53 | match >> (res) || \
54 | match> (res) || \
55 | match> (res) ||
56 | MNL_M(_eq) MNL_M(_ne)
57 | # undef MNL_M
58 | # define MNL_M(OP) \
59 | match, expr_tmp >> (res) || \
60 | match, code >> (res) || \
61 | match, expr_tmp >> (res) || \
62 | match, code >> (res) || \
63 | match, expr_tmp >> (res) || \
64 | match, code >> (res) || \
65 | match, expr_tmp >> (res) || \
66 | match, code >> (res) || \
67 | match >> (res) || \
68 | match >> (res) || \
69 | match >> (res) || \
70 | match >> (res) || \
71 | match> (res) || \
72 | match> (res) || \
73 | match >> (res) || \
74 | match >> (res) || \
75 | match >> (res) || \
76 | match >> (res) || \
77 | match> (res) || \
78 | match> (res) ||
79 | MNL_M(_lt) MNL_M(_le) MNL_M(_gt) MNL_M(_ge) MNL_M(_add) MNL_M(_sub) MNL_M(_mul)
80 | # undef MNL_M
81 | # define MNL_M(OP) \
82 | match> (res) || \
83 | match> (res) || \
84 | match> (res) || \
85 | match> (res) || \
86 | MNL_M(_xor)
87 | # undef MNL_M
88 | match, expr_lit<>, expr_tmp >> (res) ||
89 | match, expr_lit<>, code >> (res) ||
90 | match, expr_tmp, expr_lit<> >> (res) ||
91 | match, expr_tmp, expr_tmp >> (res) ||
92 | match, expr_tmp, code >> (res) ||
93 | match, code, expr_lit<> >> (res) ||
94 | match, code, expr_tmp >> (res) ||
95 | match, code, code >> (res) ||
96 | match, expr_tmp, expr_lit >> (res) ||
97 | match, expr_tmp, expr_tmp >> (res) ||
98 | match, expr_tmp, code >> (res) ||
99 | match, code, expr_lit >> (res) ||
100 | match, code, expr_tmp >> (res) ||
101 | match, code, code >> (res) ||
102 | match >> (res) ||
103 | match> (res) ||
104 | match> (res) ||
105 | match >> (res) ||
106 | match> (res) ||
107 | match> (res) ||
108 | match >> (res) ||
109 | match> (res) ||
110 | match> (res) ||
111 | match >> (res) ||
112 | match> (res) ||
113 | match> (res);
114 | # endif // # ifdef MNL_WITH_OPTIMIZE
115 | return res;
116 | }
117 | }} // namespace MNL_AUX_UUID::aux
118 |
--------------------------------------------------------------------------------
/base-opt-cond.tcc:
--------------------------------------------------------------------------------
1 | // base-opt-cond.tcc -- base optimization rules
2 |
3 | /* Copyright (C) 2018, 2019, 2020 Alexey Protasov (AKA Alex or rusini)
4 |
5 | This file is part of MANOOL.
6 |
7 | MANOOL is free software: you can redistribute it and/or modify it under the terms of the version 3 of the GNU General Public License
8 | as published by the Free Software Foundation (and only version 3).
9 |
10 | MANOOL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License along with MANOOL. If not, see . */
14 |
15 |
16 | # include "config.tcc"
17 | # include "base.tcc"
18 |
19 | namespace MNL_AUX_UUID { namespace aux {
20 | code optimize(MNL_EXPR<> expr) {
21 | code res = move(expr);
22 | # ifdef MNL_WITH_OPTIMIZE
23 | match >> (res) ||
24 | match >> (res) ||
25 | # define MNL_M(OP) \
26 | match, expr_tmp> >> (res) || \
27 | match, code> >> (res) || \
28 | match, expr_tmp> >> (res) || \
29 | match, code> >> (res) || \
30 | match, expr_tmp> >> (res) || \
31 | match, code> >> (res) || \
32 | match, expr_tmp> >> (res) || \
33 | match, code> >> (res) || \
34 | match, expr_tmp> >> (res) || \
35 | match, code> >> (res) || \
36 | match, expr_tmp> >> (res) || \
37 | match, code> >> (res) || \
38 | match, expr_tmp> >> (res) || \
39 | match, code> >> (res) || \
40 | match> >> (res) || \
41 | match> >> (res) || \
42 | match> >> (res) || \
43 | match> >> (res) || \
44 | match> >> (res) || \
45 | match> >> (res) || \
46 | match> >> (res) || \
47 | match >> (res) || \
48 | match >> (res) || \
49 | match> >> (res) || \
50 | match> >> (res) || \
51 | match> >> (res) || \
52 | match> >> (res) || \
53 | match> >> (res) || \
54 | match> >> (res) || \
55 | match> >> (res) || \
56 | match >> (res) || \
57 | match >> (res) ||
58 | MNL_M(_eq) MNL_M(_ne)
59 | # undef MNL_M
60 | # define MNL_M(OP) \
61 | match, expr_tmp> >> (res) || \
62 | match, code> >> (res) || \
63 | match, expr_tmp> >> (res) || \
64 | match, code> >> (res) || \
65 | match, expr_tmp> >> (res) || \
66 | match, code> >> (res) || \
67 | match, expr_tmp> >> (res) || \
68 | match, code> >> (res) || \
69 | match> >> (res) || \
70 | match> >> (res) || \
71 | match> >> (res) || \
72 | match> >> (res) || \
73 | match >> (res) || \
74 | match >> (res) || \
75 | match> >> (res) || \
76 | match> >> (res) || \
77 | match> >> (res) || \
78 | match> >> (res) || \
79 | match >> (res) || \
80 | match >> (res) ||
81 | MNL_M(_lt) MNL_M(_le) MNL_M(_gt) MNL_M(_ge)
82 | # undef MNL_M
83 | # define MNL_M(OP) \
84 | match >> (res) || \
85 | match >> (res) || \
86 | match >> (res) || \
87 | match >> (res) ||
88 | MNL_M(_xor)
89 | # undef MNL_M
90 | match> (res) ||
91 | match> (res);
92 | # endif // # ifdef MNL_WITH_OPTIMIZE
93 | return res;
94 | }
95 | }} // namespace MNL_AUX_UUID::aux
96 |
--------------------------------------------------------------------------------
/base-opt-if.cc:
--------------------------------------------------------------------------------
1 | // base-opt-if.cc
2 | # define MNL_EXPR expr_if
3 | # include "base-opt-cond.tcc"
4 |
--------------------------------------------------------------------------------
/base-opt-ifelse.cc:
--------------------------------------------------------------------------------
1 | // base-opt-ifelse.cc
2 | # define MNL_EXPR expr_ifelse
3 | # include "base-opt-cond.tcc"
4 |
--------------------------------------------------------------------------------
/base-opt-misc.cc:
--------------------------------------------------------------------------------
1 | // base-opt-misc.cc -- base optimization rules
2 |
3 | /* Copyright (C) 2018, 2019, 2020 Alexey Protasov (AKA Alex or rusini)
4 |
5 | This file is part of MANOOL.
6 |
7 | MANOOL is free software: you can redistribute it and/or modify it under the terms of the version 3 of the GNU General Public License
8 | as published by the Free Software Foundation (and only version 3).
9 |
10 | MANOOL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License along with MANOOL. If not, see . */
14 |
15 |
16 | # include "config.tcc"
17 | # include "base.tcc"
18 |
19 | namespace MNL_AUX_UUID { namespace aux {
20 | code optimize(expr_lit<> expr) {
21 | code res = move(expr);
22 | # ifdef MNL_WITH_OPTIMIZE
23 | match> (res) ||
24 | match> (res) ||
25 | match> (res) ||
26 | match> (res) ||
27 | match> (res) ||
28 | match> (res) ||
29 | match> (res) ||
30 | match> (res);
31 | # endif // # ifdef MNL_WITH_OPTIMIZE
32 | return res;
33 | }
34 | code optimize(expr_apply0<> expr) {
35 | code res = move(expr);
36 | # ifdef MNL_WITH_OPTIMIZE
37 | match >> (res) ||
38 | match> (res) ||
39 | match> (res);
40 | # endif // # ifdef MNL_WITH_OPTIMIZE
41 | return res;
42 | }
43 | code optimize(expr_apply1<> expr) {
44 | code res = move(expr);
45 | # ifdef MNL_WITH_OPTIMIZE
46 | match> (res) ||
47 | match> (res) ||
48 | match> (res) ||
49 | match> (res) ||
50 | match> (res) ||
51 | match> (res) ||
52 | match, code >> (res) ||
53 | match, expr_lit >> (res) ||
54 | match, expr_tmp >> (res) ||
55 | match, code >> (res) ||
56 | match >> (res) ||
57 | match> (res) ||
58 | match> (res) ||
59 | match >> (res) ||
60 | match> (res) ||
61 | match> (res);
62 | # endif // # ifdef MNL_WITH_OPTIMIZE
63 | return res;
64 | }
65 | code optimize(expr_apply3<> expr) {
66 | code res = move(expr);
67 | # ifdef MNL_WITH_OPTIMIZE
68 | match >> (res) ||
69 | match >> (res) ||
70 | match> (res) ||
71 | match> (res);
72 | # endif // # ifdef MNL_WITH_OPTIMIZE
73 | return res;
74 | }
75 | code optimize(expr_apply4<> expr) {
76 | code res = move(expr);
77 | # ifdef MNL_WITH_OPTIMIZE
78 | match >> (res) ||
79 | match >> (res) ||
80 | match> (res) ||
81 | match> (res);
82 | # endif // # ifdef MNL_WITH_OPTIMIZE
83 | return res;
84 | }
85 | code optimize(expr_move<> expr) {
86 | code res = move(expr);
87 | # ifdef MNL_WITH_OPTIMIZE
88 | match> (res) ||
89 | match> (res);
90 | # endif // # ifdef MNL_WITH_OPTIMIZE
91 | return res;
92 | }
93 | code optimize(expr_att expr) {
94 | code res = move(expr);
95 | # ifdef MNL_WITH_OPTIMIZE
96 | match (res) ||
97 | match (res);
98 | # endif // # ifdef MNL_WITH_OPTIMIZE
99 | return res;
100 | }
101 | code optimize(expr_on<> expr) {
102 | code res = move(expr);
103 | # ifdef MNL_WITH_OPTIMIZE
104 | match >> (res) ||
105 | match> (res) ||
106 | match> (res);
107 | # endif // # ifdef MNL_WITH_OPTIMIZE
108 | return res;
109 | }
110 | }} // namespace MNL_AUX_UUID::aux
111 |
--------------------------------------------------------------------------------
/base-opt-or.cc:
--------------------------------------------------------------------------------
1 | // base-opt-or.cc
2 | # define MNL_EXPR expr_or
3 | # include "base-opt-cond.tcc"
4 |
--------------------------------------------------------------------------------
/base-opt-set.cc:
--------------------------------------------------------------------------------
1 | // base-opt-set.cc -- base optimization rules
2 |
3 | /* Copyright (C) 2018, 2019, 2020 Alexey Protasov (AKA Alex or rusini)
4 |
5 | This file is part of MANOOL.
6 |
7 | MANOOL is free software: you can redistribute it and/or modify it under the terms of the version 3 of the GNU General Public License
8 | as published by the Free Software Foundation (and only version 3).
9 |
10 | MANOOL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License along with MANOOL. If not, see . */
14 |
15 |
16 | # include "config.tcc"
17 | # include "base.tcc"
18 |
19 | namespace MNL_AUX_UUID { namespace aux {
20 | code optimize(expr_set<> expr) {
21 | code res = move(expr);
22 | # ifdef MNL_WITH_OPTIMIZE
23 | match >> (res) ||
24 | match >> (res) ||
25 | match >> (res) ||
26 | match >> (res) ||
27 | match >> (res) ||
28 | match >> (res) ||
29 | match >> (res) ||
30 | match >> (res) ||
31 | match >> (res) ||
32 | match >> (res) ||
33 | match >> (res) ||
34 | match >> (res) ||
35 | match >> (res) ||
36 | match >> (res) ||
37 | # define MNL_M(OP) \
38 | match, expr_tmp> >> (res) || \
39 | match, code> >> (res) || \
40 | match, expr_tmp> >> (res) || \
41 | match, code> >> (res) || \
42 | match, expr_tmp> >> (res) || \
43 | match, code> >> (res) || \
44 | match, expr_tmp> >> (res) || \
45 | match, code> >> (res) || \
46 | match, expr_tmp> >> (res) || \
47 | match, code> >> (res) || \
48 | match, expr_tmp> >> (res) || \
49 | match, code> >> (res) || \
50 | match, expr_tmp> >> (res) || \
51 | match, code> >> (res) || \
52 | match> >> (res) || \
53 | match> >> (res) || \
54 | match> >> (res) || \
55 | match> >> (res) || \
56 | match> >> (res) || \
57 | match> >> (res) || \
58 | match> >> (res) || \
59 | match >> (res) || \
60 | match >> (res) || \
61 | match> >> (res) || \
62 | match> >> (res) || \
63 | match> >> (res) || \
64 | match> >> (res) || \
65 | match> >> (res) || \
66 | match> >> (res) || \
67 | match> >> (res) || \
68 | match >> (res) || \
69 | match >> (res) ||
70 | MNL_M(_eq) MNL_M(_ne)
71 | # undef MNL_M
72 | # define MNL_M(OP) \
73 | match, expr_tmp> >> (res) || \
74 | match, code> >> (res) || \
75 | match, expr_tmp> >> (res) || \
76 | match, code> >> (res) || \
77 | match, expr_tmp> >> (res) || \
78 | match, code> >> (res) || \
79 | match, expr_tmp> >> (res) || \
80 | match, code> >> (res) || \
81 | match> >> (res) || \
82 | match> >> (res) || \
83 | match> >> (res) || \
84 | match> >> (res) || \
85 | match >> (res) || \
86 | match >> (res) || \
87 | match> >> (res) || \
88 | match> >> (res) || \
89 | match> >> (res) || \
90 | match