This commit is contained in:
Jeehoon Kang
2021-06-21 18:45:39 +00:00
parent 2d8d1e7fb4
commit 4535b2ef6f
28 changed files with 696 additions and 370 deletions

2
.github/bors.toml vendored Normal file
View File

@@ -0,0 +1,2 @@
delete_merged_branches = true
status = ["ci"]

36
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: CI
on:
pull_request:
push:
branches:
- master
- staging
- trying
defaults:
run:
shell: bash
jobs:
ci:
name: ci
runs-on: [self-hosted, ubuntu-20.04]
steps:
- uses: actions/checkout@v2
- name: Install latest
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
components: rust-src, rustfmt, clippy
- name: Rustfmt
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all
- name: Check
run: cargo check --all
- name: Test (Debug)
run: RUST_MIN_STACK=8388608 cargo test -- --skip test_examples_asmgen
- name: Test (Release)
run: RUST_MIN_STACK=8388608 cargo test --release -- --skip test_examples_asmgen

47
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,47 @@
# Setup a cache to cache job parts between jobs to ensure faster builds
cache:
key: "$CI_JOB_NAME"
untracked: true
paths:
- $HOME/.cargo/
- target/
# Set any required environment variables here
variables:
RUST_BACKTRACE: "FULL"
image: "rust:latest"
stages:
- install
- test
install:
stage: install
script:
- rustup default stable
check:
stage: test
before_script:
- rustup component add rustfmt clippy
- cargo install cargo-audit
script:
- cargo check --verbose
- cargo fmt -- --check
- cargo clippy -- -D warnings
- cargo audit
debug:
stage: test
before_script:
- apt update && apt install -yy gcc-riscv64-linux-gnu g++-riscv64-linux-gnu qemu-user-static
script:
- RUST_MIN_STACK=8388608 cargo test
release:
stage: test
before_script:
- apt update && apt install -yy gcc-riscv64-linux-gnu g++-riscv64-linux-gnu qemu-user-static
script:
- RUST_MIN_STACK=8388608 cargo test --release

535
Cargo.lock generated
View File

@@ -1,489 +1,638 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3
[[package]] [[package]]
name = "ansi_term" name = "addr2line"
version = "0.11.0" version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a"
dependencies = [ dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "gimli",
] ]
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]] [[package]]
name = "atty" name = "atty"
version = "0.2.14" version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [ dependencies = [
"hermit-abi 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "hermit-abi",
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", "libc",
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi",
] ]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.0.0" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.46" version = "0.3.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7815ea54e4d821e791162e078acbebfd6d8c8939cd559c9335dceb1c8ca7282"
dependencies = [ dependencies = [
"backtrace-sys 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "addr2line",
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cc",
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if",
"rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "libc",
] "miniz_oxide",
"object",
[[package]] "rustc-demangle",
name = "backtrace-sys"
version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.52 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.2.1" version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.52" version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "0.1.10" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "2.33.0" version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142"
dependencies = [ dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty",
"atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags",
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap_derive",
"strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap",
"textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static",
"unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "os_str_bytes",
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "strsim",
"yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor",
"textwrap",
"unicode-width",
"vec_map",
"yaml-rust",
]
[[package]]
name = "clap_derive"
version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1"
dependencies = [
"heck",
"proc-macro-error",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.73",
] ]
[[package]] [[package]]
name = "either" name = "either"
version = "1.5.3" version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]] [[package]]
name = "failure" name = "failure"
version = "0.1.7" version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
dependencies = [ dependencies = [
"backtrace 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace",
"failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive",
] ]
[[package]] [[package]]
name = "failure_derive" name = "failure_derive"
version = "0.1.7" version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [ dependencies = [
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2",
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.9",
"syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.73",
"synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure",
] ]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.1.14" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
dependencies = [ dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if",
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", "libc",
"wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)", "wasi",
]
[[package]]
name = "gimli"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189"
[[package]]
name = "hashbrown"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
[[package]]
name = "heck"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
dependencies = [
"unicode-segmentation",
] ]
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.12" version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
dependencies = [ dependencies = [
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", "libc",
] ]
[[package]] [[package]]
name = "hexf" name = "hexf"
version = "0.1.0" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e54653cc32d838771a36532647afad59c4bf7155745eeeec406f71fd5d7e7538"
dependencies = [ dependencies = [
"hexf-impl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "hexf-impl",
"hexf-parse 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "hexf-parse",
"proc-macro-hack 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-hack",
] ]
[[package]] [[package]]
name = "hexf-impl" name = "hexf-impl"
version = "0.1.0" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22eadcfadba76a730b2764eaa577d045f35e0ef5174b9c5b46adf1ee42b85e12"
dependencies = [ dependencies = [
"hexf-parse 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "hexf-parse",
"proc-macro-hack 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-hack",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.11.11",
] ]
[[package]] [[package]]
name = "hexf-parse" name = "hexf-parse"
version = "0.1.0" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79296f72d53a89096cbc9a88c9547ee8dfe793388674620e2207593d370550ac"
[[package]]
name = "indexmap"
version = "1.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]] [[package]]
name = "itertools" name = "itertools"
version = "0.9.0" version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf"
dependencies = [ dependencies = [
"either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "either",
] ]
[[package]] [[package]]
name = "kecc" name = "kecc"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap",
"failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "failure",
"hexf 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "hexf",
"itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools",
"lang-c 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "lang-c",
"ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "ordered-float",
"peg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "peg",
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand",
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile",
"wait-timeout 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "wait-timeout",
] ]
[[package]] [[package]]
name = "lang-c" name = "lang-c"
version = "0.8.1" version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a597343db6f9affec95665270028e3113864b48a1a0ba9257c1553ade3840207"
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.69" version = "0.2.97"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
[[package]]
name = "linked-hash-map"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]]
name = "memchr"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
[[package]]
name = "miniz_oxide"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
dependencies = [
"adler",
"autocfg",
]
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.11" version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [ dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "autocfg",
]
[[package]]
name = "object"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a38f2be3697a57b4060074ff41b44c16870d916ad7877c17696e063257482bc7"
dependencies = [
"memchr",
] ]
[[package]] [[package]]
name = "ordered-float" name = "ordered-float"
version = "1.0.2" version = "2.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f100fcfb41e5385e0991f74981732049f9b896821542a219420491046baafdc2"
dependencies = [ dependencies = [
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits",
] ]
[[package]] [[package]]
name = "peg" name = "os_str_bytes"
version = "0.6.2" version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afb2e1c3ee07430c2cf76151675e583e0f19985fa6efae47d6848a3e2c824f85"
[[package]]
name = "peg"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07c0b841ea54f523f7aa556956fbd293bcbe06f2e67d2eb732b7278aaf1d166a"
dependencies = [ dependencies = [
"peg-macros 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "peg-macros",
"peg-runtime 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "peg-runtime",
] ]
[[package]] [[package]]
name = "peg-macros" name = "peg-macros"
version = "0.6.2" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5aa52829b8decbef693af90202711348ab001456803ba2a98eb4ec8fb70844c"
dependencies = [ dependencies = [
"peg-runtime 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "peg-runtime",
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2",
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.9",
] ]
[[package]] [[package]]
name = "peg-runtime" name = "peg-runtime"
version = "0.6.2" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c719dcf55f09a3a7e764c6649ab594c18a177e3599c467983cdf644bfc0a4088"
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.6" version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.73",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"version_check",
]
[[package]] [[package]]
name = "proc-macro-hack" name = "proc-macro-hack"
version = "0.3.3" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b773f824ff2a495833f85fcdddcf85e096949971decada2e93249fa2c6c3d32f"
dependencies = [ dependencies = [
"proc-macro-hack-impl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-hack-impl",
] ]
[[package]] [[package]]
name = "proc-macro-hack-impl" name = "proc-macro-hack-impl"
version = "0.3.3" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f674ccc446da486175527473ec8aa064f980b0966bbf767ee743a5dff6244a7"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.10" version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
dependencies = [ dependencies = [
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.2",
] ]
[[package]] [[package]]
name = "quote" name = "quote"
version = "0.3.15" version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.3" version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
dependencies = [ dependencies = [
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2",
] ]
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.7.3" version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [ dependencies = [
"getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "libc",
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha",
"rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core",
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc",
"rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "rand_chacha" name = "rand_chacha"
version = "0.2.2" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [ dependencies = [
"ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "ppv-lite86",
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core",
] ]
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.5.1" version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [ dependencies = [
"getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "getrandom",
] ]
[[package]] [[package]]
name = "rand_hc" name = "rand_hc"
version = "0.2.0" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [ dependencies = [
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core",
] ]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.1.56" version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee"
dependencies = [
"bitflags",
]
[[package]] [[package]]
name = "remove_dir_all" name = "remove_dir_all"
version = "0.5.2" version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [ dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi",
] ]
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.16" version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.8.0" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "0.11.11" version = "0.11.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
dependencies = [ dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.3.15",
"synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", "synom",
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.0.4",
] ]
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.18" version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
dependencies = [ dependencies = [
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2",
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.9",
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.2",
] ]
[[package]] [[package]]
name = "synom" name = "synom"
version = "0.11.3" version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
dependencies = [ dependencies = [
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.0.4",
] ]
[[package]] [[package]]
name = "synstructure" name = "synstructure"
version = "0.12.3" version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
dependencies = [ dependencies = [
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2",
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.9",
"syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.73",
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.2",
] ]
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.1.0" version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
dependencies = [ dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if",
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", "libc",
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand",
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall",
"remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all",
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi",
]
[[package]]
name = "termcolor"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
dependencies = [
"winapi-util",
] ]
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.11.0" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
dependencies = [ dependencies = [
"unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width",
] ]
[[package]] [[package]]
name = "unicode-width" name = "unicode-segmentation"
version = "0.1.7" version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
[[package]]
name = "unicode-width"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.0.4" version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.0" version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]] [[package]]
name = "vec_map" name = "vec_map"
version = "0.8.1" version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
[[package]] [[package]]
name = "wait-timeout" name = "wait-timeout"
version = "0.2.0" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6"
dependencies = [ dependencies = [
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", "libc",
] ]
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.9.0+wasi-snapshot-preview1" version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.8" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [ dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-x86_64-pc-windows-gnu",
] ]
[[package]] [[package]]
name = "winapi-i686-pc-windows-gnu" name = "winapi-i686-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "winapi-x86_64-pc-windows-gnu" name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "yaml-rust" name = "yaml-rust"
version = "0.3.5" version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
[metadata] dependencies = [
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "linked-hash-map",
"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" ]
"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
"checksum backtrace 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)" = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e"
"checksum backtrace-sys 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "78848718ee1255a2485d1309ad9cdecfc2e7d0362dd11c6829364c6b35ae1bc7"
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
"checksum cc 1.0.52 (registry+https://github.com/rust-lang/crates.io-index)" = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d"
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
"checksum failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b"
"checksum failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231"
"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
"checksum hermit-abi 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4"
"checksum hexf 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e54653cc32d838771a36532647afad59c4bf7155745eeeec406f71fd5d7e7538"
"checksum hexf-impl 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "22eadcfadba76a730b2764eaa577d045f35e0ef5174b9c5b46adf1ee42b85e12"
"checksum hexf-parse 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "79296f72d53a89096cbc9a88c9547ee8dfe793388674620e2207593d370550ac"
"checksum itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
"checksum lang-c 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2554b3a7a324e3d8ad63603fe6729c4c144bab2ab36742c45a72788bff50e8ec"
"checksum libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)" = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
"checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518"
"checksum peg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9075875c14bb21f25f11cad4b6ad2e4dd443b8fb83900b2fbdd6ebd744b82e97"
"checksum peg-macros 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c24c165fd39e995246140cc78df55c56c6733ba87e6658cb3e197b8856c62852"
"checksum peg-runtime 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0c1a2897e69d986c7986747ebad425cf03746ec5e3e09bb3b2600f91301ba864"
"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
"checksum proc-macro-hack 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b773f824ff2a495833f85fcdddcf85e096949971decada2e93249fa2c6c3d32f"
"checksum proc-macro-hack-impl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0f674ccc446da486175527473ec8aa064f980b0966bbf767ee743a5dff6244a7"
"checksum proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
"checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
"checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
"checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
"checksum wait-timeout 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6"
"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
"checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992"

View File

@@ -1,7 +1,7 @@
[package] [package]
name = "kecc" name = "kecc"
version = "0.1.0" version = "0.1.0"
authors = ["Chunmyong Park <chunmyong.park@kaist.ac.kr>", "Jeehoon Kang <jeehoon.kang@kaist.ac.kr>", "Hyunsu Kim <hyunsu.kim00@kaist.ac.kr>"] authors = ["Chunmyong Park <chunmyong.park@kaist.ac.kr>", "Jeehoon Kang <jeehoon.kang@kaist.ac.kr>"]
edition = "2018" edition = "2018"
default-run = "kecc" default-run = "kecc"
@@ -18,19 +18,24 @@ path = "src/lib.rs"
[[bin]] [[bin]]
name = "kecc" name = "kecc"
path = "bin/kecc.rs" path = "bin/kecc.rs"
required-features = ["build-bin"]
[[bin]] [[bin]]
name = "fuzz" name = "fuzz"
path = "bin/fuzz.rs" path = "bin/fuzz.rs"
required-features = ["build-bin"]
[features]
build-bin = ["clap"]
[dependencies] [dependencies]
clap = { version = "2.33.0", features = ["yaml"] } clap = { version = "3.0.0-beta.2", features = ["yaml"], optional = true }
lang-c = "0.8.1" lang-c = "0.10.1"
itertools = "0.9.0" itertools = "0.10.1"
failure = "0.1.7" failure = "0.1.8"
tempfile = "3.1.0" tempfile = "3.2.0"
ordered-float = "1.0" ordered-float = "2.5.1"
hexf = "0.1.0" hexf = "0.1.0"
wait-timeout = "0.2.0" wait-timeout = "0.2.0"
peg = "0.6.2" peg = "0.7.0"
rand = "0.7" rand = "0.8.4"

48
Jenkinsfile vendored
View File

@@ -1,48 +0,0 @@
def setupRust() {
sh "rustup component add rustfmt clippy"
sh "rustup install nightly"
sh "cargo update"
sh "cargo"
}
pipeline {
agent {
docker {
image 'rust:latest'
}
}
stages {
stage('Rustfmt') {
steps {
setupRust()
sh "cargo fmt --all -- --check"
}
}
stage('Clippy') {
steps {
setupRust()
sh "cargo clippy --all"
}
}
stage('Build') {
steps {
setupRust()
sh "cargo build"
sh "cargo build --release"
}
}
stage('Test') {
steps {
setupRust()
// When `cargo test` runs, the function `it_works()` is called in a new thread.
// The stack size of a new thread is `2 MiB` on Linux, and this small stack size
// can cause `stack-overflow` error when testing stack-intensive code.
// For this reason, we need to increase the default size of stack to `8 MiB`.
// TODO: delete `--skip test_examples_asmgen`
sh "RUST_MIN_STACK=8388608 cargo test -- --skip test_examples_asmgen"
sh "RUST_MIN_STACK=8388608 cargo test --release -- --skip test_examples_asmgen"
}
}
}
}

View File

@@ -16,15 +16,15 @@ cargo build --release # release build
## Run ## Run
```sh ```sh
cargo run -- -h # print options cargo run --features=build-bin -- -h # print options
cargo run -- -p examples/c/fibonacci.c # parse cargo run --features=build-bin -- -p examples/c/fibonacci.c # parse
cargo run -- -i examples/c/fibonacci.c # irgen cargo run --features=build-bin -- -i examples/c/fibonacci.c # irgen
cargo run -- -O --iroutput examples/c/fibonacci.c # optimize cargo run --features=build-bin -- -O --iroutput examples/c/fibonacci.c # optimize
cargo run -- examples/c/fibonacci.c # compile cargo run --features=build-bin -- examples/c/fibonacci.c # compile
cargo run -- --irrun examples/c/fibonacci.c # interprets the IR cargo run --features=build-bin -- --irrun examples/c/fibonacci.c # interprets the IR
cargo run --release -- examples/c/fibonacci.c # compile with release build cargo run --features=build-bin --release -- examples/c/fibonacci.c # compile with release build
``` ```
@@ -73,9 +73,8 @@ cat tests/test_reduced.c
### Install ### Install
```sh ```sh
# Ubuntu 18.04 or higher # Ubuntu 20.04
apt install -y make cmake python3 sudo apt install -y make cmake python3 csmith libcsmith-dev creduce
apt install -y csmith libcsmith-dev creduce
``` ```
### Run ### Run
@@ -113,8 +112,8 @@ reduces the program; check if the reduced program still fails on the test, and i
given program with the reduced one; repeat until you get a small enough buggy program. For more given program with the reduced one; repeat until you get a small enough buggy program. For more
information, we refer to the [Creduce](https://embed.cs.utah.edu/creduce/) homepage. information, we refer to the [Creduce](https://embed.cs.utah.edu/creduce/) homepage.
**[NOTICE]** The fuzzer supports Ubuntu 18.04 or 20.04 only. It may work for other platforms, but if it **[NOTICE]** The fuzzer supports Ubuntu 20.04 only. It may work for other platforms, but if it
doesn't, please run the fuzzer in Ubuntu 18.04 or 20.04. doesn't, please run the fuzzer in Ubuntu 20.04.
## Running RISC-V Binaries ## Running RISC-V Binaries
@@ -122,18 +121,18 @@ doesn't, please run the fuzzer in Ubuntu 18.04 or 20.04.
### Install ### Install
```sh ```sh
# Ubuntu 20.04 or higher # Ubuntu 20.04
apt install gcc-10-riscv64-linux-gnu g++-10-riscv64-linux-gnu qemu-user-static sudo apt install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu qemu-user-static
``` ```
### Cross-Compilation and Architecture-Emulation ### Cross-Compilation and Architecture-Emulation
```sh ```sh
# Compile C source code into RISC-V assembly # Compile C source code into RISC-V assembly
riscv64-linux-gnu-gcc-10 hello.c -S -o hello.S riscv64-linux-gnu-gcc hello.c -S -o hello.S
# Link to an RISC-V executable # Link to an RISC-V executable
riscv64-linux-gnu-gcc-10 -static hello.S -o hello riscv64-linux-gnu-gcc -static hello.S -o hello
# Emulate the executable # Emulate the executable
qemu-riscv64-static ./hello qemu-riscv64-static ./hello

View File

@@ -1,5 +1,5 @@
CC=riscv64-linux-gnu-gcc-10 CC=riscv64-linux-gnu-gcc
CXX=riscv64-linux-gnu-g++-10 CXX=riscv64-linux-gnu-g++
KECC=../target/release/kecc KECC=../target/release/kecc
CFLAGS=-O CFLAGS=-O
RM=rm -f RM=rm -f

7
bench/remote.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e
sshpass -p 'sifive' scp bench-gcc hifiveu:/mnt/home/runner/cs420-final/bench-gcc
sshpass -p 'sifive' ssh hifiveu /usr/sbin/chroot /mnt "chown runner:runner /home/runner/cs420-final/bench-gcc"
sshpass -p 'sifive' ssh hifiveu /usr/sbin/chroot /mnt /bin/su - runner -c "/home/runner/cs420-final/bench-gcc"

View File

@@ -1,6 +1,4 @@
#[macro_use] use clap::{crate_authors, crate_description, crate_version, load_yaml, App};
extern crate clap;
use clap::{crate_authors, crate_description, crate_version, App};
extern crate kecc; extern crate kecc;
@@ -9,7 +7,7 @@ use std::path::Path;
fn main() { fn main() {
let yaml = load_yaml!("fuzz_cli.yml"); let yaml = load_yaml!("fuzz_cli.yml");
#[allow(deprecated)] #[allow(deprecated)]
let matches = App::from_yaml(yaml) let matches = App::from(yaml)
.version(crate_version!()) .version(crate_version!())
.about(crate_description!()) .about(crate_description!())
.author(crate_authors!(", ")) .author(crate_authors!(", "))

View File

@@ -1,8 +1,7 @@
use std::ffi::OsStr; use std::ffi::OsStr;
use std::path::Path; use std::path::Path;
#[macro_use]
extern crate clap; use clap::{crate_authors, crate_description, crate_version, load_yaml, App};
use clap::{crate_authors, crate_description, crate_version, App};
use lang_c::ast::TranslationUnit; use lang_c::ast::TranslationUnit;
@@ -17,7 +16,7 @@ use kecc::{
fn main() { fn main() {
let yaml = load_yaml!("kecc_cli.yml"); let yaml = load_yaml!("kecc_cli.yml");
#[allow(deprecated)] #[allow(deprecated)]
let matches = App::from_yaml(yaml) let matches = App::from(yaml)
.version(crate_version!()) .version(crate_version!())
.about(crate_description!()) .about(crate_description!())
.author(crate_authors!(", ")) .author(crate_authors!(", "))
@@ -26,7 +25,7 @@ fn main() {
let input = matches.value_of("INPUT").unwrap(); let input = matches.value_of("INPUT").unwrap();
let input = Path::new(input); let input = Path::new(input);
let output = matches.value_of("output").unwrap_or_else(|| "-"); let output = matches.value_of("output").unwrap_or("-");
let mut output: Box<dyn ::std::io::Write> = if output == "-" { let mut output: Box<dyn ::std::io::Write> = if output == "-" {
Box::new(::std::io::stdout()) Box::new(::std::io::stdout())
} else { } else {
@@ -48,7 +47,7 @@ fn main() {
fn compile_c( fn compile_c(
input: &TranslationUnit, input: &TranslationUnit,
output: &mut dyn ::std::io::Write, output: &mut dyn ::std::io::Write,
matches: &clap::ArgMatches<'_>, matches: &clap::ArgMatches,
) { ) {
if matches.is_present("parse") { if matches.is_present("parse") {
return; return;
@@ -78,7 +77,7 @@ fn compile_c(
fn compile_ir( fn compile_ir(
input: &mut ir::TranslationUnit, input: &mut ir::TranslationUnit,
output: &mut dyn ::std::io::Write, output: &mut dyn ::std::io::Write,
matches: &clap::ArgMatches<'_>, matches: &clap::ArgMatches,
) { ) {
if matches.is_present("irparse") { if matches.is_present("irparse") {
return; return;

View File

@@ -1,2 +0,0 @@
status = [ "continuous-integration/jenkins/branch" ]
delete_merged_branches = true

View File

@@ -1 +1 @@
1.44.0 1.53.0

View File

@@ -5,7 +5,7 @@ use crate::ir;
use core::convert::TryFrom; use core::convert::TryFrom;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct TODO {} pub struct Todo {}
/// TODO /// TODO
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
@@ -616,9 +616,9 @@ impl Immediate {
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum RelocationFunction { pub enum RelocationFunction {
/// %hi /// %hi
HI20, Hi20,
/// %lo /// %lo
LO12, Lo12,
} }
/// `Label` is used as branch, unconditional jump targets and symbol offsets. /// `Label` is used as branch, unconditional jump targets and symbol offsets.
@@ -676,17 +676,11 @@ impl TryFrom<ir::Dtype> for DataSize {
impl DataSize { impl DataSize {
pub fn is_integer(&self) -> bool { pub fn is_integer(&self) -> bool {
match self { matches!(self, Self::Byte | Self::Half | Self::Word | Self::Double)
Self::Byte | Self::Half | Self::Word | Self::Double => true,
_ => false,
}
} }
pub fn is_floating_point(&self) -> bool { pub fn is_floating_point(&self) -> bool {
match self { matches!(self, Self::SinglePrecision | Self::DoublePrecision)
Self::SinglePrecision | Self::DoublePrecision => true,
_ => false,
}
} }
fn word(self) -> Option<Self> { fn word(self) -> Option<Self> {

View File

@@ -434,8 +434,8 @@ impl WriteString for Immediate {
impl WriteString for RelocationFunction { impl WriteString for RelocationFunction {
fn write_string(&self) -> String { fn write_string(&self) -> String {
match self { match self {
Self::HI20 => "%hi", Self::Hi20 => "%hi",
Self::LO12 => "%lo", Self::Lo12 => "%lo",
} }
.to_string() .to_string()
} }

View File

@@ -79,7 +79,7 @@ impl IsEquiv for DeclaratorKind {
(Self::Identifier(identifier), Self::Identifier(other_identifier)) => { (Self::Identifier(identifier), Self::Identifier(other_identifier)) => {
identifier.node.name == other_identifier.node.name identifier.node.name == other_identifier.node.name
} }
(Self::Declarator(decl), Self::Declarator(other_decl)) => decl.is_equiv(&other_decl), (Self::Declarator(decl), Self::Declarator(other_decl)) => decl.is_equiv(other_decl),
_ => false, _ => false,
} }
} }
@@ -104,7 +104,7 @@ impl IsEquiv for DerivedDeclarator {
params.is_equiv(other_params) params.is_equiv(other_params)
} }
(Self::KRFunction(kr_func_decl), Self::KRFunction(other_kr_func_decl)) => { (Self::KRFunction(kr_func_decl), Self::KRFunction(other_kr_func_decl)) => {
kr_func_decl.is_equiv(&other_kr_func_decl) kr_func_decl.is_equiv(other_kr_func_decl)
} }
_ => false, _ => false,
} }
@@ -128,10 +128,10 @@ impl IsEquiv for ArraySize {
(Self::Unknown, Self::Unknown) => true, (Self::Unknown, Self::Unknown) => true,
(Self::VariableUnknown, Self::VariableUnknown) => true, (Self::VariableUnknown, Self::VariableUnknown) => true,
(Self::VariableExpression(expr), Self::VariableExpression(other_expr)) => { (Self::VariableExpression(expr), Self::VariableExpression(other_expr)) => {
expr.is_equiv(&other_expr) expr.is_equiv(other_expr)
} }
(Self::StaticExpression(expr), Self::StaticExpression(other_expr)) => { (Self::StaticExpression(expr), Self::StaticExpression(other_expr)) => {
expr.is_equiv(&other_expr) expr.is_equiv(other_expr)
} }
_ => false, _ => false,
} }
@@ -492,6 +492,7 @@ impl IsEquiv for Enumerator {
impl IsEquiv for TypeQualifier { impl IsEquiv for TypeQualifier {
fn is_equiv(&self, other: &Self) -> bool { fn is_equiv(&self, other: &Self) -> bool {
#[allow(clippy::match_like_matches_macro)]
match (self, other) { match (self, other) {
(Self::Const, Self::Const) => true, (Self::Const, Self::Const) => true,
_ => false, _ => false,

View File

@@ -8,6 +8,7 @@ use lang_c::span::Node;
use crate::utils::AssertSupported; use crate::utils::AssertSupported;
use crate::Translate; use crate::Translate;
/// TODO(document)
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
ParseError(ParseError), ParseError(ParseError),
@@ -15,7 +16,8 @@ pub enum Error {
Unsupported, Unsupported,
} }
#[derive(Default)] /// TODO(document)
#[derive(Default, Debug)]
pub struct Parse {} pub struct Parse {}
impl<P: AsRef<Path>> Translate<P> for Parse { impl<P: AsRef<Path>> Translate<P> for Parse {
@@ -182,7 +184,7 @@ impl AssertSupported for AlignmentSpecifier {
fn assert_supported(&self) { fn assert_supported(&self) {
match self { match self {
Self::Type(typename) => typename.assert_supported(), Self::Type(typename) => typename.assert_supported(),
Self::Constant(_) => panic!(AlignmentSpecifier::Constant), Self::Constant(_) => std::panic::panic_any(AlignmentSpecifier::Constant),
} }
} }
} }
@@ -225,7 +227,7 @@ impl AssertSupported for DerivedDeclarator {
Self::Array(array_decl) => array_decl.assert_supported(), Self::Array(array_decl) => array_decl.assert_supported(),
Self::Function(func_decl) => func_decl.assert_supported(), Self::Function(func_decl) => func_decl.assert_supported(),
// Support when K&R function has no parameter // Support when K&R function has no parameter
Self::KRFunction(kr_func_decl) => assert_eq!(true, kr_func_decl.is_empty()), Self::KRFunction(kr_func_decl) => assert!(kr_func_decl.is_empty()),
} }
} }
} }
@@ -513,6 +515,7 @@ impl AssertSupported for SpecifierQualifier {
match self { match self {
Self::TypeSpecifier(type_specifier) => type_specifier.assert_supported(), Self::TypeSpecifier(type_specifier) => type_specifier.assert_supported(),
Self::TypeQualifier(type_qualifier) => type_qualifier.assert_supported(), Self::TypeQualifier(type_qualifier) => type_qualifier.assert_supported(),
Self::Extension(_) => panic!("SpecifierQualifier::Extension"),
} }
} }
} }
@@ -551,14 +554,14 @@ impl AssertSupported for Constant {
impl AssertSupported for Integer { impl AssertSupported for Integer {
fn assert_supported(&self) { fn assert_supported(&self) {
assert_eq!(false, self.suffix.imaginary); assert!(!self.suffix.imaginary);
} }
} }
impl AssertSupported for Float { impl AssertSupported for Float {
fn assert_supported(&self) { fn assert_supported(&self) {
self.suffix.format.assert_supported(); self.suffix.format.assert_supported();
assert_eq!(false, self.suffix.imaginary); assert!(!self.suffix.imaginary);
} }
} }

View File

@@ -12,14 +12,20 @@ use itertools::izip;
use crate::ir::*; use crate::ir::*;
use crate::some_or; use crate::some_or;
/// TODO(document)
#[derive(Debug, PartialEq, Fail)] #[derive(Debug, PartialEq, Fail)]
pub enum DtypeError { pub enum DtypeError {
/// For uncommon error /// For uncommon error
#[fail(display = "{}", message)] #[fail(display = "{}", message)]
Misc { message: String }, Misc {
/// TODO(document)
message: String,
},
} }
/// TODO(document)
pub trait HasDtype { pub trait HasDtype {
/// TODO(document)
fn dtype(&self) -> Dtype; fn dtype(&self) -> Dtype;
} }
@@ -34,40 +40,77 @@ struct BaseDtype {
is_typedef: bool, is_typedef: bool,
} }
/// TODO(document)
#[derive(Debug, PartialEq, Eq, Hash, Clone)] #[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub enum Dtype { pub enum Dtype {
/// TODO(document)
Unit { Unit {
/// TODO(document)
is_const: bool, is_const: bool,
}, },
/// TODO(document)
Int { Int {
/// TODO(document)
width: usize, width: usize,
/// TODO(document)
is_signed: bool, is_signed: bool,
/// TODO(document)
is_const: bool, is_const: bool,
}, },
/// TODO(document)
Float { Float {
/// TODO(document)
width: usize, width: usize,
/// TODO(document)
is_const: bool, is_const: bool,
}, },
/// TODO(document)
Pointer { Pointer {
/// TODO(document)
inner: Box<Dtype>, inner: Box<Dtype>,
/// TODO(document)
is_const: bool, is_const: bool,
}, },
/// TODO(document)
Array { Array {
/// TODO(document)
inner: Box<Dtype>, inner: Box<Dtype>,
/// TODO(document)
size: usize, size: usize,
}, },
/// TODO(document)
Struct { Struct {
/// TODO(document)
name: Option<String>, name: Option<String>,
/// TODO(document)
fields: Option<Vec<Named<Dtype>>>, fields: Option<Vec<Named<Dtype>>>,
/// TODO(document)
is_const: bool, is_const: bool,
/// TODO(document)
size_align_offsets: Option<(usize, usize, Vec<usize>)>, size_align_offsets: Option<(usize, usize, Vec<usize>)>,
}, },
/// TODO(document)
Function { Function {
/// TODO(document)
ret: Box<Dtype>, ret: Box<Dtype>,
/// TODO(document)
params: Vec<Dtype>, params: Vec<Dtype>,
}, },
/// TODO(document)
Typedef { Typedef {
/// TODO(document)
name: String, name: String,
/// TODO(document)
is_const: bool, is_const: bool,
}, },
} }
@@ -201,6 +244,7 @@ impl BaseDtype {
ast::SpecifierQualifier::TypeQualifier(type_qualifier) => { ast::SpecifierQualifier::TypeQualifier(type_qualifier) => {
self.apply_type_qualifier(&type_qualifier.node)? self.apply_type_qualifier(&type_qualifier.node)?
} }
ast::SpecifierQualifier::Extension(_) => panic!("unsupported specifier qualifier"),
} }
Ok(()) Ok(())
@@ -464,40 +508,73 @@ impl TryFrom<&ast::ParameterDeclaration> for Dtype {
} }
impl Dtype { impl Dtype {
/// TODO(document)
pub const BITS_OF_BYTE: usize = 8; pub const BITS_OF_BYTE: usize = 8;
/// TODO(document)
pub const SIZE_OF_BYTE: usize = 1; pub const SIZE_OF_BYTE: usize = 1;
/// TODO(document)
// TODO: consider architecture dependency (current: 64-bit architecture) // TODO: consider architecture dependency (current: 64-bit architecture)
pub const SIZE_OF_POINTER: usize = 8; pub const SIZE_OF_POINTER: usize = 8;
/// TODO(document)
pub const SIZE_OF_CHAR: usize = 1; pub const SIZE_OF_CHAR: usize = 1;
/// TODO(document)
pub const SIZE_OF_SHORT: usize = 2; pub const SIZE_OF_SHORT: usize = 2;
/// TODO(document)
pub const SIZE_OF_INT: usize = 4; pub const SIZE_OF_INT: usize = 4;
/// TODO(document)
pub const SIZE_OF_LONG: usize = 8; pub const SIZE_OF_LONG: usize = 8;
/// TODO(document)
pub const SIZE_OF_LONGLONG: usize = 8; pub const SIZE_OF_LONGLONG: usize = 8;
/// TODO(document)
pub const SIZE_OF_FLOAT: usize = 4; pub const SIZE_OF_FLOAT: usize = 4;
/// TODO(document)
pub const SIZE_OF_DOUBLE: usize = 8; pub const SIZE_OF_DOUBLE: usize = 8;
/// TODO(document)
// signed option cannot be applied to boolean value // signed option cannot be applied to boolean value
pub const BOOL: Self = Self::Int { pub const BOOL: Self = Self::Int {
width: 1, width: 1,
is_signed: false, is_signed: false,
is_const: false, is_const: false,
}; };
/// TODO(document)
pub const CHAR: Self = Self::int(Self::SIZE_OF_CHAR * Self::BITS_OF_BYTE); pub const CHAR: Self = Self::int(Self::SIZE_OF_CHAR * Self::BITS_OF_BYTE);
/// TODO(document)
pub const SHORT: Self = Self::int(Self::SIZE_OF_SHORT * Self::BITS_OF_BYTE); pub const SHORT: Self = Self::int(Self::SIZE_OF_SHORT * Self::BITS_OF_BYTE);
/// TODO(document)
pub const INT: Self = Self::int(Self::SIZE_OF_INT * Self::BITS_OF_BYTE); pub const INT: Self = Self::int(Self::SIZE_OF_INT * Self::BITS_OF_BYTE);
/// TODO(document)
pub const LONG: Self = Self::int(Self::SIZE_OF_LONG * Self::BITS_OF_BYTE); pub const LONG: Self = Self::int(Self::SIZE_OF_LONG * Self::BITS_OF_BYTE);
/// TODO(document)
pub const LONGLONG: Self = Self::int(Self::SIZE_OF_LONGLONG * Self::BITS_OF_BYTE); pub const LONGLONG: Self = Self::int(Self::SIZE_OF_LONGLONG * Self::BITS_OF_BYTE);
/// TODO(document)
pub const FLOAT: Self = Self::float(Self::SIZE_OF_FLOAT * Self::BITS_OF_BYTE); pub const FLOAT: Self = Self::float(Self::SIZE_OF_FLOAT * Self::BITS_OF_BYTE);
/// TODO(document)
pub const DOUBLE: Self = Self::float(Self::SIZE_OF_DOUBLE * Self::BITS_OF_BYTE); pub const DOUBLE: Self = Self::float(Self::SIZE_OF_DOUBLE * Self::BITS_OF_BYTE);
/// TODO(document)
#[inline] #[inline]
pub const fn unit() -> Self { pub const fn unit() -> Self {
Self::Unit { is_const: false } Self::Unit { is_const: false }
} }
/// TODO(document)
#[inline] #[inline]
pub const fn int(width: usize) -> Self { pub const fn int(width: usize) -> Self {
Self::Int { Self::Int {
@@ -507,6 +584,7 @@ impl Dtype {
} }
} }
/// TODO(document)
#[inline] #[inline]
pub const fn float(width: usize) -> Self { pub const fn float(width: usize) -> Self {
Self::Float { Self::Float {
@@ -515,6 +593,7 @@ impl Dtype {
} }
} }
/// TODO(document)
#[inline] #[inline]
pub fn pointer(inner: Dtype) -> Self { pub fn pointer(inner: Dtype) -> Self {
Self::Pointer { Self::Pointer {
@@ -523,9 +602,14 @@ impl Dtype {
} }
} }
// Suppose the C declaration is `int *a[2][3]`. Then `a`'s `ir::Dtype` should be `[2 x [3 x int*]]`. /// TODO(document)
// But in the AST, it is parsed as `Array(3, Array(2, Pointer(int)))`, reversing the order of `2` and `3`. ///
// In the recursive translation of declaration into Dtype, we need to insert `3` inside `[2 * int*]`. /// # Examples
///
/// Suppose the C declaration is `int *a[2][3]`. Then `a`'s `ir::Dtype` should be `[2 x [3 x
/// int*]]`. But in the AST, it is parsed as `Array(3, Array(2, Pointer(int)))`, reversing the
/// order of `2` and `3`. In the recursive translation of declaration into Dtype, we need to
/// insert `3` inside `[2 * int*]`.
pub fn array(base_dtype: Dtype, size: usize) -> Self { pub fn array(base_dtype: Dtype, size: usize) -> Self {
match base_dtype { match base_dtype {
Self::Array { Self::Array {
@@ -547,6 +631,7 @@ impl Dtype {
} }
} }
/// TODO(document)
#[inline] #[inline]
pub fn structure(name: Option<String>, fields: Option<Vec<Named<Self>>>) -> Self { pub fn structure(name: Option<String>, fields: Option<Vec<Named<Self>>>) -> Self {
Self::Struct { Self::Struct {
@@ -1344,7 +1429,7 @@ fn check_no_duplicate_field(fields: &[Named<Dtype>], field_names: &mut HashSet<S
.expect("`field_dtype` must be struct type") .expect("`field_dtype` must be struct type")
.as_ref() .as_ref()
.expect("struct type must have its definition"); .expect("struct type must have its definition");
if !check_no_duplicate_field(&fields, field_names) { if !check_no_duplicate_field(fields, field_names) {
return false; return false;
} }
} }

View File

@@ -4,7 +4,6 @@ use itertools::izip;
use crate::ir::*; use crate::ir::*;
use crate::utils::IsEquiv; use crate::utils::IsEquiv;
use crate::*;
impl IsEquiv for TranslationUnit { impl IsEquiv for TranslationUnit {
fn is_equiv(&self, other: &Self) -> bool { fn is_equiv(&self, other: &Self) -> bool {
@@ -30,7 +29,7 @@ impl IsEquiv for TranslationUnit {
} }
} }
impl IsEquiv for ir::Declaration { impl IsEquiv for Declaration {
fn is_equiv(&self, other: &Self) -> bool { fn is_equiv(&self, other: &Self) -> bool {
match (self, other) { match (self, other) {
( (
@@ -328,7 +327,7 @@ fn is_equiv_arg(lhs: &JumpArg, rhs: &JumpArg, map: &HashMap<BlockId, BlockId>) -
true true
} }
impl IsEquiv for ir::FunctionDefinition { impl IsEquiv for FunctionDefinition {
fn is_equiv(&self, other: &Self) -> bool { fn is_equiv(&self, other: &Self) -> bool {
if self.allocations != other.allocations { if self.allocations != other.allocations {
return false; return false;
@@ -348,7 +347,7 @@ impl IsEquiv for ir::FunctionDefinition {
let mut map = HashMap::new(); let mut map = HashMap::new();
for (f, t) in izip!(&preorder, &preorder_other) { for (f, t) in izip!(&preorder, &preorder_other) {
map.insert(*f, *t); let _ = map.insert(*f, *t);
} }
if map.get(&self.bid_init) != Some(&other.bid_init) { if map.get(&self.bid_init) != Some(&other.bid_init) {

View File

@@ -703,7 +703,7 @@ mod calculator {
let value = (-(value as i128)) as u128; let value = (-(value as i128)) as u128;
trim_unnecessary_bits(value, width as u128) trim_unnecessary_bits(value, width as u128)
}; };
Ok(Value::int(result as u128, width, is_signed)) Ok(Value::int(result, width, is_signed))
} }
ast::UnaryOperator::Negate => { ast::UnaryOperator::Negate => {
// Check if it is boolean // Check if it is boolean
@@ -781,11 +781,11 @@ mod calculator {
if value == 0 { if value == 0 {
Ok(Value::pointer(None, 0, inner.deref().clone())) Ok(Value::pointer(None, 0, inner.deref().clone()))
} else { } else {
panic!(format!( panic!(
"calculate_typecast: not support case \ "calculate_typecast: not support case \
typecast int to pointer when `value` is {}", typecast int to pointer when `value` is {}",
value value
)) )
} }
} }
( (
@@ -1028,7 +1028,7 @@ impl Byte {
let size = value.dtype().size_align_of(structs).unwrap().0; let size = value.dtype().size_align_of(structs).unwrap().0;
let value_bits: u128 = match size { let value_bits: u128 = match size {
Dtype::SIZE_OF_FLOAT => (float_value.into_inner() as f32).to_bits() as u128, Dtype::SIZE_OF_FLOAT => (float_value.into_inner() as f32).to_bits() as u128,
Dtype::SIZE_OF_DOUBLE => (float_value.into_inner() as f64).to_bits() as u128, Dtype::SIZE_OF_DOUBLE => (float_value.into_inner()).to_bits() as u128,
_ => panic!("value_to_bytes: {} is not a valid float size", size), _ => panic!("value_to_bytes: {} is not a valid float size", size),
}; };
@@ -1073,7 +1073,7 @@ impl Byte {
izip!(fields, offsets).for_each(|(f, o)| { izip!(fields, offsets).for_each(|(f, o)| {
let result = Self::value_to_bytes(f.deref(), structs); let result = Self::value_to_bytes(f.deref(), structs);
let size_of_data = f.deref().dtype().size_align_of(structs).unwrap().0; let size_of_data = f.deref().dtype().size_align_of(structs).unwrap().0;
values.splice(*o..(*o + size_of_data), result.iter().cloned()); let _ = values.splice(*o..(*o + size_of_data), result.iter().cloned());
}); });
values values
@@ -1143,7 +1143,7 @@ impl Memory {
let block = self.inner[bid].as_mut().unwrap(); let block = self.inner[bid].as_mut().unwrap();
if 0 <= offset && end <= block.len() { if 0 <= offset && end <= block.len() {
block.splice(offset as usize..end, bytes.iter().cloned()); let _ = block.splice(offset as usize..end, bytes.iter().cloned());
Ok(()) Ok(())
} else { } else {
Err(()) Err(())
@@ -1163,16 +1163,16 @@ struct State<'i> {
} }
impl<'i> State<'i> { impl<'i> State<'i> {
fn new(ir: &'i TranslationUnit, args: Vec<Value>) -> Result<State, InterpreterError> { fn new(ir: &'i TranslationUnit, args: Vec<Value>) -> Result<State<'_>, InterpreterError> {
// Interpreter starts with the main function // Interpreter starts with the main function
let func_name = String::from("main"); let func_name = String::from("main");
let func = ir let func = ir
.decls .decls
.get(&func_name) .get(&func_name)
.ok_or_else(|| InterpreterError::NoMainFunction)?; .ok_or(InterpreterError::NoMainFunction)?;
let (_, func_def) = func let (_, func_def) = func
.get_function() .get_function()
.ok_or_else(|| InterpreterError::NoMainFunction)?; .ok_or(InterpreterError::NoMainFunction)?;
let func_def = func_def let func_def = func_def
.as_ref() .as_ref()
.ok_or_else(|| InterpreterError::NoFunctionDefinition { .ok_or_else(|| InterpreterError::NoFunctionDefinition {
@@ -1218,7 +1218,7 @@ impl<'i> State<'i> {
}, },
)? )?
} else { } else {
Value::default_from_dtype(&dtype, &self.ir.structs) Value::default_from_dtype(dtype, &self.ir.structs)
.expect("default value must be derived from `dtype`") .expect("default value must be derived from `dtype`")
}; };
@@ -1244,7 +1244,7 @@ impl<'i> State<'i> {
fn alloc_local_variables(&mut self) -> Result<(), InterpreterError> { fn alloc_local_variables(&mut self) -> Result<(), InterpreterError> {
// add alloc register // add alloc register
for (id, allocation) in self.stack_frame.func_def.allocations.iter().enumerate() { for (id, allocation) in self.stack_frame.func_def.allocations.iter().enumerate() {
let bid = self.memory.alloc(&allocation, &self.ir.structs)?; let bid = self.memory.alloc(allocation, &self.ir.structs)?;
let ptr = Value::pointer(Some(bid), 0, allocation.deref().clone()); let ptr = Value::pointer(Some(bid), 0, allocation.deref().clone());
let rid = RegisterId::local(id); let rid = RegisterId::local(id);
@@ -1407,7 +1407,7 @@ impl<'i> State<'i> {
let lhs = self.interp_operand(lhs.clone())?; let lhs = self.interp_operand(lhs.clone())?;
let rhs = self.interp_operand(rhs.clone())?; let rhs = self.interp_operand(rhs.clone())?;
calculator::calculate_binary_operator_expression(&op, lhs, rhs).map_err(|_| { calculator::calculate_binary_operator_expression(op, lhs, rhs).map_err(|_| {
InterpreterError::Misc { InterpreterError::Misc {
func_name: self.stack_frame.func_name.clone(), func_name: self.stack_frame.func_name.clone(),
pc: self.stack_frame.pc, pc: self.stack_frame.pc,
@@ -1418,7 +1418,7 @@ impl<'i> State<'i> {
Instruction::UnaryOp { op, operand, .. } => { Instruction::UnaryOp { op, operand, .. } => {
let operand = self.interp_operand(operand.clone())?; let operand = self.interp_operand(operand.clone())?;
calculator::calculate_unary_operator_expression(&op, operand).map_err(|_| { calculator::calculate_unary_operator_expression(op, operand).map_err(|_| {
InterpreterError::Misc { InterpreterError::Misc {
func_name: self.stack_frame.func_name.clone(), func_name: self.stack_frame.func_name.clone(),
pc: self.stack_frame.pc, pc: self.stack_frame.pc,
@@ -1517,7 +1517,7 @@ impl<'i> State<'i> {
let offset = prev_offset + value as isize; let offset = prev_offset + value as isize;
assert!(0 <= offset); assert!(0 <= offset);
Value::pointer(*bid, offset as isize, inner_dtype.clone()) Value::pointer(*bid, offset, inner_dtype.clone())
} }
}; };

View File

@@ -1,6 +1,9 @@
//! The intermediate representation.
mod dtype; mod dtype;
mod equiv; mod equiv;
mod interp; mod interp;
#[allow(clippy::all)]
mod parse; mod parse;
mod write_ir; mod write_ir;
@@ -247,11 +250,7 @@ impl HasDtype for Instruction {
impl Instruction { impl Instruction {
pub fn is_pure(&self) -> bool { pub fn is_pure(&self) -> bool {
match self { !matches!(self, Self::Store { .. } | Self::Call { .. })
Self::Store { .. } => false,
Self::Call { .. } => false,
_ => true,
}
} }
} }
@@ -526,6 +525,7 @@ impl TryFrom<&ast::Constant> for Constant {
ast::IntegerBase::Decimal => Self::DECIMAL, ast::IntegerBase::Decimal => Self::DECIMAL,
ast::IntegerBase::Octal => Self::OCTAL, ast::IntegerBase::Octal => Self::OCTAL,
ast::IntegerBase::Hexadecimal => Self::HEXADECIMAL, ast::IntegerBase::Hexadecimal => Self::HEXADECIMAL,
ast::IntegerBase::Binary => Self::BINARY,
}; };
let value = if integer.suffix.unsigned { let value = if integer.suffix.unsigned {
@@ -636,14 +636,11 @@ impl Constant {
const DECIMAL: u32 = 10; const DECIMAL: u32 = 10;
const OCTAL: u32 = 8; const OCTAL: u32 = 8;
const HEXADECIMAL: u32 = 16; const HEXADECIMAL: u32 = 16;
const BINARY: u32 = 2;
#[inline] #[inline]
pub fn is_integer_constant(&self) -> bool { pub fn is_integer_constant(&self) -> bool {
if let Self::Int { .. } = self { matches!(self, Self::Int { .. })
true
} else {
false
}
} }
#[inline] #[inline]
@@ -730,17 +727,13 @@ impl Constant {
} }
_ => panic!( _ => panic!(
"constant value generated by `Constant::from_ast_expression` \ "constant value generated by `Constant::from_ast_expression` \
must be `Constant{{Int, Float}}`" must be `Constant(Int, Float)`"
), ),
} }
} }
pub fn is_undef(&self) -> bool { pub fn is_undef(&self) -> bool {
if let Self::Undef { .. } = self { matches!(self, Self::Undef { .. })
true
} else {
false
}
} }
pub fn typecast(self, target_dtype: Dtype) -> Self { pub fn typecast(self, target_dtype: Dtype) -> Self {

View File

@@ -660,7 +660,7 @@ pub enum Error {
ResolveError, ResolveError,
} }
#[derive(Default)] #[derive(Default, Debug)]
pub struct Parse {} pub struct Parse {}
impl<P: AsRef<Path>> Translate<P> for Parse { impl<P: AsRef<Path>> Translate<P> for Parse {

View File

@@ -1,9 +1,44 @@
//! KECC: KAIST Educational C Compiler.
// Tries to deny all lints (`rustc -W help`).
#![deny(warnings)] #![deny(warnings)]
// Neccessary for skeleton code. #![deny(absolute_paths_not_starting_with_crate)]
#![deny(anonymous_parameters)]
// #![deny(box_pointers)]
#![deny(deprecated_in_future)]
#![deny(elided_lifetimes_in_paths)]
#![deny(explicit_outlives_requirements)]
#![deny(invalid_html_tags)]
#![deny(keyword_idents)]
#![deny(macro_use_extern_crate)]
#![deny(missing_debug_implementations)]
// #![deny(missing_docs)] TODO
#![deny(missing_doc_code_examples)]
#![deny(non_ascii_idents)]
#![deny(pointer_structural_match)]
// #![deny(single_use_lifetimes)]
#![deny(trivial_numeric_casts)]
#![deny(unaligned_references)]
// #![deny(unreachable_pub)]
#![deny(unstable_features)]
// Necessary for `build-bin` trick.
// #![deny(unused_crate_dependencies)]
#![deny(unused_extern_crates)]
#![deny(unused_import_braces)]
#![deny(unused_lifetimes)]
#![deny(unused_qualifications)]
#![deny(unused_results)]
// #![deny(variant_size_differences)]
#![deny(rust_2018_idioms)]
#![deny(rustdoc::all)]
// Necessary for skeleton code.
#![allow(unreachable_code)] #![allow(unreachable_code)]
// Necessary to allow `iter.fold(false, |l, r| l || r)`. It's used when iteration should not be // Necessary to allow `iter.fold(false, |l, r| l || r)`. It's used when iteration should not be
// short-circuited. // short-circuited.
#![allow(clippy::unnecessary_fold)] #![allow(clippy::unnecessary_fold)]
#![allow(clippy::result_unit_err)]
#![allow(clippy::vec_init_then_push)]
#![allow(clippy::collapsible_match)]
mod tests; mod tests;
mod utils; mod utils;

View File

@@ -22,15 +22,15 @@ pub trait Optimize<T> {
pub type O0 = Null; pub type O0 = Null;
pub type O1 = Repeat<(SimplifyCfg, (Mem2reg, (Gvn, Deadcode)))>; pub type O1 = Repeat<(SimplifyCfg, (Mem2reg, (Gvn, Deadcode)))>;
#[derive(Default)] #[derive(Default, Debug)]
pub struct Null {} pub struct Null {}
#[derive(Default)] #[derive(Default, Debug)]
pub struct Repeat<O> { pub struct Repeat<O> {
inner: O, inner: O,
} }
#[derive(Default)] #[derive(Default, Debug)]
pub struct FunctionPass<T: Optimize<ir::FunctionDefinition>> { pub struct FunctionPass<T: Optimize<ir::FunctionDefinition>> {
inner: T, inner: T,
} }

View File

@@ -14,7 +14,8 @@ const NONCE_NAME: &str = "nonce";
fn modify_c(path: &Path, rand_num: i32) -> String { fn modify_c(path: &Path, rand_num: i32) -> String {
let mut src = File::open(path).expect("`path` must exist"); let mut src = File::open(path).expect("`path` must exist");
let mut data = String::new(); let mut data = String::new();
src.read_to_string(&mut data) let _ = src
.read_to_string(&mut data)
.expect("`src` must be converted to string"); .expect("`src` must be converted to string");
drop(src); drop(src);
@@ -69,8 +70,9 @@ fn modify_asm(unit: &mut asm::Asm, rand_num: i32) {
// Rust sets an exit code of 101 when the process panicked. // Rust sets an exit code of 101 when the process panicked.
// So, we decide KECC sets an exit code of 102 after 101 when the test skipped. // So, we decide KECC sets an exit code of 102 after 101 when the test skipped.
pub const SKIP_TEST: i32 = 102; const SKIP_TEST: i32 = 102;
/// Tests write_c.
pub fn test_write_c(path: &Path) { pub fn test_write_c(path: &Path) {
// Check if the file has .c extension // Check if the file has .c extension
assert_eq!(path.extension(), Some(std::ffi::OsStr::new("c"))); assert_eq!(path.extension(), Some(std::ffi::OsStr::new("c")));
@@ -82,7 +84,7 @@ pub fn test_write_c(path: &Path) {
let temp_file_path = temp_dir.path().join("temp.c"); let temp_file_path = temp_dir.path().join("temp.c");
let mut temp_file = File::create(&temp_file_path).unwrap(); let mut temp_file = File::create(&temp_file_path).unwrap();
crate::write(&unit, &mut temp_file).unwrap(); write(&unit, &mut temp_file).unwrap();
let new_unit = c::Parse::default() let new_unit = c::Parse::default()
.translate(&temp_file_path.as_path()) .translate(&temp_file_path.as_path())
@@ -92,6 +94,7 @@ pub fn test_write_c(path: &Path) {
temp_dir.close().expect("temp dir deletion failed"); temp_dir.close().expect("temp dir deletion failed");
} }
/// Tests irgen.
pub fn test_irgen(path: &Path) { pub fn test_irgen(path: &Path) {
// Check if the file has .c extension // Check if the file has .c extension
assert_eq!(path.extension(), Some(std::ffi::OsStr::new("c"))); assert_eq!(path.extension(), Some(std::ffi::OsStr::new("c")));
@@ -103,7 +106,7 @@ pub fn test_irgen(path: &Path) {
.translate(&unit) .translate(&unit)
.unwrap_or_else(|irgen_error| panic!("{}", irgen_error)); .unwrap_or_else(|irgen_error| panic!("{}", irgen_error));
let rand_num = rand::thread_rng().gen_range(1, 100); let rand_num = rand::thread_rng().gen_range(1..100);
let new_c = modify_c(path, rand_num); let new_c = modify_c(path, rand_num);
modify_ir(&mut ir, rand_num); modify_ir(&mut ir, rand_num);
@@ -151,7 +154,7 @@ pub fn test_irgen(path: &Path) {
{ {
println!("timeout occurs"); println!("timeout occurs");
child.kill().unwrap(); child.kill().unwrap();
child.wait().unwrap(); let _ = child.wait().unwrap();
::std::process::exit(SKIP_TEST); ::std::process::exit(SKIP_TEST);
} }
); );
@@ -187,6 +190,7 @@ pub fn test_irgen(path: &Path) {
assert_eq!(status as u8, value as u8); assert_eq!(status as u8, value as u8);
} }
/// Tests irparse.
pub fn test_irparse(path: &Path) { pub fn test_irparse(path: &Path) {
// Check if the file has .c extension // Check if the file has .c extension
assert_eq!(path.extension(), Some(std::ffi::OsStr::new("c"))); assert_eq!(path.extension(), Some(std::ffi::OsStr::new("c")));
@@ -195,7 +199,7 @@ pub fn test_irparse(path: &Path) {
.unwrap_or_else(|_| panic!("parse failed {}", path.display())); .unwrap_or_else(|_| panic!("parse failed {}", path.display()));
// Test parse // Test parse
c::Parse::default() let _ = c::Parse::default()
.translate(&path) .translate(&path)
.expect("failed to parse the given program"); .expect("failed to parse the given program");
@@ -207,7 +211,7 @@ pub fn test_irparse(path: &Path) {
.unwrap_or_else(|irgen_error| panic!("{}", irgen_error)); .unwrap_or_else(|irgen_error| panic!("{}", irgen_error));
let temp_file_path = temp_dir.path().join("ir0.ir"); let temp_file_path = temp_dir.path().join("ir0.ir");
let mut temp_file = File::create(&temp_file_path).unwrap(); let mut temp_file = File::create(&temp_file_path).unwrap();
crate::write(&ir, &mut temp_file).unwrap(); write(&ir, &mut temp_file).unwrap();
let ir0 = ir::Parse::default() let ir0 = ir::Parse::default()
.translate(&temp_file_path.as_path()) .translate(&temp_file_path.as_path())
@@ -233,9 +237,9 @@ fn test_irparse_for_optimized_ir<O: Optimize<ir::TranslationUnit>>(
temp_file_path: &Path, temp_file_path: &Path,
mut opt: O, mut opt: O,
) -> ir::TranslationUnit { ) -> ir::TranslationUnit {
opt.optimize(&mut ir); let _ = opt.optimize(&mut ir);
let mut temp_file = File::create(temp_file_path).unwrap(); let mut temp_file = File::create(temp_file_path).unwrap();
crate::write(&ir, &mut temp_file).unwrap(); write(&ir, &mut temp_file).unwrap();
let optimized_ir = ir::Parse::default() let optimized_ir = ir::Parse::default()
.translate(&temp_file_path) .translate(&temp_file_path)
@@ -246,6 +250,7 @@ fn test_irparse_for_optimized_ir<O: Optimize<ir::TranslationUnit>>(
optimized_ir optimized_ir
} }
/// Tests optimizations.
pub fn test_opt<P1: AsRef<Path>, P2: AsRef<Path>, O: Optimize<ir::TranslationUnit>>( pub fn test_opt<P1: AsRef<Path>, P2: AsRef<Path>, O: Optimize<ir::TranslationUnit>>(
from: &P1, from: &P1,
to: &P2, to: &P2,
@@ -258,7 +263,7 @@ pub fn test_opt<P1: AsRef<Path>, P2: AsRef<Path>, O: Optimize<ir::TranslationUni
let to = ir::Parse::default() let to = ir::Parse::default()
.translate(to) .translate(to)
.expect("parse failed while parsing the output from implemented printer"); .expect("parse failed while parsing the output from implemented printer");
opt.optimize(&mut ir); let _ = opt.optimize(&mut ir);
if !ir.is_equiv(&to) { if !ir.is_equiv(&to) {
stderr() stderr()
@@ -267,21 +272,22 @@ pub fn test_opt<P1: AsRef<Path>, P2: AsRef<Path>, O: Optimize<ir::TranslationUni
"[test_opt] actual outcome mismatches with the expected outcome.\n\n[before opt]" "[test_opt] actual outcome mismatches with the expected outcome.\n\n[before opt]"
)) ))
.unwrap(); .unwrap();
crate::write(&from, &mut stderr()).unwrap(); write(&from, &mut stderr()).unwrap();
stderr() stderr()
.lock() .lock()
.write_fmt(format_args!("\n[after opt]")) .write_fmt(format_args!("\n[after opt]"))
.unwrap(); .unwrap();
crate::write(&ir, &mut stderr()).unwrap(); write(&ir, &mut stderr()).unwrap();
stderr() stderr()
.lock() .lock()
.write_fmt(format_args!("\n[after opt (expected)]")) .write_fmt(format_args!("\n[after opt (expected)]"))
.unwrap(); .unwrap();
crate::write(&to, &mut stderr()).unwrap(); write(&to, &mut stderr()).unwrap();
panic!("[test_opt]"); panic!("[test_opt]");
} }
} }
/// Tests asmgen.
pub fn test_asmgen(path: &Path) { pub fn test_asmgen(path: &Path) {
// Check if the file has .ir extension // Check if the file has .ir extension
assert_eq!(path.extension(), Some(std::ffi::OsStr::new("ir"))); assert_eq!(path.extension(), Some(std::ffi::OsStr::new("ir")));
@@ -294,7 +300,7 @@ pub fn test_asmgen(path: &Path) {
.translate(&ir) .translate(&ir)
.expect("fail to create riscv assembly code"); .expect("fail to create riscv assembly code");
let rand_num = rand::thread_rng().gen_range(1, 100); let rand_num = rand::thread_rng().gen_range(1..100);
modify_ir(&mut ir, rand_num); modify_ir(&mut ir, rand_num);
modify_asm(&mut asm, rand_num); modify_asm(&mut asm, rand_num);
@@ -320,7 +326,7 @@ pub fn test_asmgen(path: &Path) {
write(&asm, &mut buffer).unwrap(); write(&asm, &mut buffer).unwrap();
// Compile the assembly code // Compile the assembly code
if !Command::new("riscv64-linux-gnu-gcc-10") if !Command::new("riscv64-linux-gnu-gcc")
.args(&["-static", &asm_path_str, "-o", &bin_path_str]) .args(&["-static", &asm_path_str, "-o", &bin_path_str])
.stderr(Stdio::null()) .stderr(Stdio::null())
.status() .status()
@@ -344,7 +350,7 @@ pub fn test_asmgen(path: &Path) {
{ {
println!("timeout occurs"); println!("timeout occurs");
child.kill().unwrap(); child.kill().unwrap();
child.wait().unwrap(); let _ = child.wait().unwrap();
::std::process::exit(SKIP_TEST); ::std::process::exit(SKIP_TEST);
} }
); );
@@ -368,6 +374,7 @@ pub fn test_asmgen(path: &Path) {
assert_eq!(value as u8, qemu_status as u8); assert_eq!(value as u8, qemu_status as u8);
} }
/// Tests end-to-end translation.
// TODO: test all the way down to assembly // TODO: test all the way down to assembly
pub fn test_end_to_end(path: &Path) { pub fn test_end_to_end(path: &Path) {
// Check if the file has .c extension // Check if the file has .c extension
@@ -377,7 +384,7 @@ pub fn test_end_to_end(path: &Path) {
.unwrap_or_else(|_| panic!("parse failed {}", path.display())); .unwrap_or_else(|_| panic!("parse failed {}", path.display()));
// Test parse // Test parse
c::Parse::default() let _ = c::Parse::default()
.translate(&path) .translate(&path)
.expect("failed to parse the given program"); .expect("failed to parse the given program");
@@ -412,7 +419,7 @@ pub fn test_end_to_end(path: &Path) {
.spawn() .spawn()
.expect("failed to execute the compiled executable"); .expect("failed to execute the compiled executable");
Command::new("rm") let _ = Command::new("rm")
.arg(bin_path) .arg(bin_path)
.status() .status()
.expect("failed to remove compiled executable"); .expect("failed to remove compiled executable");
@@ -424,7 +431,7 @@ pub fn test_end_to_end(path: &Path) {
{ {
println!("timeout occurs"); println!("timeout occurs");
child.kill().unwrap(); child.kill().unwrap();
child.wait().unwrap(); let _ = child.wait().unwrap();
::std::process::exit(SKIP_TEST); ::std::process::exit(SKIP_TEST);
} }
); );
@@ -445,7 +452,7 @@ pub fn test_end_to_end(path: &Path) {
let mut ir = Irgen::default() let mut ir = Irgen::default()
.translate(&unit) .translate(&unit)
.unwrap_or_else(|irgen_error| panic!("{}", irgen_error)); .unwrap_or_else(|irgen_error| panic!("{}", irgen_error));
O1::default().optimize(&mut ir); let _ = O1::default().optimize(&mut ir);
let args = Vec::new(); let args = Vec::new();
let result = ir::interp(&ir, args).unwrap_or_else(|interp_error| panic!("{}", interp_error)); let result = ir::interp(&ir, args).unwrap_or_else(|interp_error| panic!("{}", interp_error));
// We only allow main function whose return type is `int` // We only allow main function whose return type is `int`

View File

@@ -49,18 +49,27 @@ macro_rules! some_or_exit {
}}; }};
} }
/// TODO(document)
pub trait Translate<S> { pub trait Translate<S> {
/// TODO(document)
type Target; type Target;
/// TODO(document)
type Error; type Error;
/// TODO(document)
fn translate(&mut self, source: &S) -> Result<Self::Target, Self::Error>; fn translate(&mut self, source: &S) -> Result<Self::Target, Self::Error>;
} }
/// TODO(document)
pub trait AssertSupported { pub trait AssertSupported {
/// TODO(document)
fn assert_supported(&self); fn assert_supported(&self);
} }
/// TODO(document)
pub trait IsEquiv { pub trait IsEquiv {
/// TODO(document)
fn is_equiv(&self, other: &Self) -> bool; fn is_equiv(&self, other: &Self) -> bool;
} }

View File

@@ -1,22 +1,30 @@
use std::io::{Result, Write}; use std::io::{Result, Write};
/// TODO(document)
#[inline] #[inline]
pub fn write_indent(indent: usize, write: &mut dyn Write) -> Result<()> { pub fn write_indent(indent: usize, write: &mut dyn Write) -> Result<()> {
write!(write, "{}", " ".repeat(indent)) write!(write, "{}", " ".repeat(indent))
} }
/// TODO(document)
pub trait WriteLine { pub trait WriteLine {
/// TODO(document)
fn write_line(&self, indent: usize, write: &mut dyn Write) -> Result<()>; fn write_line(&self, indent: usize, write: &mut dyn Write) -> Result<()>;
} }
/// TODO(document)
pub trait WriteString { pub trait WriteString {
/// TODO(document)
fn write_string(&self) -> String; fn write_string(&self) -> String;
} }
/// TODO(document)
pub trait WriteOp { pub trait WriteOp {
/// TODO(document)
fn write_operation(&self) -> String; fn write_operation(&self) -> String;
} }
/// TODO(document)
pub fn write<T: WriteLine>(t: &T, write: &mut dyn Write) -> Result<()> { pub fn write<T: WriteLine>(t: &T, write: &mut dyn Write) -> Result<()> {
t.write_line(0, write) t.write_line(0, write)
} }

View File

@@ -224,7 +224,7 @@ def fuzz(tests_dir, fuzz_arg, num_iter):
dst.write(src_polished) dst.write(src_polished)
try: try:
args = ["cargo", "run", "--release", "--bin", "fuzz", "--", fuzz_arg, os.path.join(tests_dir, "test_polished.c")] args = ["cargo", "run", "--features=build-bin", "--release", "--bin", "fuzz", "--", fuzz_arg, os.path.join(tests_dir, "test_polished.c")]
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=tests_dir) proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=tests_dir)
proc.communicate(timeout=60) proc.communicate(timeout=60)