Merge commit '5988bbd24a
' into sync_cg_clif-2020-11-27
This commit is contained in:
commit
477aa67802
33 changed files with 400 additions and 222 deletions
|
@ -1 +1,2 @@
|
||||||
* text=auto eol=lf
|
* text=auto eol=lf
|
||||||
|
*.rs diff=rust
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.33"
|
version = "1.0.34"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c"
|
checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ar"
|
name = "ar"
|
||||||
|
@ -31,9 +31,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.61"
|
version = "1.0.62"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d"
|
checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
|
@ -41,18 +41,24 @@ version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-bforest"
|
name = "cranelift-bforest"
|
||||||
version = "0.67.0"
|
version = "0.68.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
|
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cranelift-entity",
|
"cranelift-entity",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-codegen"
|
name = "cranelift-codegen"
|
||||||
version = "0.67.0"
|
version = "0.68.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
|
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cranelift-bforest",
|
"cranelift-bforest",
|
||||||
|
@ -69,8 +75,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-codegen-meta"
|
name = "cranelift-codegen-meta"
|
||||||
version = "0.67.0"
|
version = "0.68.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
|
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cranelift-codegen-shared",
|
"cranelift-codegen-shared",
|
||||||
"cranelift-entity",
|
"cranelift-entity",
|
||||||
|
@ -78,18 +84,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-codegen-shared"
|
name = "cranelift-codegen-shared"
|
||||||
version = "0.67.0"
|
version = "0.68.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
|
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-entity"
|
name = "cranelift-entity"
|
||||||
version = "0.67.0"
|
version = "0.68.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
|
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-frontend"
|
name = "cranelift-frontend"
|
||||||
version = "0.67.0"
|
version = "0.68.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
|
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
"log",
|
"log",
|
||||||
|
@ -99,8 +105,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-module"
|
name = "cranelift-module"
|
||||||
version = "0.67.0"
|
version = "0.68.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
|
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
|
@ -111,8 +117,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-native"
|
name = "cranelift-native"
|
||||||
version = "0.67.0"
|
version = "0.68.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
|
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
"raw-cpuid",
|
"raw-cpuid",
|
||||||
|
@ -121,8 +127,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-object"
|
name = "cranelift-object"
|
||||||
version = "0.67.0"
|
version = "0.68.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
|
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
|
@ -134,8 +140,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-simplejit"
|
name = "cranelift-simplejit"
|
||||||
version = "0.67.0"
|
version = "0.68.0"
|
||||||
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21"
|
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
"cranelift-entity",
|
"cranelift-entity",
|
||||||
|
@ -151,18 +157,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crc32fast"
|
name = "crc32fast"
|
||||||
version = "1.2.0"
|
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 = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
|
checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 1.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "errno"
|
name = "errno"
|
||||||
version = "0.2.6"
|
version = "0.2.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6eab5ee3df98a279d9b316b1af6ac95422127b1290317e6d18c1743c99418b01"
|
checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"errno-dragonfly",
|
"errno-dragonfly",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -187,9 +193,9 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gimli"
|
name = "gimli"
|
||||||
version = "0.22.0"
|
version = "0.23.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
|
checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
]
|
]
|
||||||
|
@ -212,17 +218,17 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.79"
|
version = "0.2.80"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743"
|
checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
version = "0.6.4"
|
version = "0.6.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3557c9384f7f757f6d139cd3a4c62ef4e850696c16bf27924a5538c8a09717a1"
|
checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 1.0.0",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -232,7 +238,7 @@ version = "0.4.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -246,9 +252,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "object"
|
name = "object"
|
||||||
version = "0.21.1"
|
version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693"
|
checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
@ -274,9 +280,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "raw-cpuid"
|
name = "raw-cpuid"
|
||||||
version = "7.0.3"
|
version = "8.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf"
|
checksum = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cc",
|
"cc",
|
||||||
|
@ -361,9 +367,9 @@ checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.44"
|
version = "1.0.48"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e03e57e4fcbfe7749842d53e24ccb9aa12b7252dbe5e91d2acad31834c8b8fdd"
|
checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -372,24 +378,24 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "target-lexicon"
|
name = "target-lexicon"
|
||||||
version = "0.11.0"
|
version = "0.11.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fe2635952a442a01fd4cb53d98858b5e4bb461b02c0d111f22f31772e3e7a8b2"
|
checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.21"
|
version = "1.0.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "318234ffa22e0920fe9a40d7b8369b5f649d490980cf7aadcf1eb91594869b42"
|
checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.21"
|
version = "1.0.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cae2447b6282786c3493999f40a9be2a6ad20cb8bd268b0a0dbf5a065535c0ab"
|
checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
|
@ -15,8 +15,8 @@ cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", bran
|
||||||
cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true }
|
cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true }
|
||||||
cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
|
cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
|
||||||
target-lexicon = "0.11.0"
|
target-lexicon = "0.11.0"
|
||||||
gimli = { version = "0.22.0", default-features = false, features = ["write"]}
|
gimli = { version = "0.23.0", default-features = false, features = ["write"]}
|
||||||
object = { version = "0.21.1", default-features = false, features = ["std", "read_core", "write", "coff", "elf", "macho", "pe"] }
|
object = { version = "0.22.0", default-features = false, features = ["std", "read_core", "write", "coff", "elf", "macho", "pe"] }
|
||||||
|
|
||||||
ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
|
ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
|
||||||
indexmap = "1.0.2"
|
indexmap = "1.0.2"
|
||||||
|
|
|
@ -51,7 +51,7 @@ This should build and run your project with rustc_codegen_cranelift instead of t
|
||||||
> You should prefer using the Cargo method.
|
> You should prefer using the Cargo method.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ $cg_clif_dir/build/cg_clif my_crate.rs
|
$ $cg_clif_dir/build/bin/cg_clif my_crate.rs
|
||||||
```
|
```
|
||||||
|
|
||||||
### Jit mode
|
### Jit mode
|
||||||
|
@ -68,7 +68,7 @@ $ $cg_clif_dir/build/cargo.sh jit
|
||||||
or
|
or
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ $cg_clif_dir/build/cg_clif --jit my_crate.rs
|
$ $cg_clif_dir/build/bin/cg_clif --jit my_crate.rs
|
||||||
```
|
```
|
||||||
|
|
||||||
### Shell
|
### Shell
|
||||||
|
@ -77,7 +77,7 @@ These are a few functions that allow you to easily run rust code from the shell
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
function jit_naked() {
|
function jit_naked() {
|
||||||
echo "$@" | $cg_clif_dir/build/cg_clif - --jit
|
echo "$@" | $cg_clif_dir/build/bin/cg_clif - --jit
|
||||||
}
|
}
|
||||||
|
|
||||||
function jit() {
|
function jit() {
|
||||||
|
|
|
@ -26,22 +26,35 @@ while [[ $# != 0 ]]; do
|
||||||
done
|
done
|
||||||
|
|
||||||
# Build cg_clif
|
# Build cg_clif
|
||||||
|
unset CARGO_TARGET_DIR
|
||||||
export RUSTFLAGS="-Zrun_dsymutil=no"
|
export RUSTFLAGS="-Zrun_dsymutil=no"
|
||||||
|
unamestr=$(uname)
|
||||||
|
if [[ "$unamestr" == 'Linux' ]]; then
|
||||||
|
export RUSTFLAGS='-Clink-arg=-Wl,-rpath=$ORIGIN/../lib '$RUSTFLAGS
|
||||||
|
elif [[ "$unamestr" == 'Darwin' ]]; then
|
||||||
|
export RUSTFLAGS='-Clink-arg=-Wl,-rpath,@loader_path/../lib -Zosx-rpath-install-name '$RUSTFLAGS
|
||||||
|
dylib_ext='dylib'
|
||||||
|
else
|
||||||
|
echo "Unsupported os"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
if [[ "$CHANNEL" == "release" ]]; then
|
if [[ "$CHANNEL" == "release" ]]; then
|
||||||
cargo build --release
|
cargo build --release
|
||||||
else
|
else
|
||||||
cargo build
|
cargo build
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf $target_dir
|
rm -rf "$target_dir"
|
||||||
mkdir $target_dir
|
mkdir "$target_dir"
|
||||||
cp -a target/$CHANNEL/cg_clif{,_build_sysroot} target/$CHANNEL/*rustc_codegen_cranelift* $target_dir/
|
mkdir "$target_dir"/bin "$target_dir"/lib
|
||||||
cp -a rust-toolchain scripts/config.sh scripts/cargo.sh $target_dir
|
ln target/$CHANNEL/cg_clif{,_build_sysroot} "$target_dir"/bin
|
||||||
|
ln target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir"/lib
|
||||||
|
ln rust-toolchain scripts/config.sh scripts/cargo.sh "$target_dir"
|
||||||
|
|
||||||
if [[ "$build_sysroot" == "1" ]]; then
|
if [[ "$build_sysroot" == "1" ]]; then
|
||||||
echo "[BUILD] sysroot"
|
echo "[BUILD] sysroot"
|
||||||
export CG_CLIF_INCR_CACHE_DISABLED=1
|
export CG_CLIF_INCR_CACHE_DISABLED=1
|
||||||
dir=$(pwd)
|
dir=$(pwd)
|
||||||
cd $target_dir
|
cd "$target_dir"
|
||||||
time $dir/build_sysroot/build_sysroot.sh
|
time "$dir/build_sysroot/build_sysroot.sh"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addr2line"
|
name = "addr2line"
|
||||||
version = "0.13.0"
|
version = "0.14.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"
|
checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"compiler_builtins",
|
"compiler_builtins",
|
||||||
"gimli",
|
"gimli",
|
||||||
|
@ -47,9 +47,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.61"
|
version = "1.0.65"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d"
|
checksum = "95752358c8f7552394baf48cd82695b345628ad3f170d607de3ca03b8dacca15"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
|
@ -76,9 +76,9 @@ version = "0.0.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dlmalloc"
|
name = "dlmalloc"
|
||||||
version = "0.1.4"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "35055b1021724f4eb5262eb49130eebff23fc59fc5a14160e05faad8eeb36673"
|
checksum = "332570860c2edf2d57914987bf9e24835425f75825086b6ba7d1e6a3e4f1f254"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"compiler_builtins",
|
"compiler_builtins",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -108,9 +108,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gimli"
|
name = "gimli"
|
||||||
version = "0.22.0"
|
version = "0.23.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
|
checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"compiler_builtins",
|
"compiler_builtins",
|
||||||
"rustc-std-workspace-alloc",
|
"rustc-std-workspace-alloc",
|
||||||
|
@ -163,9 +163,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "object"
|
name = "object"
|
||||||
version = "0.20.0"
|
version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
|
checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"compiler_builtins",
|
"compiler_builtins",
|
||||||
"rustc-std-workspace-alloc",
|
"rustc-std-workspace-alloc",
|
||||||
|
|
|
@ -10,10 +10,10 @@ dir=$(pwd)
|
||||||
|
|
||||||
# Use rustc with cg_clif as hotpluggable backend instead of the custom cg_clif driver so that
|
# Use rustc with cg_clif as hotpluggable backend instead of the custom cg_clif driver so that
|
||||||
# build scripts are still compiled using cg_llvm.
|
# build scripts are still compiled using cg_llvm.
|
||||||
export RUSTC=$dir"/cg_clif_build_sysroot"
|
export RUSTC=$dir"/bin/cg_clif_build_sysroot"
|
||||||
export RUSTFLAGS=$RUSTFLAGS" --clif"
|
export RUSTFLAGS=$RUSTFLAGS" --clif"
|
||||||
|
|
||||||
cd $(dirname "$0")
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
# Cleanup for previous run
|
# Cleanup for previous run
|
||||||
# v Clean target dir except for build scripts and incremental cache
|
# v Clean target dir except for build scripts and incremental cache
|
||||||
|
@ -28,12 +28,13 @@ if [[ "$1" != "--debug" ]]; then
|
||||||
sysroot_channel='release'
|
sysroot_channel='release'
|
||||||
# FIXME Enable incremental again once rust-lang/rust#74946 is fixed
|
# FIXME Enable incremental again once rust-lang/rust#74946 is fixed
|
||||||
# FIXME Enable -Zmir-opt-level=2 again once it doesn't ice anymore
|
# FIXME Enable -Zmir-opt-level=2 again once it doesn't ice anymore
|
||||||
CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS" cargo build --target $TARGET_TRIPLE --release
|
CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS" cargo build --target "$TARGET_TRIPLE" --release
|
||||||
else
|
else
|
||||||
sysroot_channel='debug'
|
sysroot_channel='debug'
|
||||||
cargo build --target $TARGET_TRIPLE
|
cargo build --target "$TARGET_TRIPLE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy files to sysroot
|
# Copy files to sysroot
|
||||||
mkdir -p $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|
mkdir -p "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"
|
||||||
cp -a target/$TARGET_TRIPLE/$sysroot_channel/deps/* $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|
ln "target/$TARGET_TRIPLE/$sysroot_channel/deps/"* "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"
|
||||||
|
rm "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"*.{rmeta,d}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
cd $(dirname "$0")
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
SRC_DIR=$(dirname $(rustup which rustc))"/../lib/rustlib/src/rust/"
|
SRC_DIR="$(dirname "$(rustup which rustc)")/../lib/rustlib/src/rust/"
|
||||||
DST_DIR="sysroot_src"
|
DST_DIR="sysroot_src"
|
||||||
|
|
||||||
if [ ! -e $SRC_DIR ]; then
|
if [ ! -e "$SRC_DIR" ]; then
|
||||||
echo "Please install rust-src component"
|
echo "Please install rust-src component"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf $DST_DIR
|
rm -rf $DST_DIR
|
||||||
mkdir -p $DST_DIR/library
|
mkdir -p $DST_DIR/library
|
||||||
cp -a $SRC_DIR/library $DST_DIR/
|
cp -a "$SRC_DIR/library" $DST_DIR/
|
||||||
|
|
||||||
pushd $DST_DIR
|
pushd $DST_DIR
|
||||||
echo "[GIT] init"
|
echo "[GIT] init"
|
||||||
|
@ -22,8 +22,8 @@ git add .
|
||||||
echo "[GIT] commit"
|
echo "[GIT] commit"
|
||||||
git commit -m "Initial commit" -q
|
git commit -m "Initial commit" -q
|
||||||
for file in $(ls ../../patches/ | grep -v patcha); do
|
for file in $(ls ../../patches/ | grep -v patcha); do
|
||||||
echo "[GIT] apply" $file
|
echo "[GIT] apply" "$file"
|
||||||
git apply ../../patches/$file
|
git apply ../../patches/"$file"
|
||||||
git add -A
|
git add -A
|
||||||
git commit --no-gpg-sign -m "Patch $file"
|
git commit --no-gpg-sign -m "Patch $file"
|
||||||
done
|
done
|
||||||
|
|
|
@ -53,6 +53,7 @@ fn main() {
|
||||||
|
|
||||||
assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26);
|
assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26);
|
||||||
assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7);
|
assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7);
|
||||||
|
assert_eq!(core::intrinsics::saturating_sub(0, -170141183460469231731687303715884105728i128), 170141183460469231731687303715884105727i128);
|
||||||
|
|
||||||
let _d = 0i128.checked_div(2i128);
|
let _d = 0i128.checked_div(2i128);
|
||||||
let _d = 0u128.checked_div(2u128);
|
let _d = 0u128.checked_div(2u128);
|
||||||
|
|
|
@ -52,8 +52,8 @@ index 0475aeb..9558198 100644
|
||||||
fn test_rotate() {
|
fn test_rotate() {
|
||||||
assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A);
|
assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A);
|
||||||
@@ -112,6 +113,7 @@ mod tests {
|
@@ -112,6 +113,7 @@ mod tests {
|
||||||
assert_eq!(B.rotate_left(64), B);
|
assert_eq!(B.rotate_left(128), B);
|
||||||
assert_eq!(C.rotate_left(64), C);
|
assert_eq!(C.rotate_left(128), C);
|
||||||
}
|
}
|
||||||
+ */
|
+ */
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ index 04ed14f..a6e372e 100644
|
||||||
fn test_rotate() {
|
fn test_rotate() {
|
||||||
assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A);
|
assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A);
|
||||||
@@ -76,6 +77,7 @@ mod tests {
|
@@ -76,6 +77,7 @@ mod tests {
|
||||||
assert_eq!(B.rotate_left(64), B);
|
assert_eq!(B.rotate_left(128), B);
|
||||||
assert_eq!(C.rotate_left(64), C);
|
assert_eq!(C.rotate_left(128), C);
|
||||||
}
|
}
|
||||||
+ */
|
+ */
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ git checkout -- .
|
||||||
git checkout 804a7a21b9e673a482797aa289a18ed480e4d813
|
git checkout 804a7a21b9e673a482797aa289a18ed480e4d813
|
||||||
|
|
||||||
# build with cg_llvm for perf comparison
|
# build with cg_llvm for perf comparison
|
||||||
|
unset CARGO_TARGET_DIR
|
||||||
cargo build
|
cargo build
|
||||||
mv target/debug/main raytracer_cg_llvm
|
mv target/debug/main raytracer_cg_llvm
|
||||||
popd
|
popd
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
nightly-2020-10-31
|
nightly-2020-11-27
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
dir=$(dirname "$0")
|
dir=$(dirname "$0")
|
||||||
source $dir/config.sh
|
source "$dir/config.sh"
|
||||||
|
|
||||||
# read nightly compiler from rust-toolchain file
|
# read nightly compiler from rust-toolchain file
|
||||||
TOOLCHAIN=$(cat $dir/rust-toolchain)
|
TOOLCHAIN=$(cat "$dir/rust-toolchain")
|
||||||
|
|
||||||
cmd=$1
|
cmd=$1
|
||||||
shift || true
|
shift || true
|
||||||
|
|
||||||
if [[ "$cmd" = "jit" ]]; then
|
if [[ "$cmd" = "jit" ]]; then
|
||||||
cargo +${TOOLCHAIN} rustc "$@" -- --jit
|
cargo "+${TOOLCHAIN}" rustc "$@" -- --jit
|
||||||
else
|
else
|
||||||
cargo +${TOOLCHAIN} $cmd "$@"
|
cargo "+${TOOLCHAIN}" "$cmd" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
# Note to people running shellcheck: this file should only be sourced, not executed directly.
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
unamestr=`uname`
|
unamestr=$(uname)
|
||||||
if [[ "$unamestr" == 'Linux' ]]; then
|
if [[ "$unamestr" == 'Linux' ]]; then
|
||||||
dylib_ext='so'
|
dylib_ext='so'
|
||||||
elif [[ "$unamestr" == 'Darwin' ]]; then
|
elif [[ "$unamestr" == 'Darwin' ]]; then
|
||||||
|
@ -40,19 +41,19 @@ echo
|
||||||
export RUSTC_WRAPPER=
|
export RUSTC_WRAPPER=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dir=$(cd $(dirname "$BASH_SOURCE"); pwd)
|
dir=$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)
|
||||||
|
|
||||||
export RUSTC=$dir"/cg_clif"
|
export RUSTC=$dir"/bin/cg_clif"
|
||||||
export RUSTFLAGS=$linker
|
export RUSTFLAGS=$linker" "$RUSTFLAGS
|
||||||
export RUSTDOCFLAGS=$linker' -Ztrim-diagnostic-paths=no -Cpanic=abort -Zpanic-abort-tests '\
|
export RUSTDOCFLAGS=$linker' -Cpanic=abort -Zpanic-abort-tests '\
|
||||||
'-Zcodegen-backend='$dir'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$dir'/sysroot'
|
'-Zcodegen-backend='$dir'/lib/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$dir
|
||||||
|
|
||||||
# FIXME remove once the atomic shim is gone
|
# FIXME remove once the atomic shim is gone
|
||||||
if [[ `uname` == 'Darwin' ]]; then
|
if [[ $(uname) == 'Darwin' ]]; then
|
||||||
export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
|
export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export LD_LIBRARY_PATH="$dir:$(rustc --print sysroot)/lib:$dir/target/out:$dir/sysroot/lib/rustlib/"$TARGET_TRIPLE"/lib"
|
export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib"
|
||||||
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
|
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
|
||||||
|
|
||||||
export CG_CLIF_DISPLAY_CG_TIME=1
|
export CG_CLIF_DISPLAY_CG_TIME=1
|
||||||
|
|
|
@ -7,13 +7,13 @@ case $1 in
|
||||||
TOOLCHAIN=$(date +%Y-%m-%d)
|
TOOLCHAIN=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
echo "=> Installing new nightly"
|
echo "=> Installing new nightly"
|
||||||
rustup toolchain install --profile minimal nightly-${TOOLCHAIN} # Sanity check to see if the nightly exists
|
rustup toolchain install --profile minimal "nightly-${TOOLCHAIN}" # Sanity check to see if the nightly exists
|
||||||
echo nightly-${TOOLCHAIN} > rust-toolchain
|
echo "nightly-${TOOLCHAIN}" > rust-toolchain
|
||||||
rustup component add rustfmt || true
|
rustup component add rustfmt || true
|
||||||
|
|
||||||
echo "=> Uninstalling all old nighlies"
|
echo "=> Uninstalling all old nighlies"
|
||||||
for nightly in $(rustup toolchain list | grep nightly | grep -v $TOOLCHAIN | grep -v nightly-x86_64); do
|
for nightly in $(rustup toolchain list | grep nightly | grep -v "$TOOLCHAIN" | grep -v nightly-x86_64); do
|
||||||
rustup toolchain uninstall $nightly
|
rustup toolchain uninstall "$nightly"
|
||||||
done
|
done
|
||||||
|
|
||||||
./clean_all.sh
|
./clean_all.sh
|
||||||
|
@ -27,14 +27,30 @@ case $1 in
|
||||||
git commit -m "Rustup to $(rustc -V)"
|
git commit -m "Rustup to $(rustc -V)"
|
||||||
;;
|
;;
|
||||||
"push")
|
"push")
|
||||||
cg_clif=$(pwd)
|
cg_clif=$(pwd)
|
||||||
pushd ../rust
|
pushd ../rust
|
||||||
branch=update_cg_clif-$(date +%Y-%m-%d)
|
git pull origin master
|
||||||
git checkout -b $branch
|
branch=sync_cg_clif-$(date +%Y-%m-%d)
|
||||||
git subtree pull --prefix=compiler/rustc_codegen_cranelift/ https://github.com/bjorn3/rustc_codegen_cranelift.git master
|
git checkout -b "$branch"
|
||||||
git push -u my $branch
|
git subtree pull --prefix=compiler/rustc_codegen_cranelift/ https://github.com/bjorn3/rustc_codegen_cranelift.git master
|
||||||
popd
|
git push -u my "$branch"
|
||||||
|
|
||||||
|
# immediately merge the merge commit into cg_clif to prevent merge conflicts when syncing
|
||||||
|
# from rust-lang/rust later
|
||||||
|
git subtree push --prefix=compiler/rustc_codegen_cranelift/ "$cg_clif" sync_from_rust
|
||||||
|
popd
|
||||||
|
git merge sync_from_rust
|
||||||
;;
|
;;
|
||||||
|
"pull")
|
||||||
|
cg_clif=$(pwd)
|
||||||
|
pushd ../rust
|
||||||
|
git pull origin master
|
||||||
|
rust_vers="$(git rev-parse HEAD)"
|
||||||
|
git subtree push --prefix=compiler/rustc_codegen_cranelift/ "$cg_clif" sync_from_rust
|
||||||
|
popd
|
||||||
|
git merge sync_from_rust -m "Sync from rust $rust_vers"
|
||||||
|
git branch -d sync_from_rust
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown command '$1'"
|
echo "Unknown command '$1'"
|
||||||
echo "Usage: ./rustup.sh prepare|commit"
|
echo "Usage: ./rustup.sh prepare|commit"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cd $(dirname "$0")/../
|
cd "$(dirname "$0")/../"
|
||||||
|
|
||||||
./build.sh
|
./build.sh
|
||||||
source build/config.sh
|
source build/config.sh
|
||||||
|
@ -11,7 +11,7 @@ git clone https://github.com/rust-lang/rust.git || true
|
||||||
pushd rust
|
pushd rust
|
||||||
git fetch
|
git fetch
|
||||||
git checkout -- .
|
git checkout -- .
|
||||||
git checkout $(rustc -V | cut -d' ' -f3 | tr -d '(')
|
git checkout "$(rustc -V | cut -d' ' -f3 | tr -d '(')"
|
||||||
|
|
||||||
git apply - <<EOF
|
git apply - <<EOF
|
||||||
diff --git a/.gitmodules b/.gitmodules
|
diff --git a/.gitmodules b/.gitmodules
|
||||||
|
@ -48,7 +48,7 @@ cat > config.toml <<EOF
|
||||||
ninja = false
|
ninja = false
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
rustc = "$(pwd)/../build/cg_clif"
|
rustc = "$(pwd)/../build/bin/cg_clif"
|
||||||
cargo = "$(rustup which cargo)"
|
cargo = "$(rustup which cargo)"
|
||||||
full-bootstrap = true
|
full-bootstrap = true
|
||||||
local-rebuild = true
|
local-rebuild = true
|
||||||
|
|
|
@ -4,63 +4,63 @@ set -e
|
||||||
|
|
||||||
source build/config.sh
|
source build/config.sh
|
||||||
export CG_CLIF_INCR_CACHE_DISABLED=1
|
export CG_CLIF_INCR_CACHE_DISABLED=1
|
||||||
MY_RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=2"
|
MY_RUSTC="$RUSTC $RUSTFLAGS -L crate=target/out --out-dir target/out -Cdebuginfo=2"
|
||||||
|
|
||||||
function no_sysroot_tests() {
|
function no_sysroot_tests() {
|
||||||
echo "[BUILD] mini_core"
|
echo "[BUILD] mini_core"
|
||||||
$MY_RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE
|
$MY_RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target "$TARGET_TRIPLE"
|
||||||
|
|
||||||
echo "[BUILD] example"
|
echo "[BUILD] example"
|
||||||
$MY_RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE
|
$MY_RUSTC example/example.rs --crate-type lib --target "$TARGET_TRIPLE"
|
||||||
|
|
||||||
if [[ "$JIT_SUPPORTED" = "1" ]]; then
|
if [[ "$JIT_SUPPORTED" = "1" ]]; then
|
||||||
echo "[JIT] mini_core_hello_world"
|
echo "[JIT] mini_core_hello_world"
|
||||||
CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE
|
CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
|
||||||
else
|
else
|
||||||
echo "[JIT] mini_core_hello_world (skipped)"
|
echo "[JIT] mini_core_hello_world (skipped)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[AOT] mini_core_hello_world"
|
echo "[AOT] mini_core_hello_world"
|
||||||
$MY_RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
|
$MY_RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target "$TARGET_TRIPLE"
|
||||||
$RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
|
$RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
|
||||||
# (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd
|
# (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd
|
||||||
|
|
||||||
echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
|
echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
|
||||||
$MY_RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
|
$MY_RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target "$TARGET_TRIPLE"
|
||||||
$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
|
$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
|
||||||
}
|
}
|
||||||
|
|
||||||
function base_sysroot_tests() {
|
function base_sysroot_tests() {
|
||||||
echo "[AOT] alloc_example"
|
echo "[AOT] alloc_example"
|
||||||
$MY_RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
|
$MY_RUSTC example/alloc_example.rs --crate-type bin --target "$TARGET_TRIPLE"
|
||||||
$RUN_WRAPPER ./target/out/alloc_example
|
$RUN_WRAPPER ./target/out/alloc_example
|
||||||
|
|
||||||
if [[ "$JIT_SUPPORTED" = "1" ]]; then
|
if [[ "$JIT_SUPPORTED" = "1" ]]; then
|
||||||
echo "[JIT] std_example"
|
echo "[JIT] std_example"
|
||||||
$MY_RUSTC --jit example/std_example.rs --target $HOST_TRIPLE
|
$MY_RUSTC --jit example/std_example.rs --target "$HOST_TRIPLE"
|
||||||
else
|
else
|
||||||
echo "[JIT] std_example (skipped)"
|
echo "[JIT] std_example (skipped)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[AOT] dst_field_align"
|
echo "[AOT] dst_field_align"
|
||||||
# FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
|
# FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
|
||||||
$MY_RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
|
$MY_RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target "$TARGET_TRIPLE"
|
||||||
$RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false)
|
$RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false)
|
||||||
|
|
||||||
echo "[AOT] std_example"
|
echo "[AOT] std_example"
|
||||||
$MY_RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE
|
$MY_RUSTC example/std_example.rs --crate-type bin --target "$TARGET_TRIPLE"
|
||||||
$RUN_WRAPPER ./target/out/std_example arg
|
$RUN_WRAPPER ./target/out/std_example arg
|
||||||
|
|
||||||
echo "[AOT] subslice-patterns-const-eval"
|
echo "[AOT] subslice-patterns-const-eval"
|
||||||
$MY_RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
|
$MY_RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
|
||||||
$RUN_WRAPPER ./target/out/subslice-patterns-const-eval
|
$RUN_WRAPPER ./target/out/subslice-patterns-const-eval
|
||||||
|
|
||||||
echo "[AOT] track-caller-attribute"
|
echo "[AOT] track-caller-attribute"
|
||||||
$MY_RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
|
$MY_RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
|
||||||
$RUN_WRAPPER ./target/out/track-caller-attribute
|
$RUN_WRAPPER ./target/out/track-caller-attribute
|
||||||
|
|
||||||
echo "[AOT] mod_bench"
|
echo "[AOT] mod_bench"
|
||||||
$MY_RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
|
$MY_RUSTC example/mod_bench.rs --crate-type bin --target "$TARGET_TRIPLE"
|
||||||
$RUN_WRAPPER ./target/out/mod_bench
|
$RUN_WRAPPER ./target/out/mod_bench
|
||||||
|
|
||||||
pushd rand
|
pushd rand
|
||||||
|
@ -73,13 +73,13 @@ function extended_sysroot_tests() {
|
||||||
pushd simple-raytracer
|
pushd simple-raytracer
|
||||||
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
||||||
echo "[BENCH COMPILE] ebobby/simple-raytracer"
|
echo "[BENCH COMPILE] ebobby/simple-raytracer"
|
||||||
hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \
|
hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "cargo clean" \
|
||||||
"RUSTC=rustc RUSTFLAGS='' cargo build" \
|
"RUSTC=rustc RUSTFLAGS='' cargo build" \
|
||||||
"../build/cargo.sh build"
|
"../build/cargo.sh build"
|
||||||
|
|
||||||
echo "[BENCH RUN] ebobby/simple-raytracer"
|
echo "[BENCH RUN] ebobby/simple-raytracer"
|
||||||
cp ./target/debug/main ./raytracer_cg_clif
|
cp ./target/debug/main ./raytracer_cg_clif
|
||||||
hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif
|
hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_clif
|
||||||
else
|
else
|
||||||
echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
|
echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
|
||||||
echo "[COMPILE] ebobby/simple-raytracer"
|
echo "[COMPILE] ebobby/simple-raytracer"
|
||||||
|
|
|
@ -214,10 +214,8 @@ pub(crate) fn get_function_name_and_sig<'tcx>(
|
||||||
support_vararg: bool,
|
support_vararg: bool,
|
||||||
) -> (String, Signature) {
|
) -> (String, Signature) {
|
||||||
assert!(!inst.substs.needs_infer());
|
assert!(!inst.substs.needs_infer());
|
||||||
let fn_sig = tcx.normalize_erasing_late_bound_regions(
|
let fn_sig = tcx
|
||||||
ParamEnv::reveal_all(),
|
.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), fn_sig_for_fn_abi(tcx, inst));
|
||||||
fn_sig_for_fn_abi(tcx, inst),
|
|
||||||
);
|
|
||||||
if fn_sig.c_variadic && !support_vararg {
|
if fn_sig.c_variadic && !support_vararg {
|
||||||
tcx.sess.span_fatal(
|
tcx.sess.span_fatal(
|
||||||
tcx.def_span(inst.def_id()),
|
tcx.def_span(inst.def_id()),
|
||||||
|
|
|
@ -8,7 +8,7 @@ use rustc_codegen_ssa::back::archive::{find_library, ArchiveBuilder};
|
||||||
use rustc_codegen_ssa::METADATA_FILENAME;
|
use rustc_codegen_ssa::METADATA_FILENAME;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
|
|
||||||
use object::{Object, SymbolKind};
|
use object::{Object, ObjectSymbol, SymbolKind};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum ArchiveEntry {
|
enum ArchiveEntry {
|
||||||
|
@ -184,7 +184,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
||||||
entry_name.as_bytes().to_vec(),
|
entry_name.as_bytes().to_vec(),
|
||||||
object
|
object
|
||||||
.symbols()
|
.symbols()
|
||||||
.filter_map(|(_index, symbol)| {
|
.filter_map(|symbol| {
|
||||||
if symbol.is_undefined()
|
if symbol.is_undefined()
|
||||||
|| symbol.is_local()
|
|| symbol.is_local()
|
||||||
|| symbol.kind() != SymbolKind::Data
|
|| symbol.kind() != SymbolKind::Data
|
||||||
|
@ -193,7 +193,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
||||||
{
|
{
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
symbol.name().map(|name| name.as_bytes().to_vec())
|
symbol.name().map(|name| name.as_bytes().to_vec()).ok()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
|
|
|
@ -7,8 +7,7 @@ use crate::prelude::*;
|
||||||
|
|
||||||
#[cfg(all(feature = "jit", unix))]
|
#[cfg(all(feature = "jit", unix))]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t =
|
static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER;
|
||||||
libc::PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
pub(crate) fn init_global_lock(
|
pub(crate) fn init_global_lock(
|
||||||
module: &mut impl Module,
|
module: &mut impl Module,
|
||||||
|
|
|
@ -12,6 +12,10 @@ pub(crate) fn codegen_fn<'tcx>(
|
||||||
) {
|
) {
|
||||||
let tcx = cx.tcx;
|
let tcx = cx.tcx;
|
||||||
|
|
||||||
|
let _inst_guard =
|
||||||
|
crate::PrintOnPanic(|| format!("{:?} {}", instance, tcx.symbol_name(instance).name));
|
||||||
|
debug_assert!(!instance.substs.needs_infer());
|
||||||
|
|
||||||
let mir = tcx.instance_mir(instance.def);
|
let mir = tcx.instance_mir(instance.def);
|
||||||
|
|
||||||
// Declare function
|
// Declare function
|
||||||
|
@ -499,7 +503,8 @@ fn codegen_stmt<'tcx>(
|
||||||
UnOp::Neg => match layout.ty.kind() {
|
UnOp::Neg => match layout.ty.kind() {
|
||||||
ty::Int(IntTy::I128) => {
|
ty::Int(IntTy::I128) => {
|
||||||
// FIXME remove this case once ineg.i128 works
|
// FIXME remove this case once ineg.i128 works
|
||||||
let zero = CValue::const_val(fx, layout, ty::ScalarInt::null(layout.size));
|
let zero =
|
||||||
|
CValue::const_val(fx, layout, ty::ScalarInt::null(layout.size));
|
||||||
crate::num::codegen_int_binop(fx, BinOp::Sub, zero, operand)
|
crate::num::codegen_int_binop(fx, BinOp::Sub, zero, operand)
|
||||||
}
|
}
|
||||||
ty::Int(_) => CValue::by_val(fx.bcx.ins().ineg(val), layout),
|
ty::Int(_) => CValue::by_val(fx.bcx.ins().ineg(val), layout),
|
||||||
|
@ -509,7 +514,11 @@ fn codegen_stmt<'tcx>(
|
||||||
};
|
};
|
||||||
lval.write_cvalue(fx, res);
|
lval.write_cvalue(fx, res);
|
||||||
}
|
}
|
||||||
Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), ref operand, to_ty) => {
|
Rvalue::Cast(
|
||||||
|
CastKind::Pointer(PointerCast::ReifyFnPointer),
|
||||||
|
ref operand,
|
||||||
|
to_ty,
|
||||||
|
) => {
|
||||||
let from_ty = fx.monomorphize(operand.ty(&fx.mir.local_decls, fx.tcx));
|
let from_ty = fx.monomorphize(operand.ty(&fx.mir.local_decls, fx.tcx));
|
||||||
let to_layout = fx.layout_of(fx.monomorphize(to_ty));
|
let to_layout = fx.layout_of(fx.monomorphize(to_ty));
|
||||||
match *from_ty.kind() {
|
match *from_ty.kind() {
|
||||||
|
@ -530,9 +539,21 @@ fn codegen_stmt<'tcx>(
|
||||||
_ => bug!("Trying to ReifyFnPointer on non FnDef {:?}", from_ty),
|
_ => bug!("Trying to ReifyFnPointer on non FnDef {:?}", from_ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rvalue::Cast(CastKind::Pointer(PointerCast::UnsafeFnPointer), ref operand, to_ty)
|
Rvalue::Cast(
|
||||||
| Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), ref operand, to_ty)
|
CastKind::Pointer(PointerCast::UnsafeFnPointer),
|
||||||
| Rvalue::Cast(CastKind::Pointer(PointerCast::ArrayToPointer), ref operand, to_ty) => {
|
ref operand,
|
||||||
|
to_ty,
|
||||||
|
)
|
||||||
|
| Rvalue::Cast(
|
||||||
|
CastKind::Pointer(PointerCast::MutToConstPointer),
|
||||||
|
ref operand,
|
||||||
|
to_ty,
|
||||||
|
)
|
||||||
|
| Rvalue::Cast(
|
||||||
|
CastKind::Pointer(PointerCast::ArrayToPointer),
|
||||||
|
ref operand,
|
||||||
|
to_ty,
|
||||||
|
) => {
|
||||||
let to_layout = fx.layout_of(fx.monomorphize(to_ty));
|
let to_layout = fx.layout_of(fx.monomorphize(to_ty));
|
||||||
let operand = codegen_operand(fx, operand);
|
let operand = codegen_operand(fx, operand);
|
||||||
lval.write_cvalue(fx, operand.cast_pointer_to(to_layout));
|
lval.write_cvalue(fx, operand.cast_pointer_to(to_layout));
|
||||||
|
|
|
@ -26,15 +26,15 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks {
|
||||||
|
|
||||||
config.opts.cg.panic = Some(PanicStrategy::Abort);
|
config.opts.cg.panic = Some(PanicStrategy::Abort);
|
||||||
config.opts.debugging_opts.panic_abort_tests = true;
|
config.opts.debugging_opts.panic_abort_tests = true;
|
||||||
config.opts.maybe_sysroot = Some(
|
config.opts.maybe_sysroot = Some(config.opts.maybe_sysroot.clone().unwrap_or_else(|| {
|
||||||
config.opts.maybe_sysroot.clone().unwrap_or_else(
|
std::env::current_exe()
|
||||||
|| std::env::current_exe()
|
.unwrap()
|
||||||
.unwrap()
|
.parent()
|
||||||
.parent()
|
.unwrap()
|
||||||
.unwrap()
|
.parent()
|
||||||
.join("sysroot"),
|
.unwrap()
|
||||||
),
|
.to_owned()
|
||||||
);
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ pub(crate) fn type_min_max_value(
|
||||||
let min_msb = bcx.ins().iconst(types::I64, (min >> 64) as u64 as i64);
|
let min_msb = bcx.ins().iconst(types::I64, (min >> 64) as u64 as i64);
|
||||||
let min = bcx.ins().iconcat(min_lsb, min_msb);
|
let min = bcx.ins().iconcat(min_lsb, min_msb);
|
||||||
|
|
||||||
let max = i128::MIN as u128;
|
let max = i128::MAX as u128;
|
||||||
let max_lsb = bcx.ins().iconst(types::I64, max as u64 as i64);
|
let max_lsb = bcx.ins().iconst(types::I64, max as u64 as i64);
|
||||||
let max_msb = bcx.ins().iconst(types::I64, (max >> 64) as u64 as i64);
|
let max_msb = bcx.ins().iconst(types::I64, (max >> 64) as u64 as i64);
|
||||||
let max = bcx.ins().iconcat(max_lsb, max_msb);
|
let max = bcx.ins().iconcat(max_lsb, max_msb);
|
||||||
|
@ -364,7 +364,7 @@ impl<'tcx, M: Module> FunctionCx<'_, 'tcx, M> {
|
||||||
self.instance.subst_mir_and_normalize_erasing_regions(
|
self.instance.subst_mir_and_normalize_erasing_regions(
|
||||||
self.tcx,
|
self.tcx,
|
||||||
ty::ParamEnv::reveal_all(),
|
ty::ParamEnv::reveal_all(),
|
||||||
value
|
value,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,10 +163,7 @@ pub(crate) fn codegen_const_value<'tcx>(
|
||||||
assert!(!layout.is_unsized(), "sized const value");
|
assert!(!layout.is_unsized(), "sized const value");
|
||||||
|
|
||||||
if layout.is_zst() {
|
if layout.is_zst() {
|
||||||
return CValue::by_ref(
|
return CValue::by_ref(crate::Pointer::dangling(layout.align.pref), layout);
|
||||||
crate::Pointer::dangling(layout.align.pref),
|
|
||||||
layout,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match const_val {
|
match const_val {
|
||||||
|
@ -186,9 +183,7 @@ pub(crate) fn codegen_const_value<'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
match x {
|
match x {
|
||||||
Scalar::Int(int) => {
|
Scalar::Int(int) => CValue::const_val(fx, layout, int),
|
||||||
CValue::const_val(fx, layout, int)
|
|
||||||
}
|
|
||||||
Scalar::Ptr(ptr) => {
|
Scalar::Ptr(ptr) => {
|
||||||
let alloc_kind = fx.tcx.get_global_alloc(ptr.alloc_id);
|
let alloc_kind = fx.tcx.get_global_alloc(ptr.alloc_id);
|
||||||
let base_addr = match alloc_kind {
|
let base_addr = match alloc_kind {
|
||||||
|
|
|
@ -76,7 +76,7 @@ impl WriterRelocate {
|
||||||
#[cfg(feature = "jit")]
|
#[cfg(feature = "jit")]
|
||||||
pub(super) fn relocate_for_jit(
|
pub(super) fn relocate_for_jit(
|
||||||
mut self,
|
mut self,
|
||||||
jit_product: &cranelift_simplejit::SimpleJITProduct,
|
jit_module: &cranelift_simplejit::SimpleJITModule,
|
||||||
) -> Vec<u8> {
|
) -> Vec<u8> {
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
|
@ -84,8 +84,9 @@ impl WriterRelocate {
|
||||||
match reloc.name {
|
match reloc.name {
|
||||||
super::DebugRelocName::Section(_) => unreachable!(),
|
super::DebugRelocName::Section(_) => unreachable!(),
|
||||||
super::DebugRelocName::Symbol(sym) => {
|
super::DebugRelocName::Symbol(sym) => {
|
||||||
let addr = jit_product
|
let addr = jit_module.get_finalized_function(
|
||||||
.lookup_func(cranelift_module::FuncId::from_u32(sym.try_into().unwrap()));
|
cranelift_module::FuncId::from_u32(sym.try_into().unwrap()),
|
||||||
|
);
|
||||||
let val = (addr as u64 as i64 + reloc.addend) as u64;
|
let val = (addr as u64 as i64 + reloc.addend) as u64;
|
||||||
self.writer
|
self.writer
|
||||||
.write_udata_at(reloc.offset as usize, val, reloc.size)
|
.write_udata_at(reloc.offset as usize, val, reloc.size)
|
||||||
|
|
|
@ -80,7 +80,7 @@ impl<'tcx> UnwindContext<'tcx> {
|
||||||
#[cfg(feature = "jit")]
|
#[cfg(feature = "jit")]
|
||||||
pub(crate) unsafe fn register_jit(
|
pub(crate) unsafe fn register_jit(
|
||||||
self,
|
self,
|
||||||
jit_product: &cranelift_simplejit::SimpleJITProduct,
|
jit_module: &cranelift_simplejit::SimpleJITModule,
|
||||||
) -> Option<UnwindRegistry> {
|
) -> Option<UnwindRegistry> {
|
||||||
let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(
|
let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(
|
||||||
self.tcx,
|
self.tcx,
|
||||||
|
@ -91,7 +91,7 @@ impl<'tcx> UnwindContext<'tcx> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut eh_frame = eh_frame.0.relocate_for_jit(jit_product);
|
let mut eh_frame = eh_frame.0.relocate_for_jit(jit_module);
|
||||||
|
|
||||||
// GCC expects a terminating "empty" length, so write a 0 length at the end of the table.
|
// GCC expects a terminating "empty" length, so write a 0 length at the end of the table.
|
||||||
eh_frame.extend(&[0, 0, 0, 0]);
|
eh_frame.extend(&[0, 0, 0, 0]);
|
||||||
|
|
|
@ -30,8 +30,16 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
|
||||||
.ty
|
.ty
|
||||||
.discriminant_for_variant(fx.tcx, variant_index)
|
.discriminant_for_variant(fx.tcx, variant_index)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.val
|
.val;
|
||||||
.into();
|
let to = if ptr.layout().abi.is_signed() {
|
||||||
|
ty::ScalarInt::try_from_int(
|
||||||
|
ptr.layout().size.sign_extend(to) as i128,
|
||||||
|
ptr.layout().size,
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
} else {
|
||||||
|
ty::ScalarInt::try_from_uint(to, ptr.layout().size).unwrap()
|
||||||
|
};
|
||||||
let discr = CValue::const_val(fx, ptr.layout(), to);
|
let discr = CValue::const_val(fx, ptr.layout(), to);
|
||||||
ptr.write_cvalue(fx, discr);
|
ptr.write_cvalue(fx, discr);
|
||||||
}
|
}
|
||||||
|
@ -49,8 +57,12 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
|
||||||
if variant_index != dataful_variant {
|
if variant_index != dataful_variant {
|
||||||
let niche = place.place_field(fx, mir::Field::new(tag_field));
|
let niche = place.place_field(fx, mir::Field::new(tag_field));
|
||||||
let niche_value = variant_index.as_u32() - niche_variants.start().as_u32();
|
let niche_value = variant_index.as_u32() - niche_variants.start().as_u32();
|
||||||
let niche_value = u128::from(niche_value).wrapping_add(niche_start);
|
let niche_value = ty::ScalarInt::try_from_uint(
|
||||||
let niche_llval = CValue::const_val(fx, niche.layout(), niche_value.into());
|
u128::from(niche_value).wrapping_add(niche_start),
|
||||||
|
niche.layout().size,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let niche_llval = CValue::const_val(fx, niche.layout(), niche_value);
|
||||||
niche.write_cvalue(fx, niche_llval);
|
niche.write_cvalue(fx, niche_llval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +90,16 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
|
||||||
.ty
|
.ty
|
||||||
.discriminant_for_variant(fx.tcx, *index)
|
.discriminant_for_variant(fx.tcx, *index)
|
||||||
.map_or(u128::from(index.as_u32()), |discr| discr.val);
|
.map_or(u128::from(index.as_u32()), |discr| discr.val);
|
||||||
return CValue::const_val(fx, dest_layout, discr_val.into());
|
let discr_val = if dest_layout.abi.is_signed() {
|
||||||
|
ty::ScalarInt::try_from_int(
|
||||||
|
dest_layout.size.sign_extend(discr_val) as i128,
|
||||||
|
dest_layout.size,
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
} else {
|
||||||
|
ty::ScalarInt::try_from_uint(discr_val, dest_layout.size).unwrap()
|
||||||
|
};
|
||||||
|
return CValue::const_val(fx, dest_layout, discr_val);
|
||||||
}
|
}
|
||||||
Variants::Multiple {
|
Variants::Multiple {
|
||||||
tag,
|
tag,
|
||||||
|
|
|
@ -145,7 +145,11 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut cx = crate::CodegenCx::new(tcx, module, tcx.sess.opts.debuginfo != DebugInfo::None);
|
let mut cx = crate::CodegenCx::new(tcx, module, tcx.sess.opts.debuginfo != DebugInfo::None);
|
||||||
super::codegen_mono_items(&mut cx, mono_items);
|
super::predefine_mono_items(&mut cx, &mono_items);
|
||||||
|
for (mono_item, (linkage, visibility)) in mono_items {
|
||||||
|
let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility);
|
||||||
|
super::codegen_mono_item(&mut cx, mono_item, linkage);
|
||||||
|
}
|
||||||
let (mut module, global_asm, debug, mut unwind_context) =
|
let (mut module, global_asm, debug, mut unwind_context) =
|
||||||
tcx.sess.time("finalize CodegenCx", || cx.finalize());
|
tcx.sess.time("finalize CodegenCx", || cx.finalize());
|
||||||
crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context, false);
|
crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context, false);
|
||||||
|
|
|
@ -70,7 +70,11 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
|
||||||
|
|
||||||
let (mut jit_module, global_asm, _debug, mut unwind_context) =
|
let (mut jit_module, global_asm, _debug, mut unwind_context) =
|
||||||
super::time(tcx, "codegen mono items", || {
|
super::time(tcx, "codegen mono items", || {
|
||||||
super::codegen_mono_items(&mut cx, mono_items);
|
super::predefine_mono_items(&mut cx, &mono_items);
|
||||||
|
for (mono_item, (linkage, visibility)) in mono_items {
|
||||||
|
let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility);
|
||||||
|
super::codegen_mono_item(&mut cx, mono_item, linkage);
|
||||||
|
}
|
||||||
tcx.sess.time("finalize CodegenCx", || cx.finalize())
|
tcx.sess.time("finalize CodegenCx", || cx.finalize())
|
||||||
});
|
});
|
||||||
if !global_asm.is_empty() {
|
if !global_asm.is_empty() {
|
||||||
|
@ -81,11 +85,11 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
|
||||||
|
|
||||||
tcx.sess.abort_if_errors();
|
tcx.sess.abort_if_errors();
|
||||||
|
|
||||||
let jit_product = jit_module.finish();
|
jit_module.finalize_definitions();
|
||||||
|
|
||||||
let _unwind_register_guard = unsafe { unwind_context.register_jit(&jit_product) };
|
let _unwind_register_guard = unsafe { unwind_context.register_jit(&jit_module) };
|
||||||
|
|
||||||
let finalized_main: *const u8 = jit_product.lookup_func(main_func_id);
|
let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id);
|
||||||
|
|
||||||
println!("Rustc codegen cranelift will JIT run the executable, because --jit was passed");
|
println!("Rustc codegen cranelift will JIT run the executable, because --jit was passed");
|
||||||
|
|
||||||
|
@ -140,11 +144,11 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> {
|
||||||
|
|
||||||
let mut imported_symbols = Vec::new();
|
let mut imported_symbols = Vec::new();
|
||||||
for path in dylib_paths {
|
for path in dylib_paths {
|
||||||
use object::Object;
|
use object::{Object, ObjectSymbol};
|
||||||
let lib = libloading::Library::new(&path).unwrap();
|
let lib = libloading::Library::new(&path).unwrap();
|
||||||
let obj = std::fs::read(path).unwrap();
|
let obj = std::fs::read(path).unwrap();
|
||||||
let obj = object::File::parse(&obj).unwrap();
|
let obj = object::File::parse(&obj).unwrap();
|
||||||
imported_symbols.extend(obj.dynamic_symbols().filter_map(|(_idx, symbol)| {
|
imported_symbols.extend(obj.dynamic_symbols().filter_map(|symbol| {
|
||||||
let name = symbol.name().unwrap().to_string();
|
let name = symbol.name().unwrap().to_string();
|
||||||
if name.is_empty() || !symbol.is_global() || symbol.is_undefined() {
|
if name.is_empty() || !symbol.is_global() || symbol.is_undefined() {
|
||||||
return None;
|
return None;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! Drivers are responsible for calling [`codegen_mono_items`] and performing any further actions
|
//! Drivers are responsible for calling [`codegen_mono_item`] and performing any further actions
|
||||||
//! like JIT executing or writing object files.
|
//! like JIT executing or writing object files.
|
||||||
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
@ -40,12 +40,12 @@ pub(crate) fn codegen_crate(
|
||||||
aot::run_aot(tcx, metadata, need_metadata_module)
|
aot::run_aot(tcx, metadata, need_metadata_module)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn codegen_mono_items<'tcx>(
|
fn predefine_mono_items<'tcx>(
|
||||||
cx: &mut crate::CodegenCx<'tcx, impl Module>,
|
cx: &mut crate::CodegenCx<'tcx, impl Module>,
|
||||||
mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>,
|
mono_items: &[(MonoItem<'tcx>, (RLinkage, Visibility))],
|
||||||
) {
|
) {
|
||||||
cx.tcx.sess.time("predefine functions", || {
|
cx.tcx.sess.time("predefine functions", || {
|
||||||
for &(mono_item, (linkage, visibility)) in &mono_items {
|
for &(mono_item, (linkage, visibility)) in mono_items {
|
||||||
match mono_item {
|
match mono_item {
|
||||||
MonoItem::Fn(instance) => {
|
MonoItem::Fn(instance) => {
|
||||||
let (name, sig) = get_function_name_and_sig(
|
let (name, sig) = get_function_name_and_sig(
|
||||||
|
@ -61,11 +61,6 @@ fn codegen_mono_items<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (mono_item, (linkage, visibility)) in mono_items {
|
|
||||||
let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility);
|
|
||||||
codegen_mono_item(cx, mono_item, linkage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn codegen_mono_item<'tcx, M: Module>(
|
fn codegen_mono_item<'tcx, M: Module>(
|
||||||
|
@ -73,20 +68,15 @@ fn codegen_mono_item<'tcx, M: Module>(
|
||||||
mono_item: MonoItem<'tcx>,
|
mono_item: MonoItem<'tcx>,
|
||||||
linkage: Linkage,
|
linkage: Linkage,
|
||||||
) {
|
) {
|
||||||
let tcx = cx.tcx;
|
|
||||||
match mono_item {
|
match mono_item {
|
||||||
MonoItem::Fn(inst) => {
|
MonoItem::Fn(inst) => {
|
||||||
let _inst_guard =
|
cx.tcx
|
||||||
crate::PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name));
|
.sess
|
||||||
debug_assert!(!inst.substs.needs_infer());
|
|
||||||
tcx.sess
|
|
||||||
.time("codegen fn", || crate::base::codegen_fn(cx, inst, linkage));
|
.time("codegen fn", || crate::base::codegen_fn(cx, inst, linkage));
|
||||||
}
|
}
|
||||||
MonoItem::Static(def_id) => {
|
MonoItem::Static(def_id) => crate::constant::codegen_static(&mut cx.constants_cx, def_id),
|
||||||
crate::constant::codegen_static(&mut cx.constants_cx, def_id);
|
|
||||||
}
|
|
||||||
MonoItem::GlobalAsm(hir_id) => {
|
MonoItem::GlobalAsm(hir_id) => {
|
||||||
let item = tcx.hir().expect_item(hir_id);
|
let item = cx.tcx.hir().expect_item(hir_id);
|
||||||
if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind {
|
if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind {
|
||||||
cx.global_asm.push_str(&*asm.as_str());
|
cx.global_asm.push_str(&*asm.as_str());
|
||||||
cx.global_asm.push_str("\n\n");
|
cx.global_asm.push_str("\n\n");
|
||||||
|
|
|
@ -263,6 +263,48 @@ fn simd_pair_for_each_lane<'tcx, M: Module>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn simd_reduce<'tcx, M: Module>(
|
||||||
|
fx: &mut FunctionCx<'_, 'tcx, M>,
|
||||||
|
val: CValue<'tcx>,
|
||||||
|
ret: CPlace<'tcx>,
|
||||||
|
f: impl Fn(&mut FunctionCx<'_, 'tcx, M>, TyAndLayout<'tcx>, Value, Value) -> Value,
|
||||||
|
) {
|
||||||
|
let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, val.layout());
|
||||||
|
assert_eq!(lane_layout, ret.layout());
|
||||||
|
|
||||||
|
let mut res_val = val.value_field(fx, mir::Field::new(0)).load_scalar(fx);
|
||||||
|
for lane_idx in 1..lane_count {
|
||||||
|
let lane = val
|
||||||
|
.value_field(fx, mir::Field::new(lane_idx.into()))
|
||||||
|
.load_scalar(fx);
|
||||||
|
res_val = f(fx, lane_layout, res_val, lane);
|
||||||
|
}
|
||||||
|
let res = CValue::by_val(res_val, lane_layout);
|
||||||
|
ret.write_cvalue(fx, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn simd_reduce_bool<'tcx, M: Module>(
|
||||||
|
fx: &mut FunctionCx<'_, 'tcx, M>,
|
||||||
|
val: CValue<'tcx>,
|
||||||
|
ret: CPlace<'tcx>,
|
||||||
|
f: impl Fn(&mut FunctionCx<'_, 'tcx, M>, Value, Value) -> Value,
|
||||||
|
) {
|
||||||
|
let (_lane_layout, lane_count) = lane_type_and_count(fx.tcx, val.layout());
|
||||||
|
assert!(ret.layout().ty.is_bool());
|
||||||
|
|
||||||
|
let res_val = val.value_field(fx, mir::Field::new(0)).load_scalar(fx);
|
||||||
|
let mut res_val = fx.bcx.ins().band_imm(res_val, 1); // mask to boolean
|
||||||
|
for lane_idx in 1..lane_count {
|
||||||
|
let lane = val
|
||||||
|
.value_field(fx, mir::Field::new(lane_idx.into()))
|
||||||
|
.load_scalar(fx);
|
||||||
|
let lane = fx.bcx.ins().band_imm(lane, 1); // mask to boolean
|
||||||
|
res_val = f(fx, res_val, lane);
|
||||||
|
}
|
||||||
|
let res = CValue::by_val(res_val, ret.layout());
|
||||||
|
ret.write_cvalue(fx, res);
|
||||||
|
}
|
||||||
|
|
||||||
fn bool_to_zero_or_max_uint<'tcx>(
|
fn bool_to_zero_or_max_uint<'tcx>(
|
||||||
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
|
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
|
||||||
layout: TyAndLayout<'tcx>,
|
layout: TyAndLayout<'tcx>,
|
||||||
|
@ -287,7 +329,7 @@ fn bool_to_zero_or_max_uint<'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
macro simd_cmp {
|
macro simd_cmp {
|
||||||
($fx:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => {
|
($fx:expr, $cc:ident|$cc_f:ident($x:ident, $y:ident) -> $ret:ident) => {
|
||||||
let vector_ty = clif_vector_type($fx.tcx, $x.layout());
|
let vector_ty = clif_vector_type($fx.tcx, $x.layout());
|
||||||
|
|
||||||
if let Some(vector_ty) = vector_ty {
|
if let Some(vector_ty) = vector_ty {
|
||||||
|
@ -308,6 +350,7 @@ macro simd_cmp {
|
||||||
|fx, lane_layout, res_lane_layout, x_lane, y_lane| {
|
|fx, lane_layout, res_lane_layout, x_lane, y_lane| {
|
||||||
let res_lane = match lane_layout.ty.kind() {
|
let res_lane = match lane_layout.ty.kind() {
|
||||||
ty::Uint(_) | ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc, x_lane, y_lane),
|
ty::Uint(_) | ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc, x_lane, y_lane),
|
||||||
|
ty::Float(_) => fx.bcx.ins().fcmp(FloatCC::$cc_f, x_lane, y_lane),
|
||||||
_ => unreachable!("{:?}", lane_layout.ty),
|
_ => unreachable!("{:?}", lane_layout.ty),
|
||||||
};
|
};
|
||||||
bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane)
|
bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane)
|
||||||
|
@ -315,7 +358,7 @@ macro simd_cmp {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
($fx:expr, $cc_u:ident|$cc_s:ident($x:ident, $y:ident) -> $ret:ident) => {
|
($fx:expr, $cc_u:ident|$cc_s:ident|$cc_f:ident($x:ident, $y:ident) -> $ret:ident) => {
|
||||||
// FIXME use vector icmp when possible
|
// FIXME use vector icmp when possible
|
||||||
simd_pair_for_each_lane(
|
simd_pair_for_each_lane(
|
||||||
$fx,
|
$fx,
|
||||||
|
@ -326,6 +369,7 @@ macro simd_cmp {
|
||||||
let res_lane = match lane_layout.ty.kind() {
|
let res_lane = match lane_layout.ty.kind() {
|
||||||
ty::Uint(_) => fx.bcx.ins().icmp(IntCC::$cc_u, x_lane, y_lane),
|
ty::Uint(_) => fx.bcx.ins().icmp(IntCC::$cc_u, x_lane, y_lane),
|
||||||
ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc_s, x_lane, y_lane),
|
ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc_s, x_lane, y_lane),
|
||||||
|
ty::Float(_) => fx.bcx.ins().fcmp(FloatCC::$cc_f, x_lane, y_lane),
|
||||||
_ => unreachable!("{:?}", lane_layout.ty),
|
_ => unreachable!("{:?}", lane_layout.ty),
|
||||||
};
|
};
|
||||||
bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane)
|
bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane)
|
||||||
|
@ -497,12 +541,12 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
|
||||||
};
|
};
|
||||||
copy | copy_nonoverlapping, <elem_ty> (v src, v dst, v count) {
|
copy | copy_nonoverlapping, <elem_ty> (v src, v dst, v count) {
|
||||||
let elem_size: u64 = fx.layout_of(elem_ty).size.bytes();
|
let elem_size: u64 = fx.layout_of(elem_ty).size.bytes();
|
||||||
let elem_size = fx
|
|
||||||
.bcx
|
|
||||||
.ins()
|
|
||||||
.iconst(fx.pointer_type, elem_size as i64);
|
|
||||||
assert_eq!(args.len(), 3);
|
assert_eq!(args.len(), 3);
|
||||||
let byte_amount = fx.bcx.ins().imul(count, elem_size);
|
let byte_amount = if elem_size != 1 {
|
||||||
|
fx.bcx.ins().imul_imm(count, elem_size as i64)
|
||||||
|
} else {
|
||||||
|
count
|
||||||
|
};
|
||||||
|
|
||||||
if intrinsic.contains("nonoverlapping") {
|
if intrinsic.contains("nonoverlapping") {
|
||||||
// FIXME emit_small_memcpy
|
// FIXME emit_small_memcpy
|
||||||
|
@ -515,12 +559,12 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
|
||||||
// NOTE: the volatile variants have src and dst swapped
|
// NOTE: the volatile variants have src and dst swapped
|
||||||
volatile_copy_memory | volatile_copy_nonoverlapping_memory, <elem_ty> (v dst, v src, v count) {
|
volatile_copy_memory | volatile_copy_nonoverlapping_memory, <elem_ty> (v dst, v src, v count) {
|
||||||
let elem_size: u64 = fx.layout_of(elem_ty).size.bytes();
|
let elem_size: u64 = fx.layout_of(elem_ty).size.bytes();
|
||||||
let elem_size = fx
|
|
||||||
.bcx
|
|
||||||
.ins()
|
|
||||||
.iconst(fx.pointer_type, elem_size as i64);
|
|
||||||
assert_eq!(args.len(), 3);
|
assert_eq!(args.len(), 3);
|
||||||
let byte_amount = fx.bcx.ins().imul(count, elem_size);
|
let byte_amount = if elem_size != 1 {
|
||||||
|
fx.bcx.ins().imul_imm(count, elem_size as i64)
|
||||||
|
} else {
|
||||||
|
count
|
||||||
|
};
|
||||||
|
|
||||||
// FIXME make the copy actually volatile when using emit_small_mem{cpy,move}
|
// FIXME make the copy actually volatile when using emit_small_mem{cpy,move}
|
||||||
if intrinsic.contains("nonoverlapping") {
|
if intrinsic.contains("nonoverlapping") {
|
||||||
|
@ -676,7 +720,11 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
|
||||||
offset | arith_offset, (c base, v offset) {
|
offset | arith_offset, (c base, v offset) {
|
||||||
let pointee_ty = base.layout().ty.builtin_deref(true).unwrap().ty;
|
let pointee_ty = base.layout().ty.builtin_deref(true).unwrap().ty;
|
||||||
let pointee_size = fx.layout_of(pointee_ty).size.bytes();
|
let pointee_size = fx.layout_of(pointee_ty).size.bytes();
|
||||||
let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64);
|
let ptr_diff = if pointee_size != 1 {
|
||||||
|
fx.bcx.ins().imul_imm(offset, pointee_size as i64)
|
||||||
|
} else {
|
||||||
|
offset
|
||||||
|
};
|
||||||
let base_val = base.load_scalar(fx);
|
let base_val = base.load_scalar(fx);
|
||||||
let res = fx.bcx.ins().iadd(base_val, ptr_diff);
|
let res = fx.bcx.ins().iadd(base_val, ptr_diff);
|
||||||
ret.write_cvalue(fx, CValue::by_val(res, base.layout()));
|
ret.write_cvalue(fx, CValue::by_val(res, base.layout()));
|
||||||
|
@ -688,7 +736,11 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
|
||||||
write_bytes | volatile_set_memory, (c dst, v val, v count) {
|
write_bytes | volatile_set_memory, (c dst, v val, v count) {
|
||||||
let pointee_ty = dst.layout().ty.builtin_deref(true).unwrap().ty;
|
let pointee_ty = dst.layout().ty.builtin_deref(true).unwrap().ty;
|
||||||
let pointee_size = fx.layout_of(pointee_ty).size.bytes();
|
let pointee_size = fx.layout_of(pointee_ty).size.bytes();
|
||||||
let count = fx.bcx.ins().imul_imm(count, pointee_size as i64);
|
let count = if pointee_size != 1 {
|
||||||
|
fx.bcx.ins().imul_imm(count, pointee_size as i64)
|
||||||
|
} else {
|
||||||
|
count
|
||||||
|
};
|
||||||
let dst_ptr = dst.load_scalar(fx);
|
let dst_ptr = dst.load_scalar(fx);
|
||||||
// FIXME make the memset actually volatile when switching to emit_small_memset
|
// FIXME make the memset actually volatile when switching to emit_small_memset
|
||||||
// FIXME use emit_small_memset
|
// FIXME use emit_small_memset
|
||||||
|
|
|
@ -35,30 +35,33 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME support float comparisons
|
|
||||||
simd_eq, (c x, c y) {
|
simd_eq, (c x, c y) {
|
||||||
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
||||||
simd_cmp!(fx, Equal(x, y) -> ret);
|
simd_cmp!(fx, Equal|Equal(x, y) -> ret);
|
||||||
};
|
};
|
||||||
simd_ne, (c x, c y) {
|
simd_ne, (c x, c y) {
|
||||||
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
||||||
simd_cmp!(fx, NotEqual(x, y) -> ret);
|
simd_cmp!(fx, NotEqual|NotEqual(x, y) -> ret);
|
||||||
};
|
};
|
||||||
simd_lt, (c x, c y) {
|
simd_lt, (c x, c y) {
|
||||||
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
||||||
simd_cmp!(fx, UnsignedLessThan|SignedLessThan(x, y) -> ret);
|
simd_cmp!(fx, UnsignedLessThan|SignedLessThan|LessThan(x, y) -> ret);
|
||||||
};
|
};
|
||||||
simd_le, (c x, c y) {
|
simd_le, (c x, c y) {
|
||||||
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
||||||
simd_cmp!(fx, UnsignedLessThanOrEqual|SignedLessThanOrEqual(x, y) -> ret);
|
simd_cmp!(fx, UnsignedLessThanOrEqual|SignedLessThanOrEqual|LessThanOrEqual(x, y) -> ret);
|
||||||
};
|
};
|
||||||
simd_gt, (c x, c y) {
|
simd_gt, (c x, c y) {
|
||||||
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
||||||
simd_cmp!(fx, UnsignedGreaterThan|SignedGreaterThan(x, y) -> ret);
|
simd_cmp!(fx, UnsignedGreaterThan|SignedGreaterThan|GreaterThan(x, y) -> ret);
|
||||||
};
|
};
|
||||||
simd_ge, (c x, c y) {
|
simd_ge, (c x, c y) {
|
||||||
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
validate_simd_type!(fx, intrinsic, span, x.layout().ty);
|
||||||
simd_cmp!(fx, UnsignedGreaterThanOrEqual|SignedGreaterThanOrEqual(x, y) -> ret);
|
simd_cmp!(
|
||||||
|
fx,
|
||||||
|
UnsignedGreaterThanOrEqual|SignedGreaterThanOrEqual|GreaterThanOrEqual
|
||||||
|
(x, y) -> ret
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// simd_shuffle32<T, U>(x: T, y: T, idx: [u32; 32]) -> U
|
// simd_shuffle32<T, U>(x: T, y: T, idx: [u32; 32]) -> U
|
||||||
|
@ -107,9 +110,9 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||||
|
|
||||||
for (out_idx, in_idx) in indexes.into_iter().enumerate() {
|
for (out_idx, in_idx) in indexes.into_iter().enumerate() {
|
||||||
let in_lane = if in_idx < lane_count {
|
let in_lane = if in_idx < lane_count {
|
||||||
x.value_field(fx, mir::Field::new(in_idx.try_into().unwrap()))
|
x.value_field(fx, mir::Field::new(in_idx.into()))
|
||||||
} else {
|
} else {
|
||||||
y.value_field(fx, mir::Field::new((in_idx - lane_count).try_into().unwrap()))
|
y.value_field(fx, mir::Field::new((in_idx - lane_count).into()))
|
||||||
};
|
};
|
||||||
let out_lane = ret.place_field(fx, mir::Field::new(out_idx));
|
let out_lane = ret.place_field(fx, mir::Field::new(out_idx));
|
||||||
out_lane.write_cvalue(fx, in_lane);
|
out_lane.write_cvalue(fx, in_lane);
|
||||||
|
@ -143,10 +146,17 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||||
let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) {
|
let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) {
|
||||||
idx_const
|
idx_const
|
||||||
} else {
|
} else {
|
||||||
fx.tcx.sess.span_fatal(
|
fx.tcx.sess.span_warn(
|
||||||
span,
|
span,
|
||||||
"Index argument for `simd_extract` is not a constant",
|
"Index argument for `simd_extract` is not a constant",
|
||||||
);
|
);
|
||||||
|
let res = crate::trap::trap_unimplemented_ret_value(
|
||||||
|
fx,
|
||||||
|
ret.layout(),
|
||||||
|
"Index argument for `simd_extract` is not a constant",
|
||||||
|
);
|
||||||
|
ret.write_cvalue(fx, res);
|
||||||
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const));
|
let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const));
|
||||||
|
@ -207,7 +217,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||||
assert_eq!(lane_count, ret_lane_count);
|
assert_eq!(lane_count, ret_lane_count);
|
||||||
|
|
||||||
for lane in 0..lane_count {
|
for lane in 0..lane_count {
|
||||||
let lane = mir::Field::new(lane.try_into().unwrap());
|
let lane = mir::Field::new(lane.into());
|
||||||
let a_lane = a.value_field(fx, lane).load_scalar(fx);
|
let a_lane = a.value_field(fx, lane).load_scalar(fx);
|
||||||
let b_lane = b.value_field(fx, lane).load_scalar(fx);
|
let b_lane = b.value_field(fx, lane).load_scalar(fx);
|
||||||
let c_lane = c.value_field(fx, lane).load_scalar(fx);
|
let c_lane = c.value_field(fx, lane).load_scalar(fx);
|
||||||
|
@ -228,11 +238,42 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||||
simd_flt_binop!(fx, fmax(x, y) -> ret);
|
simd_flt_binop!(fx, fmax(x, y) -> ret);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
simd_reduce_add_ordered | simd_reduce_add_unordered, (c v) {
|
||||||
|
validate_simd_type!(fx, intrinsic, span, v.layout().ty);
|
||||||
|
simd_reduce(fx, v, ret, |fx, lane_layout, a, b| {
|
||||||
|
if lane_layout.ty.is_floating_point() {
|
||||||
|
fx.bcx.ins().fadd(a, b)
|
||||||
|
} else {
|
||||||
|
fx.bcx.ins().iadd(a, b)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
simd_reduce_mul_ordered | simd_reduce_mul_unordered, (c v) {
|
||||||
|
validate_simd_type!(fx, intrinsic, span, v.layout().ty);
|
||||||
|
simd_reduce(fx, v, ret, |fx, lane_layout, a, b| {
|
||||||
|
if lane_layout.ty.is_floating_point() {
|
||||||
|
fx.bcx.ins().fmul(a, b)
|
||||||
|
} else {
|
||||||
|
fx.bcx.ins().imul(a, b)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
simd_reduce_all, (c v) {
|
||||||
|
validate_simd_type!(fx, intrinsic, span, v.layout().ty);
|
||||||
|
simd_reduce_bool(fx, v, ret, |fx, a, b| fx.bcx.ins().band(a, b));
|
||||||
|
};
|
||||||
|
|
||||||
|
simd_reduce_any, (c v) {
|
||||||
|
validate_simd_type!(fx, intrinsic, span, v.layout().ty);
|
||||||
|
simd_reduce_bool(fx, v, ret, |fx, a, b| fx.bcx.ins().bor(a, b));
|
||||||
|
};
|
||||||
|
|
||||||
// simd_fabs
|
// simd_fabs
|
||||||
// simd_saturating_add
|
// simd_saturating_add
|
||||||
// simd_bitmask
|
// simd_bitmask
|
||||||
// simd_select
|
// simd_select
|
||||||
// simd_reduce_add_{,un}ordered
|
|
||||||
// simd_rem
|
// simd_rem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,3 +67,15 @@ pub(crate) fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl Module>, msg:
|
||||||
let true_ = fx.bcx.ins().iconst(types::I32, 1);
|
let true_ = fx.bcx.ins().iconst(types::I32, 1);
|
||||||
fx.bcx.ins().trapnz(true_, TrapCode::User(!0));
|
fx.bcx.ins().trapnz(true_, TrapCode::User(!0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Like `trap_unimplemented` but returns a fake value of the specified type.
|
||||||
|
///
|
||||||
|
/// Trap code: user65535
|
||||||
|
pub(crate) fn trap_unimplemented_ret_value<'tcx>(
|
||||||
|
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
|
||||||
|
dest_layout: TyAndLayout<'tcx>,
|
||||||
|
msg: impl AsRef<str>,
|
||||||
|
) -> CValue<'tcx> {
|
||||||
|
trap_unimplemented(fx, msg);
|
||||||
|
CValue::by_ref(Pointer::const_addr(fx, 0), dest_layout)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue