mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-14 22:38:46 +00:00
Update
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
# 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
|
||||
- deploy
|
||||
|
||||
install:
|
||||
stage: install
|
||||
script:
|
||||
- rustc --version # triggering installation
|
||||
|
||||
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:
|
||||
- (echo 'Acquire::http { Proxy "http://10.22.0.2:3142"; }' | tee -a /etc/apt/apt.conf.d/01proxy) && apt update && apt install -yy clang gcc-riscv64-linux-gnu g++-riscv64-linux-gnu qemu-user-static
|
||||
script:
|
||||
- RUST_MIN_STACK=8388608 cargo test -- --nocapture
|
||||
|
||||
release:
|
||||
stage: test
|
||||
before_script:
|
||||
- (echo 'Acquire::http { Proxy "http://10.22.0.2:3142"; }' | tee -a /etc/apt/apt.conf.d/01proxy) && apt update && apt install -yy clang gcc-riscv64-linux-gnu g++-riscv64-linux-gnu qemu-user-static
|
||||
script:
|
||||
- RUST_MIN_STACK=8388608 cargo test --release -- --nocapture
|
||||
|
||||
pages:
|
||||
stage: deploy
|
||||
before_script:
|
||||
# - apt update && apt install -yy
|
||||
script:
|
||||
- cargo doc
|
||||
- mkdir -p public && cp -r target/doc/* public
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
|
||||
304
Cargo.lock
generated
304
Cargo.lock
generated
@@ -1,12 +1,12 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.14"
|
||||
version = "0.6.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b"
|
||||
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
@@ -19,49 +19,55 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.4"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
|
||||
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.3"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
|
||||
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.0.2"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
|
||||
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.1"
|
||||
version = "3.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628"
|
||||
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys 0.48.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.1"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
@@ -71,9 +77,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.4"
|
||||
version = "4.5.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0"
|
||||
checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@@ -81,9 +87,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.2"
|
||||
version = "4.5.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4"
|
||||
checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@@ -93,9 +99,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.4"
|
||||
version = "4.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64"
|
||||
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
@@ -105,43 +111,43 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.0"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
|
||||
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.0"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.9.0"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.8"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
|
||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.0.1"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
|
||||
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.9"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4"
|
||||
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
@@ -162,15 +168,15 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.0"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.12.1"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
||||
checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
@@ -199,39 +205,45 @@ checksum = "720e6492b795d1f6838eb2e51879ec3073be745a20e52c32a241b80b3c8ed998"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.154"
|
||||
version = "0.2.169"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
|
||||
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.13"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
|
||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.17"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-float"
|
||||
version = "4.2.0"
|
||||
name = "once_cell"
|
||||
version = "1.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "ordered-float"
|
||||
version = "4.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "peg"
|
||||
version = "0.8.3"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a625d12ad770914cbf7eff6f9314c3ef803bfe364a1b20bc36ddf56673e71e5"
|
||||
checksum = "295283b02df346d1ef66052a757869b2876ac29a6bb0ac3f5f7cd44aebe40e8f"
|
||||
dependencies = [
|
||||
"peg-macros",
|
||||
"peg-runtime",
|
||||
@@ -239,9 +251,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "peg-macros"
|
||||
version = "0.8.3"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f241d42067ed3ab6a4fece1db720838e1418f36d868585a27931f95d6bc03582"
|
||||
checksum = "bdad6a1d9cf116a059582ce415d5f5566aabcd4008646779dab7fdc2a9a9d426"
|
||||
dependencies = [
|
||||
"peg-runtime",
|
||||
"proc-macro2",
|
||||
@@ -256,24 +268,27 @@ checksum = "e3aeb8f54c078314c2065ee649a7241f46b9d8e418e1a9581ba0546657d7aa3a"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.17"
|
||||
version = "0.2.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
|
||||
dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.82"
|
||||
version = "1.0.92"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b"
|
||||
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.36"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@@ -310,15 +325,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.34"
|
||||
version = "0.38.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
|
||||
checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -329,9 +344,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.61"
|
||||
version = "2.0.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9"
|
||||
checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -340,30 +355,32 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.10.1"
|
||||
version = "3.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
|
||||
checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.60"
|
||||
version = "2.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18"
|
||||
checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.60"
|
||||
version = "2.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524"
|
||||
checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -372,15 +389,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "wait-timeout"
|
||||
@@ -399,139 +416,94 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.5",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.5"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.48.5",
|
||||
"windows_aarch64_msvc 0.48.5",
|
||||
"windows_i686_gnu 0.48.5",
|
||||
"windows_i686_msvc 0.48.5",
|
||||
"windows_x86_64_gnu 0.48.5",
|
||||
"windows_x86_64_gnullvm 0.48.5",
|
||||
"windows_x86_64_msvc 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.52.5",
|
||||
"windows_aarch64_msvc 0.52.5",
|
||||
"windows_i686_gnu 0.52.5",
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc 0.52.5",
|
||||
"windows_x86_64_gnu 0.52.5",
|
||||
"windows_x86_64_gnullvm 0.52.5",
|
||||
"windows_x86_64_msvc 0.52.5",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.5"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.5"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.5"
|
||||
name = "zerocopy"
|
||||
version = "0.7.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
||||
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.7.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
17
Cargo.toml
17
Cargo.toml
@@ -1,7 +1,10 @@
|
||||
[package]
|
||||
name = "kecc"
|
||||
version = "0.1.0"
|
||||
authors = ["Chunmyong Park <chunmyong.park@kaist.ac.kr>", "Jeehoon Kang <jeehoon.kang@kaist.ac.kr>"]
|
||||
authors = [
|
||||
"Chunmyong Park <chunmyong.park@kaist.ac.kr>",
|
||||
"Jeehoon Kang <jeehoon.kang@kaist.ac.kr>",
|
||||
]
|
||||
edition = "2021"
|
||||
default-run = "kecc"
|
||||
|
||||
@@ -29,13 +32,13 @@ required-features = ["build-bin"]
|
||||
build-bin = ["clap"]
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.4", features = ["derive"], optional = true }
|
||||
thiserror = "1.0.60"
|
||||
clap = { version = "4.5.23", features = ["derive"], optional = true }
|
||||
thiserror = "2.0.9"
|
||||
lang-c = "0.15.1"
|
||||
itertools = "0.12.1"
|
||||
tempfile = "3.10.1"
|
||||
ordered-float = "4.2.0"
|
||||
itertools = "0.14.0"
|
||||
tempfile = "3.14.0"
|
||||
ordered-float = "4.6.0"
|
||||
hexf-parse = "0.2.1"
|
||||
wait-timeout = "0.2.0"
|
||||
peg = "0.8.3"
|
||||
peg = "0.8.4"
|
||||
rand = "0.8.5"
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
1.78.0
|
||||
3
rust-toolchain.toml
Normal file
3
rust-toolchain.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "1.83.0"
|
||||
components = ["rustfmt", "clippy", "rust-analyzer"]
|
||||
@@ -1,12 +1,11 @@
|
||||
mod write_asm;
|
||||
|
||||
use crate::ir;
|
||||
use crate::write_base::*;
|
||||
|
||||
use core::convert::TryFrom;
|
||||
use core::fmt;
|
||||
|
||||
/// TODO
|
||||
/// An assembly file.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Asm {
|
||||
pub unit: TranslationUnit,
|
||||
@@ -20,9 +19,9 @@ pub struct TranslationUnit {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Section<T> {
|
||||
/// Section Headers provide size, offset, type, alignment and flags of the sections
|
||||
/// Headers provide size, offset, type, alignment and flag information.
|
||||
///
|
||||
/// For more details: <https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#section-header>
|
||||
/// For more information: <https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#section-header>
|
||||
pub header: Vec<Directive>,
|
||||
pub body: T,
|
||||
}
|
||||
@@ -30,7 +29,7 @@ pub struct Section<T> {
|
||||
/// An object file is made up of multiple sections, with each section corresponding to distinct
|
||||
/// types of executable code or data.
|
||||
///
|
||||
/// For more details: <https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#sections>
|
||||
/// For more information: <https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#sections>
|
||||
impl<T> Section<T> {
|
||||
pub fn new(header: Vec<Directive>, body: T) -> Self {
|
||||
Self { header, body }
|
||||
@@ -174,38 +173,29 @@ impl fmt::Display for SymbolType {
|
||||
}
|
||||
}
|
||||
|
||||
/// RISC-V Base Instructions Set.
|
||||
///
|
||||
/// See Volume 1 of [RISC-V Technical Specifications](https://lf-riscv.atlassian.net/wiki/spaces/HOME/pages/16154769/RISC-V+Technical+Specifications).
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Instruction {
|
||||
/// R-type instruction format
|
||||
///
|
||||
/// For more details: <https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (104p)
|
||||
RType {
|
||||
instr: RType,
|
||||
rd: Register,
|
||||
rs1: Register,
|
||||
rs2: Option<Register>,
|
||||
},
|
||||
/// I-type instruction format
|
||||
///
|
||||
/// For more details: <https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (104p)
|
||||
IType {
|
||||
instr: IType,
|
||||
rd: Register,
|
||||
rs1: Register,
|
||||
imm: Immediate,
|
||||
},
|
||||
/// S-type instruction format
|
||||
///
|
||||
/// For more details: <https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (104p)
|
||||
SType {
|
||||
instr: SType,
|
||||
rs1: Register,
|
||||
rs2: Register,
|
||||
imm: Immediate,
|
||||
},
|
||||
/// B-type instruction format
|
||||
///
|
||||
/// For more details: <https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (104p)
|
||||
BType {
|
||||
instr: BType,
|
||||
rs1: Register,
|
||||
@@ -280,8 +270,7 @@ impl fmt::Display for Instruction {
|
||||
}
|
||||
}
|
||||
|
||||
/// If the enum variant contains `bool`,
|
||||
/// It means that different instructions exist
|
||||
/// If the enum variant contains `is_signed : bool`, it corresponds to different instructions
|
||||
/// depending on whether the operand is signed or not.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum RType {
|
||||
@@ -512,13 +501,20 @@ impl RType {
|
||||
|
||||
impl fmt::Display for RType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let filter_word = |data_size: &DataSize| -> String {
|
||||
if data_size.is_word() {
|
||||
data_size.to_string()
|
||||
} else {
|
||||
"".to_string()
|
||||
}
|
||||
};
|
||||
match self {
|
||||
Self::Add(data_size) => write!(f, "add{}", data_size.word().write_string()),
|
||||
Self::Sub(data_size) => write!(f, "sub{}", data_size.word().write_string()),
|
||||
Self::Sll(data_size) => write!(f, "sll{}", data_size.word().write_string()),
|
||||
Self::Srl(data_size) => write!(f, "srl{}", data_size.word().write_string()),
|
||||
Self::Sra(data_size) => write!(f, "sra{}", data_size.word().write_string()),
|
||||
Self::Mul(data_size) => write!(f, "mul{}", data_size.word().write_string()),
|
||||
Self::Add(data_size) => write!(f, "add{}", filter_word(data_size)),
|
||||
Self::Sub(data_size) => write!(f, "sub{}", filter_word(data_size)),
|
||||
Self::Sll(data_size) => write!(f, "sll{}", filter_word(data_size)),
|
||||
Self::Srl(data_size) => write!(f, "srl{}", filter_word(data_size)),
|
||||
Self::Sra(data_size) => write!(f, "sra{}", filter_word(data_size)),
|
||||
Self::Mul(data_size) => write!(f, "mul{}", filter_word(data_size)),
|
||||
Self::Div {
|
||||
data_size,
|
||||
is_signed,
|
||||
@@ -526,7 +522,7 @@ impl fmt::Display for RType {
|
||||
f,
|
||||
"div{}{}",
|
||||
if *is_signed { "" } else { "u" },
|
||||
data_size.word().write_string()
|
||||
filter_word(data_size)
|
||||
),
|
||||
Self::Rem {
|
||||
data_size,
|
||||
@@ -535,7 +531,7 @@ impl fmt::Display for RType {
|
||||
f,
|
||||
"rem{}{}",
|
||||
if *is_signed { "" } else { "u" },
|
||||
data_size.word().write_string()
|
||||
filter_word(data_size)
|
||||
),
|
||||
Self::Slt { is_signed } => write!(f, "slt{}", if *is_signed { "" } else { "u" }),
|
||||
Self::Xor => write!(f, "xor"),
|
||||
@@ -696,6 +692,13 @@ impl IType {
|
||||
|
||||
impl fmt::Display for IType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let filter_word = |data_size: &DataSize| -> String {
|
||||
if data_size.is_word() {
|
||||
data_size.to_string()
|
||||
} else {
|
||||
"".to_string()
|
||||
}
|
||||
};
|
||||
match self {
|
||||
Self::Load {
|
||||
data_size,
|
||||
@@ -715,13 +718,13 @@ impl fmt::Display for IType {
|
||||
)
|
||||
}
|
||||
}
|
||||
Self::Addi(data_size) => write!(f, "addi{}", data_size.word().write_string()),
|
||||
Self::Addi(data_size) => write!(f, "addi{}", filter_word(data_size)),
|
||||
Self::Xori => write!(f, "xori"),
|
||||
Self::Ori => write!(f, "ori"),
|
||||
Self::Andi => write!(f, "andi"),
|
||||
Self::Slli(data_size) => write!(f, "slli{}", data_size.word().write_string()),
|
||||
Self::Srli(data_size) => write!(f, "srli{}", data_size.word().write_string()),
|
||||
Self::Srai(data_size) => write!(f, "srai{}", data_size.word().write_string()),
|
||||
Self::Slli(data_size) => write!(f, "slli{}", filter_word(data_size)),
|
||||
Self::Srli(data_size) => write!(f, "srli{}", filter_word(data_size)),
|
||||
Self::Srai(data_size) => write!(f, "srai{}", filter_word(data_size)),
|
||||
Self::Slti { is_signed } => write!(f, "slti{}", if *is_signed { "" } else { "u" }),
|
||||
}
|
||||
}
|
||||
@@ -805,9 +808,7 @@ impl fmt::Display for UType {
|
||||
/// instructions in the base ISA, but have implicit arguments or reversed arguments that result in
|
||||
/// distinct semantics.
|
||||
///
|
||||
/// For more information:
|
||||
/// - <https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#assembler-pseudo-instructions>
|
||||
/// - <https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (110p)
|
||||
/// For more information: <https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#assembler-pseudo-instructions>
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Pseudo {
|
||||
/// la rd, symbol
|
||||
@@ -876,13 +877,20 @@ impl Pseudo {
|
||||
|
||||
impl fmt::Display for Pseudo {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let filter_word = |data_size: &DataSize| -> String {
|
||||
if data_size.is_word() {
|
||||
data_size.to_string()
|
||||
} else {
|
||||
"".to_string()
|
||||
}
|
||||
};
|
||||
match self {
|
||||
Self::La { rd, symbol } => write!(f, "la\t{rd},{symbol}"),
|
||||
Self::Li { rd, imm } => write!(f, "li\t{},{}", rd, *imm as i64),
|
||||
Self::Mv { rd, rs } => write!(f, "mv\t{rd},{rs}"),
|
||||
Self::Fmv { data_size, rd, rs } => write!(f, "fmv.{data_size}\t{rd},{rs}"),
|
||||
Self::Neg { data_size, rd, rs } => {
|
||||
write!(f, "neg{}\t{},{}", data_size.word().write_string(), rd, rs)
|
||||
write!(f, "neg{}\t{},{}", filter_word(data_size), rd, rs)
|
||||
}
|
||||
Self::SextW { rs, rd } => write!(f, "sext.w\t{rd},{rs}"),
|
||||
Self::Seqz { rd, rs } => write!(f, "seqz\t{rd},{rs}"),
|
||||
@@ -929,8 +937,8 @@ impl fmt::Display for Immediate {
|
||||
}
|
||||
}
|
||||
|
||||
/// The relocation function creates synthesize operand values that are resolved
|
||||
/// at program link time and are used as immediate parameters for specific instructions.
|
||||
/// The relocation function creates synthesize operand values that are resolved at program link time
|
||||
/// and are used as immediate parameters for specific instructions.
|
||||
///
|
||||
/// For more details: <https://github.com/riscv-non-isa/riscv-asm-manual/blob/master/riscv-asm.md>
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@@ -1023,12 +1031,8 @@ impl DataSize {
|
||||
matches!(self, Self::SinglePrecision | Self::DoublePrecision)
|
||||
}
|
||||
|
||||
fn word(self) -> Option<Self> {
|
||||
if self == DataSize::Word {
|
||||
Some(self)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
fn is_word(&self) -> bool {
|
||||
matches!(self, Self::Word)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1049,7 +1053,7 @@ impl fmt::Display for DataSize {
|
||||
}
|
||||
}
|
||||
|
||||
/// ABI name for RISC-V integer and floating-point register
|
||||
/// ABI name for RISC-V integer and floating-point register.
|
||||
///
|
||||
/// For more details: <https://content.riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (109p)
|
||||
// TODO: Add calling convention information (caller/callee-save registers)
|
||||
|
||||
@@ -73,87 +73,3 @@ impl WriteLine for Block {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for Directive {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for SectionType {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for SymbolType {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for Instruction {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for RType {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for IType {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for SType {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for BType {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for UType {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for Pseudo {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for Immediate {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for RelocationFunction {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for DataSize {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for Register {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,31 +18,9 @@ impl<T: WriteString> WriteString for Node<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: WriteString> WriteString for Box<T> {
|
||||
fn write_string(&self) -> String {
|
||||
self.deref().write_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: WriteString> WriteString for &T {
|
||||
fn write_string(&self) -> String {
|
||||
(*self).write_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: WriteString> WriteString for Option<T> {
|
||||
fn write_string(&self) -> String {
|
||||
if let Some(this) = self {
|
||||
this.write_string()
|
||||
} else {
|
||||
"".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteLine for TranslationUnit {
|
||||
fn write_line(&self, _indent: usize, _write: &mut dyn Write) -> Result<()> {
|
||||
todo!("homework 1")
|
||||
todo!("Homework: write C")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -921,7 +921,7 @@ impl Dtype {
|
||||
match self {
|
||||
Self::Unit { .. } => Ok((0, 1)),
|
||||
Self::Int { width, .. } | Self::Float { width, .. } => {
|
||||
let size_of = (*width + Self::BITS_OF_BYTE - 1) / Self::BITS_OF_BYTE;
|
||||
let size_of = (*width).div_ceil(Self::BITS_OF_BYTE);
|
||||
let align_of = size_of;
|
||||
|
||||
Ok((size_of, align_of))
|
||||
|
||||
@@ -1155,7 +1155,7 @@ struct 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<'i>, InterpreterError> {
|
||||
// Interpreter starts with the main function
|
||||
let func_name = String::from("main");
|
||||
let func = ir
|
||||
|
||||
@@ -17,7 +17,6 @@ use ordered_float::OrderedFloat;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
use crate::write_base::*;
|
||||
pub use dtype::{Dtype, DtypeError, HasDtype};
|
||||
pub use interp::{interp, Value};
|
||||
pub use parse::Parse;
|
||||
@@ -260,6 +259,16 @@ impl Instruction {
|
||||
}
|
||||
}
|
||||
|
||||
/// Format `lang_c::ast::{Binary,Unary}Operations` into KECC-IR.
|
||||
///
|
||||
/// Most cases, `fmt::Display` is used to format a type to a string. However, in some cases, we
|
||||
/// can't implement `fmt::Display` for a type as it is defined in another crate. In such cases, we
|
||||
/// can implement this trait to format the type to a string.
|
||||
pub trait WriteOp {
|
||||
/// Change operations into a String.
|
||||
fn write_operation(&self) -> String;
|
||||
}
|
||||
|
||||
impl WriteOp for ast::BinaryOperator {
|
||||
fn write_operation(&self) -> String {
|
||||
match self {
|
||||
|
||||
@@ -157,21 +157,3 @@ impl WriteLine for (&BlockId, &Block) {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for Instruction {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for Operand {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteString for BlockExit {
|
||||
fn write_string(&self) -> String {
|
||||
format!("{self}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,8 +590,11 @@ impl IrgenFunc<'_> {
|
||||
///
|
||||
/// ```C
|
||||
/// int foo(int x, int y, int z) {
|
||||
/// if (x == y) { return y; }
|
||||
/// else { return z; }
|
||||
/// if (x == y) {
|
||||
/// return y;
|
||||
/// } else {
|
||||
/// return z;
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
@@ -615,9 +618,10 @@ impl IrgenFunc<'_> {
|
||||
/// bid_init = 0
|
||||
/// name_of_params = ["x", "y", "z"]
|
||||
/// context = // omitted
|
||||
/// ```
|
||||
/// ```
|
||||
///
|
||||
/// The resulting IR after this function should be roughly follows :
|
||||
///
|
||||
/// Resulting IR after this function should be roughly follows:
|
||||
/// ```text
|
||||
/// fun i32 @foo (i32, i32, i32) {
|
||||
/// init:
|
||||
@@ -635,7 +639,7 @@ impl IrgenFunc<'_> {
|
||||
/// %b0:i1:unit = store %b0:p1:i32 %l1:i32*
|
||||
/// %b0:i2:unit = store %b0:p2:i32 %l2:i32*
|
||||
/// ```
|
||||
///
|
||||
///
|
||||
/// In particular, note that it is added to the local allocation list and store them to the
|
||||
/// initial phinodes.
|
||||
///
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
// #![deny(missing_docs)]
|
||||
#![deny(non_ascii_idents)]
|
||||
#![deny(noop_method_call)]
|
||||
#![deny(pointer_structural_match)]
|
||||
#![deny(rust_2021_incompatible_closure_captures)]
|
||||
#![deny(rust_2021_incompatible_or_patterns)]
|
||||
#![deny(rust_2021_prefixes_incompatible_syntax)]
|
||||
|
||||
@@ -1,30 +1,52 @@
|
||||
use std::io::{Result, Write};
|
||||
|
||||
/// TODO(document)
|
||||
/// Write `indent` number of double spaces to `write`.
|
||||
#[inline]
|
||||
pub fn write_indent(indent: usize, write: &mut dyn Write) -> Result<()> {
|
||||
write!(write, "{}", " ".repeat(indent))
|
||||
}
|
||||
|
||||
/// TODO(document)
|
||||
/// A trait for writing a type to a `Write` stream with a new line.
|
||||
pub trait WriteLine {
|
||||
/// TODO(document)
|
||||
/// Write `self` to `write`, starting at `indent` number of double spaces, with a newline at the
|
||||
/// ned.
|
||||
fn write_line(&self, indent: usize, write: &mut dyn Write) -> Result<()>;
|
||||
}
|
||||
|
||||
/// TODO(document)
|
||||
/// Format types to a String.
|
||||
///
|
||||
/// Most cases, `fmt::Display` is used to format a type to a string. However, in some cases, we
|
||||
/// can't implement `fmt::Display` for a type as it is defined in another crate. In such cases, we
|
||||
/// can implement this trait to format the type to a string.
|
||||
pub trait WriteString {
|
||||
/// TODO(document)
|
||||
/// Change a type into a String.
|
||||
fn write_string(&self) -> String;
|
||||
}
|
||||
|
||||
/// TODO(document)
|
||||
pub trait WriteOp {
|
||||
/// TODO(document)
|
||||
fn write_operation(&self) -> String;
|
||||
impl<T: WriteString> WriteString for Box<T> {
|
||||
fn write_string(&self) -> String {
|
||||
use core::ops::Deref;
|
||||
self.deref().write_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO(document)
|
||||
impl<T: WriteString> WriteString for &T {
|
||||
fn write_string(&self) -> String {
|
||||
(*self).write_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: WriteString> WriteString for Option<T> {
|
||||
fn write_string(&self) -> String {
|
||||
if let Some(this) = self {
|
||||
this.write_string()
|
||||
} else {
|
||||
"".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Write `t` to `write`.
|
||||
pub fn write<T: WriteLine>(t: &T, write: &mut dyn Write) -> Result<()> {
|
||||
t.write_line(0, write)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user