diff options
Diffstat (limited to 'compiler/rustc_codegen_gcc')
139 files changed, 36248 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_gcc/.cspell.json b/compiler/rustc_codegen_gcc/.cspell.json new file mode 100644 index 00000000000..388ccce2b09 --- /dev/null +++ b/compiler/rustc_codegen_gcc/.cspell.json @@ -0,0 +1,27 @@ +{ + "allowCompoundWords": true, + "dictionaries": ["cpp", "rust-extra", "rustc_codegen_gcc"], + "dictionaryDefinitions": [ + { + "name": "rust-extra", + "path": "tools/cspell_dicts/rust.txt", + "addWords": true + }, + { + "name": "rustc_codegen_gcc", + "path": "tools/cspell_dicts/rustc_codegen_gcc.txt", + "addWords": true + } + ], + "files": [ + "src/**/*.rs" + ], + "ignorePaths": [ + "src/intrinsic/archs.rs", + "src/intrinsic/llvm.rs" + ], + "ignoreRegExpList": [ + "/(FIXME|NOTE|TODO)\\([^)]+\\)/", + "__builtin_\\w*" + ] +} diff --git a/compiler/rustc_codegen_gcc/.gitattributes b/compiler/rustc_codegen_gcc/.gitattributes new file mode 100644 index 00000000000..b9cd1111c8d --- /dev/null +++ b/compiler/rustc_codegen_gcc/.gitattributes @@ -0,0 +1 @@ +Cargo.lock linguist-generated=false \ No newline at end of file diff --git a/compiler/rustc_codegen_gcc/.github/workflows/ci.yml b/compiler/rustc_codegen_gcc/.github/workflows/ci.yml new file mode 100644 index 00000000000..5c8e7d62816 --- /dev/null +++ b/compiler/rustc_codegen_gcc/.github/workflows/ci.yml @@ -0,0 +1,159 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + +permissions: + contents: read + +env: + # Enable backtraces for easier debugging + RUST_BACKTRACE: 1 + # For the run-make tests. + LLVM_BIN_DIR: /usr/bin + +jobs: + build: + runs-on: ubuntu-24.04 + + strategy: + fail-fast: false + matrix: + libgccjit_version: + - { gcc: "gcc-15.deb" } + - { gcc: "gcc-15-without-int128.deb" } + commands: [ + "--std-tests", + # FIXME: re-enable asm tests when GCC can emit in the right syntax. + # "--asm-tests", + "--test-libcore", + "--extended-rand-tests", + "--extended-regex-example-tests", + "--extended-regex-tests", + "--test-successful-rustc --nb-parts 2 --current-part 0", + "--test-successful-rustc --nb-parts 2 --current-part 1", + "--projects", + ] + + steps: + - uses: actions/checkout@v4 + + # `rustup show` installs from rust-toolchain.toml + - name: Setup rust toolchain + run: rustup show + + - name: Setup rust cache + uses: Swatinem/rust-cache@v2 + + - name: Install packages + # `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests. + run: sudo apt-get install ninja-build ripgrep llvm-14-tools llvm + + - name: Install rustfmt & clippy + run: rustup component add rustfmt clippy + + - name: Download artifact + run: curl -LO https://github.com/rust-lang/gcc/releases/latest/download/${{ matrix.libgccjit_version.gcc }} + + - name: Setup path to libgccjit + run: | + sudo dpkg --force-overwrite -i ${{ matrix.libgccjit_version.gcc }} + echo 'gcc-path = "/usr/lib/"' > config.toml + + # Some run-make tests fail if we use our forked GCC because it doesn't + # bundle libstdc++, so we switch to gcc-14 to have a GCC that has + # libstdc++. + - name: Set default GCC to gcc-14 + run: sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-14 30 + + - name: Set env + run: | + echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV + + #- name: Cache rust repository + ## We only clone the rust repository for rustc tests + #if: ${{ contains(matrix.commands, 'rustc') }} + #uses: actions/cache@v3 + #id: cache-rust-repository + #with: + #path: rust + #key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }} + + - name: Prepare + run: ./y.sh prepare --only-libcore + + - name: Check formatting + run: ./y.sh fmt --check + + - name: clippy + run: | + cargo clippy --all-targets -- -D warnings + cargo clippy --all-targets --no-default-features -- -D warnings + cargo clippy --manifest-path build_system/Cargo.toml --all-targets -- -D warnings + + - name: Build + run: | + ./y.sh build --sysroot + ./y.sh test --cargo-tests + + - name: Run y.sh cargo build + run: | + ./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml + + - name: Clean + run: | + ./y.sh clean all + + - name: Prepare dependencies + run: | + git config --global user.email "user@example.com" + git config --global user.name "User" + ./y.sh prepare + + - name: Run tests + run: | + ./y.sh test --release --clean --build-sysroot ${{ matrix.commands }} + + duplicates: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - run: python tools/check_intrinsics_duplicates.py + + spell_check: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@v1.32.0 + - uses: streetsidesoftware/cspell-action@v7 + + build_system: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Test build system + run: | + cd build_system + cargo test + + # Summary job for the merge queue. + # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! + success: + needs: [build, duplicates, build_system] + # We need to ensure this job does *not* get skipped if its dependencies fail, + # because a skipped job is considered a success by GitHub. So we have to + # overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run + # when the workflow is canceled manually. + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + steps: + # Manually check the status of all dependencies. `if: failure()` does not work. + - name: Conclusion + run: | + # Print the dependent jobs to see them in the CI log + jq -C <<< '${{ toJson(needs) }}' + # Check if all jobs that we depend on (in the needs array) were successful. + jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' diff --git a/compiler/rustc_codegen_gcc/.github/workflows/failures.yml b/compiler/rustc_codegen_gcc/.github/workflows/failures.yml new file mode 100644 index 00000000000..67b7fbe4478 --- /dev/null +++ b/compiler/rustc_codegen_gcc/.github/workflows/failures.yml @@ -0,0 +1,132 @@ +# TODO: refactor to avoid duplication with the ci.yml file. +name: Failures + +on: + push: + branches: + - master + pull_request: + +permissions: + contents: read + +env: + # Enable backtraces for easier debugging + RUST_BACKTRACE: 1 + +jobs: + build: + runs-on: ubuntu-24.04 + + strategy: + fail-fast: false + matrix: + libgccjit_version: + - gcc: "libgccjit.so" + artifacts_branch: "master" + - gcc: "libgccjit_without_int128.so" + artifacts_branch: "master-without-128bit-integers" + - gcc: "libgccjit12.so" + artifacts_branch: "gcc12" + extra: "--no-default-features" + # FIXME(antoyo): we need to set GCC_EXEC_PREFIX so that the linker can find the linker plugin. + # Not sure why it's not found otherwise. + env_extra: "TEST_FLAGS='-Cpanic=abort -Zpanic-abort-tests' GCC_EXEC_PREFIX=/usr/lib/gcc/" + + steps: + - uses: actions/checkout@v4 + + # `rustup show` installs from rust-toolchain.toml + - name: Setup rust toolchain + run: rustup show + + - name: Setup rust cache + uses: Swatinem/rust-cache@v2 + + - name: Install packages + run: sudo apt-get install ninja-build ripgrep + + - name: Install libgccjit12 + if: matrix.libgccjit_version.gcc == 'libgccjit12.so' + run: sudo apt-get install libgccjit-12-dev + + - name: Setup path to libgccjit + if: matrix.libgccjit_version.gcc == 'libgccjit12.so' + run: | + echo 'gcc-path = "/usr/lib/gcc/x86_64-linux-gnu/12"' > config.toml + echo "LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV + + - name: Download artifact + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + run: curl -LO https://github.com/rust-lang/gcc/releases/latest/download/gcc-15.deb + + - name: Setup path to libgccjit + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + run: | + sudo dpkg --force-overwrite -i gcc-15.deb + echo 'gcc-path = "/usr/lib"' > config.toml + + + + - name: Set env + run: | + echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV + + #- name: Cache rust repository + #uses: actions/cache@v3 + #id: cache-rust-repository + #with: + #path: rust + #key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }} + + - name: Git config + run: | + git config --global user.email "user@example.com" + git config --global user.name "User" + + - name: Prepare dependencies + if: matrix.libgccjit_version.gcc == 'libgccjit12.so' + run: ./y.sh prepare --libgccjit12-patches + + - name: Prepare dependencies + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + run: ./y.sh prepare + + - name: Run tests + # TODO: re-enable those tests for libgccjit 12. + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + id: tests + run: | + ${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-rustc ${{ matrix.libgccjit_version.extra }} 2>&1 | tee output_log + rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY + + - name: Run failing ui pattern tests for ICE + # TODO: re-enable those tests for libgccjit 12. + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + id: ui-tests + run: | + ${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --test-failing-ui-pattern-tests ${{ matrix.libgccjit_version.extra }} 2>&1 | tee output_log_ui + if grep -q "the compiler unexpectedly panicked" output_log_ui; then + echo "Error: 'the compiler unexpectedly panicked' found in output logs. CI Error!!" + exit 1 + fi + + # Summary job for the merge queue. + # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! + success_failures: + needs: [build] + # We need to ensure this job does *not* get skipped if its dependencies fail, + # because a skipped job is considered a success by GitHub. So we have to + # overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run + # when the workflow is canceled manually. + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + steps: + # Manually check the status of all dependencies. `if: failure()` does not work. + - name: Conclusion + run: | + # Print the dependent jobs to see them in the CI log + jq -C <<< '${{ toJson(needs) }}' + # Check if all jobs that we depend on (in the needs array) were successful. + jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' diff --git a/compiler/rustc_codegen_gcc/.github/workflows/gcc12.yml b/compiler/rustc_codegen_gcc/.github/workflows/gcc12.yml new file mode 100644 index 00000000000..da9a1506855 --- /dev/null +++ b/compiler/rustc_codegen_gcc/.github/workflows/gcc12.yml @@ -0,0 +1,108 @@ +name: CI libgccjit 12 + +on: + push: + branches: + - master + pull_request: + +permissions: + contents: read + +env: + # Enable backtraces for easier debugging + RUST_BACKTRACE: 1 + TEST_FLAGS: "-Cpanic=abort -Zpanic-abort-tests" + # FIXME(antoyo): we need to set GCC_EXEC_PREFIX so that the linker can find the linker plugin. + # Not sure why it's not found otherwise. + GCC_EXEC_PREFIX: /usr/lib/gcc/ + +jobs: + build: + runs-on: ubuntu-24.04 + + strategy: + fail-fast: false + matrix: + commands: [ + "--mini-tests", + "--std-tests", + # FIXME: re-enable asm tests when GCC can emit in the right syntax. + # "--asm-tests", + "--test-libcore", + "--test-successful-rustc --nb-parts 2 --current-part 0", + "--test-successful-rustc --nb-parts 2 --current-part 1", + ] + + steps: + - uses: actions/checkout@v4 + + # `rustup show` installs from rust-toolchain.toml + - name: Setup rust toolchain + run: rustup show + + - name: Setup rust cache + uses: Swatinem/rust-cache@v2 + + - name: Install packages + # `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests. + run: sudo apt-get install ninja-build ripgrep llvm-14-tools libgccjit-12-dev + + - name: Setup path to libgccjit + run: echo 'gcc-path = "/usr/lib/gcc/x86_64-linux-gnu/12"' > config.toml + + - name: Set env + run: | + echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV + echo "LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV + + #- name: Cache rust repository + ## We only clone the rust repository for rustc tests + #if: ${{ contains(matrix.commands, 'rustc') }} + #uses: actions/cache@v3 + #id: cache-rust-repository + #with: + #path: rust + #key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }} + + - name: Build + run: | + ./y.sh prepare --only-libcore --libgccjit12-patches + ./y.sh build --no-default-features --sysroot-panic-abort + # Uncomment when we no longer need to remove global variables. + #./y.sh build --sysroot --no-default-features --sysroot-panic-abort + #cargo test --no-default-features + #./y.sh clean all + + #- name: Prepare dependencies + #run: | + #git config --global user.email "user@example.com" + #git config --global user.name "User" + #./y.sh prepare --libgccjit12-patches + + #- name: Add more failing tests for GCC 12 + #run: cat tests/failing-ui-tests12.txt >> tests/failing-ui-tests.txt + + #- name: Run tests + #run: | + #./y.sh test --release --clean --build-sysroot ${{ matrix.commands }} --no-default-features + + # Summary job for the merge queue. + # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! + success_gcc12: + needs: [build] + # We need to ensure this job does *not* get skipped if its dependencies fail, + # because a skipped job is considered a success by GitHub. So we have to + # overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run + # when the workflow is canceled manually. + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + steps: + # Manually check the status of all dependencies. `if: failure()` does not work. + - name: Conclusion + run: | + # Print the dependent jobs to see them in the CI log + jq -C <<< '${{ toJson(needs) }}' + # Check if all jobs that we depend on (in the needs array) were successful. + jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' diff --git a/compiler/rustc_codegen_gcc/.github/workflows/m68k.yml b/compiler/rustc_codegen_gcc/.github/workflows/m68k.yml new file mode 100644 index 00000000000..759d0d59e26 --- /dev/null +++ b/compiler/rustc_codegen_gcc/.github/workflows/m68k.yml @@ -0,0 +1,142 @@ +# TODO: check if qemu-user-static-binfmt is needed (perhaps to run some tests since it probably calls exec). + +name: m68k CI + +on: + push: + branches: + - master + pull_request: + +permissions: + contents: read + +env: + # Enable backtraces for easier debugging + RUST_BACKTRACE: 1 + +jobs: + build: + runs-on: ubuntu-24.04 + + strategy: + fail-fast: false + matrix: + commands: [ + "--std-tests", + # TODO(antoyo): fix those on m68k. + #"--test-libcore", + #"--extended-rand-tests", + #"--extended-regex-example-tests", + #"--extended-regex-tests", + #"--test-successful-rustc --nb-parts 2 --current-part 0", + #"--test-successful-rustc --nb-parts 2 --current-part 1", + #"--test-failing-rustc", + ] + + steps: + - uses: actions/checkout@v4 + + # `rustup show` installs from rust-toolchain.toml + - name: Setup rust toolchain + run: rustup show + + - name: Setup rust cache + uses: Swatinem/rust-cache@v2 + + - name: Install packages + run: | + sudo apt-get update + sudo apt-get install qemu-system qemu-user-static + + - name: Download artifact + run: curl -LO https://github.com/cross-cg-gcc-tools/cross-gcc/releases/latest/download/gcc-m68k-15.deb + + - name: Download VM artifact + run: curl -LO https://github.com/cross-cg-gcc-tools/vms/releases/latest/download/debian-m68k.img + + - name: Setup path to libgccjit + run: | + sudo dpkg --force-overwrite -i gcc-m68k-15.deb + echo 'gcc-path = "/usr/lib/"' > config.toml + + - name: Set env + run: | + echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV + + #- name: Cache rust repository + ## We only clone the rust repository for rustc tests + #if: ${{ contains(matrix.commands, 'rustc') }} + #uses: actions/cache@v3 + #id: cache-rust-repository + #with: + #path: rust + #key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }} + + - name: Prepare VM + run: | + mkdir vm + sudo mount debian-m68k.img vm + sudo cp $(which qemu-m68k-static) vm/usr/bin/ + + - name: Build sample project with target defined as JSON spec + run: | + ./y.sh prepare --only-libcore --cross + ./y.sh build --sysroot --features compiler-builtins-no-f16-f128 --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json + CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ./y.sh cargo build --manifest-path=./tests/hello-world/Cargo.toml --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json + ./y.sh clean all + + - name: Build + run: | + ./y.sh prepare --only-libcore --cross + ./y.sh build --sysroot --features compiler-builtins-no-f16-f128 --target-triple m68k-unknown-linux-gnu + ./y.sh test --mini-tests --target-triple m68k-unknown-linux-gnu + # FIXME: since https://github.com/rust-lang/rust/pull/140809, we cannot run programs for architectures not + # supported by the object crate, since this adds a dependency on symbols.o for the panic runtime. + # And as such, a wrong order of the object files in the linker command now fails with an undefined reference + # to some symbols like __rustc::rust_panic. + #CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu ./y.sh test --cargo-tests --target-triple m68k-unknown-linux-gnu + ./y.sh clean all + + - name: Prepare dependencies + run: | + git config --global user.email "user@example.com" + git config --global user.name "User" + ./y.sh prepare --cross + + # FIXME: We cannot run programs for architectures not supported by the object crate. See comment above. + #- name: Run tests + #run: | + #./y.sh test --target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot --sysroot-features compiler-builtins-no-f16-f128 ${{ matrix.commands }} + + # FIXME: We cannot run programs for architectures not supported by the object crate. See comment above. + #- name: Run Hello World! + #run: | + #./y.sh build --target-triple m68k-unknown-linux-gnu + + #vm_dir=$(pwd)/vm + #cd tests/hello-world + #CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu + #sudo cp target/m68k-unknown-linux-gnu/debug/hello_world $vm_dir/home/ + #sudo chroot $vm_dir qemu-m68k-static /home/hello_world > hello_world_stdout + #expected_output="40" + #test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1) + + # Summary job for the merge queue. + # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! + success_m68k: + needs: [build] + # We need to ensure this job does *not* get skipped if its dependencies fail, + # because a skipped job is considered a success by GitHub. So we have to + # overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run + # when the workflow is canceled manually. + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + steps: + # Manually check the status of all dependencies. `if: failure()` does not work. + - name: Conclusion + run: | + # Print the dependent jobs to see them in the CI log + jq -C <<< '${{ toJson(needs) }}' + # Check if all jobs that we depend on (in the needs array) were successful. + jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' diff --git a/compiler/rustc_codegen_gcc/.github/workflows/release.yml b/compiler/rustc_codegen_gcc/.github/workflows/release.yml new file mode 100644 index 00000000000..b7e2583aad3 --- /dev/null +++ b/compiler/rustc_codegen_gcc/.github/workflows/release.yml @@ -0,0 +1,112 @@ +name: CI with sysroot compiled in release mode + +on: + push: + branches: + - master + pull_request: + +permissions: + contents: read + +env: + # Enable backtraces for easier debugging + RUST_BACKTRACE: 1 + # For the run-make tests. + LLVM_BIN_DIR: /usr/bin + +jobs: + build: + runs-on: ubuntu-24.04 + + strategy: + fail-fast: false + matrix: + commands: [ + "--test-successful-rustc --nb-parts 2 --current-part 0", + "--test-successful-rustc --nb-parts 2 --current-part 1", + ] + + steps: + - uses: actions/checkout@v4 + + # `rustup show` installs from rust-toolchain.toml + - name: Setup rust toolchain + run: rustup show + + - name: Setup rust cache + uses: Swatinem/rust-cache@v2 + + - name: Install packages + # `llvm-14-tools` is needed to install the `FileCheck` binary which is used for run-make tests. + run: sudo apt-get install ninja-build ripgrep llvm-14-tools llvm + + - name: Download artifact + run: curl -LO https://github.com/rust-lang/gcc/releases/latest/download/gcc-15.deb + + - name: Setup path to libgccjit + run: | + sudo dpkg --force-overwrite -i gcc-15.deb + echo 'gcc-path = "/usr/lib/"' > config.toml + + # Some run-make tests fail if we use our forked GCC because it doesn't + # bundle libstdc++, so we switch to gcc-14 to have a GCC that has + # libstdc++. + - name: Set default GCC to gcc-14 + run: sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-14 30 + + - name: Set env + run: | + echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV + + - name: Build + run: | + ./y.sh prepare --only-libcore + EMBED_LTO_BITCODE=1 ./y.sh build --sysroot --release --release-sysroot + ./y.sh test --cargo-tests + ./y.sh clean all + + - name: Prepare dependencies + run: | + git config --global user.email "user@example.com" + git config --global user.name "User" + ./y.sh prepare + + - name: Add more failing tests because of undefined symbol errors (FIXME) + run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt + + - name: Run tests + run: | + # FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros. + # FIXME(antoyo): this should probably not be needed since we embed the LTO bitcode. + printf '[profile.release]\nlto = "fat"\n' >> build/build_sysroot/sysroot_src/library/Cargo.toml + EMBED_LTO_BITCODE=1 ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} + + - name: Run y.sh cargo build + run: | + EMBED_LTO_BITCODE=1 CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml + call_found=$(objdump -dj .text tests/hello-world/target/release/hello_world | grep -c "call .*mylib.*my_func" ) ||: + if [ $call_found -gt 0 ]; then + echo "ERROR: call my_func found in asm" + echo "Test is done with LTO enabled, hence inlining should occur across crates" + exit 1 + fi + + # Summary job for the merge queue. + # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! + success_release: + needs: [build] + # We need to ensure this job does *not* get skipped if its dependencies fail, + # because a skipped job is considered a success by GitHub. So we have to + # overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run + # when the workflow is canceled manually. + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + steps: + # Manually check the status of all dependencies. `if: failure()` does not work. + - name: Conclusion + run: | + # Print the dependent jobs to see them in the CI log + jq -C <<< '${{ toJson(needs) }}' + # Check if all jobs that we depend on (in the needs array) were successful. + jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' diff --git a/compiler/rustc_codegen_gcc/.github/workflows/stdarch.yml b/compiler/rustc_codegen_gcc/.github/workflows/stdarch.yml new file mode 100644 index 00000000000..20d009f08a7 --- /dev/null +++ b/compiler/rustc_codegen_gcc/.github/workflows/stdarch.yml @@ -0,0 +1,124 @@ +name: stdarch tests with sysroot compiled in release mode + +on: + push: + branches: + - master + pull_request: + +permissions: + contents: read + +env: + # Enable backtraces for easier debugging + RUST_BACKTRACE: 1 + +jobs: + build: + runs-on: ubuntu-24.04 + + strategy: + fail-fast: false + matrix: + cargo_runner: [ + "sde -future -rtm_mode full --", + "", + ] + + steps: + - uses: actions/checkout@v4 + + # `rustup show` installs from rust-toolchain.toml + - name: Setup rust toolchain + run: rustup show + + - name: Setup rust cache + uses: Swatinem/rust-cache@v2 + + - name: Install packages + run: sudo apt-get install ninja-build ripgrep + + # TODO: remove when we have binutils version 2.43 in the repo. + - name: Install more recent binutils + run: | + echo "deb http://archive.ubuntu.com/ubuntu oracular main universe" | sudo tee /etc/apt/sources.list.d/oracular-copies.list + sudo apt-get update + sudo apt-get install binutils + + - name: Install Intel Software Development Emulator + if: ${{ matrix.cargo_runner }} + run: | + mkdir intel-sde + cd intel-sde + dir=sde-external-9.33.0-2024-01-07-lin + file=$dir.tar.xz + wget https://downloadmirror.intel.com/813591/$file + tar xvf $file + sudo mkdir /usr/share/intel-sde + sudo cp -r $dir/* /usr/share/intel-sde + sudo ln -s /usr/share/intel-sde/sde /usr/bin/sde + sudo ln -s /usr/share/intel-sde/sde64 /usr/bin/sde64 + + - name: Set env + run: | + echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV + echo 'download-gccjit = true' > config.toml + + - name: Build + run: | + ./y.sh prepare --only-libcore + ./y.sh build --sysroot --release --release-sysroot + + - name: Set env (part 2) + run: | + # Set the `LD_LIBRARY_PATH` and `LIBRARY_PATH` env variables... + echo "LD_LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV + echo "LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV + + - name: Clean + if: ${{ !matrix.cargo_runner }} + run: | + ./y.sh clean all + + - name: Prepare dependencies + run: | + git config --global user.email "user@example.com" + git config --global user.name "User" + ./y.sh prepare + + - name: Run tests + if: ${{ !matrix.cargo_runner }} + run: | + ./y.sh test --release --clean --release-sysroot --build-sysroot --mini-tests --std-tests --test-libcore + ./y.sh test --cargo-tests + + - name: Run stdarch tests + if: ${{ !matrix.cargo_runner }} + run: | + CHANNEL=release TARGET=x86_64-unknown-linux-gnu CG_RUSTFLAGS="-Ainternal_features" ./y.sh cargo test --manifest-path build/build_sysroot/sysroot_src/library/stdarch/Cargo.toml + + - name: Run stdarch tests + if: ${{ matrix.cargo_runner }} + run: | + # FIXME: these tests fail when the sysroot is compiled with LTO because of a missing symbol in proc-macro. + # TODO: remove --skip test_tile_ when it's implemented. + STDARCH_TEST_SKIP_FUNCTION="xsave,xsaveopt,xsave64,xsaveopt64" STDARCH_TEST_EVERYTHING=1 CHANNEL=release CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="${{ matrix.cargo_runner }}" TARGET=x86_64-unknown-linux-gnu CG_RUSTFLAGS="-Ainternal_features" ./y.sh cargo test --manifest-path build/build_sysroot/sysroot_src/library/stdarch/Cargo.toml -- --skip rtm --skip tbm --skip sse4a --skip test_tile_ + + # Summary job for the merge queue. + # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! + success_stdarch: + needs: [build] + # We need to ensure this job does *not* get skipped if its dependencies fail, + # because a skipped job is considered a success by GitHub. So we have to + # overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run + # when the workflow is canceled manually. + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + steps: + # Manually check the status of all dependencies. `if: failure()` does not work. + - name: Conclusion + run: | + # Print the dependent jobs to see them in the CI log + jq -C <<< '${{ toJson(needs) }}' + # Check if all jobs that we depend on (in the needs array) were successful. + jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' diff --git a/compiler/rustc_codegen_gcc/.gitignore b/compiler/rustc_codegen_gcc/.gitignore new file mode 100644 index 00000000000..8f73d3eb972 --- /dev/null +++ b/compiler/rustc_codegen_gcc/.gitignore @@ -0,0 +1,23 @@ +target +**/*.rs.bk +*.rlib +*.o +perf.data +perf.data.old +*.events +*.string* +gimple* +*asm +res +test-backend +projects +benchmarks +tools/llvm-project +tools/llvmint +tools/llvmint-2 +# The `llvm` folder is generated by the `tools/generate_intrinsics.py` script to update intrinsics. +llvm +build_system/target +config.toml +build +rustlantis \ No newline at end of file diff --git a/compiler/rustc_codegen_gcc/.ignore b/compiler/rustc_codegen_gcc/.ignore new file mode 100644 index 00000000000..702dd9e2a23 --- /dev/null +++ b/compiler/rustc_codegen_gcc/.ignore @@ -0,0 +1,11 @@ +!/build_sysroot/sysroot_src +!/simple-raytracer +!/regex +!/rand +!/test-backend +!/gcc_path +!/benchmarks +!*gimple* +!*asm* +!.github +!config.toml diff --git a/compiler/rustc_codegen_gcc/.rustfmt.toml b/compiler/rustc_codegen_gcc/.rustfmt.toml new file mode 100644 index 00000000000..a11bc41680d --- /dev/null +++ b/compiler/rustc_codegen_gcc/.rustfmt.toml @@ -0,0 +1,5 @@ +style_edition = "2024" +use_small_heuristics = "Max" +merge_derives = false +group_imports = "StdExternalCrate" +imports_granularity = "Module" diff --git a/compiler/rustc_codegen_gcc/CONTRIBUTING.md b/compiler/rustc_codegen_gcc/CONTRIBUTING.md new file mode 100644 index 00000000000..54cba0e6de3 --- /dev/null +++ b/compiler/rustc_codegen_gcc/CONTRIBUTING.md @@ -0,0 +1,101 @@ +# Contributing to rustc_codegen_gcc + +Welcome to the `rustc_codegen_gcc` project! This guide will help you get started as a contributor. The project aims to provide a GCC codegen backend for rustc, allowing Rust compilation on platforms unsupported by LLVM and potentially improving runtime performance through GCC's optimizations. + +## Getting Started + +### Setting Up Your Development Environment + +For detailed setup instructions including dependencies, build steps, and initial testing, please refer to our [README](Readme.md). The README contains the most up-to-date information on: + +- Required dependencies and system packages +- Repository setup and configuration +- Build process +- Basic test verification + +Once you've completed the setup process outlined in the README, you can proceed with the contributor-specific information below. + +## Communication Channels + +- Matrix: Join our [Matrix channel](https://matrix.to/#/#rustc_codegen_gcc:matrix.org) +- IRC: Join us on [IRC](https://web.libera.chat/#rustc_codegen_gcc) +- [GitHub Issues](https://github.com/rust-lang/rustc_codegen_gcc/issues): For bug reports and feature discussions + +We encourage new contributors to join our communication channels and introduce themselves. Feel free to ask questions about where to start or discuss potential contributions. + +## Understanding Core Concepts + +### Common Development Tasks + +#### Running Specific Tests + +To run specific tests, use appropriate flags such as: + +- `./y.sh test --test-libcore` +- `./y.sh test --std-tests` +- `./y.sh test --cargo-tests -- <name of test>` + +Additionally, you can run the tests of `libgccjit`: + +```bash +# libgccjit tests +cd gcc-build/gcc +make check-jit +# For a specific test: +make check-jit RUNTESTFLAGS="-v -v -v jit.exp=jit.dg/test-asm.cc" +``` + +#### Debugging Tools + +The project provides several environment variables for debugging: + +- `CG_GCCJIT_DUMP_GIMPLE`: Dumps the GIMPLE IR +- `CG_RUSTFLAGS`: Additional Rust flags +- `CG_GCCJIT_DUMP_MODULE`: Dumps a specific module +- `CG_GCCJIT_DUMP_TO_FILE`: Creates C-like representation + +Full list of debugging options can be found in the [README](Readme.md#env-vars). + +## Making Contributions + +### Finding Issues to Work On + +1. Look for issues labeled with [`good first issue`](https://github.com/rust-lang/rustc_codegen_gcc/issues?q=is%3Aissue%20state%3Aopen%20label%3A"good%20first%20issue") or [`help wanted`](https://github.com/rust-lang/rustc_codegen_gcc/issues?q=is%3Aissue%20state%3Aopen%20label%3A"help%20wanted") +2. Check the [progress report](https://blog.antoyo.xyz/rustc_codegen_gcc-progress-report-34#state_of_rustc_codegen_gcc) for larger initiatives +3. Consider improving documentation or investigating [failing tests](https://github.com/rust-lang/rustc_codegen_gcc/tree/master/tests) (except `failing-ui-tests12.txt`) + +### Pull Request Process + +1. Fork the repository and create a new branch +2. Make your changes with clear commit messages +3. Add tests for new functionality +4. Update documentation as needed +5. Submit a PR with a description of your changes + +### Code Style Guidelines + +- Follow Rust standard coding conventions +- Ensure your code passes `rustfmt` and `clippy` +- Add comments explaining complex logic, especially in GCC interface code + +## Additional Resources + +- [Rustc Dev Guide](https://rustc-dev-guide.rust-lang.org/) +- [GCC Internals Documentation](https://gcc.gnu.org/onlinedocs/gccint/) +- Project-specific documentation in the `doc/` directory: + - [Common errors](doc/errors.md) + - [Debugging](doc/debugging.md) + - [Debugging libgccjit](doc/debugging-libgccjit.md) + - [Git subtree sync](doc/subtree.md) + - [List of useful commands](doc/tips.md) + - [Send a patch to GCC](doc/sending-gcc-patch.md) + +## Getting Help + +If you're stuck or unsure about anything: +1. Check the existing documentation in the `doc/` directory +2. Ask in the IRC or Matrix channels +3. Open a GitHub issue for technical problems +4. Comment on the issue you're working on if you need guidance + +Remember that all contributions, including documentation improvements, bug reports, and feature requests, are valuable to the project. diff --git a/compiler/rustc_codegen_gcc/Cargo.lock b/compiler/rustc_codegen_gcc/Cargo.lock new file mode 100644 index 00000000000..7f35c1a80bd --- /dev/null +++ b/compiler/rustc_codegen_gcc/Cargo.lock @@ -0,0 +1,393 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +dependencies = [ + "memchr", +] + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "boml" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85fdb93f04c73bff54305fa437ffea5449c41edcaadfe882f35836206b166ac5" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "errno" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fm" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bcf4db620a804cf7e9d84fbcb5d4ac83a8c43396203b2507d62ea31814dfd4" +dependencies = [ + "regex", +] + +[[package]] +name = "gccjit" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae99a89184220d967dd300139f2d2ae7d52c1a69d632b24aacc57c54625254ce" +dependencies = [ + "gccjit_sys", +] + +[[package]] +name = "gccjit_sys" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24edb7bfe2b7b27c6d09ed23eebfcab0b359c8fe978433f902943e6f127a0f1b" +dependencies = [ + "libc", +] + +[[package]] +name = "getopts" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "lang_tester" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9af8149dbb3ed7d8e529fcb141fe033b1c26ed54cbffc6762d3a86483c485d23" +dependencies = [ + "fm", + "getopts", + "libc", + "num_cpus", + "termcolor", + "threadpool", + "wait-timeout", + "walkdir", +] + +[[package]] +name = "libc" +version = "0.2.168" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.37.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03fd943161069e1768b4b3d050890ba48730e590f57e56d4aa04e7e090e61b4a" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + +[[package]] +name = "regex" +version = "1.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" + +[[package]] +name = "rustc_codegen_gcc" +version = "0.1.0" +dependencies = [ + "boml", + "gccjit", + "lang_tester", + "object", + "tempfile", +] + +[[package]] +name = "rustix" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "tempfile" +version = "3.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + +[[package]] +name = "walkdir" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] diff --git a/compiler/rustc_codegen_gcc/Cargo.toml b/compiler/rustc_codegen_gcc/Cargo.toml new file mode 100644 index 00000000000..193348d1ef6 --- /dev/null +++ b/compiler/rustc_codegen_gcc/Cargo.toml @@ -0,0 +1,56 @@ +[package] +name = "rustc_codegen_gcc" +version = "0.1.0" +authors = ["Antoni Boucher <bouanto@zoho.com>"] +edition = "2024" +license = "MIT OR Apache-2.0" + +[lib] +crate-type = ["dylib"] + +[[test]] +name = "lang_tests_debug" +path = "tests/lang_tests_debug.rs" +harness = false +[[test]] +name = "lang_tests_release" +path = "tests/lang_tests_release.rs" +harness = false + +[features] +master = ["gccjit/master"] +default = ["master"] + +[dependencies] +object = { version = "0.37.0", default-features = false, features = ["std", "read"] } +tempfile = "3.20" +gccjit = "2.7" +#gccjit = { git = "https://github.com/rust-lang/gccjit.rs" } + +# Local copy. +#gccjit = { path = "../gccjit.rs" } + +[dev-dependencies] +boml = "0.3.1" +lang_tester = "0.8.0" + +[profile.dev] +# By compiling dependencies with optimizations, performing tests gets much faster. +opt-level = 3 + +[profile.dev.package.rustc_codegen_gcc] +# Disabling optimizations for cg_gccjit itself makes compilation after a change faster. +opt-level = 0 + +# Disable optimizations and debuginfo of build scripts and some of the heavy build deps, as the +# execution time of build scripts is so fast that optimizing them slows down the total build time. +[profile.dev.build-override] +opt-level = 0 +debug = false + +[profile.release.build-override] +opt-level = 0 +debug = false + +[package.metadata.rust-analyzer] +rustc_private = true diff --git a/compiler/rustc_codegen_gcc/LICENSE-APACHE b/compiler/rustc_codegen_gcc/LICENSE-APACHE new file mode 100644 index 00000000000..1b5ec8b78e2 --- /dev/null +++ b/compiler/rustc_codegen_gcc/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/compiler/rustc_codegen_gcc/LICENSE-MIT b/compiler/rustc_codegen_gcc/LICENSE-MIT new file mode 100644 index 00000000000..31aa79387f2 --- /dev/null +++ b/compiler/rustc_codegen_gcc/LICENSE-MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/compiler/rustc_codegen_gcc/Readme.md b/compiler/rustc_codegen_gcc/Readme.md new file mode 100644 index 00000000000..859bb1568f4 --- /dev/null +++ b/compiler/rustc_codegen_gcc/Readme.md @@ -0,0 +1,193 @@ +# WIP libgccjit codegen backend for rust + +[](https://web.libera.chat/#rustc_codegen_gcc) +[](https://matrix.to/#/#rustc_codegen_gcc:matrix.org) + +This is a GCC codegen for rustc, which means it can be loaded by the existing rustc frontend, but benefits from GCC: more architectures are supported and GCC's optimizations are used. + +**Despite its name, libgccjit can be used for ahead-of-time compilation, as is used here.** + +## Motivation + +The primary goal of this project is to be able to compile Rust code on platforms unsupported by LLVM. +A secondary goal is to check if using the gcc backend will provide any run-time speed improvement for the programs compiled using rustc. + +## Getting Started + +Note: **This requires a patched libgccjit in order to work. +You need to use my [fork of gcc](https://github.com/rust-lang/gcc) which already includes these patches.** +The default configuration (see below in the [Quick start](#quick-start) section) will download a `libgccjit` built in the CI that already contains these patches, so you don't need to build this fork yourself if you use the default configuration. + +### Dependencies + +- rustup: follow instructions on the [official website](https://rustup.rs) +- consider to install DejaGnu which is necessary for running the libgccjit test suite. [website](https://www.gnu.org/software/dejagnu/#downloading) +- additional packages: `flex`, `libmpfr-dev`, `libgmp-dev`, `libmpc3`, `libmpc-dev` + +### Quick start + +1. Clone and configure the repository: + ```bash + git clone https://github.com/rust-lang/rustc_codegen_gcc + cd rustc_codegen_gcc + cp config.example.toml config.toml + ``` + +2. Build and test: + ```bash + ./y.sh prepare # downloads and patches sysroot + ./y.sh build --sysroot --release + + # Verify setup with a simple test + ./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml + + # Run full test suite (expect ~100 failing UI tests) + ./y.sh test --release + ``` + +If don't need to test GCC patches you wrote in our GCC fork, then the default configuration should +be all you need. You can update the `rustc_codegen_gcc` without worrying about GCC. + +### Building with your own GCC version + +If you wrote a patch for GCC and want to test it without this backend, you will need +to do a few more things. + +To build it (most of these instructions come from [here](https://gcc.gnu.org/onlinedocs/jit/internals/index.html), so don't hesitate to take a look there if you encounter an issue): + +```bash +$ git clone https://github.com/rust-lang/gcc +$ sudo apt install flex libmpfr-dev libgmp-dev libmpc3 libmpc-dev +$ mkdir gcc-build gcc-install +$ cd gcc-build +$ ../gcc/configure \ + --enable-host-shared \ + --enable-languages=jit \ + --enable-checking=release \ # it enables extra checks which allow to find bugs + --disable-bootstrap \ + --disable-multilib \ + --prefix=$(pwd)/../gcc-install +$ make -j4 # You can replace `4` with another number depending on how many cores you have. +``` + +If you want to run libgccjit tests, you will need to also enable the C++ language in the `configure`: + +```bash +--enable-languages=jit,c++ +``` + +Then to run libgccjit tests: + +```bash +$ cd gcc # from the `gcc-build` folder +$ make check-jit +# To run one specific test: +$ make check-jit RUNTESTFLAGS="-v -v -v jit.exp=jit.dg/test-asm.cc" +``` + +**Put the path to your custom build of libgccjit in the file `config.toml`.** + +You now need to set the `gcc-path` value in `config.toml` with the result of this command: + +```bash +$ dirname $(readlink -f `find . -name libgccjit.so`) +``` + +and to comment the `download-gccjit` setting: + +```toml +gcc-path = "[MY PATH]" +# download-gccjit = true +``` + +Then you can run commands like this: + +```bash +$ ./y.sh prepare # download and patch sysroot src and install hyperfine for benchmarking +$ ./y.sh build --sysroot --release +``` + +To run the tests: + +```bash +$ ./y.sh test --release +``` + +## Usage + +You have to run these commands, in the corresponding order: + +```bash +$ ./y.sh prepare +$ ./y.sh build --sysroot +``` +To check if all is working correctly, run: + + ```bash +$ ./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml +``` + +### Cargo + +```bash +$ CHANNEL="release" $CG_GCCJIT_DIR/y.sh cargo run +``` + +If you compiled cg_gccjit in debug mode (aka you didn't pass `--release` to `./y.sh test`) you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely. + +### LTO + +To use LTO, you need to set the variable `EMBED_LTO_BITCODE=1` in addition to setting `lto = "fat"` in the `Cargo.toml`. + +Failing to set `EMBED_LTO_BITCODE` will give you the following error: + +``` +error: failed to copy bitcode to object file: No such file or directory (os error 2) +``` + +### Rustc + +If you want to run `rustc` directly, you can do so with: + +```bash +$ ./y.sh rustc my_crate.rs +``` + +You can do the same manually (although we don't recommend it): + +```bash +$ LIBRARY_PATH="[gcc-path value]" LD_LIBRARY_PATH="[gcc-path value]" rustc +$(cat $CG_GCCJIT_DIR/rust-toolchain | grep 'channel' | cut -d '=' -f 2 | sed 's/"//g' | sed 's/ //g') -Cpanic=abort -Zcodegen-backend=$CG_GCCJIT_DIR/target/release/librustc_codegen_gcc.so --sysroot $CG_GCCJIT_DIR/build_sysroot/sysroot my_crate.rs +``` + +## Environment variables + + * _**CG_GCCJIT_DUMP_ALL_MODULES**_: Enables dumping of all compilation modules. When set to "1", a dump is created for each module during compilation and stored in `/tmp/reproducers/`. + * _**CG_GCCJIT_DUMP_MODULE**_: Enables dumping of a specific module. When set with the module name, e.g., `CG_GCCJIT_DUMP_MODULE=module_name`, a dump of that specific module is created in `/tmp/reproducers/`. + * _**CG_RUSTFLAGS**_: Send additional flags to rustc. Can be used to build the sysroot without unwinding by setting `CG_RUSTFLAGS=-Cpanic=abort`. + * _**CG_GCCJIT_DUMP_TO_FILE**_: Dump a C-like representation to /tmp/gccjit_dumps and enable debug info in order to debug this C-like representation. + * _**CG_GCCJIT_DUMP_RTL**_: Dumps RTL (Register Transfer Language) for virtual registers. + * _**CG_GCCJIT_DUMP_RTL_ALL**_: Dumps all RTL passes. + * _**CG_GCCJIT_DUMP_TREE_ALL**_: Dumps all tree (GIMPLE) passes. + * _**CG_GCCJIT_DUMP_IPA_ALL**_: Dumps all Interprocedural Analysis (IPA) passes. + * _**CG_GCCJIT_DUMP_CODE**_: Dumps the final generated code. + * _**CG_GCCJIT_DUMP_GIMPLE**_: Dumps the initial GIMPLE representation. + * _**CG_GCCJIT_DUMP_EVERYTHING**_: Enables dumping of all intermediate representations and passes. + * _**CG_GCCJIT_KEEP_INTERMEDIATES**_: Keeps intermediate files generated during the compilation process. + * _**CG_GCCJIT_VERBOSE**_: Enables verbose output from the GCC driver. + +## Extra documentation + +More specific documentation is available in the [`doc`](./doc) folder: + + * [Common errors](./doc/errors.md) + * [Debugging GCC LTO](./doc/debugging-gcc-lto.md) + * [Debugging libgccjit](./doc/debugging-libgccjit.md) + * [Git subtree sync](./doc/subtree.md) + * [List of useful commands](./doc/tips.md) + * [Send a patch to GCC](./doc/sending-gcc-patch.md) + +## Licensing + +While this crate is licensed under a dual Apache/MIT license, it links to `libgccjit` which is under the GPLv3+ and thus, the resulting toolchain (rustc + GCC codegen) will need to be released under the GPL license. + +However, programs compiled with `rustc_codegen_gcc` do not need to be released under a GPL license. diff --git a/compiler/rustc_codegen_gcc/_typos.toml b/compiler/rustc_codegen_gcc/_typos.toml new file mode 100644 index 00000000000..4a6a506a981 --- /dev/null +++ b/compiler/rustc_codegen_gcc/_typos.toml @@ -0,0 +1,9 @@ +[default.extend-words] +ba = "ba" +hsa = "hsa" +olt = "olt" +seh = "seh" +typ = "typ" + +[files] +extend-exclude = ["src/intrinsic/archs.rs"] diff --git a/compiler/rustc_codegen_gcc/build_system/Cargo.lock b/compiler/rustc_codegen_gcc/build_system/Cargo.lock new file mode 100644 index 00000000000..e727561a2bf --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "boml" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85fdb93f04c73bff54305fa437ffea5449c41edcaadfe882f35836206b166ac5" + +[[package]] +name = "y" +version = "0.1.0" +dependencies = [ + "boml", +] diff --git a/compiler/rustc_codegen_gcc/build_system/Cargo.toml b/compiler/rustc_codegen_gcc/build_system/Cargo.toml new file mode 100644 index 00000000000..540d82369fd --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "y" +version = "0.1.0" +edition = "2024" + +[dependencies] +boml = "0.3.1" + +[[bin]] +name = "y" +path = "src/main.rs" diff --git a/compiler/rustc_codegen_gcc/build_system/src/abi_test.rs b/compiler/rustc_codegen_gcc/build_system/src/abi_test.rs new file mode 100644 index 00000000000..a85886d87f3 --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/abi_test.rs @@ -0,0 +1,65 @@ +use std::ffi::OsStr; +use std::path::Path; + +use crate::utils::run_command_with_output; + +fn show_usage() { + println!( + r#" +`abi-test` command help: + --help : Show this help"# + ); +} + +pub fn run() -> Result<(), String> { + let mut args = std::env::args().skip(2); + // FractalFir: In the future, I'd like to add some more subcommands / options. + // So, this loop ought to stay for that purpose. It should also stay as a while loop(to parse args) + #[allow(clippy::never_loop, clippy::while_let_on_iterator)] + while let Some(arg) = args.next() { + match arg.as_str() { + "--help" => { + show_usage(); + return Ok(()); + } + _ => return Err(format!("Unknown option {arg:?}")), + } + } + // Ensure that we have a cloned version of abi-cafe on hand. + crate::utils::git_clone( + "https://github.com/Gankra/abi-cafe.git", + Some("clones/abi-cafe".as_ref()), + true, + ) + .map_err(|err| format!("Git clone failed with message: {err:?}!"))?; + // Configure abi-cafe to use the exact same rustc version we use - this is crucial. + // Otherwise, the concept of ABI compatibility becomes meanignless. + std::fs::copy("rust-toolchain", "clones/abi-cafe/rust-toolchain") + .expect("Could not copy toolchain configs!"); + // Get the backend path. + // We will use the *debug* build of the backend - it has more checks enabled. + let backend_path = std::path::absolute("target/debug/librustc_codegen_gcc.so").unwrap(); + let backend_arg = format!("--add-rustc-codegen-backend=cg_gcc:{}", backend_path.display()); + // Run ABI cafe using cargo. + let cmd: &[&dyn AsRef<OsStr>] = &[ + &"cargo", + &"run", + &"--release", + &"--", + &backend_arg, + // Test rust-LLVM to Rust-GCC calls + &"--pairs", + &"rustc_calls_cg_gcc", + &"--pairs", + &"cg_gcc_calls_rustc", + // Test Rust-GCC to C calls + &"--pairs", + &"cg_gcc_calls_c", + &"--pairs", + &"c_calls_cg_gcc", + ]; + // Run ABI cafe. + run_command_with_output(cmd, Some(Path::new("clones/abi-cafe")))?; + + Ok(()) +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/build.rs b/compiler/rustc_codegen_gcc/build_system/src/build.rs new file mode 100644 index 00000000000..94b40319f4a --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/build.rs @@ -0,0 +1,225 @@ +use std::collections::HashMap; +use std::ffi::OsStr; +use std::fs; +use std::path::Path; + +use crate::config::{Channel, ConfigInfo}; +use crate::utils::{ + create_dir, get_sysroot_dir, run_command, run_command_with_output_and_env, walk_dir, +}; + +#[derive(Default)] +struct BuildArg { + flags: Vec<String>, + config_info: ConfigInfo, + build_sysroot: bool, +} + +impl BuildArg { + /// Creates a new `BuildArg` instance by parsing command-line arguments. + fn new() -> Result<Option<Self>, String> { + let mut build_arg = Self::default(); + // Skip binary name and the `build` command. + let mut args = std::env::args().skip(2); + + while let Some(arg) = args.next() { + match arg.as_str() { + "--sysroot" => { + build_arg.build_sysroot = true; + } + "--help" => { + Self::usage(); + return Ok(None); + } + arg => { + if !build_arg.config_info.parse_argument(arg, &mut args)? { + return Err(format!("Unknown argument `{arg}`")); + } + } + } + } + Ok(Some(build_arg)) + } + + fn usage() { + println!( + r#" +`build` command help: + + --sysroot : Build with sysroot"# + ); + ConfigInfo::show_usage(); + println!(" --help : Show this help"); + } +} + +fn cleanup_sysroot_previous_build(library_dir: &Path) { + // Cleanup for previous run + // Clean target dir except for build scripts and incremental cache + let _ = walk_dir( + library_dir.join("target"), + &mut |dir: &Path| { + for top in &["debug", "release"] { + let _ = fs::remove_dir_all(dir.join(top).join("build")); + let _ = fs::remove_dir_all(dir.join(top).join("deps")); + let _ = fs::remove_dir_all(dir.join(top).join("examples")); + let _ = fs::remove_dir_all(dir.join(top).join("native")); + + let _ = walk_dir( + dir.join(top), + &mut |sub_dir: &Path| { + if sub_dir + .file_name() + .map(|filename| filename.to_str().unwrap().starts_with("libsysroot")) + .unwrap_or(false) + { + let _ = fs::remove_dir_all(sub_dir); + } + Ok(()) + }, + &mut |file: &Path| { + if file + .file_name() + .map(|filename| filename.to_str().unwrap().starts_with("libsysroot")) + .unwrap_or(false) + { + let _ = fs::remove_file(file); + } + Ok(()) + }, + false, + ); + } + Ok(()) + }, + &mut |_| Ok(()), + false, + ); +} + +pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Result<(), String> { + let start_dir = get_sysroot_dir(); + + let library_dir = start_dir.join("sysroot_src").join("library"); + cleanup_sysroot_previous_build(&library_dir); + + // Builds libs + let mut rustflags = env.get("RUSTFLAGS").cloned().unwrap_or_default(); + if config.sysroot_panic_abort { + rustflags.push_str(" -Cpanic=abort -Zpanic-abort-tests"); + } + rustflags.push_str(" -Z force-unstable-if-unmarked"); + if config.no_default_features { + rustflags.push_str(" -Csymbol-mangling-version=v0"); + } + + let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"build", &"--target", &config.target]; + for feature in &config.features { + args.push(&"--features"); + args.push(feature); + } + + if config.no_default_features { + rustflags.push_str(" -Csymbol-mangling-version=v0"); + args.push(&"--no-default-features"); + } + + let channel = if config.sysroot_release_channel { + rustflags.push_str(" -Zmir-opt-level=3"); + args.push(&"--release"); + "release" + } else { + "debug" + }; + + // We have a different environment variable than RUSTFLAGS to make sure those flags are only + // sent to rustc_codegen_gcc and not the LLVM backend. + if let Ok(cg_rustflags) = std::env::var("CG_RUSTFLAGS") { + rustflags.push(' '); + rustflags.push_str(&cg_rustflags); + } + + args.push(&"--features"); + args.push(&"backtrace"); + + let mut env = env.clone(); + env.insert("RUSTFLAGS".to_string(), rustflags); + let sysroot_dir = library_dir.join("sysroot"); + run_command_with_output_and_env(&args, Some(&sysroot_dir), Some(&env))?; + + // Copy files to sysroot + let sysroot_path = start_dir.join(format!("sysroot/lib/rustlib/{}/lib/", config.target_triple)); + create_dir(&sysroot_path)?; + let mut copier = |dir_to_copy: &Path| { + // FIXME: should not use shell command! + run_command(&[&"cp", &"-r", &dir_to_copy, &sysroot_path], None).map(|_| ()) + }; + walk_dir( + library_dir.join(format!("target/{}/{}/deps", config.target_triple, channel)), + &mut copier.clone(), + &mut copier, + false, + )?; + + // Copy the source files to the sysroot (Rust for Linux needs this). + let sysroot_src_path = start_dir.join("sysroot/lib/rustlib/src/rust"); + create_dir(&sysroot_src_path)?; + run_command(&[&"cp", &"-r", &library_dir, &sysroot_src_path], None)?; + + Ok(()) +} + +fn build_codegen(args: &mut BuildArg) -> Result<(), String> { + let mut env = HashMap::new(); + + let gcc_path = + args.config_info.gcc_path.clone().expect( + "The config module should have emitted an error if the GCC path wasn't provided", + ); + env.insert("LD_LIBRARY_PATH".to_string(), gcc_path.clone()); + env.insert("LIBRARY_PATH".to_string(), gcc_path); + + if args.config_info.no_default_features { + env.insert("RUSTFLAGS".to_string(), "-Csymbol-mangling-version=v0".to_string()); + } + + let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"rustc"]; + if args.config_info.channel == Channel::Release { + command.push(&"--release"); + env.insert("CHANNEL".to_string(), "release".to_string()); + env.insert("CARGO_INCREMENTAL".to_string(), "1".to_string()); + } else { + env.insert("CHANNEL".to_string(), "debug".to_string()); + } + if args.config_info.no_default_features { + command.push(&"--no-default-features"); + } + let flags = args.flags.iter().map(|s| s.as_str()).collect::<Vec<_>>(); + for flag in &flags { + command.push(flag); + } + run_command_with_output_and_env(&command, None, Some(&env))?; + + args.config_info.setup(&mut env, false)?; + + // We voluntarily ignore the error. + let _ = fs::remove_dir_all("target/out"); + let gccjit_target = "target/out/gccjit"; + create_dir(gccjit_target)?; + if args.build_sysroot { + println!("[BUILD] sysroot"); + build_sysroot(&env, &args.config_info)?; + } + Ok(()) +} + +/// Executes the build process. +pub fn run() -> Result<(), String> { + let mut args = match BuildArg::new()? { + Some(args) => args, + None => return Ok(()), + }; + args.config_info.setup_gcc_path()?; + build_codegen(&mut args)?; + Ok(()) +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/clean.rs b/compiler/rustc_codegen_gcc/build_system/src/clean.rs new file mode 100644 index 00000000000..a441ed613f9 --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/clean.rs @@ -0,0 +1,84 @@ +use std::fs::remove_dir_all; +use std::path::Path; + +use crate::utils::{get_sysroot_dir, remove_file, run_command}; + +#[derive(Default)] +enum CleanArg { + /// `clean all` + All, + /// `clean ui-tests` + UiTests, + /// `clean --help` + #[default] + Help, +} + +impl CleanArg { + fn new() -> Result<Self, String> { + // We skip the binary and the "clean" option. + if let Some(arg) = std::env::args().nth(2) { + return match arg.as_str() { + "all" => Ok(Self::All), + "ui-tests" => Ok(Self::UiTests), + "--help" => Ok(Self::Help), + a => Err(format!("Unknown argument `{a}`")), + }; + } + Ok(Self::default()) + } +} + +fn usage() { + println!( + r#" +`clean` command help: + + all : Clean all data + ui-tests : Clean ui tests + --help : Show this help +"# + ) +} + +fn clean_all() -> Result<(), String> { + let build_sysroot = get_sysroot_dir(); + let dirs_to_remove = [ + "target".into(), + build_sysroot.join("sysroot"), + build_sysroot.join("sysroot_src"), + build_sysroot.join("target"), + ]; + for dir in dirs_to_remove { + let _ = remove_dir_all(dir); + } + let dirs_to_remove = ["regex", "rand", "simple-raytracer"]; + for dir in dirs_to_remove { + let _ = remove_dir_all(Path::new(crate::BUILD_DIR).join(dir)); + } + + let files_to_remove = + [build_sysroot.join("Cargo.lock"), "perf.data".into(), "perf.data.old".into()]; + + for file in files_to_remove { + let _ = remove_file(&file); + } + + println!("Successfully ran `clean all`"); + Ok(()) +} + +fn clean_ui_tests() -> Result<(), String> { + let path = Path::new(crate::BUILD_DIR).join("rust/build/x86_64-unknown-linux-gnu/test/ui/"); + run_command(&[&"find", &path, &"-name", &"stamp", &"-delete"], None)?; + Ok(()) +} + +pub fn run() -> Result<(), String> { + match CleanArg::new()? { + CleanArg::All => clean_all()?, + CleanArg::UiTests => clean_ui_tests()?, + CleanArg::Help => usage(), + } + Ok(()) +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/clone_gcc.rs b/compiler/rustc_codegen_gcc/build_system/src/clone_gcc.rs new file mode 100644 index 00000000000..ee683df419c --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/clone_gcc.rs @@ -0,0 +1,79 @@ +use std::path::{Path, PathBuf}; + +use crate::config::ConfigInfo; +use crate::utils::{git_clone, run_command_with_output}; + +fn show_usage() { + println!( + r#" +`clone-gcc` command help: + + --out-path : Location where the GCC repository will be cloned (default: `./gcc`)"# + ); + ConfigInfo::show_usage(); + println!(" --help : Show this help"); +} + +#[derive(Default)] +struct Args { + out_path: PathBuf, + config_info: ConfigInfo, +} + +impl Args { + fn new() -> Result<Option<Self>, String> { + let mut command_args = Self::default(); + + let mut out_path = None; + + // We skip binary name and the `clone-gcc` command. + let mut args = std::env::args().skip(2); + + while let Some(arg) = args.next() { + match arg.as_str() { + "--out-path" => match args.next() { + Some(path) if !path.is_empty() => out_path = Some(path), + _ => { + return Err("Expected an argument after `--out-path`, found nothing".into()); + } + }, + "--help" => { + show_usage(); + return Ok(None); + } + arg => { + if !command_args.config_info.parse_argument(arg, &mut args)? { + return Err(format!("Unknown option {arg}")); + } + } + } + } + command_args.out_path = match out_path { + Some(p) => p.into(), + None => PathBuf::from("./gcc"), + }; + Ok(Some(command_args)) + } +} + +pub fn run() -> Result<(), String> { + let Some(args) = Args::new()? else { + return Ok(()); + }; + + let result = git_clone("https://github.com/rust-lang/gcc", Some(&args.out_path), false)?; + if result.ran_clone { + let gcc_commit = args.config_info.get_gcc_commit()?; + println!("Checking out GCC commit `{gcc_commit}`..."); + run_command_with_output( + &[&"git", &"checkout", &gcc_commit], + Some(Path::new(&result.repo_dir)), + )?; + } else { + println!( + "There is already a GCC folder in `{}`, leaving things as is...", + args.out_path.display() + ); + } + Ok(()) +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/config.rs b/compiler/rustc_codegen_gcc/build_system/src/config.rs new file mode 100644 index 00000000000..a5f802e293a --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/config.rs @@ -0,0 +1,552 @@ +use std::collections::HashMap; +use std::ffi::OsStr; +use std::path::{Path, PathBuf}; +use std::{env as std_env, fs}; + +use boml::Toml; +use boml::types::TomlValue; + +use crate::utils::{ + create_dir, create_symlink, get_os_name, get_sysroot_dir, run_command_with_output, + rustc_version_info, split_args, +}; + +#[derive(Default, PartialEq, Eq, Clone, Copy, Debug)] +pub enum Channel { + #[default] + Debug, + Release, +} + +impl Channel { + pub fn as_str(self) -> &'static str { + match self { + Self::Debug => "debug", + Self::Release => "release", + } + } +} + +fn failed_config_parsing(config_file: &Path, err: &str) -> Result<ConfigFile, String> { + Err(format!("Failed to parse `{}`: {}", config_file.display(), err)) +} + +#[derive(Default)] +pub struct ConfigFile { + gcc_path: Option<String>, + download_gccjit: Option<bool>, +} + +impl ConfigFile { + pub fn new(config_file: &Path) -> Result<Self, String> { + let content = fs::read_to_string(config_file).map_err(|_| { + format!( + "Failed to read `{}`. Take a look at `Readme.md` to see how to set up the project", + config_file.display(), + ) + })?; + let toml = Toml::parse(&content).map_err(|err| { + format!("Error occurred around `{}`: {:?}", &content[err.start..=err.end], err.kind) + })?; + let mut config = Self::default(); + for (key, value) in toml.iter() { + match (key, value) { + ("gcc-path", TomlValue::String(value)) => { + config.gcc_path = Some(value.as_str().to_string()) + } + ("gcc-path", _) => { + return failed_config_parsing(config_file, "Expected a string for `gcc-path`"); + } + ("download-gccjit", TomlValue::Boolean(value)) => { + config.download_gccjit = Some(*value) + } + ("download-gccjit", _) => { + return failed_config_parsing( + config_file, + "Expected a boolean for `download-gccjit`", + ); + } + _ => return failed_config_parsing(config_file, &format!("Unknown key `{key}`")), + } + } + match (config.gcc_path.as_mut(), config.download_gccjit) { + (None, None | Some(false)) => { + return failed_config_parsing( + config_file, + "At least one of `gcc-path` or `download-gccjit` value must be set", + ); + } + (Some(_), Some(true)) => { + println!( + "WARNING: both `gcc-path` and `download-gccjit` arguments are used, \ + ignoring `gcc-path`" + ); + } + (Some(gcc_path), _) => { + let path = Path::new(gcc_path); + *gcc_path = path + .canonicalize() + .map_err(|err| format!("Failed to get absolute path of `{gcc_path}`: {err:?}"))? + .display() + .to_string(); + } + _ => {} + } + Ok(config) + } +} + +#[derive(Default, Debug, Clone)] +pub struct ConfigInfo { + pub target: String, + pub target_triple: String, + pub host_triple: String, + pub rustc_command: Vec<String>, + pub run_in_vm: bool, + pub cargo_target_dir: String, + pub dylib_ext: String, + pub sysroot_release_channel: bool, + pub channel: Channel, + pub sysroot_panic_abort: bool, + pub cg_backend_path: String, + pub sysroot_path: String, + pub gcc_path: Option<String>, + config_file: Option<String>, + // This is used in particular in rust compiler bootstrap because it doesn't run at the root + // of the `cg_gcc` folder, making it complicated for us to get access to local files we need + // like `libgccjit.version` or `config.toml`. + cg_gcc_path: Option<PathBuf>, + // Needed for the `info` command which doesn't want to actually download the lib if needed, + // just to set the `gcc_path` field to display it. + pub no_download: bool, + pub no_default_features: bool, + pub backend: Option<String>, + pub features: Vec<String>, +} + +impl ConfigInfo { + /// Returns `true` if the argument was taken into account. + pub fn parse_argument( + &mut self, + arg: &str, + args: &mut impl Iterator<Item = String>, + ) -> Result<bool, String> { + match arg { + "--features" => { + if let Some(arg) = args.next() { + self.features.push(arg); + } else { + return Err("Expected a value after `--features`, found nothing".to_string()); + } + } + "--target" => { + if let Some(arg) = args.next() { + self.target = arg; + } else { + return Err("Expected a value after `--target`, found nothing".to_string()); + } + } + "--target-triple" => match args.next() { + Some(arg) if !arg.is_empty() => self.target_triple = arg.to_string(), + _ => { + return Err( + "Expected a value after `--target-triple`, found nothing".to_string() + ); + } + }, + "--out-dir" => match args.next() { + Some(arg) if !arg.is_empty() => { + self.cargo_target_dir = arg.to_string(); + } + _ => return Err("Expected a value after `--out-dir`, found nothing".to_string()), + }, + "--config-file" => match args.next() { + Some(arg) if !arg.is_empty() => { + self.config_file = Some(arg.to_string()); + } + _ => { + return Err("Expected a value after `--config-file`, found nothing".to_string()); + } + }, + "--release-sysroot" => self.sysroot_release_channel = true, + "--release" => self.channel = Channel::Release, + "--sysroot-panic-abort" => self.sysroot_panic_abort = true, + "--gcc-path" => match args.next() { + Some(arg) if !arg.is_empty() => { + self.gcc_path = Some(arg); + } + _ => { + return Err("Expected a value after `--gcc-path`, found nothing".to_string()); + } + }, + "--cg_gcc-path" => match args.next() { + Some(arg) if !arg.is_empty() => { + self.cg_gcc_path = Some(arg.into()); + } + _ => { + return Err("Expected a value after `--cg_gcc-path`, found nothing".to_string()); + } + }, + "--use-backend" => match args.next() { + Some(backend) if !backend.is_empty() => self.backend = Some(backend), + _ => return Err("Expected an argument after `--use-backend`, found nothing".into()), + }, + "--no-default-features" => self.no_default_features = true, + _ => return Ok(false), + } + Ok(true) + } + + pub fn rustc_command_vec(&self) -> Vec<&dyn AsRef<OsStr>> { + let mut command: Vec<&dyn AsRef<OsStr>> = Vec::with_capacity(self.rustc_command.len()); + for arg in self.rustc_command.iter() { + command.push(arg); + } + command + } + + pub fn get_gcc_commit(&self) -> Result<String, String> { + let commit_hash_file = self.compute_path("libgccjit.version"); + let content = fs::read_to_string(&commit_hash_file).map_err(|_| { + format!( + "Failed to read `{}`. Take a look at `Readme.md` to see how to set up the project", + commit_hash_file.display(), + ) + })?; + let commit = content.trim(); + // This is a very simple check to ensure this is not a path. For the rest, it'll just fail + // when trying to download the file so we should be fine. + if commit.contains('/') || commit.contains('\\') { + return Err(format!( + "{}: invalid commit hash `{}`", + commit_hash_file.display(), + commit, + )); + } + Ok(commit.to_string()) + } + + fn download_gccjit_if_needed(&mut self) -> Result<(), String> { + let output_dir = Path::new(crate::BUILD_DIR).join("libgccjit"); + let commit = self.get_gcc_commit()?; + + let output_dir = output_dir.join(&commit); + if !output_dir.is_dir() { + create_dir(&output_dir)?; + } + let output_dir = output_dir.canonicalize().map_err(|err| { + format!("Failed to get absolute path of `{}`: {:?}", output_dir.display(), err) + })?; + + let libgccjit_so_name = "libgccjit.so"; + let libgccjit_so = output_dir.join(libgccjit_so_name); + if !libgccjit_so.is_file() && !self.no_download { + // Download time! + let tempfile_name = format!("{libgccjit_so_name}.download"); + let tempfile = output_dir.join(&tempfile_name); + let is_in_ci = std::env::var("GITHUB_ACTIONS").is_ok(); + + download_gccjit(&commit, &output_dir, tempfile_name, !is_in_ci)?; + + let libgccjit_so = output_dir.join(libgccjit_so_name); + // If we reach this point, it means the file was correctly downloaded, so let's + // rename it! + std::fs::rename(&tempfile, &libgccjit_so).map_err(|err| { + format!( + "Failed to rename `{}` into `{}`: {:?}", + tempfile.display(), + libgccjit_so.display(), + err, + ) + })?; + + println!("Downloaded libgccjit.so version {commit} successfully!"); + // We need to create a link named `libgccjit.so.0` because that's what the linker is + // looking for. + create_symlink(&libgccjit_so, output_dir.join(format!("{libgccjit_so_name}.0")))?; + } + + let gcc_path = output_dir.display().to_string(); + println!("Using `{gcc_path}` as path for libgccjit"); + self.gcc_path = Some(gcc_path); + Ok(()) + } + + pub fn compute_path<P: AsRef<Path>>(&self, other: P) -> PathBuf { + match self.cg_gcc_path { + Some(ref path) => path.join(other), + None => PathBuf::new().join(other), + } + } + + pub fn setup_gcc_path(&mut self) -> Result<(), String> { + // If the user used the `--gcc-path` option, no need to look at `config.toml` content + // since we already have everything we need. + if let Some(gcc_path) = &self.gcc_path { + println!( + "`--gcc-path` was provided, ignoring config file. Using `{gcc_path}` as path for libgccjit" + ); + return Ok(()); + } + let config_file = match self.config_file.as_deref() { + Some(config_file) => config_file.into(), + None => self.compute_path("config.toml"), + }; + let ConfigFile { gcc_path, download_gccjit } = ConfigFile::new(&config_file)?; + + if let Some(true) = download_gccjit { + self.download_gccjit_if_needed()?; + return Ok(()); + } + let Some(gcc_path) = gcc_path else { + return Err(format!("missing `gcc-path` value from `{}`", config_file.display())); + }; + println!( + "GCC path retrieved from `{}`. Using `{}` as path for libgccjit", + config_file.display(), + gcc_path + ); + self.gcc_path = Some(gcc_path); + Ok(()) + } + + pub fn setup( + &mut self, + env: &mut HashMap<String, String>, + use_system_gcc: bool, + ) -> Result<(), String> { + env.insert("CARGO_INCREMENTAL".to_string(), "0".to_string()); + + let gcc_path = if !use_system_gcc { + if self.gcc_path.is_none() { + self.setup_gcc_path()?; + } + self.gcc_path.clone().expect( + "The config module should have emitted an error if the GCC path wasn't provided", + ) + } else { + String::new() + }; + env.insert("GCC_PATH".to_string(), gcc_path.clone()); + + if self.cargo_target_dir.is_empty() { + match env.get("CARGO_TARGET_DIR").filter(|dir| !dir.is_empty()) { + Some(cargo_target_dir) => self.cargo_target_dir = cargo_target_dir.clone(), + None => self.cargo_target_dir = "target/out".to_string(), + } + } + + let os_name = get_os_name()?; + self.dylib_ext = match os_name.as_str() { + "Linux" => "so", + "Darwin" => "dylib", + os => return Err(format!("unsupported OS `{os}`")), + } + .to_string(); + let rustc = match env.get("RUSTC") { + Some(r) if !r.is_empty() => r.to_string(), + _ => "rustc".to_string(), + }; + self.host_triple = match rustc_version_info(Some(&rustc))?.host { + Some(host) => host, + None => return Err("no host found".to_string()), + }; + + if self.target_triple.is_empty() { + self.target_triple = self.host_triple.clone(); + } + if self.target.is_empty() && !self.target_triple.is_empty() { + self.target = self.target_triple.clone(); + } + + let mut linker = None; + + if self.host_triple != self.target_triple { + if self.target_triple.is_empty() { + return Err("Unknown non-native platform".to_string()); + } + linker = Some(format!("-Clinker={}-gcc", self.target_triple)); + self.run_in_vm = true; + } + + let current_dir = + std_env::current_dir().map_err(|error| format!("`current_dir` failed: {error:?}"))?; + let channel = if self.channel == Channel::Release { + "release" + } else if let Some(channel) = env.get("CHANNEL") { + channel.as_str() + } else { + "debug" + }; + + let mut rustflags = Vec::new(); + self.cg_backend_path = current_dir + .join("target") + .join(channel) + .join(format!("librustc_codegen_gcc.{}", self.dylib_ext)) + .display() + .to_string(); + self.sysroot_path = + current_dir.join(get_sysroot_dir()).join("sysroot").display().to_string(); + if let Some(backend) = &self.backend { + // This option is only used in the rust compiler testsuite. The sysroot is handled + // by its build system directly so no need to set it ourselves. + rustflags.push(format!("-Zcodegen-backend={backend}")); + } else { + rustflags.extend_from_slice(&[ + "--sysroot".to_string(), + self.sysroot_path.clone(), + format!("-Zcodegen-backend={}", self.cg_backend_path), + ]); + } + + // This environment variable is useful in case we want to change options of rustc commands. + // We have a different environment variable than RUSTFLAGS to make sure those flags are + // only sent to rustc_codegen_gcc and not the LLVM backend. + if let Some(cg_rustflags) = env.get("CG_RUSTFLAGS") { + rustflags.extend_from_slice(&split_args(cg_rustflags)?); + } + if let Some(test_flags) = env.get("TEST_FLAGS") { + rustflags.extend_from_slice(&split_args(test_flags)?); + } + + if let Some(linker) = linker { + rustflags.push(linker.to_string()); + } + + if self.no_default_features { + rustflags.push("-Csymbol-mangling-version=v0".to_string()); + } + + // FIXME(antoyo): remove once the atomic shim is gone + if os_name == "Darwin" { + rustflags.extend_from_slice(&[ + "-Clink-arg=-undefined".to_string(), + "-Clink-arg=dynamic_lookup".to_string(), + ]); + } + env.insert("RUSTFLAGS".to_string(), rustflags.join(" ")); + // display metadata load errors + env.insert("RUSTC_LOG".to_string(), "warn".to_string()); + + let sysroot = current_dir + .join(get_sysroot_dir()) + .join(format!("sysroot/lib/rustlib/{}/lib", self.target_triple)); + let ld_library_path = format!( + "{target}:{sysroot}:{gcc_path}", + target = self.cargo_target_dir, + sysroot = sysroot.display(), + gcc_path = gcc_path, + ); + env.insert("LIBRARY_PATH".to_string(), ld_library_path.clone()); + env.insert("LD_LIBRARY_PATH".to_string(), ld_library_path.clone()); + env.insert("DYLD_LIBRARY_PATH".to_string(), ld_library_path); + + // NOTE: To avoid the -fno-inline errors, use /opt/gcc/bin/gcc instead of cc. + // To do so, add a symlink for cc to /opt/gcc/bin/gcc in our PATH. + // Another option would be to add the following Rust flag: -Clinker=/opt/gcc/bin/gcc + let path = std::env::var("PATH").unwrap_or_default(); + env.insert( + "PATH".to_string(), + format!( + "/opt/gcc/bin:/opt/m68k-unknown-linux-gnu/bin{}{}", + if path.is_empty() { "" } else { ":" }, + path + ), + ); + + self.rustc_command = vec![rustc]; + self.rustc_command.extend_from_slice(&rustflags); + self.rustc_command.extend_from_slice(&[ + "-L".to_string(), + format!("crate={}", self.cargo_target_dir), + "--out-dir".to_string(), + self.cargo_target_dir.clone(), + ]); + + if !env.contains_key("RUSTC_LOG") { + env.insert("RUSTC_LOG".to_string(), "warn".to_string()); + } + Ok(()) + } + + pub fn show_usage() { + println!( + "\ + --features [arg] : Add a new feature [arg] + --target-triple [arg] : Set the target triple to [arg] + --target [arg] : Set the target to [arg] + --out-dir : Location where the files will be generated + --release : Build in release mode + --release-sysroot : Build sysroot in release mode + --sysroot-panic-abort : Build the sysroot without unwinding support + --config-file : Location of the config file to be used + --gcc-path : Location of the GCC root folder + --cg_gcc-path : Location of the rustc_codegen_gcc root folder (used + when ran from another directory) + --no-default-features : Add `--no-default-features` flag to cargo commands + --use-backend : Useful only for rustc testsuite" + ); + } +} + +fn download_gccjit( + commit: &str, + output_dir: &Path, + tempfile_name: String, + with_progress_bar: bool, +) -> Result<(), String> { + let url = if std::env::consts::OS == "linux" && std::env::consts::ARCH == "x86_64" { + format!("https://github.com/rust-lang/gcc/releases/download/master-{commit}/libgccjit.so") + } else { + eprintln!( + "\ +Pre-compiled libgccjit.so not available for this os or architecture. +Please compile it yourself and update the `config.toml` file +to `download-gccjit = false` and set `gcc-path` to the appropriate directory." + ); + return Err(String::from( + "no appropriate pre-compiled libgccjit.so available for download", + )); + }; + + println!("Downloading `{url}`..."); + + // Try curl. If that fails and we are on windows, fallback to PowerShell. + let mut ret = run_command_with_output( + &[ + &"curl", + &"--speed-time", + &"30", + &"--speed-limit", + &"10", // timeout if speed is < 10 bytes/sec for > 30 seconds + &"--connect-timeout", + &"30", // timeout if cannot connect within 30 seconds + &"-o", + &tempfile_name, + &"--retry", + &"3", + &"-SRfL", + if with_progress_bar { &"--progress-bar" } else { &"-s" }, + &url.as_str(), + ], + Some(output_dir), + ); + if ret.is_err() && cfg!(windows) { + eprintln!("Fallback to PowerShell"); + ret = run_command_with_output( + &[ + &"PowerShell.exe", + &"/nologo", + &"-Command", + &"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;", + &format!( + "(New-Object System.Net.WebClient).DownloadFile('{url}', '{tempfile_name}')", + ) + .as_str(), + ], + Some(output_dir), + ); + } + ret +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/fmt.rs b/compiler/rustc_codegen_gcc/build_system/src/fmt.rs new file mode 100644 index 00000000000..7e6594f50f9 --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/fmt.rs @@ -0,0 +1,36 @@ +use std::ffi::OsStr; +use std::path::Path; + +use crate::utils::run_command_with_output; + +fn show_usage() { + println!( + r#" +`fmt` command help: + + --check : Pass `--check` argument to `cargo fmt` commands + --help : Show this help"# + ); +} + +pub fn run() -> Result<(), String> { + let mut check = false; + // We skip binary name and the `info` command. + let args = std::env::args().skip(2); + for arg in args { + match arg.as_str() { + "--help" => { + show_usage(); + return Ok(()); + } + "--check" => check = true, + _ => return Err(format!("Unknown option {arg}")), + } + } + + let cmd: &[&dyn AsRef<OsStr>] = + if check { &[&"cargo", &"fmt", &"--check"] } else { &[&"cargo", &"fmt"] }; + + run_command_with_output(cmd, Some(Path::new(".")))?; + run_command_with_output(cmd, Some(Path::new("build_system"))) +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/fuzz.rs b/compiler/rustc_codegen_gcc/build_system/src/fuzz.rs new file mode 100644 index 00000000000..9714ce29af9 --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/fuzz.rs @@ -0,0 +1,289 @@ +use std::ffi::OsStr; +use std::path::Path; + +mod reduce; + +use crate::utils::run_command_with_output; + +fn show_usage() { + println!( + r#" +`fuzz` command help: + --reduce : Reduces a file generated by rustlantis + --help : Show this help + --start : Start of the fuzzed range + --count : The number of cases to fuzz + -j --jobs : The number of threads to use during fuzzing"# + ); +} + +pub fn run() -> Result<(), String> { + // We skip binary name and the `fuzz` command. + let mut args = std::env::args().skip(2); + let mut start = 0; + let mut count = 100; + let mut threads = + std::thread::available_parallelism().map(|threads| threads.get()).unwrap_or(1); + while let Some(arg) = args.next() { + match arg.as_str() { + "--reduce" => { + let Some(path) = args.next() else { + return Err("--reduce must be provided with a path".into()); + }; + if !std::fs::exists(&path).unwrap_or(false) { + return Err("--reduce must be provided with a valid path".into()); + } + reduce::reduce(&path); + return Ok(()); + } + "--help" => { + show_usage(); + return Ok(()); + } + "--start" => { + start = + str::parse(&args.next().ok_or_else(|| "Fuzz start not provided!".to_string())?) + .map_err(|err| format!("Fuzz start not a number {err:?}!"))?; + } + "--count" => { + count = + str::parse(&args.next().ok_or_else(|| "Fuzz count not provided!".to_string())?) + .map_err(|err| format!("Fuzz count not a number {err:?}!"))?; + } + "-j" | "--jobs" => { + threads = str::parse( + &args.next().ok_or_else(|| "Fuzz thread count not provided!".to_string())?, + ) + .map_err(|err| format!("Fuzz thread count not a number {err:?}!"))?; + } + _ => return Err(format!("Unknown option {arg}")), + } + } + + // Ensure that we have a cloned version of rustlantis on hand. + crate::utils::git_clone( + "https://github.com/cbeuw/rustlantis.git", + Some("clones/rustlantis".as_ref()), + true, + ) + .map_err(|err| format!("Git clone failed with message: {err:?}!"))?; + + // Ensure that we are on the newest rustlantis commit. + let cmd: &[&dyn AsRef<OsStr>] = &[&"git", &"pull", &"origin"]; + run_command_with_output(cmd, Some(Path::new("clones/rustlantis")))?; + + // Build the release version of rustlantis + let cmd: &[&dyn AsRef<OsStr>] = &[&"cargo", &"build", &"--release"]; + run_command_with_output(cmd, Some(Path::new("clones/rustlantis")))?; + // Fuzz a given range + fuzz_range(start, start + count, threads); + Ok(()) +} + +/// Fuzzes a range `start..end` with `threads`. +fn fuzz_range(start: u64, end: u64, threads: usize) { + use std::sync::Arc; + use std::sync::atomic::{AtomicU64, Ordering}; + use std::time::{Duration, Instant}; + // Total amount of files to fuzz + let total = end - start; + // Currently fuzzed element + let start = Arc::new(AtomicU64::new(start)); + // Count time during fuzzing + let start_time = Instant::now(); + let mut workers = Vec::with_capacity(threads); + // Spawn `threads`.. + for _ in 0..threads { + let start = start.clone(); + // .. which each will .. + workers.push(std::thread::spawn(move || { + // ... grab the next fuzz seed ... + while start.load(Ordering::Relaxed) < end { + let next = start.fetch_add(1, Ordering::Relaxed); + // .. test that seed . + match test(next, false) { + Err(err) => { + // If the test failed at compile-time... + println!("test({next}) failed because {err:?}"); + // ... copy that file to the directory `target/fuzz/compiletime_error`... + let mut out_path: std::path::PathBuf = + "target/fuzz/compiletime_error".into(); + std::fs::create_dir_all(&out_path).unwrap(); + // .. into a file named `fuzz{seed}.rs`. + out_path.push(format!("fuzz{next}.rs")); + std::fs::copy(err, out_path).unwrap(); + } + Ok(Err(err)) => { + // If the test failed at run-time... + println!("The LLVM and GCC results don't match for {err:?}"); + // ... generate a new file, which prints temporaries(instead of hashing them)... + let mut out_path: std::path::PathBuf = "target/fuzz/runtime_error".into(); + std::fs::create_dir_all(&out_path).unwrap(); + let Ok(Err(tmp_print_err)) = test(next, true) else { + // ... if that file does not reproduce the issue... + // ... save the original sample in a file named `fuzz{seed}.rs`... + out_path.push(format!("fuzz{next}.rs")); + std::fs::copy(err, &out_path).unwrap(); + continue; + }; + // ... if that new file still produces the issue, copy it to `fuzz{seed}.rs`.. + out_path.push(format!("fuzz{next}.rs")); + std::fs::copy(tmp_print_err, &out_path).unwrap(); + // ... and start reducing it, using some properties of `rustlantis` to speed up the process. + reduce::reduce(&out_path); + } + // If the test passed, do nothing + Ok(Ok(())) => (), + } + } + })); + } + // The "manager" thread loop. + while start.load(Ordering::Relaxed) < end || !workers.iter().all(|t| t.is_finished()) { + // Every 500 ms... + let five_hundred_millis = Duration::from_millis(500); + std::thread::sleep(five_hundred_millis); + // ... calculate the remaining fuzz iters ... + let remaining = end - start.load(Ordering::Relaxed); + // ... fix the count(the start counter counts the cases that + // begun fuzzing, and not only the ones that are done)... + let fuzzed = (total - remaining).saturating_sub(threads as u64); + // ... and the fuzz speed ... + let iter_per_sec = fuzzed as f64 / start_time.elapsed().as_secs_f64(); + // .. and use them to display fuzzing stats. + println!( + "fuzzed {fuzzed} cases({}%), at rate {iter_per_sec} iter/s, remaining ~{}s", + (100 * fuzzed) as f64 / total as f64, + (remaining as f64) / iter_per_sec + ) + } + drop(workers); +} + +/// Builds & runs a file with LLVM. +fn debug_llvm(path: &std::path::Path) -> Result<Vec<u8>, String> { + // Build a file named `llvm_elf`... + let exe_path = path.with_extension("llvm_elf"); + // ... using the LLVM backend ... + let output = std::process::Command::new("rustc") + .arg(path) + .arg("-o") + .arg(&exe_path) + .output() + .map_err(|err| format!("{err:?}"))?; + // ... check that the compilation succeeded ... + if !output.status.success() { + return Err(format!("LLVM compilation failed:{output:?}")); + } + // ... run the resulting executable ... + let output = + std::process::Command::new(&exe_path).output().map_err(|err| format!("{err:?}"))?; + // ... check it run normally ... + if !output.status.success() { + return Err(format!( + "The program at {path:?}, compiled with LLVM, exited unsuccessfully:{output:?}" + )); + } + // ... cleanup that executable ... + std::fs::remove_file(exe_path).map_err(|err| format!("{err:?}"))?; + // ... and return the output(stdout + stderr - this allows UB checks to fire). + let mut res = output.stdout; + res.extend(output.stderr); + Ok(res) +} + +/// Builds & runs a file with GCC. +fn release_gcc(path: &std::path::Path) -> Result<Vec<u8>, String> { + // Build a file named `gcc_elf`... + let exe_path = path.with_extension("gcc_elf"); + // ... using the GCC backend ... + let output = std::process::Command::new("./y.sh") + .arg("rustc") + .arg(path) + .arg("-O") + .arg("-o") + .arg(&exe_path) + .output() + .map_err(|err| format!("{err:?}"))?; + // ... check that the compilation succeeded ... + if !output.status.success() { + return Err(format!("GCC compilation failed:{output:?}")); + } + // ... run the resulting executable .. + let output = + std::process::Command::new(&exe_path).output().map_err(|err| format!("{err:?}"))?; + // ... check it run normally ... + if !output.status.success() { + return Err(format!( + "The program at {path:?}, compiled with GCC, exited unsuccessfully:{output:?}" + )); + } + // ... cleanup that executable ... + std::fs::remove_file(exe_path).map_err(|err| format!("{err:?}"))?; + // ... and return the output(stdout + stderr - this allows UB checks to fire). + let mut res = output.stdout; + res.extend(output.stderr); + Ok(res) +} +type ResultCache = Option<(Vec<u8>, Vec<u8>)>; +/// Generates a new rustlantis file, & compares the result of running it with GCC and LLVM. +fn test(seed: u64, print_tmp_vars: bool) -> Result<Result<(), std::path::PathBuf>, String> { + // Generate a Rust source... + let source_file = generate(seed, print_tmp_vars)?; + test_file(&source_file, true) +} +/// Tests a file with a cached LLVM result. Used for reduction, when it is known +/// that a given transformation should not change the execution result. +fn test_cached( + source_file: &Path, + remove_tmps: bool, + cache: &mut ResultCache, +) -> Result<Result<(), std::path::PathBuf>, String> { + // Test `source_file` with release GCC ... + let gcc_res = release_gcc(source_file)?; + if cache.is_none() { + // ...test `source_file` with debug LLVM ... + *cache = Some((debug_llvm(source_file)?, gcc_res.clone())); + } + let (llvm_res, old_gcc) = cache.as_ref().unwrap(); + // ... compare the results ... + if *llvm_res != gcc_res && gcc_res == *old_gcc { + // .. if they don't match, report an error. + Ok(Err(source_file.to_path_buf())) + } else { + if remove_tmps { + std::fs::remove_file(source_file).map_err(|err| format!("{err:?}"))?; + } + Ok(Ok(())) + } +} +fn test_file( + source_file: &Path, + remove_tmps: bool, +) -> Result<Result<(), std::path::PathBuf>, String> { + let mut uncached = None; + test_cached(source_file, remove_tmps, &mut uncached) +} + +/// Generates a new rustlantis file for us to run tests on. +fn generate(seed: u64, print_tmp_vars: bool) -> Result<std::path::PathBuf, String> { + use std::io::Write; + let mut out_path = std::env::temp_dir(); + out_path.push(format!("fuzz{seed}.rs")); + // We need to get the command output here. + let mut generate = std::process::Command::new("cargo"); + generate + .args(["run", "--release", "--bin", "generate"]) + .arg(format!("{seed}")) + .current_dir("clones/rustlantis"); + if print_tmp_vars { + generate.arg("--debug"); + } + let out = generate.output().map_err(|err| format!("{err:?}"))?; + // Stuff the rustlantis output in a source file. + std::fs::File::create(&out_path) + .map_err(|err| format!("{err:?}"))? + .write_all(&out.stdout) + .map_err(|err| format!("{err:?}"))?; + Ok(out_path) +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/fuzz/reduce.rs b/compiler/rustc_codegen_gcc/build_system/src/fuzz/reduce.rs new file mode 100644 index 00000000000..20715ab0e7c --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/fuzz/reduce.rs @@ -0,0 +1,432 @@ +use std::io::Write; +use std::path::{Path, PathBuf}; + +use super::ResultCache; + +/// Saves a reduced file for a given `stage` +fn save_reduction(lines: &[String], path: &Path, stage: &str) { + let mut path = path.to_path_buf(); + path.set_extension(format!("rs.{stage}")); + let mut file = std::fs::File::create(&path).expect("Could not create the reduced example file"); + for line in lines { + file.write_all(line.as_bytes()).expect("Could not save the reduced example"); + } +} + +/// Checks if a given reduction is valid. +fn test_reduction(lines: &[String], path: &Path, cache: &mut ResultCache) -> bool { + let mut path = path.to_path_buf(); + path.set_extension("rs_reduced"); + let mut file = std::fs::File::create(&path).expect("Could not create the reduced example file"); + for line in lines { + file.write_all(line.as_bytes()).expect("Could not save the reduced example"); + } + let res = super::test_cached(&path, false, cache); + let Ok(Err(_)) = res else { + return false; + }; + true +} + +/// Removes duplicate assignments in bulk. +/// If a line A = B is followed directly by A = C, +/// then removing the first line ought to be fully sound, +/// and not change the behaviour of the program at all. Detect & remove such lines. +fn remove_dup_assign( + file: &mut Vec<String>, + path: &PathBuf, + starts: usize, + ends: usize, + cache: &mut ResultCache, +) { + let mut file_copy = file.clone(); + let mut reduction_count = 0; + // Not worth it. + if ends - starts < 8 { + return; + } + for index in starts..ends { + let Some((prefix, _)) = file_copy[index].split_once('=') else { + continue; + }; + let Some((prefix2, postifx2)) = file_copy[index + 1].split_once('=') else { + continue; + }; + let prefix = prefix.trim(); + let prefix2 = prefix2.trim(); + // FIXME: Right now, remove_dup_assign cares about assignments to the exact same place. + // However, given an assigemnt like this: + // ``` + // A.0 = 1_u32; + // A = (2_u32, 3.0); + // ``` + // The first assignment could be safely omitted. + // Additionally, we try to check if the second assignment could depend on the first one. + // In such cases, the result is likely to change, so we bail. + if prefix == prefix2 && !postifx2.contains(prefix) { + file_copy[index] = "".into(); + reduction_count += 1; + } + } + // We have removed no lines - no point in testing. + if reduction_count == 0 { + return; + } + // Check if the removed lines affected the execution result in any way, shape or form. + if test_reduction(&file_copy, path, cache) { + println!("Reduced {path:?} by {reduction_count} lines `remove_dup_assign`"); + *file = file_copy; + } else { + // The execution result changed. + // This can occur if the second assignment depended on the first one. + // Eg. + // ``` + // a = b + c; + // a = a + d; + // ``` + remove_dup_assign(file, path, starts, (starts + ends) / 2, cache); + remove_dup_assign(file, path, (starts + ends) / 2, ends, cache); + } + save_reduction(file, path, "remove_dup_assign"); +} + +/// Removes all the unneeded calls to `dump_var`. This is not something tools like `cvise` can do, +/// but it greately speeds up MIR interpretation + native execution. +fn remove_dump_var(file: &mut Vec<String>, path: &PathBuf) { + let mut curr = 0; + // ... try disabling `dump_vars` one by one, until only the necessary ones are left. + while curr < file.len() { + let Some(line) = file[curr..].iter().position(|line| line.contains("dump_var")) else { + // No more `dump_var`s to remove - exit early. + break; + }; + // Make the line absolute again. + let line = line + curr; + let mut file_copy = file.clone(); + // Try removing 3 consecutive lines(the call, block end and block beginning). This effectively removes a `dump_var`. + file_copy.remove(line); + file_copy.remove(line); + file_copy.remove(line); + // Not cached - the execution result can change. + let mut uncached = None; + // Check if this reduction is valid. + if test_reduction(&file_copy, path, &mut uncached) { + println!("Reduced {path:?} by 3 lines `remove_dump_var`"); + *file = file_copy; + curr = line; + } else { + curr = line + 1; + } + } + save_reduction(file, path, "remove_dump_var"); +} + +/// Replaces matches with gotos where possible. +/// This exploits some properties of rustlantis(match arm order), +/// and is only soundly applicable to MIR generated by it. +/// Still, it is not something `cvise` can do, but it simplifies the code a ton. +fn match_to_goto(file: &mut Vec<String>, path: &PathBuf, cache: &mut ResultCache) { + let mut curr = 0; + + while curr < file.len() { + let Some(match_starts) = file[curr..].iter().position(|line| line.contains("match")) else { + // No more `match`es to remove - exit early. + break; + }; + let match_starts = match_starts + curr; + // Find the end of the match + let Some(match_ends) = file[match_starts..].iter().position(|line| line.contains('}')) + else { + // Can't find match end - exit early. + break; + }; + let match_ends = match_ends + match_starts; + let match_body = &file[match_starts..match_ends]; + + // Find where this match should normally jump to. + // This *should* be the second-last arm of the match, as per the paper(the remaining blocks are decoys). + // If this ever changes, this reduction may not always be sound. + // This is not a problem, however: we NEED to use MIRI for reduction anwyway, + // and it will catch this issue. + let jumps_to = &match_body[match_body.len() - 2].trim(); + let Some((_, bb_ident)) = jumps_to.split_once("bb") else { + break; + }; + // We now have the number of the block we jump to at runtime. + let bb_ident = bb_ident.trim_matches(','); + // Try replacing this match with an unconditional jump. + let mut file_copy = file.clone(); + for _ in match_starts..(match_ends + 1) { + file_copy.remove(match_starts); + } + file_copy.insert(match_starts, format!("Goto(bb{bb_ident})\n")); + if test_reduction(&file_copy, path, cache) { + println!("Reduced {path:?} by {} lines `match_to_goto`", match_ends - match_starts); + *file = file_copy; + curr = match_starts; + } else { + curr = match_ends; + } + } + save_reduction(file, path, "match_to_goto"); +} + +/// At this point, we can try "killing" blocks, by replacing their bodies with calls to `abort`. +/// This is always sound(the program aborts, so no UB can occur after the block), +/// and allows us to safely remove *a lot* of unneeded blocks. +fn block_abort(file: &mut Vec<String>, path: &PathBuf, cache: &mut ResultCache) { + let mut curr = 0; + while curr < file.len() { + let Some(block_starts) = file[curr..] + .iter() + .position(|line| line.starts_with("bb") && line.trim_end().ends_with(" = {")) + else { + // No more `block`s to kill - exit early. + break; + }; + let block_starts = block_starts + curr; + // Find the beginning of the next block to find the end of this block. + let Some(block_ends) = file[(block_starts + 1)..] + .iter() + .position(|line| line.starts_with("bb") && line.trim_end().ends_with(" = {")) + else { + // No more `block`s to kill - exit early. + break; + }; + let block_ends = block_starts + block_ends; + let block_starts = block_starts + 1; + let mut file_copy = file.clone(); + // Remove the block body... + for _ in block_starts..(block_ends) { + file_copy.remove(block_starts); + } + // ..and insert an unconditional call to abort. + file_copy.insert( + block_starts, + "Call(tmp = core::intrinsics::abort(), ReturnTo(bb1), UnwindUnreachable())\n" + .to_string(), + ); + file_copy.insert(block_starts, "let tmp = ();\n".to_string()); + + if test_reduction(&file_copy, path, cache) { + println!("Reduced {path:?} by {} lines `block_abort`", block_ends - block_starts - 2); + *file = file_copy; + curr = block_starts; + } else { + curr = block_ends; + } + } + save_reduction(file, path, "block_abort"); +} + +/// Removes unreachable basic blocks +fn remove_block(file: &mut Vec<String>, path: &PathBuf, cache: &mut ResultCache) { + let mut curr = 0; + + // Next, we try to outright remove blocks. + while curr < file.len() { + let Some(block_starts) = file[curr..] + .iter() + .position(|line| line.starts_with("bb") && line.trim_end().ends_with(" = {")) + else { + // No more `block`s to remove - exit early. + break; + }; + let block_starts = block_starts + curr; + // Find the beginning of the next block to find the end of this block. + let Some(block_ends) = file[(block_starts + 1)..] + .iter() + .position(|line| line.starts_with("bb") && line.trim_end().ends_with(" = {")) + else { + // No more `block`s to remove - exit early. + break; + }; + let block_ends = block_starts + block_ends + 1; + // Large blocks are likely to be necessary. + if block_ends - block_starts > 6 { + curr = block_starts + 1; + continue; + } + let mut file_copy = file.clone(); + file_copy.drain(block_starts..block_ends); + if test_reduction(&file_copy, path, cache) { + println!("Reduced {path:?} by {} lines `remove_blocks`", block_ends - block_starts); + *file = file_copy; + curr = block_starts; + } else { + curr = block_starts + 1; + } + } + save_reduction(file, path, "remove_block"); +} + +/// Merges blocks ending with unconditional jumps. +fn linearize_cf(file: &mut Vec<String>, path: &PathBuf, cache: &mut ResultCache) { + let mut curr = 0; + + // Next, we try to linearize the control flow. What the does that mean? + // Given a sequence like this: + // Goto(bb22) + // } + // bb22 = { + // We remove those 3 lines, merging the blocks together. This is not something `cvise` can do, + // and it makes other transformations easier. + while curr < file.len() { + let Some(block_starts) = file[curr..] + .iter() + .position(|line| line.starts_with("bb") && line.trim_end().ends_with(" = {")) + else { + // No more `block`s to remove - exit early. + break; + }; + let block_starts = block_starts + curr; + // Extract the block id. + let Some((block, _)) = file[block_starts].split_once('=') else { + curr = block_starts + 1; + continue; + }; + let block = block.trim(); + if file[block_starts - 2].trim() != format!("Goto({block})") { + curr = block_starts + 1; + continue; + } + let mut file_copy = file.clone(); + // Try removing 3 consecutive lines(the goto, block end and block beginning). This effectively removes a `Goto(next)`. + file_copy.remove(block_starts - 2); + file_copy.remove(block_starts - 2); + file_copy.remove(block_starts - 2); + // Check if this reduction is valid. + if test_reduction(&file_copy, path, cache) { + println!("Reduced {path:?} by 3 lines `linearize_cf`"); + *file = file_copy; + curr = block_starts; + } else { + curr = block_starts + 1; + } + } + save_reduction(file, path, "linearize_cf"); +} + +/// Replaces a call to a given function with a 0 assignment to the destination place, and a Goto. +/// This is always sound, because: +/// 1. All the functions arguments are always initialized +/// 2. and point to initialized memory(the operand of &raw must be an initialized place in rustlantis). +fn remove_fn_calls(file: &mut Vec<String>, path: &PathBuf, cache: &mut ResultCache) { + let mut curr = 0; + + while curr < file.len() { + let Some(fn_call) = + file[curr..].iter().position(|line| line.contains("Call(") && line.contains(" = fn")) + else { + // No more calls to remove - exit early. + break; + }; + let fn_call = fn_call + curr; + let line = file[fn_call].trim(); + // Skip the Call( + let line = &line["Call(".len()..]; + // Extract the destination place + let Some((place, line)) = line.split_once('=') else { + curr = fn_call + 1; + continue; + }; + // Skip till the return block id. + let Some((_, line)) = line.split_once("ReturnTo(") else { + curr = fn_call + 1; + continue; + }; + // Extract the full return block + let Some((block, _)) = line.split_once(')') else { + curr = fn_call + 1; + continue; + }; + let mut file_copy = file.clone(); + // Remove the call. + file_copy.remove(fn_call); + file_copy.insert(fn_call, format!("Goto({block})\n")); + file_copy.insert(fn_call, format!("{place} = 0;\n")); + // Check if this reduction is valid. + if test_reduction(&file_copy, path, cache) { + println!("Reduced {path:?} using `remove_fn_calls` {cache:?}"); + *file = file_copy; + curr = fn_call; + } else { + curr = fn_call + 1; + } + } + save_reduction(file, path, "remove_fn_calls"); +} + +/// Fully removes unreachable functions. +fn remove_fns(file: &mut Vec<String>, path: &PathBuf, cache: &mut ResultCache) { + let mut curr = 0; + + while curr < file.len() { + // Find a function start + let Some(fn_start) = file[curr..].iter().position(|line| { + line.contains("#[custom_mir(dialect = \"runtime\", phase = \"initial\")]") + }) else { + // No more functions to remove - exit early. + break; + }; + // Find the next function(and use that to find the end of this one). + // FIXME: this check is flawed: it will never remove the very last function(the one before main). + // The other checks will turn that function into a single call to abort, but it is still annoying that it is kept. + let fn_start = fn_start + curr; + let Some(fn_end) = file[(fn_start + 3)..].iter().position(|line| line.contains("fn fn")) + else { + // No more functions to remove - exit early. + break; + }; + let fn_end = fn_start + 2 + fn_end; + let mut file_copy = file.clone(); + // Remove the function.\\ + file_copy.drain(fn_start..fn_end); + // Check if this reduction is valid. + if test_reduction(&file_copy, path, cache) { + println!("Reduced {path:?} by {} lines `remove_fns`", fn_end - fn_start); + *file = file_copy; + } else { + curr = fn_start + 1; + } + } + save_reduction(file, path, "remove_fns"); +} + +pub(super) fn reduce(path: impl AsRef<Path>) { + let path = path.as_ref().to_owned(); + // ... read the file to a buffer .. + let file = std::fs::read_to_string(&path).expect("Could not open the file to reduce"); + let mut file: Vec<_> = file.split_inclusive('\n').map(|s| s.to_string()).collect(); + + // ... and run reduction passes. + println!("running `remove_dump_var` on {path:?}."); + remove_dump_var(&mut file, &path); + // After `dump_var`, the execution results ought not to change. Cache them. + let mut cache = None; + // Fill the cache + assert!( + test_reduction(&file, &path, &mut cache), + "Reduction error: check that the input file is a valid reproducer." + ); + println!("cache:{cache:?}"); + println!("running `remove_fn_calls` on {path:?}."); + remove_fn_calls(&mut file, &path, &mut cache); + println!("running `remove_fns` on {path:?}."); + remove_fns(&mut file, &path, &mut cache); + let len = file.len(); + println!("running `remove_dup_assign` on {path:?}."); + remove_dup_assign(&mut file, &path, 0, len, &mut cache); + file.retain(|line| !line.is_empty()); + println!("running `match_to_goto` on {path:?}."); + match_to_goto(&mut file, &path, &mut cache); + println!("running `block_abort` on {path:?}."); + block_abort(&mut file, &path, &mut cache); + println!("running `remove_block` on {path:?}."); + remove_block(&mut file, &path, &mut cache); + println!("running `linearize_cf` on {path:?}."); + linearize_cf(&mut file, &path, &mut cache); + let mut out = std::fs::File::create(&path).expect("Could not save the reduction result."); + let file = file.into_iter().collect::<String>(); + out.write_all(file.as_bytes()).expect("failed to write into file"); +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/info.rs b/compiler/rustc_codegen_gcc/build_system/src/info.rs new file mode 100644 index 00000000000..66fdcf88cbb --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/info.rs @@ -0,0 +1,21 @@ +use crate::config::ConfigInfo; + +pub fn run() -> Result<(), String> { + let mut config = ConfigInfo::default(); + + // We skip binary name and the `info` command. + let mut args = std::env::args().skip(2); + while let Some(arg) = args.next() { + if arg == "--help" { + println!("Display the path where the libgccjit will be located"); + return Ok(()); + } + config.parse_argument(&arg, &mut args)?; + } + config.no_download = true; + config.setup_gcc_path()?; + if let Some(gcc_path) = config.gcc_path { + println!("{gcc_path}"); + } + Ok(()) +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/main.rs b/compiler/rustc_codegen_gcc/build_system/src/main.rs new file mode 100644 index 00000000000..ae975c94fff --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/main.rs @@ -0,0 +1,113 @@ +use std::{env, process}; + +mod abi_test; +mod build; +mod clean; +mod clone_gcc; +mod config; +mod fmt; +mod fuzz; +mod info; +mod prepare; +mod rust_tools; +mod rustc_info; +mod test; +mod utils; +const BUILD_DIR: &str = "build"; + +macro_rules! arg_error { + ($($err:tt)*) => {{ + eprintln!($($err)*); + eprintln!(); + usage(); + std::process::exit(1); + }}; +} + +fn usage() { + println!( + "\ +rustc_codegen_gcc build system + +Usage: build_system [command] [options] + +Options: + --help : Displays this help message. + +Commands: + cargo : Executes a cargo command. + rustc : Compiles the program using the GCC compiler. + clean : Cleans the build directory, removing all compiled files and artifacts. + prepare : Prepares the environment for building, including fetching dependencies and setting up configurations. + build : Compiles the project. + test : Runs tests for the project. + info : Displays information about the build environment and project configuration. + clone-gcc : Clones the GCC compiler from a specified source. + fmt : Runs rustfmt + fuzz : Fuzzes `cg_gcc` using rustlantis + abi-test : Runs the abi-cafe test suite on the codegen, checking for ABI compatibility with LLVM" + ); +} + +pub enum Command { + Cargo, + Clean, + CloneGcc, + Prepare, + Build, + Rustc, + Test, + Info, + Fmt, + Fuzz, + AbiTest, +} + +fn main() { + if env::var("RUST_BACKTRACE").is_err() { + unsafe { + env::set_var("RUST_BACKTRACE", "1"); + } + } + + let command = match env::args().nth(1).as_deref() { + Some("cargo") => Command::Cargo, + Some("rustc") => Command::Rustc, + Some("clean") => Command::Clean, + Some("prepare") => Command::Prepare, + Some("build") => Command::Build, + Some("test") => Command::Test, + Some("info") => Command::Info, + Some("clone-gcc") => Command::CloneGcc, + Some("abi-test") => Command::AbiTest, + Some("fmt") => Command::Fmt, + Some("fuzz") => Command::Fuzz, + Some("--help") => { + usage(); + process::exit(0); + } + Some(flag) if flag.starts_with('-') => arg_error!("Expected command found flag {}", flag), + Some(command) => arg_error!("Unknown command {}", command), + None => { + usage(); + process::exit(0); + } + }; + + if let Err(e) = match command { + Command::Cargo => rust_tools::run_cargo(), + Command::Rustc => rust_tools::run_rustc(), + Command::Clean => clean::run(), + Command::Prepare => prepare::run(), + Command::Build => build::run(), + Command::Test => test::run(), + Command::Info => info::run(), + Command::CloneGcc => clone_gcc::run(), + Command::Fmt => fmt::run(), + Command::Fuzz => fuzz::run(), + Command::AbiTest => abi_test::run(), + } { + eprintln!("Command failed to run: {e}"); + process::exit(1); + } +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/prepare.rs b/compiler/rustc_codegen_gcc/build_system/src/prepare.rs new file mode 100644 index 00000000000..35a6e20fb86 --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/prepare.rs @@ -0,0 +1,261 @@ +use std::fs; +use std::path::{Path, PathBuf}; + +use crate::rustc_info::get_rustc_path; +use crate::utils::{ + cargo_install, create_dir, get_sysroot_dir, git_clone_root_dir, remove_file, run_command, + run_command_with_output, walk_dir, +}; + +fn prepare_libcore( + sysroot_path: &Path, + libgccjit12_patches: bool, + cross_compile: bool, + sysroot_source: Option<String>, +) -> Result<(), String> { + let rustlib_dir: PathBuf; + + if let Some(path) = sysroot_source { + rustlib_dir = Path::new(&path) + .canonicalize() + .map_err(|error| format!("Failed to canonicalize path: {error:?}"))?; + if !rustlib_dir.is_dir() { + return Err(format!("Custom sysroot path {rustlib_dir:?} not found")); + } + } else { + let rustc_path = match get_rustc_path() { + Some(path) => path, + None => return Err("`rustc` path not found".to_string()), + }; + + let parent = match rustc_path.parent() { + Some(path) => path, + None => return Err(format!("No parent for `{}`", rustc_path.display())), + }; + + rustlib_dir = parent + .join("../lib/rustlib/src/rust") + .canonicalize() + .map_err(|error| format!("Failed to canonicalize path: {error:?}"))?; + if !rustlib_dir.is_dir() { + return Err("Please install `rust-src` component".to_string()); + } + } + + let sysroot_dir = sysroot_path.join("sysroot_src"); + if sysroot_dir.is_dir() + && let Err(error) = fs::remove_dir_all(&sysroot_dir) + { + return Err(format!("Failed to remove `{}`: {:?}", sysroot_dir.display(), error,)); + } + + let sysroot_library_dir = sysroot_dir.join("library"); + create_dir(&sysroot_library_dir)?; + + run_command(&[&"cp", &"-r", &rustlib_dir.join("library"), &sysroot_dir], None)?; + + println!("[GIT] init (cwd): `{}`", sysroot_dir.display()); + run_command(&[&"git", &"init"], Some(&sysroot_dir))?; + println!("[GIT] add (cwd): `{}`", sysroot_dir.display()); + run_command(&[&"git", &"add", &"."], Some(&sysroot_dir))?; + println!("[GIT] commit (cwd): `{}`", sysroot_dir.display()); + + // This is needed on systems where nothing is configured. + // git really needs something here, or it will fail. + // Even using --author is not enough. + run_command(&[&"git", &"config", &"user.email", &"none@example.com"], Some(&sysroot_dir))?; + run_command(&[&"git", &"config", &"user.name", &"None"], Some(&sysroot_dir))?; + run_command(&[&"git", &"config", &"core.autocrlf", &"false"], Some(&sysroot_dir))?; + run_command(&[&"git", &"config", &"commit.gpgSign", &"false"], Some(&sysroot_dir))?; + run_command(&[&"git", &"commit", &"-m", &"Initial commit", &"-q"], Some(&sysroot_dir))?; + + let mut patches = Vec::new(); + walk_dir( + "patches", + &mut |_| Ok(()), + &mut |file_path: &Path| { + patches.push(file_path.to_path_buf()); + Ok(()) + }, + false, + )?; + if cross_compile { + walk_dir( + "patches/cross_patches", + &mut |_| Ok(()), + &mut |file_path: &Path| { + patches.push(file_path.to_path_buf()); + Ok(()) + }, + false, + )?; + } + if libgccjit12_patches { + walk_dir( + "patches/libgccjit12", + &mut |_| Ok(()), + &mut |file_path: &Path| { + patches.push(file_path.to_path_buf()); + Ok(()) + }, + false, + )?; + } + patches.sort(); + for file_path in patches { + println!("[GIT] apply `{}`", file_path.display()); + let path = Path::new("../../..").join(file_path); + run_command_with_output(&[&"git", &"apply", &path], Some(&sysroot_dir))?; + run_command_with_output(&[&"git", &"add", &"-A"], Some(&sysroot_dir))?; + run_command_with_output( + &[&"git", &"commit", &"--no-gpg-sign", &"-m", &format!("Patch {}", path.display())], + Some(&sysroot_dir), + )?; + } + println!("Successfully prepared libcore for building"); + + Ok(()) +} + +// TODO: remove when we can ignore warnings in rustdoc tests. +fn prepare_rand() -> Result<(), String> { + // Apply patch for the rand crate. + let file_path = "patches/crates/0001-Remove-deny-warnings.patch"; + let rand_dir = Path::new("build/rand"); + println!("[GIT] apply `{file_path}`"); + let path = Path::new("../..").join(file_path); + run_command_with_output(&[&"git", &"apply", &path], Some(rand_dir))?; + run_command_with_output(&[&"git", &"add", &"-A"], Some(rand_dir))?; + run_command_with_output( + &[&"git", &"commit", &"--no-gpg-sign", &"-m", &format!("Patch {}", path.display())], + Some(rand_dir), + )?; + + Ok(()) +} + +// build with cg_llvm for perf comparison +fn build_raytracer(repo_dir: &Path) -> Result<(), String> { + run_command(&[&"cargo", &"build"], Some(repo_dir))?; + let mv_target = repo_dir.join("raytracer_cg_llvm"); + if mv_target.is_file() { + remove_file(&mv_target)?; + } + run_command(&[&"mv", &"target/debug/main", &"raytracer_cg_llvm"], Some(repo_dir))?; + Ok(()) +} + +fn clone_and_setup<F>(repo_url: &str, checkout_commit: &str, extra: Option<F>) -> Result<(), String> +where + F: Fn(&Path) -> Result<(), String>, +{ + let clone_result = git_clone_root_dir(repo_url, Path::new(crate::BUILD_DIR), false)?; + if !clone_result.ran_clone { + println!("`{}` has already been cloned", clone_result.repo_name); + } + let repo_path = Path::new(crate::BUILD_DIR).join(&clone_result.repo_name); + run_command(&[&"git", &"checkout", &"--", &"."], Some(&repo_path))?; + run_command(&[&"git", &"checkout", &checkout_commit], Some(&repo_path))?; + if let Some(extra) = extra { + extra(&repo_path)?; + } + Ok(()) +} + +struct PrepareArg { + cross_compile: bool, + only_libcore: bool, + libgccjit12_patches: bool, + sysroot_source: Option<String>, +} + +impl PrepareArg { + fn new() -> Result<Option<Self>, String> { + let mut only_libcore = false; + let mut cross_compile = false; + let mut libgccjit12_patches = false; + let mut sysroot_source = None; + + let mut args = std::env::args().skip(2); + while let Some(arg) = args.next() { + match arg.as_str() { + "--only-libcore" => only_libcore = true, + "--cross" => cross_compile = true, + "--libgccjit12-patches" => libgccjit12_patches = true, + "--sysroot-source" => { + if let Some(path) = args.next() { + sysroot_source = Some(path); + } else { + return Err( + "Expected a value after `--sysroot-source`, found nothing".to_string() + ); + } + } + "--help" => { + Self::usage(); + return Ok(None); + } + a => return Err(format!("Unknown argument `{a}`")), + } + } + Ok(Some(Self { cross_compile, only_libcore, libgccjit12_patches, sysroot_source })) + } + + fn usage() { + println!( + r#" +`prepare` command help: + + --only-libcore : Only setup libcore and don't clone other repositories + --cross : Apply the patches needed to do cross-compilation + --libgccjit12-patches : Apply patches needed for libgccjit12 + --sysroot-source : Specify custom path for sysroot source + --help : Show this help"# + ) + } +} + +pub fn run() -> Result<(), String> { + let args = match PrepareArg::new()? { + Some(a) => a, + None => return Ok(()), + }; + let sysroot_path = get_sysroot_dir(); + prepare_libcore( + &sysroot_path, + args.libgccjit12_patches, + args.cross_compile, + args.sysroot_source, + )?; + + if !args.only_libcore { + cargo_install("hyperfine")?; + + let to_clone = &[ + ( + "https://github.com/rust-random/rand.git", + "1f4507a8e1cf8050e4ceef95eeda8f64645b6719", + None, + ), + ( + "https://github.com/rust-lang/regex.git", + "341f207c1071f7290e3f228c710817c280c8dca1", + None, + ), + ( + "https://github.com/ebobby/simple-raytracer", + "804a7a21b9e673a482797aa289a18ed480e4d813", + Some(build_raytracer), + ), + ]; + + for (repo_url, checkout_commit, cb) in to_clone { + clone_and_setup(repo_url, checkout_commit, *cb)?; + } + + prepare_rand()?; + } + + println!("Successfully ran `prepare`"); + Ok(()) +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/rust_tools.rs b/compiler/rustc_codegen_gcc/build_system/src/rust_tools.rs new file mode 100644 index 00000000000..b1faa27acc4 --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/rust_tools.rs @@ -0,0 +1,135 @@ +use std::collections::HashMap; +use std::ffi::OsStr; +#[cfg(unix)] +use std::os::unix::process::CommandExt; +use std::path::PathBuf; + +use crate::config::ConfigInfo; +use crate::utils::{get_toolchain, rustc_toolchain_version_info, rustc_version_info}; + +fn args(command: &str) -> Result<Option<Vec<String>>, String> { + // We skip the binary and the "cargo"/"rustc" option. + if let Some("--help") = std::env::args().nth(2).as_deref() { + usage(command); + return Ok(None); + } + let args = std::env::args().skip(2).collect::<Vec<_>>(); + if args.is_empty() { + return Err(format!( + "Expected at least one argument for `{command}` subcommand, found none" + )); + } + Ok(Some(args)) +} + +fn usage(command: &str) { + println!( + r#" +`{command}` command help: + + [args] : Arguments to be passed to the cargo command + --help : Show this help +"#, + ) +} + +struct RustcTools { + env: HashMap<String, String>, + args: Vec<String>, + toolchain: String, + config: ConfigInfo, +} + +impl RustcTools { + fn new(command: &str) -> Result<Option<Self>, String> { + let Some(args) = args(command)? else { return Ok(None) }; + + // We first need to go to the original location to ensure that the config setup will go as + // expected. + let current_dir = std::env::current_dir() + .and_then(|path| path.canonicalize()) + .map_err(|error| format!("Failed to get current directory path: {error:?}"))?; + let current_exe = std::env::current_exe() + .and_then(|path| path.canonicalize()) + .map_err(|error| format!("Failed to get current exe path: {error:?}"))?; + let mut parent_dir = + current_exe.components().map(|comp| comp.as_os_str()).collect::<Vec<_>>(); + // We run this script from "build_system/target/release/y", so we need to remove these elements. + for to_remove in &["y", "release", "target", "build_system"] { + if parent_dir.last().map(|part| part == to_remove).unwrap_or(false) { + parent_dir.pop(); + } else { + return Err(format!( + "Build script not executed from `build_system/target/release/y` (in path {})", + current_exe.display(), + )); + } + } + let parent_dir = PathBuf::from(parent_dir.join(OsStr::new("/"))); + std::env::set_current_dir(&parent_dir).map_err(|error| { + format!("Failed to go to `{}` folder: {:?}", parent_dir.display(), error) + })?; + + let mut env: HashMap<String, String> = std::env::vars().collect(); + let mut config = ConfigInfo::default(); + config.setup(&mut env, false)?; + let toolchain = get_toolchain()?; + + let toolchain_version = rustc_toolchain_version_info(&toolchain)?; + let default_version = rustc_version_info(None)?; + if toolchain_version != default_version { + println!( + "rustc_codegen_gcc is built for {} but the default rustc version is {}.", + toolchain_version.short, default_version.short, + ); + println!("Using {}.", toolchain_version.short); + } + + // We go back to the original folder since we now have set up everything we needed. + std::env::set_current_dir(¤t_dir).map_err(|error| { + format!("Failed to go back to `{}` folder: {:?}", current_dir.display(), error) + })?; + let toolchain = format!("+{toolchain}"); + Ok(Some(Self { toolchain, args, env, config })) + } +} + +fn exec(input: &[&dyn AsRef<OsStr>], env: &HashMap<String, String>) -> Result<(), String> { + #[cfg(unix)] + { + // We use `exec` to call the `execvp` syscall instead of creating a new process where the + // command will be executed because very few signals can actually kill a current process, + // so if segmentation fault (SIGSEGV signal) happens and we raise to the current process, + // it will simply do nothing and we won't have the nice error message for the shell. + let error = crate::utils::get_command_inner(input, None, Some(env)).exec(); + eprintln!("execvp syscall failed: {error:?}"); + std::process::exit(1); + } + #[cfg(not(unix))] + { + if crate::utils::run_command_with_output_and_env_no_err(input, None, Some(env)).is_err() { + std::process::exit(1); + } + Ok(()) + } +} + +pub fn run_cargo() -> Result<(), String> { + let Some(mut tools) = RustcTools::new("cargo")? else { return Ok(()) }; + let rustflags = tools.env.get("RUSTFLAGS").cloned().unwrap_or_default(); + tools.env.insert("RUSTDOCFLAGS".to_string(), rustflags); + let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &tools.toolchain]; + for arg in &tools.args { + command.push(arg); + } + exec(&command, &tools.env) +} + +pub fn run_rustc() -> Result<(), String> { + let Some(tools) = RustcTools::new("rustc")? else { return Ok(()) }; + let mut command = tools.config.rustc_command_vec(); + for arg in &tools.args { + command.push(arg); + } + exec(&command, &tools.env) +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/rustc_info.rs b/compiler/rustc_codegen_gcc/build_system/src/rustc_info.rs new file mode 100644 index 00000000000..0988b56d81e --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/rustc_info.rs @@ -0,0 +1,12 @@ +use std::path::{Path, PathBuf}; + +use crate::utils::run_command; + +pub fn get_rustc_path() -> Option<PathBuf> { + if let Ok(rustc) = std::env::var("RUSTC") { + return Some(PathBuf::from(rustc)); + } + run_command(&[&"rustup", &"which", &"rustc"], None) + .ok() + .map(|out| Path::new(String::from_utf8(out.stdout).unwrap().trim()).to_path_buf()) +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/test.rs b/compiler/rustc_codegen_gcc/build_system/src/test.rs new file mode 100644 index 00000000000..2c8271c36a9 --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/test.rs @@ -0,0 +1,1285 @@ +use std::collections::HashMap; +use std::ffi::OsStr; +use std::fs::{File, remove_dir_all}; +use std::io::{BufRead, BufReader}; +use std::path::{Path, PathBuf}; +use std::str::FromStr; + +use crate::build; +use crate::config::{Channel, ConfigInfo}; +use crate::utils::{ + create_dir, get_sysroot_dir, get_toolchain, git_clone, git_clone_root_dir, remove_file, + run_command, run_command_with_env, run_command_with_output_and_env, rustc_version_info, + split_args, walk_dir, +}; + +type Env = HashMap<String, String>; +type Runner = fn(&Env, &TestArg) -> Result<(), String>; +type Runners = HashMap<&'static str, (&'static str, Runner)>; + +fn get_runners() -> Runners { + let mut runners = HashMap::new(); + + runners.insert("--test-rustc", ("Run all rustc tests", test_rustc as Runner)); + runners + .insert("--test-successful-rustc", ("Run successful rustc tests", test_successful_rustc)); + runners.insert( + "--test-failing-ui-pattern-tests", + ("Run failing ui pattern tests", test_failing_ui_pattern_tests), + ); + runners.insert("--test-failing-rustc", ("Run failing rustc tests", test_failing_rustc)); + runners.insert("--projects", ("Run the tests of popular crates", test_projects)); + runners.insert("--test-libcore", ("Run libcore tests", test_libcore)); + runners.insert("--clean", ("Empty cargo target directory", clean)); + runners.insert("--build-sysroot", ("Build sysroot", build_sysroot)); + runners.insert("--std-tests", ("Run std tests", std_tests)); + runners.insert("--asm-tests", ("Run asm tests", asm_tests)); + runners.insert("--extended-tests", ("Run extended sysroot tests", extended_sysroot_tests)); + runners.insert("--extended-rand-tests", ("Run extended rand tests", extended_rand_tests)); + runners.insert( + "--extended-regex-example-tests", + ("Run extended regex example tests", extended_regex_example_tests), + ); + runners.insert("--extended-regex-tests", ("Run extended regex tests", extended_regex_tests)); + runners.insert("--mini-tests", ("Run mini tests", mini_tests)); + runners.insert("--cargo-tests", ("Run cargo tests", cargo_tests)); + runners +} + +fn get_number_after_arg( + args: &mut impl Iterator<Item = String>, + option: &str, +) -> Result<usize, String> { + match args.next() { + Some(nb) if !nb.is_empty() => match usize::from_str(&nb) { + Ok(nb) => Ok(nb), + Err(_) => Err(format!("Expected a number after `{option}`, found `{nb}`")), + }, + _ => Err(format!("Expected a number after `{option}`, found nothing")), + } +} + +fn show_usage() { + println!( + r#" +`test` command help: + + --release : Build codegen in release mode + --sysroot-panic-abort : Build the sysroot without unwinding support. + --features [arg] : Add a new feature [arg] + --use-system-gcc : Use system installed libgccjit + --build-only : Only build rustc_codegen_gcc then exits + --nb-parts : Used to split rustc_tests (for CI needs) + --current-part : Used with `--nb-parts`, allows you to specify which parts to test"# + ); + ConfigInfo::show_usage(); + for (option, (doc, _)) in get_runners() { + // FIXME: Instead of using the hard-coded `23` value, better to compute it instead. + let needed_spaces = 23_usize.saturating_sub(option.len()); + let spaces: String = std::iter::repeat_n(' ', needed_spaces).collect(); + println!(" {option}{spaces}: {doc}"); + } + println!(" --help : Show this help"); +} + +#[derive(Default, Debug)] +struct TestArg { + build_only: bool, + use_system_gcc: bool, + runners: Vec<String>, + flags: Vec<String>, + /// Additional arguments, to be passed to commands like `cargo test`. + test_args: Vec<String>, + nb_parts: Option<usize>, + current_part: Option<usize>, + sysroot_panic_abort: bool, + config_info: ConfigInfo, + sysroot_features: Vec<String>, + keep_lto_tests: bool, +} + +impl TestArg { + fn new() -> Result<Option<Self>, String> { + let mut test_arg = Self::default(); + + // We skip binary name and the `test` command. + let mut args = std::env::args().skip(2); + let runners = get_runners(); + + while let Some(arg) = args.next() { + match arg.as_str() { + "--features" => match args.next() { + Some(feature) if !feature.is_empty() => { + test_arg.flags.extend_from_slice(&["--features".into(), feature]); + } + _ => { + return Err("Expected an argument after `--features`, found nothing".into()); + } + }, + "--use-system-gcc" => { + println!("Using system GCC"); + test_arg.use_system_gcc = true; + } + "--build-only" => test_arg.build_only = true, + "--nb-parts" => { + test_arg.nb_parts = Some(get_number_after_arg(&mut args, "--nb-parts")?); + } + "--current-part" => { + test_arg.current_part = + Some(get_number_after_arg(&mut args, "--current-part")?); + } + "--sysroot-panic-abort" => { + test_arg.sysroot_panic_abort = true; + } + "--keep-lto-tests" => { + test_arg.keep_lto_tests = true; + } + "--sysroot-features" => match args.next() { + Some(feature) if !feature.is_empty() => { + test_arg.sysroot_features.push(feature); + } + _ => { + return Err(format!("Expected an argument after `{arg}`, found nothing")); + } + }, + "--help" => { + show_usage(); + return Ok(None); + } + "--" => test_arg.test_args.extend(&mut args), + x if runners.contains_key(x) + && !test_arg.runners.iter().any(|runner| runner == x) => + { + test_arg.runners.push(x.into()); + } + arg => { + if !test_arg.config_info.parse_argument(arg, &mut args)? { + return Err(format!("Unknown option {arg}")); + } + } + } + } + match (test_arg.current_part, test_arg.nb_parts) { + (Some(_), Some(_)) | (None, None) => {} + _ => { + return Err( + "If either `--current-part` or `--nb-parts` is specified, the other one \ + needs to be specified as well!" + .to_string(), + ); + } + } + if test_arg.config_info.no_default_features { + test_arg.flags.push("--no-default-features".into()); + } + Ok(Some(test_arg)) + } + + pub fn is_using_gcc_master_branch(&self) -> bool { + !self.config_info.no_default_features + } +} + +fn build_if_no_backend(env: &Env, args: &TestArg) -> Result<(), String> { + if args.config_info.backend.is_some() { + return Ok(()); + } + let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"rustc"]; + let mut tmp_env; + let env = if args.config_info.channel == Channel::Release { + tmp_env = env.clone(); + tmp_env.insert("CARGO_INCREMENTAL".to_string(), "1".to_string()); + command.push(&"--release"); + &tmp_env + } else { + env + }; + for flag in args.flags.iter() { + command.push(flag); + } + run_command_with_output_and_env(&command, None, Some(env)) +} + +fn clean(_env: &Env, args: &TestArg) -> Result<(), String> { + let _ = remove_dir_all(&args.config_info.cargo_target_dir); + let path = Path::new(&args.config_info.cargo_target_dir).join("gccjit"); + create_dir(&path) +} + +fn cargo_tests(test_env: &Env, test_args: &TestArg) -> Result<(), String> { + // First, we call `mini_tests` to build minicore for us. This ensures we are testing with a working `minicore`, + // and that any changes we have made affect `minicore`(since it would get rebuilt). + mini_tests(test_env, test_args)?; + // Then, we copy some of the env vars from `test_env` + // We don't want to pass things like `RUSTFLAGS`, since they contain the -Zcodegen-backend flag. + // That would force `cg_gcc` to *rebuild itself* and only then run tests, which is undesirable. + let mut env = HashMap::new(); + env.insert( + "LD_LIBRARY_PATH".into(), + test_env.get("LD_LIBRARY_PATH").expect("LD_LIBRARY_PATH missing!").to_string(), + ); + env.insert( + "LIBRARY_PATH".into(), + test_env.get("LIBRARY_PATH").expect("LIBRARY_PATH missing!").to_string(), + ); + env.insert( + "CG_RUSTFLAGS".into(), + test_env.get("CG_RUSTFLAGS").map(|s| s.as_str()).unwrap_or("").to_string(), + ); + // Pass all the default args + the user-specified ones. + let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"test"]; + args.extend(test_args.test_args.iter().map(|s| s as &dyn AsRef<OsStr>)); + run_command_with_output_and_env(&args, None, Some(&env))?; + Ok(()) +} + +fn mini_tests(env: &Env, args: &TestArg) -> Result<(), String> { + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[BUILD] mini_core"); + let crate_types = if args.config_info.host_triple != args.config_info.target_triple { + "lib" + } else { + "lib,dylib" + } + .to_string(); + let mut command = args.config_info.rustc_command_vec(); + command.extend_from_slice(&[ + &"example/mini_core.rs", + &"--crate-name", + &"mini_core", + &"--crate-type", + &crate_types, + &"--target", + &args.config_info.target_triple, + ]); + run_command_with_output_and_env(&command, None, Some(env))?; + + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[BUILD] example"); + let mut command = args.config_info.rustc_command_vec(); + command.extend_from_slice(&[ + &"example/example.rs", + &"--crate-type", + &"lib", + &"--target", + &args.config_info.target_triple, + ]); + run_command_with_output_and_env(&command, None, Some(env))?; + + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[AOT] mini_core_hello_world"); + let mut command = args.config_info.rustc_command_vec(); + command.extend_from_slice(&[ + &"example/mini_core_hello_world.rs", + &"--crate-name", + &"mini_core_hello_world", + &"--crate-type", + &"bin", + &"-g", + &"--target", + &args.config_info.target_triple, + ]); + run_command_with_output_and_env(&command, None, Some(env))?; + + let command: &[&dyn AsRef<OsStr>] = &[ + &Path::new(&args.config_info.cargo_target_dir).join("mini_core_hello_world"), + &"abc", + &"bcd", + ]; + maybe_run_command_in_vm(command, env, args)?; + Ok(()) +} + +fn build_sysroot(env: &Env, args: &TestArg) -> Result<(), String> { + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[BUILD] sysroot"); + let mut config = args.config_info.clone(); + config.features.extend(args.sysroot_features.iter().cloned()); + build::build_sysroot(env, &config)?; + Ok(()) +} + +// TODO(GuillaumeGomez): when rewriting in Rust, refactor with the code in tests/lang_tests_common.rs if possible. +fn maybe_run_command_in_vm( + command: &[&dyn AsRef<OsStr>], + env: &Env, + args: &TestArg, +) -> Result<(), String> { + if !args.config_info.run_in_vm { + run_command_with_output_and_env(command, None, Some(env))?; + return Ok(()); + } + let vm_parent_dir = match env.get("CG_GCC_VM_DIR") { + Some(dir) if !dir.is_empty() => PathBuf::from(dir.clone()), + _ => std::env::current_dir().unwrap(), + }; + let vm_dir = "vm"; + let exe_to_run = command.first().unwrap(); + let exe = Path::new(&exe_to_run); + let exe_filename = exe.file_name().unwrap(); + let vm_home_dir = vm_parent_dir.join(vm_dir).join("home"); + let vm_exe_path = vm_home_dir.join(exe_filename); + let inside_vm_exe_path = Path::new("/home").join(exe_filename); + + let sudo_command: &[&dyn AsRef<OsStr>] = &[&"sudo", &"cp", &exe, &vm_exe_path]; + run_command_with_env(sudo_command, None, Some(env))?; + + let mut vm_command: Vec<&dyn AsRef<OsStr>> = + vec![&"sudo", &"chroot", &vm_dir, &"qemu-m68k-static", &inside_vm_exe_path]; + vm_command.extend_from_slice(command); + run_command_with_output_and_env(&vm_command, Some(&vm_parent_dir), Some(env))?; + Ok(()) +} + +fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> { + let cargo_target_dir = Path::new(&args.config_info.cargo_target_dir); + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[AOT] arbitrary_self_types_pointers_and_wrappers"); + let mut command = args.config_info.rustc_command_vec(); + command.extend_from_slice(&[ + &"example/arbitrary_self_types_pointers_and_wrappers.rs", + &"--crate-name", + &"arbitrary_self_types_pointers_and_wrappers", + &"--crate-type", + &"bin", + &"--target", + &args.config_info.target_triple, + ]); + run_command_with_env(&command, None, Some(env))?; + maybe_run_command_in_vm( + &[&cargo_target_dir.join("arbitrary_self_types_pointers_and_wrappers")], + env, + args, + )?; + + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[AOT] alloc_system"); + let mut command = args.config_info.rustc_command_vec(); + command.extend_from_slice(&[ + &"example/alloc_system.rs", + &"--crate-type", + &"lib", + &"--target", + &args.config_info.target_triple, + ]); + if args.is_using_gcc_master_branch() { + command.extend_from_slice(&[&"--cfg", &"feature=\"master\""]); + } + run_command_with_env(&command, None, Some(env))?; + + // FIXME: doesn't work on m68k. + if args.config_info.host_triple == args.config_info.target_triple { + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[AOT] alloc_example"); + let mut command = args.config_info.rustc_command_vec(); + command.extend_from_slice(&[ + &"example/alloc_example.rs", + &"--crate-type", + &"bin", + &"--target", + &args.config_info.target_triple, + ]); + run_command_with_env(&command, None, Some(env))?; + maybe_run_command_in_vm(&[&cargo_target_dir.join("alloc_example")], env, args)?; + } + + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[AOT] dst_field_align"); + // FIXME(antoyo): Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed. + let mut command = args.config_info.rustc_command_vec(); + command.extend_from_slice(&[ + &"example/dst-field-align.rs", + &"--crate-name", + &"dst_field_align", + &"--crate-type", + &"bin", + &"--target", + &args.config_info.target_triple, + ]); + run_command_with_env(&command, None, Some(env))?; + maybe_run_command_in_vm(&[&cargo_target_dir.join("dst_field_align")], env, args)?; + + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[AOT] std_example"); + let mut command = args.config_info.rustc_command_vec(); + command.extend_from_slice(&[ + &"example/std_example.rs", + &"--crate-type", + &"bin", + &"--target", + &args.config_info.target_triple, + ]); + if args.is_using_gcc_master_branch() { + command.extend_from_slice(&[&"--cfg", &"feature=\"master\""]); + } + run_command_with_env(&command, None, Some(env))?; + maybe_run_command_in_vm( + &[&cargo_target_dir.join("std_example"), &"--target", &args.config_info.target_triple], + env, + args, + )?; + + let test_flags = if let Some(test_flags) = env.get("TEST_FLAGS") { + split_args(test_flags)? + } else { + Vec::new() + }; + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[AOT] subslice-patterns-const-eval"); + let mut command = args.config_info.rustc_command_vec(); + command.extend_from_slice(&[ + &"example/subslice-patterns-const-eval.rs", + &"--crate-type", + &"bin", + &"--target", + &args.config_info.target_triple, + ]); + for test_flag in &test_flags { + command.push(test_flag); + } + run_command_with_env(&command, None, Some(env))?; + maybe_run_command_in_vm(&[&cargo_target_dir.join("subslice-patterns-const-eval")], env, args)?; + + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[AOT] track-caller-attribute"); + let mut command = args.config_info.rustc_command_vec(); + command.extend_from_slice(&[ + &"example/track-caller-attribute.rs", + &"--crate-type", + &"bin", + &"--target", + &args.config_info.target_triple, + ]); + for test_flag in &test_flags { + command.push(test_flag); + } + run_command_with_env(&command, None, Some(env))?; + maybe_run_command_in_vm(&[&cargo_target_dir.join("track-caller-attribute")], env, args)?; + + Ok(()) +} + +fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<PathBuf, String> { + let toolchain = format!( + "+{channel}-{host}", + channel = get_toolchain()?, // May also include date + host = args.config_info.host_triple + ); + let rust_dir_path = Path::new(crate::BUILD_DIR).join("rust"); + // If the repository was already cloned, command will fail, so doesn't matter. + let _ = git_clone("https://github.com/rust-lang/rust.git", Some(&rust_dir_path), false); + let rust_dir: Option<&Path> = Some(&rust_dir_path); + run_command(&[&"git", &"checkout", &"--", &"tests/"], rust_dir)?; + run_command_with_output_and_env(&[&"git", &"fetch"], rust_dir, Some(env))?; + let rustc_commit = match rustc_version_info(env.get("RUSTC").map(|s| s.as_str()))?.commit_hash { + Some(commit_hash) => commit_hash, + None => return Err("Couldn't retrieve rustc commit hash".to_string()), + }; + if rustc_commit != "unknown" { + run_command_with_output_and_env( + &[&"git", &"checkout", &rustc_commit], + rust_dir, + Some(env), + )?; + } else { + run_command_with_output_and_env(&[&"git", &"checkout"], rust_dir, Some(env))?; + } + + let cargo = String::from_utf8( + run_command_with_env(&[&"rustup", &"which", &"cargo"], rust_dir, Some(env))?.stdout, + ) + .map_err(|error| format!("Failed to retrieve cargo path: {error:?}")) + .and_then(|cargo| { + let cargo = cargo.trim().to_owned(); + if cargo.is_empty() { Err("`cargo` path is empty".to_string()) } else { Ok(cargo) } + })?; + let rustc = String::from_utf8( + run_command_with_env(&[&"rustup", &toolchain, &"which", &"rustc"], rust_dir, Some(env))? + .stdout, + ) + .map_err(|error| format!("Failed to retrieve rustc path: {error:?}")) + .and_then(|rustc| { + let rustc = rustc.trim().to_owned(); + if rustc.is_empty() { Err("`rustc` path is empty".to_string()) } else { Ok(rustc) } + })?; + let llvm_filecheck = match run_command_with_env( + &[ + &"bash", + &"-c", + &"which FileCheck-10 || \ + which FileCheck-11 || \ + which FileCheck-12 || \ + which FileCheck-13 || \ + which FileCheck-14 || \ + which FileCheck", + ], + rust_dir, + Some(env), + ) { + Ok(cmd) => String::from_utf8_lossy(&cmd.stdout).to_string(), + Err(_) => { + eprintln!("Failed to retrieve LLVM FileCheck, ignoring..."); + // FIXME: the test tests/run-make/no-builtins-attribute will fail if we cannot find + // FileCheck. + String::new() + } + }; + let file_path = rust_dir_path.join("config.toml"); + std::fs::write( + &file_path, + format!( + r#"change-id = 115898 + +[rust] +codegen-backends = [] +deny-warnings = false +verbose-tests = true + +[build] +cargo = "{cargo}" +local-rebuild = true +rustc = "{rustc}" + +[target.x86_64-unknown-linux-gnu] +llvm-filecheck = "{llvm_filecheck}" + +[llvm] +download-ci-llvm = false +"#, + cargo = cargo, + rustc = rustc, + llvm_filecheck = llvm_filecheck.trim(), + ), + ) + .map_err(|error| format!("Failed to write into `{}`: {:?}", file_path.display(), error))?; + Ok(rust_dir_path) +} + +fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> { + let mut env = env.clone(); + let rust_dir = setup_rustc(&mut env, args)?; + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[TEST] rustc asm test suite"); + + let codegen_backend_path = format!( + "{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}", + pwd = std::env::current_dir() + .map_err(|error| format!("`current_dir` failed: {error:?}"))? + .display(), + channel = args.config_info.channel.as_str(), + dylib_ext = args.config_info.dylib_ext, + ); + + let extra = + if args.is_using_gcc_master_branch() { "" } else { " -Csymbol-mangling-version=v0" }; + + let rustc_args = format!( + "-Zpanic-abort-tests -Zcodegen-backend={codegen_backend_path} --sysroot {} -Cpanic=abort{extra}", + args.config_info.sysroot_path + ); + + run_command_with_env( + &[ + &"./x.py", + &"test", + &"--run", + &"always", + &"--stage", + &"0", + &"--set", + &"build.compiletest-allow-stage0=true", + &"tests/assembly-llvm/asm", + &"--compiletest-rustc-args", + &rustc_args, + ], + Some(&rust_dir), + Some(&env), + )?; + Ok(()) +} + +fn run_cargo_command( + command: &[&dyn AsRef<OsStr>], + cwd: Option<&Path>, + env: &Env, + args: &TestArg, +) -> Result<(), String> { + run_cargo_command_with_callback(command, cwd, env, args, |cargo_command, cwd, env| { + run_command_with_output_and_env(cargo_command, cwd, Some(env))?; + Ok(()) + }) +} + +fn run_cargo_command_with_callback<F>( + command: &[&dyn AsRef<OsStr>], + cwd: Option<&Path>, + env: &Env, + args: &TestArg, + callback: F, +) -> Result<(), String> +where + F: Fn(&[&dyn AsRef<OsStr>], Option<&Path>, &Env) -> Result<(), String>, +{ + let toolchain = get_toolchain()?; + let toolchain_arg = format!("+{toolchain}"); + let rustc_version = String::from_utf8( + run_command_with_env(&[&args.config_info.rustc_command[0], &"-V"], cwd, Some(env))?.stdout, + ) + .map_err(|error| format!("Failed to retrieve rustc version: {error:?}"))?; + let rustc_toolchain_version = String::from_utf8( + run_command_with_env( + &[&args.config_info.rustc_command[0], &toolchain_arg, &"-V"], + cwd, + Some(env), + )? + .stdout, + ) + .map_err(|error| format!("Failed to retrieve rustc +toolchain version: {error:?}"))?; + + if rustc_version != rustc_toolchain_version { + eprintln!( + "rustc_codegen_gcc is built for `{rustc_toolchain_version}` but the default rustc version is `{rustc_version}`.", + ); + eprintln!("Using `{rustc_toolchain_version}`."); + } + let mut env = env.clone(); + let rustflags = env.get("RUSTFLAGS").cloned().unwrap_or_default(); + env.insert("RUSTDOCFLAGS".to_string(), rustflags); + let mut cargo_command: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &toolchain_arg]; + cargo_command.extend_from_slice(command); + callback(&cargo_command, cwd, &env) +} + +// FIXME(antoyo): linker gives multiple definitions error on Linux +// echo "[BUILD] sysroot in release mode" +// ./build_sysroot/build_sysroot.sh --release + +fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> { + let projects = [ + //"https://gitlab.gnome.org/GNOME/librsvg", // FIXME: doesn't compile in the CI since the + // version of cairo and other libraries is too old. + "https://github.com/rust-random/getrandom", + "https://github.com/BurntSushi/memchr", + "https://github.com/dtolnay/itoa", + "https://github.com/rust-lang/cfg-if", + //"https://github.com/rust-lang-nursery/lazy-static.rs", // TODO: re-enable when the + //failing test is fixed upstream. + //"https://github.com/marshallpierce/rust-base64", // FIXME: one test is OOM-killed. + // TODO: ignore the base64 test that is OOM-killed. + //"https://github.com/time-rs/time", // FIXME: one test fails (https://github.com/time-rs/time/issues/719). + "https://github.com/rust-lang/log", + "https://github.com/bitflags/bitflags", + //"https://github.com/serde-rs/serde", // FIXME: one test fails. + //"https://github.com/rayon-rs/rayon", // TODO: very slow, only run on master? + //"https://github.com/rust-lang/cargo", // TODO: very slow, only run on master? + ]; + + let mut env = env.clone(); + let rustflags = + format!("{} --cap-lints allow", env.get("RUSTFLAGS").cloned().unwrap_or_default()); + env.insert("RUSTFLAGS".to_string(), rustflags); + let run_tests = |projects_path, iter: &mut dyn Iterator<Item = &&str>| -> Result<(), String> { + for project in iter { + let clone_result = git_clone_root_dir(project, projects_path, true)?; + let repo_path = Path::new(&clone_result.repo_dir); + run_cargo_command(&[&"build", &"--release"], Some(repo_path), &env, args)?; + run_cargo_command(&[&"test"], Some(repo_path), &env, args)?; + } + + Ok(()) + }; + + let projects_path = Path::new("projects"); + create_dir(projects_path)?; + + let nb_parts = args.nb_parts.unwrap_or(0); + if nb_parts > 0 { + // We increment the number of tests by one because if this is an odd number, we would skip + // one test. + let count = projects.len() / nb_parts + 1; + let current_part = args.current_part.unwrap(); + let start = current_part * count; + // We remove the projects we don't want to test. + run_tests(projects_path, &mut projects.iter().skip(start).take(count))?; + } else { + run_tests(projects_path, &mut projects.iter())?; + } + + Ok(()) +} + +fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> { + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[TEST] libcore"); + let path = get_sysroot_dir().join("sysroot_src/library/coretests"); + let _ = remove_dir_all(path.join("target")); + // TODO(antoyo): run in release mode when we fix the failures. + run_cargo_command(&[&"test"], Some(&path), env, args)?; + Ok(()) +} + +fn extended_rand_tests(env: &Env, args: &TestArg) -> Result<(), String> { + if !args.is_using_gcc_master_branch() { + println!("Not using GCC master branch. Skipping `extended_rand_tests`."); + return Ok(()); + } + let mut env = env.clone(); + // newer aho_corasick versions throw a deprecation warning + let rustflags = + format!("{} --cap-lints warn", env.get("RUSTFLAGS").cloned().unwrap_or_default()); + env.insert("RUSTFLAGS".to_string(), rustflags); + + let path = Path::new(crate::BUILD_DIR).join("rand"); + run_cargo_command(&[&"clean"], Some(&path), &env, args)?; + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[TEST] rust-random/rand"); + run_cargo_command(&[&"test", &"--workspace"], Some(&path), &env, args)?; + Ok(()) +} + +fn extended_regex_example_tests(env: &Env, args: &TestArg) -> Result<(), String> { + if !args.is_using_gcc_master_branch() { + println!("Not using GCC master branch. Skipping `extended_regex_example_tests`."); + return Ok(()); + } + let path = Path::new(crate::BUILD_DIR).join("regex"); + run_cargo_command(&[&"clean"], Some(&path), env, args)?; + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[TEST] rust-lang/regex example shootout-regex-dna"); + let mut env = env.clone(); + // newer aho_corasick versions throw a deprecation warning + let rustflags = + format!("{} --cap-lints warn", env.get("RUSTFLAGS").cloned().unwrap_or_default()); + env.insert("RUSTFLAGS".to_string(), rustflags); + // Make sure `[codegen mono items] start` doesn't poison the diff + run_cargo_command(&[&"build", &"--example", &"shootout-regex-dna"], Some(&path), &env, args)?; + + run_cargo_command_with_callback( + &[&"run", &"--example", &"shootout-regex-dna"], + Some(&path), + &env, + args, + |cargo_command, cwd, env| { + // FIXME: rewrite this with `child.stdin.write_all()` because + // `examples/regexdna-input.txt` is very small. + let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"bash", &"-c"]; + let cargo_args = + cargo_command.iter().map(|s| s.as_ref().to_str().unwrap()).collect::<Vec<_>>(); + let bash_command = format!( + "cat examples/regexdna-input.txt | {} | grep -v 'Spawned thread' > res.txt", + cargo_args.join(" "), + ); + command.push(&bash_command); + run_command_with_output_and_env(&command, cwd, Some(env))?; + run_command_with_output_and_env( + &[&"diff", &"-u", &"res.txt", &"examples/regexdna-output.txt"], + cwd, + Some(env), + )?; + Ok(()) + }, + )?; + + Ok(()) +} + +fn extended_regex_tests(env: &Env, args: &TestArg) -> Result<(), String> { + if !args.is_using_gcc_master_branch() { + println!("Not using GCC master branch. Skipping `extended_regex_tests`."); + return Ok(()); + } + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[TEST] rust-lang/regex tests"); + let mut env = env.clone(); + // newer aho_corasick versions throw a deprecation warning + let rustflags = + format!("{} --cap-lints warn", env.get("RUSTFLAGS").cloned().unwrap_or_default()); + env.insert("RUSTFLAGS".to_string(), rustflags); + let path = Path::new(crate::BUILD_DIR).join("regex"); + run_cargo_command( + &[ + &"test", + &"--tests", + &"--", + // FIXME: try removing `--exclude-should-panic` argument + &"--exclude-should-panic", + &"--test-threads", + &"1", + &"-Zunstable-options", + &"-q", + ], + Some(&path), + &env, + args, + )?; + Ok(()) +} + +fn extended_sysroot_tests(env: &Env, args: &TestArg) -> Result<(), String> { + // pushd simple-raytracer + // echo "[BENCH COMPILE] ebobby/simple-raytracer" + // hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "cargo clean" \ + // "RUSTC=rustc RUSTFLAGS='' cargo build" \ + // "../y.sh cargo build" + + // echo "[BENCH RUN] ebobby/simple-raytracer" + // cp ./target/debug/main ./raytracer_cg_gcc + // hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_gcc + // popd + extended_rand_tests(env, args)?; + extended_regex_example_tests(env, args)?; + extended_regex_tests(env, args)?; + + Ok(()) +} + +fn valid_ui_error_pattern_test(file: &str) -> bool { + // contains //~ERROR, but shouldn't be removed + [ + "issues/auxiliary/issue-3136-a.rs", + "type-alias-impl-trait/auxiliary/cross_crate_ice.rs", + "type-alias-impl-trait/auxiliary/cross_crate_ice2.rs", + "macros/rfc-2011-nicer-assert-messages/auxiliary/common.rs", + "imports/ambiguous-1.rs", + "imports/ambiguous-4-extern.rs", + "entry-point/auxiliary/bad_main_functions.rs", + ] + .iter() + .any(|to_ignore| file.ends_with(to_ignore)) +} + +fn contains_ui_error_patterns(file_path: &Path, keep_lto_tests: bool) -> Result<bool, String> { + // Tests generating errors. + let file = File::open(file_path) + .map_err(|error| format!("Failed to read `{}`: {:?}", file_path.display(), error))?; + for line in BufReader::new(file).lines().map_while(Result::ok) { + let line = line.trim(); + if line.is_empty() { + continue; + } + if [ + "//@ error-pattern:", + "//@ build-fail", + "//@ run-fail", + "//@ known-bug", + "-Cllvm-args", + "//~", + "thread", + ] + .iter() + .any(|check| line.contains(check)) + { + return Ok(true); + } + + if !keep_lto_tests + && (line.contains("-Clto") + || line.contains("-C lto") + || line.contains("compile-flags: -Clinker-plugin-lto")) + && !line.contains("-Clto=thin") + { + return Ok(true); + } + + if line.contains("//[") && line.contains("]~") { + return Ok(true); + } + } + let file_path = file_path.display().to_string(); + if file_path.contains("ambiguous-4-extern.rs") { + eprintln!("nothing found for {file_path:?}"); + } + // The files in this directory contain errors. + if file_path.contains("/error-emitter/") { + return Ok(true); + } + Ok(false) +} + +// # Parameters +// +// * `env`: An environment variable that provides context for the function. +// * `args`: The arguments passed to the test. This could include things like the flags, config etc. +// * `prepare_files_callback`: A callback function that prepares the files needed for the test. Its used to remove/retain tests giving Error to run various rust test suits. +// * `run_error_pattern_test`: A boolean that determines whether to run only error pattern tests. +// * `test_type`: A string that indicates the type of the test being run. +// +fn test_rustc_inner<F>( + env: &Env, + args: &TestArg, + prepare_files_callback: F, + run_error_pattern_test: bool, + test_type: &str, +) -> Result<(), String> +where + F: Fn(&Path) -> Result<bool, String>, +{ + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[TEST] rust-lang/rust"); + let mut env = env.clone(); + let rust_path = setup_rustc(&mut env, args)?; + + if !prepare_files_callback(&rust_path)? { + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("Keeping all {test_type} tests"); + } + + if test_type == "ui" { + if run_error_pattern_test { + // After we removed the error tests that are known to panic with rustc_codegen_gcc, we now remove the passing tests since this runs the error tests. + walk_dir( + rust_path.join("tests/ui"), + &mut |_dir| Ok(()), + &mut |file_path| { + if contains_ui_error_patterns(file_path, args.keep_lto_tests)? { + Ok(()) + } else { + remove_file(file_path).map_err(|e| e.to_string()) + } + }, + true, + )?; + } else { + walk_dir( + rust_path.join("tests/ui"), + &mut |dir| { + let dir_name = dir.file_name().and_then(|name| name.to_str()).unwrap_or(""); + if [ + "abi", + "extern", + "unsized-locals", + "proc-macro", + "threads-sendsync", + "borrowck", + "test-attrs", + ] + .contains(&dir_name) + { + remove_dir_all(dir).map_err(|error| { + format!("Failed to remove folder `{}`: {:?}", dir.display(), error) + })?; + } + Ok(()) + }, + &mut |_| Ok(()), + false, + )?; + + // These two functions are used to remove files that are known to not be working currently + // with the GCC backend to reduce noise. + fn dir_handling(keep_lto_tests: bool) -> impl Fn(&Path) -> Result<(), String> { + move |dir| { + if dir.file_name().map(|name| name == "auxiliary").unwrap_or(true) { + return Ok(()); + } + + walk_dir( + dir, + &mut dir_handling(keep_lto_tests), + &mut file_handling(keep_lto_tests), + false, + ) + } + } + + fn file_handling(keep_lto_tests: bool) -> impl Fn(&Path) -> Result<(), String> { + move |file_path| { + if !file_path.extension().map(|extension| extension == "rs").unwrap_or(false) { + return Ok(()); + } + let path_str = file_path.display().to_string().replace("\\", "/"); + if valid_ui_error_pattern_test(&path_str) { + return Ok(()); + } else if contains_ui_error_patterns(file_path, keep_lto_tests)? { + return remove_file(&file_path); + } + Ok(()) + } + } + + walk_dir( + rust_path.join("tests/ui"), + &mut dir_handling(args.keep_lto_tests), + &mut file_handling(args.keep_lto_tests), + false, + )?; + } + let nb_parts = args.nb_parts.unwrap_or(0); + if nb_parts > 0 { + let current_part = args.current_part.unwrap(); + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("Splitting ui_test into {nb_parts} parts (and running part {current_part})"); + let out = String::from_utf8( + run_command( + &[ + &"find", + &"tests/ui", + &"-type", + &"f", + &"-name", + &"*.rs", + &"-not", + &"-path", + &"*/auxiliary/*", + ], + Some(&rust_path), + )? + .stdout, + ) + .map_err(|error| format!("Failed to retrieve output of find command: {error:?}"))?; + let mut files = out + .split('\n') + .map(|line| line.trim()) + .filter(|line| !line.is_empty()) + .collect::<Vec<_>>(); + // To ensure it'll be always the same sub files, we sort the content. + files.sort(); + // We increment the number of tests by one because if this is an odd number, we would skip + // one test. + let count = files.len() / nb_parts + 1; + // We remove the files we don't want to test. + let start = current_part * count; + for path in files.iter().skip(start).take(count) { + remove_file(&rust_path.join(path))?; + } + } + } + + // FIXME: create a function "display_if_not_quiet" or something along the line. + println!("[TEST] rustc {test_type} test suite"); + + let extra = + if args.is_using_gcc_master_branch() { "" } else { " -Csymbol-mangling-version=v0" }; + + let rustc_args = format!( + "{test_flags} -Zcodegen-backend={backend} --sysroot {sysroot}{extra}", + test_flags = env.get("TEST_FLAGS").unwrap_or(&String::new()), + backend = args.config_info.cg_backend_path, + sysroot = args.config_info.sysroot_path, + extra = extra, + ); + + env.get_mut("RUSTFLAGS").unwrap().clear(); + + run_command_with_output_and_env( + &[ + &"./x.py", + &"test", + &"--run", + &"always", + &"--stage", + &"0", + &"--set", + &"build.compiletest-allow-stage0=true", + &format!("tests/{test_type}"), + &"--compiletest-rustc-args", + &rustc_args, + ], + Some(&rust_path), + Some(&env), + )?; + Ok(()) +} + +fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> { + test_rustc_inner(env, args, |_| Ok(false), false, "run-make")?; + test_rustc_inner(env, args, |_| Ok(false), false, "ui") +} + +fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { + let result1 = test_rustc_inner( + env, + args, + retain_files_callback("tests/failing-run-make-tests.txt", "run-make"), + false, + "run-make", + ); + + let result2 = test_rustc_inner( + env, + args, + retain_files_callback("tests/failing-ui-tests.txt", "ui"), + false, + "ui", + ); + + result1.and(result2) +} + +fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { + test_rustc_inner( + env, + args, + remove_files_callback("tests/failing-ui-tests.txt", "ui"), + false, + "ui", + )?; + test_rustc_inner( + env, + args, + remove_files_callback("tests/failing-run-make-tests.txt", "run-make"), + false, + "run-make", + ) +} + +fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String> { + test_rustc_inner( + env, + args, + remove_files_callback("tests/failing-ice-tests.txt", "ui"), + true, + "ui", + ) +} + +fn retain_files_callback<'a>( + file_path: &'a str, + test_type: &'a str, +) -> impl Fn(&Path) -> Result<bool, String> + 'a { + move |rust_path| { + let files = std::fs::read_to_string(file_path).unwrap_or_default(); + let first_file_name = files.lines().next().unwrap_or(""); + // If the first line ends with a `/`, we treat all lines in the file as a directory. + if first_file_name.ends_with('/') { + // Treat as directory + // Removing all tests. + run_command( + &[ + &"find", + &format!("tests/{test_type}"), + &"-mindepth", + &"1", + &"-type", + &"d", + &"-exec", + &"rm", + &"-rf", + &"{}", + &"+", + ], + Some(rust_path), + )?; + } else { + // Treat as file + // Removing all tests. + run_command( + &[ + &"find", + &format!("tests/{test_type}"), + &"-type", + &"f", + &"-name", + &"*.rs", + &"-not", + &"-path", + &"*/auxiliary/*", + &"-delete", + ], + Some(rust_path), + )?; + } + + // Putting back only the failing ones. + if let Ok(files) = std::fs::read_to_string(file_path) { + for file in files.split('\n').map(|line| line.trim()).filter(|line| !line.is_empty()) { + run_command(&[&"git", &"checkout", &"--", &file], Some(rust_path))?; + } + } else { + println!("Failed to read `{file_path}`, not putting back failing {test_type} tests"); + } + + Ok(true) + } +} + +fn remove_files_callback<'a>( + file_path: &'a str, + test_type: &'a str, +) -> impl Fn(&Path) -> Result<bool, String> + 'a { + move |rust_path| { + let files = std::fs::read_to_string(file_path).unwrap_or_default(); + let first_file_name = files.lines().next().unwrap_or(""); + // If the first line ends with a `/`, we treat all lines in the file as a directory. + if first_file_name.ends_with('/') { + // Removing the failing tests. + if let Ok(files) = std::fs::read_to_string(file_path) { + for file in + files.split('\n').map(|line| line.trim()).filter(|line| !line.is_empty()) + { + let path = rust_path.join(file); + if let Err(e) = remove_dir_all(&path) { + println!("Failed to remove directory `{}`: {}", path.display(), e); + } + } + } else { + println!( + "Failed to read `{file_path}`, not putting back failing {test_type} tests" + ); + } + } else { + // Removing the failing tests. + if let Ok(files) = std::fs::read_to_string(file_path) { + for file in + files.split('\n').map(|line| line.trim()).filter(|line| !line.is_empty()) + { + let path = rust_path.join(file); + remove_file(&path)?; + } + } else { + println!("Failed to read `{file_path}`, not putting back failing ui tests"); + } + } + Ok(true) + } +} + +fn run_all(env: &Env, args: &TestArg) -> Result<(), String> { + clean(env, args)?; + mini_tests(env, args)?; + build_sysroot(env, args)?; + std_tests(env, args)?; + // asm_tests(env, args)?; + test_libcore(env, args)?; + extended_sysroot_tests(env, args)?; + cargo_tests(env, args)?; + test_rustc(env, args)?; + + Ok(()) +} + +pub fn run() -> Result<(), String> { + let mut args = match TestArg::new()? { + Some(args) => args, + None => return Ok(()), + }; + let mut env: HashMap<String, String> = std::env::vars().collect(); + + if !args.use_system_gcc { + args.config_info.setup_gcc_path()?; + let gcc_path = args.config_info.gcc_path.clone().expect( + "The config module should have emitted an error if the GCC path wasn't provided", + ); + env.insert("LIBRARY_PATH".to_string(), gcc_path.clone()); + env.insert("LD_LIBRARY_PATH".to_string(), gcc_path); + } + + build_if_no_backend(&env, &args)?; + if args.build_only { + println!("Since it's build only, exiting..."); + return Ok(()); + } + + args.config_info.setup(&mut env, args.use_system_gcc)?; + + if args.runners.is_empty() { + run_all(&env, &args)?; + } else { + let runners = get_runners(); + for runner in args.runners.iter() { + runners.get(runner.as_str()).unwrap().1(&env, &args)?; + } + } + + Ok(()) +} diff --git a/compiler/rustc_codegen_gcc/build_system/src/utils.rs b/compiler/rustc_codegen_gcc/build_system/src/utils.rs new file mode 100644 index 00000000000..fc948c54b24 --- /dev/null +++ b/compiler/rustc_codegen_gcc/build_system/src/utils.rs @@ -0,0 +1,446 @@ +use std::collections::HashMap; +use std::ffi::OsStr; +use std::fmt::Debug; +use std::fs; +#[cfg(unix)] +use std::os::unix::process::ExitStatusExt; +use std::path::{Path, PathBuf}; +use std::process::{Command, ExitStatus, Output}; + +fn exec_command( + input: &[&dyn AsRef<OsStr>], + cwd: Option<&Path>, + env: Option<&HashMap<String, String>>, +) -> Result<ExitStatus, String> { + let status = get_command_inner(input, cwd, env) + .spawn() + .map_err(|e| command_error(input, &cwd, e))? + .wait() + .map_err(|e| command_error(input, &cwd, e))?; + #[cfg(unix)] + { + if let Some(signal) = status.signal() { + // In case the signal didn't kill the current process. + return Err(command_error(input, &cwd, format!("Process received signal {signal}"))); + } + } + Ok(status) +} + +pub(crate) fn get_command_inner( + input: &[&dyn AsRef<OsStr>], + cwd: Option<&Path>, + env: Option<&HashMap<String, String>>, +) -> Command { + let (cmd, args) = match input { + [] => panic!("empty command"), + [cmd, args @ ..] => (cmd, args), + }; + let mut command = Command::new(cmd); + command.args(args); + if let Some(cwd) = cwd { + command.current_dir(cwd); + } + if let Some(env) = env { + command.envs(env.iter().map(|(k, v)| (k.as_str(), v.as_str()))); + } + command +} + +fn check_exit_status( + input: &[&dyn AsRef<OsStr>], + cwd: Option<&Path>, + exit_status: ExitStatus, + output: Option<&Output>, + show_err: bool, +) -> Result<(), String> { + if exit_status.success() { + return Ok(()); + } + let mut error = format!( + "Command `{}`{} exited with status {:?}", + input.iter().map(|s| s.as_ref().to_str().unwrap()).collect::<Vec<_>>().join(" "), + cwd.map(|cwd| format!(" (running in folder `{}`)", cwd.display())).unwrap_or_default(), + exit_status.code() + ); + let input = input.iter().map(|i| i.as_ref()).collect::<Vec<&OsStr>>(); + if show_err { + eprintln!("Command `{input:?}` failed"); + } + if let Some(output) = output { + let stdout = String::from_utf8_lossy(&output.stdout); + if !stdout.is_empty() { + error.push_str("\n==== STDOUT ====\n"); + error.push_str(&stdout); + } + let stderr = String::from_utf8_lossy(&output.stderr); + if !stderr.is_empty() { + error.push_str("\n==== STDERR ====\n"); + error.push_str(&stderr); + } + } + Err(error) +} + +fn command_error<D: Debug>(input: &[&dyn AsRef<OsStr>], cwd: &Option<&Path>, error: D) -> String { + format!( + "Command `{}`{} failed to run: {error:?}", + input.iter().map(|s| s.as_ref().to_str().unwrap()).collect::<Vec<_>>().join(" "), + cwd.as_ref() + .map(|cwd| format!(" (running in folder `{}`)", cwd.display(),)) + .unwrap_or_default(), + ) +} + +pub fn run_command(input: &[&dyn AsRef<OsStr>], cwd: Option<&Path>) -> Result<Output, String> { + run_command_with_env(input, cwd, None) +} + +pub fn run_command_with_env( + input: &[&dyn AsRef<OsStr>], + cwd: Option<&Path>, + env: Option<&HashMap<String, String>>, +) -> Result<Output, String> { + let output = + get_command_inner(input, cwd, env).output().map_err(|e| command_error(input, &cwd, e))?; + check_exit_status(input, cwd, output.status, Some(&output), true)?; + Ok(output) +} + +pub fn run_command_with_output( + input: &[&dyn AsRef<OsStr>], + cwd: Option<&Path>, +) -> Result<(), String> { + let exit_status = exec_command(input, cwd, None)?; + check_exit_status(input, cwd, exit_status, None, true)?; + Ok(()) +} + +pub fn run_command_with_output_and_env( + input: &[&dyn AsRef<OsStr>], + cwd: Option<&Path>, + env: Option<&HashMap<String, String>>, +) -> Result<(), String> { + let exit_status = exec_command(input, cwd, env)?; + check_exit_status(input, cwd, exit_status, None, true)?; + Ok(()) +} + +#[cfg(not(unix))] +pub fn run_command_with_output_and_env_no_err( + input: &[&dyn AsRef<OsStr>], + cwd: Option<&Path>, + env: Option<&HashMap<String, String>>, +) -> Result<(), String> { + let exit_status = exec_command(input, cwd, env)?; + check_exit_status(input, cwd, exit_status, None, false)?; + Ok(()) +} + +pub fn cargo_install(to_install: &str) -> Result<(), String> { + let output = run_command(&[&"cargo", &"install", &"--list"], None)?; + + let to_install_needle = format!("{to_install} "); + // cargo install --list returns something like this: + // + // mdbook-toc v0.8.0: + // mdbook-toc + // rust-reduce v0.1.0: + // rust-reduce + // + // We are only interested into the command name so we only look for lines ending with `:`. + if String::from_utf8(output.stdout) + .unwrap() + .lines() + .any(|line| line.ends_with(':') && line.starts_with(&to_install_needle)) + { + return Ok(()); + } + // We voluntarily ignore this error. + if run_command_with_output(&[&"cargo", &"install", &to_install], None).is_err() { + println!("Skipping installation of `{to_install}`"); + } + Ok(()) +} + +pub fn get_os_name() -> Result<String, String> { + let output = run_command(&[&"uname"], None)?; + let name = std::str::from_utf8(&output.stdout).unwrap_or("").trim().to_string(); + if !name.is_empty() { Ok(name) } else { Err("Failed to retrieve the OS name".to_string()) } +} + +#[derive(Default, PartialEq)] +pub struct RustcVersionInfo { + pub short: String, + pub version: String, + pub host: Option<String>, + pub commit_hash: Option<String>, + pub commit_date: Option<String>, +} + +pub fn rustc_toolchain_version_info(toolchain: &str) -> Result<RustcVersionInfo, String> { + rustc_version_info_inner(None, Some(toolchain)) +} + +pub fn rustc_version_info(rustc: Option<&str>) -> Result<RustcVersionInfo, String> { + rustc_version_info_inner(rustc, None) +} + +fn rustc_version_info_inner( + rustc: Option<&str>, + toolchain: Option<&str>, +) -> Result<RustcVersionInfo, String> { + let output = if let Some(toolchain) = toolchain { + run_command(&[&rustc.unwrap_or("rustc"), &toolchain, &"-vV"], None) + } else { + run_command(&[&rustc.unwrap_or("rustc"), &"-vV"], None) + }?; + let content = std::str::from_utf8(&output.stdout).unwrap_or(""); + + let mut info = RustcVersionInfo::default(); + let mut lines = content.split('\n'); + info.short = match lines.next() { + Some(s) => s.to_string(), + None => return Err("failed to retrieve rustc version".to_string()), + }; + + for line in lines.map(|line| line.trim()) { + match line.split_once(':') { + Some(("host", data)) => info.host = Some(data.trim().to_string()), + Some(("release", data)) => info.version = data.trim().to_string(), + Some(("commit-hash", data)) => info.commit_hash = Some(data.trim().to_string()), + Some(("commit-date", data)) => info.commit_date = Some(data.trim().to_string()), + _ => {} + } + } + if info.version.is_empty() { + Err("failed to retrieve rustc version".to_string()) + } else { + Ok(info) + } +} + +pub fn get_toolchain() -> Result<String, String> { + let content = match fs::read_to_string("rust-toolchain") { + Ok(content) => content, + Err(_) => return Err("No `rust-toolchain` file found".to_string()), + }; + match content + .split('\n') + .map(|line| line.trim()) + .filter(|line| !line.is_empty()) + .filter_map(|line| { + if !line.starts_with("channel") { + return None; + } + line.split('"').nth(1) + }) + .next() + { + Some(toolchain) => Ok(toolchain.to_string()), + None => Err("Couldn't find `channel` in `rust-toolchain` file".to_string()), + } +} + +pub struct CloneResult { + pub ran_clone: bool, + pub repo_name: String, + pub repo_dir: String, +} + +fn git_clone_inner( + to_clone: &str, + dest: &Path, + shallow_clone: bool, + repo_name: String, +) -> Result<CloneResult, String> { + if dest.is_dir() { + return Ok(CloneResult { + ran_clone: false, + repo_name, + repo_dir: dest.display().to_string(), + }); + } + + let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"git", &"clone", &to_clone, &dest]; + if shallow_clone { + command.push(&"--depth"); + command.push(&"1"); + } + run_command_with_output(&command, None)?; + Ok(CloneResult { ran_clone: true, repo_name, repo_dir: dest.display().to_string() }) +} + +fn get_repo_name(url: &str) -> String { + let repo_name = url.split('/').next_back().unwrap(); + match repo_name.strip_suffix(".git") { + Some(n) => n.to_string(), + None => repo_name.to_string(), + } +} + +pub fn git_clone( + to_clone: &str, + dest: Option<&Path>, + shallow_clone: bool, +) -> Result<CloneResult, String> { + let repo_name = get_repo_name(to_clone); + let tmp: PathBuf; + + let dest = match dest { + Some(dest) => dest, + None => { + tmp = repo_name.clone().into(); + &tmp + } + }; + git_clone_inner(to_clone, dest, shallow_clone, repo_name) +} + +pub fn create_dir<P: AsRef<Path>>(path: P) -> Result<(), String> { + fs::create_dir_all(&path).map_err(|error| { + format!("Failed to create directory `{}`: {:?}", path.as_ref().display(), error) + }) +} + +/// This function differs from `git_clone` in how it handles *where* the repository will be cloned. +/// In `git_clone`, it is cloned in the provided path. In this function, the path you provide is +/// the parent folder. So if you pass "a" as folder and try to clone "b.git", it will be cloned into +/// `a/b`. +pub fn git_clone_root_dir( + to_clone: &str, + dest_parent_dir: &Path, + shallow_clone: bool, +) -> Result<CloneResult, String> { + let repo_name = get_repo_name(to_clone); + + git_clone_inner(to_clone, &dest_parent_dir.join(&repo_name), shallow_clone, repo_name) +} + +pub fn walk_dir<P, D, F>( + dir: P, + dir_cb: &mut D, + file_cb: &mut F, + recursive: bool, +) -> Result<(), String> +where + P: AsRef<Path>, + D: FnMut(&Path) -> Result<(), String>, + F: FnMut(&Path) -> Result<(), String>, +{ + let dir = dir.as_ref(); + for entry in fs::read_dir(dir) + .map_err(|error| format!("Failed to read dir `{}`: {:?}", dir.display(), error))? + { + let entry = entry + .map_err(|error| format!("Failed to read entry in `{}`: {:?}", dir.display(), error))?; + let entry_path = entry.path(); + if entry_path.is_dir() { + dir_cb(&entry_path)?; + if recursive { + walk_dir(entry_path, dir_cb, file_cb, recursive)?; // Recursive call + } + } else { + file_cb(&entry_path)?; + } + } + Ok(()) +} + +pub fn split_args(args: &str) -> Result<Vec<String>, String> { + let mut out = Vec::new(); + let mut start = 0; + let args = args.trim(); + let mut iter = args.char_indices().peekable(); + + while let Some((pos, c)) = iter.next() { + if c == ' ' { + out.push(args[start..pos].to_string()); + let mut found_start = false; + while let Some((pos, c)) = iter.peek() { + if *c != ' ' { + start = *pos; + found_start = true; + break; + } else { + iter.next(); + } + } + if !found_start { + return Ok(out); + } + } else if c == '"' || c == '\'' { + let end = c; + let mut found_end = false; + while let Some((_, c)) = iter.next() { + if c == end { + found_end = true; + break; + } else if c == '\\' { + // We skip the escaped character. + iter.next(); + } + } + if !found_end { + return Err(format!("Didn't find `{}` at the end of `{}`", end, &args[start..])); + } + } else if c == '\\' { + // We skip the escaped character. + iter.next(); + } + } + let s = args[start..].trim(); + if !s.is_empty() { + out.push(s.to_string()); + } + Ok(out) +} + +pub fn remove_file<P: AsRef<Path> + ?Sized>(file_path: &P) -> Result<(), String> { + std::fs::remove_file(file_path).map_err(|error| { + format!("Failed to remove `{}`: {:?}", file_path.as_ref().display(), error) + }) +} + +pub fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> Result<(), String> { + #[cfg(windows)] + let symlink = std::os::windows::fs::symlink_file; + #[cfg(not(windows))] + let symlink = std::os::unix::fs::symlink; + + symlink(&original, &link).map_err(|err| { + format!( + "failed to create a symlink `{}` to `{}`: {:?}", + original.as_ref().display(), + link.as_ref().display(), + err, + ) + }) +} + +pub fn get_sysroot_dir() -> PathBuf { + Path::new(crate::BUILD_DIR).join("build_sysroot") +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_split_args() { + // Missing `"` at the end. + assert!(split_args("\"tada").is_err()); + // Missing `'` at the end. + assert!(split_args("\'tada").is_err()); + + assert_eq!( + split_args("a \"b\" c"), + Ok(vec!["a".to_string(), "\"b\"".to_string(), "c".to_string()]) + ); + // Trailing whitespace characters. + assert_eq!( + split_args(" a \"b\" c "), + Ok(vec!["a".to_string(), "\"b\"".to_string(), "c".to_string()]) + ); + } +} diff --git a/compiler/rustc_codegen_gcc/config.example.toml b/compiler/rustc_codegen_gcc/config.example.toml new file mode 100644 index 00000000000..890387dc242 --- /dev/null +++ b/compiler/rustc_codegen_gcc/config.example.toml @@ -0,0 +1,2 @@ +#gcc-path = "gcc-build/gcc" +download-gccjit = true diff --git a/compiler/rustc_codegen_gcc/doc/add-attribute.md b/compiler/rustc_codegen_gcc/doc/add-attribute.md new file mode 100644 index 00000000000..267c1819525 --- /dev/null +++ b/compiler/rustc_codegen_gcc/doc/add-attribute.md @@ -0,0 +1,17 @@ +# Add support for a new function attribute + +To add support for a new function attribute in libgccjit, you need to do the following steps: + + 1. Copy the corresponding function from `c-family/c-attribs.cc` into `jit/dummy-frontend.cc`. For example if you add the `target` attribute, the function name will be `handle_target_attribute`. + 2. Copy the corresponding entry from the `c_common_attribute_table` variable in the `c-family/c-attribs.cc` file into the `jit_attribute_table` variable in `jit/dummy-frontend.cc`. + 3. Add a new variant in the `gcc_jit_fn_attribute` enum in the `jit/libgccjit.h` file. + 4. Add a test to ensure the attribute is correctly applied in `gcc/testsuite/jit.dg/`. Take a look at `gcc/testsuite/jit.dg/test-nonnull.c` if you want an example. + 5. Run the example like this (in your `gcc-build` folder): `make check-jit RUNTESTFLAGS="-v -v -v jit.exp=jit.dg/test-nonnull.c"` + +Once done, you need to update the [gccjit.rs] crate to add the new enum variant in the corresponding enum (`FnAttribute`). + +Finally, you need to update this repository by calling the relevant API you added in [gccjit.rs]. + +To test it, build `gcc`, run `cargo update -p gccjit` and then you can test the generated output for a given Rust crate. + +[gccjit.rs]: https://github.com/rust-lang/gccjit.rs diff --git a/compiler/rustc_codegen_gcc/doc/debugging-libgccjit.md b/compiler/rustc_codegen_gcc/doc/debugging-libgccjit.md new file mode 100644 index 00000000000..be0ec83f7cd --- /dev/null +++ b/compiler/rustc_codegen_gcc/doc/debugging-libgccjit.md @@ -0,0 +1,74 @@ +# Debugging libgccjit + +Sometimes, libgccjit will crash and output an error like this: + +``` +during RTL pass: expand +libgccjit.so: error: in expmed_mode_index, at expmed.h:249 +0x7f0da2e61a35 expmed_mode_index + ../../../gcc/gcc/expmed.h:249 +0x7f0da2e61aa4 expmed_op_cost_ptr + ../../../gcc/gcc/expmed.h:271 +0x7f0da2e620dc sdiv_cost_ptr + ../../../gcc/gcc/expmed.h:540 +0x7f0da2e62129 sdiv_cost + ../../../gcc/gcc/expmed.h:558 +0x7f0da2e73c12 expand_divmod(int, tree_code, machine_mode, rtx_def*, rtx_def*, rtx_def*, int) + ../../../gcc/gcc/expmed.c:4335 +0x7f0da2ea1423 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) + ../../../gcc/gcc/expr.c:9240 +0x7f0da2cd1a1e expand_gimple_stmt_1 + ../../../gcc/gcc/cfgexpand.c:3796 +0x7f0da2cd1c30 expand_gimple_stmt + ../../../gcc/gcc/cfgexpand.c:3857 +0x7f0da2cd90a9 expand_gimple_basic_block + ../../../gcc/gcc/cfgexpand.c:5898 +0x7f0da2cdade8 execute + ../../../gcc/gcc/cfgexpand.c:6582 +``` + +To see the code which causes this error, call the following function: + +```c +gcc_jit_context_dump_to_file(ctxt, "/tmp/output.c", 1 /* update_locations */) +``` + +This will create a C-like file and add the locations into the IR pointing to this C file. +Then, rerun the program and it will output the location in the second line: + +``` +libgccjit.so: /tmp/something.c:61322:0: error: in expmed_mode_index, at expmed.h:249 +``` + +Or add a breakpoint to `add_error` in gdb and print the line number using: + +``` +p loc->m_line +p loc->m_filename->m_buffer +``` + +To print a debug representation of a tree: + +```c +debug_tree(expr); +``` + +(defined in print-tree.h) + +To print a debug representation of a gimple struct: + +```c +debug_gimple_stmt(gimple_struct) +``` + +To get the `rustc` command to run in `gdb`, add the `--verbose` flag to `cargo build`. + +To have the correct file paths in `gdb` instead of `/usr/src/debug/gcc/libstdc++-v3/libsupc++/eh_personality.cc`: + +Maybe by calling the following at the beginning of gdb: + +``` +set substitute-path /usr/src/debug/gcc /path/to/gcc-repo/gcc +``` + +TODO(antoyo): but that's not what I remember I was doing. diff --git a/compiler/rustc_codegen_gcc/doc/debugging.md b/compiler/rustc_codegen_gcc/doc/debugging.md new file mode 100644 index 00000000000..6ff4edf8877 --- /dev/null +++ b/compiler/rustc_codegen_gcc/doc/debugging.md @@ -0,0 +1,38 @@ +# Debugging + +## How to debug GCC LTO + +Run do the command with `-v -save-temps` and then extract the `lto1` line from the output and run that under the debugger. + +## How to debug stdarch tests that cannot be ran locally + +First, run the tests normally: + +---- +cd build/build_sysroot/sysroot_src/library/stdarch/ +STDARCH_TEST_EVERYTHING=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="sde -future -rtm_mode full --" TARGET=x86_64-unknown-linux-gnu ../../../../../y.sh cargo test +---- + +It will show the command it ran, something like this: + +---- + process didn't exit successfully: `sde -future -rtm_mode full -- /home/user/projects/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/stdarch/target/debug/deps/core_arch-fd2d75f89baae5c6` (signal: 11, SIGSEGV: invalid memory reference) +---- + +Then add the `-debug` flag to it: + +---- +sde -debug -future -rtm_mode full -- /home/user/projects/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/stdarch/target/debug/deps/core_arch-fd2d75f89baae5c6 +---- + +To see the symbols in `gdb`, specify the executable in your command: + +---- +gdb /home/user/projects/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/stdarch/target/debug/deps/core_arch-fd2d75f89baae5c6 +---- + +and then write the `gdb` command that `sde` tells you to use, something like: + +---- +target remote :51299 +---- diff --git a/compiler/rustc_codegen_gcc/doc/errors.md b/compiler/rustc_codegen_gcc/doc/errors.md new file mode 100644 index 00000000000..5727b0ff7c8 --- /dev/null +++ b/compiler/rustc_codegen_gcc/doc/errors.md @@ -0,0 +1,27 @@ +# Common errors + +This file lists errors that were encountered and how to fix them. + +### `failed to build archive` error + +When you get this error: + +``` +error: failed to build archive: failed to open object file: No such file or directory (os error 2) +``` + +That can be caused by the fact that you try to compile with `lto = "fat"`, but you didn't compile the sysroot with LTO. +(Not sure if that's the reason since I cannot reproduce anymore. Maybe it happened when forgetting setting `FAT_LTO`.) + +### ld: cannot find crtbegin.o + +When compiling an executable with libgccijt, if setting the `*LIBRARY_PATH` variables to the install directory, you will get the following errors: + +``` +ld: cannot find crtbegin.o: No such file or directory +ld: cannot find -lgcc: No such file or directory +ld: cannot find -lgcc: No such file or directory +libgccjit.so: error: error invoking gcc driver +``` + +To fix this, set the variables to `gcc-build/build/gcc`. diff --git a/compiler/rustc_codegen_gcc/doc/gimple.md b/compiler/rustc_codegen_gcc/doc/gimple.md new file mode 100644 index 00000000000..145c4eda3c1 --- /dev/null +++ b/compiler/rustc_codegen_gcc/doc/gimple.md @@ -0,0 +1,111 @@ +# GIMPLE + +You can see the full documentation about what GIMPLE is [here](https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html). In this document we will explain how to generate it. + +First, we'll copy the content from `gcc/gcc/testsuite/jit.dg/test-const-attribute.c` into a +file named `local.c` and remove the content we're not interested into: + +```diff +- /* { dg-do compile { target x86_64-*-* } } */ +... +- /* We don't want set_options() in harness.h to set -O3 to see that the const +- attribute affects the optimizations. */ +- #define TEST_ESCHEWS_SET_OPTIONS +- static void set_options (gcc_jit_context *ctxt, const char *argv0) +- { +- // Set "-O3". +- gcc_jit_context_set_int_option(ctxt, GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL, 3); +- } +- +- #define TEST_COMPILING_TO_FILE +- #define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_ASSEMBLER +- #define OUTPUT_FILENAME "output-of-test-const-attribute.c.s" +- #include "harness.h" +... +- /* { dg-final { jit-verify-output-file-was-created "" } } */ +- /* Check that the loop was optimized away */ +- /* { dg-final { jit-verify-assembler-output-not "jne" } } */ +``` + +Then we'll add a `main` function which will call the `create_code` function but +also add the calls we need to generate the GIMPLE: + +```C +int main() { + gcc_jit_context *ctxt = gcc_jit_context_acquire(); + // To set `-O3`, update it depending on your needs. + gcc_jit_context_set_int_option(ctxt, GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL, 3); + // Very important option to generate the gimple format. + gcc_jit_context_set_bool_option(ctxt, GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE, 1); + create_code(ctxt, NULL); + + gcc_jit_context_compile(ctxt); + // If you want to compile to assembly (or any other format) directly, you can + // use the following call instead: + // gcc_jit_context_compile_to_file(ctxt, GCC_JIT_OUTPUT_KIND_ASSEMBLER, "out.s"); + + return 0; +} +``` + +Then we can compile it by using: + +```console +gcc local.c -I `pwd`/gcc/gcc/jit/ -L `pwd`/gcc-build/gcc -lgccjit -o out +``` + +And finally when you run it: + +```console +LD_LIBRARY_PATH=`pwd`/gcc-build/gcc LIBRARY_PATH=`pwd`/gcc-build/gcc ./out +``` + +It should display: + +```c +__attribute__((const)) +int xxx () +{ + int D.3394; + int sum; + int x; + + <D.3377>: + x = 45; + sum = 0; + goto loop_cond; + loop_cond: + x = x >> 1; + if (x != 0) goto after_loop; else goto loop_body; + loop_body: + _1 = foo (x); + _2 = _1 * 2; + x = x + _2; + goto loop_cond; + after_loop: + D.3394 = sum; + return D.3394; +} +``` + +An alternative way to generate the GIMPLE is to replace: + +```c + gcc_jit_context_set_bool_option(ctxt, GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE, 1); +``` + +with: + +```c + gcc_jit_context_add_command_line_option(ctxt, "-fdump-tree-gimple"); +``` + +(although you can have both at the same time too). Then you can compile it like previously. Only one difference: before executing it, I recommend to run: + +```console +rm -rf /tmp/libgccjit-* +``` + +to make it easier for you to know which folder to look into. + +Once the execution is done, you should now have a file with path looking like `/tmp/libgccjit-9OFqkD/fake.c.006t.gimple` which contains the GIMPLE format. diff --git a/compiler/rustc_codegen_gcc/doc/sending-gcc-patch.md b/compiler/rustc_codegen_gcc/doc/sending-gcc-patch.md new file mode 100644 index 00000000000..7a47ef29f3c --- /dev/null +++ b/compiler/rustc_codegen_gcc/doc/sending-gcc-patch.md @@ -0,0 +1,44 @@ +This guide explains what to do to send a GCC patch for review. + +All the commands are supposed to be run in the folder where you cloned GCC. + +```bash +./contrib/gcc-changelog/git_check_commit.py +``` + +You can provide a specific commit hash: + +```bash +./contrib/gcc-changelog/git_check_commit.py abdef78989 +``` + +a range: + +```bash +./contrib/gcc-changelog/git_check_commit.py HEAD~2 +``` + +or even a comparison with a remote branch: + +```bash +./contrib/gcc-changelog/git_check_commit.py upstream/master..HEAD +``` + +When there is no more errors, generate the git patch: + +```bash +git format-patch -1 `git rev-parse --short HEAD` +``` + +Then you can run the remaining checks using: + +```bash +contrib/check_GNU_style.sh 0001-your-patch.patch +``` + +When you have no more errors, you can send the `.patch` file to GCC by sending an +email to `gcc-patches@gcc.gnu.org` and to the relevant GCC mailing lists +depending on what your patch changes. You can find the list of the mailing lists +[here](https://gcc.gnu.org/lists.html). + +You can find more information about "contributing to GCC" [here](https://gcc.gnu.org/contribute.html). diff --git a/compiler/rustc_codegen_gcc/doc/subtree.md b/compiler/rustc_codegen_gcc/doc/subtree.md new file mode 100644 index 00000000000..5d7af2a066b --- /dev/null +++ b/compiler/rustc_codegen_gcc/doc/subtree.md @@ -0,0 +1,52 @@ +# git subtree sync + +`rustc_codegen_gcc` is a subtree of the rust compiler. As such, it needs to be +sync from time to time to ensure changes that happened on their side are also +included on our side. + +### How to install a forked git-subtree + +Using git-subtree with `rustc` requires a patched git to make it work. +The PR that is needed is [here](https://github.com/gitgitgadget/git/pull/493). +Use the following instructions to install it: + +```bash +git clone git@github.com:tqc/git.git +cd git +git checkout tqc/subtree +make +make install +cd contrib/subtree +make +cp git-subtree ~/bin +``` + +### Syncing with rust compiler + +Do a sync with this command: + +```bash +PATH="$HOME/bin:$PATH" ~/bin/git-subtree push -P compiler/rustc_codegen_gcc/ ../rustc_codegen_gcc/ sync_branch_name +cd ../rustc_codegen_gcc +git checkout master +git pull +git checkout sync_branch_name +git merge master +``` + +To send the changes to the rust repo: + +```bash +cd ../rust +git pull origin master +git checkout -b subtree-update_cg_gcc_YYYY-MM-DD +PATH="$HOME/bin:$PATH" ~/bin/git-subtree pull --prefix=compiler/rustc_codegen_gcc/ https://github.com/rust-lang/rustc_codegen_gcc.git master +git push + +# Immediately merge the merge commit into cg_gcc to prevent merge conflicts when syncing from rust-lang/rust later. +PATH="$HOME/bin:$PATH" ~/bin/git-subtree push -P compiler/rustc_codegen_gcc/ ../rustc_codegen_gcc/ sync_branch_name +``` + +TODO: write a script that does the above. + +https://rust-lang.zulipchat.com/#narrow/stream/301329-t-devtools/topic/subtree.20madness/near/258877725 diff --git a/compiler/rustc_codegen_gcc/doc/tests.md b/compiler/rustc_codegen_gcc/doc/tests.md new file mode 100644 index 00000000000..3ac993bc2fd --- /dev/null +++ b/compiler/rustc_codegen_gcc/doc/tests.md @@ -0,0 +1,5 @@ +# Tests + +## Show the rustc command for UI tests + +Add ` --test-args "--verbose"` to `./x.py test`. diff --git a/compiler/rustc_codegen_gcc/doc/tips.md b/compiler/rustc_codegen_gcc/doc/tips.md new file mode 100644 index 00000000000..e62c3402a29 --- /dev/null +++ b/compiler/rustc_codegen_gcc/doc/tips.md @@ -0,0 +1,80 @@ +# Tips + +The following shows how to do different random small things we encountered and thought could +be useful. + +### How to send arguments to the GCC linker + +``` +CG_RUSTFLAGS="-Clink-args=-save-temps -v" ../y.sh cargo build +``` + +### How to see the personality functions in the asm dump + +``` +CG_RUSTFLAGS="-Clink-arg=-save-temps -v -Clink-arg=-dA" ../y.sh cargo build +``` + +### How to see the LLVM IR for a sysroot crate + +``` +cargo build -v --target x86_64-unknown-linux-gnu -Zbuild-std +# Take the command from the output and add --emit=llvm-ir +``` + +### To prevent the linker from unmangling symbols + +Run with: + +``` +COLLECT_NO_DEMANGLE=1 +``` + +### How to use a custom-build rustc + + * Build the stage2 compiler (`rustup toolchain link debug-current build/x86_64-unknown-linux-gnu/stage2`). + * Clean and rebuild the codegen with `debug-current` in the file `rust-toolchain`. + +### How to use a custom sysroot source path + +If you wish to build a custom sysroot, pass the path of your sysroot source to `--sysroot-source` during the `prepare` step, like so: + +``` +./y.sh prepare --sysroot-source /path/to/custom/source +``` + +### How to use [mem-trace](https://github.com/antoyo/mem-trace) + +`rustc` needs to be built without `jemalloc` so that `mem-trace` can overload `malloc` since `jemalloc` is linked statically, so a `LD_PRELOAD`-ed library won't a chance to intercept the calls to `malloc`. + +### How to generate GIMPLE + +If you need to check what gccjit is generating (GIMPLE), then take a look at how to +generate it in [gimple.md](./doc/gimple.md). + +### How to build a cross-compiling libgccjit + +#### Building libgccjit + + * Follow the instructions on [this repo](https://github.com/cross-cg-gcc-tools/cross-gcc). + +#### Configuring rustc_codegen_gcc + + * Run `./y.sh prepare --cross` so that the sysroot is patched for the cross-compiling case. + * Set the path to the cross-compiling libgccjit in `gcc-path` (in `config.toml`). + * Make sure you have the linker for your target (for instance `m68k-unknown-linux-gnu-gcc`) in your `$PATH`. You can specify which linker to use via `CG_RUSTFLAGS="-Clinker=<linker>"`, for instance: `CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc"`. Specify the target when building the sysroot: `./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu`. + * Build your project by specifying the target and the linker to use: `CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../y.sh cargo build --target m68k-unknown-linux-gnu`. + +If the target is not yet supported by the Rust compiler, create a [target specification file](https://docs.rust-embedded.org/embedonomicon/custom-target.html) (note that the `arch` specified in this file must be supported by the rust compiler). +Then, you can use it the following way: + + * Add the target specification file using `--target` as an **absolute** path to build the sysroot: `./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu --target $(pwd)/m68k-unknown-linux-gnu.json` + * Build your project by specifying the target specification file: `../y.sh cargo build --target path/to/m68k-unknown-linux-gnu.json`. + +If you get the following error: + +``` +/usr/bin/ld: unrecognised emulation mode: m68kelf +``` + +Make sure you set `gcc-path` (in `config.toml`) to the install directory. diff --git a/compiler/rustc_codegen_gcc/example/alloc_example.rs b/compiler/rustc_codegen_gcc/example/alloc_example.rs new file mode 100644 index 00000000000..9a0b46d5b22 --- /dev/null +++ b/compiler/rustc_codegen_gcc/example/alloc_example.rs @@ -0,0 +1,49 @@ +#![feature(core_intrinsics, alloc_error_handler, lang_items)] +#![no_std] +#![no_main] +#![allow(internal_features)] + +extern crate alloc; +extern crate alloc_system; + +use alloc::boxed::Box; + +use alloc_system::System; + +#[global_allocator] +static ALLOC: System = System; + +#[link(name = "c")] +extern "C" { + fn puts(s: *const u8) -> i32; +} + +#[panic_handler] +fn panic_handler(_: &core::panic::PanicInfo<'_>) -> ! { + core::intrinsics::abort(); +} + +#[alloc_error_handler] +fn alloc_error_handler(_: alloc::alloc::Layout) -> ! { + core::intrinsics::abort(); +} + +#[lang = "eh_personality"] +fn eh_personality() -> ! { + loop {} +} + +#[no_mangle] +unsafe extern "C" fn _Unwind_Resume() { + core::intrinsics::unreachable(); +} + +#[no_mangle] +extern "C" fn main(_argc: core::ffi::c_int, _argv: *const *const u8) -> core::ffi::c_int { + let world: Box<&str> = Box::new("Hello World!\0"); + unsafe { + puts(*world as *const str as *const u8); + } + + 0 +} diff --git a/compiler/rustc_codegen_gcc/example/alloc_system.rs b/compiler/rustc_codegen_gcc/example/alloc_system.rs new file mode 100644 index 00000000000..4d70122496b --- /dev/null +++ b/compiler/rustc_codegen_gcc/example/alloc_system.rs @@ -0,0 +1,222 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// SPDX-FileCopyrightText: The Rust Project Developers (see https://thanks.rust-lang.org) + +#![no_std] +#![feature(allocator_api, rustc_private)] + +// The minimum alignment guaranteed by the architecture. This value is used to +// add fast paths for low alignment values. +#[cfg(any(target_arch = "x86", + target_arch = "arm", + target_arch = "loongarch32", + target_arch = "m68k", + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "powerpc", + target_arch = "csky", + target_arch = "powerpc64"))] +const MIN_ALIGN: usize = 8; +#[cfg(any(target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "loongarch64", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "s390x", + target_arch = "sparc64"))] +const MIN_ALIGN: usize = 16; + +pub struct System; +#[cfg(any(windows, unix, target_os = "redox"))] +mod realloc_fallback { + use core::alloc::{GlobalAlloc, Layout}; + use core::cmp; + use core::ptr; + impl super::System { + pub(crate) unsafe fn realloc_fallback(&self, ptr: *mut u8, old_layout: Layout, + new_size: usize) -> *mut u8 { + // Docs for GlobalAlloc::realloc require this to be valid: + let new_layout = Layout::from_size_align_unchecked(new_size, old_layout.align()); + let new_ptr = GlobalAlloc::alloc(self, new_layout); + if !new_ptr.is_null() { + let size = cmp::min(old_layout.size(), new_size); + ptr::copy_nonoverlapping(ptr, new_ptr, size); + GlobalAlloc::dealloc(self, ptr, old_layout); + } + new_ptr + } + } +} +#[cfg(any(unix, target_os = "redox"))] +mod platform { + mod libc { + use core::ffi::{c_void, c_int}; + + #[link(name = "c")] + extern "C" { + pub fn malloc(size: usize) -> *mut c_void; + pub fn realloc(ptr: *mut c_void, size: usize) -> *mut c_void; + pub fn calloc(nmemb: usize, size: usize) -> *mut c_void; + pub fn free(ptr: *mut u8); + pub fn posix_memalign(memptr: *mut *mut c_void, alignment: usize, size: usize) -> c_int; + } + } + use core::ptr; + use MIN_ALIGN; + use System; + use core::alloc::{GlobalAlloc, Layout}; + unsafe impl GlobalAlloc for System { + #[inline] + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() { + libc::malloc(layout.size()) as *mut u8 + } else { + #[cfg(target_os = "macos")] + { + if layout.align() > (1 << 31) { + return ptr::null_mut() + } + } + aligned_malloc(&layout) + } + } + #[inline] + unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { + if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() { + libc::calloc(layout.size(), 1) as *mut u8 + } else { + let ptr = self.alloc(layout.clone()); + if !ptr.is_null() { + ptr::write_bytes(ptr, 0, layout.size()); + } + ptr + } + } + #[inline] + unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) { + libc::free(ptr as *mut _) + } + #[inline] + unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { + if layout.align() <= MIN_ALIGN && layout.align() <= new_size { + libc::realloc(ptr as *mut _, new_size) as *mut u8 + } else { + self.realloc_fallback(ptr, layout, new_size) + } + } + } + #[cfg(any(target_os = "android", + target_os = "hermit", + target_os = "redox", + target_os = "solaris"))] + #[inline] + unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 { + // On android we currently target API level 9 which unfortunately + // doesn't have the `posix_memalign` API used below. Instead we use + // `memalign`, but this unfortunately has the property on some systems + // where the memory returned cannot be deallocated by `free`! + // + // Upon closer inspection, however, this appears to work just fine with + // Android, so for this platform we should be fine to call `memalign` + // (which is present in API level 9). Some helpful references could + // possibly be chromium using memalign [1], attempts at documenting that + // memalign + free is ok [2] [3], or the current source of chromium + // which still uses memalign on android [4]. + // + // [1]: https://codereview.chromium.org/10796020/ + // [2]: https://code.google.com/p/android/issues/detail?id=35391 + // [3]: https://bugs.chromium.org/p/chromium/issues/detail?id=138579 + // [4]: https://chromium.googlesource.com/chromium/src/base/+/master/ + // /memory/aligned_memory.cc + libc::memalign(layout.align(), layout.size()) as *mut u8 + } + #[cfg(not(any(target_os = "android", + target_os = "hermit", + target_os = "redox", + target_os = "solaris")))] + #[inline] + unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 { + let mut out = ptr::null_mut(); + let ret = libc::posix_memalign(&mut out, layout.align(), layout.size()); + if ret != 0 { + ptr::null_mut() + } else { + out as *mut u8 + } + } +} +#[cfg(windows)] +#[allow(nonstandard_style)] +mod platform { + use MIN_ALIGN; + use System; + use core::alloc::{GlobalAlloc, Layout}; + type LPVOID = *mut u8; + type HANDLE = LPVOID; + type SIZE_T = usize; + type DWORD = u32; + type BOOL = i32; + extern "system" { + fn GetProcessHeap() -> HANDLE; + fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID; + fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID; + fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL; + fn GetLastError() -> DWORD; + } + #[repr(C)] + struct Header(*mut u8); + const HEAP_ZERO_MEMORY: DWORD = 0x00000008; + unsafe fn get_header<'a>(ptr: *mut u8) -> &'a mut Header { + &mut *(ptr as *mut Header).sub(1) + } + unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 { + let aligned = ptr.add(align - (ptr as usize & (align - 1))); + *get_header(aligned) = Header(ptr); + aligned + } + #[inline] + unsafe fn allocate_with_flags(layout: Layout, flags: DWORD) -> *mut u8 { + let ptr = if layout.align() <= MIN_ALIGN { + HeapAlloc(GetProcessHeap(), flags, layout.size()) + } else { + let size = layout.size() + layout.align(); + let ptr = HeapAlloc(GetProcessHeap(), flags, size); + if ptr.is_null() { + ptr + } else { + align_ptr(ptr, layout.align()) + } + }; + ptr as *mut u8 + } + unsafe impl GlobalAlloc for System { + #[inline] + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + allocate_with_flags(layout, 0) + } + #[inline] + unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { + allocate_with_flags(layout, HEAP_ZERO_MEMORY) + } + #[inline] + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + if layout.align() <= MIN_ALIGN { + let err = HeapFree(GetProcessHeap(), 0, ptr as LPVOID); + debug_assert!(err != 0, "Failed to free heap memory: {}", + GetLastError()); + } else { + let header = get_header(ptr); + let err = HeapFree(GetProcessHeap(), 0, header.0 as LPVOID); + debug_assert!(err != 0, "Failed to free heap memory: {}", + GetLastError()); + } + } + #[inline] + unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { + if layout.align() <= MIN_ALIGN { + HeapReAlloc(GetProcessHeap(), 0, ptr as LPVOID, new_size) as *mut u8 + } else { + self.realloc_fallback(ptr, layout, new_size) + } + } + } +} diff --git a/compiler/rustc_codegen_gcc/example/arbitrary_self_types_pointers_and_wrappers.rs b/compiler/rustc_codegen_gcc/example/arbitrary_self_types_pointers_and_wrappers.rs new file mode 100644 index 00000000000..c26606f0bdd --- /dev/null +++ b/compiler/rustc_codegen_gcc/example/arbitrary_self_types_pointers_and_wrappers.rs @@ -0,0 +1,66 @@ +// Adapted from rustc run-pass test suite + +#![feature(arbitrary_self_types, unsize, coerce_unsized, dispatch_from_dyn)] +#![feature(rustc_attrs)] +#![allow(internal_features)] + +use std::{ + ops::{Deref, CoerceUnsized, DispatchFromDyn}, + marker::Unsize, +}; + +struct Ptr<T: ?Sized>(Box<T>); + +impl<T: ?Sized> Deref for Ptr<T> { + type Target = T; + + fn deref(&self) -> &T { + &*self.0 + } +} + +impl<T: Unsize<U> + ?Sized, U: ?Sized> CoerceUnsized<Ptr<U>> for Ptr<T> {} +impl<T: Unsize<U> + ?Sized, U: ?Sized> DispatchFromDyn<Ptr<U>> for Ptr<T> {} + +struct Wrapper<T: ?Sized>(T); + +impl<T: ?Sized> Deref for Wrapper<T> { + type Target = T; + + fn deref(&self) -> &T { + &self.0 + } +} + +impl<T: CoerceUnsized<U>, U> CoerceUnsized<Wrapper<U>> for Wrapper<T> {} +impl<T: DispatchFromDyn<U>, U> DispatchFromDyn<Wrapper<U>> for Wrapper<T> {} + + +trait Trait { + fn ptr_wrapper(self: Ptr<Wrapper<Self>>) -> i32; + fn wrapper_ptr(self: Wrapper<Ptr<Self>>) -> i32; + fn wrapper_ptr_wrapper(self: Wrapper<Ptr<Wrapper<Self>>>) -> i32; +} + +impl Trait for i32 { + fn ptr_wrapper(self: Ptr<Wrapper<Self>>) -> i32 { + **self + } + fn wrapper_ptr(self: Wrapper<Ptr<Self>>) -> i32 { + **self + } + fn wrapper_ptr_wrapper(self: Wrapper<Ptr<Wrapper<Self>>>) -> i32 { + ***self + } +} + +fn main() { + let pw = Ptr(Box::new(Wrapper(5))) as Ptr<Wrapper<dyn Trait>>; + assert_eq!(pw.ptr_wrapper(), 5); + + let wp = Wrapper(Ptr(Box::new(6))) as Wrapper<Ptr<dyn Trait>>; + assert_eq!(wp.wrapper_ptr(), 6); + + let wpw = Wrapper(Ptr(Box::new(Wrapper(7)))) as Wrapper<Ptr<Wrapper<dyn Trait>>>; + assert_eq!(wpw.wrapper_ptr_wrapper(), 7); +} diff --git a/compiler/rustc_codegen_gcc/example/dst-field-align.rs b/compiler/rustc_codegen_gcc/example/dst-field-align.rs new file mode 100644 index 00000000000..6c338e99912 --- /dev/null +++ b/compiler/rustc_codegen_gcc/example/dst-field-align.rs @@ -0,0 +1,67 @@ +// run-pass +#![allow(dead_code)] +struct Foo<T: ?Sized> { + a: u16, + b: T +} + +trait Bar { + fn get(&self) -> usize; +} + +impl Bar for usize { + fn get(&self) -> usize { *self } +} + +struct Baz<T: ?Sized> { + a: T +} + +struct HasDrop<T: ?Sized> { + ptr: Box<usize>, + data: T +} + +fn main() { + // Test that zero-offset works properly + let b : Baz<usize> = Baz { a: 7 }; + assert_eq!(b.a.get(), 7); + let b : &Baz<dyn Bar> = &b; + assert_eq!(b.a.get(), 7); + + // Test that the field is aligned properly + let f : Foo<usize> = Foo { a: 0, b: 11 }; + assert_eq!(f.b.get(), 11); + let ptr1 : *const u8 = &f.b as *const _ as *const u8; + + let f : &Foo<dyn Bar> = &f; + let ptr2 : *const u8 = &f.b as *const _ as *const u8; + assert_eq!(f.b.get(), 11); + + // The pointers should be the same + assert_eq!(ptr1, ptr2); + + // Test that nested DSTs work properly + let f : Foo<Foo<usize>> = Foo { a: 0, b: Foo { a: 1, b: 17 }}; + assert_eq!(f.b.b.get(), 17); + let f : &Foo<Foo<dyn Bar>> = &f; + assert_eq!(f.b.b.get(), 17); + + // Test that get the pointer via destructuring works + + let f : Foo<usize> = Foo { a: 0, b: 11 }; + let f : &Foo<dyn Bar> = &f; + let &Foo { a: _, b: ref bar } = f; + assert_eq!(bar.get(), 11); + + // Make sure that drop flags don't screw things up + + let d : HasDrop<Baz<[i32; 4]>> = HasDrop { + ptr: Box::new(0), + data: Baz { a: [1,2,3,4] } + }; + assert_eq!([1,2,3,4], d.data.a); + + let d : &HasDrop<Baz<[i32]>> = &d; + assert_eq!(&[1,2,3,4], &d.data.a); +} diff --git a/compiler/rustc_codegen_gcc/example/example.rs b/compiler/rustc_codegen_gcc/example/example.rs new file mode 100644 index 00000000000..888fa89201e --- /dev/null +++ b/compiler/rustc_codegen_gcc/example/example.rs @@ -0,0 +1,204 @@ +#![feature(no_core, unboxed_closures)] +#![no_core] +#![allow(dead_code, unnecessary_transmutes)] + +extern crate mini_core; + +use mini_core::*; + +fn abc(a: u8) -> u8 { + a * 2 +} + +fn bcd(b: bool, a: u8) -> u8 { + if b { a * 2 } else { a * 3 } +} + +fn call() { + abc(42); +} + +fn indirect_call() { + let f: fn() = call; + f(); +} + +enum BoolOption { + Some(bool), + None, +} + +fn option_unwrap_or(o: BoolOption, d: bool) -> bool { + match o { + BoolOption::Some(b) => b, + BoolOption::None => d, + } +} + +fn ret_42() -> u8 { + 42 +} + +fn return_str() -> &'static str { + "hello world" +} + +fn promoted_val() -> &'static u8 { + &(1 * 2) +} + +fn cast_ref_to_raw_ptr(abc: &u8) -> *const u8 { + abc as *const u8 +} + +fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool { + a == b +} + +fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { + ( + a as u8, a as u16, a as u32, a as usize, a as i8, a as i16, a as i32, a as isize, b as u8, + b as u32, + ) +} + +fn char_cast(c: char) -> u8 { + c as u8 +} + +pub struct DebugTuple(()); + +fn debug_tuple() -> DebugTuple { + DebugTuple(()) +} + +fn size_of<T>() -> usize { + intrinsics::size_of::<T>() +} + +fn use_size_of() -> usize { + size_of::<u64>() +} + +unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) { + intrinsics::copy::<u8>(src, dst, 1); +} + +unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) { + let copy2 = &intrinsics::copy::<u8>; + copy2(src, dst, 1); +} + +const ABC: u8 = 6 * 7; + +fn use_const() -> u8 { + ABC +} + +pub fn call_closure_3arg() { + (|_, _, _| {})(0u8, 42u16, 0u8) +} + +pub fn call_closure_2arg() { + (|_, _| {})(0u8, 42u16) +} + +struct IsNotEmpty; + +impl<'a, 'b> FnOnce<(&'a &'b [u16],)> for IsNotEmpty { + type Output = (u8, u8); + + #[inline] + extern "rust-call" fn call_once(mut self, arg: (&'a &'b [u16],)) -> (u8, u8) { + self.call_mut(arg) + } +} + +impl<'a, 'b> FnMut<(&'a &'b [u16],)> for IsNotEmpty { + #[inline] + extern "rust-call" fn call_mut(&mut self, _arg: (&'a &'b [u16],)) -> (u8, u8) { + (0, 42) + } +} + +pub fn call_is_not_empty() { + IsNotEmpty.call_once((&(&[0u16] as &[_]),)); +} + +fn eq_char(a: char, b: char) -> bool { + a == b +} + +unsafe fn transmute(c: char) -> u32 { + intrinsics::transmute(c) +} + +unsafe fn deref_str_ptr(s: *const str) -> &'static str { + &*s +} + +fn use_array(arr: [u8; 3]) -> u8 { + arr[1] +} + +fn repeat_array() -> [u8; 3] { + [0; 3] +} + +fn array_as_slice(arr: &[u8; 3]) -> &[u8] { + arr +} + +unsafe fn use_ctlz_nonzero(a: u16) -> u32 { + intrinsics::ctlz_nonzero(a) +} + +fn ptr_as_usize(ptr: *const u8) -> usize { + ptr as usize +} + +fn float_cast(a: f32, b: f64) -> (f64, f32) { + (a as f64, b as f32) +} + +fn int_to_float(a: u8, b: i32) -> (f64, f32) { + (a as f64, b as f32) +} + +fn make_array() -> [u8; 3] { + [42, 0, 5] +} + +fn some_promoted_tuple() -> &'static (&'static str, &'static str) { + &("abc", "some") +} + +fn index_slice(s: &[u8]) -> u8 { + s[2] +} + +pub struct StrWrapper { + s: str, +} + +fn str_wrapper_get(w: &StrWrapper) -> &str { + &w.s +} + +fn i16_as_i8(a: i16) -> i8 { + a as i8 +} + +struct Unsized(u8, str); + +fn get_sized_field_ref_from_unsized_type(u: &Unsized) -> &u8 { + &u.0 +} + +fn get_unsized_field_ref_from_unsized_type(u: &Unsized) -> &str { + &u.1 +} + +pub fn reuse_byref_argument_storage(a: (u8, u16, u32)) -> u8 { + a.0 +} diff --git a/compiler/rustc_codegen_gcc/example/mini_core.rs b/compiler/rustc_codegen_gcc/example/mini_core.rs new file mode 100644 index 00000000000..9dfb12be243 --- /dev/null +++ b/compiler/rustc_codegen_gcc/example/mini_core.rs @@ -0,0 +1,771 @@ +#![feature( + no_core, + lang_items, + intrinsics, + unboxed_closures, + extern_types, + decl_macro, + rustc_attrs, + transparent_unions, + auto_traits, + freeze_impls, + thread_local +)] +#![no_core] +#![allow(dead_code, internal_features, ambiguous_wide_pointer_comparisons)] + +#[no_mangle] +unsafe extern "C" fn _Unwind_Resume() { + intrinsics::unreachable(); +} + +#[lang = "pointee_sized"] +pub trait PointeeSized {} + +#[lang = "meta_sized"] +pub trait MetaSized: PointeeSized {} + +#[lang = "sized"] +pub trait Sized: MetaSized {} + +#[lang = "destruct"] +pub trait Destruct {} + +#[lang = "tuple_trait"] +pub trait Tuple {} + +#[lang = "unsize"] +pub trait Unsize<T: PointeeSized>: PointeeSized {} + +#[lang = "coerce_unsized"] +pub trait CoerceUnsized<T> {} + +impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {} +impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a mut U> for &'a mut T {} +impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *const T {} +impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*mut U> for *mut T {} + +#[lang = "dispatch_from_dyn"] +pub trait DispatchFromDyn<T> {} + +// &T -> &U +impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a U> for &'a T {} +// &mut T -> &mut U +impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a mut U> for &'a mut T {} +// *const T -> *const U +impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*const U> for *const T {} +// *mut T -> *mut U +impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*mut U> for *mut T {} +impl<T: MetaSized + Unsize<U>, U: MetaSized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {} + +#[lang = "legacy_receiver"] +pub trait LegacyReceiver {} + +impl<T: PointeeSized> LegacyReceiver for &T {} +impl<T: PointeeSized> LegacyReceiver for &mut T {} +impl<T: MetaSized> LegacyReceiver for Box<T> {} + +#[lang = "receiver"] +trait Receiver {} + +#[lang = "copy"] +pub trait Copy {} + +#[lang = "bikeshed_guaranteed_no_drop"] +pub trait BikeshedGuaranteedNoDrop {} + +impl Copy for bool {} +impl Copy for u8 {} +impl Copy for u16 {} +impl Copy for u32 {} +impl Copy for u64 {} +impl Copy for usize {} +impl Copy for u128 {} +impl Copy for i8 {} +impl Copy for i16 {} +impl Copy for i32 {} +impl Copy for i64 {} +impl Copy for isize {} +impl Copy for i128 {} +impl Copy for f32 {} +impl Copy for f64 {} +impl Copy for char {} +impl<'a, T: PointeeSized> Copy for &'a T {} +impl<T: PointeeSized> Copy for *const T {} +impl<T: PointeeSized> Copy for *mut T {} + +#[lang = "sync"] +pub unsafe trait Sync {} + +unsafe impl Sync for bool {} +unsafe impl Sync for u8 {} +unsafe impl Sync for u16 {} +unsafe impl Sync for u32 {} +unsafe impl Sync for u64 {} +unsafe impl Sync for usize {} +unsafe impl Sync for i8 {} +unsafe impl Sync for i16 {} +unsafe impl Sync for i32 {} +unsafe impl Sync for isize {} +unsafe impl Sync for char {} +unsafe impl<'a, T: PointeeSized> Sync for &'a T {} +unsafe impl Sync for [u8; 16] {} + +#[lang = "freeze"] +unsafe auto trait Freeze {} + +unsafe impl<T: PointeeSized> Freeze for PhantomData<T> {} +unsafe impl<T: PointeeSized> Freeze for *const T {} +unsafe impl<T: PointeeSized> Freeze for *mut T {} +unsafe impl<T: PointeeSized> Freeze for &T {} +unsafe impl<T: PointeeSized> Freeze for &mut T {} + +#[lang = "structural_peq"] +pub trait StructuralPartialEq {} + +#[lang = "not"] +pub trait Not { + type Output; + + fn not(self) -> Self::Output; +} + +impl Not for bool { + type Output = bool; + + fn not(self) -> bool { + !self + } +} + +#[lang = "mul"] +pub trait Mul<RHS = Self> { + type Output; + + #[must_use] + fn mul(self, rhs: RHS) -> Self::Output; +} + +impl Mul for u8 { + type Output = Self; + + fn mul(self, rhs: Self) -> Self::Output { + self * rhs + } +} + +impl Mul for i32 { + type Output = Self; + + fn mul(self, rhs: Self) -> Self::Output { + self * rhs + } +} + +impl Mul for usize { + type Output = Self; + + fn mul(self, rhs: Self) -> Self::Output { + self * rhs + } +} + +impl Mul for isize { + type Output = Self; + + fn mul(self, rhs: Self) -> Self::Output { + self * rhs + } +} + +#[lang = "add"] +pub trait Add<RHS = Self> { + type Output; + + fn add(self, rhs: RHS) -> Self::Output; +} + +impl Add for u8 { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + +impl Add for i8 { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + +impl Add for i32 { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + +impl Add for usize { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + +impl Add for isize { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + +#[lang = "sub"] +pub trait Sub<RHS = Self> { + type Output; + + fn sub(self, rhs: RHS) -> Self::Output; +} + +impl Sub for usize { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + +impl Sub for isize { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + +impl Sub for u8 { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + +impl Sub for i8 { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + +impl Sub for i16 { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + +impl Sub for i32 { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + +#[lang = "rem"] +pub trait Rem<RHS = Self> { + type Output; + + fn rem(self, rhs: RHS) -> Self::Output; +} + +impl Rem for usize { + type Output = Self; + + fn rem(self, rhs: Self) -> Self { + self % rhs + } +} + +#[lang = "bitor"] +pub trait BitOr<RHS = Self> { + type Output; + + #[must_use] + fn bitor(self, rhs: RHS) -> Self::Output; +} + +impl BitOr for bool { + type Output = bool; + + fn bitor(self, rhs: bool) -> bool { + self | rhs + } +} + +impl<'a> BitOr<bool> for &'a bool { + type Output = bool; + + fn bitor(self, rhs: bool) -> bool { + *self | rhs + } +} + +#[lang = "eq"] +pub trait PartialEq<Rhs: ?Sized = Self> { + fn eq(&self, other: &Rhs) -> bool; + fn ne(&self, other: &Rhs) -> bool; +} + +impl PartialEq for u8 { + fn eq(&self, other: &u8) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &u8) -> bool { + (*self) != (*other) + } +} + +impl PartialEq for u16 { + fn eq(&self, other: &u16) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &u16) -> bool { + (*self) != (*other) + } +} + +impl PartialEq for u32 { + fn eq(&self, other: &u32) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &u32) -> bool { + (*self) != (*other) + } +} + +impl PartialEq for u64 { + fn eq(&self, other: &u64) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &u64) -> bool { + (*self) != (*other) + } +} + +impl PartialEq for usize { + fn eq(&self, other: &usize) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &usize) -> bool { + (*self) != (*other) + } +} + +impl PartialEq for i8 { + fn eq(&self, other: &i8) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &i8) -> bool { + (*self) != (*other) + } +} + +impl PartialEq for i32 { + fn eq(&self, other: &i32) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &i32) -> bool { + (*self) != (*other) + } +} + +impl PartialEq for isize { + fn eq(&self, other: &isize) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &isize) -> bool { + (*self) != (*other) + } +} + +impl PartialEq for char { + fn eq(&self, other: &char) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &char) -> bool { + (*self) != (*other) + } +} + +impl<T: ?Sized> PartialEq for *const T { + fn eq(&self, other: &*const T) -> bool { + *self == *other + } + fn ne(&self, other: &*const T) -> bool { + *self != *other + } +} + +#[lang = "neg"] +pub trait Neg { + type Output; + + fn neg(self) -> Self::Output; +} + +impl Neg for i8 { + type Output = i8; + + fn neg(self) -> i8 { + -self + } +} + +impl Neg for i16 { + type Output = i16; + + fn neg(self) -> i16 { + self + } +} + +impl Neg for isize { + type Output = isize; + + fn neg(self) -> isize { + -self + } +} + +impl Neg for f32 { + type Output = f32; + + fn neg(self) -> f32 { + -self + } +} + +pub enum Option<T> { + Some(T), + None, +} + +pub use Option::*; + +#[lang = "phantom_data"] +pub struct PhantomData<T: PointeeSized>; + +#[lang = "fn_once"] +#[rustc_paren_sugar] +pub trait FnOnce<Args: Tuple> { + #[lang = "fn_once_output"] + type Output; + + extern "rust-call" fn call_once(self, args: Args) -> Self::Output; +} + +#[lang = "fn_mut"] +#[rustc_paren_sugar] +pub trait FnMut<Args: Tuple>: FnOnce<Args> { + extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; +} + +#[lang = "panic"] +#[track_caller] +pub fn panic(_msg: &'static str) -> ! { + unsafe { + libc::puts("Panicking\n\0" as *const str as *const u8); + intrinsics::abort(); + } +} + +macro_rules! panic_const { + ($($lang:ident = $message:expr,)+) => { + pub mod panic_const { + use super::*; + + $( + #[track_caller] + #[lang = stringify!($lang)] + pub fn $lang() -> ! { + panic($message); + } + )+ + } + } +} + +panic_const! { + panic_const_add_overflow = "attempt to add with overflow", + panic_const_sub_overflow = "attempt to subtract with overflow", + panic_const_mul_overflow = "attempt to multiply with overflow", + panic_const_div_overflow = "attempt to divide with overflow", + panic_const_rem_overflow = "attempt to calculate the remainder with overflow", + panic_const_neg_overflow = "attempt to negate with overflow", + panic_const_shr_overflow = "attempt to shift right with overflow", + panic_const_shl_overflow = "attempt to shift left with overflow", + panic_const_div_by_zero = "attempt to divide by zero", + panic_const_rem_by_zero = "attempt to calculate the remainder with a divisor of zero", +} + +#[lang = "panic_cannot_unwind"] +fn panic_cannot_unwind() -> ! { + unsafe { + libc::puts("Panicking\n\0" as *const str as *const u8); + intrinsics::abort(); + } +} + +#[lang = "panic_in_cleanup"] +#[rustc_nounwind] +fn panic_in_cleanup() -> ! { + unsafe { + libc::printf("panic in a destructor during cleanup\n\0" as *const str as *const i8); + intrinsics::abort(); + } +} + +#[lang = "panic_bounds_check"] +#[track_caller] +fn panic_bounds_check(index: usize, len: usize) -> ! { + unsafe { + libc::printf( + "index out of bounds: the len is %d but the index is %d\n\0" as *const str as *const i8, + len, + index, + ); + intrinsics::abort(); + } +} + +#[lang = "eh_personality"] +fn eh_personality() -> ! { + loop {} +} + +#[lang = "drop_in_place"] +#[allow(unconditional_recursion)] +pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { + // Code here does not matter - this is replaced by the + // real drop glue by the compiler. + drop_in_place(to_drop); +} + +#[lang = "unpin"] +pub auto trait Unpin {} + +#[lang = "deref"] +pub trait Deref { + type Target: ?Sized; + + fn deref(&self) -> &Self::Target; +} + +pub trait Allocator {} + +impl Allocator for () {} + +#[lang = "global_alloc_ty"] +pub struct Global; + +impl Allocator for Global {} + +#[repr(transparent)] +#[rustc_layout_scalar_valid_range_start(1)] +#[rustc_nonnull_optimization_guaranteed] +pub struct NonNull<T: PointeeSized>(pub *const T); + +impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {} +impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {} + +pub struct Unique<T: PointeeSized> { + pub pointer: NonNull<T>, + pub _marker: PhantomData<T>, +} + +impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {} +impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {} + +#[lang = "owned_box"] +pub struct Box<T: ?Sized, A: Allocator = Global>(Unique<T>, A); + +impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> for Box<T, A> {} + +impl<T> Box<T> { + pub fn new(val: T) -> Box<T> { + unsafe { + let size = intrinsics::size_of::<T>(); + let ptr = libc::malloc(size); + intrinsics::copy(&val as *const T as *const u8, ptr, size); + Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, Global) + } + } +} + +impl<T: ?Sized, A: Allocator> Drop for Box<T, A> { + fn drop(&mut self) { + // inner value is dropped by compiler. + unsafe { + libc::free(self.0.pointer.0 as *mut u8); + } + } +} + +impl<T: ?Sized, A: Allocator> Deref for Box<T, A> { + type Target = T; + + fn deref(&self) -> &Self::Target { + &**self + } +} + +#[lang = "exchange_malloc"] +unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { + libc::malloc(size) +} + +#[lang = "drop"] +pub trait Drop { + fn drop(&mut self); +} + +#[lang = "manually_drop"] +#[repr(transparent)] +pub struct ManuallyDrop<T: ?Sized> { + pub value: T, +} + +#[lang = "maybe_uninit"] +#[repr(transparent)] +pub union MaybeUninit<T> { + pub uninit: (), + pub value: ManuallyDrop<T>, +} + +pub mod intrinsics { + #[rustc_intrinsic] + pub const fn black_box<T>(_dummy: T) -> T; + #[rustc_intrinsic] + pub fn abort() -> !; + #[rustc_intrinsic] + pub fn size_of<T>() -> usize; + #[rustc_intrinsic] + pub unsafe fn size_of_val<T: ?::Sized>(val: *const T) -> usize; + #[rustc_intrinsic] + pub fn align_of<T>() -> usize; + #[rustc_intrinsic] + pub unsafe fn align_of_val<T: ?::Sized>(val: *const T) -> usize; + #[rustc_intrinsic] + pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize); + #[rustc_intrinsic] + pub unsafe fn transmute<T, U>(e: T) -> U; + #[rustc_intrinsic] + pub unsafe fn ctlz_nonzero<T>(x: T) -> u32; + #[rustc_intrinsic] + pub fn needs_drop<T: ?::Sized>() -> bool; + #[rustc_intrinsic] + pub fn bitreverse<T>(x: T) -> T; + #[rustc_intrinsic] + pub fn bswap<T>(x: T) -> T; + #[rustc_intrinsic] + pub unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize); + #[rustc_intrinsic] + pub unsafe fn unreachable() -> !; +} + +pub mod libc { + #[link(name = "c")] + extern "C" { + pub fn puts(s: *const u8) -> i32; + pub fn printf(format: *const i8, ...) -> i32; + pub fn malloc(size: usize) -> *mut u8; + pub fn free(ptr: *mut u8); + pub fn memcpy(dst: *mut u8, src: *const u8, size: usize); + pub fn memmove(dst: *mut u8, src: *const u8, size: usize); + pub fn strncpy(dst: *mut u8, src: *const u8, size: usize); + pub fn fflush(stream: *mut i32) -> i32; + pub fn exit(status: i32); + + pub static stdout: *mut i32; + } +} + +#[lang = "index"] +pub trait Index<Idx: ?Sized> { + type Output: ?Sized; + fn index(&self, index: Idx) -> &Self::Output; +} + +impl<T> Index<usize> for [T; 3] { + type Output = T; + + fn index(&self, index: usize) -> &Self::Output { + &self[index] + } +} + +impl<T> Index<usize> for [T] { + type Output = T; + + fn index(&self, index: usize) -> &Self::Output { + &self[index] + } +} + +extern "C" { + type VaListImpl; +} + +#[lang = "va_list"] +#[repr(transparent)] +pub struct VaList<'a>(&'a mut VaListImpl); + +#[rustc_builtin_macro] +#[rustc_macro_transparency = "semitransparent"] +pub macro stringify($($t:tt)*) { + /* compiler built-in */ +} + +#[rustc_builtin_macro] +#[rustc_macro_transparency = "semitransparent"] +pub macro file() { + /* compiler built-in */ +} + +#[rustc_builtin_macro] +#[rustc_macro_transparency = "semitransparent"] +pub macro line() { + /* compiler built-in */ +} + +#[rustc_builtin_macro] +#[rustc_macro_transparency = "semitransparent"] +pub macro cfg() { + /* compiler built-in */ +} + +pub static A_STATIC: u8 = 42; + +#[lang = "panic_location"] +struct PanicLocation { + file: &'static str, + line: u32, + column: u32, +} + +#[no_mangle] +pub fn get_tls() -> u8 { + #[thread_local] + static A: u8 = 42; + + A +} diff --git a/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs b/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs new file mode 100644 index 00000000000..85489f850e2 --- /dev/null +++ b/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs @@ -0,0 +1,450 @@ +// Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs + +#![feature( + no_core, unboxed_closures, lang_items, never_type, linkage, + extern_types, thread_local +)] +#![no_core] +#![allow(dead_code, internal_features, non_camel_case_types)] +#![rustfmt_skip] + +extern crate mini_core; + +use mini_core::*; +use mini_core::libc::*; + +unsafe extern "C" fn my_puts(s: *const u8) { + puts(s); +} + +#[lang = "termination"] +trait Termination { + fn report(self) -> i32; +} + +impl Termination for () { + fn report(self) -> i32 { + unsafe { + NUM = 6 * 7 + 1 + (1u8 == 1u8) as u8; // 44 + *NUM_REF as i32 + } + } +} + +trait SomeTrait { + fn object_safe(&self); +} + +impl SomeTrait for &'static str { + fn object_safe(&self) { + unsafe { + puts(*self as *const str as *const u8); + } + } +} + +struct NoisyDrop { + text: &'static str, + inner: NoisyDropInner, +} + +struct NoisyDropUnsized { + inner: NoisyDropInner, + text: str, +} + +struct NoisyDropInner; + +impl Drop for NoisyDrop { + fn drop(&mut self) { + unsafe { + puts(self.text as *const str as *const u8); + } + } +} + +impl Drop for NoisyDropInner { + fn drop(&mut self) { + unsafe { + puts("Inner got dropped!\0" as *const str as *const u8); + } + } +} + +impl SomeTrait for NoisyDrop { + fn object_safe(&self) {} +} + +enum Ordering { + Less = -1, + Equal = 0, + Greater = 1, +} + +#[lang = "start"] +fn start<T: Termination + 'static>( + main: fn() -> T, + argc: isize, + argv: *const *const u8, + _sigpipe: u8, +) -> isize { + if argc == 3 { + unsafe { puts(*argv); } + unsafe { puts(*((argv as usize + intrinsics::size_of::<*const u8>()) as *const *const u8)); } + unsafe { puts(*((argv as usize + 2 * intrinsics::size_of::<*const u8>()) as *const *const u8)); } + } + + main().report(); + 0 +} + +static mut NUM: u8 = 6 * 7; + +static NUM_REF: &'static u8 = unsafe { &* &raw const NUM }; + +macro_rules! assert { + ($e:expr) => { + if !$e { + panic(stringify!(! $e)); + } + }; +} + +macro_rules! assert_eq { + ($l:expr, $r: expr) => { + if $l != $r { + panic(stringify!($l != $r)); + } + } +} + +struct Unique<T: ?Sized> { + pointer: *const T, + _marker: PhantomData<T>, +} + +impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {} + +unsafe fn zeroed<T>() -> T { + let mut uninit = MaybeUninit { uninit: () }; + intrinsics::write_bytes(&mut uninit.value.value as *mut T, 0, 1); + uninit.value.value +} + +fn take_f32(_f: f32) {} +fn take_unique(_u: Unique<()>) {} + +fn return_u128_pair() -> (u128, u128) { + (0, 0) +} + +fn call_return_u128_pair() { + return_u128_pair(); +} + +fn main() { + take_unique(Unique { + pointer: 0 as *const (), + _marker: PhantomData, + }); + take_f32(0.1); + + //call_return_u128_pair(); + + let slice = &[0, 1] as &[i32]; + let slice_ptr = slice as *const [i32] as *const i32; + + let align = intrinsics::align_of::<*const i32>(); + assert_eq!(slice_ptr as usize % align, 0); + + //return; + + unsafe { + printf("Hello %s\n\0" as *const str as *const i8, "printf\0" as *const str as *const i8); + + let hello: &[u8] = b"Hello\0" as &[u8; 6]; + let ptr: *const u8 = hello as *const [u8] as *const u8; + puts(ptr); + + let world: Box<&str> = Box::new("World!\0"); + puts(*world as *const str as *const u8); + world as Box<dyn SomeTrait>; + + assert_eq!(intrinsics::bitreverse(0b10101000u8), 0b00010101u8); + assert_eq!(intrinsics::bitreverse(0xddccu16), 0x33bbu16); + assert_eq!(intrinsics::bitreverse(0xffee_ddccu32), 0x33bb77ffu32); + assert_eq!(intrinsics::bitreverse(0x1234_5678_ffee_ddccu64), 0x33bb77ff1e6a2c48u64); + + assert_eq!(intrinsics::bswap(0xabu8), 0xabu8); + assert_eq!(intrinsics::bswap(0xddccu16), 0xccddu16); + assert_eq!(intrinsics::bswap(0xffee_ddccu32), 0xccdd_eeffu32); + assert_eq!(intrinsics::bswap(0x1234_5678_ffee_ddccu64), 0xccdd_eeff_7856_3412u64); + + assert_eq!(intrinsics::size_of_val(hello) as u8, 6); + + let chars = &['C', 'h', 'a', 'r', 's']; + let chars = chars as &[char]; + assert_eq!(intrinsics::size_of_val(chars) as u8, 4 * 5); + + let a: &dyn SomeTrait = &"abc\0"; + a.object_safe(); + + #[cfg(target_arch="x86_64")] + assert_eq!(intrinsics::size_of_val(a) as u8, 16); + #[cfg(target_arch="m68k")] + assert_eq!(intrinsics::size_of_val(a) as u8, 8); + assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4); + + assert_eq!(intrinsics::align_of::<u16>() as u8, 2); + assert_eq!(intrinsics::align_of_val(&a) as u8, intrinsics::align_of::<&str>() as u8); + + /* + * TODO: re-enable in the next sync. + let u8_needs_drop = const { intrinsics::needs_drop::<u8>() }; + assert!(!u8_needs_drop); + let slice_needs_drop = const { intrinsics::needs_drop::<[u8]>() }; + assert!(!slice_needs_drop); + let noisy_drop = const { intrinsics::needs_drop::<NoisyDrop>() }; + assert!(noisy_drop); + let noisy_unsized_drop = const { intrinsics::needs_drop::<NoisyDropUnsized>() }; + assert!(noisy_unsized_drop); + */ + + Unique { + pointer: 0 as *const &str, + _marker: PhantomData, + } as Unique<dyn SomeTrait>; + + struct MyDst<T: ?Sized>(T); + + intrinsics::size_of_val(&MyDst([0u8; 4]) as &MyDst<[u8]>); + + struct Foo { + x: u8, + y: !, + } + + unsafe fn uninitialized<T>() -> T { + MaybeUninit { uninit: () }.value.value + } + + zeroed::<(u8, u8)>(); + #[allow(unreachable_code)] + { + if false { + zeroed::<!>(); + zeroed::<Foo>(); + uninitialized::<Foo>(); + } + } + } + + let _ = Box::new(NoisyDrop { + text: "Boxed outer got dropped!\0", + inner: NoisyDropInner, + }) as Box<dyn SomeTrait>; + + const FUNC_REF: Option<fn()> = Some(main); + #[allow(unreachable_code)] + match FUNC_REF { + Some(_) => {}, + None => assert!(false), + } + + match Ordering::Less { + Ordering::Less => {}, + _ => assert!(false), + } + + [NoisyDropInner, NoisyDropInner]; + + let x = &[0u32, 42u32] as &[u32]; + match x { + [] => assert_eq!(0u32, 1), + [_, ref y @ ..] => assert_eq!(&x[1] as *const u32 as usize, &y[0] as *const u32 as usize), + } + + assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42); + + extern "C" { + #[linkage = "weak"] + static ABC: *const u8; + } + + { + extern "C" { + #[linkage = "weak"] + static ABC: *const u8; + } + } + + // TODO(antoyo): to make this work, support weak linkage. + //unsafe { assert_eq!(ABC as usize, 0); } + + &mut (|| Some(0 as *const ())) as &mut dyn FnMut() -> Option<*const ()>; + + let f = 1000.0; + assert_eq!(f as u8, 255); + let f2 = -1000.0; + assert_eq!(f2 as i8, -128); + assert_eq!(f2 as u8, 0); + + static ANOTHER_STATIC: &u8 = &A_STATIC; + assert_eq!(*ANOTHER_STATIC, 42); + + check_niche_behavior(); + + extern "C" { + type ExternType; + } + + struct ExternTypeWrapper { + _a: ExternType, + } + + let nullptr = 0 as *const (); + let extern_nullptr = nullptr as *const ExternTypeWrapper; + extern_nullptr as *const (); + let slice_ptr = &[] as *const [u8]; + slice_ptr as *const u8; + + #[cfg(not(jit))] + test_tls(); +} + +#[repr(C)] +enum c_void { + _1, + _2, +} + +type c_int = i32; +type c_ulong = u64; + +type pthread_t = c_ulong; + +#[repr(C)] +struct pthread_attr_t { + __size: [u64; 7], +} + +#[link(name = "pthread")] +extern "C" { + fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int; + + fn pthread_create( + native: *mut pthread_t, + attr: *const pthread_attr_t, + f: extern "C" fn(_: *mut c_void) -> *mut c_void, + value: *mut c_void + ) -> c_int; + + fn pthread_join( + native: pthread_t, + value: *mut *mut c_void + ) -> c_int; +} + +#[thread_local] +#[cfg(not(jit))] +static mut TLS: u8 = 42; + +#[cfg(not(jit))] +extern "C" fn mutate_tls(_: *mut c_void) -> *mut c_void { + unsafe { TLS = 0; } + 0 as *mut c_void +} + +#[cfg(not(jit))] +fn test_tls() { + unsafe { + let mut attr: pthread_attr_t = zeroed(); + let mut thread: pthread_t = 0; + + assert_eq!(TLS, 42); + + if pthread_attr_init(&mut attr) != 0 { + assert!(false); + } + + if pthread_create(&mut thread, &attr, mutate_tls, 0 as *mut c_void) != 0 { + assert!(false); + } + + let mut res = 0 as *mut c_void; + pthread_join(thread, &mut res); + + // TLS of main thread must not have been changed by the other thread. + assert_eq!(TLS, 42); + + puts("TLS works!\n\0" as *const str as *const u8); + } +} + +// Copied ui/issues/issue-61696.rs + +pub enum Infallible {} + +// The check that the `bool` field of `V1` is encoding a "niche variant" +// (i.e. not `V1`, so `V3` or `V4`) used to be mathematically incorrect, +// causing valid `V1` values to be interpreted as other variants. +pub enum E1 { + V1 { f: bool }, + V2 { f: Infallible }, + V3, + V4, +} + +// Computing the discriminant used to be done using the niche type (here `u8`, +// from the `bool` field of `V1`), overflowing for variants with large enough +// indices (`V3` and `V4`), causing them to be interpreted as other variants. +pub enum E2<X> { + V1 { f: bool }, + + /*_00*/ _01(X), _02(X), _03(X), _04(X), _05(X), _06(X), _07(X), + _08(X), _09(X), _0A(X), _0B(X), _0C(X), _0D(X), _0E(X), _0F(X), + _10(X), _11(X), _12(X), _13(X), _14(X), _15(X), _16(X), _17(X), + _18(X), _19(X), _1A(X), _1B(X), _1C(X), _1D(X), _1E(X), _1F(X), + _20(X), _21(X), _22(X), _23(X), _24(X), _25(X), _26(X), _27(X), + _28(X), _29(X), _2A(X), _2B(X), _2C(X), _2D(X), _2E(X), _2F(X), + _30(X), _31(X), _32(X), _33(X), _34(X), _35(X), _36(X), _37(X), + _38(X), _39(X), _3A(X), _3B(X), _3C(X), _3D(X), _3E(X), _3F(X), + _40(X), _41(X), _42(X), _43(X), _44(X), _45(X), _46(X), _47(X), + _48(X), _49(X), _4A(X), _4B(X), _4C(X), _4D(X), _4E(X), _4F(X), + _50(X), _51(X), _52(X), _53(X), _54(X), _55(X), _56(X), _57(X), + _58(X), _59(X), _5A(X), _5B(X), _5C(X), _5D(X), _5E(X), _5F(X), + _60(X), _61(X), _62(X), _63(X), _64(X), _65(X), _66(X), _67(X), + _68(X), _69(X), _6A(X), _6B(X), _6C(X), _6D(X), _6E(X), _6F(X), + _70(X), _71(X), _72(X), _73(X), _74(X), _75(X), _76(X), _77(X), + _78(X), _79(X), _7A(X), _7B(X), _7C(X), _7D(X), _7E(X), _7F(X), + _80(X), _81(X), _82(X), _83(X), _84(X), _85(X), _86(X), _87(X), + _88(X), _89(X), _8A(X), _8B(X), _8C(X), _8D(X), _8E(X), _8F(X), + _90(X), _91(X), _92(X), _93(X), _94(X), _95(X), _96(X), _97(X), + _98(X), _99(X), _9A(X), _9B(X), _9C(X), _9D(X), _9E(X), _9F(X), + _A0(X), _A1(X), _A2(X), _A3(X), _A4(X), _A5(X), _A6(X), _A7(X), + _A8(X), _A9(X), _AA(X), _AB(X), _AC(X), _AD(X), _AE(X), _AF(X), + _B0(X), _B1(X), _B2(X), _B3(X), _B4(X), _B5(X), _B6(X), _B7(X), + _B8(X), _B9(X), _BA(X), _BB(X), _BC(X), _BD(X), _BE(X), _BF(X), + _C0(X), _C1(X), _C2(X), _C3(X), _C4(X), _C5(X), _C6(X), _C7(X), + _C8(X), _C9(X), _CA(X), _CB(X), _CC(X), _CD(X), _CE(X), _CF(X), + _D0(X), _D1(X), _D2(X), _D3(X), _D4(X), _D5(X), _D6(X), _D7(X), + _D8(X), _D9(X), _DA(X), _DB(X), _DC(X), _DD(X), _DE(X), _DF(X), + _E0(X), _E1(X), _E2(X), _E3(X), _E4(X), _E5(X), _E6(X), _E7(X), + _E8(X), _E9(X), _EA(X), _EB(X), _EC(X), _ED(X), _EE(X), _EF(X), + _F0(X), _F1(X), _F2(X), _F3(X), _F4(X), _F5(X), _F6(X), _F7(X), + _F8(X), _F9(X), _FA(X), _FB(X), _FC(X), _FD(X), _FE(X), _FF(X), + + V3, + V4, +} + +#[allow(unreachable_patterns)] +fn check_niche_behavior () { + if let E1::V2 { .. } = (E1::V1 { f: true }) { + intrinsics::abort(); + } + + if let E2::V1 { .. } = E2::V3::<Infallible> { + intrinsics::abort(); + } +} diff --git a/compiler/rustc_codegen_gcc/example/std_example.rs b/compiler/rustc_codegen_gcc/example/std_example.rs new file mode 100644 index 00000000000..7587b4827ca --- /dev/null +++ b/compiler/rustc_codegen_gcc/example/std_example.rs @@ -0,0 +1,302 @@ +#![allow(internal_features)] +#![feature(core_intrinsics, coroutines, coroutine_trait, stmt_expr_attributes)] + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +use std::arch::x86_64::*; +use std::io::Write; +use std::ops::Coroutine; + +extern "C" { + pub fn printf(format: *const i8, ...) -> i32; +} + +fn main() { + let mutex = std::sync::Mutex::new(()); + let _guard = mutex.lock().unwrap(); + + let _ = ::std::iter::repeat('a' as u8).take(10).collect::<Vec<_>>(); + let stderr = ::std::io::stderr(); + let mut stderr = stderr.lock(); + + std::thread::spawn(move || { + println!("Hello from another thread!"); + }); + + writeln!(stderr, "some {} text", "<unknown>").unwrap(); + + let _ = std::process::Command::new("true").env("c", "d").spawn(); + + println!("cargo:rustc-link-lib=z"); + + static ONCE: std::sync::Once = std::sync::Once::new(); + ONCE.call_once(|| {}); + + let _eq = LoopState::Continue(()) == LoopState::Break(()); + + // Make sure ByValPair values with differently sized components are correctly passed + map(None::<(u8, Box<Instruction>)>); + + println!("{}", 2.3f32.exp()); + println!("{}", 2.3f32.exp2()); + println!("{}", 2.3f32.abs()); + println!("{}", 2.3f32.sqrt()); + println!("{}", 2.3f32.floor()); + println!("{}", 2.3f32.ceil()); + println!("{}", 2.3f32.min(1.0)); + println!("{}", 2.3f32.max(1.0)); + println!("{}", 2.3f32.powi(2)); + println!("{}", 2.3f32.log2()); + assert_eq!(2.3f32.copysign(-1.0), -2.3f32); + println!("{}", 2.3f32.powf(2.0)); + + assert_eq!(-128i8, (-128i8).saturating_sub(1)); + assert_eq!(127i8, 127i8.saturating_sub(-128)); + assert_eq!(-128i8, (-128i8).saturating_add(-128)); + assert_eq!(127i8, 127i8.saturating_add(1)); + + assert_eq!(-32768i16, (-32768i16).saturating_add(-32768)); + assert_eq!(32767i16, 32767i16.saturating_add(1)); + + assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); + assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); + assert_eq!(0x1234_5678_ffee_ddcc_1234_5678_ffee_ddccu128.reverse_bits(), 0x33bb77ff1e6a2c4833bb77ff1e6a2c48u128); + + let _d = 0i128.checked_div(2i128); + let _d = 0u128.checked_div(2u128); + assert_eq!(1u128 + 2, 3); + + assert_eq!(0b100010000000000000000000000000000u128 >> 10, 0b10001000000000000000000u128); + assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 >> 64, 0xFEDCBA98765432u128); + assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64, 0xFEDCBA98765432i128); + + let tmp = 353985398u128; + assert_eq!(tmp * 932490u128, 330087843781020u128); + + let tmp = -0x1234_5678_9ABC_DEF0i64; + assert_eq!(tmp as i128, -0x1234_5678_9ABC_DEF0i128); + + // Check that all u/i128 <-> float casts work correctly. + let hundred_u128 = 100u128; + let hundred_i128 = 100i128; + let hundred_f32 = 100.0f32; + let hundred_f64 = 100.0f64; + assert_eq!(hundred_u128 as f32, 100.0); + assert_eq!(hundred_u128 as f64, 100.0); + assert_eq!(hundred_f32 as u128, 100); + assert_eq!(hundred_f64 as u128, 100); + assert_eq!(hundred_i128 as f32, 100.0); + assert_eq!(hundred_i128 as f64, 100.0); + assert_eq!(hundred_f32 as i128, 100); + assert_eq!(hundred_f64 as i128, 100); + + let _a = 1u32 << 2u8; + + let empty: [i32; 0] = []; + assert!(empty.is_sorted()); + + println!("{:?}", std::intrinsics::caller_location()); + + #[cfg(target_arch="x86_64")] + #[cfg(feature="master")] + unsafe { + test_simd(); + } + + Box::pin(#[coroutine] move |mut _task_context| { + yield (); + }).as_mut().resume(0); + + println!("End"); +} + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +#[target_feature(enable = "sse2")] +unsafe fn test_simd() { + let x = _mm_setzero_si128(); + let y = _mm_set1_epi16(7); + let or = _mm_or_si128(x, y); + let cmp_eq = _mm_cmpeq_epi8(y, y); + let cmp_lt = _mm_cmplt_epi8(y, y); + + assert_eq!(std::mem::transmute::<_, [u16; 8]>(or), [7, 7, 7, 7, 7, 7, 7, 7]); + assert_eq!(std::mem::transmute::<_, [u16; 8]>(cmp_eq), [0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff]); + assert_eq!(std::mem::transmute::<_, [u16; 8]>(cmp_lt), [0, 0, 0, 0, 0, 0, 0, 0]); + + test_mm_slli_si128(); + test_mm_movemask_epi8(); + test_mm256_movemask_epi8(); + test_mm_add_epi8(); + test_mm_add_pd(); + test_mm_cvtepi8_epi16(); + test_mm_cvtsi128_si64(); + + test_mm_extract_epi8(); + test_mm_insert_epi16(); + + let mask1 = _mm_movemask_epi8(dbg!(_mm_setr_epi8(255u8 as i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); + assert_eq!(mask1, 1); +} + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +#[target_feature(enable = "sse2")] +unsafe fn test_mm_slli_si128() { + #[rustfmt::skip] + let a = _mm_setr_epi8( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + ); + let r = _mm_slli_si128(a, 1); + let e = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + assert_eq_m128i(r, e); + + #[rustfmt::skip] + let a = _mm_setr_epi8( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + ); + let r = _mm_slli_si128(a, 15); + let e = _mm_setr_epi8(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); + assert_eq_m128i(r, e); + + #[rustfmt::skip] + let a = _mm_setr_epi8( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + ); + let r = _mm_slli_si128(a, 16); + assert_eq_m128i(r, _mm_set1_epi8(0)); +} + + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +#[target_feature(enable = "sse2")] +unsafe fn test_mm_movemask_epi8() { + #[rustfmt::skip] + let a = _mm_setr_epi8( + 0b1000_0000u8 as i8, 0b0, 0b1000_0000u8 as i8, 0b01, + 0b0101, 0b1111_0000u8 as i8, 0, 0, + 0, 0, 0b1111_0000u8 as i8, 0b0101, + 0b01, 0b1000_0000u8 as i8, 0b0, 0b1000_0000u8 as i8, + ); + let r = _mm_movemask_epi8(a); + assert_eq!(r, 0b10100100_00100101); +} + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +#[target_feature(enable = "avx2")] +unsafe fn test_mm256_movemask_epi8() { + let a = _mm256_set1_epi8(-1); + let r = _mm256_movemask_epi8(a); + let e = -1; + assert_eq!(r, e); +} + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +#[target_feature(enable = "sse2")] +unsafe fn test_mm_add_epi8() { + let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + #[rustfmt::skip] + let b = _mm_setr_epi8( + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + ); + let r = _mm_add_epi8(a, b); + #[rustfmt::skip] + let e = _mm_setr_epi8( + 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, + ); + assert_eq_m128i(r, e); +} + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +#[target_feature(enable = "sse2")] +unsafe fn test_mm_add_pd() { + let a = _mm_setr_pd(1.0, 2.0); + let b = _mm_setr_pd(5.0, 10.0); + let r = _mm_add_pd(a, b); + assert_eq_m128d(r, _mm_setr_pd(6.0, 12.0)); +} + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +fn assert_eq_m128i(x: std::arch::x86_64::__m128i, y: std::arch::x86_64::__m128i) { + unsafe { + assert_eq!(std::mem::transmute::<_, [u8; 16]>(x), std::mem::transmute::<_, [u8; 16]>(y)); + } +} + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +#[target_feature(enable = "sse2")] +pub unsafe fn assert_eq_m128d(a: __m128d, b: __m128d) { + if _mm_movemask_pd(_mm_cmpeq_pd(a, b)) != 0b11 { + panic!("{:?} != {:?}", a, b); + } +} + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +#[target_feature(enable = "sse2")] +unsafe fn test_mm_cvtsi128_si64() { + let r = _mm_cvtsi128_si64(std::mem::transmute::<[i64; 2], _>([5, 0])); + assert_eq!(r, 5); +} + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +#[target_feature(enable = "sse4.1")] +unsafe fn test_mm_cvtepi8_epi16() { + let a = _mm_set1_epi8(10); + let r = _mm_cvtepi8_epi16(a); + let e = _mm_set1_epi16(10); + assert_eq_m128i(r, e); + let a = _mm_set1_epi8(-10); + let r = _mm_cvtepi8_epi16(a); + let e = _mm_set1_epi16(-10); + assert_eq_m128i(r, e); +} + +#[cfg(feature="master")] +#[cfg(target_arch="x86_64")] +#[target_feature(enable = "sse4.1")] +unsafe fn test_mm_extract_epi8() { + #[rustfmt::skip] + let a = _mm_setr_epi8( + -1, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15 + ); + let r1 = _mm_extract_epi8(a, 0); + let r2 = _mm_extract_epi8(a, 3); + assert_eq!(r1, 0xFF); + assert_eq!(r2, 3); +} + +#[cfg(all(feature="master", target_arch = "x86_64"))] +#[target_feature(enable = "sse2")] +unsafe fn test_mm_insert_epi16() { + let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); + let r = _mm_insert_epi16(a, 9, 0); + let e = _mm_setr_epi16(9, 1, 2, 3, 4, 5, 6, 7); + assert_eq_m128i(r, e); +} + +#[derive(PartialEq)] +enum LoopState { + Continue(()), + Break(()) +} + +pub enum Instruction { + Increment, + Loop, +} + +fn map(a: Option<(u8, Box<Instruction>)>) -> Option<Box<Instruction>> { + match a { + None => None, + Some((_, instr)) => Some(instr), + } +} diff --git a/compiler/rustc_codegen_gcc/example/subslice-patterns-const-eval.rs b/compiler/rustc_codegen_gcc/example/subslice-patterns-const-eval.rs new file mode 100644 index 00000000000..2cb84786f56 --- /dev/null +++ b/compiler/rustc_codegen_gcc/example/subslice-patterns-const-eval.rs @@ -0,0 +1,97 @@ +// Based on https://github.com/rust-lang/rust/blob/c5840f9d252c2f5cc16698dbf385a29c5de3ca07/src/test/ui/array-slice-vec/subslice-patterns-const-eval-match.rs + +// Test that array subslice patterns are correctly handled in const evaluation. + +// run-pass + +#[derive(PartialEq, Debug, Clone)] +struct N(u8); + +#[derive(PartialEq, Debug, Clone)] +struct Z; + +macro_rules! n { + ($($e:expr),* $(,)?) => { + [$(N($e)),*] + } +} + +// This macro has an unused variable so that it can be repeated base on the +// number of times a repeated variable (`$e` in `z`) occurs. +macro_rules! zed { + ($e:expr) => { Z } +} + +macro_rules! z { + ($($e:expr),* $(,)?) => { + [$(zed!($e)),*] + } +} + +// Compare constant evaluation and runtime evaluation of a given expression. +macro_rules! compare_evaluation { + ($e:expr, $t:ty $(,)?) => {{ + const CONST_EVAL: $t = $e; + const fn const_eval() -> $t { $e } + static CONST_EVAL2: $t = const_eval(); + let runtime_eval = $e; + assert_eq!(CONST_EVAL, runtime_eval); + assert_eq!(CONST_EVAL2, runtime_eval); + }} +} + +// Repeat `$test`, substituting the given macro variables with the given +// identifiers. +// +// For example: +// +// repeat! { +// ($name); X; Y: +// struct $name; +// } +// +// Expands to: +// +// struct X; struct Y; +// +// This is used to repeat the tests using both the `N` and `Z` +// types. +macro_rules! repeat { + (($($dollar:tt $placeholder:ident)*); $($($values:ident),+);*: $($test:tt)*) => { + macro_rules! single { + ($($dollar $placeholder:ident),*) => { $($test)* } + } + $(single!($($values),+);)* + } +} + +fn main() { + repeat! { + ($arr $Ty); n, N; z, Z: + compare_evaluation!({ let [_, x @ .., _] = $arr!(1, 2, 3, 4); x }, [$Ty; 2]); + compare_evaluation!({ let [_, ref x @ .., _] = $arr!(1, 2, 3, 4); x }, &'static [$Ty; 2]); + compare_evaluation!({ let [_, x @ .., _] = &$arr!(1, 2, 3, 4); x }, &'static [$Ty; 2]); + + compare_evaluation!({ let [_, _, x @ .., _, _] = $arr!(1, 2, 3, 4); x }, [$Ty; 0]); + compare_evaluation!( + { let [_, _, ref x @ .., _, _] = $arr!(1, 2, 3, 4); x }, + &'static [$Ty; 0], + ); + compare_evaluation!( + { let [_, _, x @ .., _, _] = &$arr!(1, 2, 3, 4); x }, + &'static [$Ty; 0], + ); + + compare_evaluation!({ let [_, .., x] = $arr!(1, 2, 3, 4); x }, $Ty); + compare_evaluation!({ let [_, .., ref x] = $arr!(1, 2, 3, 4); x }, &'static $Ty); + compare_evaluation!({ let [_, _y @ .., x] = &$arr!(1, 2, 3, 4); x }, &'static $Ty); + } + + compare_evaluation!({ let [_, .., N(x)] = n!(1, 2, 3, 4); x }, u8); + compare_evaluation!({ let [_, .., N(ref x)] = n!(1, 2, 3, 4); x }, &'static u8); + compare_evaluation!({ let [_, .., N(x)] = &n!(1, 2, 3, 4); x }, &'static u8); + + compare_evaluation!({ let [N(x), .., _] = n!(1, 2, 3, 4); x }, u8); + compare_evaluation!({ let [N(ref x), .., _] = n!(1, 2, 3, 4); x }, &'static u8); + compare_evaluation!({ let [N(x), .., _] = &n!(1, 2, 3, 4); x }, &'static u8); +} diff --git a/compiler/rustc_codegen_gcc/example/track-caller-attribute.rs b/compiler/rustc_codegen_gcc/example/track-caller-attribute.rs new file mode 100644 index 00000000000..93bab17e46b --- /dev/null +++ b/compiler/rustc_codegen_gcc/example/track-caller-attribute.rs @@ -0,0 +1,40 @@ +// Based on https://github.com/anp/rust/blob/175631311716d7dfeceec40d2587cde7142ffa8c/src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs + +// run-pass + +use std::panic::Location; + +#[track_caller] +fn tracked() -> &'static Location<'static> { + Location::caller() +} + +fn nested_intrinsic() -> &'static Location<'static> { + Location::caller() +} + +fn nested_tracked() -> &'static Location<'static> { + tracked() +} + +fn main() { + let location = Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), 21); + assert_eq!(location.column(), 20); + + let tracked = tracked(); + assert_eq!(tracked.file(), file!()); + assert_eq!(tracked.line(), 26); + assert_eq!(tracked.column(), 19); + + let nested = nested_intrinsic(); + assert_eq!(nested.file(), file!()); + assert_eq!(nested.line(), 13); + assert_eq!(nested.column(), 5); + + let contained = nested_tracked(); + assert_eq!(contained.file(), file!()); + assert_eq!(contained.line(), 17); + assert_eq!(contained.column(), 5); +} diff --git a/compiler/rustc_codegen_gcc/libgccjit.version b/compiler/rustc_codegen_gcc/libgccjit.version new file mode 100644 index 00000000000..f62154968d3 --- /dev/null +++ b/compiler/rustc_codegen_gcc/libgccjit.version @@ -0,0 +1 @@ +04ce66d8c918de9273bd7101638ad8724edf5e21 diff --git a/compiler/rustc_codegen_gcc/messages.ftl b/compiler/rustc_codegen_gcc/messages.ftl new file mode 100644 index 00000000000..b9b77b7d18c --- /dev/null +++ b/compiler/rustc_codegen_gcc/messages.ftl @@ -0,0 +1,8 @@ +codegen_gcc_unwinding_inline_asm = + GCC backend does not support unwinding from inline asm + +codegen_gcc_copy_bitcode = failed to copy bitcode to object file: {$err} + +codegen_gcc_lto_bitcode_from_rlib = failed to get bitcode from object file for LTO ({$gcc_err}) + +codegen_gcc_explicit_tail_calls_unsupported = explicit tail calls with the 'become' keyword are not implemented in the GCC backend diff --git a/compiler/rustc_codegen_gcc/patches/0001-Add-stdarch-Cargo.toml-for-testing.patch b/compiler/rustc_codegen_gcc/patches/0001-Add-stdarch-Cargo.toml-for-testing.patch new file mode 100644 index 00000000000..3a8c37a8b8d --- /dev/null +++ b/compiler/rustc_codegen_gcc/patches/0001-Add-stdarch-Cargo.toml-for-testing.patch @@ -0,0 +1,39 @@ +From 190e26c9274b3c93a9ee3516b395590e6bd9213b Mon Sep 17 00:00:00 2001 +From: None <none@example.com> +Date: Sun, 3 Aug 2025 19:54:56 -0400 +Subject: [PATCH] Patch 0001-Add-stdarch-Cargo.toml-for-testing.patch + +--- + library/stdarch/Cargo.toml | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + create mode 100644 library/stdarch/Cargo.toml + +diff --git a/library/stdarch/Cargo.toml b/library/stdarch/Cargo.toml +new file mode 100644 +index 0000000..bd6725c +--- /dev/null ++++ b/library/stdarch/Cargo.toml +@@ -0,0 +1,20 @@ ++[workspace] ++resolver = "1" ++members = [ ++ "crates/*", ++ #"examples/" ++] ++exclude = [ ++ "crates/wasm-assert-instr-tests", ++ "rust_programs", ++] ++ ++[profile.release] ++debug = true ++opt-level = 3 ++incremental = true ++ ++[profile.bench] ++debug = 1 ++opt-level = 3 ++incremental = true +-- +2.50.1 + diff --git a/compiler/rustc_codegen_gcc/patches/0028-core-Disable-long-running-tests.patch b/compiler/rustc_codegen_gcc/patches/0028-core-Disable-long-running-tests.patch new file mode 100644 index 00000000000..20df4245cfd --- /dev/null +++ b/compiler/rustc_codegen_gcc/patches/0028-core-Disable-long-running-tests.patch @@ -0,0 +1,32 @@ +From ec2d0dc77fb484d926b45bb626b0db6a4bb0ab5c Mon Sep 17 00:00:00 2001 +From: None <none@example.com> +Date: Thu, 27 Mar 2025 09:20:41 -0400 +Subject: [PATCH] Disable long running tests + +--- + library/coretests/tests/slice.rs | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/library/coretests/tests/slice.rs b/library/coretests/tests/slice.rs +index d17e681..fba5cd6 100644 +--- a/library/coretests/tests/slice.rs ++++ b/library/coretests/tests/slice.rs +@@ -2486,6 +2486,7 @@ split_off_tests! { + #[cfg(not(miri))] // unused in Miri + const EMPTY_MAX: &'static [()] = &[(); usize::MAX]; + ++/* + // can't be a constant due to const mutability rules + #[cfg(not(miri))] // unused in Miri + macro_rules! empty_max_mut { +@@ -2509,6 +2510,7 @@ split_off_tests! { + (split_off_mut_oob_max_range_to_inclusive, (..=usize::MAX), None, empty_max_mut!()), + (split_off_mut_in_bounds_max_range_from, (usize::MAX..), Some(&mut [] as _), empty_max_mut!()), + } ++*/ + + #[test] + fn test_slice_from_ptr_range() { +-- +2.49.0 + diff --git a/compiler/rustc_codegen_gcc/patches/crates/0001-Remove-deny-warnings.patch b/compiler/rustc_codegen_gcc/patches/crates/0001-Remove-deny-warnings.patch new file mode 100644 index 00000000000..66ea1df4e13 --- /dev/null +++ b/compiler/rustc_codegen_gcc/patches/crates/0001-Remove-deny-warnings.patch @@ -0,0 +1,24 @@ +From f4a31d2c57cdbd578b778ab70eb2a0cfb248652c Mon Sep 17 00:00:00 2001 +From: Antoni Boucher <bouanto@zoho.com> +Date: Tue, 5 Mar 2024 12:39:44 -0500 +Subject: [PATCH] Remove #[deny(warnings)] + +--- + src/lib.rs | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/lib.rs b/src/lib.rs +index 8ade2881d5..e26c595e38 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -47,7 +47,6 @@ + )] + #![deny(missing_docs)] + #![deny(missing_debug_implementations)] +-#![doc(test(attr(allow(unused_variables), deny(warnings))))] + #![no_std] + #![cfg_attr(feature = "simd_support", feature(stdsimd, portable_simd))] + #![cfg_attr(doc_cfg, feature(doc_cfg))] +-- +2.44.0 + diff --git a/compiler/rustc_codegen_gcc/patches/cross_patches/0001-Disable-libstd-and-libtest-dylib.patch b/compiler/rustc_codegen_gcc/patches/cross_patches/0001-Disable-libstd-and-libtest-dylib.patch new file mode 100644 index 00000000000..fa360fe9e74 --- /dev/null +++ b/compiler/rustc_codegen_gcc/patches/cross_patches/0001-Disable-libstd-and-libtest-dylib.patch @@ -0,0 +1,25 @@ +From b2911e732d1bf0e28872495c4c47af1dad3c7911 Mon Sep 17 00:00:00 2001 +From: None <none@example.com> +Date: Thu, 27 Mar 2025 14:30:10 -0400 +Subject: [PATCH] Disable libstd and libtest dylib + +--- + library/std/Cargo.toml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml +index 176da60..c183cdb 100644 +--- a/library/std/Cargo.toml ++++ b/library/std/Cargo.toml +@@ -10,7 +10,7 @@ edition = "2024" + autobenches = false + + [lib] +-crate-type = ["dylib", "rlib"] ++crate-type = ["rlib"] + + [dependencies] + alloc = { path = "../alloc", public = true } +-- +2.49.0 + diff --git a/compiler/rustc_codegen_gcc/patches/libgccjit12/0001-core-Disable-portable-simd-test.patch b/compiler/rustc_codegen_gcc/patches/libgccjit12/0001-core-Disable-portable-simd-test.patch new file mode 100644 index 00000000000..9d5b2dc537d --- /dev/null +++ b/compiler/rustc_codegen_gcc/patches/libgccjit12/0001-core-Disable-portable-simd-test.patch @@ -0,0 +1,24 @@ +From 1a8f6b8e39f343959d4d2e6b6957a6d780ac3fc0 Mon Sep 17 00:00:00 2001 +From: None <none@example.com> +Date: Thu, 27 Mar 2025 14:32:14 -0400 +Subject: [PATCH] Disable portable-simd test + +--- + library/coretests/tests/lib.rs | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs +index 79022fe..9223b2f 100644 +--- a/library/coretests/tests/lib.rs ++++ b/library/coretests/tests/lib.rs +@@ -165,7 +165,6 @@ mod pin; + mod pin_macro; + mod ptr; + mod result; +-mod simd; + mod slice; + mod str; + mod str_lossy; +-- +2.49.0 + diff --git a/compiler/rustc_codegen_gcc/rust-toolchain b/compiler/rustc_codegen_gcc/rust-toolchain new file mode 100644 index 00000000000..058e734be5c --- /dev/null +++ b/compiler/rustc_codegen_gcc/rust-toolchain @@ -0,0 +1,3 @@ +[toolchain] +channel = "nightly-2025-08-03" +components = ["rust-src", "rustc-dev", "llvm-tools-preview"] diff --git a/compiler/rustc_codegen_gcc/src/abi.rs b/compiler/rustc_codegen_gcc/src/abi.rs new file mode 100644 index 00000000000..0b359f1c5c8 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/abi.rs @@ -0,0 +1,284 @@ +#[cfg(feature = "master")] +use gccjit::FnAttribute; +use gccjit::{ToLValue, ToRValue, Type}; +#[cfg(feature = "master")] +use rustc_abi::{ArmCall, CanonAbi, InterruptKind, X86Call}; +use rustc_abi::{Reg, RegKind}; +use rustc_codegen_ssa::traits::{AbiBuilderMethods, BaseTypeCodegenMethods}; +use rustc_data_structures::fx::FxHashSet; +use rustc_middle::bug; +use rustc_middle::ty::Ty; +use rustc_middle::ty::layout::LayoutOf; +#[cfg(feature = "master")] +use rustc_session::config; +use rustc_target::callconv::{ArgAttributes, CastTarget, FnAbi, PassMode}; + +use crate::builder::Builder; +use crate::context::CodegenCx; +use crate::type_of::LayoutGccExt; + +impl AbiBuilderMethods for Builder<'_, '_, '_> { + fn get_param(&mut self, index: usize) -> Self::Value { + let func = self.current_func(); + let param = func.get_param(index as i32); + let on_stack = if let Some(on_stack_param_indices) = + self.on_stack_function_params.borrow().get(&func) + { + on_stack_param_indices.contains(&index) + } else { + false + }; + if on_stack { param.to_lvalue().get_address(None) } else { param.to_rvalue() } + } +} + +impl GccType for CastTarget { + fn gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, '_>) -> Type<'gcc> { + let rest_gcc_unit = self.rest.unit.gcc_type(cx); + let (rest_count, rem_bytes) = if self.rest.unit.size.bytes() == 0 { + (0, 0) + } else { + ( + self.rest.total.bytes() / self.rest.unit.size.bytes(), + self.rest.total.bytes() % self.rest.unit.size.bytes(), + ) + }; + + if self.prefix.iter().all(|x| x.is_none()) { + // Simplify to a single unit when there is no prefix and size <= unit size + if self.rest.total <= self.rest.unit.size { + return rest_gcc_unit; + } + + // Simplify to array when all chunks are the same size and type + if rem_bytes == 0 { + return cx.type_array(rest_gcc_unit, rest_count); + } + } + + // Create list of fields in the main structure + let mut args: Vec<_> = self + .prefix + .iter() + .flat_map(|option_reg| option_reg.map(|reg| reg.gcc_type(cx))) + .chain((0..rest_count).map(|_| rest_gcc_unit)) + .collect(); + + // Append final integer + if rem_bytes != 0 { + // Only integers can be really split further. + assert_eq!(self.rest.unit.kind, RegKind::Integer); + args.push(cx.type_ix(rem_bytes * 8)); + } + + cx.type_struct(&args, false) + } +} + +pub trait GccType { + fn gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, '_>) -> Type<'gcc>; +} + +impl GccType for Reg { + fn gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, '_>) -> Type<'gcc> { + match self.kind { + RegKind::Integer => cx.type_ix(self.size.bits()), + RegKind::Float => match self.size.bits() { + 32 => cx.type_f32(), + 64 => cx.type_f64(), + _ => bug!("unsupported float: {:?}", self), + }, + RegKind::Vector => unimplemented!(), //cx.type_vector(cx.type_i8(), self.size.bytes()), + } + } +} + +pub struct FnAbiGcc<'gcc> { + pub return_type: Type<'gcc>, + pub arguments_type: Vec<Type<'gcc>>, + pub is_c_variadic: bool, + pub on_stack_param_indices: FxHashSet<usize>, + #[cfg(feature = "master")] + pub fn_attributes: Vec<FnAttribute<'gcc>>, +} + +pub trait FnAbiGccExt<'gcc, 'tcx> { + // TODO(antoyo): return a function pointer type instead? + fn gcc_type(&self, cx: &CodegenCx<'gcc, 'tcx>) -> FnAbiGcc<'gcc>; + fn ptr_to_gcc_type(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>; + #[cfg(feature = "master")] + fn gcc_cconv(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Option<FnAttribute<'gcc>>; +} + +impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { + fn gcc_type(&self, cx: &CodegenCx<'gcc, 'tcx>) -> FnAbiGcc<'gcc> { + let mut on_stack_param_indices = FxHashSet::default(); + + // This capacity calculation is approximate. + let mut argument_tys = Vec::with_capacity( + self.args.len() + if let PassMode::Indirect { .. } = self.ret.mode { 1 } else { 0 }, + ); + + let return_type = match self.ret.mode { + PassMode::Ignore => cx.type_void(), + PassMode::Direct(_) | PassMode::Pair(..) => self.ret.layout.immediate_gcc_type(cx), + PassMode::Cast { ref cast, .. } => cast.gcc_type(cx), + PassMode::Indirect { .. } => { + argument_tys.push(cx.type_ptr_to(self.ret.layout.gcc_type(cx))); + cx.type_void() + } + }; + #[cfg(feature = "master")] + let mut non_null_args = Vec::new(); + + #[cfg(feature = "master")] + let mut apply_attrs = |mut ty: Type<'gcc>, attrs: &ArgAttributes, arg_index: usize| { + if cx.sess().opts.optimize == config::OptLevel::No { + return ty; + } + if attrs.regular.contains(rustc_target::callconv::ArgAttribute::NoAlias) { + ty = ty.make_restrict() + } + if attrs.regular.contains(rustc_target::callconv::ArgAttribute::NonNull) { + non_null_args.push(arg_index as i32 + 1); + } + ty + }; + #[cfg(not(feature = "master"))] + let apply_attrs = |ty: Type<'gcc>, _attrs: &ArgAttributes, _arg_index: usize| ty; + + for arg in self.args.iter() { + let arg_ty = match arg.mode { + PassMode::Ignore => continue, + PassMode::Pair(a, b) => { + let arg_pos = argument_tys.len(); + argument_tys.push(apply_attrs( + arg.layout.scalar_pair_element_gcc_type(cx, 0), + &a, + arg_pos, + )); + argument_tys.push(apply_attrs( + arg.layout.scalar_pair_element_gcc_type(cx, 1), + &b, + arg_pos + 1, + )); + continue; + } + PassMode::Cast { ref cast, pad_i32 } => { + // add padding + if pad_i32 { + argument_tys.push(Reg::i32().gcc_type(cx)); + } + let ty = cast.gcc_type(cx); + apply_attrs(ty, &cast.attrs, argument_tys.len()) + } + PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: true } => { + // This is a "byval" argument, so we don't apply the `restrict` attribute on it. + on_stack_param_indices.insert(argument_tys.len()); + arg.layout.gcc_type(cx) + } + PassMode::Direct(attrs) => { + apply_attrs(arg.layout.immediate_gcc_type(cx), &attrs, argument_tys.len()) + } + PassMode::Indirect { attrs, meta_attrs: None, on_stack: false } => { + apply_attrs(cx.type_ptr_to(arg.layout.gcc_type(cx)), &attrs, argument_tys.len()) + } + PassMode::Indirect { attrs, meta_attrs: Some(meta_attrs), on_stack } => { + assert!(!on_stack); + // Construct the type of a (wide) pointer to `ty`, and pass its two fields. + // Any two ABI-compatible unsized types have the same metadata type and + // moreover the same metadata value leads to the same dynamic size and + // alignment, so this respects ABI compatibility. + let ptr_ty = Ty::new_mut_ptr(cx.tcx, arg.layout.ty); + let ptr_layout = cx.layout_of(ptr_ty); + let typ1 = ptr_layout.scalar_pair_element_gcc_type(cx, 0); + let typ2 = ptr_layout.scalar_pair_element_gcc_type(cx, 1); + argument_tys.push(apply_attrs(typ1, &attrs, argument_tys.len())); + argument_tys.push(apply_attrs(typ2, &meta_attrs, argument_tys.len())); + continue; + } + }; + argument_tys.push(arg_ty); + } + + #[cfg(feature = "master")] + let fn_attrs = if non_null_args.is_empty() { + Vec::new() + } else { + vec![FnAttribute::NonNull(non_null_args)] + }; + + FnAbiGcc { + return_type, + arguments_type: argument_tys, + is_c_variadic: self.c_variadic, + on_stack_param_indices, + #[cfg(feature = "master")] + fn_attributes: fn_attrs, + } + } + + fn ptr_to_gcc_type(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> { + // FIXME(antoyo): Should we do something with `FnAbiGcc::fn_attributes`? + let FnAbiGcc { return_type, arguments_type, is_c_variadic, on_stack_param_indices, .. } = + self.gcc_type(cx); + let pointer_type = + cx.context.new_function_pointer_type(None, return_type, &arguments_type, is_c_variadic); + cx.on_stack_params.borrow_mut().insert( + pointer_type.dyncast_function_ptr_type().expect("function ptr type"), + on_stack_param_indices, + ); + pointer_type + } + + #[cfg(feature = "master")] + fn gcc_cconv(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Option<FnAttribute<'gcc>> { + conv_to_fn_attribute(self.conv, &cx.tcx.sess.target.arch) + } +} + +#[cfg(feature = "master")] +pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &str) -> Option<FnAttribute<'gcc>> { + let attribute = match conv { + CanonAbi::C | CanonAbi::Rust => return None, + CanonAbi::RustCold => FnAttribute::Cold, + // Functions with this calling convention can only be called from assembly, but it is + // possible to declare an `extern "custom"` block, so the backend still needs a calling + // convention for declaring foreign functions. + CanonAbi::Custom => return None, + CanonAbi::Arm(arm_call) => match arm_call { + ArmCall::CCmseNonSecureCall => FnAttribute::ArmCmseNonsecureCall, + ArmCall::CCmseNonSecureEntry => FnAttribute::ArmCmseNonsecureEntry, + ArmCall::Aapcs => FnAttribute::ArmPcs("aapcs"), + }, + CanonAbi::GpuKernel => { + if arch == "amdgpu" { + FnAttribute::GcnAmdGpuHsaKernel + } else if arch == "nvptx64" { + FnAttribute::NvptxKernel + } else { + panic!("Architecture {} does not support GpuKernel calling convention", arch); + } + } + // TODO(antoyo): check if those AVR attributes are mapped correctly. + CanonAbi::Interrupt(interrupt_kind) => match interrupt_kind { + InterruptKind::Avr => FnAttribute::AvrSignal, + InterruptKind::AvrNonBlocking => FnAttribute::AvrInterrupt, + InterruptKind::Msp430 => FnAttribute::Msp430Interrupt, + InterruptKind::RiscvMachine => FnAttribute::RiscvInterrupt("machine"), + InterruptKind::RiscvSupervisor => FnAttribute::RiscvInterrupt("supervisor"), + InterruptKind::X86 => FnAttribute::X86Interrupt, + }, + CanonAbi::X86(x86_call) => match x86_call { + X86Call::Fastcall => FnAttribute::X86FastCall, + X86Call::Stdcall => FnAttribute::X86Stdcall, + X86Call::Thiscall => FnAttribute::X86ThisCall, + // // NOTE: the vectorcall calling convention is not yet implemented in GCC: + // // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89485 + X86Call::Vectorcall => return None, + X86Call::SysV64 => FnAttribute::X86SysvAbi, + X86Call::Win64 => FnAttribute::X86MsAbi, + }, + }; + Some(attribute) +} diff --git a/compiler/rustc_codegen_gcc/src/allocator.rs b/compiler/rustc_codegen_gcc/src/allocator.rs new file mode 100644 index 00000000000..2a95a7368aa --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/allocator.rs @@ -0,0 +1,192 @@ +#[cfg(feature = "master")] +use gccjit::FnAttribute; +use gccjit::{Context, FunctionType, RValue, ToRValue, Type}; +use rustc_ast::expand::allocator::{ + ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, + alloc_error_handler_name, default_fn_name, global_fn_name, +}; +use rustc_middle::bug; +use rustc_middle::ty::TyCtxt; +use rustc_session::config::OomStrategy; +use rustc_symbol_mangling::mangle_internal_symbol; + +use crate::GccContext; +#[cfg(feature = "master")] +use crate::base::symbol_visibility_to_gcc; + +pub(crate) unsafe fn codegen( + tcx: TyCtxt<'_>, + mods: &mut GccContext, + _module_name: &str, + kind: AllocatorKind, + alloc_error_handler_kind: AllocatorKind, +) { + let context = &mods.context; + let usize = match tcx.sess.target.pointer_width { + 16 => context.new_type::<u16>(), + 32 => context.new_type::<u32>(), + 64 => context.new_type::<u64>(), + tws => bug!("Unsupported target word size for int: {}", tws), + }; + let i8 = context.new_type::<i8>(); + let i8p = i8.make_pointer(); + + if kind == AllocatorKind::Default { + for method in ALLOCATOR_METHODS { + let mut types = Vec::with_capacity(method.inputs.len()); + for input in method.inputs.iter() { + match input.ty { + AllocatorTy::Layout => { + types.push(usize); + types.push(usize); + } + AllocatorTy::Ptr => types.push(i8p), + AllocatorTy::Usize => types.push(usize), + + AllocatorTy::ResultPtr | AllocatorTy::Unit => panic!("invalid allocator arg"), + } + } + let output = match method.output { + AllocatorTy::ResultPtr => Some(i8p), + AllocatorTy::Unit => None, + + AllocatorTy::Layout | AllocatorTy::Usize | AllocatorTy::Ptr => { + panic!("invalid allocator output") + } + }; + let from_name = mangle_internal_symbol(tcx, &global_fn_name(method.name)); + let to_name = mangle_internal_symbol(tcx, &default_fn_name(method.name)); + + create_wrapper_function(tcx, context, &from_name, Some(&to_name), &types, output); + } + } + + // FIXME(bjorn3): Add noreturn attribute + create_wrapper_function( + tcx, + context, + &mangle_internal_symbol(tcx, "__rust_alloc_error_handler"), + Some(&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind))), + &[usize, usize], + None, + ); + + create_const_value_function( + tcx, + context, + &mangle_internal_symbol(tcx, OomStrategy::SYMBOL), + i8, + context.new_rvalue_from_int(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as i32), + ); + + create_wrapper_function( + tcx, + context, + &mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE), + None, + &[], + None, + ); +} + +fn create_const_value_function( + tcx: TyCtxt<'_>, + context: &Context<'_>, + name: &str, + output: Type<'_>, + value: RValue<'_>, +) { + let func = context.new_function(None, FunctionType::Exported, output, &[], name, false); + + #[cfg(feature = "master")] + { + func.add_attribute(FnAttribute::Visibility(symbol_visibility_to_gcc( + tcx.sess.default_visibility(), + ))); + + // FIXME(antoyo): cg_llvm sets AlwaysInline, but AlwaysInline is different in GCC and using + // it here will causes linking errors when using LTO. + func.add_attribute(FnAttribute::Inline); + } + + if tcx.sess.must_emit_unwind_tables() { + // TODO(antoyo): emit unwind tables. + } + + let block = func.new_block("entry"); + block.end_with_return(None, value); +} + +fn create_wrapper_function( + tcx: TyCtxt<'_>, + context: &Context<'_>, + from_name: &str, + to_name: Option<&str>, + types: &[Type<'_>], + output: Option<Type<'_>>, +) { + let void = context.new_type::<()>(); + + let args: Vec<_> = types + .iter() + .enumerate() + .map(|(index, typ)| context.new_parameter(None, *typ, format!("param{}", index))) + .collect(); + let func = context.new_function( + None, + FunctionType::Exported, + output.unwrap_or(void), + &args, + from_name, + false, + ); + + #[cfg(feature = "master")] + func.add_attribute(FnAttribute::Visibility(symbol_visibility_to_gcc( + tcx.sess.default_visibility(), + ))); + + if tcx.sess.must_emit_unwind_tables() { + // TODO(antoyo): emit unwind tables. + } + + let block = func.new_block("entry"); + + if let Some(to_name) = to_name { + let args: Vec<_> = types + .iter() + .enumerate() + .map(|(index, typ)| context.new_parameter(None, *typ, format!("param{}", index))) + .collect(); + let callee = context.new_function( + None, + FunctionType::Extern, + output.unwrap_or(void), + &args, + to_name, + false, + ); + #[cfg(feature = "master")] + callee.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Hidden)); + + let args = args + .iter() + .enumerate() + .map(|(i, _)| func.get_param(i as i32).to_rvalue()) + .collect::<Vec<_>>(); + let ret = context.new_call(None, callee, &args); + //llvm::LLVMSetTailCall(ret, True); + if output.is_some() { + block.end_with_return(None, ret); + } else { + block.add_eval(None, ret); + block.end_with_void_return(None); + } + } else { + assert!(output.is_none()); + block.end_with_void_return(None); + } + + // TODO(@Commeownist): Check if we need to emit some extra debugging info in certain circumstances + // as described in https://github.com/rust-lang/rust/commit/77a96ed5646f7c3ee8897693decc4626fe380643 +} diff --git a/compiler/rustc_codegen_gcc/src/asm.rs b/compiler/rustc_codegen_gcc/src/asm.rs new file mode 100644 index 00000000000..17e2e028b16 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/asm.rs @@ -0,0 +1,1015 @@ +// cSpell:ignoreRegExp [afkspqvwy]reg + +use std::borrow::Cow; + +use gccjit::{LValue, RValue, ToRValue, Type}; +use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece}; +use rustc_codegen_ssa::mir::operand::OperandValue; +use rustc_codegen_ssa::mir::place::PlaceRef; +use rustc_codegen_ssa::traits::{ + AsmBuilderMethods, AsmCodegenMethods, BaseTypeCodegenMethods, BuilderMethods, + GlobalAsmOperandRef, InlineAsmOperandRef, +}; +use rustc_middle::bug; +use rustc_middle::ty::Instance; +use rustc_span::Span; +use rustc_target::asm::*; + +use crate::builder::Builder; +use crate::callee::get_fn; +use crate::context::CodegenCx; +use crate::errors::UnwindingInlineAsm; +use crate::type_of::LayoutGccExt; + +// Rust asm! and GCC Extended Asm semantics differ substantially. +// +// 1. Rust asm operands go along as one list of operands. Operands themselves indicate +// if they're "in" or "out". "In" and "out" operands can interleave. One operand can be +// both "in" and "out" (`inout(reg)`). +// +// GCC asm has two different lists for "in" and "out" operands. In terms of gccjit, +// this means that all "out" operands must go before "in" operands. "In" and "out" operands +// cannot interleave. +// +// 2. Operand lists in both Rust and GCC are indexed. Index starts from 0. Indexes are important +// because the asm template refers to operands by index. +// +// Mapping from Rust to GCC index would be 1-1 if it wasn't for... +// +// 3. Clobbers. GCC has a separate list of clobbers, and clobbers don't have indexes. +// Contrary, Rust expresses clobbers through "out" operands that aren't tied to +// a variable (`_`), and such "clobbers" do have index. Input operands cannot also +// be clobbered. +// +// 4. Furthermore, GCC Extended Asm does not support explicit register constraints +// (like `out("eax")`) directly, offering so-called "local register variables" +// as a workaround. These variables need to be declared and initialized *before* +// the Extended Asm block but *after* normal local variables +// (see comment in `codegen_inline_asm` for explanation). +// +// With that in mind, let's see how we translate Rust syntax to GCC +// (from now on, `CC` stands for "constraint code"): +// +// * `out(reg_class) var` -> translated to output operand: `"=CC"(var)` +// * `inout(reg_class) var` -> translated to output operand: `"+CC"(var)` +// * `in(reg_class) var` -> translated to input operand: `"CC"(var)` +// +// * `out(reg_class) _` -> translated to one `=r(tmp)`, where "tmp" is a temporary unused variable +// +// * `out("explicit register") _` -> not translated to any operands, register is simply added to clobbers list +// +// * `inout(reg_class) in_var => out_var` -> translated to two operands: +// output: `"=CC"(in_var)` +// input: `"num"(out_var)` where num is the GCC index +// of the corresponding output operand +// +// * `inout(reg_class) in_var => _` -> same as `inout(reg_class) in_var => tmp`, +// where "tmp" is a temporary unused variable +// +// * `out/in/inout("explicit register") var` -> translated to one or two operands as described above +// with `"r"(var)` constraint, +// and one register variable assigned to the desired register. + +const ATT_SYNTAX_INS: &str = ".att_syntax noprefix\n\t"; +const INTEL_SYNTAX_INS: &str = "\n\t.intel_syntax noprefix"; + +struct AsmOutOperand<'a, 'tcx, 'gcc> { + rust_idx: usize, + constraint: &'a str, + late: bool, + readwrite: bool, + + tmp_var: LValue<'gcc>, + out_place: Option<PlaceRef<'tcx, RValue<'gcc>>>, +} + +struct AsmInOperand<'a, 'tcx> { + rust_idx: usize, + constraint: Cow<'a, str>, + val: RValue<'tcx>, +} + +impl AsmOutOperand<'_, '_, '_> { + fn to_constraint(&self) -> String { + let mut res = String::with_capacity(self.constraint.len() + self.late as usize + 1); + + let sign = if self.readwrite { '+' } else { '=' }; + res.push(sign); + if !self.late { + res.push('&'); + } + + res.push_str(self.constraint); + res + } +} + +enum ConstraintOrRegister { + Constraint(&'static str), + Register(&'static str), +} + +impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { + fn codegen_inline_asm( + &mut self, + template: &[InlineAsmTemplatePiece], + rust_operands: &[InlineAsmOperandRef<'tcx, Self>], + options: InlineAsmOptions, + span: &[Span], + instance: Instance<'_>, + dest: Option<Self::BasicBlock>, + _dest_catch_funclet: Option<(Self::BasicBlock, Option<&Self::Funclet>)>, + ) { + if options.contains(InlineAsmOptions::MAY_UNWIND) { + self.sess().dcx().create_err(UnwindingInlineAsm { span: span[0] }).emit(); + return; + } + + let asm_arch = self.tcx.sess.asm_arch.unwrap(); + let is_x86 = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64); + let att_dialect = is_x86 && options.contains(InlineAsmOptions::ATT_SYNTAX); + + // GCC index of an output operand equals its position in the array + let mut outputs = vec![]; + + // GCC index of an input operand equals its position in the array + // added to `outputs.len()` + let mut inputs = vec![]; + + // GCC index of a label equals its position in the array added to + // `outputs.len() + inputs.len()`. + let mut labels = vec![]; + + // Clobbers collected from `out("explicit register") _` and `inout("explicit_reg") var => _` + let mut clobbers = vec![]; + + // We're trying to preallocate space for the template + let mut constants_len = 0; + + // There are rules we must adhere to if we want GCC to do the right thing: + // + // * Every local variable that the asm block uses as an output must be declared *before* + // the asm block. + // * There must be no instructions whatsoever between the register variables and the asm. + // + // Therefore, the backend must generate the instructions strictly in this order: + // + // 1. Output variables. + // 2. Register variables. + // 3. The asm block. + // + // We also must make sure that no input operands are emitted before output operands. + // + // This is why we work in passes, first emitting local vars, then local register vars. + // Also, we don't emit any asm operands immediately; we save them to + // the one of the buffers to be emitted later. + + let mut input_registers = vec![]; + + for op in rust_operands { + if let InlineAsmOperandRef::In { reg, .. } = *op + && let ConstraintOrRegister::Register(reg_name) = reg_to_gcc(reg) + { + input_registers.push(reg_name); + } + } + + // 1. Normal variables (and saving operands to buffers). + for (rust_idx, op) in rust_operands.iter().enumerate() { + match *op { + InlineAsmOperandRef::Out { reg, late, place } => { + use ConstraintOrRegister::*; + + let (constraint, ty) = match (reg_to_gcc(reg), place) { + (Constraint(constraint), Some(place)) => { + (constraint, place.layout.gcc_type(self.cx)) + } + // When `reg` is a class and not an explicit register but the out place is not specified, + // we need to create an unused output variable to assign the output to. This var + // needs to be of a type that's "compatible" with the register class, but specific type + // doesn't matter. + (Constraint(constraint), None) => { + (constraint, dummy_output_type(self.cx, reg.reg_class())) + } + (Register(_), Some(_)) => { + // left for the next pass + continue; + } + (Register(reg_name), None) => { + if input_registers.contains(®_name) { + // the `clobber_abi` operand is converted into a series of + // `lateout("reg") _` operands. Of course, a user could also + // explicitly define such an output operand. + // + // GCC does not allow input registers to be clobbered, so if this out register + // is also used as an in register, do not add it to the clobbers list. + // it will be treated as a lateout register with `out_place: None` + if !late { + bug!("input registers can only be used as lateout registers"); + } + ("r", dummy_output_type(self.cx, reg.reg_class())) + } else { + // `clobber_abi` can add lots of clobbers that are not supported by the target, + // such as AVX-512 registers, so we just ignore unsupported registers + let is_target_supported = + reg.reg_class().supported_types(asm_arch, true).iter().any( + |&(_, feature)| { + if let Some(feature) = feature { + self.tcx + .asm_target_features(instance.def_id()) + .contains(&feature) + } else { + true // Register class is unconditionally supported + } + }, + ); + + if is_target_supported && !clobbers.contains(®_name) { + clobbers.push(reg_name); + } + continue; + } + } + }; + + let tmp_var = self.current_func().new_local(None, ty, "output_register"); + outputs.push(AsmOutOperand { + constraint, + rust_idx, + late, + readwrite: false, + tmp_var, + out_place: place, + }); + } + + InlineAsmOperandRef::In { reg, value } => { + if let ConstraintOrRegister::Constraint(constraint) = reg_to_gcc(reg) { + inputs.push(AsmInOperand { + constraint: Cow::Borrowed(constraint), + rust_idx, + val: value.immediate(), + }); + } else { + // left for the next pass + continue; + } + } + + InlineAsmOperandRef::InOut { reg, late, in_value, out_place } => { + let ConstraintOrRegister::Constraint(constraint) = reg_to_gcc(reg) else { + // left for the next pass + continue; + }; + + // Rustc frontend guarantees that input and output types are "compatible", + // so we can just use input var's type for the output variable. + // + // This decision is also backed by the fact that LLVM needs in and out + // values to be of *exactly the same type*, not just "compatible". + // I'm not sure if GCC is so picky too, but better safe than sorry. + let ty = in_value.layout.gcc_type(self.cx); + let tmp_var = self.current_func().new_local(None, ty, "output_register"); + + // If the out_place is None (i.e `inout(reg) _` syntax was used), we translate + // it to one "readwrite (+) output variable", otherwise we translate it to two + // "out and tied in" vars as described above. + let readwrite = out_place.is_none(); + outputs.push(AsmOutOperand { + constraint, + rust_idx, + late, + readwrite, + tmp_var, + out_place, + }); + + if !readwrite { + let out_gcc_idx = outputs.len() - 1; + let constraint = Cow::Owned(out_gcc_idx.to_string()); + + inputs.push(AsmInOperand { + constraint, + rust_idx, + val: in_value.immediate(), + }); + } + } + + InlineAsmOperandRef::Const { ref string } => { + constants_len += string.len() + att_dialect as usize; + } + + InlineAsmOperandRef::SymFn { instance } => { + // TODO(@Amanieu): Additional mangling is needed on + // some targets to add a leading underscore (Mach-O) + // or byte count suffixes (x86 Windows). + constants_len += self.tcx.symbol_name(instance).name.len(); + } + InlineAsmOperandRef::SymStatic { def_id } => { + // TODO(@Amanieu): Additional mangling is needed on + // some targets to add a leading underscore (Mach-O). + constants_len += + self.tcx.symbol_name(Instance::mono(self.tcx, def_id)).name.len(); + } + + InlineAsmOperandRef::Label { label } => { + labels.push(label); + } + } + } + + // 2. Register variables. + for (rust_idx, op) in rust_operands.iter().enumerate() { + match *op { + // `out("explicit register") var` + InlineAsmOperandRef::Out { reg, late, place } => { + if let ConstraintOrRegister::Register(reg_name) = reg_to_gcc(reg) { + let out_place = if let Some(place) = place { + place + } else { + // processed in the previous pass + continue; + }; + + let ty = out_place.layout.gcc_type(self.cx); + let tmp_var = self.current_func().new_local(None, ty, "output_register"); + tmp_var.set_register_name(reg_name); + + outputs.push(AsmOutOperand { + constraint: "r", + rust_idx, + late, + readwrite: false, + tmp_var, + out_place: Some(out_place), + }); + } + + // processed in the previous pass + } + + // `in("explicit register") var` + InlineAsmOperandRef::In { reg, value } => { + if let ConstraintOrRegister::Register(reg_name) = reg_to_gcc(reg) { + let ty = value.layout.gcc_type(self.cx); + let reg_var = self.current_func().new_local(None, ty, "input_register"); + reg_var.set_register_name(reg_name); + self.llbb().add_assignment(None, reg_var, value.immediate()); + + inputs.push(AsmInOperand { + constraint: "r".into(), + rust_idx, + val: reg_var.to_rvalue(), + }); + } + + // processed in the previous pass + } + + // `inout("explicit register") in_var => out_var` + InlineAsmOperandRef::InOut { reg, late, in_value, out_place } => { + if let ConstraintOrRegister::Register(reg_name) = reg_to_gcc(reg) { + // See explanation in the first pass. + let ty = in_value.layout.gcc_type(self.cx); + let tmp_var = self.current_func().new_local(None, ty, "output_register"); + tmp_var.set_register_name(reg_name); + + outputs.push(AsmOutOperand { + constraint: "r", + rust_idx, + late, + readwrite: false, + tmp_var, + out_place, + }); + + let constraint = Cow::Owned((outputs.len() - 1).to_string()); + inputs.push(AsmInOperand { + constraint, + rust_idx, + val: in_value.immediate(), + }); + } + + // processed in the previous pass + } + + InlineAsmOperandRef::SymFn { instance } => { + inputs.push(AsmInOperand { + constraint: "X".into(), + rust_idx, + val: get_fn(self.cx, instance).get_address(None), + }); + } + + InlineAsmOperandRef::SymStatic { def_id } => { + inputs.push(AsmInOperand { + constraint: "X".into(), + rust_idx, + val: self.cx.get_static(def_id).get_address(None), + }); + } + + InlineAsmOperandRef::Const { .. } => { + // processed in the previous pass + } + + InlineAsmOperandRef::Label { .. } => { + // processed in the previous pass + } + } + } + + // 3. Build the template string + + let mut template_str = + String::with_capacity(estimate_template_length(template, constants_len, att_dialect)); + if att_dialect { + template_str.push_str(ATT_SYNTAX_INS); + } + + for piece in template { + match *piece { + InlineAsmTemplatePiece::String(ref string) => { + for char in string.chars() { + // TODO(antoyo): might also need to escape | if rustc doesn't do it. + let escaped_char = match char { + '%' => "%%", + '{' => "%{", + '}' => "%}", + _ => { + template_str.push(char); + continue; + } + }; + template_str.push_str(escaped_char); + } + } + InlineAsmTemplatePiece::Placeholder { operand_idx, modifier, span: _ } => { + let mut push_to_template = |modifier, gcc_idx| { + use std::fmt::Write; + + template_str.push('%'); + if let Some(modifier) = modifier { + template_str.push(modifier); + } + write!(template_str, "{}", gcc_idx).expect("pushing to string failed"); + }; + + match rust_operands[operand_idx] { + InlineAsmOperandRef::Out { reg, .. } => { + let modifier = modifier_to_gcc(asm_arch, reg.reg_class(), modifier); + let gcc_index = outputs + .iter() + .position(|op| operand_idx == op.rust_idx) + .expect("wrong rust index"); + push_to_template(modifier, gcc_index); + } + + InlineAsmOperandRef::In { reg, .. } => { + let modifier = modifier_to_gcc(asm_arch, reg.reg_class(), modifier); + let in_gcc_index = inputs + .iter() + .position(|op| operand_idx == op.rust_idx) + .expect("wrong rust index"); + let gcc_index = in_gcc_index + outputs.len(); + push_to_template(modifier, gcc_index); + } + + InlineAsmOperandRef::InOut { reg, .. } => { + let modifier = modifier_to_gcc(asm_arch, reg.reg_class(), modifier); + + // The input register is tied to the output, so we can just use the index of the output register + let gcc_index = outputs + .iter() + .position(|op| operand_idx == op.rust_idx) + .expect("wrong rust index"); + push_to_template(modifier, gcc_index); + } + + InlineAsmOperandRef::SymFn { instance } => { + // TODO(@Amanieu): Additional mangling is needed on + // some targets to add a leading underscore (Mach-O) + // or byte count suffixes (x86 Windows). + let name = self.tcx.symbol_name(instance).name; + template_str.push_str(name); + } + + InlineAsmOperandRef::SymStatic { def_id } => { + // TODO(@Amanieu): Additional mangling is needed on + // some targets to add a leading underscore (Mach-O). + let instance = Instance::mono(self.tcx, def_id); + let name = self.tcx.symbol_name(instance).name; + template_str.push_str(name); + } + + InlineAsmOperandRef::Const { ref string } => { + template_str.push_str(string); + } + + InlineAsmOperandRef::Label { label } => { + let label_gcc_index = + labels.iter().position(|&l| l == label).expect("wrong rust index"); + let gcc_index = label_gcc_index + outputs.len() + inputs.len(); + push_to_template(Some('l'), gcc_index); + } + } + } + } + } + + if att_dialect { + template_str.push_str(INTEL_SYNTAX_INS); + } + + // 4. Generate Extended Asm block + + let block = self.llbb(); + let extended_asm = if let Some(dest) = dest { + assert!(!labels.is_empty()); + block.end_with_extended_asm_goto(None, &template_str, &labels, Some(dest)) + } else { + block.add_extended_asm(None, &template_str) + }; + + for op in &outputs { + extended_asm.add_output_operand(None, &op.to_constraint(), op.tmp_var); + } + + for op in &inputs { + extended_asm.add_input_operand(None, &op.constraint, op.val); + } + + for clobber in clobbers.iter() { + extended_asm.add_clobber(clobber); + } + + if !options.contains(InlineAsmOptions::PRESERVES_FLAGS) { + // TODO(@Commeownist): I'm not 100% sure this one clobber is sufficient + // on all architectures. For instance, what about FP stack? + extended_asm.add_clobber("cc"); + } + if !options.contains(InlineAsmOptions::NOMEM) { + extended_asm.add_clobber("memory"); + } + if !options.contains(InlineAsmOptions::PURE) { + extended_asm.set_volatile_flag(true); + } + if !options.contains(InlineAsmOptions::NOSTACK) { + // TODO(@Commeownist): figure out how to align stack + } + if dest.is_none() && options.contains(InlineAsmOptions::NORETURN) { + let builtin_unreachable = self.context.get_builtin_function("__builtin_unreachable"); + let builtin_unreachable: RValue<'gcc> = + unsafe { std::mem::transmute(builtin_unreachable) }; + self.call(self.type_void(), None, None, builtin_unreachable, &[], None, None); + } + + // Write results to outputs. + // + // We need to do this because: + // 1. Turning `PlaceRef` into `RValue` is error-prone and has nasty edge cases + // (especially with current `rustc_backend_ssa` API). + // 2. Not every output operand has an `out_place`, and it's required by `add_output_operand`. + // + // Instead, we generate a temporary output variable for each output operand, and then this loop, + // generates `out_place = tmp_var;` assignments if out_place exists. + for op in &outputs { + if let Some(place) = op.out_place { + OperandValue::Immediate(op.tmp_var.to_rvalue()).store(self, place); + } + } + } +} + +fn estimate_template_length( + template: &[InlineAsmTemplatePiece], + constants_len: usize, + att_dialect: bool, +) -> usize { + let len: usize = template + .iter() + .map(|piece| { + match *piece { + InlineAsmTemplatePiece::String(ref string) => string.len(), + InlineAsmTemplatePiece::Placeholder { .. } => { + // '%' + 1 char modifier + 1 char index + 3 + } + } + }) + .sum(); + + // increase it by 5% to account for possible '%' signs that'll be duplicated + // I pulled the number out of blue, but should be fair enough + // as the upper bound + let mut res = (len as f32 * 1.05) as usize + constants_len; + + if att_dialect { + res += INTEL_SYNTAX_INS.len() + ATT_SYNTAX_INS.len(); + } + res +} + +/// Converts a register class to a GCC constraint code. +fn reg_to_gcc(reg_or_reg_class: InlineAsmRegOrRegClass) -> ConstraintOrRegister { + match reg_or_reg_class { + InlineAsmRegOrRegClass::Reg(reg) => { + ConstraintOrRegister::Register(explicit_reg_to_gcc(reg)) + } + InlineAsmRegOrRegClass::RegClass(reg_class) => { + ConstraintOrRegister::Constraint(reg_class_to_gcc(reg_class)) + } + } +} + +fn explicit_reg_to_gcc(reg: InlineAsmReg) -> &'static str { + // For explicit registers, we have to create a register variable: https://stackoverflow.com/a/31774784/389119 + match reg { + InlineAsmReg::X86(reg) => { + // TODO(antoyo): add support for vector register. + match reg.reg_class() { + X86InlineAsmRegClass::reg_byte => { + // GCC does not support the `b` suffix, so we just strip it + // see https://github.com/rust-lang/rustc_codegen_gcc/issues/485 + reg.name().trim_end_matches('b') + } + _ => match reg.name() { + // Some of registers' names does not map 1-1 from rust to gcc + "st(0)" => "st", + + name => name, + }, + } + } + InlineAsmReg::Arm(reg) => reg.name(), + InlineAsmReg::AArch64(reg) => reg.name(), + _ => unimplemented!(), + } +} + +/// They can be retrieved from https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html +fn reg_class_to_gcc(reg_class: InlineAsmRegClass) -> &'static str { + match reg_class { + InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::reg) => "r", + InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg) => "w", + InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg_low16) => "x", + InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::preg) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::Arm(ArmInlineAsmRegClass::reg) => "r", + InlineAsmRegClass::Arm(ArmInlineAsmRegClass::sreg) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::dreg_low16) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::qreg_low8) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::sreg_low16) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::dreg_low8) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::qreg_low4) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::dreg) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::qreg) => "t", + InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg) => "r", + InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_upper) => "d", + InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_pair) => "r", + InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_iw) => "w", + InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_ptr) => "e", + InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::reg) => "r", + InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::wreg) => "w", + InlineAsmRegClass::Hexagon(HexagonInlineAsmRegClass::reg) => "r", + InlineAsmRegClass::Hexagon(HexagonInlineAsmRegClass::preg) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::LoongArch(LoongArchInlineAsmRegClass::reg) => "r", + InlineAsmRegClass::LoongArch(LoongArchInlineAsmRegClass::freg) => "f", + InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg) => "r", + InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_addr) => "a", + InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_data) => "d", + InlineAsmRegClass::CSKY(CSKYInlineAsmRegClass::reg) => "r", + InlineAsmRegClass::CSKY(CSKYInlineAsmRegClass::freg) => "f", + InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg) => "d", // more specific than "r" + InlineAsmRegClass::Mips(MipsInlineAsmRegClass::freg) => "f", + InlineAsmRegClass::Msp430(Msp430InlineAsmRegClass::reg) => "r", + // https://github.com/gcc-mirror/gcc/blob/master/gcc/config/nvptx/nvptx.md -> look for + // "define_constraint". + InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg16) => "h", + InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg32) => "r", + InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg64) => "l", + + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg) => "r", + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => "b", + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => "f", + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => "v", + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::cr) + | InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => "r", + InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::freg) => "f", + InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::vreg) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::X86(X86InlineAsmRegClass::reg) => "r", + InlineAsmRegClass::X86(X86InlineAsmRegClass::reg_abcd) => "Q", + InlineAsmRegClass::X86(X86InlineAsmRegClass::reg_byte) => "q", + InlineAsmRegClass::X86(X86InlineAsmRegClass::xmm_reg) + | InlineAsmRegClass::X86(X86InlineAsmRegClass::ymm_reg) => "x", + InlineAsmRegClass::X86(X86InlineAsmRegClass::zmm_reg) => "v", + InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => "Yk", + InlineAsmRegClass::X86( + X86InlineAsmRegClass::kreg0 + | X86InlineAsmRegClass::x87_reg + | X86InlineAsmRegClass::mmx_reg + | X86InlineAsmRegClass::tmm_reg, + ) => unreachable!("clobber-only"), + InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => { + bug!("GCC backend does not support SPIR-V") + } + InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => "r", + InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg) => "r", + InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg_addr) => "a", + InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => "f", + InlineAsmRegClass::S390x(S390xInlineAsmRegClass::vreg) => "v", + InlineAsmRegClass::S390x(S390xInlineAsmRegClass::areg) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::Sparc(SparcInlineAsmRegClass::reg) => "r", + InlineAsmRegClass::Sparc(SparcInlineAsmRegClass::yreg) => unreachable!("clobber-only"), + InlineAsmRegClass::Err => unreachable!(), + } +} + +/// Type to use for outputs that are discarded. It doesn't really matter what +/// the type is, as long as it is valid for the constraint code. +fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegClass) -> Type<'gcc> { + match reg { + InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::reg) => cx.type_i32(), + InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg) + | InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg_low16) => { + cx.type_vector(cx.type_i64(), 2) + } + InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::preg) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::Arm(ArmInlineAsmRegClass::reg) => cx.type_i32(), + InlineAsmRegClass::Arm(ArmInlineAsmRegClass::sreg) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::sreg_low16) => cx.type_f32(), + InlineAsmRegClass::Arm(ArmInlineAsmRegClass::dreg) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::dreg_low16) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::dreg_low8) => cx.type_f64(), + InlineAsmRegClass::Arm(ArmInlineAsmRegClass::qreg) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::qreg_low8) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::qreg_low4) => { + cx.type_vector(cx.type_i64(), 2) + } + InlineAsmRegClass::Hexagon(HexagonInlineAsmRegClass::reg) => cx.type_i32(), + InlineAsmRegClass::Hexagon(HexagonInlineAsmRegClass::preg) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::LoongArch(LoongArchInlineAsmRegClass::reg) => cx.type_i32(), + InlineAsmRegClass::LoongArch(LoongArchInlineAsmRegClass::freg) => cx.type_f32(), + InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg) => cx.type_i32(), + InlineAsmRegClass::Mips(MipsInlineAsmRegClass::freg) => cx.type_f32(), + InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg16) => cx.type_i16(), + InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg32) => cx.type_i32(), + InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg64) => cx.type_i64(), + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg) => cx.type_i32(), + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => cx.type_i32(), + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => cx.type_f64(), + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => { + cx.type_vector(cx.type_i32(), 4) + } + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::cr) + | InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => cx.type_i32(), + InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::freg) => cx.type_f32(), + InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::vreg) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::X86(X86InlineAsmRegClass::reg) + | InlineAsmRegClass::X86(X86InlineAsmRegClass::reg_abcd) => cx.type_i32(), + InlineAsmRegClass::X86(X86InlineAsmRegClass::reg_byte) => cx.type_i8(), + InlineAsmRegClass::X86(X86InlineAsmRegClass::xmm_reg) + | InlineAsmRegClass::X86(X86InlineAsmRegClass::ymm_reg) + | InlineAsmRegClass::X86(X86InlineAsmRegClass::zmm_reg) => cx.type_f32(), + InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => cx.type_i16(), + InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg) + | InlineAsmRegClass::X86(X86InlineAsmRegClass::mmx_reg) + | InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) + | InlineAsmRegClass::X86(X86InlineAsmRegClass::tmm_reg) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => cx.type_i32(), + InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::reg) => cx.type_i64(), + InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::wreg) => cx.type_i32(), + InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg) => cx.type_i8(), + InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_upper) => cx.type_i8(), + InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_pair) => cx.type_i16(), + InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_iw) => cx.type_i16(), + InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_ptr) => cx.type_i16(), + InlineAsmRegClass::S390x( + S390xInlineAsmRegClass::reg | S390xInlineAsmRegClass::reg_addr, + ) => cx.type_i32(), + InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => cx.type_f64(), + InlineAsmRegClass::S390x(S390xInlineAsmRegClass::vreg) => cx.type_vector(cx.type_i64(), 2), + InlineAsmRegClass::S390x(S390xInlineAsmRegClass::areg) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::Sparc(SparcInlineAsmRegClass::reg) => cx.type_i32(), + InlineAsmRegClass::Sparc(SparcInlineAsmRegClass::yreg) => unreachable!("clobber-only"), + InlineAsmRegClass::Msp430(Msp430InlineAsmRegClass::reg) => cx.type_i16(), + InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg) => cx.type_i32(), + InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_addr) => cx.type_i32(), + InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_data) => cx.type_i32(), + InlineAsmRegClass::CSKY(CSKYInlineAsmRegClass::reg) => cx.type_i32(), + InlineAsmRegClass::CSKY(CSKYInlineAsmRegClass::freg) => cx.type_f32(), + InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => { + bug!("GCC backend does not support SPIR-V") + } + InlineAsmRegClass::Err => unreachable!(), + } +} + +impl<'gcc, 'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> { + fn codegen_global_asm( + &mut self, + template: &[InlineAsmTemplatePiece], + operands: &[GlobalAsmOperandRef<'tcx>], + options: InlineAsmOptions, + _line_spans: &[Span], + ) { + let asm_arch = self.tcx.sess.asm_arch.unwrap(); + + // Default to Intel syntax on x86 + let att_dialect = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64) + && options.contains(InlineAsmOptions::ATT_SYNTAX); + + // Build the template string + let mut template_str = ".pushsection .text\n".to_owned(); + if att_dialect { + template_str.push_str(".att_syntax\n"); + } + for piece in template { + match *piece { + InlineAsmTemplatePiece::String(ref string) => { + let mut index = 0; + while index < string.len() { + // NOTE: gcc does not allow inline comment, so remove them. + let comment_index = string[index..] + .find("//") + .map(|comment_index| comment_index + index) + .unwrap_or(string.len()); + template_str.push_str(&string[index..comment_index]); + index = string[comment_index..] + .find('\n') + .map(|index| index + comment_index) + .unwrap_or(string.len()); + } + } + InlineAsmTemplatePiece::Placeholder { operand_idx, modifier: _, span: _ } => { + match operands[operand_idx] { + GlobalAsmOperandRef::Const { ref string } => { + // Const operands get injected directly into the + // template. Note that we don't need to escape % + // here unlike normal inline assembly. + template_str.push_str(string); + } + + GlobalAsmOperandRef::SymFn { instance } => { + let function = get_fn(self, instance); + self.add_used_function(function); + // TODO(@Amanieu): Additional mangling is needed on + // some targets to add a leading underscore (Mach-O) + // or byte count suffixes (x86 Windows). + let name = self.tcx.symbol_name(instance).name; + template_str.push_str(name); + } + + GlobalAsmOperandRef::SymStatic { def_id } => { + // TODO(antoyo): set the global variable as used. + // TODO(@Amanieu): Additional mangling is needed on + // some targets to add a leading underscore (Mach-O). + let instance = Instance::mono(self.tcx, def_id); + let name = self.tcx.symbol_name(instance).name; + template_str.push_str(name); + } + } + } + } + } + + if att_dialect { + template_str.push_str("\n\t.intel_syntax noprefix"); + } + // NOTE: seems like gcc will put the asm in the wrong section, so set it to .text manually. + template_str.push_str("\n.popsection"); + self.context.add_top_level_asm(None, &template_str); + } + + fn mangled_name(&self, instance: Instance<'tcx>) -> String { + // TODO(@Amanieu): Additional mangling is needed on + // some targets to add a leading underscore (Mach-O) + // or byte count suffixes (x86 Windows). + self.tcx.symbol_name(instance).name.to_string() + } +} + +fn modifier_to_gcc( + arch: InlineAsmArch, + reg: InlineAsmRegClass, + modifier: Option<char>, +) -> Option<char> { + // The modifiers can be retrieved from + // https://gcc.gnu.org/onlinedocs/gcc/Modifiers.html#Modifiers + match reg { + InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::reg) => modifier, + InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg) + | InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg_low16) => { + if modifier == Some('v') { None } else { modifier } + } + InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::preg) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::Arm(ArmInlineAsmRegClass::reg) => None, + InlineAsmRegClass::Arm(ArmInlineAsmRegClass::sreg) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::sreg_low16) => None, + InlineAsmRegClass::Arm(ArmInlineAsmRegClass::dreg) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::dreg_low16) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::dreg_low8) => Some('P'), + InlineAsmRegClass::Arm(ArmInlineAsmRegClass::qreg) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::qreg_low8) + | InlineAsmRegClass::Arm(ArmInlineAsmRegClass::qreg_low4) => { + if modifier.is_none() { + Some('q') + } else { + modifier + } + } + InlineAsmRegClass::Hexagon(_) => None, + InlineAsmRegClass::LoongArch(_) => None, + InlineAsmRegClass::Mips(_) => None, + InlineAsmRegClass::Nvptx(_) => None, + InlineAsmRegClass::PowerPC(_) => None, + InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) + | InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::freg) => None, + InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::vreg) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::X86(X86InlineAsmRegClass::reg) + | InlineAsmRegClass::X86(X86InlineAsmRegClass::reg_abcd) => match modifier { + None => { + if arch == InlineAsmArch::X86_64 { + Some('q') + } else { + Some('k') + } + } + Some('l') => Some('b'), + Some('h') => Some('h'), + Some('x') => Some('w'), + Some('e') => Some('k'), + Some('r') => Some('q'), + _ => unreachable!(), + }, + InlineAsmRegClass::X86(X86InlineAsmRegClass::reg_byte) => None, + InlineAsmRegClass::X86(reg @ X86InlineAsmRegClass::xmm_reg) + | InlineAsmRegClass::X86(reg @ X86InlineAsmRegClass::ymm_reg) + | InlineAsmRegClass::X86(reg @ X86InlineAsmRegClass::zmm_reg) => match (reg, modifier) { + (X86InlineAsmRegClass::xmm_reg, None) => Some('x'), + (X86InlineAsmRegClass::ymm_reg, None) => Some('t'), + (X86InlineAsmRegClass::zmm_reg, None) => Some('g'), + (_, Some('x')) => Some('x'), + (_, Some('y')) => Some('t'), + (_, Some('z')) => Some('g'), + _ => unreachable!(), + }, + InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => None, + InlineAsmRegClass::X86( + X86InlineAsmRegClass::x87_reg + | X86InlineAsmRegClass::mmx_reg + | X86InlineAsmRegClass::kreg0 + | X86InlineAsmRegClass::tmm_reg, + ) => { + unreachable!("clobber-only") + } + InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => None, + InlineAsmRegClass::Bpf(_) => None, + InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_pair) + | InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_iw) + | InlineAsmRegClass::Avr(AvrInlineAsmRegClass::reg_ptr) => match modifier { + Some('h') => Some('B'), + Some('l') => Some('A'), + _ => None, + }, + InlineAsmRegClass::Avr(_) => None, + InlineAsmRegClass::S390x(_) => None, + InlineAsmRegClass::Sparc(_) => None, + InlineAsmRegClass::Msp430(_) => None, + InlineAsmRegClass::M68k(_) => None, + InlineAsmRegClass::CSKY(_) => None, + InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => { + bug!("LLVM backend does not support SPIR-V") + } + InlineAsmRegClass::Err => unreachable!(), + } +} diff --git a/compiler/rustc_codegen_gcc/src/attributes.rs b/compiler/rustc_codegen_gcc/src/attributes.rs new file mode 100644 index 00000000000..04b43bb8bb7 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/attributes.rs @@ -0,0 +1,164 @@ +#[cfg(feature = "master")] +use gccjit::FnAttribute; +use gccjit::Function; +#[cfg(feature = "master")] +use rustc_hir::attrs::InlineAttr; +use rustc_hir::attrs::InstructionSetAttr; +#[cfg(feature = "master")] +use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; +#[cfg(feature = "master")] +use rustc_middle::mir::TerminatorKind; +use rustc_middle::ty; + +use crate::context::CodegenCx; +use crate::gcc_util::to_gcc_features; + +/// Checks if the function `instance` is recursively inline. +/// Returns `false` if a functions is guaranteed to be non-recursive, and `true` if it *might* be recursive. +#[cfg(feature = "master")] +fn recursively_inline<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + instance: ty::Instance<'tcx>, +) -> bool { + // No body, so we can't check if this is recursively inline, so we assume it is. + if !cx.tcx.is_mir_available(instance.def_id()) { + return true; + } + // `expect_local` ought to never fail: we should be checking a function within this codegen unit. + let body = cx.tcx.optimized_mir(instance.def_id()); + for block in body.basic_blocks.iter() { + let Some(ref terminator) = block.terminator else { continue }; + // I assume that the recursive-inline issue applies only to functions, and not to drops. + // In principle, a recursive, `#[inline(always)]` drop could(?) exist, but I don't think it does. + let TerminatorKind::Call { ref func, .. } = terminator.kind else { continue }; + let Some((def, _args)) = func.const_fn_def() else { continue }; + // Check if the called function is recursively inline. + if matches!( + cx.tcx.codegen_fn_attrs(def).inline, + InlineAttr::Always | InlineAttr::Force { .. } + ) { + return true; + } + } + false +} + +/// Get GCC attribute for the provided inline heuristic, attached to `instance`. +#[cfg(feature = "master")] +#[inline] +fn inline_attr<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + inline: InlineAttr, + instance: ty::Instance<'tcx>, +) -> Option<FnAttribute<'gcc>> { + match inline { + InlineAttr::Always => { + // We can't simply always return `always_inline` unconditionally. + // It is *NOT A HINT* and does not work for recursive functions. + // + // So, it can only be applied *if*: + // The current function does not call any functions marked `#[inline(always)]`. + // + // That prevents issues steming from recursive `#[inline(always)]` at a *relatively* small cost. + // We *only* need to check all the terminators of a function marked with this attribute. + if recursively_inline(cx, instance) { + Some(FnAttribute::Inline) + } else { + Some(FnAttribute::AlwaysInline) + } + } + InlineAttr::Hint => Some(FnAttribute::Inline), + InlineAttr::Force { .. } => Some(FnAttribute::AlwaysInline), + InlineAttr::Never => { + if cx.sess().target.arch != "amdgpu" { + Some(FnAttribute::NoInline) + } else { + None + } + } + InlineAttr::None => None, + } +} + +/// Composite function which sets GCC attributes for function depending on its AST (`#[attribute]`) +/// attributes. +pub fn from_fn_attrs<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + #[cfg_attr(not(feature = "master"), allow(unused_variables))] func: Function<'gcc>, + instance: ty::Instance<'tcx>, +) { + let codegen_fn_attrs = cx.tcx.codegen_instance_attrs(instance.def); + + #[cfg(feature = "master")] + { + let inline = if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) { + InlineAttr::Never + } else if codegen_fn_attrs.inline == InlineAttr::None + && instance.def.requires_inline(cx.tcx) + { + InlineAttr::Hint + } else { + codegen_fn_attrs.inline + }; + if let Some(attr) = inline_attr(cx, inline, instance) { + if let FnAttribute::AlwaysInline = attr { + func.add_attribute(FnAttribute::Inline); + } + func.add_attribute(attr); + } + + if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) { + func.add_attribute(FnAttribute::Cold); + } + if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_PURE) { + func.add_attribute(FnAttribute::Pure); + } + if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_CONST) { + func.add_attribute(FnAttribute::Const); + } + } + + let mut function_features = codegen_fn_attrs + .target_features + .iter() + .map(|features| features.name.as_str()) + .flat_map(|feat| to_gcc_features(cx.tcx.sess, feat).into_iter()) + .chain(codegen_fn_attrs.instruction_set.iter().map(|x| match *x { + InstructionSetAttr::ArmA32 => "-thumb-mode", // TODO(antoyo): support removing feature. + InstructionSetAttr::ArmT32 => "thumb-mode", + })) + .collect::<Vec<_>>(); + + // TODO(antoyo): cg_llvm adds global features to each function so that LTO keep them. + // Check if GCC requires the same. + let mut global_features = cx.tcx.global_backend_features(()).iter().map(|s| s.as_str()); + function_features.extend(&mut global_features); + let target_features = function_features + .iter() + .filter_map(|feature| { + // TODO(antoyo): support soft-float. + if feature.contains("soft-float") { + return None; + } + + if feature.starts_with('-') { + Some(format!("no{}", feature)) + } else if let Some(stripped) = feature.strip_prefix('+') { + Some(stripped.to_string()) + } else { + Some(feature.to_string()) + } + }) + .collect::<Vec<_>>() + .join(","); + if !target_features.is_empty() { + #[cfg(feature = "master")] + match cx.sess().target.arch.as_ref() { + "x86" | "x86_64" | "powerpc" => { + func.add_attribute(FnAttribute::Target(&target_features)) + } + // The target attribute is not supported on other targets in GCC. + _ => (), + } + } +} diff --git a/compiler/rustc_codegen_gcc/src/back/lto.rs b/compiler/rustc_codegen_gcc/src/back/lto.rs new file mode 100644 index 00000000000..d558dfbc1c4 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/back/lto.rs @@ -0,0 +1,666 @@ +/// GCC requires to use the same toolchain for the whole compilation when doing LTO. +/// So, we need the same version/commit of the linker (gcc) and lto front-end binaries (lto1, +/// lto-wrapper, liblto_plugin.so). +// FIXME(antoyo): the executables compiled with LTO are bigger than those compiled without LTO. +// Since it is the opposite for cg_llvm, check if this is normal. +// +// Maybe we embed the bitcode in the final binary? +// It doesn't look like we try to generate fat objects for the final binary. +// Check if the way we combine the object files make it keep the LTO sections on the final link. +// Maybe that's because the combined object files contain the IR (true) and the final link +// does not remove it? +// +// TODO(antoyo): for performance, check which optimizations the C++ frontend enables. +// cSpell:disable +// Fix these warnings: +// /usr/bin/ld: warning: type of symbol `_RNvNvNvNtCs5JWOrf9uCus_5rayon11thread_pool19WORKER_THREAD_STATE7___getit5___KEY' changed from 1 to 6 in /tmp/ccKeUSiR.ltrans0.ltrans.o +// /usr/bin/ld: warning: type of symbol `_RNvNvNvNvNtNtNtCsAj5i4SGTR7_3std4sync4mpmc5waker17current_thread_id5DUMMY7___getit5___KEY' changed from 1 to 6 in /tmp/ccKeUSiR.ltrans0.ltrans.o +// /usr/bin/ld: warning: incremental linking of LTO and non-LTO objects; using -flinker-output=nolto-rel which will bypass whole program optimization +// cSpell:enable +use std::ffi::{CStr, CString}; +use std::fs::{self, File}; +use std::path::{Path, PathBuf}; +use std::sync::Arc; + +use gccjit::{Context, OutputKind}; +use object::read::archive::ArchiveFile; +use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule, ThinShared}; +use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput}; +use rustc_codegen_ssa::traits::*; +use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file}; +use rustc_data_structures::memmap::Mmap; +use rustc_errors::{DiagCtxtHandle, FatalError}; +use rustc_middle::bug; +use rustc_middle::dep_graph::WorkProduct; +use rustc_session::config::Lto; +use rustc_target::spec::RelocModel; +use tempfile::{TempDir, tempdir}; + +use crate::back::write::save_temp_bitcode; +use crate::errors::LtoBitcodeFromRlib; +use crate::{GccCodegenBackend, GccContext, SyncContext, to_gcc_opt_level}; + +struct LtoData { + // TODO(antoyo): use symbols_below_threshold. + //symbols_below_threshold: Vec<String>, + upstream_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, + tmp_path: TempDir, +} + +fn prepare_lto( + cgcx: &CodegenContext<GccCodegenBackend>, + each_linked_rlib_for_lto: &[PathBuf], + dcx: DiagCtxtHandle<'_>, +) -> Result<LtoData, FatalError> { + let tmp_path = match tempdir() { + Ok(tmp_path) => tmp_path, + Err(error) => { + eprintln!("Cannot create temporary directory: {}", error); + return Err(FatalError); + } + }; + + // If we're performing LTO for the entire crate graph, then for each of our + // upstream dependencies, find the corresponding rlib and load the bitcode + // from the archive. + // + // We save off all the bytecode and GCC module file path for later processing + // with either fat or thin LTO + let mut upstream_modules = Vec::new(); + if cgcx.lto != Lto::ThinLocal { + for path in each_linked_rlib_for_lto { + let archive_data = unsafe { + Mmap::map(File::open(path).expect("couldn't open rlib")).expect("couldn't map rlib") + }; + let archive = ArchiveFile::parse(&*archive_data).expect("wanted an rlib"); + let obj_files = archive + .members() + .filter_map(|child| { + child.ok().and_then(|c| { + std::str::from_utf8(c.name()).ok().map(|name| (name.trim(), c)) + }) + }) + .filter(|&(name, _)| looks_like_rust_object_file(name)); + for (name, child) in obj_files { + info!("adding bitcode from {}", name); + let path = tmp_path.path().join(name); + match save_as_file(child.data(&*archive_data).expect("corrupt rlib"), &path) { + Ok(()) => { + let buffer = ModuleBuffer::new(path); + let module = SerializedModule::Local(buffer); + upstream_modules.push((module, CString::new(name).unwrap())); + } + Err(e) => { + dcx.emit_err(e); + return Err(FatalError); + } + } + } + } + } + + Ok(LtoData { upstream_modules, tmp_path }) +} + +fn save_as_file(obj: &[u8], path: &Path) -> Result<(), LtoBitcodeFromRlib> { + fs::write(path, obj).map_err(|error| LtoBitcodeFromRlib { + gcc_err: format!("write object file to temp dir: {}", error), + }) +} + +/// Performs fat LTO by merging all modules into a single one and returning it +/// for further optimization. +pub(crate) fn run_fat( + cgcx: &CodegenContext<GccCodegenBackend>, + each_linked_rlib_for_lto: &[PathBuf], + modules: Vec<FatLtoInput<GccCodegenBackend>>, +) -> Result<ModuleCodegen<GccContext>, FatalError> { + let dcx = cgcx.create_dcx(); + let dcx = dcx.handle(); + let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx)?; + /*let symbols_below_threshold = + lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/ + fat_lto( + cgcx, + dcx, + modules, + lto_data.upstream_modules, + lto_data.tmp_path, + //<o_data.symbols_below_threshold, + ) +} + +fn fat_lto( + cgcx: &CodegenContext<GccCodegenBackend>, + _dcx: DiagCtxtHandle<'_>, + modules: Vec<FatLtoInput<GccCodegenBackend>>, + mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, + tmp_path: TempDir, + //symbols_below_threshold: &[String], +) -> Result<ModuleCodegen<GccContext>, FatalError> { + let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module"); + info!("going for a fat lto"); + + // Sort out all our lists of incoming modules into two lists. + // + // * `serialized_modules` (also and argument to this function) contains all + // modules that are serialized in-memory. + // * `in_memory` contains modules which are already parsed and in-memory, + // such as from multi-CGU builds. + let mut in_memory = Vec::new(); + for module in modules { + match module { + FatLtoInput::InMemory(m) => in_memory.push(m), + FatLtoInput::Serialized { name, buffer } => { + info!("pushing serialized module {:?}", name); + serialized_modules.push((buffer, CString::new(name).unwrap())); + } + } + } + + // Find the "costliest" module and merge everything into that codegen unit. + // All the other modules will be serialized and reparsed into the new + // context, so this hopefully avoids serializing and parsing the largest + // codegen unit. + // + // Additionally use a regular module as the base here to ensure that various + // file copy operations in the backend work correctly. The only other kind + // of module here should be an allocator one, and if your crate is smaller + // than the allocator module then the size doesn't really matter anyway. + let costliest_module = in_memory + .iter() + .enumerate() + .filter(|&(_, module)| module.kind == ModuleKind::Regular) + .map(|(i, _module)| { + //let cost = unsafe { llvm::LLVMRustModuleCost(module.module_llvm.llmod()) }; + // TODO(antoyo): compute the cost of a module if GCC allows this. + (0, i) + }) + .max(); + + // If we found a costliest module, we're good to go. Otherwise all our + // inputs were serialized which could happen in the case, for example, that + // all our inputs were incrementally reread from the cache and we're just + // re-executing the LTO passes. If that's the case deserialize the first + // module and create a linker with it. + let mut module: ModuleCodegen<GccContext> = match costliest_module { + Some((_cost, i)) => in_memory.remove(i), + None => { + unimplemented!("Incremental"); + /*assert!(!serialized_modules.is_empty(), "must have at least one serialized module"); + let (buffer, name) = serialized_modules.remove(0); + info!("no in-memory regular modules to choose from, parsing {:?}", name); + ModuleCodegen { + module_llvm: GccContext::parse(cgcx, &name, buffer.data(), dcx)?, + name: name.into_string().unwrap(), + kind: ModuleKind::Regular, + }*/ + } + }; + { + info!("using {:?} as a base module", module.name); + + // We cannot load and merge GCC contexts in memory like cg_llvm is doing. + // Instead, we combine the object files into a single object file. + for module in in_memory { + let path = tmp_path.path().to_path_buf().join(&module.name); + let path = path.to_str().expect("path"); + let context = &module.module_llvm.context; + let config = cgcx.config(module.kind); + // NOTE: we need to set the optimization level here in order for LTO to do its job. + context.set_optimization_level(to_gcc_opt_level(config.opt_level)); + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + context.compile_to_file(OutputKind::ObjectFile, path); + let buffer = ModuleBuffer::new(PathBuf::from(path)); + let llmod_id = CString::new(&module.name[..]).unwrap(); + serialized_modules.push((SerializedModule::Local(buffer), llmod_id)); + } + // Sort the modules to ensure we produce deterministic results. + serialized_modules.sort_by(|module1, module2| module1.1.cmp(&module2.1)); + + // We add the object files and save in should_combine_object_files that we should combine + // them into a single object file when compiling later. + for (bc_decoded, name) in serialized_modules { + let _timer = cgcx + .prof + .generic_activity_with_arg_recorder("GCC_fat_lto_link_module", |recorder| { + recorder.record_arg(format!("{:?}", name)) + }); + info!("linking {:?}", name); + match bc_decoded { + SerializedModule::Local(ref module_buffer) => { + module.module_llvm.should_combine_object_files = true; + module + .module_llvm + .context + .add_driver_option(module_buffer.0.to_str().expect("path")); + } + SerializedModule::FromRlib(_) => unimplemented!("from rlib"), + SerializedModule::FromUncompressedFile(_) => { + unimplemented!("from uncompressed file") + } + } + } + save_temp_bitcode(cgcx, &module, "lto.input"); + + // Internalize everything below threshold to help strip out more modules and such. + /*unsafe { + let ptr = symbols_below_threshold.as_ptr(); + llvm::LLVMRustRunRestrictionPass( + llmod, + ptr as *const *const libc::c_char, + symbols_below_threshold.len() as libc::size_t, + );*/ + + save_temp_bitcode(cgcx, &module, "lto.after-restriction"); + //} + } + + // NOTE: save the temporary directory used by LTO so that it gets deleted after linking instead + // of now. + module.module_llvm.temp_dir = Some(tmp_path); + + Ok(module) +} + +pub struct ModuleBuffer(PathBuf); + +impl ModuleBuffer { + pub fn new(path: PathBuf) -> ModuleBuffer { + ModuleBuffer(path) + } +} + +impl ModuleBufferMethods for ModuleBuffer { + fn data(&self) -> &[u8] { + &[] + } +} + +/// Performs thin LTO by performing necessary global analysis and returning two +/// lists, one of the modules that need optimization and another for modules that +/// can simply be copied over from the incr. comp. cache. +pub(crate) fn run_thin( + cgcx: &CodegenContext<GccCodegenBackend>, + each_linked_rlib_for_lto: &[PathBuf], + modules: Vec<(String, ThinBuffer)>, + cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, +) -> Result<(Vec<ThinModule<GccCodegenBackend>>, Vec<WorkProduct>), FatalError> { + let dcx = cgcx.create_dcx(); + let dcx = dcx.handle(); + let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx)?; + if cgcx.opts.cg.linker_plugin_lto.enabled() { + unreachable!( + "We should never reach this case if the LTO step \ + is deferred to the linker" + ); + } + thin_lto( + cgcx, + dcx, + modules, + lto_data.upstream_modules, + lto_data.tmp_path, + cached_modules, + //<o_data.symbols_below_threshold, + ) +} + +pub(crate) fn prepare_thin( + module: ModuleCodegen<GccContext>, + _emit_summary: bool, +) -> (String, ThinBuffer) { + let name = module.name; + //let buffer = ThinBuffer::new(module.module_llvm.context, true, emit_summary); + let buffer = ThinBuffer::new(&module.module_llvm.context); + (name, buffer) +} + +/// Prepare "thin" LTO to get run on these modules. +/// +/// The general structure of ThinLTO is quite different from the structure of +/// "fat" LTO above. With "fat" LTO all LLVM modules in question are merged into +/// one giant LLVM module, and then we run more optimization passes over this +/// big module after internalizing most symbols. Thin LTO, on the other hand, +/// avoid this large bottleneck through more targeted optimization. +/// +/// At a high level Thin LTO looks like: +/// +/// 1. Prepare a "summary" of each LLVM module in question which describes +/// the values inside, cost of the values, etc. +/// 2. Merge the summaries of all modules in question into one "index" +/// 3. Perform some global analysis on this index +/// 4. For each module, use the index and analysis calculated previously to +/// perform local transformations on the module, for example inlining +/// small functions from other modules. +/// 5. Run thin-specific optimization passes over each module, and then code +/// generate everything at the end. +/// +/// The summary for each module is intended to be quite cheap, and the global +/// index is relatively quite cheap to create as well. As a result, the goal of +/// ThinLTO is to reduce the bottleneck on LTO and enable LTO to be used in more +/// situations. For example one cheap optimization is that we can parallelize +/// all codegen modules, easily making use of all the cores on a machine. +/// +/// With all that in mind, the function here is designed at specifically just +/// calculating the *index* for ThinLTO. This index will then be shared amongst +/// all of the `LtoModuleCodegen` units returned below and destroyed once +/// they all go out of scope. +fn thin_lto( + cgcx: &CodegenContext<GccCodegenBackend>, + _dcx: DiagCtxtHandle<'_>, + modules: Vec<(String, ThinBuffer)>, + serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, + tmp_path: TempDir, + cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, + //_symbols_below_threshold: &[String], +) -> Result<(Vec<ThinModule<GccCodegenBackend>>, Vec<WorkProduct>), FatalError> { + let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_global_analysis"); + info!("going for that thin, thin LTO"); + + /*let green_modules: FxHashMap<_, _> = + cached_modules.iter().map(|(_, wp)| (wp.cgu_name.clone(), wp.clone())).collect();*/ + + let full_scope_len = modules.len() + serialized_modules.len() + cached_modules.len(); + let mut thin_buffers = Vec::with_capacity(modules.len()); + let mut module_names = Vec::with_capacity(full_scope_len); + //let mut thin_modules = Vec::with_capacity(full_scope_len); + + for (i, (name, buffer)) in modules.into_iter().enumerate() { + info!("local module: {} - {}", i, name); + let cname = CString::new(name.as_bytes()).unwrap(); + /*thin_modules.push(llvm::ThinLTOModule { + identifier: cname.as_ptr(), + data: buffer.data().as_ptr(), + len: buffer.data().len(), + });*/ + thin_buffers.push(buffer); + module_names.push(cname); + } + + // FIXME: All upstream crates are deserialized internally in the + // function below to extract their summary and modules. Note that + // unlike the loop above we *must* decode and/or read something + // here as these are all just serialized files on disk. An + // improvement, however, to make here would be to store the + // module summary separately from the actual module itself. Right + // now this is store in one large bitcode file, and the entire + // file is deflate-compressed. We could try to bypass some of the + // decompression by storing the index uncompressed and only + // lazily decompressing the bytecode if necessary. + // + // Note that truly taking advantage of this optimization will + // likely be further down the road. We'd have to implement + // incremental ThinLTO first where we could actually avoid + // looking at upstream modules entirely sometimes (the contents, + // we must always unconditionally look at the index). + let mut serialized = Vec::with_capacity(serialized_modules.len() + cached_modules.len()); + + let cached_modules = + cached_modules.into_iter().map(|(sm, wp)| (sm, CString::new(wp.cgu_name).unwrap())); + + for (module, name) in serialized_modules.into_iter().chain(cached_modules) { + info!("upstream or cached module {:?}", name); + /*thin_modules.push(llvm::ThinLTOModule { + identifier: name.as_ptr(), + data: module.data().as_ptr(), + len: module.data().len(), + });*/ + + match module { + SerializedModule::Local(_) => { + //let path = module_buffer.0.to_str().expect("path"); + //let my_path = PathBuf::from(path); + //let exists = my_path.exists(); + /*module.module_llvm.should_combine_object_files = true; + module + .module_llvm + .context + .add_driver_option(module_buffer.0.to_str().expect("path"));*/ + } + SerializedModule::FromRlib(_) => unimplemented!("from rlib"), + SerializedModule::FromUncompressedFile(_) => { + unimplemented!("from uncompressed file") + } + } + + serialized.push(module); + module_names.push(name); + } + + // Sanity check + //assert_eq!(thin_modules.len(), module_names.len()); + + // Delegate to the C++ bindings to create some data here. Once this is a + // tried-and-true interface we may wish to try to upstream some of this + // to LLVM itself, right now we reimplement a lot of what they do + // upstream... + /*let data = llvm::LLVMRustCreateThinLTOData( + thin_modules.as_ptr(), + thin_modules.len() as u32, + symbols_below_threshold.as_ptr(), + symbols_below_threshold.len() as u32, + ) + .ok_or_else(|| write::llvm_err(dcx, LlvmError::PrepareThinLtoContext))?; + */ + + let data = ThinData; //(Arc::new(tmp_path))/*(data)*/; + + info!("thin LTO data created"); + + /*let (key_map_path, prev_key_map, curr_key_map) = + if let Some(ref incr_comp_session_dir) = cgcx.incr_comp_session_dir { + let path = incr_comp_session_dir.join(THIN_LTO_KEYS_INCR_COMP_FILE_NAME); + // If the previous file was deleted, or we get an IO error + // reading the file, then we'll just use `None` as the + // prev_key_map, which will force the code to be recompiled. + let prev = + if path.exists() { ThinLTOKeysMap::load_from_file(&path).ok() } else { None }; + let curr = ThinLTOKeysMap::from_thin_lto_modules(&data, &thin_modules, &module_names); + (Some(path), prev, curr) + } + else { + // If we don't compile incrementally, we don't need to load the + // import data from LLVM. + assert!(green_modules.is_empty()); + let curr = ThinLTOKeysMap::default(); + (None, None, curr) + }; + info!("thin LTO cache key map loaded"); + info!("prev_key_map: {:#?}", prev_key_map); + info!("curr_key_map: {:#?}", curr_key_map);*/ + + // Throw our data in an `Arc` as we'll be sharing it across threads. We + // also put all memory referenced by the C++ data (buffers, ids, etc) + // into the arc as well. After this we'll create a thin module + // codegen per module in this data. + let shared = + Arc::new(ThinShared { data, thin_buffers, serialized_modules: serialized, module_names }); + + let copy_jobs = vec![]; + let mut opt_jobs = vec![]; + + info!("checking which modules can be-reused and which have to be re-optimized."); + for (module_index, module_name) in shared.module_names.iter().enumerate() { + let module_name = module_name_to_str(module_name); + /*if let (Some(prev_key_map), true) = + (prev_key_map.as_ref(), green_modules.contains_key(module_name)) + { + assert!(cgcx.incr_comp_session_dir.is_some()); + + // If a module exists in both the current and the previous session, + // and has the same LTO cache key in both sessions, then we can re-use it + if prev_key_map.keys.get(module_name) == curr_key_map.keys.get(module_name) { + let work_product = green_modules[module_name].clone(); + copy_jobs.push(work_product); + info!(" - {}: re-used", module_name); + assert!(cgcx.incr_comp_session_dir.is_some()); + continue; + } + }*/ + + info!(" - {}: re-compiled", module_name); + opt_jobs.push(ThinModule { shared: shared.clone(), idx: module_index }); + } + + // Save the current ThinLTO import information for the next compilation + // session, overwriting the previous serialized data (if any). + /*if let Some(path) = key_map_path { + if let Err(err) = curr_key_map.save_to_file(&path) { + return Err(write::llvm_err(dcx, LlvmError::WriteThinLtoKey { err })); + } + }*/ + + // NOTE: save the temporary directory used by LTO so that it gets deleted after linking instead + // of now. + //module.module_llvm.temp_dir = Some(tmp_path); + // TODO: save the directory so that it gets deleted later. + std::mem::forget(tmp_path); + + Ok((opt_jobs, copy_jobs)) +} + +pub fn optimize_thin_module( + thin_module: ThinModule<GccCodegenBackend>, + _cgcx: &CodegenContext<GccCodegenBackend>, +) -> Result<ModuleCodegen<GccContext>, FatalError> { + //let dcx = cgcx.create_dcx(); + + //let module_name = &thin_module.shared.module_names[thin_module.idx]; + /*let tm_factory_config = TargetMachineFactoryConfig::new(cgcx, module_name.to_str().unwrap()); + let tm = (cgcx.tm_factory)(tm_factory_config).map_err(|e| write::llvm_err(&dcx, e))?;*/ + + // Right now the implementation we've got only works over serialized + // modules, so we create a fresh new LLVM context and parse the module + // into that context. One day, however, we may do this for upstream + // crates but for locally codegened modules we may be able to reuse + // that LLVM Context and Module. + //let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names); + //let llmod_raw = parse_module(llcx, module_name, thin_module.data(), &dcx)? as *const _; + let mut should_combine_object_files = false; + let context = match thin_module.shared.thin_buffers.get(thin_module.idx) { + Some(thin_buffer) => Arc::clone(&thin_buffer.context), + None => { + let context = Context::default(); + let len = thin_module.shared.thin_buffers.len(); + let module = &thin_module.shared.serialized_modules[thin_module.idx - len]; + match *module { + SerializedModule::Local(ref module_buffer) => { + let path = module_buffer.0.to_str().expect("path"); + context.add_driver_option(path); + should_combine_object_files = true; + /*module.module_llvm.should_combine_object_files = true; + module + .module_llvm + .context + .add_driver_option(module_buffer.0.to_str().expect("path"));*/ + } + SerializedModule::FromRlib(_) => unimplemented!("from rlib"), + SerializedModule::FromUncompressedFile(_) => { + unimplemented!("from uncompressed file") + } + } + Arc::new(SyncContext::new(context)) + } + }; + let module = ModuleCodegen::new_regular( + thin_module.name().to_string(), + GccContext { + context, + should_combine_object_files, + // TODO(antoyo): use the correct relocation model here. + relocation_model: RelocModel::Pic, + temp_dir: None, + }, + ); + /*{ + let target = &*module.module_llvm.tm; + let llmod = module.module_llvm.llmod(); + save_temp_bitcode(cgcx, &module, "thin-lto-input"); + + // Up next comes the per-module local analyses that we do for Thin LTO. + // Each of these functions is basically copied from the LLVM + // implementation and then tailored to suit this implementation. Ideally + // each of these would be supported by upstream LLVM but that's perhaps + // a patch for another day! + // + // You can find some more comments about these functions in the LLVM + // bindings we've got (currently `PassWrapper.cpp`) + { + let _timer = + cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name()); + unsafe { llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) }; + save_temp_bitcode(cgcx, &module, "thin-lto-after-rename"); + } + + { + let _timer = cgcx + .prof + .generic_activity_with_arg("LLVM_thin_lto_resolve_weak", thin_module.name()); + if !llvm::LLVMRustPrepareThinLTOResolveWeak(thin_module.shared.data.0, llmod) { + return Err(write::llvm_err(&dcx, LlvmError::PrepareThinLtoModule)); + } + save_temp_bitcode(cgcx, &module, "thin-lto-after-resolve"); + } + + { + let _timer = cgcx + .prof + .generic_activity_with_arg("LLVM_thin_lto_internalize", thin_module.name()); + if !llvm::LLVMRustPrepareThinLTOInternalize(thin_module.shared.data.0, llmod) { + return Err(write::llvm_err(&dcx, LlvmError::PrepareThinLtoModule)); + } + save_temp_bitcode(cgcx, &module, "thin-lto-after-internalize"); + } + + { + let _timer = + cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_import", thin_module.name()); + if !llvm::LLVMRustPrepareThinLTOImport(thin_module.shared.data.0, llmod, target) { + return Err(write::llvm_err(&dcx, LlvmError::PrepareThinLtoModule)); + } + save_temp_bitcode(cgcx, &module, "thin-lto-after-import"); + } + + // Alright now that we've done everything related to the ThinLTO + // analysis it's time to run some optimizations! Here we use the same + // `run_pass_manager` as the "fat" LTO above except that we tell it to + // populate a thin-specific pass manager, which presumably LLVM treats a + // little differently. + { + info!("running thin lto passes over {}", module.name); + run_pass_manager(cgcx, &dcx, &mut module, true)?; + save_temp_bitcode(cgcx, &module, "thin-lto-after-pm"); + } + }*/ + Ok(module) +} + +pub struct ThinBuffer { + context: Arc<SyncContext>, +} + +impl ThinBuffer { + pub(crate) fn new(context: &Arc<SyncContext>) -> Self { + Self { context: Arc::clone(context) } + } +} + +impl ThinBufferMethods for ThinBuffer { + fn data(&self) -> &[u8] { + &[] + } + + fn thin_link_data(&self) -> &[u8] { + unimplemented!(); + } +} + +pub struct ThinData; //(Arc<TempDir>); + +fn module_name_to_str(c_str: &CStr) -> &str { + c_str.to_str().unwrap_or_else(|e| { + bug!("Encountered non-utf8 GCC module name `{}`: {}", c_str.to_string_lossy(), e) + }) +} diff --git a/compiler/rustc_codegen_gcc/src/back/mod.rs b/compiler/rustc_codegen_gcc/src/back/mod.rs new file mode 100644 index 00000000000..10187eab0d7 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/back/mod.rs @@ -0,0 +1,2 @@ +pub mod lto; +pub mod write; diff --git a/compiler/rustc_codegen_gcc/src/back/write.rs b/compiler/rustc_codegen_gcc/src/back/write.rs new file mode 100644 index 00000000000..c1231142c65 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/back/write.rs @@ -0,0 +1,277 @@ +use std::{env, fs}; + +use gccjit::{Context, OutputKind}; +use rustc_codegen_ssa::back::link::ensure_removed; +use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig}; +use rustc_codegen_ssa::{CompiledModule, ModuleCodegen}; +use rustc_fs_util::link_or_copy; +use rustc_session::config::OutputType; +use rustc_span::fatal_error::FatalError; +use rustc_target::spec::SplitDebuginfo; + +use crate::base::add_pic_option; +use crate::errors::CopyBitcode; +use crate::{GccCodegenBackend, GccContext}; + +pub(crate) fn codegen( + cgcx: &CodegenContext<GccCodegenBackend>, + module: ModuleCodegen<GccContext>, + config: &ModuleConfig, +) -> Result<CompiledModule, FatalError> { + let dcx = cgcx.create_dcx(); + let dcx = dcx.handle(); + + let _timer = cgcx.prof.generic_activity_with_arg("GCC_module_codegen", &*module.name); + { + let context = &module.module_llvm.context; + + let should_combine_object_files = module.module_llvm.should_combine_object_files; + + // NOTE: Only generate object files with GIMPLE when this environment variable is set for + // now because this requires a particular setup (same gcc/lto1/lto-wrapper commit as libgccjit). + // TODO(antoyo): remove this environment variable. + let fat_lto = env::var("EMBED_LTO_BITCODE").as_deref() == Ok("1"); + + let bc_out = cgcx.output_filenames.temp_path_for_cgu( + OutputType::Bitcode, + &module.name, + cgcx.invocation_temp.as_deref(), + ); + let obj_out = cgcx.output_filenames.temp_path_for_cgu( + OutputType::Object, + &module.name, + cgcx.invocation_temp.as_deref(), + ); + + if config.bitcode_needed() { + if fat_lto { + let _timer = cgcx + .prof + .generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name); + + // TODO(antoyo) + /*if let Some(bitcode_filename) = bc_out.file_name() { + cgcx.prof.artifact_size( + "llvm_bitcode", + bitcode_filename.to_string_lossy(), + data.len() as u64, + ); + }*/ + + if config.emit_bc || config.emit_obj == EmitObj::Bitcode { + let _timer = cgcx.prof.generic_activity_with_arg( + "GCC_module_codegen_emit_bitcode", + &*module.name, + ); + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. + context.add_command_line_option("-ffat-lto-objects"); + context.compile_to_file( + OutputKind::ObjectFile, + bc_out.to_str().expect("path to str"), + ); + } + + if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) { + let _timer = cgcx.prof.generic_activity_with_arg( + "GCC_module_codegen_embed_bitcode", + &*module.name, + ); + // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? + //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); + + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + context.add_command_line_option("-ffat-lto-objects"); + // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument). + context.compile_to_file( + OutputKind::ObjectFile, + bc_out.to_str().expect("path to str"), + ); + } + } else { + if config.emit_bc || config.emit_obj == EmitObj::Bitcode { + let _timer = cgcx.prof.generic_activity_with_arg( + "GCC_module_codegen_emit_bitcode", + &*module.name, + ); + context.compile_to_file( + OutputKind::ObjectFile, + bc_out.to_str().expect("path to str"), + ); + } + + if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) { + // TODO(antoyo): we might want to emit to emit an error here, saying to set the + // environment variable EMBED_LTO_BITCODE. + let _timer = cgcx.prof.generic_activity_with_arg( + "GCC_module_codegen_embed_bitcode", + &*module.name, + ); + // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? + //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); + + // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument). + context.compile_to_file( + OutputKind::ObjectFile, + bc_out.to_str().expect("path to str"), + ); + } + } + } + + if config.emit_ir { + let out = cgcx.output_filenames.temp_path_for_cgu( + OutputType::LlvmAssembly, + &module.name, + cgcx.invocation_temp.as_deref(), + ); + std::fs::write(out, "").expect("write file"); + } + + if config.emit_asm { + let _timer = + cgcx.prof.generic_activity_with_arg("GCC_module_codegen_emit_asm", &*module.name); + let path = cgcx.output_filenames.temp_path_for_cgu( + OutputType::Assembly, + &module.name, + cgcx.invocation_temp.as_deref(), + ); + context.compile_to_file(OutputKind::Assembler, path.to_str().expect("path to str")); + } + + match config.emit_obj { + EmitObj::ObjectCode(_) => { + let _timer = cgcx + .prof + .generic_activity_with_arg("GCC_module_codegen_emit_obj", &*module.name); + if env::var("CG_GCCJIT_DUMP_MODULE_NAMES").as_deref() == Ok("1") { + println!("Module {}", module.name); + } + if env::var("CG_GCCJIT_DUMP_ALL_MODULES").as_deref() == Ok("1") + || env::var("CG_GCCJIT_DUMP_MODULE").as_deref() == Ok(&module.name) + { + println!("Dumping reproducer {}", module.name); + let _ = fs::create_dir("/tmp/reproducers"); + // FIXME(antoyo): segfault in dump_reproducer_to_file() might be caused by + // transmuting an rvalue to an lvalue. + // Segfault is actually in gcc::jit::reproducer::get_identifier_as_lvalue + context.dump_reproducer_to_file(format!("/tmp/reproducers/{}.c", module.name)); + println!("Dumped reproducer {}", module.name); + } + if env::var("CG_GCCJIT_DUMP_TO_FILE").as_deref() == Ok("1") { + let _ = fs::create_dir("/tmp/gccjit_dumps"); + let path = &format!("/tmp/gccjit_dumps/{}.c", module.name); + context.set_debug_info(true); + context.dump_to_file(path, true); + } + if should_combine_object_files { + if fat_lto { + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + + // NOTE: without -fuse-linker-plugin, we get the following error: + // lto1: internal compiler error: decompressed stream: Destination buffer is too small + // TODO(antoyo): since we do not do LTO when the linker is invoked anymore, perhaps + // the following flag is not necessary anymore. + context.add_driver_option("-fuse-linker-plugin"); + } + + context.add_driver_option("-Wl,-r"); + // NOTE: we need -nostdlib, otherwise, we get the following error: + // /usr/bin/ld: cannot find -lgcc_s: No such file or directory + context.add_driver_option("-nostdlib"); + + let path = obj_out.to_str().expect("path to str"); + + if fat_lto { + let lto_path = format!("{}.lto", path); + // cSpell:disable + // FIXME(antoyo): The LTO frontend generates the following warning: + // ../build_sysroot/sysroot_src/library/core/src/num/dec2flt/lemire.rs:150:15: warning: type of ‘_ZN4core3num7dec2flt5table17POWER_OF_FIVE_12817ha449a68fb31379e4E’ does not match original declaration [-Wlto-type-mismatch] + // 150 | let (lo5, hi5) = POWER_OF_FIVE_128[index]; + // | ^ + // lto1: note: ‘_ZN4core3num7dec2flt5table17POWER_OF_FIVE_12817ha449a68fb31379e4E’ was previously declared here + // + // This option is to mute it to make the UI tests pass with LTO enabled. + // cSpell:enable + context.add_driver_option("-Wno-lto-type-mismatch"); + // NOTE: this doesn't actually generate an executable. With the above + // flags, it combines the .o files together in another .o. + context.compile_to_file(OutputKind::Executable, <o_path); + + let context = Context::default(); + if cgcx.target_arch == "x86" || cgcx.target_arch == "x86_64" { + // NOTE: it seems we need to use add_driver_option instead of + // add_command_line_option here because we use the LTO frontend via gcc. + context.add_driver_option("-masm=intel"); + } + + // NOTE: these two options are needed to invoke LTO to produce an object file. + // We need to initiate a second compilation because the arguments "-x lto" + // needs to be at the very beginning. + context.add_driver_option("-x"); + context.add_driver_option("lto"); + add_pic_option(&context, module.module_llvm.relocation_model); + context.add_driver_option(lto_path); + + context.compile_to_file(OutputKind::ObjectFile, path); + } else { + // NOTE: this doesn't actually generate an executable. With the above + // flags, it combines the .o files together in another .o. + context.compile_to_file(OutputKind::Executable, path); + } + } else { + context.compile_to_file( + OutputKind::ObjectFile, + obj_out.to_str().expect("path to str"), + ); + } + } + + EmitObj::Bitcode => { + debug!("copying bitcode {:?} to obj {:?}", bc_out, obj_out); + if let Err(err) = link_or_copy(&bc_out, &obj_out) { + dcx.emit_err(CopyBitcode { err }); + } + + if !config.emit_bc { + debug!("removing_bitcode {:?}", bc_out); + ensure_removed(dcx, &bc_out); + } + } + + EmitObj::None => {} + } + } + + Ok(module.into_compiled_module( + config.emit_obj != EmitObj::None, + cgcx.target_can_use_split_dwarf && cgcx.split_debuginfo == SplitDebuginfo::Unpacked, + config.emit_bc, + config.emit_asm, + config.emit_ir, + &cgcx.output_filenames, + cgcx.invocation_temp.as_deref(), + )) +} + +pub(crate) fn save_temp_bitcode( + cgcx: &CodegenContext<GccCodegenBackend>, + _module: &ModuleCodegen<GccContext>, + _name: &str, +) { + if !cgcx.save_temps { + return; + } + unimplemented!(); + /*unsafe { + let ext = format!("{}.bc", name); + let cgu = Some(&module.name[..]); + let path = cgcx.output_filenames.temp_path_ext(&ext, cgu); + let cstr = path_to_c_string(&path); + let llmod = module.module_llvm.llmod(); + llvm::LLVMWriteBitcodeToFile(llmod, cstr.as_ptr()); + }*/ +} diff --git a/compiler/rustc_codegen_gcc/src/base.rs b/compiler/rustc_codegen_gcc/src/base.rs new file mode 100644 index 00000000000..c105916bbb2 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/base.rs @@ -0,0 +1,278 @@ +use std::collections::HashSet; +use std::env; +use std::sync::Arc; +use std::time::Instant; + +use gccjit::{CType, Context, FunctionType, GlobalKind}; +use rustc_codegen_ssa::ModuleCodegen; +use rustc_codegen_ssa::base::maybe_create_entry_wrapper; +use rustc_codegen_ssa::mono_item::MonoItemExt; +use rustc_codegen_ssa::traits::DebugInfoCodegenMethods; +use rustc_middle::dep_graph; +use rustc_middle::mir::mono::Linkage; +#[cfg(feature = "master")] +use rustc_middle::mir::mono::Visibility; +use rustc_middle::ty::TyCtxt; +use rustc_session::config::DebugInfo; +use rustc_span::Symbol; +#[cfg(feature = "master")] +use rustc_target::spec::SymbolVisibility; +use rustc_target::spec::{PanicStrategy, RelocModel}; + +use crate::builder::Builder; +use crate::context::CodegenCx; +use crate::{GccContext, LockedTargetInfo, SyncContext, gcc_util, new_context}; + +#[cfg(feature = "master")] +pub fn visibility_to_gcc(visibility: Visibility) -> gccjit::Visibility { + match visibility { + Visibility::Default => gccjit::Visibility::Default, + Visibility::Hidden => gccjit::Visibility::Hidden, + Visibility::Protected => gccjit::Visibility::Protected, + } +} + +#[cfg(feature = "master")] +pub fn symbol_visibility_to_gcc(visibility: SymbolVisibility) -> gccjit::Visibility { + match visibility { + SymbolVisibility::Hidden => gccjit::Visibility::Hidden, + SymbolVisibility::Protected => gccjit::Visibility::Protected, + SymbolVisibility::Interposable => gccjit::Visibility::Default, + } +} + +pub fn global_linkage_to_gcc(linkage: Linkage) -> GlobalKind { + match linkage { + Linkage::External => GlobalKind::Imported, + Linkage::AvailableExternally => GlobalKind::Imported, + Linkage::LinkOnceAny => unimplemented!(), + Linkage::LinkOnceODR => unimplemented!(), + Linkage::WeakAny => unimplemented!(), + Linkage::WeakODR => unimplemented!(), + Linkage::Internal => GlobalKind::Internal, + Linkage::ExternalWeak => GlobalKind::Imported, // TODO(antoyo): should be weak linkage. + Linkage::Common => unimplemented!(), + } +} + +pub fn linkage_to_gcc(linkage: Linkage) -> FunctionType { + match linkage { + Linkage::External => FunctionType::Exported, + // TODO(antoyo): set the attribute externally_visible. + Linkage::AvailableExternally => FunctionType::Extern, + Linkage::LinkOnceAny => unimplemented!(), + Linkage::LinkOnceODR => unimplemented!(), + Linkage::WeakAny => FunctionType::Exported, // FIXME(antoyo): should be similar to linkonce. + Linkage::WeakODR => unimplemented!(), + Linkage::Internal => FunctionType::Internal, + Linkage::ExternalWeak => unimplemented!(), + Linkage::Common => unimplemented!(), + } +} + +pub fn compile_codegen_unit( + tcx: TyCtxt<'_>, + cgu_name: Symbol, + target_info: LockedTargetInfo, +) -> (ModuleCodegen<GccContext>, u64) { + let prof_timer = tcx.prof.generic_activity("codegen_module"); + let start_time = Instant::now(); + + let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx); + let (module, _) = tcx.dep_graph.with_task( + dep_node, + tcx, + (cgu_name, target_info), + module_codegen, + Some(dep_graph::hash_result), + ); + let time_to_codegen = start_time.elapsed(); + drop(prof_timer); + + // We assume that the cost to run GCC on a CGU is proportional to + // the time we needed for codegenning it. + let cost = time_to_codegen.as_secs() * 1_000_000_000 + time_to_codegen.subsec_nanos() as u64; + + fn module_codegen( + tcx: TyCtxt<'_>, + (cgu_name, target_info): (Symbol, LockedTargetInfo), + ) -> ModuleCodegen<GccContext> { + let cgu = tcx.codegen_unit(cgu_name); + // Instantiate monomorphizations without filling out definitions yet... + let context = new_context(tcx); + + if tcx.sess.panic_strategy() == PanicStrategy::Unwind { + context.add_command_line_option("-fexceptions"); + context.add_driver_option("-fexceptions"); + } + + let disabled_features: HashSet<_> = tcx + .sess + .opts + .cg + .target_feature + .split(',') + .filter(|feature| feature.starts_with('-')) + .map(|string| &string[1..]) + .collect(); + + if !disabled_features.contains("avx") && tcx.sess.target.arch == "x86_64" { + // NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for + // SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead. + // FIXME(antoyo): use the proper builtins for llvm.x86.sse2.cmp.pd and similar. + context.add_command_line_option("-mavx"); + } + + for arg in &tcx.sess.opts.cg.llvm_args { + context.add_command_line_option(arg); + } + // NOTE: This is needed to compile the file src/intrinsic/archs.rs during a bootstrap of rustc. + context.add_command_line_option("-fno-var-tracking-assignments"); + // NOTE: an optimization (https://github.com/rust-lang/rustc_codegen_gcc/issues/53). + context.add_command_line_option("-fno-semantic-interposition"); + // NOTE: Rust relies on LLVM not doing TBAA (https://github.com/rust-lang/unsafe-code-guidelines/issues/292). + context.add_command_line_option("-fno-strict-aliasing"); + // NOTE: Rust relies on LLVM doing wrapping on overflow. + context.add_command_line_option("-fwrapv"); + + if let Some(model) = tcx.sess.code_model() { + use rustc_target::spec::CodeModel; + + context.add_command_line_option(match model { + CodeModel::Tiny => "-mcmodel=tiny", + CodeModel::Small => "-mcmodel=small", + CodeModel::Kernel => "-mcmodel=kernel", + CodeModel::Medium => "-mcmodel=medium", + CodeModel::Large => "-mcmodel=large", + }); + } + + add_pic_option(&context, tcx.sess.relocation_model()); + + let target_cpu = gcc_util::target_cpu(tcx.sess); + if target_cpu != "generic" { + context.add_command_line_option(format!("-march={}", target_cpu)); + } + + if tcx + .sess + .opts + .unstable_opts + .function_sections + .unwrap_or(tcx.sess.target.function_sections) + { + context.add_command_line_option("-ffunction-sections"); + context.add_command_line_option("-fdata-sections"); + } + + if env::var("CG_GCCJIT_DUMP_RTL").as_deref() == Ok("1") { + context.add_command_line_option("-fdump-rtl-vregs"); + } + if env::var("CG_GCCJIT_DUMP_RTL_ALL").as_deref() == Ok("1") { + context.add_command_line_option("-fdump-rtl-all"); + } + if env::var("CG_GCCJIT_DUMP_TREE_ALL").as_deref() == Ok("1") { + context.add_command_line_option("-fdump-tree-all-eh"); + } + if env::var("CG_GCCJIT_DUMP_IPA_ALL").as_deref() == Ok("1") { + context.add_command_line_option("-fdump-ipa-all-eh"); + } + if env::var("CG_GCCJIT_DUMP_CODE").as_deref() == Ok("1") { + context.set_dump_code_on_compile(true); + } + if env::var("CG_GCCJIT_DUMP_GIMPLE").as_deref() == Ok("1") { + context.set_dump_initial_gimple(true); + } + if env::var("CG_GCCJIT_DUMP_EVERYTHING").as_deref() == Ok("1") { + context.set_dump_everything(true); + } + if env::var("CG_GCCJIT_KEEP_INTERMEDIATES").as_deref() == Ok("1") { + context.set_keep_intermediates(true); + } + if env::var("CG_GCCJIT_VERBOSE").as_deref() == Ok("1") { + context.add_driver_option("-v"); + } + + // NOTE: The codegen generates unreachable blocks. + context.set_allow_unreachable_blocks(true); + + { + // TODO: to make it less error-prone (calling get_target_info() will add the flag + // -fsyntax-only), forbid the compilation when get_target_info() is called on a + // context. + let f16_type_supported = target_info.supports_target_dependent_type(CType::Float16); + let f32_type_supported = target_info.supports_target_dependent_type(CType::Float32); + let f64_type_supported = target_info.supports_target_dependent_type(CType::Float64); + let f128_type_supported = target_info.supports_target_dependent_type(CType::Float128); + let u128_type_supported = target_info.supports_target_dependent_type(CType::UInt128t); + // TODO: improve this to avoid passing that many arguments. + let mut cx = CodegenCx::new( + &context, + cgu, + tcx, + u128_type_supported, + f16_type_supported, + f32_type_supported, + f64_type_supported, + f128_type_supported, + ); + + let mono_items = cgu.items_in_deterministic_order(tcx); + for &(mono_item, data) in &mono_items { + mono_item.predefine::<Builder<'_, '_, '_>>( + &mut cx, + cgu_name.as_str(), + data.linkage, + data.visibility, + ); + } + + // ... and now that we have everything pre-defined, fill out those definitions. + for &(mono_item, item_data) in &mono_items { + mono_item.define::<Builder<'_, '_, '_>>(&mut cx, cgu_name.as_str(), item_data); + } + + // If this codegen unit contains the main function, also create the + // wrapper here + maybe_create_entry_wrapper::<Builder<'_, '_, '_>>(&cx, cx.codegen_unit); + + // Finalize debuginfo + if cx.sess().opts.debuginfo != DebugInfo::None { + cx.debuginfo_finalize(); + } + } + + ModuleCodegen::new_regular( + cgu_name.to_string(), + GccContext { + context: Arc::new(SyncContext::new(context)), + relocation_model: tcx.sess.relocation_model(), + should_combine_object_files: false, + temp_dir: None, + }, + ) + } + + (module, cost) +} + +pub fn add_pic_option<'gcc>(context: &Context<'gcc>, relocation_model: RelocModel) { + match relocation_model { + rustc_target::spec::RelocModel::Static => { + context.add_command_line_option("-fno-pie"); + context.add_driver_option("-fno-pie"); + } + rustc_target::spec::RelocModel::Pic => { + context.add_command_line_option("-fPIC"); + // NOTE: we use both add_command_line_option and add_driver_option because the usage in + // this module (compile_codegen_unit) requires add_command_line_option while the usage + // in the back::write module (codegen) requires add_driver_option. + context.add_driver_option("-fPIC"); + } + rustc_target::spec::RelocModel::Pie => { + context.add_command_line_option("-fPIE"); + context.add_driver_option("-fPIE"); + } + model => eprintln!("Unsupported relocation model: {:?}", model), + } +} diff --git a/compiler/rustc_codegen_gcc/src/builder.rs b/compiler/rustc_codegen_gcc/src/builder.rs new file mode 100644 index 00000000000..34ade3d025f --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/builder.rs @@ -0,0 +1,2534 @@ +use std::borrow::Cow; +use std::cell::Cell; +use std::convert::TryFrom; +use std::ops::Deref; + +use gccjit::{ + BinaryOp, Block, ComparisonOp, Context, Function, LValue, Location, RValue, ToRValue, Type, + UnaryOp, +}; +use rustc_abi as abi; +use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout, WrappingRange}; +use rustc_apfloat::{Float, Round, Status, ieee}; +use rustc_codegen_ssa::MemFlags; +use rustc_codegen_ssa::common::{ + AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind, +}; +use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; +use rustc_codegen_ssa::mir::place::PlaceRef; +use rustc_codegen_ssa::traits::{ + BackendTypes, BaseTypeCodegenMethods, BuilderMethods, ConstCodegenMethods, + LayoutTypeCodegenMethods, OverflowOp, StaticBuilderMethods, +}; +use rustc_data_structures::fx::FxHashSet; +use rustc_middle::bug; +use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; +use rustc_middle::ty::layout::{ + FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTyCtxt, HasTypingEnv, LayoutError, LayoutOfHelpers, +}; +use rustc_middle::ty::{self, AtomicOrdering, Instance, Ty, TyCtxt}; +use rustc_span::Span; +use rustc_span::def_id::DefId; +use rustc_target::callconv::FnAbi; +use rustc_target::spec::{HasTargetSpec, HasX86AbiOpt, Target, X86Abi}; + +use crate::common::{SignType, TypeReflection, type_is_pointer}; +use crate::context::CodegenCx; +use crate::errors; +use crate::intrinsic::llvm; +use crate::type_of::LayoutGccExt; + +// TODO(antoyo) +type Funclet = (); + +enum ExtremumOperation { + Max, + Min, +} + +pub struct Builder<'a, 'gcc, 'tcx> { + pub cx: &'a CodegenCx<'gcc, 'tcx>, + pub block: Block<'gcc>, + pub location: Option<Location<'gcc>>, + value_counter: Cell<u64>, +} + +impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { + fn with_cx(cx: &'a CodegenCx<'gcc, 'tcx>, block: Block<'gcc>) -> Self { + Builder { cx, block, location: None, value_counter: Cell::new(0) } + } + + fn next_value_counter(&self) -> u64 { + self.value_counter.set(self.value_counter.get() + 1); + self.value_counter.get() + } + + fn atomic_extremum( + &mut self, + operation: ExtremumOperation, + dst: RValue<'gcc>, + src: RValue<'gcc>, + order: AtomicOrdering, + ) -> RValue<'gcc> { + let size = get_maybe_pointer_size(src); + + let func = self.current_func(); + + let load_ordering = match order { + // TODO(antoyo): does this make sense? + AtomicOrdering::AcqRel | AtomicOrdering::Release => AtomicOrdering::Acquire, + _ => order, + }; + let previous_value = + self.atomic_load(dst.get_type(), dst, load_ordering, Size::from_bytes(size)); + let previous_var = + func.new_local(self.location, previous_value.get_type(), "previous_value"); + let return_value = func.new_local(self.location, previous_value.get_type(), "return_value"); + self.llbb().add_assignment(self.location, previous_var, previous_value); + self.llbb().add_assignment(self.location, return_value, previous_var.to_rvalue()); + + let while_block = func.new_block("while"); + let after_block = func.new_block("after_while"); + self.llbb().end_with_jump(self.location, while_block); + + // NOTE: since jumps were added and compare_exchange doesn't expect this, the current block in the + // state need to be updated. + self.switch_to_block(while_block); + + let comparison_operator = match operation { + ExtremumOperation::Max => ComparisonOp::LessThan, + ExtremumOperation::Min => ComparisonOp::GreaterThan, + }; + + let cond1 = self.context.new_comparison( + self.location, + comparison_operator, + previous_var.to_rvalue(), + self.context.new_cast(self.location, src, previous_value.get_type()), + ); + let compare_exchange = + self.compare_exchange(dst, previous_var, src, order, load_ordering, false); + let cond2 = self.cx.context.new_unary_op( + self.location, + UnaryOp::LogicalNegate, + compare_exchange.get_type(), + compare_exchange, + ); + let cond = self.cx.context.new_binary_op( + self.location, + BinaryOp::LogicalAnd, + self.cx.bool_type, + cond1, + cond2, + ); + + while_block.end_with_conditional(self.location, cond, while_block, after_block); + + // NOTE: since jumps were added in a place rustc does not expect, the current block in the + // state need to be updated. + self.switch_to_block(after_block); + + return_value.to_rvalue() + } + + fn compare_exchange( + &self, + dst: RValue<'gcc>, + cmp: LValue<'gcc>, + src: RValue<'gcc>, + order: AtomicOrdering, + failure_order: AtomicOrdering, + weak: bool, + ) -> RValue<'gcc> { + let size = get_maybe_pointer_size(src); + let compare_exchange = + self.context.get_builtin_function(format!("__atomic_compare_exchange_{}", size)); + let order = self.context.new_rvalue_from_int(self.i32_type, order.to_gcc()); + let failure_order = self.context.new_rvalue_from_int(self.i32_type, failure_order.to_gcc()); + let weak = self.context.new_rvalue_from_int(self.bool_type, weak as i32); + + let void_ptr_type = self.context.new_type::<*mut ()>(); + let volatile_void_ptr_type = void_ptr_type.make_volatile(); + let dst = self.context.new_cast(self.location, dst, volatile_void_ptr_type); + let expected = + self.context.new_cast(self.location, cmp.get_address(self.location), void_ptr_type); + + // NOTE: not sure why, but we have the wrong type here. + let int_type = compare_exchange.get_param(2).to_rvalue().get_type(); + let src = self.context.new_bitcast(self.location, src, int_type); + self.context.new_call( + self.location, + compare_exchange, + &[dst, expected, src, weak, order, failure_order], + ) + } + + pub fn assign(&self, lvalue: LValue<'gcc>, value: RValue<'gcc>) { + self.llbb().add_assignment(self.location, lvalue, value); + } + + fn check_call<'b>( + &mut self, + _typ: &str, + func: Function<'gcc>, + args: &'b [RValue<'gcc>], + ) -> Cow<'b, [RValue<'gcc>]> { + let mut all_args_match = true; + let mut param_types = vec![]; + let param_count = func.get_param_count(); + for (index, arg) in args.iter().enumerate().take(param_count) { + let param = func.get_param(index as i32); + let param = param.to_rvalue().get_type(); + if param != arg.get_type() { + all_args_match = false; + } + param_types.push(param); + } + + if all_args_match { + return Cow::Borrowed(args); + } + + let casted_args: Vec<_> = param_types + .into_iter() + .zip(args.iter()) + .map(|(expected_ty, &actual_val)| { + let actual_ty = actual_val.get_type(); + if expected_ty != actual_ty { + self.bitcast(actual_val, expected_ty) + } else { + actual_val + } + }) + .collect(); + + debug_assert_eq!(casted_args.len(), args.len()); + + Cow::Owned(casted_args) + } + + fn check_ptr_call<'b>( + &mut self, + _typ: &str, + func_ptr: RValue<'gcc>, + args: &'b [RValue<'gcc>], + ) -> Cow<'b, [RValue<'gcc>]> { + let mut all_args_match = true; + let mut param_types = vec![]; + let gcc_func = func_ptr.get_type().dyncast_function_ptr_type().expect("function ptr"); + for (index, arg) in args.iter().enumerate().take(gcc_func.get_param_count()) { + let param = gcc_func.get_param_type(index); + if param != arg.get_type() { + all_args_match = false; + } + param_types.push(param); + } + + let mut on_stack_param_indices = FxHashSet::default(); + if let Some(indices) = self.on_stack_params.borrow().get(&gcc_func) { + on_stack_param_indices.clone_from(indices); + } + + if all_args_match { + return Cow::Borrowed(args); + } + + let func_name = format!("{:?}", func_ptr); + + let mut casted_args: Vec<_> = param_types + .into_iter() + .zip(args.iter()) + .enumerate() + .map(|(index, (expected_ty, &actual_val))| { + if llvm::ignore_arg_cast(&func_name, index, args.len()) { + return actual_val; + } + + let actual_ty = actual_val.get_type(); + if expected_ty != actual_ty { + if !actual_ty.is_vector() + && !expected_ty.is_vector() + && (actual_ty.is_integral() && expected_ty.is_integral()) + || (actual_ty.get_pointee().is_some() + && expected_ty.get_pointee().is_some()) + { + self.context.new_cast(self.location, actual_val, expected_ty) + } else if on_stack_param_indices.contains(&index) { + let ty = actual_val.get_type(); + // It's possible that the value behind the pointer is actually not exactly + // the expected type, so to go around that, we add a cast before + // dereferencing the value. + if let Some(pointee_val) = ty.get_pointee() + && pointee_val != expected_ty + { + let new_val = self.context.new_cast( + self.location, + actual_val, + expected_ty.make_pointer(), + ); + new_val.dereference(self.location).to_rvalue() + } else { + actual_val.dereference(self.location).to_rvalue() + } + } else { + // FIXME: this condition seems wrong: it will pass when both types are not + // a vector. + assert!( + (!expected_ty.is_vector() || actual_ty.is_vector()) + && (expected_ty.is_vector() || !actual_ty.is_vector()), + "{:?} (is vector: {}) -> {:?} (is vector: {}), Function: {:?}[{}]", + actual_ty, + actual_ty.is_vector(), + expected_ty, + expected_ty.is_vector(), + func_ptr, + index + ); + // TODO(antoyo): perhaps use __builtin_convertvector for vector casting. + // TODO: remove bitcast now that vector types can be compared? + // ==> We use bitcast to avoid having to do many manual casts from e.g. __m256i to __v32qi (in + // the case of _mm256_aesenc_epi128). + self.bitcast(actual_val, expected_ty) + } + } else { + actual_val + } + }) + .collect(); + + // NOTE: to take into account variadic functions. + for arg in args.iter().skip(casted_args.len()) { + casted_args.push(*arg); + } + + Cow::Owned(casted_args) + } + + fn check_store(&mut self, val: RValue<'gcc>, ptr: RValue<'gcc>) -> RValue<'gcc> { + let stored_ty = self.cx.val_ty(val); + let stored_ptr_ty = self.cx.type_ptr_to(stored_ty); + self.bitcast(ptr, stored_ptr_ty) + } + + pub fn current_func(&self) -> Function<'gcc> { + self.block.get_function() + } + + fn function_call( + &mut self, + func: RValue<'gcc>, + args: &[RValue<'gcc>], + _funclet: Option<&Funclet>, + ) -> RValue<'gcc> { + // TODO(antoyo): remove when the API supports a different type for functions. + let func: Function<'gcc> = self.cx.rvalue_as_function(func); + let args = self.check_call("call", func, args); + + // gccjit requires to use the result of functions, even when it's not used. + // That's why we assign the result to a local or call add_eval(). + let return_type = func.get_return_type(); + let void_type = self.context.new_type::<()>(); + let current_func = self.block.get_function(); + if return_type != void_type { + let result = current_func.new_local( + self.location, + return_type, + format!("returnValue{}", self.next_value_counter()), + ); + self.block.add_assignment( + self.location, + result, + self.cx.context.new_call(self.location, func, &args), + ); + result.to_rvalue() + } else { + self.block + .add_eval(self.location, self.cx.context.new_call(self.location, func, &args)); + // Return dummy value when not having return value. + self.context.new_rvalue_zero(self.isize_type) + } + } + + fn function_ptr_call( + &mut self, + typ: Type<'gcc>, + mut func_ptr: RValue<'gcc>, + args: &[RValue<'gcc>], + _funclet: Option<&Funclet>, + ) -> RValue<'gcc> { + let gcc_func = match func_ptr.get_type().dyncast_function_ptr_type() { + Some(func) => func, + None => { + // NOTE: due to opaque pointers now being used, we need to cast here. + let new_func_type = typ.dyncast_function_ptr_type().expect("function ptr"); + func_ptr = self.context.new_cast(self.location, func_ptr, typ); + new_func_type + } + }; + let func_name = format!("{:?}", func_ptr); + let previous_arg_count = args.len(); + let orig_args = args; + let args = { + func_ptr = llvm::adjust_function(self.context, &func_name, func_ptr, args); + llvm::adjust_intrinsic_arguments(self, gcc_func, args.into(), &func_name) + }; + let args_adjusted = args.len() != previous_arg_count; + let args = self.check_ptr_call("call", func_ptr, &args); + + // gccjit requires to use the result of functions, even when it's not used. + // That's why we assign the result to a local or call add_eval(). + let return_type = gcc_func.get_return_type(); + let void_type = self.context.new_type::<()>(); + let current_func = self.block.get_function(); + + if return_type != void_type { + let return_value = self.cx.context.new_call_through_ptr(self.location, func_ptr, &args); + let return_value = llvm::adjust_intrinsic_return_value( + self, + return_value, + &func_name, + &args, + args_adjusted, + orig_args, + ); + let result = current_func.new_local( + self.location, + return_value.get_type(), + format!("ptrReturnValue{}", self.next_value_counter()), + ); + self.block.add_assignment(self.location, result, return_value); + result.to_rvalue() + } else { + #[cfg(not(feature = "master"))] + if gcc_func.get_param_count() == 0 { + // FIXME(antoyo): As a temporary workaround for unsupported LLVM intrinsics. + self.block.add_eval( + self.location, + self.cx.context.new_call_through_ptr(self.location, func_ptr, &[]), + ); + } else { + self.block.add_eval( + self.location, + self.cx.context.new_call_through_ptr(self.location, func_ptr, &args), + ); + } + #[cfg(feature = "master")] + self.block.add_eval( + self.location, + self.cx.context.new_call_through_ptr(self.location, func_ptr, &args), + ); + // Return dummy value when not having return value. + self.context.new_rvalue_zero(self.isize_type) + } + } + + pub fn overflow_call( + &self, + func: Function<'gcc>, + args: &[RValue<'gcc>], + _funclet: Option<&Funclet>, + ) -> RValue<'gcc> { + // gccjit requires to use the result of functions, even when it's not used. + // That's why we assign the result to a local. + let return_type = self.context.new_type::<bool>(); + let current_func = self.block.get_function(); + // TODO(antoyo): return the new_call() directly? Since the overflow function has no side-effects. + let result = current_func.new_local( + self.location, + return_type, + format!("overflowReturnValue{}", self.next_value_counter()), + ); + self.block.add_assignment( + self.location, + result, + self.cx.context.new_call(self.location, func, args), + ); + result.to_rvalue() + } +} + +impl<'tcx> HasTyCtxt<'tcx> for Builder<'_, '_, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { + self.cx.tcx() + } +} + +impl HasDataLayout for Builder<'_, '_, '_> { + fn data_layout(&self) -> &TargetDataLayout { + self.cx.data_layout() + } +} + +impl<'tcx> LayoutOfHelpers<'tcx> for Builder<'_, '_, 'tcx> { + #[inline] + fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { + self.cx.handle_layout_err(err, span, ty) + } +} + +impl<'tcx> FnAbiOfHelpers<'tcx> for Builder<'_, '_, 'tcx> { + #[inline] + fn handle_fn_abi_err( + &self, + err: FnAbiError<'tcx>, + span: Span, + fn_abi_request: FnAbiRequest<'tcx>, + ) -> ! { + self.cx.handle_fn_abi_err(err, span, fn_abi_request) + } +} + +impl<'a, 'gcc, 'tcx> Deref for Builder<'a, 'gcc, 'tcx> { + type Target = CodegenCx<'gcc, 'tcx>; + + fn deref<'b>(&'b self) -> &'a Self::Target { + self.cx + } +} + +impl<'gcc, 'tcx> BackendTypes for Builder<'_, 'gcc, 'tcx> { + type Value = <CodegenCx<'gcc, 'tcx> as BackendTypes>::Value; + type Metadata = <CodegenCx<'gcc, 'tcx> as BackendTypes>::Metadata; + type Function = <CodegenCx<'gcc, 'tcx> as BackendTypes>::Function; + type BasicBlock = <CodegenCx<'gcc, 'tcx> as BackendTypes>::BasicBlock; + type Type = <CodegenCx<'gcc, 'tcx> as BackendTypes>::Type; + type Funclet = <CodegenCx<'gcc, 'tcx> as BackendTypes>::Funclet; + + type DIScope = <CodegenCx<'gcc, 'tcx> as BackendTypes>::DIScope; + type DILocation = <CodegenCx<'gcc, 'tcx> as BackendTypes>::DILocation; + type DIVariable = <CodegenCx<'gcc, 'tcx> as BackendTypes>::DIVariable; +} + +fn set_rvalue_location<'a, 'gcc, 'tcx>( + bx: &mut Builder<'a, 'gcc, 'tcx>, + rvalue: RValue<'gcc>, +) -> RValue<'gcc> { + if bx.location.is_some() { + #[cfg(feature = "master")] + rvalue.set_location(bx.location.unwrap()); + } + rvalue +} + +impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { + type CodegenCx = CodegenCx<'gcc, 'tcx>; + + fn build(cx: &'a CodegenCx<'gcc, 'tcx>, block: Block<'gcc>) -> Builder<'a, 'gcc, 'tcx> { + Builder::with_cx(cx, block) + } + + fn llbb(&self) -> Block<'gcc> { + self.block + } + + fn append_block(_: &'a CodegenCx<'gcc, 'tcx>, func: Function<'gcc>, name: &str) -> Block<'gcc> { + func.new_block(name) + } + + fn append_sibling_block(&mut self, name: &str) -> Block<'gcc> { + let func = self.current_func(); + func.new_block(name) + } + + fn switch_to_block(&mut self, block: Self::BasicBlock) { + self.block = block; + } + + fn ret_void(&mut self) { + self.llbb().end_with_void_return(self.location) + } + + fn ret(&mut self, mut value: RValue<'gcc>) { + let expected_return_type = self.current_func().get_return_type(); + let value_type = value.get_type(); + if !expected_return_type.is_compatible_with(value_type) { + // NOTE: due to opaque pointers now being used, we need to (bit)cast here. + if self.is_native_int_type(value_type) && self.is_native_int_type(expected_return_type) + { + value = self.context.new_cast(self.location, value, expected_return_type); + } else { + value = self.context.new_bitcast(self.location, value, expected_return_type); + } + } + self.llbb().end_with_return(self.location, value); + } + + fn br(&mut self, dest: Block<'gcc>) { + self.llbb().end_with_jump(self.location, dest) + } + + fn cond_br(&mut self, cond: RValue<'gcc>, then_block: Block<'gcc>, else_block: Block<'gcc>) { + self.llbb().end_with_conditional(self.location, cond, then_block, else_block) + } + + fn switch( + &mut self, + value: RValue<'gcc>, + default_block: Block<'gcc>, + cases: impl ExactSizeIterator<Item = (u128, Block<'gcc>)>, + ) { + let mut gcc_cases = vec![]; + let typ = self.val_ty(value); + // FIXME(FractalFir): This is a workaround for a libgccjit limitation. + // Currently, libgccjit can't directly create 128 bit integers. + // Since switch cases must be values, and casts are not constant, we can't use 128 bit switch cases. + // In such a case, we will simply fall back to an if-ladder. + // This *may* be slower than a native switch, but a slow working solution is better than none at all. + if typ.is_i128(self) || typ.is_u128(self) { + for (on_val, dest) in cases { + let on_val = self.const_uint_big(typ, on_val); + let is_case = + self.context.new_comparison(self.location, ComparisonOp::Equals, value, on_val); + let next_block = self.current_func().new_block("case"); + self.block.end_with_conditional(self.location, is_case, dest, next_block); + self.block = next_block; + } + self.block.end_with_jump(self.location, default_block); + } else { + for (on_val, dest) in cases { + let on_val = self.const_uint_big(typ, on_val); + gcc_cases.push(self.context.new_case(on_val, on_val, dest)); + } + self.block.end_with_switch(self.location, value, default_block, &gcc_cases); + } + } + + #[cfg(feature = "master")] + fn invoke( + &mut self, + typ: Type<'gcc>, + fn_attrs: Option<&CodegenFnAttrs>, + _fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>, + func: RValue<'gcc>, + args: &[RValue<'gcc>], + then: Block<'gcc>, + catch: Block<'gcc>, + _funclet: Option<&Funclet>, + instance: Option<Instance<'tcx>>, + ) -> RValue<'gcc> { + let try_block = self.current_func().new_block("try"); + + let current_block = self.block; + self.block = try_block; + let call = self.call(typ, fn_attrs, None, func, args, None, instance); // TODO(antoyo): use funclet here? + self.block = current_block; + + let return_value = + self.current_func().new_local(self.location, call.get_type(), "invokeResult"); + + try_block.add_assignment(self.location, return_value, call); + + try_block.end_with_jump(self.location, then); + + if self.cleanup_blocks.borrow().contains(&catch) { + self.block.add_try_finally(self.location, try_block, catch); + } else { + self.block.add_try_catch(self.location, try_block, catch); + } + + self.block.end_with_jump(self.location, then); + + return_value.to_rvalue() + } + + #[cfg(not(feature = "master"))] + fn invoke( + &mut self, + typ: Type<'gcc>, + fn_attrs: Option<&CodegenFnAttrs>, + fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>, + func: RValue<'gcc>, + args: &[RValue<'gcc>], + then: Block<'gcc>, + catch: Block<'gcc>, + _funclet: Option<&Funclet>, + instance: Option<Instance<'tcx>>, + ) -> RValue<'gcc> { + let call_site = self.call(typ, fn_attrs, None, func, args, None, instance); + let condition = self.context.new_rvalue_from_int(self.bool_type, 1); + self.llbb().end_with_conditional(self.location, condition, then, catch); + if let Some(_fn_abi) = fn_abi { + // TODO(bjorn3): Apply function attributes + } + call_site + } + + fn unreachable(&mut self) { + let func = self.context.get_builtin_function("__builtin_unreachable"); + self.block.add_eval(self.location, self.context.new_call(self.location, func, &[])); + let return_type = self.block.get_function().get_return_type(); + let void_type = self.context.new_type::<()>(); + if return_type == void_type { + self.block.end_with_void_return(self.location) + } else { + let return_value = + self.current_func().new_local(self.location, return_type, "unreachableReturn"); + self.block.end_with_return(self.location, return_value) + } + } + + fn add(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.gcc_add(a, b) + } + + fn fadd(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + a + b + } + + // TODO(antoyo): should we also override the `unchecked_` versions? + fn sub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.gcc_sub(a, b) + } + + fn fsub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + a - b + } + + fn mul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.gcc_mul(a, b) + } + + fn fmul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.cx.context.new_binary_op(self.location, BinaryOp::Mult, a.get_type(), a, b) + } + + fn udiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.gcc_udiv(a, b) + } + + fn exactudiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + // TODO(antoyo): poison if not exact. + let a_type = a.get_type().to_unsigned(self); + let a = self.gcc_int_cast(a, a_type); + let b_type = b.get_type().to_unsigned(self); + let b = self.gcc_int_cast(b, b_type); + self.gcc_udiv(a, b) + } + + fn sdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.gcc_sdiv(a, b) + } + + fn exactsdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + // TODO(antoyo): poison if not exact. + // FIXME(antoyo): rustc_codegen_ssa::mir::intrinsic uses different types for a and b but they + // should be the same. + let typ = a.get_type().to_signed(self); + let b = self.gcc_int_cast(b, typ); + self.gcc_sdiv(a, b) + } + + fn fdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + a / b + } + + fn urem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.gcc_urem(a, b) + } + + fn srem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.gcc_srem(a, b) + } + + fn frem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + // TODO(antoyo): add check in libgccjit since using the binary operator % causes the following error: + // during RTL pass: expand + // libgccjit.so: error: in expmed_mode_index, at expmed.h:240 + // 0x7f0101d58dc6 expmed_mode_index + // ../../../gcc/gcc/expmed.h:240 + // 0x7f0101d58e35 expmed_op_cost_ptr + // ../../../gcc/gcc/expmed.h:262 + // 0x7f0101d594a1 sdiv_cost_ptr + // ../../../gcc/gcc/expmed.h:531 + // 0x7f0101d594f3 sdiv_cost + // ../../../gcc/gcc/expmed.h:549 + // 0x7f0101d6af7e expand_divmod(int, tree_code, machine_mode, rtx_def*, rtx_def*, rtx_def*, int, optab_methods) + // ../../../gcc/gcc/expmed.cc:4356 + // 0x7f0101d94f9e expand_expr_divmod + // ../../../gcc/gcc/expr.cc:8929 + // 0x7f0101d97a26 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) + // ../../../gcc/gcc/expr.cc:9566 + // 0x7f0101bef6ef expand_gimple_stmt_1 + // ../../../gcc/gcc/cfgexpand.cc:3967 + // 0x7f0101bef910 expand_gimple_stmt + // ../../../gcc/gcc/cfgexpand.cc:4028 + // 0x7f0101bf6ee7 expand_gimple_basic_block + // ../../../gcc/gcc/cfgexpand.cc:6069 + // 0x7f0101bf9194 execute + // ../../../gcc/gcc/cfgexpand.cc:6795 + let a_type = a.get_type(); + let a_type_unqualified = a_type.unqualified(); + if a_type.is_compatible_with(self.cx.float_type) { + let fmodf = self.context.get_builtin_function("fmodf"); + // FIXME(antoyo): this seems to produce the wrong result. + return self.context.new_call(self.location, fmodf, &[a, b]); + } + + #[cfg(feature = "master")] + match self.cx.type_kind(a_type) { + TypeKind::Half => { + let fmodf = self.context.get_builtin_function("fmodf"); + let f32_type = self.type_f32(); + let a = self.context.new_cast(self.location, a, f32_type); + let b = self.context.new_cast(self.location, b, f32_type); + let result = self.context.new_call(self.location, fmodf, &[a, b]); + return self.context.new_cast(self.location, result, a_type); + } + TypeKind::Float => { + let fmodf = self.context.get_builtin_function("fmodf"); + return self.context.new_call(self.location, fmodf, &[a, b]); + } + TypeKind::Double => { + let fmod = self.context.get_builtin_function("fmod"); + return self.context.new_call(self.location, fmod, &[a, b]); + } + TypeKind::FP128 => { + // TODO(antoyo): use get_simple_function_f128_2args. + let f128_type = self.type_f128(); + let fmodf128 = self.context.new_function( + None, + gccjit::FunctionType::Extern, + f128_type, + &[ + self.context.new_parameter(None, f128_type, "a"), + self.context.new_parameter(None, f128_type, "b"), + ], + "fmodf128", + false, + ); + return self.context.new_call(self.location, fmodf128, &[a, b]); + } + _ => (), + } + + if let Some(vector_type) = a_type_unqualified.dyncast_vector() { + assert_eq!(a_type_unqualified, b.get_type().unqualified()); + + let num_units = vector_type.get_num_units(); + let new_elements: Vec<_> = (0..num_units) + .map(|i| { + let index = self.context.new_rvalue_from_long(self.cx.type_u32(), i as _); + let x = self.extract_element(a, index).to_rvalue(); + let y = self.extract_element(b, index).to_rvalue(); + self.frem(x, y) + }) + .collect(); + + return self.context.new_rvalue_from_vector(self.location, a_type, &new_elements); + } + assert_eq!(a_type_unqualified, self.cx.double_type); + + let fmod = self.context.get_builtin_function("fmod"); + self.context.new_call(self.location, fmod, &[a, b]) + } + + fn shl(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.gcc_shl(a, b) + } + + fn lshr(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.gcc_lshr(a, b) + } + + fn ashr(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + // TODO(antoyo): check whether behavior is an arithmetic shift for >> . + // It seems to be if the value is signed. + self.gcc_lshr(a, b) + } + + fn and(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.gcc_and(a, b) + } + + fn or(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.cx.gcc_or(a, b, self.location) + } + + fn xor(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + set_rvalue_location(self, self.gcc_xor(a, b)) + } + + fn neg(&mut self, a: RValue<'gcc>) -> RValue<'gcc> { + set_rvalue_location(self, self.gcc_neg(a)) + } + + fn fneg(&mut self, a: RValue<'gcc>) -> RValue<'gcc> { + set_rvalue_location( + self, + self.cx.context.new_unary_op(self.location, UnaryOp::Minus, a.get_type(), a), + ) + } + + fn not(&mut self, a: RValue<'gcc>) -> RValue<'gcc> { + set_rvalue_location(self, self.gcc_not(a)) + } + + fn fadd_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. + set_rvalue_location(self, lhs + rhs) + } + + fn fsub_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. + set_rvalue_location(self, lhs - rhs) + } + + fn fmul_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. + set_rvalue_location(self, lhs * rhs) + } + + fn fdiv_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. + set_rvalue_location(self, lhs / rhs) + } + + fn frem_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. + let result = self.frem(lhs, rhs); + set_rvalue_location(self, result); + result + } + + fn fadd_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. + lhs + rhs + } + + fn fsub_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. + lhs - rhs + } + + fn fmul_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. + lhs * rhs + } + + fn fdiv_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. + lhs / rhs + } + + fn frem_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. + self.frem(lhs, rhs) + } + + fn checked_binop( + &mut self, + oop: OverflowOp, + typ: Ty<'tcx>, + lhs: Self::Value, + rhs: Self::Value, + ) -> (Self::Value, Self::Value) { + self.gcc_checked_binop(oop, typ, lhs, rhs) + } + + fn alloca(&mut self, size: Size, align: Align) -> RValue<'gcc> { + let ty = self.cx.type_array(self.cx.type_i8(), size.bytes()).get_aligned(align.bytes()); + // TODO(antoyo): It might be better to return a LValue, but fixing the rustc API is non-trivial. + self.current_func() + .new_local(self.location, ty, format!("stack_var_{}", self.next_value_counter())) + .get_address(self.location) + } + + fn load(&mut self, pointee_ty: Type<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> { + let block = self.llbb(); + let function = block.get_function(); + // NOTE(FractalFir): In some cases, we *should* skip the call to get_aligned. + // For example, calling `get_aligned` on a i8 is pointless(since it can only be 1 aligned) + // Calling get_aligned on a `u128`/`i128` causes the attribute to become "stacked" + // + // From GCCs perspective: + // __int128_t __attribute__((aligned(16))) __attribute__((aligned(16))) + // and: + // __int128_t __attribute__((aligned(16))) + // are 2 distinct, incompatible types. + // + // So, we skip the call to `get_aligned` in such a case. *Ideally*, we could do this for all the types, + // but the GCC APIs to facilitate this just aren't quite there yet. + + // This checks that we only skip `get_aligned` on 128 bit ints if they have the correct alignment. + // Otherwise, this may be an under-aligned load, so we will still call get_aligned. + let mut can_skip_align = (pointee_ty == self.cx.u128_type + || pointee_ty == self.cx.i128_type) + && align == self.int128_align; + // We can skip the call to `get_aligned` for byte-sized types with alignment of 1. + can_skip_align = can_skip_align + || (pointee_ty == self.cx.u8_type || pointee_ty == self.cx.i8_type) + && align.bytes() == 1; + // Skip the call to `get_aligned` when possible. + let aligned_type = + if can_skip_align { pointee_ty } else { pointee_ty.get_aligned(align.bytes()) }; + + let ptr = self.context.new_cast(self.location, ptr, aligned_type.make_pointer()); + // NOTE: instead of returning the dereference here, we have to assign it to a variable in + // the current basic block. Otherwise, it could be used in another basic block, causing a + // dereference after a drop, for instance. + let deref = ptr.dereference(self.location).to_rvalue(); + let loaded_value = function.new_local( + self.location, + aligned_type, + format!("loadedValue{}", self.next_value_counter()), + ); + block.add_assignment(self.location, loaded_value, deref); + loaded_value.to_rvalue() + } + + fn volatile_load(&mut self, ty: Type<'gcc>, ptr: RValue<'gcc>) -> RValue<'gcc> { + let ptr = self.context.new_cast(self.location, ptr, ty.make_volatile().make_pointer()); + // (FractalFir): We insert a local here, to ensure this volatile load can't move across + // blocks. + let local = self.current_func().new_local(self.location, ty, "volatile_tmp"); + self.block.add_assignment(self.location, local, ptr.dereference(self.location).to_rvalue()); + local.to_rvalue() + } + + fn atomic_load( + &mut self, + _ty: Type<'gcc>, + ptr: RValue<'gcc>, + order: AtomicOrdering, + size: Size, + ) -> RValue<'gcc> { + // TODO(antoyo): use ty. + // TODO(antoyo): handle alignment. + let atomic_load = + self.context.get_builtin_function(format!("__atomic_load_{}", size.bytes())); + let ordering = self.context.new_rvalue_from_int(self.i32_type, order.to_gcc()); + + let volatile_const_void_ptr_type = + self.context.new_type::<()>().make_const().make_volatile().make_pointer(); + let ptr = self.context.new_cast(self.location, ptr, volatile_const_void_ptr_type); + self.context.new_call(self.location, atomic_load, &[ptr, ordering]) + } + + fn load_operand( + &mut self, + place: PlaceRef<'tcx, RValue<'gcc>>, + ) -> OperandRef<'tcx, RValue<'gcc>> { + assert_eq!(place.val.llextra.is_some(), place.layout.is_unsized()); + + if place.layout.is_zst() { + return OperandRef::zero_sized(place.layout); + } + + fn scalar_load_metadata<'a, 'gcc, 'tcx>( + bx: &mut Builder<'a, 'gcc, 'tcx>, + load: RValue<'gcc>, + scalar: &abi::Scalar, + ) { + let vr = scalar.valid_range(bx); + match scalar.primitive() { + abi::Primitive::Int(..) => { + if !scalar.is_always_valid(bx) { + bx.range_metadata(load, vr); + } + } + abi::Primitive::Pointer(_) if vr.start < vr.end && !vr.contains(0) => { + bx.nonnull_metadata(load); + } + _ => {} + } + } + + let val = if place.val.llextra.is_some() { + // FIXME: Merge with the `else` below? + OperandValue::Ref(place.val) + } else if place.layout.is_gcc_immediate() { + let load = self.load(place.layout.gcc_type(self), place.val.llval, place.val.align); + OperandValue::Immediate( + if let abi::BackendRepr::Scalar(ref scalar) = place.layout.backend_repr { + scalar_load_metadata(self, load, scalar); + self.to_immediate_scalar(load, *scalar) + } else { + load + }, + ) + } else if let abi::BackendRepr::ScalarPair(ref a, ref b) = place.layout.backend_repr { + let b_offset = a.size(self).align_to(b.align(self).abi); + + let mut load = |i, scalar: &abi::Scalar, align| { + let ptr = if i == 0 { + place.val.llval + } else { + self.inbounds_ptradd(place.val.llval, self.const_usize(b_offset.bytes())) + }; + let llty = place.layout.scalar_pair_element_gcc_type(self, i); + let load = self.load(llty, ptr, align); + scalar_load_metadata(self, load, scalar); + if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load } + }; + + OperandValue::Pair( + load(0, a, place.val.align), + load(1, b, place.val.align.restrict_for_offset(b_offset)), + ) + } else { + OperandValue::Ref(place.val) + }; + + OperandRef { val, layout: place.layout } + } + + fn write_operand_repeatedly( + &mut self, + cg_elem: OperandRef<'tcx, RValue<'gcc>>, + count: u64, + dest: PlaceRef<'tcx, RValue<'gcc>>, + ) { + let zero = self.const_usize(0); + let count = self.const_usize(count); + let start = dest.project_index(self, zero).val.llval; + let end = dest.project_index(self, count).val.llval; + + let header_bb = self.append_sibling_block("repeat_loop_header"); + let body_bb = self.append_sibling_block("repeat_loop_body"); + let next_bb = self.append_sibling_block("repeat_loop_next"); + + let ptr_type = start.get_type(); + let current = self.llbb().get_function().new_local(self.location, ptr_type, "loop_var"); + let current_val = current.to_rvalue(); + self.assign(current, start); + + self.br(header_bb); + + self.switch_to_block(header_bb); + let keep_going = self.icmp(IntPredicate::IntNE, current_val, end); + self.cond_br(keep_going, body_bb, next_bb); + + self.switch_to_block(body_bb); + let align = dest.val.align.restrict_for_offset(dest.layout.field(self.cx(), 0).size); + cg_elem.val.store(self, PlaceRef::new_sized_aligned(current_val, cg_elem.layout, align)); + + let next = self.inbounds_gep( + self.backend_type(cg_elem.layout), + current.to_rvalue(), + &[self.const_usize(1)], + ); + self.llbb().add_assignment(self.location, current, next); + self.br(header_bb); + + self.switch_to_block(next_bb); + } + + fn range_metadata(&mut self, _load: RValue<'gcc>, _range: WrappingRange) { + // TODO(antoyo) + } + + fn nonnull_metadata(&mut self, _load: RValue<'gcc>) { + // TODO(antoyo) + } + + fn store(&mut self, val: RValue<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> { + self.store_with_flags(val, ptr, align, MemFlags::empty()) + } + + fn store_with_flags( + &mut self, + val: RValue<'gcc>, + ptr: RValue<'gcc>, + align: Align, + flags: MemFlags, + ) -> RValue<'gcc> { + let ptr = self.check_store(val, ptr); + let destination = ptr.dereference(self.location); + // NOTE: libgccjit does not support specifying the alignment on the assignment, so we cast + // to type so it gets the proper alignment. + let destination_type = destination.to_rvalue().get_type().unqualified(); + let align = if flags.contains(MemFlags::UNALIGNED) { 1 } else { align.bytes() }; + let mut modified_destination_type = destination_type.get_aligned(align); + if flags.contains(MemFlags::VOLATILE) { + modified_destination_type = modified_destination_type.make_volatile(); + } + + let modified_ptr = + self.cx.context.new_cast(self.location, ptr, modified_destination_type.make_pointer()); + let modified_destination = modified_ptr.dereference(self.location); + self.llbb().add_assignment(self.location, modified_destination, val); + // TODO(antoyo): handle `MemFlags::NONTEMPORAL`. + // NOTE: dummy value here since it's never used. FIXME(antoyo): API should not return a value here? + // When adding support for NONTEMPORAL, make sure to not just emit MOVNT on x86; see the + // LLVM backend for details. + self.cx.context.new_rvalue_zero(self.type_i32()) + } + + fn atomic_store( + &mut self, + value: RValue<'gcc>, + ptr: RValue<'gcc>, + order: AtomicOrdering, + size: Size, + ) { + // TODO(antoyo): handle alignment. + let atomic_store = + self.context.get_builtin_function(format!("__atomic_store_{}", size.bytes())); + let ordering = self.context.new_rvalue_from_int(self.i32_type, order.to_gcc()); + let volatile_const_void_ptr_type = + self.context.new_type::<()>().make_volatile().make_pointer(); + let ptr = self.context.new_cast(self.location, ptr, volatile_const_void_ptr_type); + + // FIXME(antoyo): fix libgccjit to allow comparing an integer type with an aligned integer type because + // the following cast is required to avoid this error: + // gcc_jit_context_new_call: mismatching types for argument 2 of function "__atomic_store_4": assignment to param arg1 (type: int) from loadedValue3577 (type: unsigned int __attribute__((aligned(4)))) + let int_type = atomic_store.get_param(1).to_rvalue().get_type(); + let value = self.context.new_bitcast(self.location, value, int_type); + self.llbb().add_eval( + self.location, + self.context.new_call(self.location, atomic_store, &[ptr, value, ordering]), + ); + } + + fn gep( + &mut self, + typ: Type<'gcc>, + ptr: RValue<'gcc>, + indices: &[RValue<'gcc>], + ) -> RValue<'gcc> { + // NOTE: due to opaque pointers now being used, we need to cast here. + let ptr = self.context.new_cast(self.location, ptr, typ.make_pointer()); + let ptr_type = ptr.get_type(); + let mut pointee_type = ptr.get_type(); + // NOTE: we cannot use array indexing here like in inbounds_gep because array indexing is + // always considered in bounds in GCC (TODO(antoyo): to be verified). + // So, we have to cast to a number. + let mut result = self.context.new_bitcast(self.location, ptr, self.sizet_type); + // FIXME(antoyo): if there were more than 1 index, this code is probably wrong and would + // require dereferencing the pointer. + for index in indices { + pointee_type = pointee_type.get_pointee().expect("pointee type"); + #[cfg(feature = "master")] + let pointee_size = { + let size = self.cx.context.new_sizeof(pointee_type); + self.context.new_cast(self.location, size, index.get_type()) + }; + #[cfg(not(feature = "master"))] + let pointee_size = + self.context.new_rvalue_from_int(index.get_type(), pointee_type.get_size() as i32); + result = result + self.gcc_int_cast(*index * pointee_size, self.sizet_type); + } + self.context.new_bitcast(self.location, result, ptr_type) + } + + fn inbounds_gep( + &mut self, + typ: Type<'gcc>, + ptr: RValue<'gcc>, + indices: &[RValue<'gcc>], + ) -> RValue<'gcc> { + // NOTE: due to opaque pointers now being used, we need to cast here. + let ptr = self.context.new_cast(self.location, ptr, typ.make_pointer()); + // NOTE: array indexing is always considered in bounds in GCC (TODO(antoyo): to be verified). + let mut indices = indices.iter(); + let index = indices.next().expect("first index in inbounds_gep"); + let mut result = self.context.new_array_access(self.location, ptr, *index); + for index in indices { + result = self.context.new_array_access(self.location, result, *index); + } + result.get_address(self.location) + } + + /* Casts */ + fn trunc(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + // TODO(antoyo): check that it indeed truncate the value. + self.gcc_int_cast(value, dest_ty) + } + + fn sext(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + // TODO(antoyo): check that it indeed sign extend the value. + if dest_ty.dyncast_vector().is_some() { + // TODO(antoyo): nothing to do as it is only for LLVM? + return value; + } + self.context.new_cast(self.location, value, dest_ty) + } + + fn fptoui(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + set_rvalue_location(self, self.gcc_float_to_uint_cast(value, dest_ty)) + } + + fn fptosi(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + set_rvalue_location(self, self.gcc_float_to_int_cast(value, dest_ty)) + } + + fn uitofp(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + set_rvalue_location(self, self.gcc_uint_to_float_cast(value, dest_ty)) + } + + fn sitofp(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + set_rvalue_location(self, self.gcc_int_to_float_cast(value, dest_ty)) + } + + fn fptrunc(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + // TODO(antoyo): make sure it truncates. + set_rvalue_location(self, self.context.new_cast(self.location, value, dest_ty)) + } + + fn fpext(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + set_rvalue_location(self, self.context.new_cast(self.location, value, dest_ty)) + } + + fn ptrtoint(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + let usize_value = self.cx.context.new_cast(None, value, self.cx.type_isize()); + self.intcast(usize_value, dest_ty, false) + } + + fn inttoptr(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + let usize_value = self.intcast(value, self.cx.type_isize(), false); + self.cx.context.new_cast(None, usize_value, dest_ty) + } + + fn bitcast(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + self.cx.const_bitcast(value, dest_ty) + } + + fn intcast( + &mut self, + mut value: RValue<'gcc>, + dest_typ: Type<'gcc>, + is_signed: bool, + ) -> RValue<'gcc> { + let value_type = value.get_type(); + if is_signed && !value_type.is_signed(self.cx) { + let signed_type = value_type.to_signed(self.cx); + value = self.gcc_int_cast(value, signed_type); + } else if !is_signed && value_type.is_signed(self.cx) { + let unsigned_type = value_type.to_unsigned(self.cx); + value = self.gcc_int_cast(value, unsigned_type); + } + + self.gcc_int_cast(value, dest_typ) + } + + fn pointercast(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + let val_type = value.get_type(); + match (type_is_pointer(val_type), type_is_pointer(dest_ty)) { + (false, true) => { + // NOTE: Projecting a field of a pointer type will attempt a cast from a signed char to + // a pointer, which is not supported by gccjit. + self.cx.context.new_cast( + self.location, + self.inttoptr(value, val_type.make_pointer()), + dest_ty, + ) + } + (false, false) => { + // When they are not pointers, we want a transmute (or reinterpret_cast). + self.bitcast(value, dest_ty) + } + (true, true) => self.cx.context.new_cast(self.location, value, dest_ty), + (true, false) => unimplemented!(), + } + } + + /* Comparisons */ + fn icmp(&mut self, op: IntPredicate, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + self.gcc_icmp(op, lhs, rhs) + } + + fn fcmp(&mut self, op: RealPredicate, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { + // LLVM has a concept of "unordered compares", where eg ULT returns true if either the two + // arguments are unordered (i.e. either is NaN), or the lhs is less than the rhs. GCC does + // not natively have this concept, so in some cases we must manually handle NaNs + let must_handle_nan = match op { + RealPredicate::RealPredicateFalse => unreachable!(), + RealPredicate::RealOEQ => false, + RealPredicate::RealOGT => false, + RealPredicate::RealOGE => false, + RealPredicate::RealOLT => false, + RealPredicate::RealOLE => false, + RealPredicate::RealONE => false, + RealPredicate::RealORD => unreachable!(), + RealPredicate::RealUNO => unreachable!(), + RealPredicate::RealUEQ => false, + RealPredicate::RealUGT => true, + RealPredicate::RealUGE => true, + RealPredicate::RealULT => true, + RealPredicate::RealULE => true, + RealPredicate::RealUNE => false, + RealPredicate::RealPredicateTrue => unreachable!(), + }; + + let cmp = self.context.new_comparison(self.location, op.to_gcc_comparison(), lhs, rhs); + + if must_handle_nan { + let is_nan = self.context.new_binary_op( + self.location, + BinaryOp::LogicalOr, + self.cx.bool_type, + // compare a value to itself to check whether it is NaN + self.context.new_comparison(self.location, ComparisonOp::NotEquals, lhs, lhs), + self.context.new_comparison(self.location, ComparisonOp::NotEquals, rhs, rhs), + ); + + self.context.new_binary_op( + self.location, + BinaryOp::LogicalOr, + self.cx.bool_type, + is_nan, + cmp, + ) + } else { + cmp + } + } + + /* Miscellaneous instructions */ + fn memcpy( + &mut self, + dst: RValue<'gcc>, + _dst_align: Align, + src: RValue<'gcc>, + _src_align: Align, + size: RValue<'gcc>, + flags: MemFlags, + ) { + assert!(!flags.contains(MemFlags::NONTEMPORAL), "non-temporal memcpy not supported"); + let size = self.intcast(size, self.type_size_t(), false); + let _is_volatile = flags.contains(MemFlags::VOLATILE); + let dst = self.pointercast(dst, self.type_i8p()); + let src = self.pointercast(src, self.type_ptr_to(self.type_void())); + let memcpy = self.context.get_builtin_function("memcpy"); + // TODO(antoyo): handle aligns and is_volatile. + self.block.add_eval( + self.location, + self.context.new_call(self.location, memcpy, &[dst, src, size]), + ); + } + + fn memmove( + &mut self, + dst: RValue<'gcc>, + _dst_align: Align, + src: RValue<'gcc>, + _src_align: Align, + size: RValue<'gcc>, + flags: MemFlags, + ) { + assert!(!flags.contains(MemFlags::NONTEMPORAL), "non-temporal memmove not supported"); + let size = self.intcast(size, self.type_size_t(), false); + let _is_volatile = flags.contains(MemFlags::VOLATILE); + let dst = self.pointercast(dst, self.type_i8p()); + let src = self.pointercast(src, self.type_ptr_to(self.type_void())); + + let memmove = self.context.get_builtin_function("memmove"); + // TODO(antoyo): handle is_volatile. + self.block.add_eval( + self.location, + self.context.new_call(self.location, memmove, &[dst, src, size]), + ); + } + + fn memset( + &mut self, + ptr: RValue<'gcc>, + fill_byte: RValue<'gcc>, + size: RValue<'gcc>, + _align: Align, + flags: MemFlags, + ) { + assert!(!flags.contains(MemFlags::NONTEMPORAL), "non-temporal memset not supported"); + let _is_volatile = flags.contains(MemFlags::VOLATILE); + let ptr = self.pointercast(ptr, self.type_i8p()); + let memset = self.context.get_builtin_function("memset"); + // TODO(antoyo): handle align and is_volatile. + let fill_byte = self.context.new_cast(self.location, fill_byte, self.i32_type); + let size = self.intcast(size, self.type_size_t(), false); + self.block.add_eval( + self.location, + self.context.new_call(self.location, memset, &[ptr, fill_byte, size]), + ); + } + + fn select( + &mut self, + cond: RValue<'gcc>, + then_val: RValue<'gcc>, + mut else_val: RValue<'gcc>, + ) -> RValue<'gcc> { + let func = self.current_func(); + let variable = func.new_local(self.location, then_val.get_type(), "selectVar"); + let then_block = func.new_block("then"); + let else_block = func.new_block("else"); + let after_block = func.new_block("after"); + self.llbb().end_with_conditional(self.location, cond, then_block, else_block); + + then_block.add_assignment(self.location, variable, then_val); + then_block.end_with_jump(self.location, after_block); + + if !then_val.get_type().is_compatible_with(else_val.get_type()) { + else_val = self.context.new_cast(self.location, else_val, then_val.get_type()); + } + else_block.add_assignment(self.location, variable, else_val); + else_block.end_with_jump(self.location, after_block); + + // NOTE: since jumps were added in a place rustc does not expect, the current block in the + // state need to be updated. + self.switch_to_block(after_block); + + variable.to_rvalue() + } + + #[allow(dead_code)] + fn va_arg(&mut self, _list: RValue<'gcc>, _ty: Type<'gcc>) -> RValue<'gcc> { + unimplemented!(); + } + + #[cfg(feature = "master")] + fn extract_element(&mut self, vec: RValue<'gcc>, idx: RValue<'gcc>) -> RValue<'gcc> { + self.context.new_vector_access(self.location, vec, idx).to_rvalue() + } + + #[cfg(not(feature = "master"))] + fn extract_element(&mut self, vec: RValue<'gcc>, idx: RValue<'gcc>) -> RValue<'gcc> { + let vector_type = vec + .get_type() + .unqualified() + .dyncast_vector() + .expect("Called extract_element on a non-vector type"); + let element_type = vector_type.get_element_type(); + let vec_num_units = vector_type.get_num_units(); + let array_type = + self.context.new_array_type(self.location, element_type, vec_num_units as u64); + let array = self.context.new_bitcast(self.location, vec, array_type).to_rvalue(); + self.context.new_array_access(self.location, array, idx).to_rvalue() + } + + fn vector_splat(&mut self, _num_elts: usize, _elt: RValue<'gcc>) -> RValue<'gcc> { + unimplemented!(); + } + + fn extract_value(&mut self, aggregate_value: RValue<'gcc>, idx: u64) -> RValue<'gcc> { + // FIXME(antoyo): it would be better if the API only called this on struct, not on arrays. + assert_eq!(idx as usize as u64, idx); + let value_type = aggregate_value.get_type(); + + if value_type.dyncast_array().is_some() { + let index = self + .context + .new_rvalue_from_long(self.u64_type, i64::try_from(idx).expect("i64::try_from")); + let element = self.context.new_array_access(self.location, aggregate_value, index); + element.get_address(self.location) + } else if value_type.dyncast_vector().is_some() { + panic!(); + } else if let Some(struct_type) = value_type.is_struct() { + aggregate_value + .access_field(self.location, struct_type.get_field(idx as i32)) + .to_rvalue() + } else { + panic!("Unexpected type {:?}", value_type); + } + } + + fn insert_value( + &mut self, + aggregate_value: RValue<'gcc>, + value: RValue<'gcc>, + idx: u64, + ) -> RValue<'gcc> { + // FIXME(antoyo): it would be better if the API only called this on struct, not on arrays. + assert_eq!(idx as usize as u64, idx); + let value_type = aggregate_value.get_type(); + + let new_val = self.current_func().new_local(None, value_type, "aggregate_value"); + self.block.add_assignment(None, new_val, aggregate_value); + + let lvalue = if value_type.dyncast_array().is_some() { + let index = self + .context + .new_rvalue_from_long(self.u64_type, i64::try_from(idx).expect("i64::try_from")); + self.context.new_array_access(self.location, new_val, index) + } else if value_type.dyncast_vector().is_some() { + panic!(); + } else if let Some(struct_type) = value_type.is_struct() { + new_val.access_field(None, struct_type.get_field(idx as i32)) + } else { + panic!("Unexpected type {:?}", value_type); + }; + + let lvalue_type = lvalue.to_rvalue().get_type(); + let value = + // NOTE: sometimes, rustc will create a value with the wrong type. + if lvalue_type != value.get_type() { + self.context.new_cast(self.location, value, lvalue_type) + } + else { + value + }; + + self.llbb().add_assignment(self.location, lvalue, value); + + new_val.to_rvalue() + } + + fn set_personality_fn(&mut self, _personality: Function<'gcc>) { + #[cfg(feature = "master")] + self.current_func().set_personality_function(_personality); + } + + #[cfg(feature = "master")] + fn cleanup_landing_pad(&mut self, pers_fn: Function<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) { + self.set_personality_fn(pers_fn); + + // NOTE: insert the current block in a variable so that a later call to invoke knows to + // generate a try/finally instead of a try/catch for this block. + self.cleanup_blocks.borrow_mut().insert(self.block); + + let eh_pointer_builtin = + self.cx.context.get_target_builtin_function("__builtin_eh_pointer"); + let zero = self.cx.context.new_rvalue_zero(self.int_type); + let ptr = self.cx.context.new_call(self.location, eh_pointer_builtin, &[zero]); + + let value1_type = self.u8_type.make_pointer(); + let ptr = self.cx.context.new_cast(self.location, ptr, value1_type); + let value1 = ptr; + let value2 = zero; // TODO(antoyo): set the proper value here (the type of exception?). + + (value1, value2) + } + + #[cfg(not(feature = "master"))] + fn cleanup_landing_pad(&mut self, _pers_fn: Function<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) { + let value1 = self + .current_func() + .new_local(self.location, self.u8_type.make_pointer(), "landing_pad0") + .to_rvalue(); + let value2 = + self.current_func().new_local(self.location, self.i32_type, "landing_pad1").to_rvalue(); + (value1, value2) + } + + fn filter_landing_pad(&mut self, pers_fn: Function<'gcc>) { + // TODO(antoyo): generate the correct landing pad + self.cleanup_landing_pad(pers_fn); + } + + #[cfg(feature = "master")] + fn resume(&mut self, exn0: RValue<'gcc>, _exn1: RValue<'gcc>) { + let exn_type = exn0.get_type(); + let exn = self.context.new_cast(self.location, exn0, exn_type); + let unwind_resume = self.context.get_target_builtin_function("__builtin_unwind_resume"); + self.llbb() + .add_eval(self.location, self.context.new_call(self.location, unwind_resume, &[exn])); + self.unreachable(); + } + + #[cfg(not(feature = "master"))] + fn resume(&mut self, _exn0: RValue<'gcc>, _exn1: RValue<'gcc>) { + self.unreachable(); + } + + fn cleanup_pad(&mut self, _parent: Option<RValue<'gcc>>, _args: &[RValue<'gcc>]) -> Funclet { + unimplemented!(); + } + + fn cleanup_ret(&mut self, _funclet: &Funclet, _unwind: Option<Block<'gcc>>) { + unimplemented!(); + } + + fn catch_pad(&mut self, _parent: RValue<'gcc>, _args: &[RValue<'gcc>]) -> Funclet { + unimplemented!(); + } + + fn catch_switch( + &mut self, + _parent: Option<RValue<'gcc>>, + _unwind: Option<Block<'gcc>>, + _handlers: &[Block<'gcc>], + ) -> RValue<'gcc> { + unimplemented!(); + } + + // Atomic Operations + fn atomic_cmpxchg( + &mut self, + dst: RValue<'gcc>, + cmp: RValue<'gcc>, + src: RValue<'gcc>, + order: AtomicOrdering, + failure_order: AtomicOrdering, + weak: bool, + ) -> (RValue<'gcc>, RValue<'gcc>) { + let expected = self.current_func().new_local(None, cmp.get_type(), "expected"); + self.llbb().add_assignment(None, expected, cmp); + // NOTE: gcc doesn't support a failure memory model that is stronger than the success + // memory model. + let order = if failure_order as i32 > order as i32 { failure_order } else { order }; + let success = self.compare_exchange(dst, expected, src, order, failure_order, weak); + + // NOTE: since success contains the call to the intrinsic, it must be added to the basic block before + // expected so that we store expected after the call. + let success_var = self.current_func().new_local(self.location, self.bool_type, "success"); + self.llbb().add_assignment(self.location, success_var, success); + + (expected.to_rvalue(), success_var.to_rvalue()) + } + + fn atomic_rmw( + &mut self, + op: AtomicRmwBinOp, + dst: RValue<'gcc>, + src: RValue<'gcc>, + order: AtomicOrdering, + ) -> RValue<'gcc> { + let size = get_maybe_pointer_size(src); + let name = match op { + AtomicRmwBinOp::AtomicXchg => format!("__atomic_exchange_{}", size), + AtomicRmwBinOp::AtomicAdd => format!("__atomic_fetch_add_{}", size), + AtomicRmwBinOp::AtomicSub => format!("__atomic_fetch_sub_{}", size), + AtomicRmwBinOp::AtomicAnd => format!("__atomic_fetch_and_{}", size), + AtomicRmwBinOp::AtomicNand => format!("__atomic_fetch_nand_{}", size), + AtomicRmwBinOp::AtomicOr => format!("__atomic_fetch_or_{}", size), + AtomicRmwBinOp::AtomicXor => format!("__atomic_fetch_xor_{}", size), + AtomicRmwBinOp::AtomicMax => { + return self.atomic_extremum(ExtremumOperation::Max, dst, src, order); + } + AtomicRmwBinOp::AtomicMin => { + return self.atomic_extremum(ExtremumOperation::Min, dst, src, order); + } + AtomicRmwBinOp::AtomicUMax => { + return self.atomic_extremum(ExtremumOperation::Max, dst, src, order); + } + AtomicRmwBinOp::AtomicUMin => { + return self.atomic_extremum(ExtremumOperation::Min, dst, src, order); + } + }; + + let atomic_function = self.context.get_builtin_function(name); + let order = self.context.new_rvalue_from_int(self.i32_type, order.to_gcc()); + + let void_ptr_type = self.context.new_type::<*mut ()>(); + let volatile_void_ptr_type = void_ptr_type.make_volatile(); + let dst = self.context.new_cast(self.location, dst, volatile_void_ptr_type); + // FIXME(antoyo): not sure why, but we have the wrong type here. + let new_src_type = atomic_function.get_param(1).to_rvalue().get_type(); + let src = self.context.new_bitcast(self.location, src, new_src_type); + let res = self.context.new_call(self.location, atomic_function, &[dst, src, order]); + self.context.new_cast(self.location, res, src.get_type()) + } + + fn atomic_fence(&mut self, order: AtomicOrdering, scope: SynchronizationScope) { + let name = match scope { + SynchronizationScope::SingleThread => "__atomic_signal_fence", + SynchronizationScope::CrossThread => "__atomic_thread_fence", + }; + let thread_fence = self.context.get_builtin_function(name); + let order = self.context.new_rvalue_from_int(self.i32_type, order.to_gcc()); + self.llbb() + .add_eval(self.location, self.context.new_call(self.location, thread_fence, &[order])); + } + + fn set_invariant_load(&mut self, load: RValue<'gcc>) { + // NOTE: Hack to consider vtable function pointer as non-global-variable function pointer. + self.normal_function_addresses.borrow_mut().insert(load); + // TODO(antoyo) + } + + fn lifetime_start(&mut self, _ptr: RValue<'gcc>, _size: Size) { + // TODO(antoyo) + } + + fn lifetime_end(&mut self, _ptr: RValue<'gcc>, _size: Size) { + // TODO(antoyo) + } + + fn call( + &mut self, + typ: Type<'gcc>, + _fn_attrs: Option<&CodegenFnAttrs>, + fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>, + func: RValue<'gcc>, + args: &[RValue<'gcc>], + funclet: Option<&Funclet>, + _instance: Option<Instance<'tcx>>, + ) -> RValue<'gcc> { + // FIXME(antoyo): remove when having a proper API. + let gcc_func = unsafe { std::mem::transmute::<RValue<'gcc>, Function<'gcc>>(func) }; + let call = if self.functions.borrow().values().any(|value| *value == gcc_func) { + self.function_call(func, args, funclet) + } else { + // If it's a not function that was defined, it's a function pointer. + self.function_ptr_call(typ, func, args, funclet) + }; + if let Some(_fn_abi) = fn_abi { + // TODO(bjorn3): Apply function attributes + } + call + } + + fn tail_call( + &mut self, + _llty: Self::Type, + _fn_attrs: Option<&CodegenFnAttrs>, + _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, + _llfn: Self::Value, + _args: &[Self::Value], + _funclet: Option<&Self::Funclet>, + _instance: Option<Instance<'tcx>>, + ) { + // FIXME: implement support for explicit tail calls like rustc_codegen_llvm. + self.tcx.dcx().emit_fatal(errors::ExplicitTailCallsUnsupported); + } + + fn zext(&mut self, value: RValue<'gcc>, dest_typ: Type<'gcc>) -> RValue<'gcc> { + // FIXME(antoyo): this does not zero-extend. + self.gcc_int_cast(value, dest_typ) + } + + fn cx(&self) -> &CodegenCx<'gcc, 'tcx> { + self.cx + } + + fn apply_attrs_to_cleanup_callsite(&mut self, _llret: RValue<'gcc>) { + // FIXME(bjorn3): implement + } + + fn set_span(&mut self, _span: Span) {} + + fn from_immediate(&mut self, val: Self::Value) -> Self::Value { + if self.cx().val_ty(val) == self.cx().type_i1() { + self.zext(val, self.cx().type_i8()) + } else { + val + } + } + + fn to_immediate_scalar(&mut self, val: Self::Value, scalar: abi::Scalar) -> Self::Value { + if scalar.is_bool() { + return self.unchecked_utrunc(val, self.cx().type_i1()); + } + val + } + + fn fptoui_sat(&mut self, val: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + self.fptoint_sat(false, val, dest_ty) + } + + fn fptosi_sat(&mut self, val: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> { + self.fptoint_sat(true, val, dest_ty) + } +} + +impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { + fn fptoint_sat( + &mut self, + signed: bool, + val: RValue<'gcc>, + dest_ty: Type<'gcc>, + ) -> RValue<'gcc> { + let src_ty = self.cx.val_ty(val); + let (float_ty, int_ty) = if self.cx.type_kind(src_ty) == TypeKind::Vector { + assert_eq!(self.cx.vector_length(src_ty), self.cx.vector_length(dest_ty)); + (self.cx.element_type(src_ty), self.cx.element_type(dest_ty)) + } else { + (src_ty, dest_ty) + }; + + // FIXME(jistone): the following was originally the fallback SSA implementation, before LLVM 13 + // added native `fptosi.sat` and `fptoui.sat` conversions, but it was used by GCC as well. + // Now that LLVM always relies on its own, the code has been moved to GCC, but the comments are + // still LLVM-specific. This should be updated, and use better GCC specifics if possible. + + let int_width = self.cx.int_width(int_ty); + let float_width = self.cx.float_width(float_ty); + // LLVM's fpto[su]i returns undef when the input val is infinite, NaN, or does not fit into the + // destination integer type after rounding towards zero. This `undef` value can cause UB in + // safe code (see issue #10184), so we implement a saturating conversion on top of it: + // Semantically, the mathematical value of the input is rounded towards zero to the next + // mathematical integer, and then the result is clamped into the range of the destination + // integer type. Positive and negative infinity are mapped to the maximum and minimum value of + // the destination integer type. NaN is mapped to 0. + // + // Define f_min and f_max as the largest and smallest (finite) floats that are exactly equal to + // a value representable in int_ty. + // They are exactly equal to int_ty::{MIN,MAX} if float_ty has enough significand bits. + // Otherwise, int_ty::MAX must be rounded towards zero, as it is one less than a power of two. + // int_ty::MIN, however, is either zero or a negative power of two and is thus exactly + // representable. Note that this only works if float_ty's exponent range is sufficiently large. + // f16 or 256 bit integers would break this property. Right now the smallest float type is f32 + // with exponents ranging up to 127, which is barely enough for i128::MIN = -2^127. + // On the other hand, f_max works even if int_ty::MAX is greater than float_ty::MAX. Because + // we're rounding towards zero, we just get float_ty::MAX (which is always an integer). + // This already happens today with u128::MAX = 2^128 - 1 > f32::MAX. + let int_max = |signed: bool, int_width: u64| -> u128 { + let shift_amount = 128 - int_width; + if signed { i128::MAX as u128 >> shift_amount } else { u128::MAX >> shift_amount } + }; + let int_min = |signed: bool, int_width: u64| -> i128 { + if signed { i128::MIN >> (128 - int_width) } else { 0 } + }; + + let compute_clamp_bounds_single = |signed: bool, int_width: u64| -> (u128, u128) { + let rounded_min = + ieee::Single::from_i128_r(int_min(signed, int_width), Round::TowardZero); + assert_eq!(rounded_min.status, Status::OK); + let rounded_max = + ieee::Single::from_u128_r(int_max(signed, int_width), Round::TowardZero); + assert!(rounded_max.value.is_finite()); + (rounded_min.value.to_bits(), rounded_max.value.to_bits()) + }; + let compute_clamp_bounds_double = |signed: bool, int_width: u64| -> (u128, u128) { + let rounded_min = + ieee::Double::from_i128_r(int_min(signed, int_width), Round::TowardZero); + assert_eq!(rounded_min.status, Status::OK); + let rounded_max = + ieee::Double::from_u128_r(int_max(signed, int_width), Round::TowardZero); + assert!(rounded_max.value.is_finite()); + (rounded_min.value.to_bits(), rounded_max.value.to_bits()) + }; + // To implement saturation, we perform the following steps: + // + // 1. Cast val to an integer with fpto[su]i. This may result in undef. + // 2. Compare val to f_min and f_max, and use the comparison results to select: + // a) int_ty::MIN if val < f_min or val is NaN + // b) int_ty::MAX if val > f_max + // c) the result of fpto[su]i otherwise + // 3. If val is NaN, return 0.0, otherwise return the result of step 2. + // + // This avoids resulting undef because values in range [f_min, f_max] by definition fit into the + // destination type. It creates an undef temporary, but *producing* undef is not UB. Our use of + // undef does not introduce any non-determinism either. + // More importantly, the above procedure correctly implements saturating conversion. + // Proof (sketch): + // If val is NaN, 0 is returned by definition. + // Otherwise, val is finite or infinite and thus can be compared with f_min and f_max. + // This yields three cases to consider: + // (1) if val in [f_min, f_max], the result of fpto[su]i is returned, which agrees with + // saturating conversion for inputs in that range. + // (2) if val > f_max, then val is larger than int_ty::MAX. This holds even if f_max is rounded + // (i.e., if f_max < int_ty::MAX) because in those cases, nextUp(f_max) is already larger + // than int_ty::MAX. Because val is larger than int_ty::MAX, the return value of int_ty::MAX + // is correct. + // (3) if val < f_min, then val is smaller than int_ty::MIN. As shown earlier, f_min exactly equals + // int_ty::MIN and therefore the return value of int_ty::MIN is correct. + // QED. + + let float_bits_to_llval = |bx: &mut Self, bits| { + let bits_llval = match float_width { + 32 => bx.cx().const_u32(bits as u32), + 64 => bx.cx().const_u64(bits as u64), + n => bug!("unsupported float width {}", n), + }; + bx.bitcast(bits_llval, float_ty) + }; + let (f_min, f_max) = match float_width { + 32 => compute_clamp_bounds_single(signed, int_width), + 64 => compute_clamp_bounds_double(signed, int_width), + n => bug!("unsupported float width {}", n), + }; + let f_min = float_bits_to_llval(self, f_min); + let f_max = float_bits_to_llval(self, f_max); + let int_max = self.cx.const_uint_big(int_ty, int_max(signed, int_width)); + let int_min = self.cx.const_uint_big(int_ty, int_min(signed, int_width) as u128); + let zero = self.cx.const_uint(int_ty, 0); + + // If we're working with vectors, constants must be "splatted": the constant is duplicated + // into each lane of the vector. The algorithm stays the same, we are just using the + // same constant across all lanes. + let maybe_splat = |bx: &mut Self, val| { + if bx.cx().type_kind(dest_ty) == TypeKind::Vector { + bx.vector_splat(bx.vector_length(dest_ty), val) + } else { + val + } + }; + let f_min = maybe_splat(self, f_min); + let f_max = maybe_splat(self, f_max); + let int_max = maybe_splat(self, int_max); + let int_min = maybe_splat(self, int_min); + let zero = maybe_splat(self, zero); + + // Step 1 ... + let fptosui_result = + if signed { self.fptosi(val, dest_ty) } else { self.fptoui(val, dest_ty) }; + let less_or_nan = self.fcmp(RealPredicate::RealULT, val, f_min); + let greater = self.fcmp(RealPredicate::RealOGT, val, f_max); + + // Step 2: We use two comparisons and two selects, with %s1 being the + // result: + // %less_or_nan = fcmp ult %val, %f_min + // %greater = fcmp olt %val, %f_max + // %s0 = select %less_or_nan, int_ty::MIN, %fptosi_result + // %s1 = select %greater, int_ty::MAX, %s0 + // Note that %less_or_nan uses an *unordered* comparison. This + // comparison is true if the operands are not comparable (i.e., if val is + // NaN). The unordered comparison ensures that s1 becomes int_ty::MIN if + // val is NaN. + // + // Performance note: Unordered comparison can be lowered to a "flipped" + // comparison and a negation, and the negation can be merged into the + // select. Therefore, it not necessarily any more expensive than an + // ordered ("normal") comparison. Whether these optimizations will be + // performed is ultimately up to the backend, but at least x86 does + // perform them. + let s0 = self.select(less_or_nan, int_min, fptosui_result); + let s1 = self.select(greater, int_max, s0); + + // Step 3: NaN replacement. + // For unsigned types, the above step already yielded int_ty::MIN == 0 if val is NaN. + // Therefore we only need to execute this step for signed integer types. + if signed { + // LLVM has no isNaN predicate, so we use (val == val) instead + let cmp = self.fcmp(RealPredicate::RealOEQ, val, val); + self.select(cmp, s1, zero) + } else { + s1 + } + } + + #[cfg(feature = "master")] + pub fn shuffle_vector( + &mut self, + v1: RValue<'gcc>, + v2: RValue<'gcc>, + mask: RValue<'gcc>, + ) -> RValue<'gcc> { + // NOTE: if the `mask` is a constant value, the following code will copy it in many places, + // which will make GCC create a lot (+4000) local variables in some cases. + // So we assign it to an explicit local variable once to avoid this. + let func = self.current_func(); + let mask_var = func.new_local(self.location, mask.get_type(), "mask"); + let block = self.block; + block.add_assignment(self.location, mask_var, mask); + let mask = mask_var.to_rvalue(); + + // TODO(antoyo): use a recursive unqualified() here. + let vector_type = v1.get_type().unqualified().dyncast_vector().expect("vector type"); + let element_type = vector_type.get_element_type(); + let vec_num_units = vector_type.get_num_units(); + + let mask_element_type = if element_type.is_integral() { + element_type + } else { + #[cfg(feature = "master")] + { + self.cx.type_ix(element_type.get_size() as u64 * 8) + } + #[cfg(not(feature = "master"))] + self.int_type + }; + + // NOTE: this condition is needed because we call shuffle_vector in the implementation of + // simd_gather. + let mut mask_elements = if let Some(vector_type) = mask.get_type().dyncast_vector() { + let mask_num_units = vector_type.get_num_units(); + let mut mask_elements = vec![]; + for i in 0..mask_num_units { + let index = self.context.new_rvalue_from_long(self.cx.type_u32(), i as _); + mask_elements.push(self.context.new_cast( + self.location, + self.extract_element(mask, index).to_rvalue(), + mask_element_type, + )); + } + mask_elements + } else { + let struct_type = mask.get_type().is_struct().expect("mask should be of struct type"); + let mask_num_units = struct_type.get_field_count(); + let mut mask_elements = vec![]; + for i in 0..mask_num_units { + let field = struct_type.get_field(i as i32); + mask_elements.push(self.context.new_cast( + self.location, + mask.access_field(self.location, field).to_rvalue(), + mask_element_type, + )); + } + mask_elements + }; + let mask_num_units = mask_elements.len(); + + // NOTE: the mask needs to be the same length as the input vectors, so add the missing + // elements in the mask if needed. + for _ in mask_num_units..vec_num_units { + mask_elements.push(self.context.new_rvalue_zero(mask_element_type)); + } + + let result_type = self.context.new_vector_type(element_type, mask_num_units as u64); + let (v1, v2) = if vec_num_units < mask_num_units { + // NOTE: the mask needs to be the same length as the input vectors, so join the 2 + // vectors and create a dummy second vector. + let mut elements = vec![]; + for i in 0..vec_num_units { + elements.push( + self.context + .new_vector_access( + self.location, + v1, + self.context.new_rvalue_from_int(self.int_type, i as i32), + ) + .to_rvalue(), + ); + } + for i in 0..(mask_num_units - vec_num_units) { + elements.push( + self.context + .new_vector_access( + self.location, + v2, + self.context.new_rvalue_from_int(self.int_type, i as i32), + ) + .to_rvalue(), + ); + } + let v1 = self.context.new_rvalue_from_vector(self.location, result_type, &elements); + let zero = self.context.new_rvalue_zero(element_type); + let v2 = self.context.new_rvalue_from_vector( + self.location, + result_type, + &vec![zero; mask_num_units], + ); + (v1, v2) + } else { + (v1, v2) + }; + + let new_mask_num_units = std::cmp::max(mask_num_units, vec_num_units); + let mask_type = self.context.new_vector_type(mask_element_type, new_mask_num_units as u64); + let mask = self.context.new_rvalue_from_vector(self.location, mask_type, &mask_elements); + let result = self.context.new_rvalue_vector_perm(self.location, v1, v2, mask); + + if vec_num_units != mask_num_units { + // NOTE: if padding was added, only select the number of elements of the masks to + // remove that padding in the result. + let mut elements = vec![]; + for i in 0..mask_num_units { + elements.push( + self.context + .new_vector_access( + self.location, + result, + self.context.new_rvalue_from_int(self.int_type, i as i32), + ) + .to_rvalue(), + ); + } + self.context.new_rvalue_from_vector(self.location, result_type, &elements) + } else { + result + } + } + + #[cfg(not(feature = "master"))] + pub fn shuffle_vector( + &mut self, + _v1: RValue<'gcc>, + _v2: RValue<'gcc>, + _mask: RValue<'gcc>, + ) -> RValue<'gcc> { + unimplemented!(); + } + + #[cfg(feature = "master")] + pub fn vector_reduce<F>(&mut self, src: RValue<'gcc>, op: F) -> RValue<'gcc> + where + F: Fn(RValue<'gcc>, RValue<'gcc>, &'gcc Context<'gcc>) -> RValue<'gcc>, + { + let vector_type = src.get_type().unqualified().dyncast_vector().expect("vector type"); + let element_type = vector_type.get_element_type(); + let mask_element_type = self.type_ix(element_type.get_size() as u64 * 8); + let element_count = vector_type.get_num_units(); + let mut vector_elements = vec![]; + for i in 0..element_count { + vector_elements.push(i); + } + let mask_type = self.context.new_vector_type(mask_element_type, element_count as u64); + let mut shift = 1; + let mut res = src; + while shift < element_count { + let vector_elements: Vec<_> = vector_elements + .iter() + .map(|i| { + self.context.new_rvalue_from_int( + mask_element_type, + ((i + shift) % element_count) as i32, + ) + }) + .collect(); + let mask = + self.context.new_rvalue_from_vector(self.location, mask_type, &vector_elements); + let shifted = self.context.new_rvalue_vector_perm(self.location, res, res, mask); + shift *= 2; + res = op(res, shifted, self.context); + } + self.context + .new_vector_access(self.location, res, self.context.new_rvalue_zero(self.int_type)) + .to_rvalue() + } + + #[cfg(not(feature = "master"))] + pub fn vector_reduce<F>(&mut self, _src: RValue<'gcc>, _op: F) -> RValue<'gcc> + where + F: Fn(RValue<'gcc>, RValue<'gcc>, &'gcc Context<'gcc>) -> RValue<'gcc>, + { + unimplemented!(); + } + + pub fn vector_reduce_op(&mut self, src: RValue<'gcc>, op: BinaryOp) -> RValue<'gcc> { + let loc = self.location; + self.vector_reduce(src, |a, b, context| context.new_binary_op(loc, op, a.get_type(), a, b)) + } + + pub fn vector_reduce_fadd_reassoc( + &mut self, + _acc: RValue<'gcc>, + _src: RValue<'gcc>, + ) -> RValue<'gcc> { + unimplemented!(); + } + + #[cfg(feature = "master")] + pub fn vector_reduce_fadd(&mut self, acc: RValue<'gcc>, src: RValue<'gcc>) -> RValue<'gcc> { + let vector_type = src.get_type().unqualified().dyncast_vector().expect("vector type"); + let element_count = vector_type.get_num_units(); + (0..element_count) + .map(|i| { + self.context + .new_vector_access( + self.location, + src, + self.context.new_rvalue_from_int(self.int_type, i as _), + ) + .to_rvalue() + }) + .fold(acc, |x, i| x + i) + } + + #[cfg(not(feature = "master"))] + pub fn vector_reduce_fadd(&mut self, _acc: RValue<'gcc>, _src: RValue<'gcc>) -> RValue<'gcc> { + unimplemented!(); + } + + pub fn vector_reduce_fmul_reassoc( + &mut self, + _acc: RValue<'gcc>, + _src: RValue<'gcc>, + ) -> RValue<'gcc> { + unimplemented!(); + } + + #[cfg(feature = "master")] + pub fn vector_reduce_fmul(&mut self, acc: RValue<'gcc>, src: RValue<'gcc>) -> RValue<'gcc> { + let vector_type = src.get_type().unqualified().dyncast_vector().expect("vector type"); + let element_count = vector_type.get_num_units(); + (0..element_count) + .map(|i| { + self.context + .new_vector_access( + self.location, + src, + self.context.new_rvalue_from_int(self.int_type, i as _), + ) + .to_rvalue() + }) + .fold(acc, |x, i| x * i) + } + + #[cfg(not(feature = "master"))] + pub fn vector_reduce_fmul(&mut self, _acc: RValue<'gcc>, _src: RValue<'gcc>) -> RValue<'gcc> { + unimplemented!() + } + + // Inspired by Hacker's Delight min implementation. + pub fn vector_reduce_min(&mut self, src: RValue<'gcc>) -> RValue<'gcc> { + let loc = self.location; + self.vector_reduce(src, |a, b, context| { + let differences_or_zeros = difference_or_zero(loc, a, b, context); + context.new_binary_op(loc, BinaryOp::Plus, b.get_type(), b, differences_or_zeros) + }) + } + + // Inspired by Hacker's Delight max implementation. + pub fn vector_reduce_max(&mut self, src: RValue<'gcc>) -> RValue<'gcc> { + let loc = self.location; + self.vector_reduce(src, |a, b, context| { + let differences_or_zeros = difference_or_zero(loc, a, b, context); + context.new_binary_op(loc, BinaryOp::Minus, a.get_type(), a, differences_or_zeros) + }) + } + + fn vector_extremum( + &mut self, + a: RValue<'gcc>, + b: RValue<'gcc>, + direction: ExtremumOperation, + ) -> RValue<'gcc> { + let vector_type = a.get_type(); + + // mask out the NaNs in b and replace them with the corresponding lane in a, so when a and + // b get compared & spliced together, we get the numeric values instead of NaNs. + let b_nan_mask = self.context.new_comparison(self.location, ComparisonOp::NotEquals, b, b); + let mask_type = b_nan_mask.get_type(); + let b_nan_mask_inverted = + self.context.new_unary_op(self.location, UnaryOp::BitwiseNegate, mask_type, b_nan_mask); + let a_cast = self.context.new_bitcast(self.location, a, mask_type); + let b_cast = self.context.new_bitcast(self.location, b, mask_type); + let res = (b_nan_mask & a_cast) | (b_nan_mask_inverted & b_cast); + let b = self.context.new_bitcast(self.location, res, vector_type); + + // now do the actual comparison + let comparison_op = match direction { + ExtremumOperation::Min => ComparisonOp::LessThan, + ExtremumOperation::Max => ComparisonOp::GreaterThan, + }; + let cmp = self.context.new_comparison(self.location, comparison_op, a, b); + let cmp_inverted = + self.context.new_unary_op(self.location, UnaryOp::BitwiseNegate, cmp.get_type(), cmp); + let res = (cmp & a_cast) | (cmp_inverted & res); + self.context.new_bitcast(self.location, res, vector_type) + } + + pub fn vector_fmin(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.vector_extremum(a, b, ExtremumOperation::Min) + } + + #[cfg(feature = "master")] + pub fn vector_reduce_fmin(&mut self, src: RValue<'gcc>) -> RValue<'gcc> { + let vector_type = src.get_type().unqualified().dyncast_vector().expect("vector type"); + let element_count = vector_type.get_num_units(); + let mut acc = self + .context + .new_vector_access(self.location, src, self.context.new_rvalue_zero(self.int_type)) + .to_rvalue(); + for i in 1..element_count { + let elem = self + .context + .new_vector_access( + self.location, + src, + self.context.new_rvalue_from_int(self.int_type, i as _), + ) + .to_rvalue(); + let cmp = self.context.new_comparison(self.location, ComparisonOp::LessThan, acc, elem); + acc = self.select(cmp, acc, elem); + } + acc + } + + #[cfg(not(feature = "master"))] + pub fn vector_reduce_fmin(&mut self, _src: RValue<'gcc>) -> RValue<'gcc> { + unimplemented!(); + } + + pub fn vector_fmax(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.vector_extremum(a, b, ExtremumOperation::Max) + } + + #[cfg(feature = "master")] + pub fn vector_reduce_fmax(&mut self, src: RValue<'gcc>) -> RValue<'gcc> { + let vector_type = src.get_type().unqualified().dyncast_vector().expect("vector type"); + let element_count = vector_type.get_num_units(); + let mut acc = self + .context + .new_vector_access(self.location, src, self.context.new_rvalue_zero(self.int_type)) + .to_rvalue(); + for i in 1..element_count { + let elem = self + .context + .new_vector_access( + self.location, + src, + self.context.new_rvalue_from_int(self.int_type, i as _), + ) + .to_rvalue(); + let cmp = + self.context.new_comparison(self.location, ComparisonOp::GreaterThan, acc, elem); + acc = self.select(cmp, acc, elem); + } + acc + } + + #[cfg(not(feature = "master"))] + pub fn vector_reduce_fmax(&mut self, _src: RValue<'gcc>) -> RValue<'gcc> { + unimplemented!(); + } + + pub fn vector_select( + &mut self, + cond: RValue<'gcc>, + then_val: RValue<'gcc>, + else_val: RValue<'gcc>, + ) -> RValue<'gcc> { + // cond is a vector of integers, not of bools. + let vector_type = cond.get_type().unqualified().dyncast_vector().expect("vector type"); + let num_units = vector_type.get_num_units(); + let element_type = vector_type.get_element_type(); + + #[cfg(feature = "master")] + let (cond, element_type) = { + // TODO(antoyo): dyncast_vector should not require a call to unqualified. + let then_val_vector_type = + then_val.get_type().unqualified().dyncast_vector().expect("vector type"); + let then_val_element_type = then_val_vector_type.get_element_type(); + let then_val_element_size = then_val_element_type.get_size(); + + // NOTE: the mask needs to be of the same size as the other arguments in order for the & + // operation to work. + if then_val_element_size != element_type.get_size() { + let new_element_type = self.type_ix(then_val_element_size as u64 * 8); + let new_vector_type = + self.context.new_vector_type(new_element_type, num_units as u64); + let cond = self.context.convert_vector(self.location, cond, new_vector_type); + (cond, new_element_type) + } else { + (cond, element_type) + } + }; + + let cond_type = cond.get_type(); + + let zeros = vec![self.context.new_rvalue_zero(element_type); num_units]; + let zeros = self.context.new_rvalue_from_vector(self.location, cond_type, &zeros); + + let result_type = then_val.get_type(); + + let masks = + self.context.new_comparison(self.location, ComparisonOp::NotEquals, cond, zeros); + // NOTE: masks is a vector of integers, but the values can be vectors of floats, so use bitcast to make + // the & operation work. + let then_val = self.bitcast_if_needed(then_val, masks.get_type()); + let then_vals = masks & then_val; + + let minus_ones = vec![self.context.new_rvalue_from_int(element_type, -1); num_units]; + let minus_ones = self.context.new_rvalue_from_vector(self.location, cond_type, &minus_ones); + let inverted_masks = masks ^ minus_ones; + // NOTE: sometimes, the type of else_val can be different than the type of then_val in + // libgccjit (vector of int vs vector of int32_t), but they should be the same for the AND + // operation to work. + // TODO: remove bitcast now that vector types can be compared? + let else_val = self.context.new_bitcast(self.location, else_val, then_val.get_type()); + let else_vals = inverted_masks & else_val; + + let res = then_vals | else_vals; + self.bitcast_if_needed(res, result_type) + } +} + +fn difference_or_zero<'gcc>( + loc: Option<Location<'gcc>>, + a: RValue<'gcc>, + b: RValue<'gcc>, + context: &'gcc Context<'gcc>, +) -> RValue<'gcc> { + let difference = a - b; + let masks = context.new_comparison(loc, ComparisonOp::GreaterThanEquals, b, a); + // NOTE: masks is a vector of integers, but the values can be vectors of floats, so use bitcast to make + // the & operation work. + let a_type = a.get_type(); + let masks = + if masks.get_type() != a_type { context.new_bitcast(loc, masks, a_type) } else { masks }; + difference & masks +} + +impl<'a, 'gcc, 'tcx> StaticBuilderMethods for Builder<'a, 'gcc, 'tcx> { + fn get_static(&mut self, def_id: DefId) -> RValue<'gcc> { + // Forward to the `get_static` method of `CodegenCx` + self.cx().get_static(def_id).get_address(self.location) + } +} + +impl<'tcx> HasTypingEnv<'tcx> for Builder<'_, '_, 'tcx> { + fn typing_env(&self) -> ty::TypingEnv<'tcx> { + self.cx.typing_env() + } +} + +impl<'tcx> HasTargetSpec for Builder<'_, '_, 'tcx> { + fn target_spec(&self) -> &Target { + self.cx.target_spec() + } +} + +impl<'tcx> HasX86AbiOpt for Builder<'_, '_, 'tcx> { + fn x86_abi_opt(&self) -> X86Abi { + self.cx.x86_abi_opt() + } +} + +pub trait ToGccComp { + fn to_gcc_comparison(&self) -> ComparisonOp; +} + +impl ToGccComp for IntPredicate { + fn to_gcc_comparison(&self) -> ComparisonOp { + match *self { + IntPredicate::IntEQ => ComparisonOp::Equals, + IntPredicate::IntNE => ComparisonOp::NotEquals, + IntPredicate::IntUGT => ComparisonOp::GreaterThan, + IntPredicate::IntUGE => ComparisonOp::GreaterThanEquals, + IntPredicate::IntULT => ComparisonOp::LessThan, + IntPredicate::IntULE => ComparisonOp::LessThanEquals, + IntPredicate::IntSGT => ComparisonOp::GreaterThan, + IntPredicate::IntSGE => ComparisonOp::GreaterThanEquals, + IntPredicate::IntSLT => ComparisonOp::LessThan, + IntPredicate::IntSLE => ComparisonOp::LessThanEquals, + } + } +} + +impl ToGccComp for RealPredicate { + fn to_gcc_comparison(&self) -> ComparisonOp { + // TODO(antoyo): check that ordered vs non-ordered is respected. + match *self { + RealPredicate::RealPredicateFalse => unreachable!(), + RealPredicate::RealOEQ => ComparisonOp::Equals, + RealPredicate::RealOGT => ComparisonOp::GreaterThan, + RealPredicate::RealOGE => ComparisonOp::GreaterThanEquals, + RealPredicate::RealOLT => ComparisonOp::LessThan, + RealPredicate::RealOLE => ComparisonOp::LessThanEquals, + RealPredicate::RealONE => ComparisonOp::NotEquals, + RealPredicate::RealORD => unreachable!(), + RealPredicate::RealUNO => unreachable!(), + RealPredicate::RealUEQ => ComparisonOp::Equals, + RealPredicate::RealUGT => ComparisonOp::GreaterThan, + RealPredicate::RealUGE => ComparisonOp::GreaterThan, + RealPredicate::RealULT => ComparisonOp::LessThan, + RealPredicate::RealULE => ComparisonOp::LessThan, + RealPredicate::RealUNE => ComparisonOp::NotEquals, + RealPredicate::RealPredicateTrue => unreachable!(), + } + } +} + +#[repr(C)] +#[allow(non_camel_case_types)] +enum MemOrdering { + __ATOMIC_RELAXED, + __ATOMIC_CONSUME, + __ATOMIC_ACQUIRE, + __ATOMIC_RELEASE, + __ATOMIC_ACQ_REL, + __ATOMIC_SEQ_CST, +} + +trait ToGccOrdering { + fn to_gcc(self) -> i32; +} + +impl ToGccOrdering for AtomicOrdering { + fn to_gcc(self) -> i32 { + use MemOrdering::*; + + let ordering = match self { + AtomicOrdering::Relaxed => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same. + AtomicOrdering::Acquire => __ATOMIC_ACQUIRE, + AtomicOrdering::Release => __ATOMIC_RELEASE, + AtomicOrdering::AcqRel => __ATOMIC_ACQ_REL, + AtomicOrdering::SeqCst => __ATOMIC_SEQ_CST, + }; + ordering as i32 + } +} + +// Needed because gcc 12 `get_size()` doesn't work on pointers. +#[cfg(feature = "master")] +fn get_maybe_pointer_size(value: RValue<'_>) -> u32 { + value.get_type().get_size() +} + +#[cfg(not(feature = "master"))] +fn get_maybe_pointer_size(value: RValue<'_>) -> u32 { + let type_ = value.get_type(); + if type_.get_pointee().is_some() { size_of::<*const ()>() as _ } else { type_.get_size() } +} diff --git a/compiler/rustc_codegen_gcc/src/callee.rs b/compiler/rustc_codegen_gcc/src/callee.rs new file mode 100644 index 00000000000..8487a85bd03 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/callee.rs @@ -0,0 +1,151 @@ +#[cfg(feature = "master")] +use gccjit::{FnAttribute, Visibility}; +use gccjit::{Function, FunctionType}; +use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt}; +use rustc_middle::ty::{self, Instance, TypeVisitableExt}; + +use crate::attributes; +use crate::context::CodegenCx; + +/// Codegens a reference to a fn/method item, monomorphizing and +/// inlining as it goes. +/// +/// # Parameters +/// +/// - `cx`: the crate context +/// - `instance`: the instance to be instantiated +pub fn get_fn<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, instance: Instance<'tcx>) -> Function<'gcc> { + let tcx = cx.tcx(); + + assert!(!instance.args.has_infer()); + assert!(!instance.args.has_escaping_bound_vars()); + + let sym = tcx.symbol_name(instance).name; + + if let Some(&func) = cx.function_instances.borrow().get(&instance) { + return func; + } + + let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty()); + + let func = if let Some(_func) = cx.get_declared_value(sym) { + // FIXME(antoyo): we never reach this because get_declared_value only returns global variables + // and here we try to get a function. + unreachable!(); + /* + // Create a fn pointer with the new signature. + let ptrtype = fn_abi.ptr_to_gcc_type(cx); + + // This is subtle and surprising, but sometimes we have to bitcast + // the resulting fn pointer. The reason has to do with external + // functions. If you have two crates that both bind the same C + // library, they may not use precisely the same types: for + // example, they will probably each declare their own structs, + // which are distinct types from LLVM's point of view (nominal + // types). + // + // Now, if those two crates are linked into an application, and + // they contain inlined code, you can wind up with a situation + // where both of those functions wind up being loaded into this + // application simultaneously. In that case, the same function + // (from LLVM's point of view) requires two types. But of course + // LLVM won't allow one function to have two types. + // + // What we currently do, therefore, is declare the function with + // one of the two types (whichever happens to come first) and then + // bitcast as needed when the function is referenced to make sure + // it has the type we expect. + // + // This can occur on either a crate-local or crate-external + // reference. It also occurs when testing libcore and in some + // other weird situations. Annoying. + if cx.val_ty(func) != ptrtype { + // TODO(antoyo): cast the pointer. + func + } + else { + func + }*/ + } else { + cx.linkage.set(FunctionType::Extern); + let func = cx.declare_fn(sym, fn_abi); + + attributes::from_fn_attrs(cx, func, instance); + + #[cfg(feature = "master")] + { + let instance_def_id = instance.def_id(); + + // TODO(antoyo): set linkage and attributes. + + // Apply an appropriate linkage/visibility value to our item that we + // just declared. + // + // This is sort of subtle. Inside our codegen unit we started off + // compilation by predefining all our own `MonoItem` instances. That + // is, everything we're codegenning ourselves is already defined. That + // means that anything we're actually codegenning in this codegen unit + // will have hit the above branch in `get_declared_value`. As a result, + // we're guaranteed here that we're declaring a symbol that won't get + // defined, or in other words we're referencing a value from another + // codegen unit or even another crate. + // + // So because this is a foreign value we blanket apply an external + // linkage directive because it's coming from a different object file. + // The visibility here is where it gets tricky. This symbol could be + // referencing some foreign crate or foreign library (an `extern` + // block) in which case we want to leave the default visibility. We may + // also, though, have multiple codegen units. It could be a + // monomorphization, in which case its expected visibility depends on + // whether we are sharing generics or not. The important thing here is + // that the visibility we apply to the declaration is the same one that + // has been applied to the definition (wherever that definition may be). + let is_generic = instance.args.non_erasable_generics().next().is_some(); + + let is_hidden = if is_generic { + // This is a monomorphization of a generic function. + if !(cx.tcx.sess.opts.share_generics() + || tcx.codegen_instance_attrs(instance.def).inline + == rustc_hir::attrs::InlineAttr::Never) + { + // When not sharing generics, all instances are in the same + // crate and have hidden visibility. + true + } else if let Some(instance_def_id) = instance_def_id.as_local() { + // This is a monomorphization of a generic function + // defined in the current crate. It is hidden if: + // - the definition is unreachable for downstream + // crates, or + // - the current crate does not re-export generics + // (because the crate is a C library or executable) + cx.tcx.is_unreachable_local_definition(instance_def_id) + || !cx.tcx.local_crate_exports_generics() + } else { + // This is a monomorphization of a generic function + // defined in an upstream crate. It is hidden if: + // - it is instantiated in this crate, and + // - the current crate does not re-export generics + instance.upstream_monomorphization(tcx).is_none() + && !cx.tcx.local_crate_exports_generics() + } + } else { + // This is a non-generic function. It is hidden if: + // - it is instantiated in the local crate, and + // - it is defined an upstream crate (non-local), or + // - it is not reachable + cx.tcx.is_codegened_item(instance_def_id) + && (!instance_def_id.is_local() + || !cx.tcx.is_reachable_non_generic(instance_def_id)) + }; + if is_hidden { + func.add_attribute(FnAttribute::Visibility(Visibility::Hidden)); + } + } + + func + }; + + cx.function_instances.borrow_mut().insert(instance, func); + + func +} diff --git a/compiler/rustc_codegen_gcc/src/common.rs b/compiler/rustc_codegen_gcc/src/common.rs new file mode 100644 index 00000000000..28848ca6184 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/common.rs @@ -0,0 +1,525 @@ +use gccjit::{LValue, RValue, ToRValue, Type}; +use rustc_abi::Primitive::Pointer; +use rustc_abi::{self as abi, HasDataLayout}; +use rustc_codegen_ssa::traits::{ + BaseTypeCodegenMethods, ConstCodegenMethods, MiscCodegenMethods, StaticCodegenMethods, +}; +use rustc_middle::mir::Mutability; +use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; +use rustc_middle::ty::layout::LayoutOf; + +use crate::context::CodegenCx; +use crate::type_of::LayoutGccExt; + +impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { + pub fn const_ptrcast(&self, val: RValue<'gcc>, ty: Type<'gcc>) -> RValue<'gcc> { + self.context.new_cast(None, val, ty) + } + + pub fn const_bytes(&self, bytes: &[u8]) -> RValue<'gcc> { + bytes_in_context(self, bytes) + } + + fn global_string(&self, string: &str) -> LValue<'gcc> { + // TODO(antoyo): handle non-null-terminated strings. + let string = self.context.new_string_literal(string); + let sym = self.generate_local_symbol_name("str"); + let global = self.declare_private_global(&sym, self.val_ty(string)); + global.global_set_initializer_rvalue(string); + global + // TODO(antoyo): set linkage. + } + + pub fn const_bitcast(&self, value: RValue<'gcc>, typ: Type<'gcc>) -> RValue<'gcc> { + if value.get_type() == self.bool_type.make_pointer() + && let Some(pointee) = typ.get_pointee() + && pointee.dyncast_vector().is_some() + { + panic!() + } + // NOTE: since bitcast makes a value non-constant, don't bitcast if not necessary as some + // SIMD builtins require a constant value. + self.bitcast_if_needed(value, typ) + } +} + +pub fn bytes_in_context<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, bytes: &[u8]) -> RValue<'gcc> { + // Instead of always using an array of bytes, use an array of larger integers of target endianness + // if possible. This reduces the amount of `rvalues` we use, which reduces memory usage significantly. + // + // FIXME(FractalFir): Consider using `global_set_initializer` instead. Before this is done, we need to confirm that + // `global_set_initializer` is more memory efficient than the current solution. + // `global_set_initializer` calls `global_set_initializer_rvalue` under the hood - does it generate an array of rvalues, + // or is it using a more efficient representation? + match bytes.len() % 8 { + 0 => { + let context = &cx.context; + let byte_type = context.new_type::<u64>(); + let typ = context.new_array_type(None, byte_type, bytes.len() as u64 / 8); + let elements: Vec<_> = bytes + .chunks_exact(8) + .map(|arr| { + let arr: [u8; 8] = arr.try_into().unwrap(); + context.new_rvalue_from_long( + byte_type, + // Since we are representing arbitrary byte runs as integers, we need to follow the target + // endianness. + match cx.sess().target.options.endian { + rustc_abi::Endian::Little => u64::from_le_bytes(arr) as i64, + rustc_abi::Endian::Big => u64::from_be_bytes(arr) as i64, + }, + ) + }) + .collect(); + context.new_array_constructor(None, typ, &elements) + } + 4 => { + let context = &cx.context; + let byte_type = context.new_type::<u32>(); + let typ = context.new_array_type(None, byte_type, bytes.len() as u64 / 4); + let elements: Vec<_> = bytes + .chunks_exact(4) + .map(|arr| { + let arr: [u8; 4] = arr.try_into().unwrap(); + context.new_rvalue_from_int( + byte_type, + match cx.sess().target.options.endian { + rustc_abi::Endian::Little => u32::from_le_bytes(arr) as i32, + rustc_abi::Endian::Big => u32::from_be_bytes(arr) as i32, + }, + ) + }) + .collect(); + context.new_array_constructor(None, typ, &elements) + } + _ => { + let context = cx.context; + let byte_type = context.new_type::<u8>(); + let typ = context.new_array_type(None, byte_type, bytes.len() as u64); + let elements: Vec<_> = bytes + .iter() + .map(|&byte| context.new_rvalue_from_int(byte_type, byte as i32)) + .collect(); + context.new_array_constructor(None, typ, &elements) + } + } +} + +pub fn type_is_pointer(typ: Type<'_>) -> bool { + typ.get_pointee().is_some() +} + +impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> { + fn const_null(&self, typ: Type<'gcc>) -> RValue<'gcc> { + if type_is_pointer(typ) { self.context.new_null(typ) } else { self.const_int(typ, 0) } + } + + fn const_undef(&self, typ: Type<'gcc>) -> RValue<'gcc> { + let local = self.current_func.borrow().expect("func").new_local(None, typ, "undefined"); + local.to_rvalue() + } + + fn const_poison(&self, typ: Type<'gcc>) -> RValue<'gcc> { + // No distinction between undef and poison. + self.const_undef(typ) + } + + fn const_bool(&self, val: bool) -> RValue<'gcc> { + self.const_uint(self.type_i1(), val as u64) + } + + fn const_i8(&self, i: i8) -> RValue<'gcc> { + self.const_int(self.type_i8(), i as i64) + } + + fn const_i16(&self, i: i16) -> RValue<'gcc> { + self.const_int(self.type_i16(), i as i64) + } + + fn const_i32(&self, i: i32) -> RValue<'gcc> { + self.const_int(self.type_i32(), i as i64) + } + + fn const_int(&self, typ: Type<'gcc>, int: i64) -> RValue<'gcc> { + self.gcc_int(typ, int) + } + + fn const_u8(&self, i: u8) -> RValue<'gcc> { + self.const_uint(self.type_u8(), i as u64) + } + + fn const_u32(&self, i: u32) -> RValue<'gcc> { + self.const_uint(self.type_u32(), i as u64) + } + + fn const_u64(&self, i: u64) -> RValue<'gcc> { + self.const_uint(self.type_u64(), i) + } + + fn const_u128(&self, i: u128) -> RValue<'gcc> { + self.const_uint_big(self.type_u128(), i) + } + + fn const_usize(&self, i: u64) -> RValue<'gcc> { + let bit_size = self.data_layout().pointer_size().bits(); + if bit_size < 64 { + // make sure it doesn't overflow + assert!(i < (1 << bit_size)); + } + + self.const_uint(self.usize_type, i) + } + + fn const_uint(&self, typ: Type<'gcc>, int: u64) -> RValue<'gcc> { + self.gcc_uint(typ, int) + } + + fn const_uint_big(&self, typ: Type<'gcc>, num: u128) -> RValue<'gcc> { + self.gcc_uint_big(typ, num) + } + + fn const_real(&self, typ: Type<'gcc>, val: f64) -> RValue<'gcc> { + self.context.new_rvalue_from_double(typ, val) + } + + fn const_str(&self, s: &str) -> (RValue<'gcc>, RValue<'gcc>) { + let mut const_str_cache = self.const_str_cache.borrow_mut(); + let str_global = const_str_cache.get(s).copied().unwrap_or_else(|| { + let g = self.global_string(s); + const_str_cache.insert(s.to_owned(), g); + g + }); + let len = s.len(); + let cs = self.const_ptrcast( + str_global.get_address(None), + self.type_ptr_to(self.layout_of(self.tcx.types.str_).gcc_type(self)), + ); + (cs, self.const_usize(len as u64)) + } + + fn const_struct(&self, values: &[RValue<'gcc>], packed: bool) -> RValue<'gcc> { + let fields: Vec<_> = values.iter().map(|value| value.get_type()).collect(); + // TODO(antoyo): cache the type? It's anonymous, so probably not. + let typ = self.type_struct(&fields, packed); + let struct_type = typ.is_struct().expect("struct type"); + self.context.new_struct_constructor(None, struct_type.as_type(), None, values) + } + + fn const_vector(&self, values: &[RValue<'gcc>]) -> RValue<'gcc> { + let typ = self.type_vector(values[0].get_type(), values.len() as u64); + self.context.new_rvalue_from_vector(None, typ, values) + } + + fn const_to_opt_uint(&self, _v: RValue<'gcc>) -> Option<u64> { + // TODO(antoyo) + None + } + + fn const_to_opt_u128(&self, _v: RValue<'gcc>, _sign_ext: bool) -> Option<u128> { + // TODO(antoyo) + None + } + + fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, ty: Type<'gcc>) -> RValue<'gcc> { + let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() }; + match cv { + Scalar::Int(int) => { + let data = int.to_bits(layout.size(self)); + let value = self.const_uint_big(self.type_ix(bitsize), data); + let bytesize = layout.size(self).bytes(); + if bitsize > 1 && ty.is_integral() && bytesize as u32 == ty.get_size() { + // NOTE: since the intrinsic _xabort is called with a bitcast, which + // is non-const, but expects a constant, do a normal cast instead of a bitcast. + // FIXME(antoyo): fix bitcast to work in constant contexts. + // TODO(antoyo): perhaps only use bitcast for pointers? + self.context.new_cast(None, value, ty) + } else { + // TODO(bjorn3): assert size is correct + self.const_bitcast(value, ty) + } + } + Scalar::Ptr(ptr, _size) => { + let (prov, offset) = ptr.prov_and_relative_offset(); + let alloc_id = prov.alloc_id(); + let base_addr = match self.tcx.global_alloc(alloc_id) { + GlobalAlloc::Memory(alloc) => { + // For ZSTs directly codegen an aligned pointer. + // This avoids generating a zero-sized constant value and actually needing a + // real address at runtime. + if alloc.inner().len() == 0 { + assert_eq!(offset.bytes(), 0); + let val = self.const_usize(alloc.inner().align.bytes()); + return if matches!(layout.primitive(), Pointer(_)) { + self.context.new_cast(None, val, ty) + } else { + self.const_bitcast(val, ty) + }; + } + + let init = self.const_data_from_alloc(alloc); + let alloc = alloc.inner(); + let value = match alloc.mutability { + Mutability::Mut => self.static_addr_of_mut(init, alloc.align, None), + _ => self.static_addr_of(init, alloc.align, None), + }; + if !self.sess().fewer_names() { + // TODO(antoyo): set value name. + } + value + } + GlobalAlloc::Function { instance, .. } => self.get_fn_addr(instance), + GlobalAlloc::VTable(ty, dyn_ty) => { + let alloc = self + .tcx + .global_alloc(self.tcx.vtable_allocation(( + ty, + dyn_ty.principal().map(|principal| { + self.tcx.instantiate_bound_regions_with_erased(principal) + }), + ))) + .unwrap_memory(); + let init = self.const_data_from_alloc(alloc); + self.static_addr_of(init, alloc.inner().align, None) + } + GlobalAlloc::TypeId { .. } => { + let val = self.const_usize(offset.bytes()); + // This is still a variable of pointer type, even though we only use the provenance + // of that pointer in CTFE and Miri. But to make LLVM's type system happy, + // we need an int-to-ptr cast here (it doesn't matter at all which provenance that picks). + return self.context.new_cast(None, val, ty); + } + GlobalAlloc::Static(def_id) => { + assert!(self.tcx.is_static(def_id)); + self.get_static(def_id).get_address(None) + } + }; + let ptr_type = base_addr.get_type(); + let base_addr = self.context.new_cast(None, base_addr, self.usize_type); + let offset = + self.context.new_rvalue_from_long(self.usize_type, offset.bytes() as i64); + let ptr = self.context.new_cast(None, base_addr + offset, ptr_type); + if !matches!(layout.primitive(), Pointer(_)) { + self.const_bitcast(ptr.dereference(None).to_rvalue(), ty) + } else { + self.context.new_cast(None, ptr, ty) + } + } + } + } + + fn const_data_from_alloc(&self, alloc: ConstAllocation<'_>) -> Self::Value { + // We ignore the alignment for the purpose of deduping RValues + // The alignment is not handled / used in any way by `const_alloc_to_gcc`, + // so it is OK to overwrite it here. + let mut mock_alloc = alloc.inner().clone(); + mock_alloc.align = rustc_abi::Align::MAX; + // Check if the rvalue is already in the cache - if so, just return it directly. + if let Some(res) = self.const_cache.borrow().get(&mock_alloc) { + return *res; + } + // Rvalue not in the cache - convert and add it. + let res = crate::consts::const_alloc_to_gcc_uncached(self, alloc); + self.const_cache.borrow_mut().insert(mock_alloc, res); + res + } + + fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value { + self.context + .new_array_access(None, base_addr, self.const_usize(offset.bytes())) + .get_address(None) + } +} + +pub trait SignType<'gcc, 'tcx> { + fn is_signed(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_unsigned(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn to_signed(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>; + fn to_unsigned(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>; +} + +impl<'gcc, 'tcx> SignType<'gcc, 'tcx> for Type<'gcc> { + fn is_signed(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.is_i8(cx) || self.is_i16(cx) || self.is_i32(cx) || self.is_i64(cx) || self.is_i128(cx) + } + + fn is_unsigned(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.is_u8(cx) || self.is_u16(cx) || self.is_u32(cx) || self.is_u64(cx) || self.is_u128(cx) + } + + fn to_signed(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> { + if self.is_u8(cx) { + cx.i8_type + } else if self.is_u16(cx) { + cx.i16_type + } else if self.is_u32(cx) { + cx.i32_type + } else if self.is_u64(cx) { + cx.i64_type + } else if self.is_u128(cx) { + cx.i128_type + } else if self.is_uchar(cx) { + cx.char_type + } else if self.is_ushort(cx) { + cx.short_type + } else if self.is_uint(cx) { + cx.int_type + } else if self.is_ulong(cx) { + cx.long_type + } else if self.is_ulonglong(cx) { + cx.longlong_type + } else { + *self + } + } + + fn to_unsigned(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> { + if self.is_i8(cx) { + cx.u8_type + } else if self.is_i16(cx) { + cx.u16_type + } else if self.is_i32(cx) { + cx.u32_type + } else if self.is_i64(cx) { + cx.u64_type + } else if self.is_i128(cx) { + cx.u128_type + } else if self.is_char(cx) { + cx.uchar_type + } else if self.is_short(cx) { + cx.ushort_type + } else if self.is_int(cx) { + cx.uint_type + } else if self.is_long(cx) { + cx.ulong_type + } else if self.is_longlong(cx) { + cx.ulonglong_type + } else { + *self + } + } +} + +pub trait TypeReflection<'gcc, 'tcx> { + fn is_uchar(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_ushort(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_uint(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_ulong(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_ulonglong(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_char(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_short(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_int(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_long(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_longlong(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + + fn is_i8(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_u8(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_i16(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_u16(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_i32(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_u32(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_i64(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_u64(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_i128(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + fn is_u128(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; + + fn is_vector(&self) -> bool; +} + +impl<'gcc, 'tcx> TypeReflection<'gcc, 'tcx> for Type<'gcc> { + fn is_uchar(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.uchar_type + } + + fn is_ushort(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.ushort_type + } + + fn is_uint(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.uint_type + } + + fn is_ulong(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.ulong_type + } + + fn is_ulonglong(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.ulonglong_type + } + + fn is_char(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.char_type + } + + fn is_short(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.short_type + } + + fn is_int(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.int_type + } + + fn is_long(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.long_type + } + + fn is_longlong(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.longlong_type + } + + fn is_i8(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.is_compatible_with(cx.i8_type) + } + + fn is_u8(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.is_compatible_with(cx.u8_type) + } + + fn is_i16(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.is_compatible_with(cx.i16_type) + } + + fn is_u16(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.is_compatible_with(cx.u16_type) + } + + fn is_i32(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.is_compatible_with(cx.i32_type) + } + + fn is_u32(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.is_compatible_with(cx.u32_type) + } + + fn is_i64(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.is_compatible_with(cx.i64_type) + } + + fn is_u64(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.is_compatible_with(cx.u64_type) + } + + fn is_i128(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.i128_type.unqualified() + } + + fn is_u128(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool { + self.unqualified() == cx.u128_type.unqualified() + } + + fn is_vector(&self) -> bool { + let mut typ = *self; + loop { + if typ.dyncast_vector().is_some() { + return true; + } + + let old_type = typ; + typ = typ.unqualified(); + if old_type == typ { + break; + } + } + + false + } +} diff --git a/compiler/rustc_codegen_gcc/src/consts.rs b/compiler/rustc_codegen_gcc/src/consts.rs new file mode 100644 index 00000000000..c04c75e1b11 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/consts.rs @@ -0,0 +1,406 @@ +#[cfg(feature = "master")] +use gccjit::{FnAttribute, VarAttribute, Visibility}; +use gccjit::{Function, GlobalKind, LValue, RValue, ToRValue, Type}; +use rustc_abi::{self as abi, Align, HasDataLayout, Primitive, Size, WrappingRange}; +use rustc_codegen_ssa::traits::{ + BaseTypeCodegenMethods, ConstCodegenMethods, StaticCodegenMethods, +}; +use rustc_hir::def::DefKind; +use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; +use rustc_middle::mir::interpret::{ + self, ConstAllocation, ErrorHandled, Scalar as InterpScalar, read_target_uint, +}; +use rustc_middle::mir::mono::Linkage; +use rustc_middle::ty::layout::LayoutOf; +use rustc_middle::ty::{self, Instance}; +use rustc_middle::{bug, span_bug}; +use rustc_span::def_id::DefId; + +use crate::base; +use crate::context::CodegenCx; +use crate::type_of::LayoutGccExt; + +fn set_global_alignment<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + gv: LValue<'gcc>, + mut align: Align, +) { + // The target may require greater alignment for globals than the type does. + // Note: GCC and Clang also allow `__attribute__((aligned))` on variables, + // which can force it to be smaller. Rust doesn't support this yet. + if let Some(min_global) = cx.sess().target.min_global_align { + align = Ord::max(align, min_global); + } + gv.set_alignment(align.bytes() as i32); +} + +impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> { + fn static_addr_of(&self, cv: RValue<'gcc>, align: Align, kind: Option<&str>) -> RValue<'gcc> { + if let Some(variable) = self.const_globals.borrow().get(&cv) { + if let Some(global_variable) = self.global_lvalues.borrow().get(variable) { + let alignment = align.bits() as i32; + if alignment > global_variable.get_alignment() { + global_variable.set_alignment(alignment); + } + } + return *variable; + } + let global_value = self.static_addr_of_mut(cv, align, kind); + #[cfg(feature = "master")] + self.global_lvalues + .borrow() + .get(&global_value) + .expect("`static_addr_of_mut` did not add the global to `self.global_lvalues`") + .global_set_readonly(); + self.const_globals.borrow_mut().insert(cv, global_value); + global_value + } + + #[cfg_attr(not(feature = "master"), allow(unused_mut))] + fn codegen_static(&mut self, def_id: DefId) { + let attrs = self.tcx.codegen_fn_attrs(def_id); + + let Ok((value, alloc)) = codegen_static_initializer(self, def_id) else { + // Error has already been reported + return; + }; + let alloc = alloc.inner(); + + // boolean SSA values are i1, but they have to be stored in i8 slots, + // otherwise some LLVM optimization passes don't work as expected + let val_llty = self.val_ty(value); + if val_llty == self.type_i1() { + unimplemented!(); + }; + + let is_thread_local = attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL); + let global = self.get_static_inner(def_id, val_llty); + + #[cfg(feature = "master")] + if global.to_rvalue().get_type() != val_llty { + global.to_rvalue().set_type(val_llty); + } + set_global_alignment(self, global, alloc.align); + + global.global_set_initializer_rvalue(value); + + // As an optimization, all shared statics which do not have interior + // mutability are placed into read-only memory. + if alloc.mutability.is_not() { + #[cfg(feature = "master")] + global.global_set_readonly(); + } + + if is_thread_local { + // Do not allow LLVM to change the alignment of a TLS on macOS. + // + // By default a global's alignment can be freely increased. + // This allows LLVM to generate more performant instructions + // e.g., using load-aligned into a SIMD register. + // + // However, on macOS 10.10 or below, the dynamic linker does not + // respect any alignment given on the TLS (radar 24221680). + // This will violate the alignment assumption, and causing segfault at runtime. + // + // This bug is very easy to trigger. In `println!` and `panic!`, + // the `LOCAL_STDOUT`/`LOCAL_STDERR` handles are stored in a TLS, + // which the values would be `mem::replace`d on initialization. + // The implementation of `mem::replace` will use SIMD + // whenever the size is 32 bytes or higher. LLVM notices SIMD is used + // and tries to align `LOCAL_STDOUT`/`LOCAL_STDERR` to a 32-byte boundary, + // which macOS's dyld disregarded and causing crashes + // (see issues #51794, #51758, #50867, #48866 and #44056). + // + // To workaround the bug, we trick LLVM into not increasing + // the global's alignment by explicitly assigning a section to it + // (equivalent to automatically generating a `#[link_section]` attribute). + // See the comment in the `GlobalValue::canIncreaseAlignment()` function + // of `lib/IR/Globals.cpp` for why this works. + // + // When the alignment is not increased, the optimized `mem::replace` + // will use load-unaligned instructions instead, and thus avoiding the crash. + // + // We could remove this hack whenever we decide to drop macOS 10.10 support. + if self.tcx.sess.target.options.is_like_darwin { + // The `inspect` method is okay here because we checked for provenance, and + // because we are doing this access to inspect the final interpreter state + // (not as part of the interpreter execution). + // + // FIXME: This check requires that the (arbitrary) value of undefined bytes + // happens to be zero. Instead, we should only check the value of defined bytes + // and set all undefined bytes to zero if this allocation is headed for the + // BSS. + unimplemented!(); + } + } + + // Wasm statics with custom link sections get special treatment as they + // go into custom sections of the wasm executable. + if self.tcx.sess.target.is_like_wasm { + if let Some(_section) = attrs.link_section { + unimplemented!(); + } + } else { + // TODO(antoyo): set link section. + } + + if attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER) + || attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) + { + self.add_used_global(global.to_rvalue()); + } + } +} + +impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { + /// Add a global value to a list to be stored in the `llvm.used` variable, an array of i8*. + pub fn add_used_global(&mut self, _global: RValue<'gcc>) { + // TODO(antoyo) + } + + #[cfg_attr(not(feature = "master"), allow(unused_variables))] + pub fn add_used_function(&self, function: Function<'gcc>) { + #[cfg(feature = "master")] + function.add_attribute(FnAttribute::Used); + } + + pub fn static_addr_of_mut( + &self, + cv: RValue<'gcc>, + align: Align, + kind: Option<&str>, + ) -> RValue<'gcc> { + let global = match kind { + Some(kind) if !self.tcx.sess.fewer_names() => { + let name = self.generate_local_symbol_name(kind); + // TODO(antoyo): check if it's okay that no link_section is set. + + let typ = self.val_ty(cv).get_aligned(align.bytes()); + self.declare_private_global(&name[..], typ) + } + _ => { + let typ = self.val_ty(cv).get_aligned(align.bytes()); + self.declare_unnamed_global(typ) + } + }; + global.global_set_initializer_rvalue(cv); + // TODO(antoyo): set unnamed address. + let rvalue = global.get_address(None); + self.global_lvalues.borrow_mut().insert(rvalue, global); + rvalue + } + + pub fn get_static(&self, def_id: DefId) -> LValue<'gcc> { + let instance = Instance::mono(self.tcx, def_id); + let DefKind::Static { nested, .. } = self.tcx.def_kind(def_id) else { bug!() }; + // Nested statics do not have a type, so pick a random type and let `define_static` figure out + // the gcc type from the actual evaluated initializer. + let gcc_type = if nested { + self.type_i8() + } else { + let ty = instance.ty(self.tcx, ty::TypingEnv::fully_monomorphized()); + self.layout_of(ty).gcc_type(self) + }; + + self.get_static_inner(def_id, gcc_type) + } + + pub(crate) fn get_static_inner(&self, def_id: DefId, gcc_type: Type<'gcc>) -> LValue<'gcc> { + let instance = Instance::mono(self.tcx, def_id); + if let Some(&global) = self.instances.borrow().get(&instance) { + trace!("used cached value"); + return global; + } + + // FIXME: Once we stop removing globals in `codegen_static`, we can uncomment this code. + // let defined_in_current_codegen_unit = + // self.codegen_unit.items().contains_key(&MonoItem::Static(def_id)); + // assert!( + // !defined_in_current_codegen_unit, + // "consts::get_static() should always hit the cache for \ + // statics defined in the same CGU, but did not for `{:?}`", + // def_id + // ); + let sym = self.tcx.symbol_name(instance).name; + let fn_attrs = self.tcx.codegen_fn_attrs(def_id); + + let global = if def_id.is_local() && !self.tcx.is_foreign_item(def_id) { + if let Some(global) = self.get_declared_value(sym) + && self.val_ty(global) != self.type_ptr_to(gcc_type) + { + span_bug!(self.tcx.def_span(def_id), "Conflicting types for static"); + } + + let is_tls = fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL); + let global = self.declare_global( + sym, + gcc_type, + GlobalKind::Imported, + is_tls, + fn_attrs.link_section, + ); + + if !self.tcx.is_reachable_non_generic(def_id) { + #[cfg(feature = "master")] + global.add_attribute(VarAttribute::Visibility(Visibility::Hidden)); + } + + global + } else { + check_and_apply_linkage(self, fn_attrs, gcc_type, sym) + }; + + if !def_id.is_local() { + let needs_dll_storage_attr = false; // TODO(antoyo) + + // If this assertion triggers, there's something wrong with commandline + // argument validation. + debug_assert!( + !(self.tcx.sess.opts.cg.linker_plugin_lto.enabled() + && self.tcx.sess.target.options.is_like_msvc + && self.tcx.sess.opts.cg.prefer_dynamic) + ); + + if needs_dll_storage_attr { + // This item is external but not foreign, i.e., it originates from an external Rust + // crate. Since we don't know whether this crate will be linked dynamically or + // statically in the final application, we always mark such symbols as 'dllimport'. + // If final linkage happens to be static, we rely on compiler-emitted __imp_ stubs + // to make things work. + // + // However, in some scenarios we defer emission of statics to downstream + // crates, so there are cases where a static with an upstream DefId + // is actually present in the current crate. We can find out via the + // is_codegened_item query. + if !self.tcx.is_codegened_item(def_id) { + unimplemented!(); + } + } + } + + // TODO(antoyo): set dll storage class. + + self.instances.borrow_mut().insert(instance, global); + global + } +} +/// Converts a given const alloc to a gcc Rvalue, without any caching or deduplication. +/// YOU SHOULD NOT call this function directly - that may break the semantics of Rust. +/// Use `const_data_from_alloc` instead. +pub(crate) fn const_alloc_to_gcc_uncached<'gcc>( + cx: &CodegenCx<'gcc, '_>, + alloc: ConstAllocation<'_>, +) -> RValue<'gcc> { + let alloc = alloc.inner(); + let mut llvals = Vec::with_capacity(alloc.provenance().ptrs().len() + 1); + let dl = cx.data_layout(); + let pointer_size = dl.pointer_size().bytes() as usize; + + let mut next_offset = 0; + for &(offset, prov) in alloc.provenance().ptrs().iter() { + let alloc_id = prov.alloc_id(); + let offset = offset.bytes(); + assert_eq!(offset as usize as u64, offset); + let offset = offset as usize; + if offset > next_offset { + // This `inspect` is okay since we have checked that it is not within a pointer with provenance, it + // is within the bounds of the allocation, and it doesn't affect interpreter execution + // (we inspect the result after interpreter execution). Any undef byte is replaced with + // some arbitrary byte value. + // + // FIXME: relay undef bytes to codegen as undef const bytes + let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(next_offset..offset); + llvals.push(cx.const_bytes(bytes)); + } + let ptr_offset = read_target_uint( + dl.endian, + // This `inspect` is okay since it is within the bounds of the allocation, it doesn't + // affect interpreter execution (we inspect the result after interpreter execution), + // and we properly interpret the provenance as a relocation pointer offset. + alloc.inspect_with_uninit_and_ptr_outside_interpreter(offset..(offset + pointer_size)), + ) + .expect("const_alloc_to_gcc_uncached: could not read relocation pointer") + as u64; + + let address_space = cx.tcx.global_alloc(alloc_id).address_space(cx); + + llvals.push(cx.scalar_to_backend( + InterpScalar::from_pointer( + interpret::Pointer::new(prov, Size::from_bytes(ptr_offset)), + &cx.tcx, + ), + abi::Scalar::Initialized { + value: Primitive::Pointer(address_space), + valid_range: WrappingRange::full(dl.pointer_size()), + }, + cx.type_i8p_ext(address_space), + )); + next_offset = offset + pointer_size; + } + if alloc.len() >= next_offset { + let range = next_offset..alloc.len(); + // This `inspect` is okay since we have check that it is after all provenance, it is + // within the bounds of the allocation, and it doesn't affect interpreter execution (we + // inspect the result after interpreter execution). Any undef byte is replaced with some + // arbitrary byte value. + // + // FIXME: relay undef bytes to codegen as undef const bytes + let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(range); + llvals.push(cx.const_bytes(bytes)); + } + + // FIXME(bjorn3) avoid wrapping in a struct when there is only a single element. + cx.const_struct(&llvals, true) +} + +fn codegen_static_initializer<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + def_id: DefId, +) -> Result<(RValue<'gcc>, ConstAllocation<'tcx>), ErrorHandled> { + let alloc = cx.tcx.eval_static_initializer(def_id)?; + Ok((cx.const_data_from_alloc(alloc), alloc)) +} + +fn check_and_apply_linkage<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + attrs: &CodegenFnAttrs, + gcc_type: Type<'gcc>, + sym: &str, +) -> LValue<'gcc> { + let is_tls = attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL); + if let Some(linkage) = attrs.import_linkage { + // Declare a symbol `foo` with the desired linkage. + let global1 = + cx.declare_global_with_linkage(sym, cx.type_i8(), base::global_linkage_to_gcc(linkage)); + + if linkage == Linkage::ExternalWeak { + #[cfg(feature = "master")] + global1.add_attribute(VarAttribute::Weak); + } + + // Declare an internal global `extern_with_linkage_foo` which + // is initialized with the address of `foo`. If `foo` is + // discarded during linking (for example, if `foo` has weak + // linkage and there are no definitions), then + // `extern_with_linkage_foo` will instead be initialized to + // zero. + let mut real_name = "_rust_extern_with_linkage_".to_string(); + real_name.push_str(sym); + let global2 = cx.define_global(&real_name, gcc_type, is_tls, attrs.link_section); + // TODO(antoyo): set linkage. + let value = cx.const_ptrcast(global1.get_address(None), gcc_type); + global2.global_set_initializer_rvalue(value); + global2 + } else { + // Generate an external declaration. + // FIXME(nagisa): investigate whether it can be changed into define_global + + // Thread-local statics in some other crate need to *always* be linked + // against in a thread-local fashion, so we need to be sure to apply the + // thread-local attribute locally if it was present remotely. If we + // don't do this then linker errors can be generated where the linker + // complains that one object files has a thread local version of the + // symbol and another one doesn't. + cx.declare_global(sym, gcc_type, GlobalKind::Imported, is_tls, attrs.link_section) + } +} diff --git a/compiler/rustc_codegen_gcc/src/context.rs b/compiler/rustc_codegen_gcc/src/context.rs new file mode 100644 index 00000000000..665cf22ddba --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/context.rs @@ -0,0 +1,599 @@ +use std::cell::{Cell, RefCell}; +use std::collections::HashMap; + +use gccjit::{ + Block, CType, Context, Function, FunctionPtrType, FunctionType, LValue, Location, RValue, Type, +}; +use rustc_abi::{Align, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx}; +use rustc_codegen_ssa::base::wants_msvc_seh; +use rustc_codegen_ssa::errors as ssa_errors; +use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeCodegenMethods, MiscCodegenMethods}; +use rustc_data_structures::base_n::{ALPHANUMERIC_ONLY, ToBaseN}; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_middle::mir::interpret::Allocation; +use rustc_middle::mir::mono::CodegenUnit; +use rustc_middle::span_bug; +use rustc_middle::ty::layout::{ + FnAbiError, FnAbiOf, FnAbiOfHelpers, FnAbiRequest, HasTyCtxt, HasTypingEnv, LayoutError, + LayoutOfHelpers, +}; +use rustc_middle::ty::{self, ExistentialTraitRef, Instance, Ty, TyCtxt}; +use rustc_session::Session; +use rustc_span::source_map::respan; +use rustc_span::{DUMMY_SP, Span}; +use rustc_target::spec::{HasTargetSpec, HasX86AbiOpt, Target, TlsModel, X86Abi}; + +#[cfg(feature = "master")] +use crate::abi::conv_to_fn_attribute; +use crate::callee::get_fn; +use crate::common::SignType; + +#[cfg_attr(not(feature = "master"), allow(dead_code))] +pub struct CodegenCx<'gcc, 'tcx> { + /// A cache of converted ConstAllocs + pub const_cache: RefCell<HashMap<Allocation, RValue<'gcc>>>, + pub codegen_unit: &'tcx CodegenUnit<'tcx>, + pub context: &'gcc Context<'gcc>, + + // TODO(bjorn3): Can this field be removed? + pub current_func: RefCell<Option<Function<'gcc>>>, + pub normal_function_addresses: RefCell<FxHashSet<RValue<'gcc>>>, + pub function_address_names: RefCell<FxHashMap<RValue<'gcc>, String>>, + + pub functions: RefCell<FxHashMap<String, Function<'gcc>>>, + pub intrinsics: RefCell<FxHashMap<String, Function<'gcc>>>, + + pub tls_model: gccjit::TlsModel, + + pub bool_type: Type<'gcc>, + pub i8_type: Type<'gcc>, + pub i16_type: Type<'gcc>, + pub i32_type: Type<'gcc>, + pub i64_type: Type<'gcc>, + pub i128_type: Type<'gcc>, + pub isize_type: Type<'gcc>, + + pub u8_type: Type<'gcc>, + pub u16_type: Type<'gcc>, + pub u32_type: Type<'gcc>, + pub u64_type: Type<'gcc>, + pub u128_type: Type<'gcc>, + pub usize_type: Type<'gcc>, + + pub char_type: Type<'gcc>, + pub uchar_type: Type<'gcc>, + pub short_type: Type<'gcc>, + pub ushort_type: Type<'gcc>, + pub int_type: Type<'gcc>, + pub uint_type: Type<'gcc>, + pub long_type: Type<'gcc>, + pub ulong_type: Type<'gcc>, + pub longlong_type: Type<'gcc>, + pub ulonglong_type: Type<'gcc>, + pub sizet_type: Type<'gcc>, + + pub supports_128bit_integers: bool, + pub supports_f16_type: bool, + pub supports_f32_type: bool, + pub supports_f64_type: bool, + pub supports_f128_type: bool, + + pub float_type: Type<'gcc>, + pub double_type: Type<'gcc>, + + pub linkage: Cell<FunctionType>, + pub scalar_types: RefCell<FxHashMap<Ty<'tcx>, Type<'gcc>>>, + pub types: RefCell<FxHashMap<(Ty<'tcx>, Option<VariantIdx>), Type<'gcc>>>, + pub tcx: TyCtxt<'tcx>, + + pub struct_types: RefCell<FxHashMap<Vec<Type<'gcc>>, Type<'gcc>>>, + + /// Cache instances of monomorphic and polymorphic items + pub instances: RefCell<FxHashMap<Instance<'tcx>, LValue<'gcc>>>, + /// Cache function instances of monomorphic and polymorphic items + pub function_instances: RefCell<FxHashMap<Instance<'tcx>, Function<'gcc>>>, + /// Cache generated vtables + pub vtables: + RefCell<FxHashMap<(Ty<'tcx>, Option<ty::ExistentialTraitRef<'tcx>>), RValue<'gcc>>>, + + // TODO(antoyo): improve the SSA API to not require those. + /// Mapping from function pointer type to indexes of on stack parameters. + pub on_stack_params: RefCell<FxHashMap<FunctionPtrType<'gcc>, FxHashSet<usize>>>, + /// Mapping from function to indexes of on stack parameters. + pub on_stack_function_params: RefCell<FxHashMap<Function<'gcc>, FxHashSet<usize>>>, + + /// Cache of emitted const globals (value -> global) + pub const_globals: RefCell<FxHashMap<RValue<'gcc>, RValue<'gcc>>>, + + /// Map from the address of a global variable (rvalue) to the global variable itself (lvalue). + /// TODO(antoyo): remove when the rustc API is fixed. + pub global_lvalues: RefCell<FxHashMap<RValue<'gcc>, LValue<'gcc>>>, + + /// Cache of constant strings, + pub const_str_cache: RefCell<FxHashMap<String, LValue<'gcc>>>, + + /// Cache of globals. + pub globals: RefCell<FxHashMap<String, RValue<'gcc>>>, + + /// A counter that is used for generating local symbol names + local_gen_sym_counter: Cell<usize>, + + eh_personality: Cell<Option<Function<'gcc>>>, + #[cfg(feature = "master")] + pub rust_try_fn: Cell<Option<(Type<'gcc>, Function<'gcc>)>>, + + pub pointee_infos: RefCell<FxHashMap<(Ty<'tcx>, Size), Option<PointeeInfo>>>, + + #[cfg(feature = "master")] + pub cleanup_blocks: RefCell<FxHashSet<Block<'gcc>>>, + /// The alignment of a u128/i128 type. + // We cache this, since it is needed for alignment checks during loads. + pub int128_align: Align, +} + +impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { + #[allow(clippy::too_many_arguments)] + pub fn new( + context: &'gcc Context<'gcc>, + codegen_unit: &'tcx CodegenUnit<'tcx>, + tcx: TyCtxt<'tcx>, + supports_128bit_integers: bool, + supports_f16_type: bool, + supports_f32_type: bool, + supports_f64_type: bool, + supports_f128_type: bool, + ) -> Self { + let create_type = |ctype, rust_type| { + let layout = tcx + .layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(rust_type)) + .unwrap(); + let align = layout.align.abi.bytes(); + // For types with size 1, the alignment can be 1 and only 1 + // So, we can skip the call to ``get_aligned`. + // In the future, we can add a GCC API to query the type align, + // and call `get_aligned` if and only if that differs from Rust's expectations. + if layout.size.bytes() == 1 { + return context.new_c_type(ctype); + } + #[cfg(feature = "master")] + { + context.new_c_type(ctype).get_aligned(align) + } + #[cfg(not(feature = "master"))] + { + // Since libgccjit 12 doesn't contain the fix to compare aligned integer types, + // only align u128 and i128. + if layout.ty.int_size_and_signed(tcx).0.bytes() == 16 { + context.new_c_type(ctype).get_aligned(align) + } else { + context.new_c_type(ctype) + } + } + }; + + let i8_type = create_type(CType::Int8t, tcx.types.i8); + let i16_type = create_type(CType::Int16t, tcx.types.i16); + let i32_type = create_type(CType::Int32t, tcx.types.i32); + let i64_type = create_type(CType::Int64t, tcx.types.i64); + let u8_type = create_type(CType::UInt8t, tcx.types.u8); + let u16_type = create_type(CType::UInt16t, tcx.types.u16); + let u32_type = create_type(CType::UInt32t, tcx.types.u32); + let u64_type = create_type(CType::UInt64t, tcx.types.u64); + + let (i128_type, u128_type) = if supports_128bit_integers { + let i128_type = create_type(CType::Int128t, tcx.types.i128); + let u128_type = create_type(CType::UInt128t, tcx.types.u128); + (i128_type, u128_type) + } else { + /*let layout = tcx.layout_of(ParamEnv::reveal_all().and(tcx.types.i128)).unwrap(); + let i128_align = layout.align.abi.bytes(); + let layout = tcx.layout_of(ParamEnv::reveal_all().and(tcx.types.u128)).unwrap(); + let u128_align = layout.align.abi.bytes();*/ + + // TODO(antoyo): re-enable the alignment when libgccjit fixed the issue in + // gcc_jit_context_new_array_constructor (it should not use reinterpret_cast). + let i128_type = context.new_array_type(None, i64_type, 2)/*.get_aligned(i128_align)*/; + let u128_type = context.new_array_type(None, u64_type, 2)/*.get_aligned(u128_align)*/; + (i128_type, u128_type) + }; + + let tls_model = to_gcc_tls_mode(tcx.sess.tls_model()); + + // TODO(antoyo): set alignment on those types as well. + let float_type = context.new_type::<f32>(); + let double_type = context.new_type::<f64>(); + + let char_type = context.new_c_type(CType::Char); + let uchar_type = context.new_c_type(CType::UChar); + let short_type = context.new_c_type(CType::Short); + let ushort_type = context.new_c_type(CType::UShort); + let int_type = context.new_c_type(CType::Int); + let uint_type = context.new_c_type(CType::UInt); + let long_type = context.new_c_type(CType::Long); + let ulong_type = context.new_c_type(CType::ULong); + let longlong_type = context.new_c_type(CType::LongLong); + let ulonglong_type = context.new_c_type(CType::ULongLong); + let sizet_type = context.new_c_type(CType::SizeT); + + let usize_type = sizet_type; + let isize_type = usize_type; + let bool_type = context.new_type::<bool>(); + + let mut functions = FxHashMap::default(); + let builtins = ["abort"]; + + for builtin in builtins.iter() { + functions.insert(builtin.to_string(), context.get_builtin_function(builtin)); + } + + let mut cx = Self { + int128_align: tcx + .layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(tcx.types.i128)) + .expect("Can't get the layout of `i128`") + .align + .abi, + const_cache: Default::default(), + codegen_unit, + context, + current_func: RefCell::new(None), + normal_function_addresses: Default::default(), + function_address_names: Default::default(), + functions: RefCell::new(functions), + intrinsics: RefCell::new(FxHashMap::default()), + + tls_model, + + bool_type, + i8_type, + i16_type, + i32_type, + i64_type, + i128_type, + isize_type, + usize_type, + u8_type, + u16_type, + u32_type, + u64_type, + u128_type, + char_type, + uchar_type, + short_type, + ushort_type, + int_type, + uint_type, + long_type, + ulong_type, + longlong_type, + ulonglong_type, + sizet_type, + + supports_128bit_integers, + supports_f16_type, + supports_f32_type, + supports_f64_type, + supports_f128_type, + + float_type, + double_type, + + linkage: Cell::new(FunctionType::Internal), + instances: Default::default(), + function_instances: Default::default(), + on_stack_params: Default::default(), + on_stack_function_params: Default::default(), + vtables: Default::default(), + const_globals: Default::default(), + global_lvalues: Default::default(), + const_str_cache: Default::default(), + globals: Default::default(), + scalar_types: Default::default(), + types: Default::default(), + tcx, + struct_types: Default::default(), + local_gen_sym_counter: Cell::new(0), + eh_personality: Cell::new(None), + #[cfg(feature = "master")] + rust_try_fn: Cell::new(None), + pointee_infos: Default::default(), + #[cfg(feature = "master")] + cleanup_blocks: Default::default(), + }; + // TODO(antoyo): instead of doing this, add SsizeT to libgccjit. + cx.isize_type = usize_type.to_signed(&cx); + cx + } + + pub fn rvalue_as_function(&self, value: RValue<'gcc>) -> Function<'gcc> { + let function: Function<'gcc> = unsafe { std::mem::transmute(value) }; + debug_assert!( + self.functions.borrow().values().any(|value| *value == function), + "{:?} ({:?}) is not a function", + value, + value.get_type() + ); + function + } + + pub fn is_native_int_type(&self, typ: Type<'gcc>) -> bool { + let types = [ + self.u8_type, + self.u16_type, + self.u32_type, + self.u64_type, + self.i8_type, + self.i16_type, + self.i32_type, + self.i64_type, + ]; + + for native_type in types { + if native_type.is_compatible_with(typ) { + return true; + } + } + + self.supports_128bit_integers + && (self.u128_type.is_compatible_with(typ) || self.i128_type.is_compatible_with(typ)) + } + + pub fn is_non_native_int_type(&self, typ: Type<'gcc>) -> bool { + !self.supports_128bit_integers + && (self.u128_type.is_compatible_with(typ) || self.i128_type.is_compatible_with(typ)) + } + + pub fn is_native_int_type_or_bool(&self, typ: Type<'gcc>) -> bool { + self.is_native_int_type(typ) || typ.is_compatible_with(self.bool_type) + } + + pub fn is_int_type_or_bool(&self, typ: Type<'gcc>) -> bool { + self.is_native_int_type(typ) + || self.is_non_native_int_type(typ) + || typ.is_compatible_with(self.bool_type) + } + + pub fn sess(&self) -> &'tcx Session { + self.tcx.sess + } + + pub fn bitcast_if_needed( + &self, + value: RValue<'gcc>, + expected_type: Type<'gcc>, + ) -> RValue<'gcc> { + if value.get_type() != expected_type { + self.context.new_bitcast(None, value, expected_type) + } else { + value + } + } +} + +impl<'gcc, 'tcx> BackendTypes for CodegenCx<'gcc, 'tcx> { + type Value = RValue<'gcc>; + type Metadata = RValue<'gcc>; + type Function = Function<'gcc>; + + type BasicBlock = Block<'gcc>; + type Type = Type<'gcc>; + type Funclet = (); // TODO(antoyo) + + type DIScope = (); // TODO(antoyo) + type DILocation = Location<'gcc>; + type DIVariable = (); // TODO(antoyo) +} + +impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> { + fn vtables( + &self, + ) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<ExistentialTraitRef<'tcx>>), RValue<'gcc>>> { + &self.vtables + } + + fn get_fn(&self, instance: Instance<'tcx>) -> Function<'gcc> { + let func = get_fn(self, instance); + *self.current_func.borrow_mut() = Some(func); + func + } + + fn get_fn_addr(&self, instance: Instance<'tcx>) -> RValue<'gcc> { + let func_name = self.tcx.symbol_name(instance).name; + + let func = if self.intrinsics.borrow().contains_key(func_name) { + self.intrinsics.borrow()[func_name] + } else if let Some(variable) = self.get_declared_value(func_name) { + return variable; + } else { + get_fn(self, instance) + }; + let ptr = func.get_address(None); + + // TODO(antoyo): don't do this twice: i.e. in declare_fn and here. + // FIXME(antoyo): the rustc API seems to call get_fn_addr() when not needed (e.g. for FFI). + + self.normal_function_addresses.borrow_mut().insert(ptr); + self.function_address_names.borrow_mut().insert(ptr, func_name.to_string()); + + ptr + } + + fn eh_personality(&self) -> Function<'gcc> { + // The exception handling personality function. + // + // If our compilation unit has the `eh_personality` lang item somewhere + // within it, then we just need to codegen that. Otherwise, we're + // building an rlib which will depend on some upstream implementation of + // this function, so we just codegen a generic reference to it. We don't + // specify any of the types for the function, we just make it a symbol + // that LLVM can later use. + // + // Note that MSVC is a little special here in that we don't use the + // `eh_personality` lang item at all. Currently LLVM has support for + // both Dwarf and SEH unwind mechanisms for MSVC targets and uses the + // *name of the personality function* to decide what kind of unwind side + // tables/landing pads to emit. It looks like Dwarf is used by default, + // injecting a dependency on the `_Unwind_Resume` symbol for resuming + // an "exception", but for MSVC we want to force SEH. This means that we + // can't actually have the personality function be our standard + // `rust_eh_personality` function, but rather we wired it up to the + // CRT's custom personality function, which forces LLVM to consider + // landing pads as "landing pads for SEH". + if let Some(personality_func) = self.eh_personality.get() { + return personality_func; + } + let tcx = self.tcx; + let func = match tcx.lang_items().eh_personality() { + Some(def_id) if !wants_msvc_seh(self.sess()) => { + let instance = ty::Instance::expect_resolve( + tcx, + self.typing_env(), + def_id, + ty::List::empty(), + DUMMY_SP, + ); + + let symbol_name = tcx.symbol_name(instance).name; + let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty()); + self.linkage.set(FunctionType::Extern); + self.declare_fn(symbol_name, fn_abi) + } + _ => { + let name = if wants_msvc_seh(self.sess()) { + "__CxxFrameHandler3" + } else { + "rust_eh_personality" + }; + self.declare_func(name, self.type_i32(), &[], true) + } + }; + // TODO(antoyo): apply target cpu attributes. + self.eh_personality.set(Some(func)); + func + } + + fn sess(&self) -> &Session { + self.tcx.sess + } + + fn set_frame_pointer_type(&self, _llfn: Function<'gcc>) { + // TODO(antoyo) + } + + fn apply_target_cpu_attr(&self, _llfn: Function<'gcc>) { + // TODO(antoyo) + } + + fn declare_c_main(&self, fn_type: Self::Type) -> Option<Self::Function> { + let entry_name = self.sess().target.entry_name.as_ref(); + if !self.functions.borrow().contains_key(entry_name) { + #[cfg(feature = "master")] + let conv = conv_to_fn_attribute(self.sess().target.entry_abi, &self.sess().target.arch); + #[cfg(not(feature = "master"))] + let conv = None; + Some(self.declare_entry_fn(entry_name, fn_type, conv)) + } else { + // If the symbol already exists, it is an error: for example, the user wrote + // #[no_mangle] extern "C" fn main(..) {..} + None + } + } +} + +impl<'gcc, 'tcx> HasTyCtxt<'tcx> for CodegenCx<'gcc, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { + self.tcx + } +} + +impl<'gcc, 'tcx> HasDataLayout for CodegenCx<'gcc, 'tcx> { + fn data_layout(&self) -> &TargetDataLayout { + &self.tcx.data_layout + } +} + +impl<'gcc, 'tcx> HasTargetSpec for CodegenCx<'gcc, 'tcx> { + fn target_spec(&self) -> &Target { + &self.tcx.sess.target + } +} + +impl<'gcc, 'tcx> HasX86AbiOpt for CodegenCx<'gcc, 'tcx> { + fn x86_abi_opt(&self) -> X86Abi { + X86Abi { + regparm: self.tcx.sess.opts.unstable_opts.regparm, + reg_struct_return: self.tcx.sess.opts.unstable_opts.reg_struct_return, + } + } +} + +impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> { + #[inline] + fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { + if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err { + self.tcx.dcx().emit_fatal(respan(span, err.into_diagnostic())) + } else { + self.tcx.dcx().emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err }) + } + } +} + +impl<'gcc, 'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> { + #[inline] + fn handle_fn_abi_err( + &self, + err: FnAbiError<'tcx>, + span: Span, + fn_abi_request: FnAbiRequest<'tcx>, + ) -> ! { + if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err { + self.tcx.dcx().emit_fatal(respan(span, err)) + } else { + match fn_abi_request { + FnAbiRequest::OfFnPtr { sig, extra_args } => { + span_bug!(span, "`fn_abi_of_fn_ptr({sig}, {extra_args:?})` failed: {err:?}"); + } + FnAbiRequest::OfInstance { instance, extra_args } => { + span_bug!( + span, + "`fn_abi_of_instance({instance}, {extra_args:?})` failed: {err:?}" + ); + } + } + } + } +} + +impl<'tcx, 'gcc> HasTypingEnv<'tcx> for CodegenCx<'gcc, 'tcx> { + fn typing_env(&self) -> ty::TypingEnv<'tcx> { + ty::TypingEnv::fully_monomorphized() + } +} + +impl<'b, 'tcx> CodegenCx<'b, 'tcx> { + /// Generates a new symbol name with the given prefix. This symbol name must + /// only be used for definitions with `internal` or `private` linkage. + pub fn generate_local_symbol_name(&self, prefix: &str) -> String { + let idx = self.local_gen_sym_counter.get(); + self.local_gen_sym_counter.set(idx + 1); + // Include a '.' character, so there can be no accidental conflicts with + // user defined names + let mut name = String::with_capacity(prefix.len() + 6); + name.push_str(prefix); + name.push('.'); + // Offset the index by the base so that always at least two characters + // are generated. This avoids cases where the suffix is interpreted as + // size by the assembler (for m68k: .b, .w, .l). + name.push_str(&(idx as u64 + ALPHANUMERIC_ONLY as u64).to_base(ALPHANUMERIC_ONLY)); + name + } +} + +fn to_gcc_tls_mode(tls_model: TlsModel) -> gccjit::TlsModel { + match tls_model { + TlsModel::GeneralDynamic => gccjit::TlsModel::GlobalDynamic, + TlsModel::LocalDynamic => gccjit::TlsModel::LocalDynamic, + TlsModel::InitialExec => gccjit::TlsModel::InitialExec, + TlsModel::LocalExec => gccjit::TlsModel::LocalExec, + TlsModel::Emulated => gccjit::TlsModel::GlobalDynamic, + } +} diff --git a/compiler/rustc_codegen_gcc/src/coverageinfo.rs b/compiler/rustc_codegen_gcc/src/coverageinfo.rs new file mode 100644 index 00000000000..4e44f78f23c --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/coverageinfo.rs @@ -0,0 +1,11 @@ +use rustc_codegen_ssa::traits::CoverageInfoBuilderMethods; +use rustc_middle::mir::coverage::CoverageKind; +use rustc_middle::ty::Instance; + +use crate::builder::Builder; + +impl<'a, 'gcc, 'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { + fn add_coverage(&mut self, _instance: Instance<'tcx>, _kind: &CoverageKind) { + // TODO(antoyo) + } +} diff --git a/compiler/rustc_codegen_gcc/src/debuginfo.rs b/compiler/rustc_codegen_gcc/src/debuginfo.rs new file mode 100644 index 00000000000..4c8585192a1 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/debuginfo.rs @@ -0,0 +1,315 @@ +use std::ops::Range; +use std::sync::Arc; + +use gccjit::{Function, Location, RValue}; +use rustc_abi::Size; +use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind}; +use rustc_codegen_ssa::traits::{DebugInfoBuilderMethods, DebugInfoCodegenMethods}; +use rustc_index::bit_set::DenseBitSet; +use rustc_index::{Idx, IndexVec}; +use rustc_middle::mir::{self, Body, SourceScope}; +use rustc_middle::ty::{ExistentialTraitRef, Instance, Ty}; +use rustc_session::config::DebugInfo; +use rustc_span::{BytePos, Pos, SourceFile, SourceFileAndLine, Span, Symbol}; +use rustc_target::callconv::FnAbi; + +use crate::builder::Builder; +use crate::context::CodegenCx; + +pub(super) const UNKNOWN_LINE_NUMBER: u32 = 0; +pub(super) const UNKNOWN_COLUMN_NUMBER: u32 = 0; + +impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> { + // FIXME(eddyb) find a common convention for all of the debuginfo-related + // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.). + fn dbg_var_addr( + &mut self, + _dbg_var: Self::DIVariable, + _dbg_loc: Self::DILocation, + _variable_alloca: Self::Value, + _direct_offset: Size, + _indirect_offsets: &[Size], + _fragment: Option<Range<Size>>, + ) { + // FIXME(tempdragon): Not sure if this is correct, probably wrong but still keep it here. + #[cfg(feature = "master")] + _variable_alloca.set_location(_dbg_loc); + } + + fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) { + // TODO(antoyo): insert reference to gdb debug scripts section global. + } + + /// FIXME(tempdragon): Currently, this function is not yet implemented. It seems that the + /// debug name and the mangled name should both be included in the LValues. + /// Besides, a function to get the rvalue type(m_is_lvalue) should also be included. + fn set_var_name(&mut self, _value: RValue<'gcc>, _name: &str) {} + + fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation) { + self.location = Some(dbg_loc); + } + + fn clear_dbg_loc(&mut self) { + self.location = None; + } +} + +/// Generate the `debug_context` in an MIR Body. +/// # Source of Origin +/// Copied from `create_scope_map.rs` of rustc_codegen_llvm +fn compute_mir_scopes<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + instance: Instance<'tcx>, + mir: &Body<'tcx>, + debug_context: &mut FunctionDebugContext<'tcx, (), Location<'gcc>>, +) { + // Find all scopes with variables defined in them. + let variables = if cx.sess().opts.debuginfo == DebugInfo::Full { + let mut vars = DenseBitSet::new_empty(mir.source_scopes.len()); + // FIXME(eddyb) take into account that arguments always have debuginfo, + // irrespective of their name (assuming full debuginfo is enabled). + // NOTE(eddyb) actually, on second thought, those are always in the + // function scope, which always exists. + for var_debug_info in &mir.var_debug_info { + vars.insert(var_debug_info.source_info.scope); + } + Some(vars) + } else { + // Nothing to emit, of course. + None + }; + let mut instantiated = DenseBitSet::new_empty(mir.source_scopes.len()); + // Instantiate all scopes. + for idx in 0..mir.source_scopes.len() { + let scope = SourceScope::new(idx); + make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); + } + assert!(instantiated.count() == mir.source_scopes.len()); +} + +/// Update the `debug_context`, adding new scope to it, +/// if it's not added as is denoted in `instantiated`. +/// +/// # Source of Origin +/// Copied from `create_scope_map.rs` of rustc_codegen_llvm +/// FIXME(tempdragon/?): Add Scope Support Here. +fn make_mir_scope<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + _instance: Instance<'tcx>, + mir: &Body<'tcx>, + variables: &Option<DenseBitSet<SourceScope>>, + debug_context: &mut FunctionDebugContext<'tcx, (), Location<'gcc>>, + instantiated: &mut DenseBitSet<SourceScope>, + scope: SourceScope, +) { + if instantiated.contains(scope) { + return; + } + + let scope_data = &mir.source_scopes[scope]; + let parent_scope = if let Some(parent) = scope_data.parent_scope { + make_mir_scope(cx, _instance, mir, variables, debug_context, instantiated, parent); + debug_context.scopes[parent] + } else { + // The root is the function itself. + let file = cx.sess().source_map().lookup_source_file(mir.span.lo()); + debug_context.scopes[scope] = DebugScope { + file_start_pos: file.start_pos, + file_end_pos: file.end_position(), + ..debug_context.scopes[scope] + }; + instantiated.insert(scope); + return; + }; + + if let Some(ref vars) = *variables + && !vars.contains(scope) + && scope_data.inlined.is_none() + { + // Do not create a DIScope if there are no variables defined in this + // MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat. + debug_context.scopes[scope] = parent_scope; + instantiated.insert(scope); + return; + } + + let loc = cx.lookup_debug_loc(scope_data.span.lo()); + + // FIXME(tempdragon): Add the scope related code here if the scope is supported. + let dbg_scope = (); + + let inlined_at = scope_data.inlined.map(|(_, callsite_span)| { + // FIXME(eddyb) this doesn't account for the macro-related + // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. + + // TODO(tempdragon): Add scope support and then revert to cg_llvm version of this closure + // NOTE: These variables passed () here. + // Changed to comply to clippy. + + /* let callsite_scope = */ + parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); + cx.dbg_loc(/* callsite_scope */ (), parent_scope.inlined_at, callsite_span) + }); + let p_inlined_at = parent_scope.inlined_at; + // TODO(tempdragon): dbg_scope: Add support for scope extension here. + inlined_at.or(p_inlined_at); + + debug_context.scopes[scope] = DebugScope { + dbg_scope, + inlined_at, + file_start_pos: loc.file.start_pos, + file_end_pos: loc.file.end_position(), + }; + instantiated.insert(scope); +} + +/// A source code location used to generate debug information. +// FIXME(eddyb) rename this to better indicate it's a duplicate of +// `rustc_span::Loc` rather than `DILocation`, perhaps by making +// `lookup_char_pos` return the right information instead. +pub struct DebugLoc { + /// Information about the original source file. + pub file: Arc<SourceFile>, + /// The (1-based) line number. + pub line: u32, + /// The (1-based) column number. + pub col: u32, +} + +impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { + /// Looks up debug source information about a `BytePos`. + // FIXME(eddyb) rename this to better indicate it's a duplicate of + // `lookup_char_pos` rather than `dbg_loc`, perhaps by making + // `lookup_char_pos` return the right information instead. + // Source of Origin: cg_llvm + pub fn lookup_debug_loc(&self, pos: BytePos) -> DebugLoc { + let (file, line, col) = match self.sess().source_map().lookup_line(pos) { + Ok(SourceFileAndLine { sf: file, line }) => { + let line_pos = file.lines()[line]; + + // Use 1-based indexing. + let line = (line + 1) as u32; + let col = (file.relative_position(pos) - line_pos).to_u32() + 1; + + (file, line, col) + } + Err(file) => (file, UNKNOWN_LINE_NUMBER, UNKNOWN_COLUMN_NUMBER), + }; + + // For MSVC, omit the column number. + // Otherwise, emit it. This mimics clang behaviour. + // See discussion in https://github.com/rust-lang/rust/issues/42921 + if self.sess().target.is_like_msvc { + DebugLoc { file, line, col: UNKNOWN_COLUMN_NUMBER } + } else { + DebugLoc { file, line, col } + } + } +} + +impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> { + fn create_vtable_debuginfo( + &self, + _ty: Ty<'tcx>, + _trait_ref: Option<ExistentialTraitRef<'tcx>>, + _vtable: Self::Value, + ) { + // TODO(antoyo) + } + + fn create_function_debug_context( + &self, + instance: Instance<'tcx>, + fn_abi: &FnAbi<'tcx, Ty<'tcx>>, + llfn: Function<'gcc>, + mir: &mir::Body<'tcx>, + ) -> Option<FunctionDebugContext<'tcx, Self::DIScope, Self::DILocation>> { + if self.sess().opts.debuginfo == DebugInfo::None { + return None; + } + + // Initialize fn debug context (including scopes). + let empty_scope = DebugScope { + dbg_scope: self.dbg_scope_fn(instance, fn_abi, Some(llfn)), + inlined_at: None, + file_start_pos: BytePos(0), + file_end_pos: BytePos(0), + }; + let mut fn_debug_context = FunctionDebugContext { + scopes: IndexVec::from_elem(empty_scope, mir.source_scopes.as_slice()), + inlined_function_scopes: Default::default(), + }; + + // Fill in all the scopes, with the information from the MIR body. + compute_mir_scopes(self, instance, mir, &mut fn_debug_context); + + Some(fn_debug_context) + } + + fn extend_scope_to_file( + &self, + _scope_metadata: Self::DIScope, + _file: &SourceFile, + ) -> Self::DIScope { + // TODO(antoyo): implement. + } + + fn debuginfo_finalize(&self) { + self.context.set_debug_info(true) + } + + fn create_dbg_var( + &self, + _variable_name: Symbol, + _variable_type: Ty<'tcx>, + _scope_metadata: Self::DIScope, + _variable_kind: VariableKind, + _span: Span, + ) -> Self::DIVariable { + } + + fn dbg_scope_fn( + &self, + _instance: Instance<'tcx>, + _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, + _maybe_definition_llfn: Option<Function<'gcc>>, + ) -> Self::DIScope { + // TODO(antoyo): implement. + } + + fn dbg_loc( + &self, + _scope: Self::DIScope, + _inlined_at: Option<Self::DILocation>, + span: Span, + ) -> Self::DILocation { + let pos = span.lo(); + let DebugLoc { file, line, col } = self.lookup_debug_loc(pos); + match file.name { + rustc_span::FileName::Real(ref name) => match *name { + rustc_span::RealFileName::LocalPath(ref name) => { + if let Some(name) = name.to_str() { + self.context.new_location(name, line as i32, col as i32) + } else { + Location::null() + } + } + rustc_span::RealFileName::Remapped { + ref local_path, + virtual_name: ref _unused, + } => { + if let Some(name) = local_path.as_ref() { + if let Some(name) = name.to_str() { + self.context.new_location(name, line as i32, col as i32) + } else { + Location::null() + } + } else { + Location::null() + } + } + }, + _ => Location::null(), + } + } +} diff --git a/compiler/rustc_codegen_gcc/src/declare.rs b/compiler/rustc_codegen_gcc/src/declare.rs new file mode 100644 index 00000000000..691fd8729e3 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/declare.rs @@ -0,0 +1,281 @@ +#[cfg(feature = "master")] +use gccjit::{FnAttribute, ToRValue}; +use gccjit::{Function, FunctionType, GlobalKind, LValue, RValue, Type}; +use rustc_codegen_ssa::traits::BaseTypeCodegenMethods; +use rustc_middle::ty::Ty; +use rustc_span::Symbol; +use rustc_target::callconv::FnAbi; + +use crate::abi::{FnAbiGcc, FnAbiGccExt}; +use crate::context::CodegenCx; +use crate::intrinsic::llvm; + +impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { + pub fn get_or_insert_global( + &self, + name: &str, + ty: Type<'gcc>, + is_tls: bool, + link_section: Option<Symbol>, + ) -> LValue<'gcc> { + if self.globals.borrow().contains_key(name) { + let typ = self.globals.borrow()[name].get_type(); + let global = self.context.new_global(None, GlobalKind::Imported, typ, name); + if is_tls { + global.set_tls_model(self.tls_model); + } + if let Some(link_section) = link_section { + global.set_link_section(link_section.as_str()); + } + global + } else { + self.declare_global(name, ty, GlobalKind::Exported, is_tls, link_section) + } + } + + pub fn declare_unnamed_global(&self, ty: Type<'gcc>) -> LValue<'gcc> { + let name = self.generate_local_symbol_name("global"); + self.context.new_global(None, GlobalKind::Internal, ty, name) + } + + pub fn declare_global_with_linkage( + &self, + name: &str, + ty: Type<'gcc>, + linkage: GlobalKind, + ) -> LValue<'gcc> { + let global = self.context.new_global(None, linkage, ty, name); + let global_address = global.get_address(None); + self.globals.borrow_mut().insert(name.to_string(), global_address); + global + } + + pub fn declare_func( + &self, + name: &str, + return_type: Type<'gcc>, + params: &[Type<'gcc>], + variadic: bool, + ) -> Function<'gcc> { + self.linkage.set(FunctionType::Extern); + declare_raw_fn(self, name, None, return_type, params, variadic) + } + + pub fn declare_global( + &self, + name: &str, + ty: Type<'gcc>, + global_kind: GlobalKind, + is_tls: bool, + link_section: Option<Symbol>, + ) -> LValue<'gcc> { + let global = self.context.new_global(None, global_kind, ty, name); + if is_tls { + global.set_tls_model(self.tls_model); + } + if let Some(link_section) = link_section { + global.set_link_section(link_section.as_str()); + } + let global_address = global.get_address(None); + self.globals.borrow_mut().insert(name.to_string(), global_address); + global + } + + pub fn declare_private_global(&self, name: &str, ty: Type<'gcc>) -> LValue<'gcc> { + let global = self.context.new_global(None, GlobalKind::Internal, ty, name); + let global_address = global.get_address(None); + self.globals.borrow_mut().insert(name.to_string(), global_address); + global + } + + pub fn declare_entry_fn( + &self, + name: &str, + _fn_type: Type<'gcc>, + #[cfg(feature = "master")] callconv: Option<FnAttribute<'gcc>>, + #[cfg(not(feature = "master"))] callconv: Option<()>, + ) -> Function<'gcc> { + // TODO(antoyo): use the fn_type parameter. + let const_string = self.context.new_type::<u8>().make_pointer().make_pointer(); + let return_type = self.type_i32(); + let variadic = false; + self.linkage.set(FunctionType::Exported); + let func = declare_raw_fn( + self, + name, + callconv, + return_type, + &[self.type_i32(), const_string], + variadic, + ); + // NOTE: it is needed to set the current_func here as well, because get_fn() is not called + // for the main function. + *self.current_func.borrow_mut() = Some(func); + func + } + + pub fn declare_fn(&self, name: &str, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> Function<'gcc> { + let FnAbiGcc { + return_type, + arguments_type, + is_c_variadic, + on_stack_param_indices, + #[cfg(feature = "master")] + fn_attributes, + } = fn_abi.gcc_type(self); + #[cfg(feature = "master")] + let conv = fn_abi.gcc_cconv(self); + #[cfg(not(feature = "master"))] + let conv = None; + let func = declare_raw_fn(self, name, conv, return_type, &arguments_type, is_c_variadic); + self.on_stack_function_params.borrow_mut().insert(func, on_stack_param_indices); + #[cfg(feature = "master")] + for fn_attr in fn_attributes { + func.add_attribute(fn_attr); + } + func + } + + pub fn define_global( + &self, + name: &str, + ty: Type<'gcc>, + is_tls: bool, + link_section: Option<Symbol>, + ) -> LValue<'gcc> { + self.get_or_insert_global(name, ty, is_tls, link_section) + } + + pub fn get_declared_value(&self, name: &str) -> Option<RValue<'gcc>> { + // TODO(antoyo): use a different field than globals, because this seems to return a function? + self.globals.borrow().get(name).cloned() + } +} + +/// Declare a function. +/// +/// If there’s a value with the same name already declared, the function will +/// update the declaration and return existing Value instead. +#[allow(clippy::let_and_return)] +fn declare_raw_fn<'gcc>( + cx: &CodegenCx<'gcc, '_>, + name: &str, + #[cfg(feature = "master")] callconv: Option<FnAttribute<'gcc>>, + #[cfg(not(feature = "master"))] _callconv: Option<()>, + return_type: Type<'gcc>, + param_types: &[Type<'gcc>], + variadic: bool, +) -> Function<'gcc> { + if name.starts_with("llvm.") { + let intrinsic = match name { + "llvm.fma.f16" => { + // fma is not a target builtin, but a normal builtin, so we handle it differently + // here. + cx.context.get_builtin_function("fma") + } + _ => llvm::intrinsic(name, cx), + }; + + cx.intrinsics.borrow_mut().insert(name.to_string(), intrinsic); + return intrinsic; + } + let func = if cx.functions.borrow().contains_key(name) { + cx.functions.borrow()[name] + } else { + let params: Vec<_> = param_types + .iter() + .enumerate() + .map(|(index, param)| cx.context.new_parameter(None, *param, format!("param{}", index))) // TODO(antoyo): set name. + .collect(); + #[cfg(not(feature = "master"))] + let name = &mangle_name(name); + let func = + cx.context.new_function(None, cx.linkage.get(), return_type, ¶ms, name, variadic); + #[cfg(feature = "master")] + if let Some(attribute) = callconv { + func.add_attribute(attribute); + } + cx.functions.borrow_mut().insert(name.to_string(), func); + + #[cfg(feature = "master")] + if name == "rust_eh_personality" { + // NOTE: GCC will sometimes change the personality function set on a function from + // rust_eh_personality to __gcc_personality_v0 as an optimization. + // As such, we need to create a weak alias from __gcc_personality_v0 to + // rust_eh_personality in order to avoid a linker error. + // This needs to be weak in order to still allow using the standard + // __gcc_personality_v0 when the linking to it. + // Since aliases don't work (maybe because of a bug in LTO partitioning?), we + // create a wrapper function that calls rust_eh_personality. + + let params: Vec<_> = param_types + .iter() + .enumerate() + .map(|(index, param)| { + cx.context.new_parameter(None, *param, format!("param{}", index)) + }) // TODO(antoyo): set name. + .collect(); + let gcc_func = cx.context.new_function( + None, + FunctionType::Exported, + return_type, + ¶ms, + "__gcc_personality_v0", + variadic, + ); + + // We need a normal extern function for the crates that access rust_eh_personality + // without defining it, otherwise we'll get a compiler error. + // + // For the crate defining it, that needs to be a weak alias instead. + gcc_func.add_attribute(FnAttribute::Weak); + + let block = gcc_func.new_block("start"); + let mut args = vec![]; + for param in ¶ms { + args.push(param.to_rvalue()); + } + let call = cx.context.new_call(None, func, &args); + if return_type == cx.type_void() { + block.add_eval(None, call); + block.end_with_void_return(None); + } else { + block.end_with_return(None, call); + } + } + + func + }; + + // TODO(antoyo): set function calling convention. + // TODO(antoyo): set unnamed address. + // TODO(antoyo): set no red zone function attribute. + // TODO(antoyo): set attributes for optimisation. + // TODO(antoyo): set attributes for non lazy bind. + + // FIXME(antoyo): invalid cast. + func +} + +// FIXME(antoyo): this is a hack because libgccjit currently only supports alpha, num and _. +// Unsupported characters: `$`, `.` and `*`. +// FIXME(antoyo): `*` might not be expected: https://github.com/rust-lang/rust/issues/116979#issuecomment-1840926865 +#[cfg(not(feature = "master"))] +fn mangle_name(name: &str) -> String { + name.replace( + |char: char| { + if !char.is_alphanumeric() && char != '_' { + debug_assert!( + "$.*".contains(char), + "Unsupported char in function name {}: {}", + name, + char + ); + true + } else { + false + } + }, + "_", + ) +} diff --git a/compiler/rustc_codegen_gcc/src/errors.rs b/compiler/rustc_codegen_gcc/src/errors.rs new file mode 100644 index 00000000000..b252c39c0c0 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/errors.rs @@ -0,0 +1,25 @@ +use rustc_macros::Diagnostic; +use rustc_span::Span; + +#[derive(Diagnostic)] +#[diag(codegen_gcc_unwinding_inline_asm)] +pub(crate) struct UnwindingInlineAsm { + #[primary_span] + pub span: Span, +} + +#[derive(Diagnostic)] +#[diag(codegen_gcc_copy_bitcode)] +pub(crate) struct CopyBitcode { + pub err: std::io::Error, +} + +#[derive(Diagnostic)] +#[diag(codegen_gcc_lto_bitcode_from_rlib)] +pub(crate) struct LtoBitcodeFromRlib { + pub gcc_err: String, +} + +#[derive(Diagnostic)] +#[diag(codegen_gcc_explicit_tail_calls_unsupported)] +pub(crate) struct ExplicitTailCallsUnsupported; diff --git a/compiler/rustc_codegen_gcc/src/gcc_util.rs b/compiler/rustc_codegen_gcc/src/gcc_util.rs new file mode 100644 index 00000000000..42ba40692b7 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/gcc_util.rs @@ -0,0 +1,139 @@ +#[cfg(feature = "master")] +use gccjit::Context; +use rustc_codegen_ssa::target_features; +use rustc_session::Session; +use smallvec::{SmallVec, smallvec}; + +fn gcc_features_by_flags(sess: &Session, features: &mut Vec<String>) { + target_features::retpoline_features_by_flags(sess, features); + // FIXME: LLVM also sets +reserve-x18 here under some conditions. +} + +/// The list of GCC features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`, +/// `--target` and similar). +pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<String> { + // Features that come earlier are overridden by conflicting features later in the string. + // Typically we'll want more explicit settings to override the implicit ones, so: + // + // * Features from -Ctarget-cpu=*; are overridden by [^1] + // * Features implied by --target; are overridden by + // * Features from -Ctarget-feature; are overridden by + // * function specific features. + // + // [^1]: target-cpu=native is handled here, other target-cpu values are handled implicitly + // through GCC march implementation. + // + // FIXME(nagisa): it isn't clear what's the best interaction between features implied by + // `-Ctarget-cpu` and `--target` are. On one hand, you'd expect CLI arguments to always + // override anything that's implicit, so e.g. when there's no `--target` flag, features implied + // the host target are overridden by `-Ctarget-cpu=*`. On the other hand, what about when both + // `--target` and `-Ctarget-cpu=*` are specified? Both then imply some target features and both + // flags are specified by the user on the CLI. It isn't as clear-cut which order of precedence + // should be taken in cases like these. + let mut features = vec![]; + + // Features implied by an implicit or explicit `--target`. + features.extend(sess.target.features.split(',').filter(|v| !v.is_empty()).map(String::from)); + + // -Ctarget-features + target_features::flag_to_backend_features( + sess, + diagnostics, + |feature| to_gcc_features(sess, feature), + |feature, enable| { + // We run through `to_gcc_features` when + // passing requests down to GCC. This means that all in-language + // features also work on the command line instead of having two + // different names when the GCC name and the Rust name differ. + features.extend( + to_gcc_features(sess, feature) + .iter() + .flat_map(|feat| to_gcc_features(sess, feat).into_iter()) + .map( + |feature| { + if !enable { format!("-{}", feature) } else { feature.to_string() } + }, + ), + ); + }, + ); + + gcc_features_by_flags(sess, &mut features); + + features +} + +// To find a list of GCC's names, check https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html +pub fn to_gcc_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]> { + let arch = if sess.target.arch == "x86_64" { "x86" } else { &*sess.target.arch }; + // cSpell:disable + match (arch, s) { + // FIXME: seems like x87 does not exist? + ("x86", "x87") => smallvec![], + ("x86", "sse4.2") => smallvec!["sse4.2", "crc32"], + ("x86", "pclmulqdq") => smallvec!["pclmul"], + ("x86", "rdrand") => smallvec!["rdrnd"], + ("x86", "bmi1") => smallvec!["bmi"], + ("x86", "cmpxchg16b") => smallvec!["cx16"], + ("x86", "avx512vaes") => smallvec!["vaes"], + ("x86", "avx512gfni") => smallvec!["gfni"], + ("x86", "avx512vpclmulqdq") => smallvec!["vpclmulqdq"], + // NOTE: seems like GCC requires 'avx512bw' for 'avx512vbmi2'. + ("x86", "avx512vbmi2") => smallvec!["avx512vbmi2", "avx512bw"], + // NOTE: seems like GCC requires 'avx512bw' for 'avx512bitalg'. + ("x86", "avx512bitalg") => smallvec!["avx512bitalg", "avx512bw"], + ("aarch64", "rcpc2") => smallvec!["rcpc-immo"], + ("aarch64", "dpb") => smallvec!["ccpp"], + ("aarch64", "dpb2") => smallvec!["ccdp"], + ("aarch64", "frintts") => smallvec!["fptoint"], + ("aarch64", "fcma") => smallvec!["complxnum"], + ("aarch64", "pmuv3") => smallvec!["perfmon"], + ("aarch64", "paca") => smallvec!["pauth"], + ("aarch64", "pacg") => smallvec!["pauth"], + // Rust ties fp and neon together. In GCC neon implicitly enables fp, + // but we manually enable neon when a feature only implicitly enables fp + ("aarch64", "f32mm") => smallvec!["f32mm", "neon"], + ("aarch64", "f64mm") => smallvec!["f64mm", "neon"], + ("aarch64", "fhm") => smallvec!["fp16fml", "neon"], + ("aarch64", "fp16") => smallvec!["fullfp16", "neon"], + ("aarch64", "jsconv") => smallvec!["jsconv", "neon"], + ("aarch64", "sve") => smallvec!["sve", "neon"], + ("aarch64", "sve2") => smallvec!["sve2", "neon"], + ("aarch64", "sve2-aes") => smallvec!["sve2-aes", "neon"], + ("aarch64", "sve2-sm4") => smallvec!["sve2-sm4", "neon"], + ("aarch64", "sve2-sha3") => smallvec!["sve2-sha3", "neon"], + ("aarch64", "sve2-bitperm") => smallvec!["sve2-bitperm", "neon"], + (_, s) => smallvec![s], + } + // cSpell:enable +} + +fn arch_to_gcc(name: &str) -> &str { + match name { + "M68000" => "68000", + "M68020" => "68020", + _ => name, + } +} + +fn handle_native(name: &str) -> &str { + if name != "native" { + return arch_to_gcc(name); + } + + #[cfg(feature = "master")] + { + // Get the native arch. + let context = Context::default(); + context.get_target_info().arch().unwrap().to_str().unwrap() + } + #[cfg(not(feature = "master"))] + unimplemented!(); +} + +pub fn target_cpu(sess: &Session) -> &str { + match sess.opts.cg.target_cpu { + Some(ref name) => handle_native(name), + None => handle_native(sess.target.cpu.as_ref()), + } +} diff --git a/compiler/rustc_codegen_gcc/src/int.rs b/compiler/rustc_codegen_gcc/src/int.rs new file mode 100644 index 00000000000..9fb7f6bad68 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/int.rs @@ -0,0 +1,1102 @@ +//! Module to handle integer operations. +//! This module exists because some integer types are not supported on some gcc platforms, e.g. +//! 128-bit integers on 32-bit platforms and thus require to be handled manually. + +// cSpell:words cmpti divti modti mulodi muloti udivti umodti + +use gccjit::{ + BinaryOp, CType, ComparisonOp, FunctionType, Location, RValue, ToRValue, Type, UnaryOp, +}; +use rustc_abi::{CanonAbi, Endian, ExternAbi}; +use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; +use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeCodegenMethods, BuilderMethods, OverflowOp}; +use rustc_middle::ty::{self, Ty}; +use rustc_target::callconv::{ArgAbi, ArgAttributes, FnAbi, PassMode}; +use rustc_type_ir::{Interner, TyKind}; + +use crate::builder::{Builder, ToGccComp}; +use crate::common::{SignType, TypeReflection}; +use crate::context::CodegenCx; + +impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { + pub fn gcc_urem(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + // 128-bit unsigned %: __umodti3 + self.multiplicative_operation(BinaryOp::Modulo, "mod", false, a, b) + } + + pub fn gcc_srem(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + // 128-bit signed %: __modti3 + self.multiplicative_operation(BinaryOp::Modulo, "mod", true, a, b) + } + + pub fn gcc_not(&self, a: RValue<'gcc>) -> RValue<'gcc> { + let typ = a.get_type(); + if self.is_native_int_type_or_bool(typ) { + let operation = + if typ.is_bool() { UnaryOp::LogicalNegate } else { UnaryOp::BitwiseNegate }; + self.cx.context.new_unary_op(self.location, operation, typ, a) + } else { + let element_type = typ.dyncast_array().expect("element type"); + self.concat_low_high_rvalues( + typ, + self.cx.context.new_unary_op( + self.location, + UnaryOp::BitwiseNegate, + element_type, + self.low(a), + ), + self.cx.context.new_unary_op( + self.location, + UnaryOp::BitwiseNegate, + element_type, + self.high(a), + ), + ) + } + } + + pub fn gcc_neg(&self, a: RValue<'gcc>) -> RValue<'gcc> { + let a_type = a.get_type(); + if self.is_native_int_type(a_type) || a_type.is_vector() { + self.cx.context.new_unary_op(self.location, UnaryOp::Minus, a.get_type(), a) + } else { + self.gcc_add(self.gcc_not(a), self.gcc_int(a_type, 1)) + } + } + + pub fn gcc_and(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.cx.bitwise_operation(BinaryOp::BitwiseAnd, a, b, self.location) + } + + pub fn gcc_lshr(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + let a_type = a.get_type(); + let b_type = b.get_type(); + let a_native = self.is_native_int_type(a_type); + let b_native = self.is_native_int_type(b_type); + if a_native && b_native { + // FIXME(antoyo): remove the casts when libgccjit can shift an unsigned number by a signed number. + // TODO(antoyo): cast to unsigned to do a logical shift if that does not work. + if a_type.is_signed(self) != b_type.is_signed(self) { + let b = self.context.new_cast(self.location, b, a_type); + a >> b + } else { + let a_size = a_type.get_size(); + let b_size = b_type.get_size(); + match a_size.cmp(&b_size) { + std::cmp::Ordering::Less => { + let a = self.context.new_cast(self.location, a, b_type); + a >> b + } + std::cmp::Ordering::Equal => a >> b, + std::cmp::Ordering::Greater => { + let b = self.context.new_cast(self.location, b, a_type); + a >> b + } + } + } + } else if a_type.is_vector() && b_type.is_vector() { + a >> b + } else if a_native && !b_native { + self.gcc_lshr(a, self.gcc_int_cast(b, a_type)) + } else { + // NOTE: we cannot use the lshr builtin because it's calling hi() (to get the most + // significant half of the number) which uses lshr. + + let native_int_type = a_type.dyncast_array().expect("get element type"); + + let func = self.current_func(); + let then_block = func.new_block("then"); + let else_block = func.new_block("else"); + let after_block = func.new_block("after"); + let b0_block = func.new_block("b0"); + let actual_else_block = func.new_block("actual_else"); + + let result = func.new_local(self.location, a_type, "shiftResult"); + + let sixty_four = self.gcc_int(native_int_type, 64); + let sixty_three = self.gcc_int(native_int_type, 63); + let zero = self.gcc_zero(native_int_type); + let b = self.gcc_int_cast(b, native_int_type); + let condition = self.gcc_icmp(IntPredicate::IntNE, self.gcc_and(b, sixty_four), zero); + self.llbb().end_with_conditional(self.location, condition, then_block, else_block); + + let shift_value = self.gcc_sub(b, sixty_four); + let high = self.high(a); + let sign = if a_type.is_signed(self) { high >> sixty_three } else { zero }; + let array_value = self.concat_low_high_rvalues(a_type, high >> shift_value, sign); + then_block.add_assignment(self.location, result, array_value); + then_block.end_with_jump(self.location, after_block); + + let condition = self.gcc_icmp(IntPredicate::IntEQ, b, zero); + else_block.end_with_conditional(self.location, condition, b0_block, actual_else_block); + + b0_block.add_assignment(self.location, result, a); + b0_block.end_with_jump(self.location, after_block); + + let shift_value = self.gcc_sub(sixty_four, b); + // NOTE: cast low to its unsigned type in order to perform a logical right shift. + let unsigned_type = native_int_type.to_unsigned(self.cx); + let casted_low = self.context.new_cast(self.location, self.low(a), unsigned_type); + let shifted_low = casted_low >> self.context.new_cast(self.location, b, unsigned_type); + let shifted_low = self.context.new_cast(self.location, shifted_low, native_int_type); + let array_value = self.concat_low_high_rvalues( + a_type, + (high << shift_value) | shifted_low, + high >> b, + ); + actual_else_block.add_assignment(self.location, result, array_value); + actual_else_block.end_with_jump(self.location, after_block); + + // NOTE: since jumps were added in a place rustc does not expect, the current block in the + // state need to be updated. + self.switch_to_block(after_block); + + result.to_rvalue() + } + } + + fn additive_operation( + &self, + operation: BinaryOp, + a: RValue<'gcc>, + mut b: RValue<'gcc>, + ) -> RValue<'gcc> { + let a_type = a.get_type(); + let b_type = b.get_type(); + if (self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type)) + || (a_type.is_vector() && b_type.is_vector()) + { + if a_type != b_type { + if a_type.is_vector() { + // Vector types need to be bitcast. + // TODO(antoyo): perhaps use __builtin_convertvector for vector casting. + b = self.context.new_bitcast(self.location, b, a_type); + } else { + b = self.context.new_cast(self.location, b, a_type); + } + } + self.context.new_binary_op(self.location, operation, a_type, a, b) + } else { + debug_assert!(a_type.dyncast_array().is_some()); + debug_assert!(b_type.dyncast_array().is_some()); + let signed = a_type.is_compatible_with(self.i128_type); + let func_name = match (operation, signed) { + (BinaryOp::Plus, true) => "__rust_i128_add", + (BinaryOp::Plus, false) => "__rust_u128_add", + (BinaryOp::Minus, true) => "__rust_i128_sub", + (BinaryOp::Minus, false) => "__rust_u128_sub", + _ => unreachable!("unexpected additive operation {:?}", operation), + }; + let param_a = self.context.new_parameter(self.location, a_type, "a"); + let param_b = self.context.new_parameter(self.location, b_type, "b"); + let func = self.context.new_function( + self.location, + FunctionType::Extern, + a_type, + &[param_a, param_b], + func_name, + false, + ); + self.context.new_call(self.location, func, &[a, b]) + } + } + + pub fn gcc_add(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.additive_operation(BinaryOp::Plus, a, b) + } + + pub fn gcc_mul(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.multiplicative_operation(BinaryOp::Mult, "mul", true, a, b) + } + + pub fn gcc_sub(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + self.additive_operation(BinaryOp::Minus, a, b) + } + + fn multiplicative_operation( + &self, + operation: BinaryOp, + operation_name: &str, + signed: bool, + a: RValue<'gcc>, + mut b: RValue<'gcc>, + ) -> RValue<'gcc> { + let a_type = a.get_type(); + let b_type = b.get_type(); + if (self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type)) + || (a_type.is_vector() && b_type.is_vector()) + { + if !a_type.is_compatible_with(b_type) { + if a_type.is_vector() { + // Vector types need to be bitcast. + // TODO(antoyo): perhaps use __builtin_convertvector for vector casting. + b = self.context.new_bitcast(self.location, b, a_type); + } else { + b = self.context.new_cast(self.location, b, a_type); + } + } + self.context.new_binary_op(self.location, operation, a_type, a, b) + } else { + debug_assert!(a_type.dyncast_array().is_some()); + debug_assert!(b_type.dyncast_array().is_some()); + let sign = if signed { "" } else { "u" }; + let func_name = format!("__{}{}ti3", sign, operation_name); + let param_a = self.context.new_parameter(self.location, a_type, "a"); + let param_b = self.context.new_parameter(self.location, b_type, "b"); + let func = self.context.new_function( + self.location, + FunctionType::Extern, + a_type, + &[param_a, param_b], + func_name, + false, + ); + self.context.new_call(self.location, func, &[a, b]) + } + } + + pub fn gcc_sdiv(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + // TODO(antoyo): check if the types are signed? + // 128-bit, signed: __divti3 + // TODO(antoyo): convert the arguments to signed? + self.multiplicative_operation(BinaryOp::Divide, "div", true, a, b) + } + + pub fn gcc_udiv(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + // 128-bit, unsigned: __udivti3 + self.multiplicative_operation(BinaryOp::Divide, "div", false, a, b) + } + + pub fn gcc_checked_binop( + &self, + oop: OverflowOp, + typ: Ty<'_>, + lhs: <Self as BackendTypes>::Value, + rhs: <Self as BackendTypes>::Value, + ) -> (<Self as BackendTypes>::Value, <Self as BackendTypes>::Value) { + use rustc_middle::ty::IntTy::*; + use rustc_middle::ty::UintTy::*; + use rustc_middle::ty::{Int, Uint}; + + let new_kind = match *typ.kind() { + Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.pointer_width)), + Uint(t @ Usize) => Uint(t.normalize(self.tcx.sess.target.pointer_width)), + t @ (Uint(_) | Int(_)) => t, + _ => panic!("tried to get overflow intrinsic for op applied to non-int type"), + }; + + // TODO(antoyo): remove duplication with intrinsic? + let name = if self.is_native_int_type(lhs.get_type()) { + match oop { + OverflowOp::Add => match new_kind { + Int(I8) => "__builtin_add_overflow", + Int(I16) => "__builtin_add_overflow", + Int(I32) => "__builtin_sadd_overflow", + Int(I64) => "__builtin_saddll_overflow", + Int(I128) => "__builtin_add_overflow", + + Uint(U8) => "__builtin_add_overflow", + Uint(U16) => "__builtin_add_overflow", + Uint(U32) => "__builtin_uadd_overflow", + Uint(U64) => "__builtin_uaddll_overflow", + Uint(U128) => "__builtin_add_overflow", + + _ => unreachable!(), + }, + OverflowOp::Sub => match new_kind { + Int(I8) => "__builtin_sub_overflow", + Int(I16) => "__builtin_sub_overflow", + Int(I32) => "__builtin_ssub_overflow", + Int(I64) => "__builtin_ssubll_overflow", + Int(I128) => "__builtin_sub_overflow", + + Uint(U8) => "__builtin_sub_overflow", + Uint(U16) => "__builtin_sub_overflow", + Uint(U32) => "__builtin_usub_overflow", + Uint(U64) => "__builtin_usubll_overflow", + Uint(U128) => "__builtin_sub_overflow", + + _ => unreachable!(), + }, + OverflowOp::Mul => match new_kind { + Int(I8) => "__builtin_mul_overflow", + Int(I16) => "__builtin_mul_overflow", + Int(I32) => "__builtin_smul_overflow", + Int(I64) => "__builtin_smulll_overflow", + Int(I128) => "__builtin_mul_overflow", + + Uint(U8) => "__builtin_mul_overflow", + Uint(U16) => "__builtin_mul_overflow", + Uint(U32) => "__builtin_umul_overflow", + Uint(U64) => "__builtin_umulll_overflow", + Uint(U128) => "__builtin_mul_overflow", + + _ => unreachable!(), + }, + } + } else { + let (func_name, width) = match oop { + OverflowOp::Add => match new_kind { + Int(I128) => ("__rust_i128_addo", 128), + Uint(U128) => ("__rust_u128_addo", 128), + _ => unreachable!(), + }, + OverflowOp::Sub => match new_kind { + Int(I128) => ("__rust_i128_subo", 128), + Uint(U128) => ("__rust_u128_subo", 128), + _ => unreachable!(), + }, + OverflowOp::Mul => match new_kind { + Int(I32) => ("__mulosi4", 32), + Int(I64) => ("__mulodi4", 64), + Int(I128) => ("__rust_i128_mulo", 128), // TODO(antoyo): use __muloti4d instead? + Uint(U128) => ("__rust_u128_mulo", 128), + _ => unreachable!(), + }, + }; + return self.operation_with_overflow(func_name, lhs, rhs, width); + }; + + let intrinsic = self.context.get_builtin_function(name); + let res = self + .current_func() + // TODO(antoyo): is it correct to use rhs type instead of the parameter typ? + .new_local(self.location, rhs.get_type(), "binopResult") + .get_address(self.location); + let new_type = type_kind_to_gcc_type(new_kind); + let new_type = self.context.new_c_type(new_type); + let lhs = self.context.new_cast(self.location, lhs, new_type); + let rhs = self.context.new_cast(self.location, rhs, new_type); + let res = self.context.new_cast(self.location, res, new_type.make_pointer()); + let overflow = self.overflow_call(intrinsic, &[lhs, rhs, res], None); + (res.dereference(self.location).to_rvalue(), overflow) + } + + /// Non-`__builtin_*` overflow operations with a `fn(T, T, &mut i32) -> T` signature. + pub fn operation_with_overflow( + &self, + func_name: &str, + lhs: RValue<'gcc>, + rhs: RValue<'gcc>, + width: u64, + ) -> (RValue<'gcc>, RValue<'gcc>) { + let a_type = lhs.get_type(); + let b_type = rhs.get_type(); + debug_assert!(a_type.dyncast_array().is_some()); + debug_assert!(b_type.dyncast_array().is_some()); + let overflow_type = self.i32_type; + let overflow_param_type = overflow_type.make_pointer(); + let res_type = a_type; + + let overflow_value = + self.current_func().new_local(self.location, overflow_type, "overflow"); + let overflow_addr = overflow_value.get_address(self.location); + + let param_a = self.context.new_parameter(self.location, a_type, "a"); + let param_b = self.context.new_parameter(self.location, b_type, "b"); + let param_overflow = + self.context.new_parameter(self.location, overflow_param_type, "overflow"); + + let a_elem_type = a_type.dyncast_array().expect("non-array a value"); + debug_assert!(a_elem_type.is_integral()); + let res_ty = match width { + 32 => self.tcx.types.i32, + 64 => self.tcx.types.i64, + 128 => self.tcx.types.i128, + _ => unreachable!("unexpected integer size"), + }; + let layout = self + .tcx + .layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(res_ty)) + .unwrap(); + + let arg_abi = ArgAbi { layout, mode: PassMode::Direct(ArgAttributes::new()) }; + let mut fn_abi = FnAbi { + args: vec![arg_abi.clone(), arg_abi.clone(), arg_abi.clone()].into_boxed_slice(), + ret: arg_abi, + c_variadic: false, + fixed_count: 3, + conv: CanonAbi::C, + can_unwind: false, + }; + fn_abi.adjust_for_foreign_abi(self.cx, ExternAbi::C { unwind: false }); + + let ret_indirect = matches!(fn_abi.ret.mode, PassMode::Indirect { .. }); + + let call = if ret_indirect { + let res_value = self.current_func().new_local(self.location, res_type, "result_value"); + let res_addr = res_value.get_address(self.location); + let res_param_type = res_type.make_pointer(); + let param_res = self.context.new_parameter(self.location, res_param_type, "result"); + + let func = self.context.new_function( + self.location, + FunctionType::Extern, + self.type_void(), + &[param_res, param_a, param_b, param_overflow], + func_name, + false, + ); + let _void = + self.context.new_call(self.location, func, &[res_addr, lhs, rhs, overflow_addr]); + res_value.to_rvalue() + } else { + let func = self.context.new_function( + self.location, + FunctionType::Extern, + res_type, + &[param_a, param_b, param_overflow], + func_name, + false, + ); + self.context.new_call(self.location, func, &[lhs, rhs, overflow_addr]) + }; + // NOTE: we must assign the result of the operation to a variable at this point to make + // sure it will be evaluated by libgccjit now. + // Otherwise, it will only be evaluated when the rvalue for the call is used somewhere else + // and overflow_value will not be initialized at the correct point in the program. + let result = self.current_func().new_local(self.location, res_type, "result"); + self.block.add_assignment(self.location, result, call); + + ( + result.to_rvalue(), + self.context.new_cast(self.location, overflow_value, self.bool_type).to_rvalue(), + ) + } + + pub fn gcc_icmp( + &mut self, + op: IntPredicate, + mut lhs: RValue<'gcc>, + mut rhs: RValue<'gcc>, + ) -> RValue<'gcc> { + let a_type = lhs.get_type(); + let b_type = rhs.get_type(); + if self.is_non_native_int_type(a_type) || self.is_non_native_int_type(b_type) { + // This algorithm is based on compiler-rt's __cmpti2: + // https://github.com/llvm-mirror/compiler-rt/blob/f0745e8476f069296a7c71accedd061dce4cdf79/lib/builtins/cmpti2.c#L21 + let result = self.current_func().new_local(self.location, self.int_type, "icmp_result"); + let block1 = self.current_func().new_block("block1"); + let block2 = self.current_func().new_block("block2"); + let block3 = self.current_func().new_block("block3"); + let block4 = self.current_func().new_block("block4"); + let block5 = self.current_func().new_block("block5"); + let block6 = self.current_func().new_block("block6"); + let block7 = self.current_func().new_block("block7"); + let block8 = self.current_func().new_block("block8"); + let after = self.current_func().new_block("after"); + + let native_int_type = a_type.dyncast_array().expect("get element type"); + // NOTE: cast low to its unsigned type in order to perform a comparison correctly (e.g. + // the sign is only on high). + let unsigned_type = native_int_type.to_unsigned(self.cx); + + let lhs_low = self.context.new_cast(self.location, self.low(lhs), unsigned_type); + let rhs_low = self.context.new_cast(self.location, self.low(rhs), unsigned_type); + + let mut lhs_high = self.high(lhs); + let mut rhs_high = self.high(rhs); + + match op { + IntPredicate::IntUGT + | IntPredicate::IntUGE + | IntPredicate::IntULT + | IntPredicate::IntULE => { + lhs_high = self.context.new_cast(self.location, lhs_high, unsigned_type); + rhs_high = self.context.new_cast(self.location, rhs_high, unsigned_type); + } + // TODO(antoyo): we probably need to handle signed comparison for unsigned + // integers. + _ => (), + } + + let condition = self.context.new_comparison( + self.location, + ComparisonOp::LessThan, + lhs_high, + rhs_high, + ); + self.llbb().end_with_conditional(self.location, condition, block1, block2); + + block1.add_assignment( + self.location, + result, + self.context.new_rvalue_zero(self.int_type), + ); + block1.end_with_jump(self.location, after); + + let condition = self.context.new_comparison( + self.location, + ComparisonOp::GreaterThan, + lhs_high, + rhs_high, + ); + block2.end_with_conditional(self.location, condition, block3, block4); + + block3.add_assignment( + self.location, + result, + self.context.new_rvalue_from_int(self.int_type, 2), + ); + block3.end_with_jump(self.location, after); + + let condition = self.context.new_comparison( + self.location, + ComparisonOp::LessThan, + lhs_low, + rhs_low, + ); + block4.end_with_conditional(self.location, condition, block5, block6); + + block5.add_assignment( + self.location, + result, + self.context.new_rvalue_zero(self.int_type), + ); + block5.end_with_jump(self.location, after); + + let condition = self.context.new_comparison( + self.location, + ComparisonOp::GreaterThan, + lhs_low, + rhs_low, + ); + block6.end_with_conditional(self.location, condition, block7, block8); + + block7.add_assignment( + self.location, + result, + self.context.new_rvalue_from_int(self.int_type, 2), + ); + block7.end_with_jump(self.location, after); + + block8.add_assignment( + self.location, + result, + self.context.new_rvalue_one(self.int_type), + ); + block8.end_with_jump(self.location, after); + + // NOTE: since jumps were added in a place rustc does not expect, the current block in the + // state need to be updated. + self.switch_to_block(after); + + let cmp = result.to_rvalue(); + let (op, limit) = match op { + IntPredicate::IntEQ => { + return self.context.new_comparison( + self.location, + ComparisonOp::Equals, + cmp, + self.context.new_rvalue_one(self.int_type), + ); + } + IntPredicate::IntNE => { + return self.context.new_comparison( + self.location, + ComparisonOp::NotEquals, + cmp, + self.context.new_rvalue_one(self.int_type), + ); + } + // TODO(antoyo): cast to u128 for unsigned comparison. See below. + IntPredicate::IntUGT => (ComparisonOp::Equals, 2), + IntPredicate::IntUGE => (ComparisonOp::GreaterThanEquals, 1), + IntPredicate::IntULT => (ComparisonOp::Equals, 0), + IntPredicate::IntULE => (ComparisonOp::LessThanEquals, 1), + IntPredicate::IntSGT => (ComparisonOp::Equals, 2), + IntPredicate::IntSGE => (ComparisonOp::GreaterThanEquals, 1), + IntPredicate::IntSLT => (ComparisonOp::Equals, 0), + IntPredicate::IntSLE => (ComparisonOp::LessThanEquals, 1), + }; + self.context.new_comparison( + self.location, + op, + cmp, + self.context.new_rvalue_from_int(self.int_type, limit), + ) + } else if a_type.get_pointee().is_some() && b_type.get_pointee().is_some() { + // NOTE: gcc cannot compare pointers to different objects, but rustc does that, so cast them to usize. + lhs = self.context.new_bitcast(self.location, lhs, self.usize_type); + rhs = self.context.new_bitcast(self.location, rhs, self.usize_type); + self.context.new_comparison(self.location, op.to_gcc_comparison(), lhs, rhs) + } else { + if a_type != b_type { + // NOTE: because libgccjit cannot compare function pointers. + if a_type.dyncast_function_ptr_type().is_some() + && b_type.dyncast_function_ptr_type().is_some() + { + lhs = self.context.new_cast(self.location, lhs, self.usize_type.make_pointer()); + rhs = self.context.new_cast(self.location, rhs, self.usize_type.make_pointer()); + } + // NOTE: hack because we try to cast a vector type to the same vector type. + else if format!("{:?}", a_type) != format!("{:?}", b_type) { + rhs = self.context.new_cast(self.location, rhs, a_type); + } + } + match op { + IntPredicate::IntUGT + | IntPredicate::IntUGE + | IntPredicate::IntULT + | IntPredicate::IntULE => { + if !a_type.is_vector() { + let unsigned_type = a_type.to_unsigned(self.cx); + lhs = self.context.new_cast(self.location, lhs, unsigned_type); + rhs = self.context.new_cast(self.location, rhs, unsigned_type); + } + } + // TODO(antoyo): we probably need to handle signed comparison for unsigned + // integers. + _ => (), + } + self.context.new_comparison(self.location, op.to_gcc_comparison(), lhs, rhs) + } + } + + pub fn gcc_xor(&self, a: RValue<'gcc>, mut b: RValue<'gcc>) -> RValue<'gcc> { + let a_type = a.get_type(); + let b_type = b.get_type(); + if a_type.is_vector() && b_type.is_vector() { + let b = self.bitcast_if_needed(b, a_type); + a ^ b + } else if self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type) + { + if !a_type.is_compatible_with(b_type) { + b = self.context.new_cast(self.location, b, a_type); + } + a ^ b + } else { + self.concat_low_high_rvalues( + a_type, + self.low(a) ^ self.low(b), + self.high(a) ^ self.high(b), + ) + } + } + + pub fn gcc_shl(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { + let a_type = a.get_type(); + let b_type = b.get_type(); + let a_native = self.is_native_int_type(a_type); + let b_native = self.is_native_int_type(b_type); + if a_native && b_native { + // FIXME(antoyo): remove the casts when libgccjit can shift an unsigned number by an unsigned number. + if a_type.is_unsigned(self) && b_type.is_signed(self) { + let a = self.context.new_cast(self.location, a, b_type); + let result = a << b; + self.context.new_cast(self.location, result, a_type) + } else if a_type.is_signed(self) && b_type.is_unsigned(self) { + let b = self.context.new_cast(self.location, b, a_type); + a << b + } else { + let a_size = a_type.get_size(); + let b_size = b_type.get_size(); + match a_size.cmp(&b_size) { + std::cmp::Ordering::Less => { + let a = self.context.new_cast(self.location, a, b_type); + a << b + } + std::cmp::Ordering::Equal => a << b, + std::cmp::Ordering::Greater => { + let b = self.context.new_cast(self.location, b, a_type); + a << b + } + } + } + } else if a_type.is_vector() && b_type.is_vector() { + a << b + } else if a_native && !b_native { + self.gcc_shl(a, self.gcc_int_cast(b, a_type)) + } else { + // NOTE: we cannot use the ashl builtin because it's calling widen_hi() which uses ashl. + let native_int_type = a_type.dyncast_array().expect("get element type"); + + let func = self.current_func(); + let then_block = func.new_block("then"); + let else_block = func.new_block("else"); + let after_block = func.new_block("after"); + let b0_block = func.new_block("b0"); + let actual_else_block = func.new_block("actual_else"); + + let result = func.new_local(self.location, a_type, "shiftResult"); + + let b = self.gcc_int_cast(b, native_int_type); + let sixty_four = self.gcc_int(native_int_type, 64); + let zero = self.gcc_zero(native_int_type); + let condition = self.gcc_icmp(IntPredicate::IntNE, self.gcc_and(b, sixty_four), zero); + self.llbb().end_with_conditional(self.location, condition, then_block, else_block); + + let array_value = + self.concat_low_high_rvalues(a_type, zero, self.low(a) << (b - sixty_four)); + then_block.add_assignment(self.location, result, array_value); + then_block.end_with_jump(self.location, after_block); + + let condition = self.gcc_icmp(IntPredicate::IntEQ, b, zero); + else_block.end_with_conditional(self.location, condition, b0_block, actual_else_block); + + b0_block.add_assignment(self.location, result, a); + b0_block.end_with_jump(self.location, after_block); + + // NOTE: cast low to its unsigned type in order to perform a logical right shift. + // TODO(antoyo): adjust this ^ comment. + let unsigned_type = native_int_type.to_unsigned(self.cx); + let casted_low = self.context.new_cast(self.location, self.low(a), unsigned_type); + let shift_value = self.context.new_cast(self.location, sixty_four - b, unsigned_type); + let high_low = + self.context.new_cast(self.location, casted_low >> shift_value, native_int_type); + + let array_value = self.concat_low_high_rvalues( + a_type, + self.low(a) << b, + (self.high(a) << b) | high_low, + ); + actual_else_block.add_assignment(self.location, result, array_value); + actual_else_block.end_with_jump(self.location, after_block); + + // NOTE: since jumps were added in a place rustc does not expect, the current block in the + // state need to be updated. + self.switch_to_block(after_block); + + result.to_rvalue() + } + } + + pub fn gcc_bswap(&mut self, mut arg: RValue<'gcc>, width: u64) -> RValue<'gcc> { + let arg_type = arg.get_type(); + if !self.is_native_int_type(arg_type) { + let native_int_type = arg_type.dyncast_array().expect("get element type"); + let lsb = self.low(arg); + let swapped_lsb = self.gcc_bswap(lsb, width / 2); + let swapped_lsb = self.context.new_cast(self.location, swapped_lsb, native_int_type); + let msb = self.high(arg); + let swapped_msb = self.gcc_bswap(msb, width / 2); + let swapped_msb = self.context.new_cast(self.location, swapped_msb, native_int_type); + + // NOTE: we also need to swap the two elements here, in addition to swapping inside + // the elements themselves like done above. + return self.concat_low_high_rvalues(arg_type, swapped_msb, swapped_lsb); + } + + // TODO(antoyo): check if it's faster to use string literals and a + // match instead of format!. + let bswap = self.cx.context.get_builtin_function(format!("__builtin_bswap{}", width)); + // FIXME(antoyo): this cast should not be necessary. Remove + // when having proper sized integer types. + let param_type = bswap.get_param(0).to_rvalue().get_type(); + if param_type != arg_type { + arg = self.bitcast(arg, param_type); + } + self.cx.context.new_call(self.location, bswap, &[arg]) + } +} + +impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { + pub fn gcc_int(&self, typ: Type<'gcc>, int: i64) -> RValue<'gcc> { + if self.is_native_int_type_or_bool(typ) { + self.context.new_rvalue_from_long(typ, int) + } else { + // NOTE: set the sign in high. + self.concat_low_high(typ, int, -(int.is_negative() as i64)) + } + } + + pub fn gcc_uint(&self, typ: Type<'gcc>, int: u64) -> RValue<'gcc> { + if typ.is_u128(self) { + // FIXME(antoyo): libgccjit cannot create 128-bit values yet. + let num = self.context.new_rvalue_from_long(self.u64_type, int as i64); + self.gcc_int_cast(num, typ) + } else if self.is_native_int_type_or_bool(typ) { + self.context.new_rvalue_from_long(typ, int as i64) + } else { + self.concat_low_high(typ, int as i64, 0) + } + } + + pub fn gcc_uint_big(&self, typ: Type<'gcc>, num: u128) -> RValue<'gcc> { + let low = num as u64; + let high = (num >> 64) as u64; + if num >> 64 != 0 { + // FIXME(antoyo): use a new function new_rvalue_from_unsigned_long()? + if self.is_native_int_type(typ) { + let low = self.context.new_rvalue_from_long(self.u64_type, low as i64); + let high = self.context.new_rvalue_from_long(typ, high as i64); + + let sixty_four = self.context.new_rvalue_from_long(typ, 64); + let shift = high << sixty_four; + shift | self.context.new_cast(None, low, typ) + } else { + self.concat_low_high(typ, low as i64, high as i64) + } + } else if typ.is_i128(self) { + // FIXME(antoyo): libgccjit cannot create 128-bit values yet. + let num = self.context.new_rvalue_from_long(self.u64_type, num as u64 as i64); + self.gcc_int_cast(num, typ) + } else { + self.gcc_uint(typ, num as u64) + } + } + + pub fn gcc_zero(&self, typ: Type<'gcc>) -> RValue<'gcc> { + if self.is_native_int_type_or_bool(typ) { + self.context.new_rvalue_zero(typ) + } else { + self.concat_low_high(typ, 0, 0) + } + } + + pub fn gcc_int_width(&self, typ: Type<'gcc>) -> u64 { + if self.is_native_int_type_or_bool(typ) { + typ.get_size() as u64 * 8 + } else { + // NOTE: the only unsupported types are u128 and i128. + 128 + } + } + + fn bitwise_operation( + &self, + operation: BinaryOp, + a: RValue<'gcc>, + mut b: RValue<'gcc>, + loc: Option<Location<'gcc>>, + ) -> RValue<'gcc> { + let a_type = a.get_type(); + let b_type = b.get_type(); + let a_native = self.is_native_int_type_or_bool(a_type); + let b_native = self.is_native_int_type_or_bool(b_type); + if a_type.is_vector() && b_type.is_vector() { + let b = self.bitcast_if_needed(b, a_type); + self.context.new_binary_op(loc, operation, a_type, a, b) + } else if a_native && b_native { + if a_type != b_type { + b = self.context.new_cast(loc, b, a_type); + } + self.context.new_binary_op(loc, operation, a_type, a, b) + } else { + assert!( + !a_native && !b_native, + "both types should either be native or non-native for or operation" + ); + let native_int_type = a_type.dyncast_array().expect("get element type"); + self.concat_low_high_rvalues( + a_type, + self.context.new_binary_op( + loc, + operation, + native_int_type, + self.low(a), + self.low(b), + ), + self.context.new_binary_op( + loc, + operation, + native_int_type, + self.high(a), + self.high(b), + ), + ) + } + } + + pub fn gcc_or( + &self, + a: RValue<'gcc>, + b: RValue<'gcc>, + loc: Option<Location<'gcc>>, + ) -> RValue<'gcc> { + self.bitwise_operation(BinaryOp::BitwiseOr, a, b, loc) + } + + // TODO(antoyo): can we use https://github.com/rust-lang/compiler-builtins/blob/master/src/int/mod.rs#L379 instead? + pub fn gcc_int_cast(&self, value: RValue<'gcc>, dest_typ: Type<'gcc>) -> RValue<'gcc> { + let value_type = value.get_type(); + if self.is_native_int_type_or_bool(dest_typ) && self.is_native_int_type_or_bool(value_type) + { + // TODO: use self.location. + self.context.new_cast(None, value, dest_typ) + } else if self.is_native_int_type_or_bool(dest_typ) { + self.context.new_cast(None, self.low(value), dest_typ) + } else if self.is_native_int_type_or_bool(value_type) { + let dest_element_type = dest_typ.dyncast_array().expect("get element type"); + + // NOTE: set the sign of the value. + let zero = self.context.new_rvalue_zero(value_type); + let is_negative = + self.context.new_comparison(None, ComparisonOp::LessThan, value, zero); + let is_negative = self.gcc_int_cast(is_negative, dest_element_type); + self.concat_low_high_rvalues( + dest_typ, + self.context.new_cast(None, value, dest_element_type), + self.context.new_unary_op(None, UnaryOp::Minus, dest_element_type, is_negative), + ) + } else { + // Since u128 and i128 are the only types that can be unsupported, we know the type of + // value and the destination type have the same size, so a bitcast is fine. + + // TODO(antoyo): perhaps use __builtin_convertvector for vector casting. + self.context.new_bitcast(None, value, dest_typ) + } + } + + fn int_to_float_cast( + &self, + signed: bool, + value: RValue<'gcc>, + dest_typ: Type<'gcc>, + ) -> RValue<'gcc> { + let value_type = value.get_type(); + if self.is_native_int_type_or_bool(value_type) { + return self.context.new_cast(None, value, dest_typ); + } + + debug_assert!(value_type.dyncast_array().is_some()); + let name_suffix = match self.type_kind(dest_typ) { + // cSpell:disable + TypeKind::Float => "tisf", + TypeKind::Double => "tidf", + TypeKind::FP128 => "titf", + // cSpell:enable + kind => panic!("cannot cast a non-native integer to type {:?}", kind), + }; + let sign = if signed { "" } else { "un" }; + let func_name = format!("__float{}{}", sign, name_suffix); + let param = self.context.new_parameter(None, value_type, "n"); + let func = self.context.new_function( + None, + FunctionType::Extern, + dest_typ, + &[param], + func_name, + false, + ); + self.context.new_call(None, func, &[value]) + } + + pub fn gcc_int_to_float_cast(&self, value: RValue<'gcc>, dest_typ: Type<'gcc>) -> RValue<'gcc> { + self.int_to_float_cast(true, value, dest_typ) + } + + pub fn gcc_uint_to_float_cast( + &self, + value: RValue<'gcc>, + dest_typ: Type<'gcc>, + ) -> RValue<'gcc> { + self.int_to_float_cast(false, value, dest_typ) + } + + fn float_to_int_cast( + &self, + signed: bool, + value: RValue<'gcc>, + dest_typ: Type<'gcc>, + ) -> RValue<'gcc> { + let value_type = value.get_type(); + if self.is_native_int_type_or_bool(dest_typ) { + return self.context.new_cast(None, value, dest_typ); + } + + debug_assert!(dest_typ.dyncast_array().is_some()); + let name_suffix = match self.type_kind(value_type) { + // cSpell:disable + TypeKind::Float => "sfti", + TypeKind::Double => "dfti", + // cSpell:enable + kind => panic!("cannot cast a {:?} to non-native integer", kind), + }; + let sign = if signed { "" } else { "uns" }; + let func_name = format!("__fix{}{}", sign, name_suffix); + let param = self.context.new_parameter(None, value_type, "n"); + let func = self.context.new_function( + None, + FunctionType::Extern, + dest_typ, + &[param], + func_name, + false, + ); + self.context.new_call(None, func, &[value]) + } + + pub fn gcc_float_to_int_cast(&self, value: RValue<'gcc>, dest_typ: Type<'gcc>) -> RValue<'gcc> { + self.float_to_int_cast(true, value, dest_typ) + } + + pub fn gcc_float_to_uint_cast( + &self, + value: RValue<'gcc>, + dest_typ: Type<'gcc>, + ) -> RValue<'gcc> { + self.float_to_int_cast(false, value, dest_typ) + } + + fn high(&self, value: RValue<'gcc>) -> RValue<'gcc> { + let index = match self.sess().target.options.endian { + Endian::Little => 1, + Endian::Big => 0, + }; + self.context + .new_array_access(None, value, self.context.new_rvalue_from_int(self.int_type, index)) + .to_rvalue() + } + + fn low(&self, value: RValue<'gcc>) -> RValue<'gcc> { + let index = match self.sess().target.options.endian { + Endian::Little => 0, + Endian::Big => 1, + }; + self.context + .new_array_access(None, value, self.context.new_rvalue_from_int(self.int_type, index)) + .to_rvalue() + } + + fn concat_low_high_rvalues( + &self, + typ: Type<'gcc>, + low: RValue<'gcc>, + high: RValue<'gcc>, + ) -> RValue<'gcc> { + let (first, last) = match self.sess().target.options.endian { + Endian::Little => (low, high), + Endian::Big => (high, low), + }; + + let values = [first, last]; + self.context.new_array_constructor(None, typ, &values) + } + + fn concat_low_high(&self, typ: Type<'gcc>, low: i64, high: i64) -> RValue<'gcc> { + let (first, last) = match self.sess().target.options.endian { + Endian::Little => (low, high), + Endian::Big => (high, low), + }; + + let native_int_type = typ.dyncast_array().expect("get element type"); + let values = [ + self.context.new_rvalue_from_long(native_int_type, first), + self.context.new_rvalue_from_long(native_int_type, last), + ]; + self.context.new_array_constructor(None, typ, &values) + } +} + +fn type_kind_to_gcc_type<I: Interner>(kind: TyKind<I>) -> CType { + use rustc_middle::ty::IntTy::*; + use rustc_middle::ty::UintTy::*; + use rustc_middle::ty::{Int, Uint}; + + match kind { + Int(I8) => CType::Int8t, + Int(I16) => CType::Int16t, + Int(I32) => CType::Int32t, + Int(I64) => CType::Int64t, + Int(I128) => CType::Int128t, + + Uint(U8) => CType::UInt8t, + Uint(U16) => CType::UInt16t, + Uint(U32) => CType::UInt32t, + Uint(U64) => CType::UInt64t, + Uint(U128) => CType::UInt128t, + + _ => unimplemented!("Kind: {:?}", kind), + } +} diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/archs.rs b/compiler/rustc_codegen_gcc/src/intrinsic/archs.rs new file mode 100644 index 00000000000..d1b2a93243d --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/intrinsic/archs.rs @@ -0,0 +1,10246 @@ +// File generated by `rustc_codegen_gcc/tools/generate_intrinsics.py` +// DO NOT EDIT IT! +/// Translate a given LLVM intrinsic name to an equivalent GCC one. +fn map_arch_intrinsic(full_name: &str) -> &'static str { + let Some(name) = full_name.strip_prefix("llvm.") else { + unimplemented!("***** unsupported LLVM intrinsic {}", full_name) + }; + let Some((arch, name)) = name.split_once('.') else { + unimplemented!("***** unsupported LLVM intrinsic {}", name) + }; + match arch { + "AMDGPU" => { + #[allow(non_snake_case)] + fn AMDGPU(name: &str, full_name: &str) -> &'static str { + match name { + // AMDGPU + "div.fixup.f32" => "__builtin_amdgpu_div_fixup", + "div.fixup.f64" => "__builtin_amdgpu_div_fixup", + "div.fixup.v2f64" => "__builtin_amdgpu_div_fixup", + "div.fixup.v4f32" => "__builtin_amdgpu_div_fixup", + "div.fmas.f32" => "__builtin_amdgpu_div_fmas", + "div.fmas.f64" => "__builtin_amdgpu_div_fmas", + "div.fmas.v2f64" => "__builtin_amdgpu_div_fmas", + "div.fmas.v4f32" => "__builtin_amdgpu_div_fmas", + "ldexp.f32" => "__builtin_amdgpu_ldexp", + "ldexp.f64" => "__builtin_amdgpu_ldexp", + "ldexp.v2f64" => "__builtin_amdgpu_ldexp", + "ldexp.v4f32" => "__builtin_amdgpu_ldexp", + "rcp.f32" => "__builtin_amdgpu_rcp", + "rcp.f64" => "__builtin_amdgpu_rcp", + "rcp.v2f64" => "__builtin_amdgpu_rcp", + "rcp.v4f32" => "__builtin_amdgpu_rcp", + "rsq.clamped.f32" => "__builtin_amdgpu_rsq_clamped", + "rsq.clamped.f64" => "__builtin_amdgpu_rsq_clamped", + "rsq.clamped.v2f64" => "__builtin_amdgpu_rsq_clamped", + "rsq.clamped.v4f32" => "__builtin_amdgpu_rsq_clamped", + "rsq.f32" => "__builtin_amdgpu_rsq", + "rsq.f64" => "__builtin_amdgpu_rsq", + "rsq.v2f64" => "__builtin_amdgpu_rsq", + "rsq.v4f32" => "__builtin_amdgpu_rsq", + "trig.preop.f32" => "__builtin_amdgpu_trig_preop", + "trig.preop.f64" => "__builtin_amdgpu_trig_preop", + "trig.preop.v2f64" => "__builtin_amdgpu_trig_preop", + "trig.preop.v4f32" => "__builtin_amdgpu_trig_preop", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + AMDGPU(name, full_name) + } + "aarch64" => { + #[allow(non_snake_case)] + fn aarch64(name: &str, full_name: &str) -> &'static str { + match name { + // aarch64 + "chkfeat" => "__builtin_arm_chkfeat", + "dmb" => "__builtin_arm_dmb", + "dsb" => "__builtin_arm_dsb", + "gcspopm" => "__builtin_arm_gcspopm", + "gcsss" => "__builtin_arm_gcsss", + "isb" => "__builtin_arm_isb", + "prefetch" => "__builtin_arm_prefetch", + "sme.in.streaming.mode" => "__builtin_arm_in_streaming_mode", + "sve.aesd" => "__builtin_sve_svaesd_u8", + "sve.aese" => "__builtin_sve_svaese_u8", + "sve.aesimc" => "__builtin_sve_svaesimc_u8", + "sve.aesmc" => "__builtin_sve_svaesmc_u8", + "sve.rax1" => "__builtin_sve_svrax1_u64", + "sve.rdffr" => "__builtin_sve_svrdffr", + "sve.rdffr.z" => "__builtin_sve_svrdffr_z", + "sve.setffr" => "__builtin_sve_svsetffr", + "sve.sm4e" => "__builtin_sve_svsm4e_u32", + "sve.sm4ekey" => "__builtin_sve_svsm4ekey_u32", + "sve.wrffr" => "__builtin_sve_svwrffr", + "tcancel" => "__builtin_arm_tcancel", + "tcommit" => "__builtin_arm_tcommit", + "tstart" => "__builtin_arm_tstart", + "ttest" => "__builtin_arm_ttest", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + aarch64(name, full_name) + } + "amdgcn" => { + #[allow(non_snake_case)] + fn amdgcn(name: &str, full_name: &str) -> &'static str { + match name { + // amdgcn + "alignbyte" => "__builtin_amdgcn_alignbyte", + "ashr.pk.i8.i32" => "__builtin_amdgcn_ashr_pk_i8_i32", + "ashr.pk.u8.i32" => "__builtin_amdgcn_ashr_pk_u8_i32", + "buffer.wbinvl1" => "__builtin_amdgcn_buffer_wbinvl1", + "buffer.wbinvl1.sc" => "__builtin_amdgcn_buffer_wbinvl1_sc", + "buffer.wbinvl1.vol" => "__builtin_amdgcn_buffer_wbinvl1_vol", + "cubeid" => "__builtin_amdgcn_cubeid", + "cubema" => "__builtin_amdgcn_cubema", + "cubesc" => "__builtin_amdgcn_cubesc", + "cubetc" => "__builtin_amdgcn_cubetc", + "cvt.f16.bf8" => "__builtin_amdgcn_cvt_f16_bf8", + "cvt.f16.fp8" => "__builtin_amdgcn_cvt_f16_fp8", + "cvt.f32.bf8" => "__builtin_amdgcn_cvt_f32_bf8", + "cvt.f32.fp8" => "__builtin_amdgcn_cvt_f32_fp8", + "cvt.f32.fp8.e5m3" => "__builtin_amdgcn_cvt_f32_fp8_e5m3", + "cvt.off.f32.i4" => "__builtin_amdgcn_cvt_off_f32_i4", + "cvt.pk.bf8.f32" => "__builtin_amdgcn_cvt_pk_bf8_f32", + "cvt.pk.f16.bf8" => "__builtin_amdgcn_cvt_pk_f16_bf8", + "cvt.pk.f16.fp8" => "__builtin_amdgcn_cvt_pk_f16_fp8", + "cvt.pk.f32.bf8" => "__builtin_amdgcn_cvt_pk_f32_bf8", + "cvt.pk.f32.fp8" => "__builtin_amdgcn_cvt_pk_f32_fp8", + "cvt.pk.fp8.f32" => "__builtin_amdgcn_cvt_pk_fp8_f32", + "cvt.pk.i16" => "__builtin_amdgcn_cvt_pk_i16", + "cvt.pk.u16" => "__builtin_amdgcn_cvt_pk_u16", + "cvt.pk.u8.f32" => "__builtin_amdgcn_cvt_pk_u8_f32", + "cvt.pknorm.i16" => "__builtin_amdgcn_cvt_pknorm_i16", + "cvt.pknorm.u16" => "__builtin_amdgcn_cvt_pknorm_u16", + "cvt.pkrtz" => "__builtin_amdgcn_cvt_pkrtz", + "cvt.scalef32.2xpk16.bf6.f32" => "__builtin_amdgcn_cvt_scalef32_2xpk16_bf6_f32", + "cvt.scalef32.2xpk16.fp6.f32" => "__builtin_amdgcn_cvt_scalef32_2xpk16_fp6_f32", + "cvt.scalef32.f16.bf8" => "__builtin_amdgcn_cvt_scalef32_f16_bf8", + "cvt.scalef32.f16.fp8" => "__builtin_amdgcn_cvt_scalef32_f16_fp8", + "cvt.scalef32.f32.bf8" => "__builtin_amdgcn_cvt_scalef32_f32_bf8", + "cvt.scalef32.f32.fp8" => "__builtin_amdgcn_cvt_scalef32_f32_fp8", + "cvt.scalef32.pk.bf16.bf8" => "__builtin_amdgcn_cvt_scalef32_pk_bf16_bf8", + "cvt.scalef32.pk.bf16.fp4" => "__builtin_amdgcn_cvt_scalef32_pk_bf16_fp4", + "cvt.scalef32.pk.bf16.fp8" => "__builtin_amdgcn_cvt_scalef32_pk_bf16_fp8", + "cvt.scalef32.pk.bf8.bf16" => "__builtin_amdgcn_cvt_scalef32_pk_bf8_bf16", + "cvt.scalef32.pk.bf8.f16" => "__builtin_amdgcn_cvt_scalef32_pk_bf8_f16", + "cvt.scalef32.pk.bf8.f32" => "__builtin_amdgcn_cvt_scalef32_pk_bf8_f32", + "cvt.scalef32.pk.f16.bf8" => "__builtin_amdgcn_cvt_scalef32_pk_f16_bf8", + "cvt.scalef32.pk.f16.fp4" => "__builtin_amdgcn_cvt_scalef32_pk_f16_fp4", + "cvt.scalef32.pk.f16.fp8" => "__builtin_amdgcn_cvt_scalef32_pk_f16_fp8", + "cvt.scalef32.pk.f32.bf8" => "__builtin_amdgcn_cvt_scalef32_pk_f32_bf8", + "cvt.scalef32.pk.f32.fp4" => "__builtin_amdgcn_cvt_scalef32_pk_f32_fp4", + "cvt.scalef32.pk.f32.fp8" => "__builtin_amdgcn_cvt_scalef32_pk_f32_fp8", + "cvt.scalef32.pk.fp4.bf16" => "__builtin_amdgcn_cvt_scalef32_pk_fp4_bf16", + "cvt.scalef32.pk.fp4.f16" => "__builtin_amdgcn_cvt_scalef32_pk_fp4_f16", + "cvt.scalef32.pk.fp4.f32" => "__builtin_amdgcn_cvt_scalef32_pk_fp4_f32", + "cvt.scalef32.pk.fp8.bf16" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_bf16", + "cvt.scalef32.pk.fp8.f16" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_f16", + "cvt.scalef32.pk.fp8.f32" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_f32", + "cvt.scalef32.pk32.bf16.bf6" => "__builtin_amdgcn_cvt_scalef32_pk32_bf16_bf6", + "cvt.scalef32.pk32.bf16.fp6" => "__builtin_amdgcn_cvt_scalef32_pk32_bf16_fp6", + "cvt.scalef32.pk32.bf6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk32_bf6_bf16", + "cvt.scalef32.pk32.bf6.f16" => "__builtin_amdgcn_cvt_scalef32_pk32_bf6_f16", + "cvt.scalef32.pk32.f16.bf6" => "__builtin_amdgcn_cvt_scalef32_pk32_f16_bf6", + "cvt.scalef32.pk32.f16.fp6" => "__builtin_amdgcn_cvt_scalef32_pk32_f16_fp6", + "cvt.scalef32.pk32.f32.bf6" => "__builtin_amdgcn_cvt_scalef32_pk32_f32_bf6", + "cvt.scalef32.pk32.f32.fp6" => "__builtin_amdgcn_cvt_scalef32_pk32_f32_fp6", + "cvt.scalef32.pk32.fp6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk32_fp6_bf16", + "cvt.scalef32.pk32.fp6.f16" => "__builtin_amdgcn_cvt_scalef32_pk32_fp6_f16", + "cvt.scalef32.sr.bf8.bf16" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_bf16", + "cvt.scalef32.sr.bf8.f16" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_f16", + "cvt.scalef32.sr.bf8.f32" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_f32", + "cvt.scalef32.sr.fp8.bf16" => "__builtin_amdgcn_cvt_scalef32_sr_fp8_bf16", + "cvt.scalef32.sr.fp8.f16" => "__builtin_amdgcn_cvt_scalef32_sr_fp8_f16", + "cvt.scalef32.sr.fp8.f32" => "__builtin_amdgcn_cvt_scalef32_sr_fp8_f32", + "cvt.scalef32.sr.pk.fp4.bf16" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_bf16", + "cvt.scalef32.sr.pk.fp4.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_f16", + "cvt.scalef32.sr.pk.fp4.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_f32", + "cvt.scalef32.sr.pk32.bf6.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk32_bf6_bf16" + } + "cvt.scalef32.sr.pk32.bf6.f16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk32_bf6_f16" + } + "cvt.scalef32.sr.pk32.bf6.f32" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk32_bf6_f32" + } + "cvt.scalef32.sr.pk32.fp6.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk32_fp6_bf16" + } + "cvt.scalef32.sr.pk32.fp6.f16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk32_fp6_f16" + } + "cvt.scalef32.sr.pk32.fp6.f32" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk32_fp6_f32" + } + "cvt.sr.bf16.f32" => "__builtin_amdgcn_cvt_sr_bf16_f32", + "cvt.sr.bf8.f32" => "__builtin_amdgcn_cvt_sr_bf8_f32", + "cvt.sr.f16.f32" => "__builtin_amdgcn_cvt_sr_f16_f32", + "cvt.sr.fp8.f32" => "__builtin_amdgcn_cvt_sr_fp8_f32", + "dispatch.id" => "__builtin_amdgcn_dispatch_id", + "dot4.f32.bf8.bf8" => "__builtin_amdgcn_dot4_f32_bf8_bf8", + "dot4.f32.bf8.fp8" => "__builtin_amdgcn_dot4_f32_bf8_fp8", + "dot4.f32.fp8.bf8" => "__builtin_amdgcn_dot4_f32_fp8_bf8", + "dot4.f32.fp8.fp8" => "__builtin_amdgcn_dot4_f32_fp8_fp8", + "ds.add.gs.reg.rtn" => "__builtin_amdgcn_ds_add_gs_reg_rtn", + "ds.atomic.async.barrier.arrive.b64" => { + "__builtin_amdgcn_ds_atomic_async_barrier_arrive_b64" + } + "ds.atomic.barrier.arrive.rtn.b64" => { + "__builtin_amdgcn_ds_atomic_barrier_arrive_rtn_b64" + } + "ds.bpermute" => "__builtin_amdgcn_ds_bpermute", + "ds.bpermute.fi.b32" => "__builtin_amdgcn_ds_bpermute_fi_b32", + "ds.gws.barrier" => "__builtin_amdgcn_ds_gws_barrier", + "ds.gws.init" => "__builtin_amdgcn_ds_gws_init", + "ds.gws.sema.br" => "__builtin_amdgcn_ds_gws_sema_br", + "ds.gws.sema.p" => "__builtin_amdgcn_ds_gws_sema_p", + "ds.gws.sema.release.all" => "__builtin_amdgcn_ds_gws_sema_release_all", + "ds.gws.sema.v" => "__builtin_amdgcn_ds_gws_sema_v", + "ds.permute" => "__builtin_amdgcn_ds_permute", + "ds.sub.gs.reg.rtn" => "__builtin_amdgcn_ds_sub_gs_reg_rtn", + "ds.swizzle" => "__builtin_amdgcn_ds_swizzle", + "endpgm" => "__builtin_amdgcn_endpgm", + "fdot2" => "__builtin_amdgcn_fdot2", + "fdot2.bf16.bf16" => "__builtin_amdgcn_fdot2_bf16_bf16", + "fdot2.f16.f16" => "__builtin_amdgcn_fdot2_f16_f16", + "fdot2.f32.bf16" => "__builtin_amdgcn_fdot2_f32_bf16", + "fdot2c.f32.bf16" => "__builtin_amdgcn_fdot2c_f32_bf16", + "flat.prefetch" => "__builtin_amdgcn_flat_prefetch", + "fmul.legacy" => "__builtin_amdgcn_fmul_legacy", + "global.load.async.to.lds.b128" => { + "__builtin_amdgcn_global_load_async_to_lds_b128" + } + "global.load.async.to.lds.b32" => { + "__builtin_amdgcn_global_load_async_to_lds_b32" + } + "global.load.async.to.lds.b64" => { + "__builtin_amdgcn_global_load_async_to_lds_b64" + } + "global.load.async.to.lds.b8" => "__builtin_amdgcn_global_load_async_to_lds_b8", + "global.load.lds" => "__builtin_amdgcn_global_load_lds", + "global.prefetch" => "__builtin_amdgcn_global_prefetch", + "global.store.async.from.lds.b128" => { + "__builtin_amdgcn_global_store_async_from_lds_b128" + } + "global.store.async.from.lds.b32" => { + "__builtin_amdgcn_global_store_async_from_lds_b32" + } + "global.store.async.from.lds.b64" => { + "__builtin_amdgcn_global_store_async_from_lds_b64" + } + "global.store.async.from.lds.b8" => { + "__builtin_amdgcn_global_store_async_from_lds_b8" + } + "groupstaticsize" => "__builtin_amdgcn_groupstaticsize", + "iglp.opt" => "__builtin_amdgcn_iglp_opt", + "implicit.buffer.ptr" => "__builtin_amdgcn_implicit_buffer_ptr", + "implicitarg.ptr" => "__builtin_amdgcn_implicitarg_ptr", + "interp.mov" => "__builtin_amdgcn_interp_mov", + "interp.p1" => "__builtin_amdgcn_interp_p1", + "interp.p1.f16" => "__builtin_amdgcn_interp_p1_f16", + "interp.p2" => "__builtin_amdgcn_interp_p2", + "interp.p2.f16" => "__builtin_amdgcn_interp_p2_f16", + "is.private" => "__builtin_amdgcn_is_private", + "is.shared" => "__builtin_amdgcn_is_shared", + "kernarg.segment.ptr" => "__builtin_amdgcn_kernarg_segment_ptr", + "lerp" => "__builtin_amdgcn_lerp", + "mbcnt.hi" => "__builtin_amdgcn_mbcnt_hi", + "mbcnt.lo" => "__builtin_amdgcn_mbcnt_lo", + "mfma.f32.16x16x16bf16.1k" => "__builtin_amdgcn_mfma_f32_16x16x16bf16_1k", + "mfma.f32.16x16x16f16" => "__builtin_amdgcn_mfma_f32_16x16x16f16", + "mfma.f32.16x16x1f32" => "__builtin_amdgcn_mfma_f32_16x16x1f32", + "mfma.f32.16x16x2bf16" => "__builtin_amdgcn_mfma_f32_16x16x2bf16", + "mfma.f32.16x16x32.bf16" => "__builtin_amdgcn_mfma_f32_16x16x32_bf16", + "mfma.f32.16x16x32.bf8.bf8" => "__builtin_amdgcn_mfma_f32_16x16x32_bf8_bf8", + "mfma.f32.16x16x32.bf8.fp8" => "__builtin_amdgcn_mfma_f32_16x16x32_bf8_fp8", + "mfma.f32.16x16x32.f16" => "__builtin_amdgcn_mfma_f32_16x16x32_f16", + "mfma.f32.16x16x32.fp8.bf8" => "__builtin_amdgcn_mfma_f32_16x16x32_fp8_bf8", + "mfma.f32.16x16x32.fp8.fp8" => "__builtin_amdgcn_mfma_f32_16x16x32_fp8_fp8", + "mfma.f32.16x16x4bf16.1k" => "__builtin_amdgcn_mfma_f32_16x16x4bf16_1k", + "mfma.f32.16x16x4f16" => "__builtin_amdgcn_mfma_f32_16x16x4f16", + "mfma.f32.16x16x4f32" => "__builtin_amdgcn_mfma_f32_16x16x4f32", + "mfma.f32.16x16x8.xf32" => "__builtin_amdgcn_mfma_f32_16x16x8_xf32", + "mfma.f32.16x16x8bf16" => "__builtin_amdgcn_mfma_f32_16x16x8bf16", + "mfma.f32.32x32x16.bf16" => "__builtin_amdgcn_mfma_f32_32x32x16_bf16", + "mfma.f32.32x32x16.bf8.bf8" => "__builtin_amdgcn_mfma_f32_32x32x16_bf8_bf8", + "mfma.f32.32x32x16.bf8.fp8" => "__builtin_amdgcn_mfma_f32_32x32x16_bf8_fp8", + "mfma.f32.32x32x16.f16" => "__builtin_amdgcn_mfma_f32_32x32x16_f16", + "mfma.f32.32x32x16.fp8.bf8" => "__builtin_amdgcn_mfma_f32_32x32x16_fp8_bf8", + "mfma.f32.32x32x16.fp8.fp8" => "__builtin_amdgcn_mfma_f32_32x32x16_fp8_fp8", + "mfma.f32.32x32x1f32" => "__builtin_amdgcn_mfma_f32_32x32x1f32", + "mfma.f32.32x32x2bf16" => "__builtin_amdgcn_mfma_f32_32x32x2bf16", + "mfma.f32.32x32x2f32" => "__builtin_amdgcn_mfma_f32_32x32x2f32", + "mfma.f32.32x32x4.xf32" => "__builtin_amdgcn_mfma_f32_32x32x4_xf32", + "mfma.f32.32x32x4bf16" => "__builtin_amdgcn_mfma_f32_32x32x4bf16", + "mfma.f32.32x32x4bf16.1k" => "__builtin_amdgcn_mfma_f32_32x32x4bf16_1k", + "mfma.f32.32x32x4f16" => "__builtin_amdgcn_mfma_f32_32x32x4f16", + "mfma.f32.32x32x8bf16.1k" => "__builtin_amdgcn_mfma_f32_32x32x8bf16_1k", + "mfma.f32.32x32x8f16" => "__builtin_amdgcn_mfma_f32_32x32x8f16", + "mfma.f32.4x4x1f32" => "__builtin_amdgcn_mfma_f32_4x4x1f32", + "mfma.f32.4x4x2bf16" => "__builtin_amdgcn_mfma_f32_4x4x2bf16", + "mfma.f32.4x4x4bf16.1k" => "__builtin_amdgcn_mfma_f32_4x4x4bf16_1k", + "mfma.f32.4x4x4f16" => "__builtin_amdgcn_mfma_f32_4x4x4f16", + "mfma.f64.16x16x4f64" => "__builtin_amdgcn_mfma_f64_16x16x4f64", + "mfma.f64.4x4x4f64" => "__builtin_amdgcn_mfma_f64_4x4x4f64", + "mfma.i32.16x16x16i8" => "__builtin_amdgcn_mfma_i32_16x16x16i8", + "mfma.i32.16x16x32.i8" => "__builtin_amdgcn_mfma_i32_16x16x32_i8", + "mfma.i32.16x16x4i8" => "__builtin_amdgcn_mfma_i32_16x16x4i8", + "mfma.i32.16x16x64.i8" => "__builtin_amdgcn_mfma_i32_16x16x64_i8", + "mfma.i32.32x32x16.i8" => "__builtin_amdgcn_mfma_i32_32x32x16_i8", + "mfma.i32.32x32x32.i8" => "__builtin_amdgcn_mfma_i32_32x32x32_i8", + "mfma.i32.32x32x4i8" => "__builtin_amdgcn_mfma_i32_32x32x4i8", + "mfma.i32.32x32x8i8" => "__builtin_amdgcn_mfma_i32_32x32x8i8", + "mfma.i32.4x4x4i8" => "__builtin_amdgcn_mfma_i32_4x4x4i8", + "mqsad.pk.u16.u8" => "__builtin_amdgcn_mqsad_pk_u16_u8", + "mqsad.u32.u8" => "__builtin_amdgcn_mqsad_u32_u8", + "msad.u8" => "__builtin_amdgcn_msad_u8", + "perm" => "__builtin_amdgcn_perm", + "permlane16.var" => "__builtin_amdgcn_permlane16_var", + "permlanex16.var" => "__builtin_amdgcn_permlanex16_var", + "prng.b32" => "__builtin_amdgcn_prng_b32", + "qsad.pk.u16.u8" => "__builtin_amdgcn_qsad_pk_u16_u8", + "queue.ptr" => "__builtin_amdgcn_queue_ptr", + "raw.ptr.buffer.load.lds" => "__builtin_amdgcn_raw_ptr_buffer_load_lds", + "rcp.legacy" => "__builtin_amdgcn_rcp_legacy", + "rsq.legacy" => "__builtin_amdgcn_rsq_legacy", + "s.barrier" => "__builtin_amdgcn_s_barrier", + "s.barrier.signal" => "__builtin_amdgcn_s_barrier_signal", + "s.barrier.signal.isfirst" => "__builtin_amdgcn_s_barrier_signal_isfirst", + "s.barrier.signal.var" => "__builtin_amdgcn_s_barrier_signal_var", + "s.barrier.wait" => "__builtin_amdgcn_s_barrier_wait", + "s.buffer.prefetch.data" => "__builtin_amdgcn_s_buffer_prefetch_data", + "s.dcache.inv" => "__builtin_amdgcn_s_dcache_inv", + "s.dcache.inv.vol" => "__builtin_amdgcn_s_dcache_inv_vol", + "s.dcache.wb" => "__builtin_amdgcn_s_dcache_wb", + "s.dcache.wb.vol" => "__builtin_amdgcn_s_dcache_wb_vol", + "s.decperflevel" => "__builtin_amdgcn_s_decperflevel", + "s.get.barrier.state" => "__builtin_amdgcn_s_get_barrier_state", + "s.get.named.barrier.state" => "__builtin_amdgcn_s_get_named_barrier_state", + "s.get.waveid.in.workgroup" => "__builtin_amdgcn_s_get_waveid_in_workgroup", + "s.getpc" => "__builtin_amdgcn_s_getpc", + "s.getreg" => "__builtin_amdgcn_s_getreg", + "s.incperflevel" => "__builtin_amdgcn_s_incperflevel", + "s.memrealtime" => "__builtin_amdgcn_s_memrealtime", + "s.memtime" => "__builtin_amdgcn_s_memtime", + "s.monitor.sleep" => "__builtin_amdgcn_s_monitor_sleep", + "s.sendmsg" => "__builtin_amdgcn_s_sendmsg", + "s.sendmsghalt" => "__builtin_amdgcn_s_sendmsghalt", + "s.setprio" => "__builtin_amdgcn_s_setprio", + "s.setprio.inc.wg" => "__builtin_amdgcn_s_setprio_inc_wg", + "s.setreg" => "__builtin_amdgcn_s_setreg", + "s.sleep" => "__builtin_amdgcn_s_sleep", + "s.sleep.var" => "__builtin_amdgcn_s_sleep_var", + "s.ttracedata" => "__builtin_amdgcn_s_ttracedata", + "s.ttracedata.imm" => "__builtin_amdgcn_s_ttracedata_imm", + "s.wait.asynccnt" => "__builtin_amdgcn_s_wait_asynccnt", + "s.wait.event.export.ready" => "__builtin_amdgcn_s_wait_event_export_ready", + "s.wait.tensorcnt" => "__builtin_amdgcn_s_wait_tensorcnt", + "s.waitcnt" => "__builtin_amdgcn_s_waitcnt", + "sad.hi.u8" => "__builtin_amdgcn_sad_hi_u8", + "sad.u16" => "__builtin_amdgcn_sad_u16", + "sad.u8" => "__builtin_amdgcn_sad_u8", + "sat.pk4.i4.i8" => "__builtin_amdgcn_sat_pk4_i4_i8", + "sat.pk4.u4.u8" => "__builtin_amdgcn_sat_pk4_u4_u8", + "sched.barrier" => "__builtin_amdgcn_sched_barrier", + "sched.group.barrier" => "__builtin_amdgcn_sched_group_barrier", + "sdot2" => "__builtin_amdgcn_sdot2", + "sdot4" => "__builtin_amdgcn_sdot4", + "sdot8" => "__builtin_amdgcn_sdot8", + "smfmac.f32.16x16x128.bf8.bf8" => { + "__builtin_amdgcn_smfmac_f32_16x16x128_bf8_bf8" + } + "smfmac.f32.16x16x128.bf8.fp8" => { + "__builtin_amdgcn_smfmac_f32_16x16x128_bf8_fp8" + } + "smfmac.f32.16x16x128.fp8.bf8" => { + "__builtin_amdgcn_smfmac_f32_16x16x128_fp8_bf8" + } + "smfmac.f32.16x16x128.fp8.fp8" => { + "__builtin_amdgcn_smfmac_f32_16x16x128_fp8_fp8" + } + "smfmac.f32.16x16x32.bf16" => "__builtin_amdgcn_smfmac_f32_16x16x32_bf16", + "smfmac.f32.16x16x32.f16" => "__builtin_amdgcn_smfmac_f32_16x16x32_f16", + "smfmac.f32.16x16x64.bf16" => "__builtin_amdgcn_smfmac_f32_16x16x64_bf16", + "smfmac.f32.16x16x64.bf8.bf8" => "__builtin_amdgcn_smfmac_f32_16x16x64_bf8_bf8", + "smfmac.f32.16x16x64.bf8.fp8" => "__builtin_amdgcn_smfmac_f32_16x16x64_bf8_fp8", + "smfmac.f32.16x16x64.f16" => "__builtin_amdgcn_smfmac_f32_16x16x64_f16", + "smfmac.f32.16x16x64.fp8.bf8" => "__builtin_amdgcn_smfmac_f32_16x16x64_fp8_bf8", + "smfmac.f32.16x16x64.fp8.fp8" => "__builtin_amdgcn_smfmac_f32_16x16x64_fp8_fp8", + "smfmac.f32.32x32x16.bf16" => "__builtin_amdgcn_smfmac_f32_32x32x16_bf16", + "smfmac.f32.32x32x16.f16" => "__builtin_amdgcn_smfmac_f32_32x32x16_f16", + "smfmac.f32.32x32x32.bf16" => "__builtin_amdgcn_smfmac_f32_32x32x32_bf16", + "smfmac.f32.32x32x32.bf8.bf8" => "__builtin_amdgcn_smfmac_f32_32x32x32_bf8_bf8", + "smfmac.f32.32x32x32.bf8.fp8" => "__builtin_amdgcn_smfmac_f32_32x32x32_bf8_fp8", + "smfmac.f32.32x32x32.f16" => "__builtin_amdgcn_smfmac_f32_32x32x32_f16", + "smfmac.f32.32x32x32.fp8.bf8" => "__builtin_amdgcn_smfmac_f32_32x32x32_fp8_bf8", + "smfmac.f32.32x32x32.fp8.fp8" => "__builtin_amdgcn_smfmac_f32_32x32x32_fp8_fp8", + "smfmac.f32.32x32x64.bf8.bf8" => "__builtin_amdgcn_smfmac_f32_32x32x64_bf8_bf8", + "smfmac.f32.32x32x64.bf8.fp8" => "__builtin_amdgcn_smfmac_f32_32x32x64_bf8_fp8", + "smfmac.f32.32x32x64.fp8.bf8" => "__builtin_amdgcn_smfmac_f32_32x32x64_fp8_bf8", + "smfmac.f32.32x32x64.fp8.fp8" => "__builtin_amdgcn_smfmac_f32_32x32x64_fp8_fp8", + "smfmac.i32.16x16x128.i8" => "__builtin_amdgcn_smfmac_i32_16x16x128_i8", + "smfmac.i32.16x16x64.i8" => "__builtin_amdgcn_smfmac_i32_16x16x64_i8", + "smfmac.i32.32x32x32.i8" => "__builtin_amdgcn_smfmac_i32_32x32x32_i8", + "smfmac.i32.32x32x64.i8" => "__builtin_amdgcn_smfmac_i32_32x32x64_i8", + "struct.ptr.buffer.load.lds" => "__builtin_amdgcn_struct_ptr_buffer_load_lds", + "sudot4" => "__builtin_amdgcn_sudot4", + "sudot8" => "__builtin_amdgcn_sudot8", + "tensor.load.to.lds" => "__builtin_amdgcn_tensor_load_to_lds", + "tensor.load.to.lds.d2" => "__builtin_amdgcn_tensor_load_to_lds_d2", + "tensor.store.from.lds" => "__builtin_amdgcn_tensor_store_from_lds", + "tensor.store.from.lds.d2" => "__builtin_amdgcn_tensor_store_from_lds_d2", + "udot2" => "__builtin_amdgcn_udot2", + "udot4" => "__builtin_amdgcn_udot4", + "udot8" => "__builtin_amdgcn_udot8", + "wave.barrier" => "__builtin_amdgcn_wave_barrier", + "wavefrontsize" => "__builtin_amdgcn_wavefrontsize", + "workgroup.id.x" => "__builtin_amdgcn_workgroup_id_x", + "workgroup.id.y" => "__builtin_amdgcn_workgroup_id_y", + "workgroup.id.z" => "__builtin_amdgcn_workgroup_id_z", + "workitem.id.x" => "__builtin_amdgcn_workitem_id_x", + "workitem.id.y" => "__builtin_amdgcn_workitem_id_y", + "workitem.id.z" => "__builtin_amdgcn_workitem_id_z", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + amdgcn(name, full_name) + } + "arm" => { + #[allow(non_snake_case)] + fn arm(name: &str, full_name: &str) -> &'static str { + match name { + // arm + "cdp" => "__builtin_arm_cdp", + "cdp2" => "__builtin_arm_cdp2", + "cmse.tt" => "__builtin_arm_cmse_TT", + "cmse.tta" => "__builtin_arm_cmse_TTA", + "cmse.ttat" => "__builtin_arm_cmse_TTAT", + "cmse.ttt" => "__builtin_arm_cmse_TTT", + "dmb" => "__builtin_arm_dmb", + "dsb" => "__builtin_arm_dsb", + "get.fpscr" => "__builtin_arm_get_fpscr", + "isb" => "__builtin_arm_isb", + "ldc" => "__builtin_arm_ldc", + "ldc2" => "__builtin_arm_ldc2", + "ldc2l" => "__builtin_arm_ldc2l", + "ldcl" => "__builtin_arm_ldcl", + "mcr" => "__builtin_arm_mcr", + "mcr2" => "__builtin_arm_mcr2", + "mcrr" => "__builtin_arm_mcrr", + "mcrr2" => "__builtin_arm_mcrr2", + "mrc" => "__builtin_arm_mrc", + "mrc2" => "__builtin_arm_mrc2", + "qadd" => "__builtin_arm_qadd", + "qadd16" => "__builtin_arm_qadd16", + "qadd8" => "__builtin_arm_qadd8", + "qasx" => "__builtin_arm_qasx", + "qsax" => "__builtin_arm_qsax", + "qsub" => "__builtin_arm_qsub", + "qsub16" => "__builtin_arm_qsub16", + "qsub8" => "__builtin_arm_qsub8", + "sadd16" => "__builtin_arm_sadd16", + "sadd8" => "__builtin_arm_sadd8", + "sasx" => "__builtin_arm_sasx", + "sel" => "__builtin_arm_sel", + "set.fpscr" => "__builtin_arm_set_fpscr", + "shadd16" => "__builtin_arm_shadd16", + "shadd8" => "__builtin_arm_shadd8", + "shasx" => "__builtin_arm_shasx", + "shsax" => "__builtin_arm_shsax", + "shsub16" => "__builtin_arm_shsub16", + "shsub8" => "__builtin_arm_shsub8", + "smlabb" => "__builtin_arm_smlabb", + "smlabt" => "__builtin_arm_smlabt", + "smlad" => "__builtin_arm_smlad", + "smladx" => "__builtin_arm_smladx", + "smlald" => "__builtin_arm_smlald", + "smlaldx" => "__builtin_arm_smlaldx", + "smlatb" => "__builtin_arm_smlatb", + "smlatt" => "__builtin_arm_smlatt", + "smlawb" => "__builtin_arm_smlawb", + "smlawt" => "__builtin_arm_smlawt", + "smlsd" => "__builtin_arm_smlsd", + "smlsdx" => "__builtin_arm_smlsdx", + "smlsld" => "__builtin_arm_smlsld", + "smlsldx" => "__builtin_arm_smlsldx", + "smuad" => "__builtin_arm_smuad", + "smuadx" => "__builtin_arm_smuadx", + "smulbb" => "__builtin_arm_smulbb", + "smulbt" => "__builtin_arm_smulbt", + "smultb" => "__builtin_arm_smultb", + "smultt" => "__builtin_arm_smultt", + "smulwb" => "__builtin_arm_smulwb", + "smulwt" => "__builtin_arm_smulwt", + "smusd" => "__builtin_arm_smusd", + "smusdx" => "__builtin_arm_smusdx", + "ssat" => "__builtin_arm_ssat", + "ssat16" => "__builtin_arm_ssat16", + "ssax" => "__builtin_arm_ssax", + "ssub16" => "__builtin_arm_ssub16", + "ssub8" => "__builtin_arm_ssub8", + "stc" => "__builtin_arm_stc", + "stc2" => "__builtin_arm_stc2", + "stc2l" => "__builtin_arm_stc2l", + "stcl" => "__builtin_arm_stcl", + "sxtab16" => "__builtin_arm_sxtab16", + "sxtb16" => "__builtin_arm_sxtb16", + "thread.pointer" => "__builtin_thread_pointer", + "uadd16" => "__builtin_arm_uadd16", + "uadd8" => "__builtin_arm_uadd8", + "uasx" => "__builtin_arm_uasx", + "uhadd16" => "__builtin_arm_uhadd16", + "uhadd8" => "__builtin_arm_uhadd8", + "uhasx" => "__builtin_arm_uhasx", + "uhsax" => "__builtin_arm_uhsax", + "uhsub16" => "__builtin_arm_uhsub16", + "uhsub8" => "__builtin_arm_uhsub8", + "uqadd16" => "__builtin_arm_uqadd16", + "uqadd8" => "__builtin_arm_uqadd8", + "uqasx" => "__builtin_arm_uqasx", + "uqsax" => "__builtin_arm_uqsax", + "uqsub16" => "__builtin_arm_uqsub16", + "uqsub8" => "__builtin_arm_uqsub8", + "usad8" => "__builtin_arm_usad8", + "usada8" => "__builtin_arm_usada8", + "usat" => "__builtin_arm_usat", + "usat16" => "__builtin_arm_usat16", + "usax" => "__builtin_arm_usax", + "usub16" => "__builtin_arm_usub16", + "usub8" => "__builtin_arm_usub8", + "uxtab16" => "__builtin_arm_uxtab16", + "uxtb16" => "__builtin_arm_uxtb16", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + arm(name, full_name) + } + "bpf" => { + #[allow(non_snake_case)] + fn bpf(name: &str, full_name: &str) -> &'static str { + match name { + // bpf + "btf.type.id" => "__builtin_bpf_btf_type_id", + "compare" => "__builtin_bpf_compare", + "getelementptr.and.load" => "__builtin_bpf_getelementptr_and_load", + "getelementptr.and.store" => "__builtin_bpf_getelementptr_and_store", + "load.byte" => "__builtin_bpf_load_byte", + "load.half" => "__builtin_bpf_load_half", + "load.word" => "__builtin_bpf_load_word", + "passthrough" => "__builtin_bpf_passthrough", + "preserve.enum.value" => "__builtin_bpf_preserve_enum_value", + "preserve.field.info" => "__builtin_bpf_preserve_field_info", + "preserve.type.info" => "__builtin_bpf_preserve_type_info", + "pseudo" => "__builtin_bpf_pseudo", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + bpf(name, full_name) + } + "cuda" => { + #[allow(non_snake_case)] + fn cuda(name: &str, full_name: &str) -> &'static str { + match name { + // cuda + "syncthreads" => "__syncthreads", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + cuda(name, full_name) + } + "hexagon" => { + #[allow(non_snake_case)] + fn hexagon(name: &str, full_name: &str) -> &'static str { + match name { + // hexagon + "A2.abs" => "__builtin_HEXAGON_A2_abs", + "A2.absp" => "__builtin_HEXAGON_A2_absp", + "A2.abssat" => "__builtin_HEXAGON_A2_abssat", + "A2.add" => "__builtin_HEXAGON_A2_add", + "A2.addh.h16.hh" => "__builtin_HEXAGON_A2_addh_h16_hh", + "A2.addh.h16.hl" => "__builtin_HEXAGON_A2_addh_h16_hl", + "A2.addh.h16.lh" => "__builtin_HEXAGON_A2_addh_h16_lh", + "A2.addh.h16.ll" => "__builtin_HEXAGON_A2_addh_h16_ll", + "A2.addh.h16.sat.hh" => "__builtin_HEXAGON_A2_addh_h16_sat_hh", + "A2.addh.h16.sat.hl" => "__builtin_HEXAGON_A2_addh_h16_sat_hl", + "A2.addh.h16.sat.lh" => "__builtin_HEXAGON_A2_addh_h16_sat_lh", + "A2.addh.h16.sat.ll" => "__builtin_HEXAGON_A2_addh_h16_sat_ll", + "A2.addh.l16.hl" => "__builtin_HEXAGON_A2_addh_l16_hl", + "A2.addh.l16.ll" => "__builtin_HEXAGON_A2_addh_l16_ll", + "A2.addh.l16.sat.hl" => "__builtin_HEXAGON_A2_addh_l16_sat_hl", + "A2.addh.l16.sat.ll" => "__builtin_HEXAGON_A2_addh_l16_sat_ll", + "A2.addi" => "__builtin_HEXAGON_A2_addi", + "A2.addp" => "__builtin_HEXAGON_A2_addp", + "A2.addpsat" => "__builtin_HEXAGON_A2_addpsat", + "A2.addsat" => "__builtin_HEXAGON_A2_addsat", + "A2.addsp" => "__builtin_HEXAGON_A2_addsp", + "A2.and" => "__builtin_HEXAGON_A2_and", + "A2.andir" => "__builtin_HEXAGON_A2_andir", + "A2.andp" => "__builtin_HEXAGON_A2_andp", + "A2.aslh" => "__builtin_HEXAGON_A2_aslh", + "A2.asrh" => "__builtin_HEXAGON_A2_asrh", + "A2.combine.hh" => "__builtin_HEXAGON_A2_combine_hh", + "A2.combine.hl" => "__builtin_HEXAGON_A2_combine_hl", + "A2.combine.lh" => "__builtin_HEXAGON_A2_combine_lh", + "A2.combine.ll" => "__builtin_HEXAGON_A2_combine_ll", + "A2.combineii" => "__builtin_HEXAGON_A2_combineii", + "A2.combinew" => "__builtin_HEXAGON_A2_combinew", + "A2.max" => "__builtin_HEXAGON_A2_max", + "A2.maxp" => "__builtin_HEXAGON_A2_maxp", + "A2.maxu" => "__builtin_HEXAGON_A2_maxu", + "A2.maxup" => "__builtin_HEXAGON_A2_maxup", + "A2.min" => "__builtin_HEXAGON_A2_min", + "A2.minp" => "__builtin_HEXAGON_A2_minp", + "A2.minu" => "__builtin_HEXAGON_A2_minu", + "A2.minup" => "__builtin_HEXAGON_A2_minup", + "A2.neg" => "__builtin_HEXAGON_A2_neg", + "A2.negp" => "__builtin_HEXAGON_A2_negp", + "A2.negsat" => "__builtin_HEXAGON_A2_negsat", + "A2.not" => "__builtin_HEXAGON_A2_not", + "A2.notp" => "__builtin_HEXAGON_A2_notp", + "A2.or" => "__builtin_HEXAGON_A2_or", + "A2.orir" => "__builtin_HEXAGON_A2_orir", + "A2.orp" => "__builtin_HEXAGON_A2_orp", + "A2.roundsat" => "__builtin_HEXAGON_A2_roundsat", + "A2.sat" => "__builtin_HEXAGON_A2_sat", + "A2.satb" => "__builtin_HEXAGON_A2_satb", + "A2.sath" => "__builtin_HEXAGON_A2_sath", + "A2.satub" => "__builtin_HEXAGON_A2_satub", + "A2.satuh" => "__builtin_HEXAGON_A2_satuh", + "A2.sub" => "__builtin_HEXAGON_A2_sub", + "A2.subh.h16.hh" => "__builtin_HEXAGON_A2_subh_h16_hh", + "A2.subh.h16.hl" => "__builtin_HEXAGON_A2_subh_h16_hl", + "A2.subh.h16.lh" => "__builtin_HEXAGON_A2_subh_h16_lh", + "A2.subh.h16.ll" => "__builtin_HEXAGON_A2_subh_h16_ll", + "A2.subh.h16.sat.hh" => "__builtin_HEXAGON_A2_subh_h16_sat_hh", + "A2.subh.h16.sat.hl" => "__builtin_HEXAGON_A2_subh_h16_sat_hl", + "A2.subh.h16.sat.lh" => "__builtin_HEXAGON_A2_subh_h16_sat_lh", + "A2.subh.h16.sat.ll" => "__builtin_HEXAGON_A2_subh_h16_sat_ll", + "A2.subh.l16.hl" => "__builtin_HEXAGON_A2_subh_l16_hl", + "A2.subh.l16.ll" => "__builtin_HEXAGON_A2_subh_l16_ll", + "A2.subh.l16.sat.hl" => "__builtin_HEXAGON_A2_subh_l16_sat_hl", + "A2.subh.l16.sat.ll" => "__builtin_HEXAGON_A2_subh_l16_sat_ll", + "A2.subp" => "__builtin_HEXAGON_A2_subp", + "A2.subri" => "__builtin_HEXAGON_A2_subri", + "A2.subsat" => "__builtin_HEXAGON_A2_subsat", + "A2.svaddh" => "__builtin_HEXAGON_A2_svaddh", + "A2.svaddhs" => "__builtin_HEXAGON_A2_svaddhs", + "A2.svadduhs" => "__builtin_HEXAGON_A2_svadduhs", + "A2.svavgh" => "__builtin_HEXAGON_A2_svavgh", + "A2.svavghs" => "__builtin_HEXAGON_A2_svavghs", + "A2.svnavgh" => "__builtin_HEXAGON_A2_svnavgh", + "A2.svsubh" => "__builtin_HEXAGON_A2_svsubh", + "A2.svsubhs" => "__builtin_HEXAGON_A2_svsubhs", + "A2.svsubuhs" => "__builtin_HEXAGON_A2_svsubuhs", + "A2.swiz" => "__builtin_HEXAGON_A2_swiz", + "A2.sxtb" => "__builtin_HEXAGON_A2_sxtb", + "A2.sxth" => "__builtin_HEXAGON_A2_sxth", + "A2.sxtw" => "__builtin_HEXAGON_A2_sxtw", + "A2.tfr" => "__builtin_HEXAGON_A2_tfr", + "A2.tfrih" => "__builtin_HEXAGON_A2_tfrih", + "A2.tfril" => "__builtin_HEXAGON_A2_tfril", + "A2.tfrp" => "__builtin_HEXAGON_A2_tfrp", + "A2.tfrpi" => "__builtin_HEXAGON_A2_tfrpi", + "A2.tfrsi" => "__builtin_HEXAGON_A2_tfrsi", + "A2.vabsh" => "__builtin_HEXAGON_A2_vabsh", + "A2.vabshsat" => "__builtin_HEXAGON_A2_vabshsat", + "A2.vabsw" => "__builtin_HEXAGON_A2_vabsw", + "A2.vabswsat" => "__builtin_HEXAGON_A2_vabswsat", + "A2.vaddb.map" => "__builtin_HEXAGON_A2_vaddb_map", + "A2.vaddh" => "__builtin_HEXAGON_A2_vaddh", + "A2.vaddhs" => "__builtin_HEXAGON_A2_vaddhs", + "A2.vaddub" => "__builtin_HEXAGON_A2_vaddub", + "A2.vaddubs" => "__builtin_HEXAGON_A2_vaddubs", + "A2.vadduhs" => "__builtin_HEXAGON_A2_vadduhs", + "A2.vaddw" => "__builtin_HEXAGON_A2_vaddw", + "A2.vaddws" => "__builtin_HEXAGON_A2_vaddws", + "A2.vavgh" => "__builtin_HEXAGON_A2_vavgh", + "A2.vavghcr" => "__builtin_HEXAGON_A2_vavghcr", + "A2.vavghr" => "__builtin_HEXAGON_A2_vavghr", + "A2.vavgub" => "__builtin_HEXAGON_A2_vavgub", + "A2.vavgubr" => "__builtin_HEXAGON_A2_vavgubr", + "A2.vavguh" => "__builtin_HEXAGON_A2_vavguh", + "A2.vavguhr" => "__builtin_HEXAGON_A2_vavguhr", + "A2.vavguw" => "__builtin_HEXAGON_A2_vavguw", + "A2.vavguwr" => "__builtin_HEXAGON_A2_vavguwr", + "A2.vavgw" => "__builtin_HEXAGON_A2_vavgw", + "A2.vavgwcr" => "__builtin_HEXAGON_A2_vavgwcr", + "A2.vavgwr" => "__builtin_HEXAGON_A2_vavgwr", + "A2.vcmpbeq" => "__builtin_HEXAGON_A2_vcmpbeq", + "A2.vcmpbgtu" => "__builtin_HEXAGON_A2_vcmpbgtu", + "A2.vcmpheq" => "__builtin_HEXAGON_A2_vcmpheq", + "A2.vcmphgt" => "__builtin_HEXAGON_A2_vcmphgt", + "A2.vcmphgtu" => "__builtin_HEXAGON_A2_vcmphgtu", + "A2.vcmpweq" => "__builtin_HEXAGON_A2_vcmpweq", + "A2.vcmpwgt" => "__builtin_HEXAGON_A2_vcmpwgt", + "A2.vcmpwgtu" => "__builtin_HEXAGON_A2_vcmpwgtu", + "A2.vconj" => "__builtin_HEXAGON_A2_vconj", + "A2.vmaxb" => "__builtin_HEXAGON_A2_vmaxb", + "A2.vmaxh" => "__builtin_HEXAGON_A2_vmaxh", + "A2.vmaxub" => "__builtin_HEXAGON_A2_vmaxub", + "A2.vmaxuh" => "__builtin_HEXAGON_A2_vmaxuh", + "A2.vmaxuw" => "__builtin_HEXAGON_A2_vmaxuw", + "A2.vmaxw" => "__builtin_HEXAGON_A2_vmaxw", + "A2.vminb" => "__builtin_HEXAGON_A2_vminb", + "A2.vminh" => "__builtin_HEXAGON_A2_vminh", + "A2.vminub" => "__builtin_HEXAGON_A2_vminub", + "A2.vminuh" => "__builtin_HEXAGON_A2_vminuh", + "A2.vminuw" => "__builtin_HEXAGON_A2_vminuw", + "A2.vminw" => "__builtin_HEXAGON_A2_vminw", + "A2.vnavgh" => "__builtin_HEXAGON_A2_vnavgh", + "A2.vnavghcr" => "__builtin_HEXAGON_A2_vnavghcr", + "A2.vnavghr" => "__builtin_HEXAGON_A2_vnavghr", + "A2.vnavgw" => "__builtin_HEXAGON_A2_vnavgw", + "A2.vnavgwcr" => "__builtin_HEXAGON_A2_vnavgwcr", + "A2.vnavgwr" => "__builtin_HEXAGON_A2_vnavgwr", + "A2.vraddub" => "__builtin_HEXAGON_A2_vraddub", + "A2.vraddub.acc" => "__builtin_HEXAGON_A2_vraddub_acc", + "A2.vrsadub" => "__builtin_HEXAGON_A2_vrsadub", + "A2.vrsadub.acc" => "__builtin_HEXAGON_A2_vrsadub_acc", + "A2.vsubb.map" => "__builtin_HEXAGON_A2_vsubb_map", + "A2.vsubh" => "__builtin_HEXAGON_A2_vsubh", + "A2.vsubhs" => "__builtin_HEXAGON_A2_vsubhs", + "A2.vsubub" => "__builtin_HEXAGON_A2_vsubub", + "A2.vsububs" => "__builtin_HEXAGON_A2_vsububs", + "A2.vsubuhs" => "__builtin_HEXAGON_A2_vsubuhs", + "A2.vsubw" => "__builtin_HEXAGON_A2_vsubw", + "A2.vsubws" => "__builtin_HEXAGON_A2_vsubws", + "A2.xor" => "__builtin_HEXAGON_A2_xor", + "A2.xorp" => "__builtin_HEXAGON_A2_xorp", + "A2.zxtb" => "__builtin_HEXAGON_A2_zxtb", + "A2.zxth" => "__builtin_HEXAGON_A2_zxth", + "A4.andn" => "__builtin_HEXAGON_A4_andn", + "A4.andnp" => "__builtin_HEXAGON_A4_andnp", + "A4.bitsplit" => "__builtin_HEXAGON_A4_bitsplit", + "A4.bitspliti" => "__builtin_HEXAGON_A4_bitspliti", + "A4.boundscheck" => "__builtin_HEXAGON_A4_boundscheck", + "A4.cmpbeq" => "__builtin_HEXAGON_A4_cmpbeq", + "A4.cmpbeqi" => "__builtin_HEXAGON_A4_cmpbeqi", + "A4.cmpbgt" => "__builtin_HEXAGON_A4_cmpbgt", + "A4.cmpbgti" => "__builtin_HEXAGON_A4_cmpbgti", + "A4.cmpbgtu" => "__builtin_HEXAGON_A4_cmpbgtu", + "A4.cmpbgtui" => "__builtin_HEXAGON_A4_cmpbgtui", + "A4.cmpheq" => "__builtin_HEXAGON_A4_cmpheq", + "A4.cmpheqi" => "__builtin_HEXAGON_A4_cmpheqi", + "A4.cmphgt" => "__builtin_HEXAGON_A4_cmphgt", + "A4.cmphgti" => "__builtin_HEXAGON_A4_cmphgti", + "A4.cmphgtu" => "__builtin_HEXAGON_A4_cmphgtu", + "A4.cmphgtui" => "__builtin_HEXAGON_A4_cmphgtui", + "A4.combineir" => "__builtin_HEXAGON_A4_combineir", + "A4.combineri" => "__builtin_HEXAGON_A4_combineri", + "A4.cround.ri" => "__builtin_HEXAGON_A4_cround_ri", + "A4.cround.rr" => "__builtin_HEXAGON_A4_cround_rr", + "A4.modwrapu" => "__builtin_HEXAGON_A4_modwrapu", + "A4.orn" => "__builtin_HEXAGON_A4_orn", + "A4.ornp" => "__builtin_HEXAGON_A4_ornp", + "A4.rcmpeq" => "__builtin_HEXAGON_A4_rcmpeq", + "A4.rcmpeqi" => "__builtin_HEXAGON_A4_rcmpeqi", + "A4.rcmpneq" => "__builtin_HEXAGON_A4_rcmpneq", + "A4.rcmpneqi" => "__builtin_HEXAGON_A4_rcmpneqi", + "A4.round.ri" => "__builtin_HEXAGON_A4_round_ri", + "A4.round.ri.sat" => "__builtin_HEXAGON_A4_round_ri_sat", + "A4.round.rr" => "__builtin_HEXAGON_A4_round_rr", + "A4.round.rr.sat" => "__builtin_HEXAGON_A4_round_rr_sat", + "A4.tlbmatch" => "__builtin_HEXAGON_A4_tlbmatch", + "A4.vcmpbeq.any" => "__builtin_HEXAGON_A4_vcmpbeq_any", + "A4.vcmpbeqi" => "__builtin_HEXAGON_A4_vcmpbeqi", + "A4.vcmpbgt" => "__builtin_HEXAGON_A4_vcmpbgt", + "A4.vcmpbgti" => "__builtin_HEXAGON_A4_vcmpbgti", + "A4.vcmpbgtui" => "__builtin_HEXAGON_A4_vcmpbgtui", + "A4.vcmpheqi" => "__builtin_HEXAGON_A4_vcmpheqi", + "A4.vcmphgti" => "__builtin_HEXAGON_A4_vcmphgti", + "A4.vcmphgtui" => "__builtin_HEXAGON_A4_vcmphgtui", + "A4.vcmpweqi" => "__builtin_HEXAGON_A4_vcmpweqi", + "A4.vcmpwgti" => "__builtin_HEXAGON_A4_vcmpwgti", + "A4.vcmpwgtui" => "__builtin_HEXAGON_A4_vcmpwgtui", + "A4.vrmaxh" => "__builtin_HEXAGON_A4_vrmaxh", + "A4.vrmaxuh" => "__builtin_HEXAGON_A4_vrmaxuh", + "A4.vrmaxuw" => "__builtin_HEXAGON_A4_vrmaxuw", + "A4.vrmaxw" => "__builtin_HEXAGON_A4_vrmaxw", + "A4.vrminh" => "__builtin_HEXAGON_A4_vrminh", + "A4.vrminuh" => "__builtin_HEXAGON_A4_vrminuh", + "A4.vrminuw" => "__builtin_HEXAGON_A4_vrminuw", + "A4.vrminw" => "__builtin_HEXAGON_A4_vrminw", + "A5.vaddhubs" => "__builtin_HEXAGON_A5_vaddhubs", + "A6.vcmpbeq.notany" => "__builtin_HEXAGON_A6_vcmpbeq_notany", + "A7.clip" => "__builtin_HEXAGON_A7_clip", + "A7.croundd.ri" => "__builtin_HEXAGON_A7_croundd_ri", + "A7.croundd.rr" => "__builtin_HEXAGON_A7_croundd_rr", + "A7.vclip" => "__builtin_HEXAGON_A7_vclip", + "C2.all8" => "__builtin_HEXAGON_C2_all8", + "C2.and" => "__builtin_HEXAGON_C2_and", + "C2.andn" => "__builtin_HEXAGON_C2_andn", + "C2.any8" => "__builtin_HEXAGON_C2_any8", + "C2.bitsclr" => "__builtin_HEXAGON_C2_bitsclr", + "C2.bitsclri" => "__builtin_HEXAGON_C2_bitsclri", + "C2.bitsset" => "__builtin_HEXAGON_C2_bitsset", + "C2.cmpeq" => "__builtin_HEXAGON_C2_cmpeq", + "C2.cmpeqi" => "__builtin_HEXAGON_C2_cmpeqi", + "C2.cmpeqp" => "__builtin_HEXAGON_C2_cmpeqp", + "C2.cmpgei" => "__builtin_HEXAGON_C2_cmpgei", + "C2.cmpgeui" => "__builtin_HEXAGON_C2_cmpgeui", + "C2.cmpgt" => "__builtin_HEXAGON_C2_cmpgt", + "C2.cmpgti" => "__builtin_HEXAGON_C2_cmpgti", + "C2.cmpgtp" => "__builtin_HEXAGON_C2_cmpgtp", + "C2.cmpgtu" => "__builtin_HEXAGON_C2_cmpgtu", + "C2.cmpgtui" => "__builtin_HEXAGON_C2_cmpgtui", + "C2.cmpgtup" => "__builtin_HEXAGON_C2_cmpgtup", + "C2.cmplt" => "__builtin_HEXAGON_C2_cmplt", + "C2.cmpltu" => "__builtin_HEXAGON_C2_cmpltu", + "C2.mask" => "__builtin_HEXAGON_C2_mask", + "C2.mux" => "__builtin_HEXAGON_C2_mux", + "C2.muxii" => "__builtin_HEXAGON_C2_muxii", + "C2.muxir" => "__builtin_HEXAGON_C2_muxir", + "C2.muxri" => "__builtin_HEXAGON_C2_muxri", + "C2.not" => "__builtin_HEXAGON_C2_not", + "C2.or" => "__builtin_HEXAGON_C2_or", + "C2.orn" => "__builtin_HEXAGON_C2_orn", + "C2.pxfer.map" => "__builtin_HEXAGON_C2_pxfer_map", + "C2.tfrpr" => "__builtin_HEXAGON_C2_tfrpr", + "C2.tfrrp" => "__builtin_HEXAGON_C2_tfrrp", + "C2.vitpack" => "__builtin_HEXAGON_C2_vitpack", + "C2.vmux" => "__builtin_HEXAGON_C2_vmux", + "C2.xor" => "__builtin_HEXAGON_C2_xor", + "C4.and.and" => "__builtin_HEXAGON_C4_and_and", + "C4.and.andn" => "__builtin_HEXAGON_C4_and_andn", + "C4.and.or" => "__builtin_HEXAGON_C4_and_or", + "C4.and.orn" => "__builtin_HEXAGON_C4_and_orn", + "C4.cmplte" => "__builtin_HEXAGON_C4_cmplte", + "C4.cmpltei" => "__builtin_HEXAGON_C4_cmpltei", + "C4.cmplteu" => "__builtin_HEXAGON_C4_cmplteu", + "C4.cmplteui" => "__builtin_HEXAGON_C4_cmplteui", + "C4.cmpneq" => "__builtin_HEXAGON_C4_cmpneq", + "C4.cmpneqi" => "__builtin_HEXAGON_C4_cmpneqi", + "C4.fastcorner9" => "__builtin_HEXAGON_C4_fastcorner9", + "C4.fastcorner9.not" => "__builtin_HEXAGON_C4_fastcorner9_not", + "C4.nbitsclr" => "__builtin_HEXAGON_C4_nbitsclr", + "C4.nbitsclri" => "__builtin_HEXAGON_C4_nbitsclri", + "C4.nbitsset" => "__builtin_HEXAGON_C4_nbitsset", + "C4.or.and" => "__builtin_HEXAGON_C4_or_and", + "C4.or.andn" => "__builtin_HEXAGON_C4_or_andn", + "C4.or.or" => "__builtin_HEXAGON_C4_or_or", + "C4.or.orn" => "__builtin_HEXAGON_C4_or_orn", + "F2.conv.d2df" => "__builtin_HEXAGON_F2_conv_d2df", + "F2.conv.d2sf" => "__builtin_HEXAGON_F2_conv_d2sf", + "F2.conv.df2d" => "__builtin_HEXAGON_F2_conv_df2d", + "F2.conv.df2d.chop" => "__builtin_HEXAGON_F2_conv_df2d_chop", + "F2.conv.df2sf" => "__builtin_HEXAGON_F2_conv_df2sf", + "F2.conv.df2ud" => "__builtin_HEXAGON_F2_conv_df2ud", + "F2.conv.df2ud.chop" => "__builtin_HEXAGON_F2_conv_df2ud_chop", + "F2.conv.df2uw" => "__builtin_HEXAGON_F2_conv_df2uw", + "F2.conv.df2uw.chop" => "__builtin_HEXAGON_F2_conv_df2uw_chop", + "F2.conv.df2w" => "__builtin_HEXAGON_F2_conv_df2w", + "F2.conv.df2w.chop" => "__builtin_HEXAGON_F2_conv_df2w_chop", + "F2.conv.sf2d" => "__builtin_HEXAGON_F2_conv_sf2d", + "F2.conv.sf2d.chop" => "__builtin_HEXAGON_F2_conv_sf2d_chop", + "F2.conv.sf2df" => "__builtin_HEXAGON_F2_conv_sf2df", + "F2.conv.sf2ud" => "__builtin_HEXAGON_F2_conv_sf2ud", + "F2.conv.sf2ud.chop" => "__builtin_HEXAGON_F2_conv_sf2ud_chop", + "F2.conv.sf2uw" => "__builtin_HEXAGON_F2_conv_sf2uw", + "F2.conv.sf2uw.chop" => "__builtin_HEXAGON_F2_conv_sf2uw_chop", + "F2.conv.sf2w" => "__builtin_HEXAGON_F2_conv_sf2w", + "F2.conv.sf2w.chop" => "__builtin_HEXAGON_F2_conv_sf2w_chop", + "F2.conv.ud2df" => "__builtin_HEXAGON_F2_conv_ud2df", + "F2.conv.ud2sf" => "__builtin_HEXAGON_F2_conv_ud2sf", + "F2.conv.uw2df" => "__builtin_HEXAGON_F2_conv_uw2df", + "F2.conv.uw2sf" => "__builtin_HEXAGON_F2_conv_uw2sf", + "F2.conv.w2df" => "__builtin_HEXAGON_F2_conv_w2df", + "F2.conv.w2sf" => "__builtin_HEXAGON_F2_conv_w2sf", + "F2.dfadd" => "__builtin_HEXAGON_F2_dfadd", + "F2.dfclass" => "__builtin_HEXAGON_F2_dfclass", + "F2.dfcmpeq" => "__builtin_HEXAGON_F2_dfcmpeq", + "F2.dfcmpge" => "__builtin_HEXAGON_F2_dfcmpge", + "F2.dfcmpgt" => "__builtin_HEXAGON_F2_dfcmpgt", + "F2.dfcmpuo" => "__builtin_HEXAGON_F2_dfcmpuo", + "F2.dffixupd" => "__builtin_HEXAGON_F2_dffixupd", + "F2.dffixupn" => "__builtin_HEXAGON_F2_dffixupn", + "F2.dffixupr" => "__builtin_HEXAGON_F2_dffixupr", + "F2.dffma" => "__builtin_HEXAGON_F2_dffma", + "F2.dffma.lib" => "__builtin_HEXAGON_F2_dffma_lib", + "F2.dffma.sc" => "__builtin_HEXAGON_F2_dffma_sc", + "F2.dffms" => "__builtin_HEXAGON_F2_dffms", + "F2.dffms.lib" => "__builtin_HEXAGON_F2_dffms_lib", + "F2.dfimm.n" => "__builtin_HEXAGON_F2_dfimm_n", + "F2.dfimm.p" => "__builtin_HEXAGON_F2_dfimm_p", + "F2.dfmax" => "__builtin_HEXAGON_F2_dfmax", + "F2.dfmin" => "__builtin_HEXAGON_F2_dfmin", + "F2.dfmpy" => "__builtin_HEXAGON_F2_dfmpy", + "F2.dfmpyfix" => "__builtin_HEXAGON_F2_dfmpyfix", + "F2.dfmpyhh" => "__builtin_HEXAGON_F2_dfmpyhh", + "F2.dfmpylh" => "__builtin_HEXAGON_F2_dfmpylh", + "F2.dfmpyll" => "__builtin_HEXAGON_F2_dfmpyll", + "F2.dfsub" => "__builtin_HEXAGON_F2_dfsub", + "F2.sfadd" => "__builtin_HEXAGON_F2_sfadd", + "F2.sfclass" => "__builtin_HEXAGON_F2_sfclass", + "F2.sfcmpeq" => "__builtin_HEXAGON_F2_sfcmpeq", + "F2.sfcmpge" => "__builtin_HEXAGON_F2_sfcmpge", + "F2.sfcmpgt" => "__builtin_HEXAGON_F2_sfcmpgt", + "F2.sfcmpuo" => "__builtin_HEXAGON_F2_sfcmpuo", + "F2.sffixupd" => "__builtin_HEXAGON_F2_sffixupd", + "F2.sffixupn" => "__builtin_HEXAGON_F2_sffixupn", + "F2.sffixupr" => "__builtin_HEXAGON_F2_sffixupr", + "F2.sffma" => "__builtin_HEXAGON_F2_sffma", + "F2.sffma.lib" => "__builtin_HEXAGON_F2_sffma_lib", + "F2.sffma.sc" => "__builtin_HEXAGON_F2_sffma_sc", + "F2.sffms" => "__builtin_HEXAGON_F2_sffms", + "F2.sffms.lib" => "__builtin_HEXAGON_F2_sffms_lib", + "F2.sfimm.n" => "__builtin_HEXAGON_F2_sfimm_n", + "F2.sfimm.p" => "__builtin_HEXAGON_F2_sfimm_p", + "F2.sfmax" => "__builtin_HEXAGON_F2_sfmax", + "F2.sfmin" => "__builtin_HEXAGON_F2_sfmin", + "F2.sfmpy" => "__builtin_HEXAGON_F2_sfmpy", + "F2.sfsub" => "__builtin_HEXAGON_F2_sfsub", + "L2.loadw.locked" => "__builtin_HEXAGON_L2_loadw_locked", + "L4.loadd.locked" => "__builtin__HEXAGON_L4_loadd_locked", + "M2.acci" => "__builtin_HEXAGON_M2_acci", + "M2.accii" => "__builtin_HEXAGON_M2_accii", + "M2.cmaci.s0" => "__builtin_HEXAGON_M2_cmaci_s0", + "M2.cmacr.s0" => "__builtin_HEXAGON_M2_cmacr_s0", + "M2.cmacs.s0" => "__builtin_HEXAGON_M2_cmacs_s0", + "M2.cmacs.s1" => "__builtin_HEXAGON_M2_cmacs_s1", + "M2.cmacsc.s0" => "__builtin_HEXAGON_M2_cmacsc_s0", + "M2.cmacsc.s1" => "__builtin_HEXAGON_M2_cmacsc_s1", + "M2.cmpyi.s0" => "__builtin_HEXAGON_M2_cmpyi_s0", + "M2.cmpyr.s0" => "__builtin_HEXAGON_M2_cmpyr_s0", + "M2.cmpyrs.s0" => "__builtin_HEXAGON_M2_cmpyrs_s0", + "M2.cmpyrs.s1" => "__builtin_HEXAGON_M2_cmpyrs_s1", + "M2.cmpyrsc.s0" => "__builtin_HEXAGON_M2_cmpyrsc_s0", + "M2.cmpyrsc.s1" => "__builtin_HEXAGON_M2_cmpyrsc_s1", + "M2.cmpys.s0" => "__builtin_HEXAGON_M2_cmpys_s0", + "M2.cmpys.s1" => "__builtin_HEXAGON_M2_cmpys_s1", + "M2.cmpysc.s0" => "__builtin_HEXAGON_M2_cmpysc_s0", + "M2.cmpysc.s1" => "__builtin_HEXAGON_M2_cmpysc_s1", + "M2.cnacs.s0" => "__builtin_HEXAGON_M2_cnacs_s0", + "M2.cnacs.s1" => "__builtin_HEXAGON_M2_cnacs_s1", + "M2.cnacsc.s0" => "__builtin_HEXAGON_M2_cnacsc_s0", + "M2.cnacsc.s1" => "__builtin_HEXAGON_M2_cnacsc_s1", + "M2.dpmpyss.acc.s0" => "__builtin_HEXAGON_M2_dpmpyss_acc_s0", + "M2.dpmpyss.nac.s0" => "__builtin_HEXAGON_M2_dpmpyss_nac_s0", + "M2.dpmpyss.rnd.s0" => "__builtin_HEXAGON_M2_dpmpyss_rnd_s0", + "M2.dpmpyss.s0" => "__builtin_HEXAGON_M2_dpmpyss_s0", + "M2.dpmpyuu.acc.s0" => "__builtin_HEXAGON_M2_dpmpyuu_acc_s0", + "M2.dpmpyuu.nac.s0" => "__builtin_HEXAGON_M2_dpmpyuu_nac_s0", + "M2.dpmpyuu.s0" => "__builtin_HEXAGON_M2_dpmpyuu_s0", + "M2.hmmpyh.rs1" => "__builtin_HEXAGON_M2_hmmpyh_rs1", + "M2.hmmpyh.s1" => "__builtin_HEXAGON_M2_hmmpyh_s1", + "M2.hmmpyl.rs1" => "__builtin_HEXAGON_M2_hmmpyl_rs1", + "M2.hmmpyl.s1" => "__builtin_HEXAGON_M2_hmmpyl_s1", + "M2.maci" => "__builtin_HEXAGON_M2_maci", + "M2.macsin" => "__builtin_HEXAGON_M2_macsin", + "M2.macsip" => "__builtin_HEXAGON_M2_macsip", + "M2.mmachs.rs0" => "__builtin_HEXAGON_M2_mmachs_rs0", + "M2.mmachs.rs1" => "__builtin_HEXAGON_M2_mmachs_rs1", + "M2.mmachs.s0" => "__builtin_HEXAGON_M2_mmachs_s0", + "M2.mmachs.s1" => "__builtin_HEXAGON_M2_mmachs_s1", + "M2.mmacls.rs0" => "__builtin_HEXAGON_M2_mmacls_rs0", + "M2.mmacls.rs1" => "__builtin_HEXAGON_M2_mmacls_rs1", + "M2.mmacls.s0" => "__builtin_HEXAGON_M2_mmacls_s0", + "M2.mmacls.s1" => "__builtin_HEXAGON_M2_mmacls_s1", + "M2.mmacuhs.rs0" => "__builtin_HEXAGON_M2_mmacuhs_rs0", + "M2.mmacuhs.rs1" => "__builtin_HEXAGON_M2_mmacuhs_rs1", + "M2.mmacuhs.s0" => "__builtin_HEXAGON_M2_mmacuhs_s0", + "M2.mmacuhs.s1" => "__builtin_HEXAGON_M2_mmacuhs_s1", + "M2.mmaculs.rs0" => "__builtin_HEXAGON_M2_mmaculs_rs0", + "M2.mmaculs.rs1" => "__builtin_HEXAGON_M2_mmaculs_rs1", + "M2.mmaculs.s0" => "__builtin_HEXAGON_M2_mmaculs_s0", + "M2.mmaculs.s1" => "__builtin_HEXAGON_M2_mmaculs_s1", + "M2.mmpyh.rs0" => "__builtin_HEXAGON_M2_mmpyh_rs0", + "M2.mmpyh.rs1" => "__builtin_HEXAGON_M2_mmpyh_rs1", + "M2.mmpyh.s0" => "__builtin_HEXAGON_M2_mmpyh_s0", + "M2.mmpyh.s1" => "__builtin_HEXAGON_M2_mmpyh_s1", + "M2.mmpyl.rs0" => "__builtin_HEXAGON_M2_mmpyl_rs0", + "M2.mmpyl.rs1" => "__builtin_HEXAGON_M2_mmpyl_rs1", + "M2.mmpyl.s0" => "__builtin_HEXAGON_M2_mmpyl_s0", + "M2.mmpyl.s1" => "__builtin_HEXAGON_M2_mmpyl_s1", + "M2.mmpyuh.rs0" => "__builtin_HEXAGON_M2_mmpyuh_rs0", + "M2.mmpyuh.rs1" => "__builtin_HEXAGON_M2_mmpyuh_rs1", + "M2.mmpyuh.s0" => "__builtin_HEXAGON_M2_mmpyuh_s0", + "M2.mmpyuh.s1" => "__builtin_HEXAGON_M2_mmpyuh_s1", + "M2.mmpyul.rs0" => "__builtin_HEXAGON_M2_mmpyul_rs0", + "M2.mmpyul.rs1" => "__builtin_HEXAGON_M2_mmpyul_rs1", + "M2.mmpyul.s0" => "__builtin_HEXAGON_M2_mmpyul_s0", + "M2.mmpyul.s1" => "__builtin_HEXAGON_M2_mmpyul_s1", + "M2.mnaci" => "__builtin_HEXAGON_M2_mnaci", + "M2.mpy.acc.hh.s0" => "__builtin_HEXAGON_M2_mpy_acc_hh_s0", + "M2.mpy.acc.hh.s1" => "__builtin_HEXAGON_M2_mpy_acc_hh_s1", + "M2.mpy.acc.hl.s0" => "__builtin_HEXAGON_M2_mpy_acc_hl_s0", + "M2.mpy.acc.hl.s1" => "__builtin_HEXAGON_M2_mpy_acc_hl_s1", + "M2.mpy.acc.lh.s0" => "__builtin_HEXAGON_M2_mpy_acc_lh_s0", + "M2.mpy.acc.lh.s1" => "__builtin_HEXAGON_M2_mpy_acc_lh_s1", + "M2.mpy.acc.ll.s0" => "__builtin_HEXAGON_M2_mpy_acc_ll_s0", + "M2.mpy.acc.ll.s1" => "__builtin_HEXAGON_M2_mpy_acc_ll_s1", + "M2.mpy.acc.sat.hh.s0" => "__builtin_HEXAGON_M2_mpy_acc_sat_hh_s0", + "M2.mpy.acc.sat.hh.s1" => "__builtin_HEXAGON_M2_mpy_acc_sat_hh_s1", + "M2.mpy.acc.sat.hl.s0" => "__builtin_HEXAGON_M2_mpy_acc_sat_hl_s0", + "M2.mpy.acc.sat.hl.s1" => "__builtin_HEXAGON_M2_mpy_acc_sat_hl_s1", + "M2.mpy.acc.sat.lh.s0" => "__builtin_HEXAGON_M2_mpy_acc_sat_lh_s0", + "M2.mpy.acc.sat.lh.s1" => "__builtin_HEXAGON_M2_mpy_acc_sat_lh_s1", + "M2.mpy.acc.sat.ll.s0" => "__builtin_HEXAGON_M2_mpy_acc_sat_ll_s0", + "M2.mpy.acc.sat.ll.s1" => "__builtin_HEXAGON_M2_mpy_acc_sat_ll_s1", + "M2.mpy.hh.s0" => "__builtin_HEXAGON_M2_mpy_hh_s0", + "M2.mpy.hh.s1" => "__builtin_HEXAGON_M2_mpy_hh_s1", + "M2.mpy.hl.s0" => "__builtin_HEXAGON_M2_mpy_hl_s0", + "M2.mpy.hl.s1" => "__builtin_HEXAGON_M2_mpy_hl_s1", + "M2.mpy.lh.s0" => "__builtin_HEXAGON_M2_mpy_lh_s0", + "M2.mpy.lh.s1" => "__builtin_HEXAGON_M2_mpy_lh_s1", + "M2.mpy.ll.s0" => "__builtin_HEXAGON_M2_mpy_ll_s0", + "M2.mpy.ll.s1" => "__builtin_HEXAGON_M2_mpy_ll_s1", + "M2.mpy.nac.hh.s0" => "__builtin_HEXAGON_M2_mpy_nac_hh_s0", + "M2.mpy.nac.hh.s1" => "__builtin_HEXAGON_M2_mpy_nac_hh_s1", + "M2.mpy.nac.hl.s0" => "__builtin_HEXAGON_M2_mpy_nac_hl_s0", + "M2.mpy.nac.hl.s1" => "__builtin_HEXAGON_M2_mpy_nac_hl_s1", + "M2.mpy.nac.lh.s0" => "__builtin_HEXAGON_M2_mpy_nac_lh_s0", + "M2.mpy.nac.lh.s1" => "__builtin_HEXAGON_M2_mpy_nac_lh_s1", + "M2.mpy.nac.ll.s0" => "__builtin_HEXAGON_M2_mpy_nac_ll_s0", + "M2.mpy.nac.ll.s1" => "__builtin_HEXAGON_M2_mpy_nac_ll_s1", + "M2.mpy.nac.sat.hh.s0" => "__builtin_HEXAGON_M2_mpy_nac_sat_hh_s0", + "M2.mpy.nac.sat.hh.s1" => "__builtin_HEXAGON_M2_mpy_nac_sat_hh_s1", + "M2.mpy.nac.sat.hl.s0" => "__builtin_HEXAGON_M2_mpy_nac_sat_hl_s0", + "M2.mpy.nac.sat.hl.s1" => "__builtin_HEXAGON_M2_mpy_nac_sat_hl_s1", + "M2.mpy.nac.sat.lh.s0" => "__builtin_HEXAGON_M2_mpy_nac_sat_lh_s0", + "M2.mpy.nac.sat.lh.s1" => "__builtin_HEXAGON_M2_mpy_nac_sat_lh_s1", + "M2.mpy.nac.sat.ll.s0" => "__builtin_HEXAGON_M2_mpy_nac_sat_ll_s0", + "M2.mpy.nac.sat.ll.s1" => "__builtin_HEXAGON_M2_mpy_nac_sat_ll_s1", + "M2.mpy.rnd.hh.s0" => "__builtin_HEXAGON_M2_mpy_rnd_hh_s0", + "M2.mpy.rnd.hh.s1" => "__builtin_HEXAGON_M2_mpy_rnd_hh_s1", + "M2.mpy.rnd.hl.s0" => "__builtin_HEXAGON_M2_mpy_rnd_hl_s0", + "M2.mpy.rnd.hl.s1" => "__builtin_HEXAGON_M2_mpy_rnd_hl_s1", + "M2.mpy.rnd.lh.s0" => "__builtin_HEXAGON_M2_mpy_rnd_lh_s0", + "M2.mpy.rnd.lh.s1" => "__builtin_HEXAGON_M2_mpy_rnd_lh_s1", + "M2.mpy.rnd.ll.s0" => "__builtin_HEXAGON_M2_mpy_rnd_ll_s0", + "M2.mpy.rnd.ll.s1" => "__builtin_HEXAGON_M2_mpy_rnd_ll_s1", + "M2.mpy.sat.hh.s0" => "__builtin_HEXAGON_M2_mpy_sat_hh_s0", + "M2.mpy.sat.hh.s1" => "__builtin_HEXAGON_M2_mpy_sat_hh_s1", + "M2.mpy.sat.hl.s0" => "__builtin_HEXAGON_M2_mpy_sat_hl_s0", + "M2.mpy.sat.hl.s1" => "__builtin_HEXAGON_M2_mpy_sat_hl_s1", + "M2.mpy.sat.lh.s0" => "__builtin_HEXAGON_M2_mpy_sat_lh_s0", + "M2.mpy.sat.lh.s1" => "__builtin_HEXAGON_M2_mpy_sat_lh_s1", + "M2.mpy.sat.ll.s0" => "__builtin_HEXAGON_M2_mpy_sat_ll_s0", + "M2.mpy.sat.ll.s1" => "__builtin_HEXAGON_M2_mpy_sat_ll_s1", + "M2.mpy.sat.rnd.hh.s0" => "__builtin_HEXAGON_M2_mpy_sat_rnd_hh_s0", + "M2.mpy.sat.rnd.hh.s1" => "__builtin_HEXAGON_M2_mpy_sat_rnd_hh_s1", + "M2.mpy.sat.rnd.hl.s0" => "__builtin_HEXAGON_M2_mpy_sat_rnd_hl_s0", + "M2.mpy.sat.rnd.hl.s1" => "__builtin_HEXAGON_M2_mpy_sat_rnd_hl_s1", + "M2.mpy.sat.rnd.lh.s0" => "__builtin_HEXAGON_M2_mpy_sat_rnd_lh_s0", + "M2.mpy.sat.rnd.lh.s1" => "__builtin_HEXAGON_M2_mpy_sat_rnd_lh_s1", + "M2.mpy.sat.rnd.ll.s0" => "__builtin_HEXAGON_M2_mpy_sat_rnd_ll_s0", + "M2.mpy.sat.rnd.ll.s1" => "__builtin_HEXAGON_M2_mpy_sat_rnd_ll_s1", + "M2.mpy.up" => "__builtin_HEXAGON_M2_mpy_up", + "M2.mpy.up.s1" => "__builtin_HEXAGON_M2_mpy_up_s1", + "M2.mpy.up.s1.sat" => "__builtin_HEXAGON_M2_mpy_up_s1_sat", + "M2.mpyd.acc.hh.s0" => "__builtin_HEXAGON_M2_mpyd_acc_hh_s0", + "M2.mpyd.acc.hh.s1" => "__builtin_HEXAGON_M2_mpyd_acc_hh_s1", + "M2.mpyd.acc.hl.s0" => "__builtin_HEXAGON_M2_mpyd_acc_hl_s0", + "M2.mpyd.acc.hl.s1" => "__builtin_HEXAGON_M2_mpyd_acc_hl_s1", + "M2.mpyd.acc.lh.s0" => "__builtin_HEXAGON_M2_mpyd_acc_lh_s0", + "M2.mpyd.acc.lh.s1" => "__builtin_HEXAGON_M2_mpyd_acc_lh_s1", + "M2.mpyd.acc.ll.s0" => "__builtin_HEXAGON_M2_mpyd_acc_ll_s0", + "M2.mpyd.acc.ll.s1" => "__builtin_HEXAGON_M2_mpyd_acc_ll_s1", + "M2.mpyd.hh.s0" => "__builtin_HEXAGON_M2_mpyd_hh_s0", + "M2.mpyd.hh.s1" => "__builtin_HEXAGON_M2_mpyd_hh_s1", + "M2.mpyd.hl.s0" => "__builtin_HEXAGON_M2_mpyd_hl_s0", + "M2.mpyd.hl.s1" => "__builtin_HEXAGON_M2_mpyd_hl_s1", + "M2.mpyd.lh.s0" => "__builtin_HEXAGON_M2_mpyd_lh_s0", + "M2.mpyd.lh.s1" => "__builtin_HEXAGON_M2_mpyd_lh_s1", + "M2.mpyd.ll.s0" => "__builtin_HEXAGON_M2_mpyd_ll_s0", + "M2.mpyd.ll.s1" => "__builtin_HEXAGON_M2_mpyd_ll_s1", + "M2.mpyd.nac.hh.s0" => "__builtin_HEXAGON_M2_mpyd_nac_hh_s0", + "M2.mpyd.nac.hh.s1" => "__builtin_HEXAGON_M2_mpyd_nac_hh_s1", + "M2.mpyd.nac.hl.s0" => "__builtin_HEXAGON_M2_mpyd_nac_hl_s0", + "M2.mpyd.nac.hl.s1" => "__builtin_HEXAGON_M2_mpyd_nac_hl_s1", + "M2.mpyd.nac.lh.s0" => "__builtin_HEXAGON_M2_mpyd_nac_lh_s0", + "M2.mpyd.nac.lh.s1" => "__builtin_HEXAGON_M2_mpyd_nac_lh_s1", + "M2.mpyd.nac.ll.s0" => "__builtin_HEXAGON_M2_mpyd_nac_ll_s0", + "M2.mpyd.nac.ll.s1" => "__builtin_HEXAGON_M2_mpyd_nac_ll_s1", + "M2.mpyd.rnd.hh.s0" => "__builtin_HEXAGON_M2_mpyd_rnd_hh_s0", + "M2.mpyd.rnd.hh.s1" => "__builtin_HEXAGON_M2_mpyd_rnd_hh_s1", + "M2.mpyd.rnd.hl.s0" => "__builtin_HEXAGON_M2_mpyd_rnd_hl_s0", + "M2.mpyd.rnd.hl.s1" => "__builtin_HEXAGON_M2_mpyd_rnd_hl_s1", + "M2.mpyd.rnd.lh.s0" => "__builtin_HEXAGON_M2_mpyd_rnd_lh_s0", + "M2.mpyd.rnd.lh.s1" => "__builtin_HEXAGON_M2_mpyd_rnd_lh_s1", + "M2.mpyd.rnd.ll.s0" => "__builtin_HEXAGON_M2_mpyd_rnd_ll_s0", + "M2.mpyd.rnd.ll.s1" => "__builtin_HEXAGON_M2_mpyd_rnd_ll_s1", + "M2.mpyi" => "__builtin_HEXAGON_M2_mpyi", + "M2.mpysmi" => "__builtin_HEXAGON_M2_mpysmi", + "M2.mpysu.up" => "__builtin_HEXAGON_M2_mpysu_up", + "M2.mpyu.acc.hh.s0" => "__builtin_HEXAGON_M2_mpyu_acc_hh_s0", + "M2.mpyu.acc.hh.s1" => "__builtin_HEXAGON_M2_mpyu_acc_hh_s1", + "M2.mpyu.acc.hl.s0" => "__builtin_HEXAGON_M2_mpyu_acc_hl_s0", + "M2.mpyu.acc.hl.s1" => "__builtin_HEXAGON_M2_mpyu_acc_hl_s1", + "M2.mpyu.acc.lh.s0" => "__builtin_HEXAGON_M2_mpyu_acc_lh_s0", + "M2.mpyu.acc.lh.s1" => "__builtin_HEXAGON_M2_mpyu_acc_lh_s1", + "M2.mpyu.acc.ll.s0" => "__builtin_HEXAGON_M2_mpyu_acc_ll_s0", + "M2.mpyu.acc.ll.s1" => "__builtin_HEXAGON_M2_mpyu_acc_ll_s1", + "M2.mpyu.hh.s0" => "__builtin_HEXAGON_M2_mpyu_hh_s0", + "M2.mpyu.hh.s1" => "__builtin_HEXAGON_M2_mpyu_hh_s1", + "M2.mpyu.hl.s0" => "__builtin_HEXAGON_M2_mpyu_hl_s0", + "M2.mpyu.hl.s1" => "__builtin_HEXAGON_M2_mpyu_hl_s1", + "M2.mpyu.lh.s0" => "__builtin_HEXAGON_M2_mpyu_lh_s0", + "M2.mpyu.lh.s1" => "__builtin_HEXAGON_M2_mpyu_lh_s1", + "M2.mpyu.ll.s0" => "__builtin_HEXAGON_M2_mpyu_ll_s0", + "M2.mpyu.ll.s1" => "__builtin_HEXAGON_M2_mpyu_ll_s1", + "M2.mpyu.nac.hh.s0" => "__builtin_HEXAGON_M2_mpyu_nac_hh_s0", + "M2.mpyu.nac.hh.s1" => "__builtin_HEXAGON_M2_mpyu_nac_hh_s1", + "M2.mpyu.nac.hl.s0" => "__builtin_HEXAGON_M2_mpyu_nac_hl_s0", + "M2.mpyu.nac.hl.s1" => "__builtin_HEXAGON_M2_mpyu_nac_hl_s1", + "M2.mpyu.nac.lh.s0" => "__builtin_HEXAGON_M2_mpyu_nac_lh_s0", + "M2.mpyu.nac.lh.s1" => "__builtin_HEXAGON_M2_mpyu_nac_lh_s1", + "M2.mpyu.nac.ll.s0" => "__builtin_HEXAGON_M2_mpyu_nac_ll_s0", + "M2.mpyu.nac.ll.s1" => "__builtin_HEXAGON_M2_mpyu_nac_ll_s1", + "M2.mpyu.up" => "__builtin_HEXAGON_M2_mpyu_up", + "M2.mpyud.acc.hh.s0" => "__builtin_HEXAGON_M2_mpyud_acc_hh_s0", + "M2.mpyud.acc.hh.s1" => "__builtin_HEXAGON_M2_mpyud_acc_hh_s1", + "M2.mpyud.acc.hl.s0" => "__builtin_HEXAGON_M2_mpyud_acc_hl_s0", + "M2.mpyud.acc.hl.s1" => "__builtin_HEXAGON_M2_mpyud_acc_hl_s1", + "M2.mpyud.acc.lh.s0" => "__builtin_HEXAGON_M2_mpyud_acc_lh_s0", + "M2.mpyud.acc.lh.s1" => "__builtin_HEXAGON_M2_mpyud_acc_lh_s1", + "M2.mpyud.acc.ll.s0" => "__builtin_HEXAGON_M2_mpyud_acc_ll_s0", + "M2.mpyud.acc.ll.s1" => "__builtin_HEXAGON_M2_mpyud_acc_ll_s1", + "M2.mpyud.hh.s0" => "__builtin_HEXAGON_M2_mpyud_hh_s0", + "M2.mpyud.hh.s1" => "__builtin_HEXAGON_M2_mpyud_hh_s1", + "M2.mpyud.hl.s0" => "__builtin_HEXAGON_M2_mpyud_hl_s0", + "M2.mpyud.hl.s1" => "__builtin_HEXAGON_M2_mpyud_hl_s1", + "M2.mpyud.lh.s0" => "__builtin_HEXAGON_M2_mpyud_lh_s0", + "M2.mpyud.lh.s1" => "__builtin_HEXAGON_M2_mpyud_lh_s1", + "M2.mpyud.ll.s0" => "__builtin_HEXAGON_M2_mpyud_ll_s0", + "M2.mpyud.ll.s1" => "__builtin_HEXAGON_M2_mpyud_ll_s1", + "M2.mpyud.nac.hh.s0" => "__builtin_HEXAGON_M2_mpyud_nac_hh_s0", + "M2.mpyud.nac.hh.s1" => "__builtin_HEXAGON_M2_mpyud_nac_hh_s1", + "M2.mpyud.nac.hl.s0" => "__builtin_HEXAGON_M2_mpyud_nac_hl_s0", + "M2.mpyud.nac.hl.s1" => "__builtin_HEXAGON_M2_mpyud_nac_hl_s1", + "M2.mpyud.nac.lh.s0" => "__builtin_HEXAGON_M2_mpyud_nac_lh_s0", + "M2.mpyud.nac.lh.s1" => "__builtin_HEXAGON_M2_mpyud_nac_lh_s1", + "M2.mpyud.nac.ll.s0" => "__builtin_HEXAGON_M2_mpyud_nac_ll_s0", + "M2.mpyud.nac.ll.s1" => "__builtin_HEXAGON_M2_mpyud_nac_ll_s1", + "M2.mpyui" => "__builtin_HEXAGON_M2_mpyui", + "M2.nacci" => "__builtin_HEXAGON_M2_nacci", + "M2.naccii" => "__builtin_HEXAGON_M2_naccii", + "M2.subacc" => "__builtin_HEXAGON_M2_subacc", + "M2.vabsdiffh" => "__builtin_HEXAGON_M2_vabsdiffh", + "M2.vabsdiffw" => "__builtin_HEXAGON_M2_vabsdiffw", + "M2.vcmac.s0.sat.i" => "__builtin_HEXAGON_M2_vcmac_s0_sat_i", + "M2.vcmac.s0.sat.r" => "__builtin_HEXAGON_M2_vcmac_s0_sat_r", + "M2.vcmpy.s0.sat.i" => "__builtin_HEXAGON_M2_vcmpy_s0_sat_i", + "M2.vcmpy.s0.sat.r" => "__builtin_HEXAGON_M2_vcmpy_s0_sat_r", + "M2.vcmpy.s1.sat.i" => "__builtin_HEXAGON_M2_vcmpy_s1_sat_i", + "M2.vcmpy.s1.sat.r" => "__builtin_HEXAGON_M2_vcmpy_s1_sat_r", + "M2.vdmacs.s0" => "__builtin_HEXAGON_M2_vdmacs_s0", + "M2.vdmacs.s1" => "__builtin_HEXAGON_M2_vdmacs_s1", + "M2.vdmpyrs.s0" => "__builtin_HEXAGON_M2_vdmpyrs_s0", + "M2.vdmpyrs.s1" => "__builtin_HEXAGON_M2_vdmpyrs_s1", + "M2.vdmpys.s0" => "__builtin_HEXAGON_M2_vdmpys_s0", + "M2.vdmpys.s1" => "__builtin_HEXAGON_M2_vdmpys_s1", + "M2.vmac2" => "__builtin_HEXAGON_M2_vmac2", + "M2.vmac2es" => "__builtin_HEXAGON_M2_vmac2es", + "M2.vmac2es.s0" => "__builtin_HEXAGON_M2_vmac2es_s0", + "M2.vmac2es.s1" => "__builtin_HEXAGON_M2_vmac2es_s1", + "M2.vmac2s.s0" => "__builtin_HEXAGON_M2_vmac2s_s0", + "M2.vmac2s.s1" => "__builtin_HEXAGON_M2_vmac2s_s1", + "M2.vmac2su.s0" => "__builtin_HEXAGON_M2_vmac2su_s0", + "M2.vmac2su.s1" => "__builtin_HEXAGON_M2_vmac2su_s1", + "M2.vmpy2es.s0" => "__builtin_HEXAGON_M2_vmpy2es_s0", + "M2.vmpy2es.s1" => "__builtin_HEXAGON_M2_vmpy2es_s1", + "M2.vmpy2s.s0" => "__builtin_HEXAGON_M2_vmpy2s_s0", + "M2.vmpy2s.s0pack" => "__builtin_HEXAGON_M2_vmpy2s_s0pack", + "M2.vmpy2s.s1" => "__builtin_HEXAGON_M2_vmpy2s_s1", + "M2.vmpy2s.s1pack" => "__builtin_HEXAGON_M2_vmpy2s_s1pack", + "M2.vmpy2su.s0" => "__builtin_HEXAGON_M2_vmpy2su_s0", + "M2.vmpy2su.s1" => "__builtin_HEXAGON_M2_vmpy2su_s1", + "M2.vraddh" => "__builtin_HEXAGON_M2_vraddh", + "M2.vradduh" => "__builtin_HEXAGON_M2_vradduh", + "M2.vrcmaci.s0" => "__builtin_HEXAGON_M2_vrcmaci_s0", + "M2.vrcmaci.s0c" => "__builtin_HEXAGON_M2_vrcmaci_s0c", + "M2.vrcmacr.s0" => "__builtin_HEXAGON_M2_vrcmacr_s0", + "M2.vrcmacr.s0c" => "__builtin_HEXAGON_M2_vrcmacr_s0c", + "M2.vrcmpyi.s0" => "__builtin_HEXAGON_M2_vrcmpyi_s0", + "M2.vrcmpyi.s0c" => "__builtin_HEXAGON_M2_vrcmpyi_s0c", + "M2.vrcmpyr.s0" => "__builtin_HEXAGON_M2_vrcmpyr_s0", + "M2.vrcmpyr.s0c" => "__builtin_HEXAGON_M2_vrcmpyr_s0c", + "M2.vrcmpys.acc.s1" => "__builtin_HEXAGON_M2_vrcmpys_acc_s1", + "M2.vrcmpys.s1" => "__builtin_HEXAGON_M2_vrcmpys_s1", + "M2.vrcmpys.s1rp" => "__builtin_HEXAGON_M2_vrcmpys_s1rp", + "M2.vrmac.s0" => "__builtin_HEXAGON_M2_vrmac_s0", + "M2.vrmpy.s0" => "__builtin_HEXAGON_M2_vrmpy_s0", + "M2.xor.xacc" => "__builtin_HEXAGON_M2_xor_xacc", + "M4.and.and" => "__builtin_HEXAGON_M4_and_and", + "M4.and.andn" => "__builtin_HEXAGON_M4_and_andn", + "M4.and.or" => "__builtin_HEXAGON_M4_and_or", + "M4.and.xor" => "__builtin_HEXAGON_M4_and_xor", + "M4.cmpyi.wh" => "__builtin_HEXAGON_M4_cmpyi_wh", + "M4.cmpyi.whc" => "__builtin_HEXAGON_M4_cmpyi_whc", + "M4.cmpyr.wh" => "__builtin_HEXAGON_M4_cmpyr_wh", + "M4.cmpyr.whc" => "__builtin_HEXAGON_M4_cmpyr_whc", + "M4.mac.up.s1.sat" => "__builtin_HEXAGON_M4_mac_up_s1_sat", + "M4.mpyri.addi" => "__builtin_HEXAGON_M4_mpyri_addi", + "M4.mpyri.addr" => "__builtin_HEXAGON_M4_mpyri_addr", + "M4.mpyri.addr.u2" => "__builtin_HEXAGON_M4_mpyri_addr_u2", + "M4.mpyrr.addi" => "__builtin_HEXAGON_M4_mpyrr_addi", + "M4.mpyrr.addr" => "__builtin_HEXAGON_M4_mpyrr_addr", + "M4.nac.up.s1.sat" => "__builtin_HEXAGON_M4_nac_up_s1_sat", + "M4.or.and" => "__builtin_HEXAGON_M4_or_and", + "M4.or.andn" => "__builtin_HEXAGON_M4_or_andn", + "M4.or.or" => "__builtin_HEXAGON_M4_or_or", + "M4.or.xor" => "__builtin_HEXAGON_M4_or_xor", + "M4.pmpyw" => "__builtin_HEXAGON_M4_pmpyw", + "M4.pmpyw.acc" => "__builtin_HEXAGON_M4_pmpyw_acc", + "M4.vpmpyh" => "__builtin_HEXAGON_M4_vpmpyh", + "M4.vpmpyh.acc" => "__builtin_HEXAGON_M4_vpmpyh_acc", + "M4.vrmpyeh.acc.s0" => "__builtin_HEXAGON_M4_vrmpyeh_acc_s0", + "M4.vrmpyeh.acc.s1" => "__builtin_HEXAGON_M4_vrmpyeh_acc_s1", + "M4.vrmpyeh.s0" => "__builtin_HEXAGON_M4_vrmpyeh_s0", + "M4.vrmpyeh.s1" => "__builtin_HEXAGON_M4_vrmpyeh_s1", + "M4.vrmpyoh.acc.s0" => "__builtin_HEXAGON_M4_vrmpyoh_acc_s0", + "M4.vrmpyoh.acc.s1" => "__builtin_HEXAGON_M4_vrmpyoh_acc_s1", + "M4.vrmpyoh.s0" => "__builtin_HEXAGON_M4_vrmpyoh_s0", + "M4.vrmpyoh.s1" => "__builtin_HEXAGON_M4_vrmpyoh_s1", + "M4.xor.and" => "__builtin_HEXAGON_M4_xor_and", + "M4.xor.andn" => "__builtin_HEXAGON_M4_xor_andn", + "M4.xor.or" => "__builtin_HEXAGON_M4_xor_or", + "M4.xor.xacc" => "__builtin_HEXAGON_M4_xor_xacc", + "M5.vdmacbsu" => "__builtin_HEXAGON_M5_vdmacbsu", + "M5.vdmpybsu" => "__builtin_HEXAGON_M5_vdmpybsu", + "M5.vmacbsu" => "__builtin_HEXAGON_M5_vmacbsu", + "M5.vmacbuu" => "__builtin_HEXAGON_M5_vmacbuu", + "M5.vmpybsu" => "__builtin_HEXAGON_M5_vmpybsu", + "M5.vmpybuu" => "__builtin_HEXAGON_M5_vmpybuu", + "M5.vrmacbsu" => "__builtin_HEXAGON_M5_vrmacbsu", + "M5.vrmacbuu" => "__builtin_HEXAGON_M5_vrmacbuu", + "M5.vrmpybsu" => "__builtin_HEXAGON_M5_vrmpybsu", + "M5.vrmpybuu" => "__builtin_HEXAGON_M5_vrmpybuu", + "M6.vabsdiffb" => "__builtin_HEXAGON_M6_vabsdiffb", + "M6.vabsdiffub" => "__builtin_HEXAGON_M6_vabsdiffub", + "M7.dcmpyiw" => "__builtin_HEXAGON_M7_dcmpyiw", + "M7.dcmpyiw.acc" => "__builtin_HEXAGON_M7_dcmpyiw_acc", + "M7.dcmpyiwc" => "__builtin_HEXAGON_M7_dcmpyiwc", + "M7.dcmpyiwc.acc" => "__builtin_HEXAGON_M7_dcmpyiwc_acc", + "M7.dcmpyrw" => "__builtin_HEXAGON_M7_dcmpyrw", + "M7.dcmpyrw.acc" => "__builtin_HEXAGON_M7_dcmpyrw_acc", + "M7.dcmpyrwc" => "__builtin_HEXAGON_M7_dcmpyrwc", + "M7.dcmpyrwc.acc" => "__builtin_HEXAGON_M7_dcmpyrwc_acc", + "M7.vdmpy" => "__builtin_HEXAGON_M7_vdmpy", + "M7.vdmpy.acc" => "__builtin_HEXAGON_M7_vdmpy_acc", + "M7.wcmpyiw" => "__builtin_HEXAGON_M7_wcmpyiw", + "M7.wcmpyiw.rnd" => "__builtin_HEXAGON_M7_wcmpyiw_rnd", + "M7.wcmpyiwc" => "__builtin_HEXAGON_M7_wcmpyiwc", + "M7.wcmpyiwc.rnd" => "__builtin_HEXAGON_M7_wcmpyiwc_rnd", + "M7.wcmpyrw" => "__builtin_HEXAGON_M7_wcmpyrw", + "M7.wcmpyrw.rnd" => "__builtin_HEXAGON_M7_wcmpyrw_rnd", + "M7.wcmpyrwc" => "__builtin_HEXAGON_M7_wcmpyrwc", + "M7.wcmpyrwc.rnd" => "__builtin_HEXAGON_M7_wcmpyrwc_rnd", + "S2.addasl.rrri" => "__builtin_HEXAGON_S2_addasl_rrri", + "S2.asl.i.p" => "__builtin_HEXAGON_S2_asl_i_p", + "S2.asl.i.p.acc" => "__builtin_HEXAGON_S2_asl_i_p_acc", + "S2.asl.i.p.and" => "__builtin_HEXAGON_S2_asl_i_p_and", + "S2.asl.i.p.nac" => "__builtin_HEXAGON_S2_asl_i_p_nac", + "S2.asl.i.p.or" => "__builtin_HEXAGON_S2_asl_i_p_or", + "S2.asl.i.p.xacc" => "__builtin_HEXAGON_S2_asl_i_p_xacc", + "S2.asl.i.r" => "__builtin_HEXAGON_S2_asl_i_r", + "S2.asl.i.r.acc" => "__builtin_HEXAGON_S2_asl_i_r_acc", + "S2.asl.i.r.and" => "__builtin_HEXAGON_S2_asl_i_r_and", + "S2.asl.i.r.nac" => "__builtin_HEXAGON_S2_asl_i_r_nac", + "S2.asl.i.r.or" => "__builtin_HEXAGON_S2_asl_i_r_or", + "S2.asl.i.r.sat" => "__builtin_HEXAGON_S2_asl_i_r_sat", + "S2.asl.i.r.xacc" => "__builtin_HEXAGON_S2_asl_i_r_xacc", + "S2.asl.i.vh" => "__builtin_HEXAGON_S2_asl_i_vh", + "S2.asl.i.vw" => "__builtin_HEXAGON_S2_asl_i_vw", + "S2.asl.r.p" => "__builtin_HEXAGON_S2_asl_r_p", + "S2.asl.r.p.acc" => "__builtin_HEXAGON_S2_asl_r_p_acc", + "S2.asl.r.p.and" => "__builtin_HEXAGON_S2_asl_r_p_and", + "S2.asl.r.p.nac" => "__builtin_HEXAGON_S2_asl_r_p_nac", + "S2.asl.r.p.or" => "__builtin_HEXAGON_S2_asl_r_p_or", + "S2.asl.r.p.xor" => "__builtin_HEXAGON_S2_asl_r_p_xor", + "S2.asl.r.r" => "__builtin_HEXAGON_S2_asl_r_r", + "S2.asl.r.r.acc" => "__builtin_HEXAGON_S2_asl_r_r_acc", + "S2.asl.r.r.and" => "__builtin_HEXAGON_S2_asl_r_r_and", + "S2.asl.r.r.nac" => "__builtin_HEXAGON_S2_asl_r_r_nac", + "S2.asl.r.r.or" => "__builtin_HEXAGON_S2_asl_r_r_or", + "S2.asl.r.r.sat" => "__builtin_HEXAGON_S2_asl_r_r_sat", + "S2.asl.r.vh" => "__builtin_HEXAGON_S2_asl_r_vh", + "S2.asl.r.vw" => "__builtin_HEXAGON_S2_asl_r_vw", + "S2.asr.i.p" => "__builtin_HEXAGON_S2_asr_i_p", + "S2.asr.i.p.acc" => "__builtin_HEXAGON_S2_asr_i_p_acc", + "S2.asr.i.p.and" => "__builtin_HEXAGON_S2_asr_i_p_and", + "S2.asr.i.p.nac" => "__builtin_HEXAGON_S2_asr_i_p_nac", + "S2.asr.i.p.or" => "__builtin_HEXAGON_S2_asr_i_p_or", + "S2.asr.i.p.rnd" => "__builtin_HEXAGON_S2_asr_i_p_rnd", + "S2.asr.i.p.rnd.goodsyntax" => "__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax", + "S2.asr.i.r" => "__builtin_HEXAGON_S2_asr_i_r", + "S2.asr.i.r.acc" => "__builtin_HEXAGON_S2_asr_i_r_acc", + "S2.asr.i.r.and" => "__builtin_HEXAGON_S2_asr_i_r_and", + "S2.asr.i.r.nac" => "__builtin_HEXAGON_S2_asr_i_r_nac", + "S2.asr.i.r.or" => "__builtin_HEXAGON_S2_asr_i_r_or", + "S2.asr.i.r.rnd" => "__builtin_HEXAGON_S2_asr_i_r_rnd", + "S2.asr.i.r.rnd.goodsyntax" => "__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax", + "S2.asr.i.svw.trun" => "__builtin_HEXAGON_S2_asr_i_svw_trun", + "S2.asr.i.vh" => "__builtin_HEXAGON_S2_asr_i_vh", + "S2.asr.i.vw" => "__builtin_HEXAGON_S2_asr_i_vw", + "S2.asr.r.p" => "__builtin_HEXAGON_S2_asr_r_p", + "S2.asr.r.p.acc" => "__builtin_HEXAGON_S2_asr_r_p_acc", + "S2.asr.r.p.and" => "__builtin_HEXAGON_S2_asr_r_p_and", + "S2.asr.r.p.nac" => "__builtin_HEXAGON_S2_asr_r_p_nac", + "S2.asr.r.p.or" => "__builtin_HEXAGON_S2_asr_r_p_or", + "S2.asr.r.p.xor" => "__builtin_HEXAGON_S2_asr_r_p_xor", + "S2.asr.r.r" => "__builtin_HEXAGON_S2_asr_r_r", + "S2.asr.r.r.acc" => "__builtin_HEXAGON_S2_asr_r_r_acc", + "S2.asr.r.r.and" => "__builtin_HEXAGON_S2_asr_r_r_and", + "S2.asr.r.r.nac" => "__builtin_HEXAGON_S2_asr_r_r_nac", + "S2.asr.r.r.or" => "__builtin_HEXAGON_S2_asr_r_r_or", + "S2.asr.r.r.sat" => "__builtin_HEXAGON_S2_asr_r_r_sat", + "S2.asr.r.svw.trun" => "__builtin_HEXAGON_S2_asr_r_svw_trun", + "S2.asr.r.vh" => "__builtin_HEXAGON_S2_asr_r_vh", + "S2.asr.r.vw" => "__builtin_HEXAGON_S2_asr_r_vw", + "S2.brev" => "__builtin_HEXAGON_S2_brev", + "S2.brevp" => "__builtin_HEXAGON_S2_brevp", + "S2.cabacencbin" => "__builtin_HEXAGON_S2_cabacencbin", + "S2.cl0" => "__builtin_HEXAGON_S2_cl0", + "S2.cl0p" => "__builtin_HEXAGON_S2_cl0p", + "S2.cl1" => "__builtin_HEXAGON_S2_cl1", + "S2.cl1p" => "__builtin_HEXAGON_S2_cl1p", + "S2.clb" => "__builtin_HEXAGON_S2_clb", + "S2.clbnorm" => "__builtin_HEXAGON_S2_clbnorm", + "S2.clbp" => "__builtin_HEXAGON_S2_clbp", + "S2.clrbit.i" => "__builtin_HEXAGON_S2_clrbit_i", + "S2.clrbit.r" => "__builtin_HEXAGON_S2_clrbit_r", + "S2.ct0" => "__builtin_HEXAGON_S2_ct0", + "S2.ct0p" => "__builtin_HEXAGON_S2_ct0p", + "S2.ct1" => "__builtin_HEXAGON_S2_ct1", + "S2.ct1p" => "__builtin_HEXAGON_S2_ct1p", + "S2.deinterleave" => "__builtin_HEXAGON_S2_deinterleave", + "S2.extractu" => "__builtin_HEXAGON_S2_extractu", + "S2.extractu.rp" => "__builtin_HEXAGON_S2_extractu_rp", + "S2.extractup" => "__builtin_HEXAGON_S2_extractup", + "S2.extractup.rp" => "__builtin_HEXAGON_S2_extractup_rp", + "S2.insert" => "__builtin_HEXAGON_S2_insert", + "S2.insert.rp" => "__builtin_HEXAGON_S2_insert_rp", + "S2.insertp" => "__builtin_HEXAGON_S2_insertp", + "S2.insertp.rp" => "__builtin_HEXAGON_S2_insertp_rp", + "S2.interleave" => "__builtin_HEXAGON_S2_interleave", + "S2.lfsp" => "__builtin_HEXAGON_S2_lfsp", + "S2.lsl.r.p" => "__builtin_HEXAGON_S2_lsl_r_p", + "S2.lsl.r.p.acc" => "__builtin_HEXAGON_S2_lsl_r_p_acc", + "S2.lsl.r.p.and" => "__builtin_HEXAGON_S2_lsl_r_p_and", + "S2.lsl.r.p.nac" => "__builtin_HEXAGON_S2_lsl_r_p_nac", + "S2.lsl.r.p.or" => "__builtin_HEXAGON_S2_lsl_r_p_or", + "S2.lsl.r.p.xor" => "__builtin_HEXAGON_S2_lsl_r_p_xor", + "S2.lsl.r.r" => "__builtin_HEXAGON_S2_lsl_r_r", + "S2.lsl.r.r.acc" => "__builtin_HEXAGON_S2_lsl_r_r_acc", + "S2.lsl.r.r.and" => "__builtin_HEXAGON_S2_lsl_r_r_and", + "S2.lsl.r.r.nac" => "__builtin_HEXAGON_S2_lsl_r_r_nac", + "S2.lsl.r.r.or" => "__builtin_HEXAGON_S2_lsl_r_r_or", + "S2.lsl.r.vh" => "__builtin_HEXAGON_S2_lsl_r_vh", + "S2.lsl.r.vw" => "__builtin_HEXAGON_S2_lsl_r_vw", + "S2.lsr.i.p" => "__builtin_HEXAGON_S2_lsr_i_p", + "S2.lsr.i.p.acc" => "__builtin_HEXAGON_S2_lsr_i_p_acc", + "S2.lsr.i.p.and" => "__builtin_HEXAGON_S2_lsr_i_p_and", + "S2.lsr.i.p.nac" => "__builtin_HEXAGON_S2_lsr_i_p_nac", + "S2.lsr.i.p.or" => "__builtin_HEXAGON_S2_lsr_i_p_or", + "S2.lsr.i.p.xacc" => "__builtin_HEXAGON_S2_lsr_i_p_xacc", + "S2.lsr.i.r" => "__builtin_HEXAGON_S2_lsr_i_r", + "S2.lsr.i.r.acc" => "__builtin_HEXAGON_S2_lsr_i_r_acc", + "S2.lsr.i.r.and" => "__builtin_HEXAGON_S2_lsr_i_r_and", + "S2.lsr.i.r.nac" => "__builtin_HEXAGON_S2_lsr_i_r_nac", + "S2.lsr.i.r.or" => "__builtin_HEXAGON_S2_lsr_i_r_or", + "S2.lsr.i.r.xacc" => "__builtin_HEXAGON_S2_lsr_i_r_xacc", + "S2.lsr.i.vh" => "__builtin_HEXAGON_S2_lsr_i_vh", + "S2.lsr.i.vw" => "__builtin_HEXAGON_S2_lsr_i_vw", + "S2.lsr.r.p" => "__builtin_HEXAGON_S2_lsr_r_p", + "S2.lsr.r.p.acc" => "__builtin_HEXAGON_S2_lsr_r_p_acc", + "S2.lsr.r.p.and" => "__builtin_HEXAGON_S2_lsr_r_p_and", + "S2.lsr.r.p.nac" => "__builtin_HEXAGON_S2_lsr_r_p_nac", + "S2.lsr.r.p.or" => "__builtin_HEXAGON_S2_lsr_r_p_or", + "S2.lsr.r.p.xor" => "__builtin_HEXAGON_S2_lsr_r_p_xor", + "S2.lsr.r.r" => "__builtin_HEXAGON_S2_lsr_r_r", + "S2.lsr.r.r.acc" => "__builtin_HEXAGON_S2_lsr_r_r_acc", + "S2.lsr.r.r.and" => "__builtin_HEXAGON_S2_lsr_r_r_and", + "S2.lsr.r.r.nac" => "__builtin_HEXAGON_S2_lsr_r_r_nac", + "S2.lsr.r.r.or" => "__builtin_HEXAGON_S2_lsr_r_r_or", + "S2.lsr.r.vh" => "__builtin_HEXAGON_S2_lsr_r_vh", + "S2.lsr.r.vw" => "__builtin_HEXAGON_S2_lsr_r_vw", + "S2.mask" => "__builtin_HEXAGON_S2_mask", + "S2.packhl" => "__builtin_HEXAGON_S2_packhl", + "S2.parityp" => "__builtin_HEXAGON_S2_parityp", + "S2.setbit.i" => "__builtin_HEXAGON_S2_setbit_i", + "S2.setbit.r" => "__builtin_HEXAGON_S2_setbit_r", + "S2.shuffeb" => "__builtin_HEXAGON_S2_shuffeb", + "S2.shuffeh" => "__builtin_HEXAGON_S2_shuffeh", + "S2.shuffob" => "__builtin_HEXAGON_S2_shuffob", + "S2.shuffoh" => "__builtin_HEXAGON_S2_shuffoh", + "S2.storerb.pbr" => "__builtin_brev_stb", + "S2.storerd.pbr" => "__builtin_brev_std", + "S2.storerf.pbr" => "__builtin_brev_sthhi", + "S2.storerh.pbr" => "__builtin_brev_sth", + "S2.storeri.pbr" => "__builtin_brev_stw", + "S2.storew.locked" => "__builtin_HEXAGON_S2_storew_locked", + "S2.svsathb" => "__builtin_HEXAGON_S2_svsathb", + "S2.svsathub" => "__builtin_HEXAGON_S2_svsathub", + "S2.tableidxb.goodsyntax" => "__builtin_HEXAGON_S2_tableidxb_goodsyntax", + "S2.tableidxd.goodsyntax" => "__builtin_HEXAGON_S2_tableidxd_goodsyntax", + "S2.tableidxh.goodsyntax" => "__builtin_HEXAGON_S2_tableidxh_goodsyntax", + "S2.tableidxw.goodsyntax" => "__builtin_HEXAGON_S2_tableidxw_goodsyntax", + "S2.togglebit.i" => "__builtin_HEXAGON_S2_togglebit_i", + "S2.togglebit.r" => "__builtin_HEXAGON_S2_togglebit_r", + "S2.tstbit.i" => "__builtin_HEXAGON_S2_tstbit_i", + "S2.tstbit.r" => "__builtin_HEXAGON_S2_tstbit_r", + "S2.valignib" => "__builtin_HEXAGON_S2_valignib", + "S2.valignrb" => "__builtin_HEXAGON_S2_valignrb", + "S2.vcnegh" => "__builtin_HEXAGON_S2_vcnegh", + "S2.vcrotate" => "__builtin_HEXAGON_S2_vcrotate", + "S2.vrcnegh" => "__builtin_HEXAGON_S2_vrcnegh", + "S2.vrndpackwh" => "__builtin_HEXAGON_S2_vrndpackwh", + "S2.vrndpackwhs" => "__builtin_HEXAGON_S2_vrndpackwhs", + "S2.vsathb" => "__builtin_HEXAGON_S2_vsathb", + "S2.vsathb.nopack" => "__builtin_HEXAGON_S2_vsathb_nopack", + "S2.vsathub" => "__builtin_HEXAGON_S2_vsathub", + "S2.vsathub.nopack" => "__builtin_HEXAGON_S2_vsathub_nopack", + "S2.vsatwh" => "__builtin_HEXAGON_S2_vsatwh", + "S2.vsatwh.nopack" => "__builtin_HEXAGON_S2_vsatwh_nopack", + "S2.vsatwuh" => "__builtin_HEXAGON_S2_vsatwuh", + "S2.vsatwuh.nopack" => "__builtin_HEXAGON_S2_vsatwuh_nopack", + "S2.vsplatrb" => "__builtin_HEXAGON_S2_vsplatrb", + "S2.vsplatrh" => "__builtin_HEXAGON_S2_vsplatrh", + "S2.vspliceib" => "__builtin_HEXAGON_S2_vspliceib", + "S2.vsplicerb" => "__builtin_HEXAGON_S2_vsplicerb", + "S2.vsxtbh" => "__builtin_HEXAGON_S2_vsxtbh", + "S2.vsxthw" => "__builtin_HEXAGON_S2_vsxthw", + "S2.vtrunehb" => "__builtin_HEXAGON_S2_vtrunehb", + "S2.vtrunewh" => "__builtin_HEXAGON_S2_vtrunewh", + "S2.vtrunohb" => "__builtin_HEXAGON_S2_vtrunohb", + "S2.vtrunowh" => "__builtin_HEXAGON_S2_vtrunowh", + "S2.vzxtbh" => "__builtin_HEXAGON_S2_vzxtbh", + "S2.vzxthw" => "__builtin_HEXAGON_S2_vzxthw", + "S4.addaddi" => "__builtin_HEXAGON_S4_addaddi", + "S4.addi.asl.ri" => "__builtin_HEXAGON_S4_addi_asl_ri", + "S4.addi.lsr.ri" => "__builtin_HEXAGON_S4_addi_lsr_ri", + "S4.andi.asl.ri" => "__builtin_HEXAGON_S4_andi_asl_ri", + "S4.andi.lsr.ri" => "__builtin_HEXAGON_S4_andi_lsr_ri", + "S4.clbaddi" => "__builtin_HEXAGON_S4_clbaddi", + "S4.clbpaddi" => "__builtin_HEXAGON_S4_clbpaddi", + "S4.clbpnorm" => "__builtin_HEXAGON_S4_clbpnorm", + "S4.extract" => "__builtin_HEXAGON_S4_extract", + "S4.extract.rp" => "__builtin_HEXAGON_S4_extract_rp", + "S4.extractp" => "__builtin_HEXAGON_S4_extractp", + "S4.extractp.rp" => "__builtin_HEXAGON_S4_extractp_rp", + "S4.lsli" => "__builtin_HEXAGON_S4_lsli", + "S4.ntstbit.i" => "__builtin_HEXAGON_S4_ntstbit_i", + "S4.ntstbit.r" => "__builtin_HEXAGON_S4_ntstbit_r", + "S4.or.andi" => "__builtin_HEXAGON_S4_or_andi", + "S4.or.andix" => "__builtin_HEXAGON_S4_or_andix", + "S4.or.ori" => "__builtin_HEXAGON_S4_or_ori", + "S4.ori.asl.ri" => "__builtin_HEXAGON_S4_ori_asl_ri", + "S4.ori.lsr.ri" => "__builtin_HEXAGON_S4_ori_lsr_ri", + "S4.parity" => "__builtin_HEXAGON_S4_parity", + "S4.stored.locked" => "__builtin_HEXAGON_S4_stored_locked", + "S4.subaddi" => "__builtin_HEXAGON_S4_subaddi", + "S4.subi.asl.ri" => "__builtin_HEXAGON_S4_subi_asl_ri", + "S4.subi.lsr.ri" => "__builtin_HEXAGON_S4_subi_lsr_ri", + "S4.vrcrotate" => "__builtin_HEXAGON_S4_vrcrotate", + "S4.vrcrotate.acc" => "__builtin_HEXAGON_S4_vrcrotate_acc", + "S4.vxaddsubh" => "__builtin_HEXAGON_S4_vxaddsubh", + "S4.vxaddsubhr" => "__builtin_HEXAGON_S4_vxaddsubhr", + "S4.vxaddsubw" => "__builtin_HEXAGON_S4_vxaddsubw", + "S4.vxsubaddh" => "__builtin_HEXAGON_S4_vxsubaddh", + "S4.vxsubaddhr" => "__builtin_HEXAGON_S4_vxsubaddhr", + "S4.vxsubaddw" => "__builtin_HEXAGON_S4_vxsubaddw", + "S5.asrhub.rnd.sat.goodsyntax" => { + "__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax" + } + "S5.asrhub.sat" => "__builtin_HEXAGON_S5_asrhub_sat", + "S5.popcountp" => "__builtin_HEXAGON_S5_popcountp", + "S5.vasrhrnd.goodsyntax" => "__builtin_HEXAGON_S5_vasrhrnd_goodsyntax", + "S6.rol.i.p" => "__builtin_HEXAGON_S6_rol_i_p", + "S6.rol.i.p.acc" => "__builtin_HEXAGON_S6_rol_i_p_acc", + "S6.rol.i.p.and" => "__builtin_HEXAGON_S6_rol_i_p_and", + "S6.rol.i.p.nac" => "__builtin_HEXAGON_S6_rol_i_p_nac", + "S6.rol.i.p.or" => "__builtin_HEXAGON_S6_rol_i_p_or", + "S6.rol.i.p.xacc" => "__builtin_HEXAGON_S6_rol_i_p_xacc", + "S6.rol.i.r" => "__builtin_HEXAGON_S6_rol_i_r", + "S6.rol.i.r.acc" => "__builtin_HEXAGON_S6_rol_i_r_acc", + "S6.rol.i.r.and" => "__builtin_HEXAGON_S6_rol_i_r_and", + "S6.rol.i.r.nac" => "__builtin_HEXAGON_S6_rol_i_r_nac", + "S6.rol.i.r.or" => "__builtin_HEXAGON_S6_rol_i_r_or", + "S6.rol.i.r.xacc" => "__builtin_HEXAGON_S6_rol_i_r_xacc", + "S6.vsplatrbp" => "__builtin_HEXAGON_S6_vsplatrbp", + "S6.vtrunehb.ppp" => "__builtin_HEXAGON_S6_vtrunehb_ppp", + "S6.vtrunohb.ppp" => "__builtin_HEXAGON_S6_vtrunohb_ppp", + "SI.to.SXTHI.asrh" => "__builtin_SI_to_SXTHI_asrh", + "V6.extractw" => "__builtin_HEXAGON_V6_extractw", + "V6.extractw.128B" => "__builtin_HEXAGON_V6_extractw_128B", + "V6.get.qfext" => "__builtin_HEXAGON_V6_get_qfext", + "V6.get.qfext.128B" => "__builtin_HEXAGON_V6_get_qfext_128B", + "V6.get.qfext.oracc" => "__builtin_HEXAGON_V6_get_qfext_oracc", + "V6.get.qfext.oracc.128B" => "__builtin_HEXAGON_V6_get_qfext_oracc_128B", + "V6.hi" => "__builtin_HEXAGON_V6_hi", + "V6.hi.128B" => "__builtin_HEXAGON_V6_hi_128B", + "V6.lo" => "__builtin_HEXAGON_V6_lo", + "V6.lo.128B" => "__builtin_HEXAGON_V6_lo_128B", + "V6.lvsplatb" => "__builtin_HEXAGON_V6_lvsplatb", + "V6.lvsplatb.128B" => "__builtin_HEXAGON_V6_lvsplatb_128B", + "V6.lvsplath" => "__builtin_HEXAGON_V6_lvsplath", + "V6.lvsplath.128B" => "__builtin_HEXAGON_V6_lvsplath_128B", + "V6.lvsplatw" => "__builtin_HEXAGON_V6_lvsplatw", + "V6.lvsplatw.128B" => "__builtin_HEXAGON_V6_lvsplatw_128B", + "V6.pred.and" => "__builtin_HEXAGON_V6_pred_and", + "V6.pred.and.128B" => "__builtin_HEXAGON_V6_pred_and_128B", + "V6.pred.and.n" => "__builtin_HEXAGON_V6_pred_and_n", + "V6.pred.and.n.128B" => "__builtin_HEXAGON_V6_pred_and_n_128B", + "V6.pred.not" => "__builtin_HEXAGON_V6_pred_not", + "V6.pred.not.128B" => "__builtin_HEXAGON_V6_pred_not_128B", + "V6.pred.or" => "__builtin_HEXAGON_V6_pred_or", + "V6.pred.or.128B" => "__builtin_HEXAGON_V6_pred_or_128B", + "V6.pred.or.n" => "__builtin_HEXAGON_V6_pred_or_n", + "V6.pred.or.n.128B" => "__builtin_HEXAGON_V6_pred_or_n_128B", + "V6.pred.scalar2" => "__builtin_HEXAGON_V6_pred_scalar2", + "V6.pred.scalar2.128B" => "__builtin_HEXAGON_V6_pred_scalar2_128B", + "V6.pred.scalar2v2" => "__builtin_HEXAGON_V6_pred_scalar2v2", + "V6.pred.scalar2v2.128B" => "__builtin_HEXAGON_V6_pred_scalar2v2_128B", + "V6.pred.xor" => "__builtin_HEXAGON_V6_pred_xor", + "V6.pred.xor.128B" => "__builtin_HEXAGON_V6_pred_xor_128B", + "V6.set.qfext" => "__builtin_HEXAGON_V6_set_qfext", + "V6.set.qfext.128B" => "__builtin_HEXAGON_V6_set_qfext_128B", + "V6.shuffeqh" => "__builtin_HEXAGON_V6_shuffeqh", + "V6.shuffeqh.128B" => "__builtin_HEXAGON_V6_shuffeqh_128B", + "V6.shuffeqw" => "__builtin_HEXAGON_V6_shuffeqw", + "V6.shuffeqw.128B" => "__builtin_HEXAGON_V6_shuffeqw_128B", + "V6.v6mpyhubs10" => "__builtin_HEXAGON_V6_v6mpyhubs10", + "V6.v6mpyhubs10.128B" => "__builtin_HEXAGON_V6_v6mpyhubs10_128B", + "V6.v6mpyhubs10.vxx" => "__builtin_HEXAGON_V6_v6mpyhubs10_vxx", + "V6.v6mpyhubs10.vxx.128B" => "__builtin_HEXAGON_V6_v6mpyhubs10_vxx_128B", + "V6.v6mpyvubs10" => "__builtin_HEXAGON_V6_v6mpyvubs10", + "V6.v6mpyvubs10.128B" => "__builtin_HEXAGON_V6_v6mpyvubs10_128B", + "V6.v6mpyvubs10.vxx" => "__builtin_HEXAGON_V6_v6mpyvubs10_vxx", + "V6.v6mpyvubs10.vxx.128B" => "__builtin_HEXAGON_V6_v6mpyvubs10_vxx_128B", + "V6.vS32b.nqpred.ai" => "__builtin_HEXAGON_V6_vS32b_nqpred_ai", + "V6.vS32b.nqpred.ai.128B" => "__builtin_HEXAGON_V6_vS32b_nqpred_ai_128B", + "V6.vS32b.nt.nqpred.ai" => "__builtin_HEXAGON_V6_vS32b_nt_nqpred_ai", + "V6.vS32b.nt.nqpred.ai.128B" => "__builtin_HEXAGON_V6_vS32b_nt_nqpred_ai_128B", + "V6.vS32b.nt.qpred.ai" => "__builtin_HEXAGON_V6_vS32b_nt_qpred_ai", + "V6.vS32b.nt.qpred.ai.128B" => "__builtin_HEXAGON_V6_vS32b_nt_qpred_ai_128B", + "V6.vS32b.qpred.ai" => "__builtin_HEXAGON_V6_vS32b_qpred_ai", + "V6.vS32b.qpred.ai.128B" => "__builtin_HEXAGON_V6_vS32b_qpred_ai_128B", + "V6.vabs.f8" => "__builtin_HEXAGON_V6_vabs_f8", + "V6.vabs.f8.128B" => "__builtin_HEXAGON_V6_vabs_f8_128B", + "V6.vabs.hf" => "__builtin_HEXAGON_V6_vabs_hf", + "V6.vabs.hf.128B" => "__builtin_HEXAGON_V6_vabs_hf_128B", + "V6.vabs.sf" => "__builtin_HEXAGON_V6_vabs_sf", + "V6.vabs.sf.128B" => "__builtin_HEXAGON_V6_vabs_sf_128B", + "V6.vabsb" => "__builtin_HEXAGON_V6_vabsb", + "V6.vabsb.128B" => "__builtin_HEXAGON_V6_vabsb_128B", + "V6.vabsb.sat" => "__builtin_HEXAGON_V6_vabsb_sat", + "V6.vabsb.sat.128B" => "__builtin_HEXAGON_V6_vabsb_sat_128B", + "V6.vabsdiffh" => "__builtin_HEXAGON_V6_vabsdiffh", + "V6.vabsdiffh.128B" => "__builtin_HEXAGON_V6_vabsdiffh_128B", + "V6.vabsdiffub" => "__builtin_HEXAGON_V6_vabsdiffub", + "V6.vabsdiffub.128B" => "__builtin_HEXAGON_V6_vabsdiffub_128B", + "V6.vabsdiffuh" => "__builtin_HEXAGON_V6_vabsdiffuh", + "V6.vabsdiffuh.128B" => "__builtin_HEXAGON_V6_vabsdiffuh_128B", + "V6.vabsdiffw" => "__builtin_HEXAGON_V6_vabsdiffw", + "V6.vabsdiffw.128B" => "__builtin_HEXAGON_V6_vabsdiffw_128B", + "V6.vabsh" => "__builtin_HEXAGON_V6_vabsh", + "V6.vabsh.128B" => "__builtin_HEXAGON_V6_vabsh_128B", + "V6.vabsh.sat" => "__builtin_HEXAGON_V6_vabsh_sat", + "V6.vabsh.sat.128B" => "__builtin_HEXAGON_V6_vabsh_sat_128B", + "V6.vabsw" => "__builtin_HEXAGON_V6_vabsw", + "V6.vabsw.128B" => "__builtin_HEXAGON_V6_vabsw_128B", + "V6.vabsw.sat" => "__builtin_HEXAGON_V6_vabsw_sat", + "V6.vabsw.sat.128B" => "__builtin_HEXAGON_V6_vabsw_sat_128B", + "V6.vadd.hf" => "__builtin_HEXAGON_V6_vadd_hf", + "V6.vadd.hf.128B" => "__builtin_HEXAGON_V6_vadd_hf_128B", + "V6.vadd.hf.f8" => "__builtin_HEXAGON_V6_vadd_hf_f8", + "V6.vadd.hf.f8.128B" => "__builtin_HEXAGON_V6_vadd_hf_f8_128B", + "V6.vadd.hf.hf" => "__builtin_HEXAGON_V6_vadd_hf_hf", + "V6.vadd.hf.hf.128B" => "__builtin_HEXAGON_V6_vadd_hf_hf_128B", + "V6.vadd.qf16" => "__builtin_HEXAGON_V6_vadd_qf16", + "V6.vadd.qf16.128B" => "__builtin_HEXAGON_V6_vadd_qf16_128B", + "V6.vadd.qf16.mix" => "__builtin_HEXAGON_V6_vadd_qf16_mix", + "V6.vadd.qf16.mix.128B" => "__builtin_HEXAGON_V6_vadd_qf16_mix_128B", + "V6.vadd.qf32" => "__builtin_HEXAGON_V6_vadd_qf32", + "V6.vadd.qf32.128B" => "__builtin_HEXAGON_V6_vadd_qf32_128B", + "V6.vadd.qf32.mix" => "__builtin_HEXAGON_V6_vadd_qf32_mix", + "V6.vadd.qf32.mix.128B" => "__builtin_HEXAGON_V6_vadd_qf32_mix_128B", + "V6.vadd.sf" => "__builtin_HEXAGON_V6_vadd_sf", + "V6.vadd.sf.128B" => "__builtin_HEXAGON_V6_vadd_sf_128B", + "V6.vadd.sf.bf" => "__builtin_HEXAGON_V6_vadd_sf_bf", + "V6.vadd.sf.bf.128B" => "__builtin_HEXAGON_V6_vadd_sf_bf_128B", + "V6.vadd.sf.hf" => "__builtin_HEXAGON_V6_vadd_sf_hf", + "V6.vadd.sf.hf.128B" => "__builtin_HEXAGON_V6_vadd_sf_hf_128B", + "V6.vadd.sf.sf" => "__builtin_HEXAGON_V6_vadd_sf_sf", + "V6.vadd.sf.sf.128B" => "__builtin_HEXAGON_V6_vadd_sf_sf_128B", + "V6.vaddb" => "__builtin_HEXAGON_V6_vaddb", + "V6.vaddb.128B" => "__builtin_HEXAGON_V6_vaddb_128B", + "V6.vaddb.dv" => "__builtin_HEXAGON_V6_vaddb_dv", + "V6.vaddb.dv.128B" => "__builtin_HEXAGON_V6_vaddb_dv_128B", + "V6.vaddbnq" => "__builtin_HEXAGON_V6_vaddbnq", + "V6.vaddbnq.128B" => "__builtin_HEXAGON_V6_vaddbnq_128B", + "V6.vaddbq" => "__builtin_HEXAGON_V6_vaddbq", + "V6.vaddbq.128B" => "__builtin_HEXAGON_V6_vaddbq_128B", + "V6.vaddbsat" => "__builtin_HEXAGON_V6_vaddbsat", + "V6.vaddbsat.128B" => "__builtin_HEXAGON_V6_vaddbsat_128B", + "V6.vaddbsat.dv" => "__builtin_HEXAGON_V6_vaddbsat_dv", + "V6.vaddbsat.dv.128B" => "__builtin_HEXAGON_V6_vaddbsat_dv_128B", + "V6.vaddcarrysat" => "__builtin_HEXAGON_V6_vaddcarrysat", + "V6.vaddcarrysat.128B" => "__builtin_HEXAGON_V6_vaddcarrysat_128B", + "V6.vaddclbh" => "__builtin_HEXAGON_V6_vaddclbh", + "V6.vaddclbh.128B" => "__builtin_HEXAGON_V6_vaddclbh_128B", + "V6.vaddclbw" => "__builtin_HEXAGON_V6_vaddclbw", + "V6.vaddclbw.128B" => "__builtin_HEXAGON_V6_vaddclbw_128B", + "V6.vaddh" => "__builtin_HEXAGON_V6_vaddh", + "V6.vaddh.128B" => "__builtin_HEXAGON_V6_vaddh_128B", + "V6.vaddh.dv" => "__builtin_HEXAGON_V6_vaddh_dv", + "V6.vaddh.dv.128B" => "__builtin_HEXAGON_V6_vaddh_dv_128B", + "V6.vaddhnq" => "__builtin_HEXAGON_V6_vaddhnq", + "V6.vaddhnq.128B" => "__builtin_HEXAGON_V6_vaddhnq_128B", + "V6.vaddhq" => "__builtin_HEXAGON_V6_vaddhq", + "V6.vaddhq.128B" => "__builtin_HEXAGON_V6_vaddhq_128B", + "V6.vaddhsat" => "__builtin_HEXAGON_V6_vaddhsat", + "V6.vaddhsat.128B" => "__builtin_HEXAGON_V6_vaddhsat_128B", + "V6.vaddhsat.dv" => "__builtin_HEXAGON_V6_vaddhsat_dv", + "V6.vaddhsat.dv.128B" => "__builtin_HEXAGON_V6_vaddhsat_dv_128B", + "V6.vaddhw" => "__builtin_HEXAGON_V6_vaddhw", + "V6.vaddhw.128B" => "__builtin_HEXAGON_V6_vaddhw_128B", + "V6.vaddhw.acc" => "__builtin_HEXAGON_V6_vaddhw_acc", + "V6.vaddhw.acc.128B" => "__builtin_HEXAGON_V6_vaddhw_acc_128B", + "V6.vaddubh" => "__builtin_HEXAGON_V6_vaddubh", + "V6.vaddubh.128B" => "__builtin_HEXAGON_V6_vaddubh_128B", + "V6.vaddubh.acc" => "__builtin_HEXAGON_V6_vaddubh_acc", + "V6.vaddubh.acc.128B" => "__builtin_HEXAGON_V6_vaddubh_acc_128B", + "V6.vaddubsat" => "__builtin_HEXAGON_V6_vaddubsat", + "V6.vaddubsat.128B" => "__builtin_HEXAGON_V6_vaddubsat_128B", + "V6.vaddubsat.dv" => "__builtin_HEXAGON_V6_vaddubsat_dv", + "V6.vaddubsat.dv.128B" => "__builtin_HEXAGON_V6_vaddubsat_dv_128B", + "V6.vaddububb.sat" => "__builtin_HEXAGON_V6_vaddububb_sat", + "V6.vaddububb.sat.128B" => "__builtin_HEXAGON_V6_vaddububb_sat_128B", + "V6.vadduhsat" => "__builtin_HEXAGON_V6_vadduhsat", + "V6.vadduhsat.128B" => "__builtin_HEXAGON_V6_vadduhsat_128B", + "V6.vadduhsat.dv" => "__builtin_HEXAGON_V6_vadduhsat_dv", + "V6.vadduhsat.dv.128B" => "__builtin_HEXAGON_V6_vadduhsat_dv_128B", + "V6.vadduhw" => "__builtin_HEXAGON_V6_vadduhw", + "V6.vadduhw.128B" => "__builtin_HEXAGON_V6_vadduhw_128B", + "V6.vadduhw.acc" => "__builtin_HEXAGON_V6_vadduhw_acc", + "V6.vadduhw.acc.128B" => "__builtin_HEXAGON_V6_vadduhw_acc_128B", + "V6.vadduwsat" => "__builtin_HEXAGON_V6_vadduwsat", + "V6.vadduwsat.128B" => "__builtin_HEXAGON_V6_vadduwsat_128B", + "V6.vadduwsat.dv" => "__builtin_HEXAGON_V6_vadduwsat_dv", + "V6.vadduwsat.dv.128B" => "__builtin_HEXAGON_V6_vadduwsat_dv_128B", + "V6.vaddw" => "__builtin_HEXAGON_V6_vaddw", + "V6.vaddw.128B" => "__builtin_HEXAGON_V6_vaddw_128B", + "V6.vaddw.dv" => "__builtin_HEXAGON_V6_vaddw_dv", + "V6.vaddw.dv.128B" => "__builtin_HEXAGON_V6_vaddw_dv_128B", + "V6.vaddwnq" => "__builtin_HEXAGON_V6_vaddwnq", + "V6.vaddwnq.128B" => "__builtin_HEXAGON_V6_vaddwnq_128B", + "V6.vaddwq" => "__builtin_HEXAGON_V6_vaddwq", + "V6.vaddwq.128B" => "__builtin_HEXAGON_V6_vaddwq_128B", + "V6.vaddwsat" => "__builtin_HEXAGON_V6_vaddwsat", + "V6.vaddwsat.128B" => "__builtin_HEXAGON_V6_vaddwsat_128B", + "V6.vaddwsat.dv" => "__builtin_HEXAGON_V6_vaddwsat_dv", + "V6.vaddwsat.dv.128B" => "__builtin_HEXAGON_V6_vaddwsat_dv_128B", + "V6.valignb" => "__builtin_HEXAGON_V6_valignb", + "V6.valignb.128B" => "__builtin_HEXAGON_V6_valignb_128B", + "V6.valignbi" => "__builtin_HEXAGON_V6_valignbi", + "V6.valignbi.128B" => "__builtin_HEXAGON_V6_valignbi_128B", + "V6.vand" => "__builtin_HEXAGON_V6_vand", + "V6.vand.128B" => "__builtin_HEXAGON_V6_vand_128B", + "V6.vandnqrt" => "__builtin_HEXAGON_V6_vandnqrt", + "V6.vandnqrt.128B" => "__builtin_HEXAGON_V6_vandnqrt_128B", + "V6.vandnqrt.acc" => "__builtin_HEXAGON_V6_vandnqrt_acc", + "V6.vandnqrt.acc.128B" => "__builtin_HEXAGON_V6_vandnqrt_acc_128B", + "V6.vandqrt" => "__builtin_HEXAGON_V6_vandqrt", + "V6.vandqrt.128B" => "__builtin_HEXAGON_V6_vandqrt_128B", + "V6.vandqrt.acc" => "__builtin_HEXAGON_V6_vandqrt_acc", + "V6.vandqrt.acc.128B" => "__builtin_HEXAGON_V6_vandqrt_acc_128B", + "V6.vandvnqv" => "__builtin_HEXAGON_V6_vandvnqv", + "V6.vandvnqv.128B" => "__builtin_HEXAGON_V6_vandvnqv_128B", + "V6.vandvqv" => "__builtin_HEXAGON_V6_vandvqv", + "V6.vandvqv.128B" => "__builtin_HEXAGON_V6_vandvqv_128B", + "V6.vandvrt" => "__builtin_HEXAGON_V6_vandvrt", + "V6.vandvrt.128B" => "__builtin_HEXAGON_V6_vandvrt_128B", + "V6.vandvrt.acc" => "__builtin_HEXAGON_V6_vandvrt_acc", + "V6.vandvrt.acc.128B" => "__builtin_HEXAGON_V6_vandvrt_acc_128B", + "V6.vaslh" => "__builtin_HEXAGON_V6_vaslh", + "V6.vaslh.128B" => "__builtin_HEXAGON_V6_vaslh_128B", + "V6.vaslh.acc" => "__builtin_HEXAGON_V6_vaslh_acc", + "V6.vaslh.acc.128B" => "__builtin_HEXAGON_V6_vaslh_acc_128B", + "V6.vaslhv" => "__builtin_HEXAGON_V6_vaslhv", + "V6.vaslhv.128B" => "__builtin_HEXAGON_V6_vaslhv_128B", + "V6.vaslw" => "__builtin_HEXAGON_V6_vaslw", + "V6.vaslw.128B" => "__builtin_HEXAGON_V6_vaslw_128B", + "V6.vaslw.acc" => "__builtin_HEXAGON_V6_vaslw_acc", + "V6.vaslw.acc.128B" => "__builtin_HEXAGON_V6_vaslw_acc_128B", + "V6.vaslwv" => "__builtin_HEXAGON_V6_vaslwv", + "V6.vaslwv.128B" => "__builtin_HEXAGON_V6_vaslwv_128B", + "V6.vasr.into" => "__builtin_HEXAGON_V6_vasr_into", + "V6.vasr.into.128B" => "__builtin_HEXAGON_V6_vasr_into_128B", + "V6.vasrh" => "__builtin_HEXAGON_V6_vasrh", + "V6.vasrh.128B" => "__builtin_HEXAGON_V6_vasrh_128B", + "V6.vasrh.acc" => "__builtin_HEXAGON_V6_vasrh_acc", + "V6.vasrh.acc.128B" => "__builtin_HEXAGON_V6_vasrh_acc_128B", + "V6.vasrhbrndsat" => "__builtin_HEXAGON_V6_vasrhbrndsat", + "V6.vasrhbrndsat.128B" => "__builtin_HEXAGON_V6_vasrhbrndsat_128B", + "V6.vasrhbsat" => "__builtin_HEXAGON_V6_vasrhbsat", + "V6.vasrhbsat.128B" => "__builtin_HEXAGON_V6_vasrhbsat_128B", + "V6.vasrhubrndsat" => "__builtin_HEXAGON_V6_vasrhubrndsat", + "V6.vasrhubrndsat.128B" => "__builtin_HEXAGON_V6_vasrhubrndsat_128B", + "V6.vasrhubsat" => "__builtin_HEXAGON_V6_vasrhubsat", + "V6.vasrhubsat.128B" => "__builtin_HEXAGON_V6_vasrhubsat_128B", + "V6.vasrhv" => "__builtin_HEXAGON_V6_vasrhv", + "V6.vasrhv.128B" => "__builtin_HEXAGON_V6_vasrhv_128B", + "V6.vasruhubrndsat" => "__builtin_HEXAGON_V6_vasruhubrndsat", + "V6.vasruhubrndsat.128B" => "__builtin_HEXAGON_V6_vasruhubrndsat_128B", + "V6.vasruhubsat" => "__builtin_HEXAGON_V6_vasruhubsat", + "V6.vasruhubsat.128B" => "__builtin_HEXAGON_V6_vasruhubsat_128B", + "V6.vasruwuhrndsat" => "__builtin_HEXAGON_V6_vasruwuhrndsat", + "V6.vasruwuhrndsat.128B" => "__builtin_HEXAGON_V6_vasruwuhrndsat_128B", + "V6.vasruwuhsat" => "__builtin_HEXAGON_V6_vasruwuhsat", + "V6.vasruwuhsat.128B" => "__builtin_HEXAGON_V6_vasruwuhsat_128B", + "V6.vasrvuhubrndsat" => "__builtin_HEXAGON_V6_vasrvuhubrndsat", + "V6.vasrvuhubrndsat.128B" => "__builtin_HEXAGON_V6_vasrvuhubrndsat_128B", + "V6.vasrvuhubsat" => "__builtin_HEXAGON_V6_vasrvuhubsat", + "V6.vasrvuhubsat.128B" => "__builtin_HEXAGON_V6_vasrvuhubsat_128B", + "V6.vasrvwuhrndsat" => "__builtin_HEXAGON_V6_vasrvwuhrndsat", + "V6.vasrvwuhrndsat.128B" => "__builtin_HEXAGON_V6_vasrvwuhrndsat_128B", + "V6.vasrvwuhsat" => "__builtin_HEXAGON_V6_vasrvwuhsat", + "V6.vasrvwuhsat.128B" => "__builtin_HEXAGON_V6_vasrvwuhsat_128B", + "V6.vasrw" => "__builtin_HEXAGON_V6_vasrw", + "V6.vasrw.128B" => "__builtin_HEXAGON_V6_vasrw_128B", + "V6.vasrw.acc" => "__builtin_HEXAGON_V6_vasrw_acc", + "V6.vasrw.acc.128B" => "__builtin_HEXAGON_V6_vasrw_acc_128B", + "V6.vasrwh" => "__builtin_HEXAGON_V6_vasrwh", + "V6.vasrwh.128B" => "__builtin_HEXAGON_V6_vasrwh_128B", + "V6.vasrwhrndsat" => "__builtin_HEXAGON_V6_vasrwhrndsat", + "V6.vasrwhrndsat.128B" => "__builtin_HEXAGON_V6_vasrwhrndsat_128B", + "V6.vasrwhsat" => "__builtin_HEXAGON_V6_vasrwhsat", + "V6.vasrwhsat.128B" => "__builtin_HEXAGON_V6_vasrwhsat_128B", + "V6.vasrwuhrndsat" => "__builtin_HEXAGON_V6_vasrwuhrndsat", + "V6.vasrwuhrndsat.128B" => "__builtin_HEXAGON_V6_vasrwuhrndsat_128B", + "V6.vasrwuhsat" => "__builtin_HEXAGON_V6_vasrwuhsat", + "V6.vasrwuhsat.128B" => "__builtin_HEXAGON_V6_vasrwuhsat_128B", + "V6.vasrwv" => "__builtin_HEXAGON_V6_vasrwv", + "V6.vasrwv.128B" => "__builtin_HEXAGON_V6_vasrwv_128B", + "V6.vassign" => "__builtin_HEXAGON_V6_vassign", + "V6.vassign.128B" => "__builtin_HEXAGON_V6_vassign_128B", + "V6.vassign.fp" => "__builtin_HEXAGON_V6_vassign_fp", + "V6.vassign.fp.128B" => "__builtin_HEXAGON_V6_vassign_fp_128B", + "V6.vassignp" => "__builtin_HEXAGON_V6_vassignp", + "V6.vassignp.128B" => "__builtin_HEXAGON_V6_vassignp_128B", + "V6.vavgb" => "__builtin_HEXAGON_V6_vavgb", + "V6.vavgb.128B" => "__builtin_HEXAGON_V6_vavgb_128B", + "V6.vavgbrnd" => "__builtin_HEXAGON_V6_vavgbrnd", + "V6.vavgbrnd.128B" => "__builtin_HEXAGON_V6_vavgbrnd_128B", + "V6.vavgh" => "__builtin_HEXAGON_V6_vavgh", + "V6.vavgh.128B" => "__builtin_HEXAGON_V6_vavgh_128B", + "V6.vavghrnd" => "__builtin_HEXAGON_V6_vavghrnd", + "V6.vavghrnd.128B" => "__builtin_HEXAGON_V6_vavghrnd_128B", + "V6.vavgub" => "__builtin_HEXAGON_V6_vavgub", + "V6.vavgub.128B" => "__builtin_HEXAGON_V6_vavgub_128B", + "V6.vavgubrnd" => "__builtin_HEXAGON_V6_vavgubrnd", + "V6.vavgubrnd.128B" => "__builtin_HEXAGON_V6_vavgubrnd_128B", + "V6.vavguh" => "__builtin_HEXAGON_V6_vavguh", + "V6.vavguh.128B" => "__builtin_HEXAGON_V6_vavguh_128B", + "V6.vavguhrnd" => "__builtin_HEXAGON_V6_vavguhrnd", + "V6.vavguhrnd.128B" => "__builtin_HEXAGON_V6_vavguhrnd_128B", + "V6.vavguw" => "__builtin_HEXAGON_V6_vavguw", + "V6.vavguw.128B" => "__builtin_HEXAGON_V6_vavguw_128B", + "V6.vavguwrnd" => "__builtin_HEXAGON_V6_vavguwrnd", + "V6.vavguwrnd.128B" => "__builtin_HEXAGON_V6_vavguwrnd_128B", + "V6.vavgw" => "__builtin_HEXAGON_V6_vavgw", + "V6.vavgw.128B" => "__builtin_HEXAGON_V6_vavgw_128B", + "V6.vavgwrnd" => "__builtin_HEXAGON_V6_vavgwrnd", + "V6.vavgwrnd.128B" => "__builtin_HEXAGON_V6_vavgwrnd_128B", + "V6.vcl0h" => "__builtin_HEXAGON_V6_vcl0h", + "V6.vcl0h.128B" => "__builtin_HEXAGON_V6_vcl0h_128B", + "V6.vcl0w" => "__builtin_HEXAGON_V6_vcl0w", + "V6.vcl0w.128B" => "__builtin_HEXAGON_V6_vcl0w_128B", + "V6.vcombine" => "__builtin_HEXAGON_V6_vcombine", + "V6.vcombine.128B" => "__builtin_HEXAGON_V6_vcombine_128B", + "V6.vconv.h.hf" => "__builtin_HEXAGON_V6_vconv_h_hf", + "V6.vconv.h.hf.128B" => "__builtin_HEXAGON_V6_vconv_h_hf_128B", + "V6.vconv.hf.h" => "__builtin_HEXAGON_V6_vconv_hf_h", + "V6.vconv.hf.h.128B" => "__builtin_HEXAGON_V6_vconv_hf_h_128B", + "V6.vconv.hf.qf16" => "__builtin_HEXAGON_V6_vconv_hf_qf16", + "V6.vconv.hf.qf16.128B" => "__builtin_HEXAGON_V6_vconv_hf_qf16_128B", + "V6.vconv.hf.qf32" => "__builtin_HEXAGON_V6_vconv_hf_qf32", + "V6.vconv.hf.qf32.128B" => "__builtin_HEXAGON_V6_vconv_hf_qf32_128B", + "V6.vconv.sf.qf32" => "__builtin_HEXAGON_V6_vconv_sf_qf32", + "V6.vconv.sf.qf32.128B" => "__builtin_HEXAGON_V6_vconv_sf_qf32_128B", + "V6.vconv.sf.w" => "__builtin_HEXAGON_V6_vconv_sf_w", + "V6.vconv.sf.w.128B" => "__builtin_HEXAGON_V6_vconv_sf_w_128B", + "V6.vconv.w.sf" => "__builtin_HEXAGON_V6_vconv_w_sf", + "V6.vconv.w.sf.128B" => "__builtin_HEXAGON_V6_vconv_w_sf_128B", + "V6.vcvt.b.hf" => "__builtin_HEXAGON_V6_vcvt_b_hf", + "V6.vcvt.b.hf.128B" => "__builtin_HEXAGON_V6_vcvt_b_hf_128B", + "V6.vcvt.bf.sf" => "__builtin_HEXAGON_V6_vcvt_bf_sf", + "V6.vcvt.bf.sf.128B" => "__builtin_HEXAGON_V6_vcvt_bf_sf_128B", + "V6.vcvt.f8.hf" => "__builtin_HEXAGON_V6_vcvt_f8_hf", + "V6.vcvt.f8.hf.128B" => "__builtin_HEXAGON_V6_vcvt_f8_hf_128B", + "V6.vcvt.h.hf" => "__builtin_HEXAGON_V6_vcvt_h_hf", + "V6.vcvt.h.hf.128B" => "__builtin_HEXAGON_V6_vcvt_h_hf_128B", + "V6.vcvt.hf.b" => "__builtin_HEXAGON_V6_vcvt_hf_b", + "V6.vcvt.hf.b.128B" => "__builtin_HEXAGON_V6_vcvt_hf_b_128B", + "V6.vcvt.hf.f8" => "__builtin_HEXAGON_V6_vcvt_hf_f8", + "V6.vcvt.hf.f8.128B" => "__builtin_HEXAGON_V6_vcvt_hf_f8_128B", + "V6.vcvt.hf.h" => "__builtin_HEXAGON_V6_vcvt_hf_h", + "V6.vcvt.hf.h.128B" => "__builtin_HEXAGON_V6_vcvt_hf_h_128B", + "V6.vcvt.hf.sf" => "__builtin_HEXAGON_V6_vcvt_hf_sf", + "V6.vcvt.hf.sf.128B" => "__builtin_HEXAGON_V6_vcvt_hf_sf_128B", + "V6.vcvt.hf.ub" => "__builtin_HEXAGON_V6_vcvt_hf_ub", + "V6.vcvt.hf.ub.128B" => "__builtin_HEXAGON_V6_vcvt_hf_ub_128B", + "V6.vcvt.hf.uh" => "__builtin_HEXAGON_V6_vcvt_hf_uh", + "V6.vcvt.hf.uh.128B" => "__builtin_HEXAGON_V6_vcvt_hf_uh_128B", + "V6.vcvt.sf.hf" => "__builtin_HEXAGON_V6_vcvt_sf_hf", + "V6.vcvt.sf.hf.128B" => "__builtin_HEXAGON_V6_vcvt_sf_hf_128B", + "V6.vcvt.ub.hf" => "__builtin_HEXAGON_V6_vcvt_ub_hf", + "V6.vcvt.ub.hf.128B" => "__builtin_HEXAGON_V6_vcvt_ub_hf_128B", + "V6.vcvt.uh.hf" => "__builtin_HEXAGON_V6_vcvt_uh_hf", + "V6.vcvt.uh.hf.128B" => "__builtin_HEXAGON_V6_vcvt_uh_hf_128B", + "V6.vcvt2.b.hf" => "__builtin_HEXAGON_V6_vcvt2_b_hf", + "V6.vcvt2.b.hf.128B" => "__builtin_HEXAGON_V6_vcvt2_b_hf_128B", + "V6.vcvt2.hf.b" => "__builtin_HEXAGON_V6_vcvt2_hf_b", + "V6.vcvt2.hf.b.128B" => "__builtin_HEXAGON_V6_vcvt2_hf_b_128B", + "V6.vcvt2.hf.ub" => "__builtin_HEXAGON_V6_vcvt2_hf_ub", + "V6.vcvt2.hf.ub.128B" => "__builtin_HEXAGON_V6_vcvt2_hf_ub_128B", + "V6.vcvt2.ub.hf" => "__builtin_HEXAGON_V6_vcvt2_ub_hf", + "V6.vcvt2.ub.hf.128B" => "__builtin_HEXAGON_V6_vcvt2_ub_hf_128B", + "V6.vd0" => "__builtin_HEXAGON_V6_vd0", + "V6.vd0.128B" => "__builtin_HEXAGON_V6_vd0_128B", + "V6.vdd0" => "__builtin_HEXAGON_V6_vdd0", + "V6.vdd0.128B" => "__builtin_HEXAGON_V6_vdd0_128B", + "V6.vdealb" => "__builtin_HEXAGON_V6_vdealb", + "V6.vdealb.128B" => "__builtin_HEXAGON_V6_vdealb_128B", + "V6.vdealb4w" => "__builtin_HEXAGON_V6_vdealb4w", + "V6.vdealb4w.128B" => "__builtin_HEXAGON_V6_vdealb4w_128B", + "V6.vdealh" => "__builtin_HEXAGON_V6_vdealh", + "V6.vdealh.128B" => "__builtin_HEXAGON_V6_vdealh_128B", + "V6.vdealvdd" => "__builtin_HEXAGON_V6_vdealvdd", + "V6.vdealvdd.128B" => "__builtin_HEXAGON_V6_vdealvdd_128B", + "V6.vdelta" => "__builtin_HEXAGON_V6_vdelta", + "V6.vdelta.128B" => "__builtin_HEXAGON_V6_vdelta_128B", + "V6.vdmpy.sf.hf" => "__builtin_HEXAGON_V6_vdmpy_sf_hf", + "V6.vdmpy.sf.hf.128B" => "__builtin_HEXAGON_V6_vdmpy_sf_hf_128B", + "V6.vdmpy.sf.hf.acc" => "__builtin_HEXAGON_V6_vdmpy_sf_hf_acc", + "V6.vdmpy.sf.hf.acc.128B" => "__builtin_HEXAGON_V6_vdmpy_sf_hf_acc_128B", + "V6.vdmpybus" => "__builtin_HEXAGON_V6_vdmpybus", + "V6.vdmpybus.128B" => "__builtin_HEXAGON_V6_vdmpybus_128B", + "V6.vdmpybus.acc" => "__builtin_HEXAGON_V6_vdmpybus_acc", + "V6.vdmpybus.acc.128B" => "__builtin_HEXAGON_V6_vdmpybus_acc_128B", + "V6.vdmpybus.dv" => "__builtin_HEXAGON_V6_vdmpybus_dv", + "V6.vdmpybus.dv.128B" => "__builtin_HEXAGON_V6_vdmpybus_dv_128B", + "V6.vdmpybus.dv.acc" => "__builtin_HEXAGON_V6_vdmpybus_dv_acc", + "V6.vdmpybus.dv.acc.128B" => "__builtin_HEXAGON_V6_vdmpybus_dv_acc_128B", + "V6.vdmpyhb" => "__builtin_HEXAGON_V6_vdmpyhb", + "V6.vdmpyhb.128B" => "__builtin_HEXAGON_V6_vdmpyhb_128B", + "V6.vdmpyhb.acc" => "__builtin_HEXAGON_V6_vdmpyhb_acc", + "V6.vdmpyhb.acc.128B" => "__builtin_HEXAGON_V6_vdmpyhb_acc_128B", + "V6.vdmpyhb.dv" => "__builtin_HEXAGON_V6_vdmpyhb_dv", + "V6.vdmpyhb.dv.128B" => "__builtin_HEXAGON_V6_vdmpyhb_dv_128B", + "V6.vdmpyhb.dv.acc" => "__builtin_HEXAGON_V6_vdmpyhb_dv_acc", + "V6.vdmpyhb.dv.acc.128B" => "__builtin_HEXAGON_V6_vdmpyhb_dv_acc_128B", + "V6.vdmpyhisat" => "__builtin_HEXAGON_V6_vdmpyhisat", + "V6.vdmpyhisat.128B" => "__builtin_HEXAGON_V6_vdmpyhisat_128B", + "V6.vdmpyhisat.acc" => "__builtin_HEXAGON_V6_vdmpyhisat_acc", + "V6.vdmpyhisat.acc.128B" => "__builtin_HEXAGON_V6_vdmpyhisat_acc_128B", + "V6.vdmpyhsat" => "__builtin_HEXAGON_V6_vdmpyhsat", + "V6.vdmpyhsat.128B" => "__builtin_HEXAGON_V6_vdmpyhsat_128B", + "V6.vdmpyhsat.acc" => "__builtin_HEXAGON_V6_vdmpyhsat_acc", + "V6.vdmpyhsat.acc.128B" => "__builtin_HEXAGON_V6_vdmpyhsat_acc_128B", + "V6.vdmpyhsuisat" => "__builtin_HEXAGON_V6_vdmpyhsuisat", + "V6.vdmpyhsuisat.128B" => "__builtin_HEXAGON_V6_vdmpyhsuisat_128B", + "V6.vdmpyhsuisat.acc" => "__builtin_HEXAGON_V6_vdmpyhsuisat_acc", + "V6.vdmpyhsuisat.acc.128B" => "__builtin_HEXAGON_V6_vdmpyhsuisat_acc_128B", + "V6.vdmpyhsusat" => "__builtin_HEXAGON_V6_vdmpyhsusat", + "V6.vdmpyhsusat.128B" => "__builtin_HEXAGON_V6_vdmpyhsusat_128B", + "V6.vdmpyhsusat.acc" => "__builtin_HEXAGON_V6_vdmpyhsusat_acc", + "V6.vdmpyhsusat.acc.128B" => "__builtin_HEXAGON_V6_vdmpyhsusat_acc_128B", + "V6.vdmpyhvsat" => "__builtin_HEXAGON_V6_vdmpyhvsat", + "V6.vdmpyhvsat.128B" => "__builtin_HEXAGON_V6_vdmpyhvsat_128B", + "V6.vdmpyhvsat.acc" => "__builtin_HEXAGON_V6_vdmpyhvsat_acc", + "V6.vdmpyhvsat.acc.128B" => "__builtin_HEXAGON_V6_vdmpyhvsat_acc_128B", + "V6.vdsaduh" => "__builtin_HEXAGON_V6_vdsaduh", + "V6.vdsaduh.128B" => "__builtin_HEXAGON_V6_vdsaduh_128B", + "V6.vdsaduh.acc" => "__builtin_HEXAGON_V6_vdsaduh_acc", + "V6.vdsaduh.acc.128B" => "__builtin_HEXAGON_V6_vdsaduh_acc_128B", + "V6.veqb" => "__builtin_HEXAGON_V6_veqb", + "V6.veqb.128B" => "__builtin_HEXAGON_V6_veqb_128B", + "V6.veqb.and" => "__builtin_HEXAGON_V6_veqb_and", + "V6.veqb.and.128B" => "__builtin_HEXAGON_V6_veqb_and_128B", + "V6.veqb.or" => "__builtin_HEXAGON_V6_veqb_or", + "V6.veqb.or.128B" => "__builtin_HEXAGON_V6_veqb_or_128B", + "V6.veqb.xor" => "__builtin_HEXAGON_V6_veqb_xor", + "V6.veqb.xor.128B" => "__builtin_HEXAGON_V6_veqb_xor_128B", + "V6.veqh" => "__builtin_HEXAGON_V6_veqh", + "V6.veqh.128B" => "__builtin_HEXAGON_V6_veqh_128B", + "V6.veqh.and" => "__builtin_HEXAGON_V6_veqh_and", + "V6.veqh.and.128B" => "__builtin_HEXAGON_V6_veqh_and_128B", + "V6.veqh.or" => "__builtin_HEXAGON_V6_veqh_or", + "V6.veqh.or.128B" => "__builtin_HEXAGON_V6_veqh_or_128B", + "V6.veqh.xor" => "__builtin_HEXAGON_V6_veqh_xor", + "V6.veqh.xor.128B" => "__builtin_HEXAGON_V6_veqh_xor_128B", + "V6.veqw" => "__builtin_HEXAGON_V6_veqw", + "V6.veqw.128B" => "__builtin_HEXAGON_V6_veqw_128B", + "V6.veqw.and" => "__builtin_HEXAGON_V6_veqw_and", + "V6.veqw.and.128B" => "__builtin_HEXAGON_V6_veqw_and_128B", + "V6.veqw.or" => "__builtin_HEXAGON_V6_veqw_or", + "V6.veqw.or.128B" => "__builtin_HEXAGON_V6_veqw_or_128B", + "V6.veqw.xor" => "__builtin_HEXAGON_V6_veqw_xor", + "V6.veqw.xor.128B" => "__builtin_HEXAGON_V6_veqw_xor_128B", + "V6.vfmax.f8" => "__builtin_HEXAGON_V6_vfmax_f8", + "V6.vfmax.f8.128B" => "__builtin_HEXAGON_V6_vfmax_f8_128B", + "V6.vfmax.hf" => "__builtin_HEXAGON_V6_vfmax_hf", + "V6.vfmax.hf.128B" => "__builtin_HEXAGON_V6_vfmax_hf_128B", + "V6.vfmax.sf" => "__builtin_HEXAGON_V6_vfmax_sf", + "V6.vfmax.sf.128B" => "__builtin_HEXAGON_V6_vfmax_sf_128B", + "V6.vfmin.f8" => "__builtin_HEXAGON_V6_vfmin_f8", + "V6.vfmin.f8.128B" => "__builtin_HEXAGON_V6_vfmin_f8_128B", + "V6.vfmin.hf" => "__builtin_HEXAGON_V6_vfmin_hf", + "V6.vfmin.hf.128B" => "__builtin_HEXAGON_V6_vfmin_hf_128B", + "V6.vfmin.sf" => "__builtin_HEXAGON_V6_vfmin_sf", + "V6.vfmin.sf.128B" => "__builtin_HEXAGON_V6_vfmin_sf_128B", + "V6.vfneg.f8" => "__builtin_HEXAGON_V6_vfneg_f8", + "V6.vfneg.f8.128B" => "__builtin_HEXAGON_V6_vfneg_f8_128B", + "V6.vfneg.hf" => "__builtin_HEXAGON_V6_vfneg_hf", + "V6.vfneg.hf.128B" => "__builtin_HEXAGON_V6_vfneg_hf_128B", + "V6.vfneg.sf" => "__builtin_HEXAGON_V6_vfneg_sf", + "V6.vfneg.sf.128B" => "__builtin_HEXAGON_V6_vfneg_sf_128B", + "V6.vgathermh" => "__builtin_HEXAGON_V6_vgathermh", + "V6.vgathermh.128B" => "__builtin_HEXAGON_V6_vgathermh_128B", + "V6.vgathermhq" => "__builtin_HEXAGON_V6_vgathermhq", + "V6.vgathermhq.128B" => "__builtin_HEXAGON_V6_vgathermhq_128B", + "V6.vgathermhw" => "__builtin_HEXAGON_V6_vgathermhw", + "V6.vgathermhw.128B" => "__builtin_HEXAGON_V6_vgathermhw_128B", + "V6.vgathermhwq" => "__builtin_HEXAGON_V6_vgathermhwq", + "V6.vgathermhwq.128B" => "__builtin_HEXAGON_V6_vgathermhwq_128B", + "V6.vgathermw" => "__builtin_HEXAGON_V6_vgathermw", + "V6.vgathermw.128B" => "__builtin_HEXAGON_V6_vgathermw_128B", + "V6.vgathermwq" => "__builtin_HEXAGON_V6_vgathermwq", + "V6.vgathermwq.128B" => "__builtin_HEXAGON_V6_vgathermwq_128B", + "V6.vgtb" => "__builtin_HEXAGON_V6_vgtb", + "V6.vgtb.128B" => "__builtin_HEXAGON_V6_vgtb_128B", + "V6.vgtb.and" => "__builtin_HEXAGON_V6_vgtb_and", + "V6.vgtb.and.128B" => "__builtin_HEXAGON_V6_vgtb_and_128B", + "V6.vgtb.or" => "__builtin_HEXAGON_V6_vgtb_or", + "V6.vgtb.or.128B" => "__builtin_HEXAGON_V6_vgtb_or_128B", + "V6.vgtb.xor" => "__builtin_HEXAGON_V6_vgtb_xor", + "V6.vgtb.xor.128B" => "__builtin_HEXAGON_V6_vgtb_xor_128B", + "V6.vgtbf" => "__builtin_HEXAGON_V6_vgtbf", + "V6.vgtbf.128B" => "__builtin_HEXAGON_V6_vgtbf_128B", + "V6.vgtbf.and" => "__builtin_HEXAGON_V6_vgtbf_and", + "V6.vgtbf.and.128B" => "__builtin_HEXAGON_V6_vgtbf_and_128B", + "V6.vgtbf.or" => "__builtin_HEXAGON_V6_vgtbf_or", + "V6.vgtbf.or.128B" => "__builtin_HEXAGON_V6_vgtbf_or_128B", + "V6.vgtbf.xor" => "__builtin_HEXAGON_V6_vgtbf_xor", + "V6.vgtbf.xor.128B" => "__builtin_HEXAGON_V6_vgtbf_xor_128B", + "V6.vgth" => "__builtin_HEXAGON_V6_vgth", + "V6.vgth.128B" => "__builtin_HEXAGON_V6_vgth_128B", + "V6.vgth.and" => "__builtin_HEXAGON_V6_vgth_and", + "V6.vgth.and.128B" => "__builtin_HEXAGON_V6_vgth_and_128B", + "V6.vgth.or" => "__builtin_HEXAGON_V6_vgth_or", + "V6.vgth.or.128B" => "__builtin_HEXAGON_V6_vgth_or_128B", + "V6.vgth.xor" => "__builtin_HEXAGON_V6_vgth_xor", + "V6.vgth.xor.128B" => "__builtin_HEXAGON_V6_vgth_xor_128B", + "V6.vgthf" => "__builtin_HEXAGON_V6_vgthf", + "V6.vgthf.128B" => "__builtin_HEXAGON_V6_vgthf_128B", + "V6.vgthf.and" => "__builtin_HEXAGON_V6_vgthf_and", + "V6.vgthf.and.128B" => "__builtin_HEXAGON_V6_vgthf_and_128B", + "V6.vgthf.or" => "__builtin_HEXAGON_V6_vgthf_or", + "V6.vgthf.or.128B" => "__builtin_HEXAGON_V6_vgthf_or_128B", + "V6.vgthf.xor" => "__builtin_HEXAGON_V6_vgthf_xor", + "V6.vgthf.xor.128B" => "__builtin_HEXAGON_V6_vgthf_xor_128B", + "V6.vgtsf" => "__builtin_HEXAGON_V6_vgtsf", + "V6.vgtsf.128B" => "__builtin_HEXAGON_V6_vgtsf_128B", + "V6.vgtsf.and" => "__builtin_HEXAGON_V6_vgtsf_and", + "V6.vgtsf.and.128B" => "__builtin_HEXAGON_V6_vgtsf_and_128B", + "V6.vgtsf.or" => "__builtin_HEXAGON_V6_vgtsf_or", + "V6.vgtsf.or.128B" => "__builtin_HEXAGON_V6_vgtsf_or_128B", + "V6.vgtsf.xor" => "__builtin_HEXAGON_V6_vgtsf_xor", + "V6.vgtsf.xor.128B" => "__builtin_HEXAGON_V6_vgtsf_xor_128B", + "V6.vgtub" => "__builtin_HEXAGON_V6_vgtub", + "V6.vgtub.128B" => "__builtin_HEXAGON_V6_vgtub_128B", + "V6.vgtub.and" => "__builtin_HEXAGON_V6_vgtub_and", + "V6.vgtub.and.128B" => "__builtin_HEXAGON_V6_vgtub_and_128B", + "V6.vgtub.or" => "__builtin_HEXAGON_V6_vgtub_or", + "V6.vgtub.or.128B" => "__builtin_HEXAGON_V6_vgtub_or_128B", + "V6.vgtub.xor" => "__builtin_HEXAGON_V6_vgtub_xor", + "V6.vgtub.xor.128B" => "__builtin_HEXAGON_V6_vgtub_xor_128B", + "V6.vgtuh" => "__builtin_HEXAGON_V6_vgtuh", + "V6.vgtuh.128B" => "__builtin_HEXAGON_V6_vgtuh_128B", + "V6.vgtuh.and" => "__builtin_HEXAGON_V6_vgtuh_and", + "V6.vgtuh.and.128B" => "__builtin_HEXAGON_V6_vgtuh_and_128B", + "V6.vgtuh.or" => "__builtin_HEXAGON_V6_vgtuh_or", + "V6.vgtuh.or.128B" => "__builtin_HEXAGON_V6_vgtuh_or_128B", + "V6.vgtuh.xor" => "__builtin_HEXAGON_V6_vgtuh_xor", + "V6.vgtuh.xor.128B" => "__builtin_HEXAGON_V6_vgtuh_xor_128B", + "V6.vgtuw" => "__builtin_HEXAGON_V6_vgtuw", + "V6.vgtuw.128B" => "__builtin_HEXAGON_V6_vgtuw_128B", + "V6.vgtuw.and" => "__builtin_HEXAGON_V6_vgtuw_and", + "V6.vgtuw.and.128B" => "__builtin_HEXAGON_V6_vgtuw_and_128B", + "V6.vgtuw.or" => "__builtin_HEXAGON_V6_vgtuw_or", + "V6.vgtuw.or.128B" => "__builtin_HEXAGON_V6_vgtuw_or_128B", + "V6.vgtuw.xor" => "__builtin_HEXAGON_V6_vgtuw_xor", + "V6.vgtuw.xor.128B" => "__builtin_HEXAGON_V6_vgtuw_xor_128B", + "V6.vgtw" => "__builtin_HEXAGON_V6_vgtw", + "V6.vgtw.128B" => "__builtin_HEXAGON_V6_vgtw_128B", + "V6.vgtw.and" => "__builtin_HEXAGON_V6_vgtw_and", + "V6.vgtw.and.128B" => "__builtin_HEXAGON_V6_vgtw_and_128B", + "V6.vgtw.or" => "__builtin_HEXAGON_V6_vgtw_or", + "V6.vgtw.or.128B" => "__builtin_HEXAGON_V6_vgtw_or_128B", + "V6.vgtw.xor" => "__builtin_HEXAGON_V6_vgtw_xor", + "V6.vgtw.xor.128B" => "__builtin_HEXAGON_V6_vgtw_xor_128B", + "V6.vinsertwr" => "__builtin_HEXAGON_V6_vinsertwr", + "V6.vinsertwr.128B" => "__builtin_HEXAGON_V6_vinsertwr_128B", + "V6.vlalignb" => "__builtin_HEXAGON_V6_vlalignb", + "V6.vlalignb.128B" => "__builtin_HEXAGON_V6_vlalignb_128B", + "V6.vlalignbi" => "__builtin_HEXAGON_V6_vlalignbi", + "V6.vlalignbi.128B" => "__builtin_HEXAGON_V6_vlalignbi_128B", + "V6.vlsrb" => "__builtin_HEXAGON_V6_vlsrb", + "V6.vlsrb.128B" => "__builtin_HEXAGON_V6_vlsrb_128B", + "V6.vlsrh" => "__builtin_HEXAGON_V6_vlsrh", + "V6.vlsrh.128B" => "__builtin_HEXAGON_V6_vlsrh_128B", + "V6.vlsrhv" => "__builtin_HEXAGON_V6_vlsrhv", + "V6.vlsrhv.128B" => "__builtin_HEXAGON_V6_vlsrhv_128B", + "V6.vlsrw" => "__builtin_HEXAGON_V6_vlsrw", + "V6.vlsrw.128B" => "__builtin_HEXAGON_V6_vlsrw_128B", + "V6.vlsrwv" => "__builtin_HEXAGON_V6_vlsrwv", + "V6.vlsrwv.128B" => "__builtin_HEXAGON_V6_vlsrwv_128B", + "V6.vlut4" => "__builtin_HEXAGON_V6_vlut4", + "V6.vlut4.128B" => "__builtin_HEXAGON_V6_vlut4_128B", + "V6.vlutb" => "__builtin_HEXAGON_V6_vlutb", + "V6.vlutb.128B" => "__builtin_HEXAGON_V6_vlutb_128B", + "V6.vlutb.acc" => "__builtin_HEXAGON_V6_vlutb_acc", + "V6.vlutb.acc.128B" => "__builtin_HEXAGON_V6_vlutb_acc_128B", + "V6.vlutb.dv" => "__builtin_HEXAGON_V6_vlutb_dv", + "V6.vlutb.dv.128B" => "__builtin_HEXAGON_V6_vlutb_dv_128B", + "V6.vlutb.dv.acc" => "__builtin_HEXAGON_V6_vlutb_dv_acc", + "V6.vlutb.dv.acc.128B" => "__builtin_HEXAGON_V6_vlutb_dv_acc_128B", + "V6.vlutvvb" => "__builtin_HEXAGON_V6_vlutvvb", + "V6.vlutvvb.128B" => "__builtin_HEXAGON_V6_vlutvvb_128B", + "V6.vlutvvb.nm" => "__builtin_HEXAGON_V6_vlutvvb_nm", + "V6.vlutvvb.nm.128B" => "__builtin_HEXAGON_V6_vlutvvb_nm_128B", + "V6.vlutvvb.oracc" => "__builtin_HEXAGON_V6_vlutvvb_oracc", + "V6.vlutvvb.oracc.128B" => "__builtin_HEXAGON_V6_vlutvvb_oracc_128B", + "V6.vlutvvb.oracci" => "__builtin_HEXAGON_V6_vlutvvb_oracci", + "V6.vlutvvb.oracci.128B" => "__builtin_HEXAGON_V6_vlutvvb_oracci_128B", + "V6.vlutvvbi" => "__builtin_HEXAGON_V6_vlutvvbi", + "V6.vlutvvbi.128B" => "__builtin_HEXAGON_V6_vlutvvbi_128B", + "V6.vlutvwh" => "__builtin_HEXAGON_V6_vlutvwh", + "V6.vlutvwh.128B" => "__builtin_HEXAGON_V6_vlutvwh_128B", + "V6.vlutvwh.nm" => "__builtin_HEXAGON_V6_vlutvwh_nm", + "V6.vlutvwh.nm.128B" => "__builtin_HEXAGON_V6_vlutvwh_nm_128B", + "V6.vlutvwh.oracc" => "__builtin_HEXAGON_V6_vlutvwh_oracc", + "V6.vlutvwh.oracc.128B" => "__builtin_HEXAGON_V6_vlutvwh_oracc_128B", + "V6.vlutvwh.oracci" => "__builtin_HEXAGON_V6_vlutvwh_oracci", + "V6.vlutvwh.oracci.128B" => "__builtin_HEXAGON_V6_vlutvwh_oracci_128B", + "V6.vlutvwhi" => "__builtin_HEXAGON_V6_vlutvwhi", + "V6.vlutvwhi.128B" => "__builtin_HEXAGON_V6_vlutvwhi_128B", + "V6.vmax.bf" => "__builtin_HEXAGON_V6_vmax_bf", + "V6.vmax.bf.128B" => "__builtin_HEXAGON_V6_vmax_bf_128B", + "V6.vmax.hf" => "__builtin_HEXAGON_V6_vmax_hf", + "V6.vmax.hf.128B" => "__builtin_HEXAGON_V6_vmax_hf_128B", + "V6.vmax.sf" => "__builtin_HEXAGON_V6_vmax_sf", + "V6.vmax.sf.128B" => "__builtin_HEXAGON_V6_vmax_sf_128B", + "V6.vmaxb" => "__builtin_HEXAGON_V6_vmaxb", + "V6.vmaxb.128B" => "__builtin_HEXAGON_V6_vmaxb_128B", + "V6.vmaxh" => "__builtin_HEXAGON_V6_vmaxh", + "V6.vmaxh.128B" => "__builtin_HEXAGON_V6_vmaxh_128B", + "V6.vmaxub" => "__builtin_HEXAGON_V6_vmaxub", + "V6.vmaxub.128B" => "__builtin_HEXAGON_V6_vmaxub_128B", + "V6.vmaxuh" => "__builtin_HEXAGON_V6_vmaxuh", + "V6.vmaxuh.128B" => "__builtin_HEXAGON_V6_vmaxuh_128B", + "V6.vmaxw" => "__builtin_HEXAGON_V6_vmaxw", + "V6.vmaxw.128B" => "__builtin_HEXAGON_V6_vmaxw_128B", + "V6.vmerge.qf" => "__builtin_HEXAGON_V6_vmerge_qf", + "V6.vmerge.qf.128B" => "__builtin_HEXAGON_V6_vmerge_qf_128B", + "V6.vmin.bf" => "__builtin_HEXAGON_V6_vmin_bf", + "V6.vmin.bf.128B" => "__builtin_HEXAGON_V6_vmin_bf_128B", + "V6.vmin.hf" => "__builtin_HEXAGON_V6_vmin_hf", + "V6.vmin.hf.128B" => "__builtin_HEXAGON_V6_vmin_hf_128B", + "V6.vmin.sf" => "__builtin_HEXAGON_V6_vmin_sf", + "V6.vmin.sf.128B" => "__builtin_HEXAGON_V6_vmin_sf_128B", + "V6.vminb" => "__builtin_HEXAGON_V6_vminb", + "V6.vminb.128B" => "__builtin_HEXAGON_V6_vminb_128B", + "V6.vminh" => "__builtin_HEXAGON_V6_vminh", + "V6.vminh.128B" => "__builtin_HEXAGON_V6_vminh_128B", + "V6.vminub" => "__builtin_HEXAGON_V6_vminub", + "V6.vminub.128B" => "__builtin_HEXAGON_V6_vminub_128B", + "V6.vminuh" => "__builtin_HEXAGON_V6_vminuh", + "V6.vminuh.128B" => "__builtin_HEXAGON_V6_vminuh_128B", + "V6.vminw" => "__builtin_HEXAGON_V6_vminw", + "V6.vminw.128B" => "__builtin_HEXAGON_V6_vminw_128B", + "V6.vmpabus" => "__builtin_HEXAGON_V6_vmpabus", + "V6.vmpabus.128B" => "__builtin_HEXAGON_V6_vmpabus_128B", + "V6.vmpabus.acc" => "__builtin_HEXAGON_V6_vmpabus_acc", + "V6.vmpabus.acc.128B" => "__builtin_HEXAGON_V6_vmpabus_acc_128B", + "V6.vmpabusv" => "__builtin_HEXAGON_V6_vmpabusv", + "V6.vmpabusv.128B" => "__builtin_HEXAGON_V6_vmpabusv_128B", + "V6.vmpabuu" => "__builtin_HEXAGON_V6_vmpabuu", + "V6.vmpabuu.128B" => "__builtin_HEXAGON_V6_vmpabuu_128B", + "V6.vmpabuu.acc" => "__builtin_HEXAGON_V6_vmpabuu_acc", + "V6.vmpabuu.acc.128B" => "__builtin_HEXAGON_V6_vmpabuu_acc_128B", + "V6.vmpabuuv" => "__builtin_HEXAGON_V6_vmpabuuv", + "V6.vmpabuuv.128B" => "__builtin_HEXAGON_V6_vmpabuuv_128B", + "V6.vmpahb" => "__builtin_HEXAGON_V6_vmpahb", + "V6.vmpahb.128B" => "__builtin_HEXAGON_V6_vmpahb_128B", + "V6.vmpahb.acc" => "__builtin_HEXAGON_V6_vmpahb_acc", + "V6.vmpahb.acc.128B" => "__builtin_HEXAGON_V6_vmpahb_acc_128B", + "V6.vmpahhsat" => "__builtin_HEXAGON_V6_vmpahhsat", + "V6.vmpahhsat.128B" => "__builtin_HEXAGON_V6_vmpahhsat_128B", + "V6.vmpauhb" => "__builtin_HEXAGON_V6_vmpauhb", + "V6.vmpauhb.128B" => "__builtin_HEXAGON_V6_vmpauhb_128B", + "V6.vmpauhb.acc" => "__builtin_HEXAGON_V6_vmpauhb_acc", + "V6.vmpauhb.acc.128B" => "__builtin_HEXAGON_V6_vmpauhb_acc_128B", + "V6.vmpauhuhsat" => "__builtin_HEXAGON_V6_vmpauhuhsat", + "V6.vmpauhuhsat.128B" => "__builtin_HEXAGON_V6_vmpauhuhsat_128B", + "V6.vmpsuhuhsat" => "__builtin_HEXAGON_V6_vmpsuhuhsat", + "V6.vmpsuhuhsat.128B" => "__builtin_HEXAGON_V6_vmpsuhuhsat_128B", + "V6.vmpy.hf.f8" => "__builtin_HEXAGON_V6_vmpy_hf_f8", + "V6.vmpy.hf.f8.128B" => "__builtin_HEXAGON_V6_vmpy_hf_f8_128B", + "V6.vmpy.hf.f8.acc" => "__builtin_HEXAGON_V6_vmpy_hf_f8_acc", + "V6.vmpy.hf.f8.acc.128B" => "__builtin_HEXAGON_V6_vmpy_hf_f8_acc_128B", + "V6.vmpy.hf.hf" => "__builtin_HEXAGON_V6_vmpy_hf_hf", + "V6.vmpy.hf.hf.128B" => "__builtin_HEXAGON_V6_vmpy_hf_hf_128B", + "V6.vmpy.hf.hf.acc" => "__builtin_HEXAGON_V6_vmpy_hf_hf_acc", + "V6.vmpy.hf.hf.acc.128B" => "__builtin_HEXAGON_V6_vmpy_hf_hf_acc_128B", + "V6.vmpy.qf16" => "__builtin_HEXAGON_V6_vmpy_qf16", + "V6.vmpy.qf16.128B" => "__builtin_HEXAGON_V6_vmpy_qf16_128B", + "V6.vmpy.qf16.hf" => "__builtin_HEXAGON_V6_vmpy_qf16_hf", + "V6.vmpy.qf16.hf.128B" => "__builtin_HEXAGON_V6_vmpy_qf16_hf_128B", + "V6.vmpy.qf16.mix.hf" => "__builtin_HEXAGON_V6_vmpy_qf16_mix_hf", + "V6.vmpy.qf16.mix.hf.128B" => "__builtin_HEXAGON_V6_vmpy_qf16_mix_hf_128B", + "V6.vmpy.qf32" => "__builtin_HEXAGON_V6_vmpy_qf32", + "V6.vmpy.qf32.128B" => "__builtin_HEXAGON_V6_vmpy_qf32_128B", + "V6.vmpy.qf32.hf" => "__builtin_HEXAGON_V6_vmpy_qf32_hf", + "V6.vmpy.qf32.hf.128B" => "__builtin_HEXAGON_V6_vmpy_qf32_hf_128B", + "V6.vmpy.qf32.mix.hf" => "__builtin_HEXAGON_V6_vmpy_qf32_mix_hf", + "V6.vmpy.qf32.mix.hf.128B" => "__builtin_HEXAGON_V6_vmpy_qf32_mix_hf_128B", + "V6.vmpy.qf32.qf16" => "__builtin_HEXAGON_V6_vmpy_qf32_qf16", + "V6.vmpy.qf32.qf16.128B" => "__builtin_HEXAGON_V6_vmpy_qf32_qf16_128B", + "V6.vmpy.qf32.sf" => "__builtin_HEXAGON_V6_vmpy_qf32_sf", + "V6.vmpy.qf32.sf.128B" => "__builtin_HEXAGON_V6_vmpy_qf32_sf_128B", + "V6.vmpy.rt.hf" => "__builtin_HEXAGON_V6_vmpy_rt_hf", + "V6.vmpy.rt.hf.128B" => "__builtin_HEXAGON_V6_vmpy_rt_hf_128B", + "V6.vmpy.rt.qf16" => "__builtin_HEXAGON_V6_vmpy_rt_qf16", + "V6.vmpy.rt.qf16.128B" => "__builtin_HEXAGON_V6_vmpy_rt_qf16_128B", + "V6.vmpy.rt.sf" => "__builtin_HEXAGON_V6_vmpy_rt_sf", + "V6.vmpy.rt.sf.128B" => "__builtin_HEXAGON_V6_vmpy_rt_sf_128B", + "V6.vmpy.sf.bf" => "__builtin_HEXAGON_V6_vmpy_sf_bf", + "V6.vmpy.sf.bf.128B" => "__builtin_HEXAGON_V6_vmpy_sf_bf_128B", + "V6.vmpy.sf.bf.acc" => "__builtin_HEXAGON_V6_vmpy_sf_bf_acc", + "V6.vmpy.sf.bf.acc.128B" => "__builtin_HEXAGON_V6_vmpy_sf_bf_acc_128B", + "V6.vmpy.sf.hf" => "__builtin_HEXAGON_V6_vmpy_sf_hf", + "V6.vmpy.sf.hf.128B" => "__builtin_HEXAGON_V6_vmpy_sf_hf_128B", + "V6.vmpy.sf.hf.acc" => "__builtin_HEXAGON_V6_vmpy_sf_hf_acc", + "V6.vmpy.sf.hf.acc.128B" => "__builtin_HEXAGON_V6_vmpy_sf_hf_acc_128B", + "V6.vmpy.sf.sf" => "__builtin_HEXAGON_V6_vmpy_sf_sf", + "V6.vmpy.sf.sf.128B" => "__builtin_HEXAGON_V6_vmpy_sf_sf_128B", + "V6.vmpybus" => "__builtin_HEXAGON_V6_vmpybus", + "V6.vmpybus.128B" => "__builtin_HEXAGON_V6_vmpybus_128B", + "V6.vmpybus.acc" => "__builtin_HEXAGON_V6_vmpybus_acc", + "V6.vmpybus.acc.128B" => "__builtin_HEXAGON_V6_vmpybus_acc_128B", + "V6.vmpybusv" => "__builtin_HEXAGON_V6_vmpybusv", + "V6.vmpybusv.128B" => "__builtin_HEXAGON_V6_vmpybusv_128B", + "V6.vmpybusv.acc" => "__builtin_HEXAGON_V6_vmpybusv_acc", + "V6.vmpybusv.acc.128B" => "__builtin_HEXAGON_V6_vmpybusv_acc_128B", + "V6.vmpybv" => "__builtin_HEXAGON_V6_vmpybv", + "V6.vmpybv.128B" => "__builtin_HEXAGON_V6_vmpybv_128B", + "V6.vmpybv.acc" => "__builtin_HEXAGON_V6_vmpybv_acc", + "V6.vmpybv.acc.128B" => "__builtin_HEXAGON_V6_vmpybv_acc_128B", + "V6.vmpyewuh" => "__builtin_HEXAGON_V6_vmpyewuh", + "V6.vmpyewuh.128B" => "__builtin_HEXAGON_V6_vmpyewuh_128B", + "V6.vmpyewuh.64" => "__builtin_HEXAGON_V6_vmpyewuh_64", + "V6.vmpyewuh.64.128B" => "__builtin_HEXAGON_V6_vmpyewuh_64_128B", + "V6.vmpyh" => "__builtin_HEXAGON_V6_vmpyh", + "V6.vmpyh.128B" => "__builtin_HEXAGON_V6_vmpyh_128B", + "V6.vmpyh.acc" => "__builtin_HEXAGON_V6_vmpyh_acc", + "V6.vmpyh.acc.128B" => "__builtin_HEXAGON_V6_vmpyh_acc_128B", + "V6.vmpyhsat.acc" => "__builtin_HEXAGON_V6_vmpyhsat_acc", + "V6.vmpyhsat.acc.128B" => "__builtin_HEXAGON_V6_vmpyhsat_acc_128B", + "V6.vmpyhsrs" => "__builtin_HEXAGON_V6_vmpyhsrs", + "V6.vmpyhsrs.128B" => "__builtin_HEXAGON_V6_vmpyhsrs_128B", + "V6.vmpyhss" => "__builtin_HEXAGON_V6_vmpyhss", + "V6.vmpyhss.128B" => "__builtin_HEXAGON_V6_vmpyhss_128B", + "V6.vmpyhus" => "__builtin_HEXAGON_V6_vmpyhus", + "V6.vmpyhus.128B" => "__builtin_HEXAGON_V6_vmpyhus_128B", + "V6.vmpyhus.acc" => "__builtin_HEXAGON_V6_vmpyhus_acc", + "V6.vmpyhus.acc.128B" => "__builtin_HEXAGON_V6_vmpyhus_acc_128B", + "V6.vmpyhv" => "__builtin_HEXAGON_V6_vmpyhv", + "V6.vmpyhv.128B" => "__builtin_HEXAGON_V6_vmpyhv_128B", + "V6.vmpyhv.acc" => "__builtin_HEXAGON_V6_vmpyhv_acc", + "V6.vmpyhv.acc.128B" => "__builtin_HEXAGON_V6_vmpyhv_acc_128B", + "V6.vmpyhvsrs" => "__builtin_HEXAGON_V6_vmpyhvsrs", + "V6.vmpyhvsrs.128B" => "__builtin_HEXAGON_V6_vmpyhvsrs_128B", + "V6.vmpyieoh" => "__builtin_HEXAGON_V6_vmpyieoh", + "V6.vmpyieoh.128B" => "__builtin_HEXAGON_V6_vmpyieoh_128B", + "V6.vmpyiewh.acc" => "__builtin_HEXAGON_V6_vmpyiewh_acc", + "V6.vmpyiewh.acc.128B" => "__builtin_HEXAGON_V6_vmpyiewh_acc_128B", + "V6.vmpyiewuh" => "__builtin_HEXAGON_V6_vmpyiewuh", + "V6.vmpyiewuh.128B" => "__builtin_HEXAGON_V6_vmpyiewuh_128B", + "V6.vmpyiewuh.acc" => "__builtin_HEXAGON_V6_vmpyiewuh_acc", + "V6.vmpyiewuh.acc.128B" => "__builtin_HEXAGON_V6_vmpyiewuh_acc_128B", + "V6.vmpyih" => "__builtin_HEXAGON_V6_vmpyih", + "V6.vmpyih.128B" => "__builtin_HEXAGON_V6_vmpyih_128B", + "V6.vmpyih.acc" => "__builtin_HEXAGON_V6_vmpyih_acc", + "V6.vmpyih.acc.128B" => "__builtin_HEXAGON_V6_vmpyih_acc_128B", + "V6.vmpyihb" => "__builtin_HEXAGON_V6_vmpyihb", + "V6.vmpyihb.128B" => "__builtin_HEXAGON_V6_vmpyihb_128B", + "V6.vmpyihb.acc" => "__builtin_HEXAGON_V6_vmpyihb_acc", + "V6.vmpyihb.acc.128B" => "__builtin_HEXAGON_V6_vmpyihb_acc_128B", + "V6.vmpyiowh" => "__builtin_HEXAGON_V6_vmpyiowh", + "V6.vmpyiowh.128B" => "__builtin_HEXAGON_V6_vmpyiowh_128B", + "V6.vmpyiwb" => "__builtin_HEXAGON_V6_vmpyiwb", + "V6.vmpyiwb.128B" => "__builtin_HEXAGON_V6_vmpyiwb_128B", + "V6.vmpyiwb.acc" => "__builtin_HEXAGON_V6_vmpyiwb_acc", + "V6.vmpyiwb.acc.128B" => "__builtin_HEXAGON_V6_vmpyiwb_acc_128B", + "V6.vmpyiwh" => "__builtin_HEXAGON_V6_vmpyiwh", + "V6.vmpyiwh.128B" => "__builtin_HEXAGON_V6_vmpyiwh_128B", + "V6.vmpyiwh.acc" => "__builtin_HEXAGON_V6_vmpyiwh_acc", + "V6.vmpyiwh.acc.128B" => "__builtin_HEXAGON_V6_vmpyiwh_acc_128B", + "V6.vmpyiwub" => "__builtin_HEXAGON_V6_vmpyiwub", + "V6.vmpyiwub.128B" => "__builtin_HEXAGON_V6_vmpyiwub_128B", + "V6.vmpyiwub.acc" => "__builtin_HEXAGON_V6_vmpyiwub_acc", + "V6.vmpyiwub.acc.128B" => "__builtin_HEXAGON_V6_vmpyiwub_acc_128B", + "V6.vmpyowh" => "__builtin_HEXAGON_V6_vmpyowh", + "V6.vmpyowh.128B" => "__builtin_HEXAGON_V6_vmpyowh_128B", + "V6.vmpyowh.64.acc" => "__builtin_HEXAGON_V6_vmpyowh_64_acc", + "V6.vmpyowh.64.acc.128B" => "__builtin_HEXAGON_V6_vmpyowh_64_acc_128B", + "V6.vmpyowh.rnd" => "__builtin_HEXAGON_V6_vmpyowh_rnd", + "V6.vmpyowh.rnd.128B" => "__builtin_HEXAGON_V6_vmpyowh_rnd_128B", + "V6.vmpyowh.rnd.sacc" => "__builtin_HEXAGON_V6_vmpyowh_rnd_sacc", + "V6.vmpyowh.rnd.sacc.128B" => "__builtin_HEXAGON_V6_vmpyowh_rnd_sacc_128B", + "V6.vmpyowh.sacc" => "__builtin_HEXAGON_V6_vmpyowh_sacc", + "V6.vmpyowh.sacc.128B" => "__builtin_HEXAGON_V6_vmpyowh_sacc_128B", + "V6.vmpyub" => "__builtin_HEXAGON_V6_vmpyub", + "V6.vmpyub.128B" => "__builtin_HEXAGON_V6_vmpyub_128B", + "V6.vmpyub.acc" => "__builtin_HEXAGON_V6_vmpyub_acc", + "V6.vmpyub.acc.128B" => "__builtin_HEXAGON_V6_vmpyub_acc_128B", + "V6.vmpyubv" => "__builtin_HEXAGON_V6_vmpyubv", + "V6.vmpyubv.128B" => "__builtin_HEXAGON_V6_vmpyubv_128B", + "V6.vmpyubv.acc" => "__builtin_HEXAGON_V6_vmpyubv_acc", + "V6.vmpyubv.acc.128B" => "__builtin_HEXAGON_V6_vmpyubv_acc_128B", + "V6.vmpyuh" => "__builtin_HEXAGON_V6_vmpyuh", + "V6.vmpyuh.128B" => "__builtin_HEXAGON_V6_vmpyuh_128B", + "V6.vmpyuh.acc" => "__builtin_HEXAGON_V6_vmpyuh_acc", + "V6.vmpyuh.acc.128B" => "__builtin_HEXAGON_V6_vmpyuh_acc_128B", + "V6.vmpyuhe" => "__builtin_HEXAGON_V6_vmpyuhe", + "V6.vmpyuhe.128B" => "__builtin_HEXAGON_V6_vmpyuhe_128B", + "V6.vmpyuhe.acc" => "__builtin_HEXAGON_V6_vmpyuhe_acc", + "V6.vmpyuhe.acc.128B" => "__builtin_HEXAGON_V6_vmpyuhe_acc_128B", + "V6.vmpyuhv" => "__builtin_HEXAGON_V6_vmpyuhv", + "V6.vmpyuhv.128B" => "__builtin_HEXAGON_V6_vmpyuhv_128B", + "V6.vmpyuhv.acc" => "__builtin_HEXAGON_V6_vmpyuhv_acc", + "V6.vmpyuhv.acc.128B" => "__builtin_HEXAGON_V6_vmpyuhv_acc_128B", + "V6.vmpyuhvs" => "__builtin_HEXAGON_V6_vmpyuhvs", + "V6.vmpyuhvs.128B" => "__builtin_HEXAGON_V6_vmpyuhvs_128B", + "V6.vmux" => "__builtin_HEXAGON_V6_vmux", + "V6.vmux.128B" => "__builtin_HEXAGON_V6_vmux_128B", + "V6.vnavgb" => "__builtin_HEXAGON_V6_vnavgb", + "V6.vnavgb.128B" => "__builtin_HEXAGON_V6_vnavgb_128B", + "V6.vnavgh" => "__builtin_HEXAGON_V6_vnavgh", + "V6.vnavgh.128B" => "__builtin_HEXAGON_V6_vnavgh_128B", + "V6.vnavgub" => "__builtin_HEXAGON_V6_vnavgub", + "V6.vnavgub.128B" => "__builtin_HEXAGON_V6_vnavgub_128B", + "V6.vnavgw" => "__builtin_HEXAGON_V6_vnavgw", + "V6.vnavgw.128B" => "__builtin_HEXAGON_V6_vnavgw_128B", + "V6.vnormamth" => "__builtin_HEXAGON_V6_vnormamth", + "V6.vnormamth.128B" => "__builtin_HEXAGON_V6_vnormamth_128B", + "V6.vnormamtw" => "__builtin_HEXAGON_V6_vnormamtw", + "V6.vnormamtw.128B" => "__builtin_HEXAGON_V6_vnormamtw_128B", + "V6.vnot" => "__builtin_HEXAGON_V6_vnot", + "V6.vnot.128B" => "__builtin_HEXAGON_V6_vnot_128B", + "V6.vor" => "__builtin_HEXAGON_V6_vor", + "V6.vor.128B" => "__builtin_HEXAGON_V6_vor_128B", + "V6.vpackeb" => "__builtin_HEXAGON_V6_vpackeb", + "V6.vpackeb.128B" => "__builtin_HEXAGON_V6_vpackeb_128B", + "V6.vpackeh" => "__builtin_HEXAGON_V6_vpackeh", + "V6.vpackeh.128B" => "__builtin_HEXAGON_V6_vpackeh_128B", + "V6.vpackhb.sat" => "__builtin_HEXAGON_V6_vpackhb_sat", + "V6.vpackhb.sat.128B" => "__builtin_HEXAGON_V6_vpackhb_sat_128B", + "V6.vpackhub.sat" => "__builtin_HEXAGON_V6_vpackhub_sat", + "V6.vpackhub.sat.128B" => "__builtin_HEXAGON_V6_vpackhub_sat_128B", + "V6.vpackob" => "__builtin_HEXAGON_V6_vpackob", + "V6.vpackob.128B" => "__builtin_HEXAGON_V6_vpackob_128B", + "V6.vpackoh" => "__builtin_HEXAGON_V6_vpackoh", + "V6.vpackoh.128B" => "__builtin_HEXAGON_V6_vpackoh_128B", + "V6.vpackwh.sat" => "__builtin_HEXAGON_V6_vpackwh_sat", + "V6.vpackwh.sat.128B" => "__builtin_HEXAGON_V6_vpackwh_sat_128B", + "V6.vpackwuh.sat" => "__builtin_HEXAGON_V6_vpackwuh_sat", + "V6.vpackwuh.sat.128B" => "__builtin_HEXAGON_V6_vpackwuh_sat_128B", + "V6.vpopcounth" => "__builtin_HEXAGON_V6_vpopcounth", + "V6.vpopcounth.128B" => "__builtin_HEXAGON_V6_vpopcounth_128B", + "V6.vprefixqb" => "__builtin_HEXAGON_V6_vprefixqb", + "V6.vprefixqb.128B" => "__builtin_HEXAGON_V6_vprefixqb_128B", + "V6.vprefixqh" => "__builtin_HEXAGON_V6_vprefixqh", + "V6.vprefixqh.128B" => "__builtin_HEXAGON_V6_vprefixqh_128B", + "V6.vprefixqw" => "__builtin_HEXAGON_V6_vprefixqw", + "V6.vprefixqw.128B" => "__builtin_HEXAGON_V6_vprefixqw_128B", + "V6.vrdelta" => "__builtin_HEXAGON_V6_vrdelta", + "V6.vrdelta.128B" => "__builtin_HEXAGON_V6_vrdelta_128B", + "V6.vrmpybub.rtt" => "__builtin_HEXAGON_V6_vrmpybub_rtt", + "V6.vrmpybub.rtt.128B" => "__builtin_HEXAGON_V6_vrmpybub_rtt_128B", + "V6.vrmpybub.rtt.acc" => "__builtin_HEXAGON_V6_vrmpybub_rtt_acc", + "V6.vrmpybub.rtt.acc.128B" => "__builtin_HEXAGON_V6_vrmpybub_rtt_acc_128B", + "V6.vrmpybus" => "__builtin_HEXAGON_V6_vrmpybus", + "V6.vrmpybus.128B" => "__builtin_HEXAGON_V6_vrmpybus_128B", + "V6.vrmpybus.acc" => "__builtin_HEXAGON_V6_vrmpybus_acc", + "V6.vrmpybus.acc.128B" => "__builtin_HEXAGON_V6_vrmpybus_acc_128B", + "V6.vrmpybusi" => "__builtin_HEXAGON_V6_vrmpybusi", + "V6.vrmpybusi.128B" => "__builtin_HEXAGON_V6_vrmpybusi_128B", + "V6.vrmpybusi.acc" => "__builtin_HEXAGON_V6_vrmpybusi_acc", + "V6.vrmpybusi.acc.128B" => "__builtin_HEXAGON_V6_vrmpybusi_acc_128B", + "V6.vrmpybusv" => "__builtin_HEXAGON_V6_vrmpybusv", + "V6.vrmpybusv.128B" => "__builtin_HEXAGON_V6_vrmpybusv_128B", + "V6.vrmpybusv.acc" => "__builtin_HEXAGON_V6_vrmpybusv_acc", + "V6.vrmpybusv.acc.128B" => "__builtin_HEXAGON_V6_vrmpybusv_acc_128B", + "V6.vrmpybv" => "__builtin_HEXAGON_V6_vrmpybv", + "V6.vrmpybv.128B" => "__builtin_HEXAGON_V6_vrmpybv_128B", + "V6.vrmpybv.acc" => "__builtin_HEXAGON_V6_vrmpybv_acc", + "V6.vrmpybv.acc.128B" => "__builtin_HEXAGON_V6_vrmpybv_acc_128B", + "V6.vrmpyub" => "__builtin_HEXAGON_V6_vrmpyub", + "V6.vrmpyub.128B" => "__builtin_HEXAGON_V6_vrmpyub_128B", + "V6.vrmpyub.acc" => "__builtin_HEXAGON_V6_vrmpyub_acc", + "V6.vrmpyub.acc.128B" => "__builtin_HEXAGON_V6_vrmpyub_acc_128B", + "V6.vrmpyub.rtt" => "__builtin_HEXAGON_V6_vrmpyub_rtt", + "V6.vrmpyub.rtt.128B" => "__builtin_HEXAGON_V6_vrmpyub_rtt_128B", + "V6.vrmpyub.rtt.acc" => "__builtin_HEXAGON_V6_vrmpyub_rtt_acc", + "V6.vrmpyub.rtt.acc.128B" => "__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B", + "V6.vrmpyubi" => "__builtin_HEXAGON_V6_vrmpyubi", + "V6.vrmpyubi.128B" => "__builtin_HEXAGON_V6_vrmpyubi_128B", + "V6.vrmpyubi.acc" => "__builtin_HEXAGON_V6_vrmpyubi_acc", + "V6.vrmpyubi.acc.128B" => "__builtin_HEXAGON_V6_vrmpyubi_acc_128B", + "V6.vrmpyubv" => "__builtin_HEXAGON_V6_vrmpyubv", + "V6.vrmpyubv.128B" => "__builtin_HEXAGON_V6_vrmpyubv_128B", + "V6.vrmpyubv.acc" => "__builtin_HEXAGON_V6_vrmpyubv_acc", + "V6.vrmpyubv.acc.128B" => "__builtin_HEXAGON_V6_vrmpyubv_acc_128B", + "V6.vror" => "__builtin_HEXAGON_V6_vror", + "V6.vror.128B" => "__builtin_HEXAGON_V6_vror_128B", + "V6.vrotr" => "__builtin_HEXAGON_V6_vrotr", + "V6.vrotr.128B" => "__builtin_HEXAGON_V6_vrotr_128B", + "V6.vroundhb" => "__builtin_HEXAGON_V6_vroundhb", + "V6.vroundhb.128B" => "__builtin_HEXAGON_V6_vroundhb_128B", + "V6.vroundhub" => "__builtin_HEXAGON_V6_vroundhub", + "V6.vroundhub.128B" => "__builtin_HEXAGON_V6_vroundhub_128B", + "V6.vrounduhub" => "__builtin_HEXAGON_V6_vrounduhub", + "V6.vrounduhub.128B" => "__builtin_HEXAGON_V6_vrounduhub_128B", + "V6.vrounduwuh" => "__builtin_HEXAGON_V6_vrounduwuh", + "V6.vrounduwuh.128B" => "__builtin_HEXAGON_V6_vrounduwuh_128B", + "V6.vroundwh" => "__builtin_HEXAGON_V6_vroundwh", + "V6.vroundwh.128B" => "__builtin_HEXAGON_V6_vroundwh_128B", + "V6.vroundwuh" => "__builtin_HEXAGON_V6_vroundwuh", + "V6.vroundwuh.128B" => "__builtin_HEXAGON_V6_vroundwuh_128B", + "V6.vrsadubi" => "__builtin_HEXAGON_V6_vrsadubi", + "V6.vrsadubi.128B" => "__builtin_HEXAGON_V6_vrsadubi_128B", + "V6.vrsadubi.acc" => "__builtin_HEXAGON_V6_vrsadubi_acc", + "V6.vrsadubi.acc.128B" => "__builtin_HEXAGON_V6_vrsadubi_acc_128B", + "V6.vsatdw" => "__builtin_HEXAGON_V6_vsatdw", + "V6.vsatdw.128B" => "__builtin_HEXAGON_V6_vsatdw_128B", + "V6.vsathub" => "__builtin_HEXAGON_V6_vsathub", + "V6.vsathub.128B" => "__builtin_HEXAGON_V6_vsathub_128B", + "V6.vsatuwuh" => "__builtin_HEXAGON_V6_vsatuwuh", + "V6.vsatuwuh.128B" => "__builtin_HEXAGON_V6_vsatuwuh_128B", + "V6.vsatwh" => "__builtin_HEXAGON_V6_vsatwh", + "V6.vsatwh.128B" => "__builtin_HEXAGON_V6_vsatwh_128B", + "V6.vsb" => "__builtin_HEXAGON_V6_vsb", + "V6.vsb.128B" => "__builtin_HEXAGON_V6_vsb_128B", + "V6.vscattermh" => "__builtin_HEXAGON_V6_vscattermh", + "V6.vscattermh.128B" => "__builtin_HEXAGON_V6_vscattermh_128B", + "V6.vscattermh.add" => "__builtin_HEXAGON_V6_vscattermh_add", + "V6.vscattermh.add.128B" => "__builtin_HEXAGON_V6_vscattermh_add_128B", + "V6.vscattermhq" => "__builtin_HEXAGON_V6_vscattermhq", + "V6.vscattermhq.128B" => "__builtin_HEXAGON_V6_vscattermhq_128B", + "V6.vscattermhw" => "__builtin_HEXAGON_V6_vscattermhw", + "V6.vscattermhw.128B" => "__builtin_HEXAGON_V6_vscattermhw_128B", + "V6.vscattermhw.add" => "__builtin_HEXAGON_V6_vscattermhw_add", + "V6.vscattermhw.add.128B" => "__builtin_HEXAGON_V6_vscattermhw_add_128B", + "V6.vscattermhwq" => "__builtin_HEXAGON_V6_vscattermhwq", + "V6.vscattermhwq.128B" => "__builtin_HEXAGON_V6_vscattermhwq_128B", + "V6.vscattermw" => "__builtin_HEXAGON_V6_vscattermw", + "V6.vscattermw.128B" => "__builtin_HEXAGON_V6_vscattermw_128B", + "V6.vscattermw.add" => "__builtin_HEXAGON_V6_vscattermw_add", + "V6.vscattermw.add.128B" => "__builtin_HEXAGON_V6_vscattermw_add_128B", + "V6.vscattermwq" => "__builtin_HEXAGON_V6_vscattermwq", + "V6.vscattermwq.128B" => "__builtin_HEXAGON_V6_vscattermwq_128B", + "V6.vsh" => "__builtin_HEXAGON_V6_vsh", + "V6.vsh.128B" => "__builtin_HEXAGON_V6_vsh_128B", + "V6.vshufeh" => "__builtin_HEXAGON_V6_vshufeh", + "V6.vshufeh.128B" => "__builtin_HEXAGON_V6_vshufeh_128B", + "V6.vshuffb" => "__builtin_HEXAGON_V6_vshuffb", + "V6.vshuffb.128B" => "__builtin_HEXAGON_V6_vshuffb_128B", + "V6.vshuffeb" => "__builtin_HEXAGON_V6_vshuffeb", + "V6.vshuffeb.128B" => "__builtin_HEXAGON_V6_vshuffeb_128B", + "V6.vshuffh" => "__builtin_HEXAGON_V6_vshuffh", + "V6.vshuffh.128B" => "__builtin_HEXAGON_V6_vshuffh_128B", + "V6.vshuffob" => "__builtin_HEXAGON_V6_vshuffob", + "V6.vshuffob.128B" => "__builtin_HEXAGON_V6_vshuffob_128B", + "V6.vshuffvdd" => "__builtin_HEXAGON_V6_vshuffvdd", + "V6.vshuffvdd.128B" => "__builtin_HEXAGON_V6_vshuffvdd_128B", + "V6.vshufoeb" => "__builtin_HEXAGON_V6_vshufoeb", + "V6.vshufoeb.128B" => "__builtin_HEXAGON_V6_vshufoeb_128B", + "V6.vshufoeh" => "__builtin_HEXAGON_V6_vshufoeh", + "V6.vshufoeh.128B" => "__builtin_HEXAGON_V6_vshufoeh_128B", + "V6.vshufoh" => "__builtin_HEXAGON_V6_vshufoh", + "V6.vshufoh.128B" => "__builtin_HEXAGON_V6_vshufoh_128B", + "V6.vsub.hf" => "__builtin_HEXAGON_V6_vsub_hf", + "V6.vsub.hf.128B" => "__builtin_HEXAGON_V6_vsub_hf_128B", + "V6.vsub.hf.f8" => "__builtin_HEXAGON_V6_vsub_hf_f8", + "V6.vsub.hf.f8.128B" => "__builtin_HEXAGON_V6_vsub_hf_f8_128B", + "V6.vsub.hf.hf" => "__builtin_HEXAGON_V6_vsub_hf_hf", + "V6.vsub.hf.hf.128B" => "__builtin_HEXAGON_V6_vsub_hf_hf_128B", + "V6.vsub.qf16" => "__builtin_HEXAGON_V6_vsub_qf16", + "V6.vsub.qf16.128B" => "__builtin_HEXAGON_V6_vsub_qf16_128B", + "V6.vsub.qf16.mix" => "__builtin_HEXAGON_V6_vsub_qf16_mix", + "V6.vsub.qf16.mix.128B" => "__builtin_HEXAGON_V6_vsub_qf16_mix_128B", + "V6.vsub.qf32" => "__builtin_HEXAGON_V6_vsub_qf32", + "V6.vsub.qf32.128B" => "__builtin_HEXAGON_V6_vsub_qf32_128B", + "V6.vsub.qf32.mix" => "__builtin_HEXAGON_V6_vsub_qf32_mix", + "V6.vsub.qf32.mix.128B" => "__builtin_HEXAGON_V6_vsub_qf32_mix_128B", + "V6.vsub.sf" => "__builtin_HEXAGON_V6_vsub_sf", + "V6.vsub.sf.128B" => "__builtin_HEXAGON_V6_vsub_sf_128B", + "V6.vsub.sf.bf" => "__builtin_HEXAGON_V6_vsub_sf_bf", + "V6.vsub.sf.bf.128B" => "__builtin_HEXAGON_V6_vsub_sf_bf_128B", + "V6.vsub.sf.hf" => "__builtin_HEXAGON_V6_vsub_sf_hf", + "V6.vsub.sf.hf.128B" => "__builtin_HEXAGON_V6_vsub_sf_hf_128B", + "V6.vsub.sf.sf" => "__builtin_HEXAGON_V6_vsub_sf_sf", + "V6.vsub.sf.sf.128B" => "__builtin_HEXAGON_V6_vsub_sf_sf_128B", + "V6.vsubb" => "__builtin_HEXAGON_V6_vsubb", + "V6.vsubb.128B" => "__builtin_HEXAGON_V6_vsubb_128B", + "V6.vsubb.dv" => "__builtin_HEXAGON_V6_vsubb_dv", + "V6.vsubb.dv.128B" => "__builtin_HEXAGON_V6_vsubb_dv_128B", + "V6.vsubbnq" => "__builtin_HEXAGON_V6_vsubbnq", + "V6.vsubbnq.128B" => "__builtin_HEXAGON_V6_vsubbnq_128B", + "V6.vsubbq" => "__builtin_HEXAGON_V6_vsubbq", + "V6.vsubbq.128B" => "__builtin_HEXAGON_V6_vsubbq_128B", + "V6.vsubbsat" => "__builtin_HEXAGON_V6_vsubbsat", + "V6.vsubbsat.128B" => "__builtin_HEXAGON_V6_vsubbsat_128B", + "V6.vsubbsat.dv" => "__builtin_HEXAGON_V6_vsubbsat_dv", + "V6.vsubbsat.dv.128B" => "__builtin_HEXAGON_V6_vsubbsat_dv_128B", + "V6.vsubh" => "__builtin_HEXAGON_V6_vsubh", + "V6.vsubh.128B" => "__builtin_HEXAGON_V6_vsubh_128B", + "V6.vsubh.dv" => "__builtin_HEXAGON_V6_vsubh_dv", + "V6.vsubh.dv.128B" => "__builtin_HEXAGON_V6_vsubh_dv_128B", + "V6.vsubhnq" => "__builtin_HEXAGON_V6_vsubhnq", + "V6.vsubhnq.128B" => "__builtin_HEXAGON_V6_vsubhnq_128B", + "V6.vsubhq" => "__builtin_HEXAGON_V6_vsubhq", + "V6.vsubhq.128B" => "__builtin_HEXAGON_V6_vsubhq_128B", + "V6.vsubhsat" => "__builtin_HEXAGON_V6_vsubhsat", + "V6.vsubhsat.128B" => "__builtin_HEXAGON_V6_vsubhsat_128B", + "V6.vsubhsat.dv" => "__builtin_HEXAGON_V6_vsubhsat_dv", + "V6.vsubhsat.dv.128B" => "__builtin_HEXAGON_V6_vsubhsat_dv_128B", + "V6.vsubhw" => "__builtin_HEXAGON_V6_vsubhw", + "V6.vsubhw.128B" => "__builtin_HEXAGON_V6_vsubhw_128B", + "V6.vsububh" => "__builtin_HEXAGON_V6_vsububh", + "V6.vsububh.128B" => "__builtin_HEXAGON_V6_vsububh_128B", + "V6.vsububsat" => "__builtin_HEXAGON_V6_vsububsat", + "V6.vsububsat.128B" => "__builtin_HEXAGON_V6_vsububsat_128B", + "V6.vsububsat.dv" => "__builtin_HEXAGON_V6_vsububsat_dv", + "V6.vsububsat.dv.128B" => "__builtin_HEXAGON_V6_vsububsat_dv_128B", + "V6.vsubububb.sat" => "__builtin_HEXAGON_V6_vsubububb_sat", + "V6.vsubububb.sat.128B" => "__builtin_HEXAGON_V6_vsubububb_sat_128B", + "V6.vsubuhsat" => "__builtin_HEXAGON_V6_vsubuhsat", + "V6.vsubuhsat.128B" => "__builtin_HEXAGON_V6_vsubuhsat_128B", + "V6.vsubuhsat.dv" => "__builtin_HEXAGON_V6_vsubuhsat_dv", + "V6.vsubuhsat.dv.128B" => "__builtin_HEXAGON_V6_vsubuhsat_dv_128B", + "V6.vsubuhw" => "__builtin_HEXAGON_V6_vsubuhw", + "V6.vsubuhw.128B" => "__builtin_HEXAGON_V6_vsubuhw_128B", + "V6.vsubuwsat" => "__builtin_HEXAGON_V6_vsubuwsat", + "V6.vsubuwsat.128B" => "__builtin_HEXAGON_V6_vsubuwsat_128B", + "V6.vsubuwsat.dv" => "__builtin_HEXAGON_V6_vsubuwsat_dv", + "V6.vsubuwsat.dv.128B" => "__builtin_HEXAGON_V6_vsubuwsat_dv_128B", + "V6.vsubw" => "__builtin_HEXAGON_V6_vsubw", + "V6.vsubw.128B" => "__builtin_HEXAGON_V6_vsubw_128B", + "V6.vsubw.dv" => "__builtin_HEXAGON_V6_vsubw_dv", + "V6.vsubw.dv.128B" => "__builtin_HEXAGON_V6_vsubw_dv_128B", + "V6.vsubwnq" => "__builtin_HEXAGON_V6_vsubwnq", + "V6.vsubwnq.128B" => "__builtin_HEXAGON_V6_vsubwnq_128B", + "V6.vsubwq" => "__builtin_HEXAGON_V6_vsubwq", + "V6.vsubwq.128B" => "__builtin_HEXAGON_V6_vsubwq_128B", + "V6.vsubwsat" => "__builtin_HEXAGON_V6_vsubwsat", + "V6.vsubwsat.128B" => "__builtin_HEXAGON_V6_vsubwsat_128B", + "V6.vsubwsat.dv" => "__builtin_HEXAGON_V6_vsubwsat_dv", + "V6.vsubwsat.dv.128B" => "__builtin_HEXAGON_V6_vsubwsat_dv_128B", + "V6.vswap" => "__builtin_HEXAGON_V6_vswap", + "V6.vswap.128B" => "__builtin_HEXAGON_V6_vswap_128B", + "V6.vtmpyb" => "__builtin_HEXAGON_V6_vtmpyb", + "V6.vtmpyb.128B" => "__builtin_HEXAGON_V6_vtmpyb_128B", + "V6.vtmpyb.acc" => "__builtin_HEXAGON_V6_vtmpyb_acc", + "V6.vtmpyb.acc.128B" => "__builtin_HEXAGON_V6_vtmpyb_acc_128B", + "V6.vtmpybus" => "__builtin_HEXAGON_V6_vtmpybus", + "V6.vtmpybus.128B" => "__builtin_HEXAGON_V6_vtmpybus_128B", + "V6.vtmpybus.acc" => "__builtin_HEXAGON_V6_vtmpybus_acc", + "V6.vtmpybus.acc.128B" => "__builtin_HEXAGON_V6_vtmpybus_acc_128B", + "V6.vtmpyhb" => "__builtin_HEXAGON_V6_vtmpyhb", + "V6.vtmpyhb.128B" => "__builtin_HEXAGON_V6_vtmpyhb_128B", + "V6.vtmpyhb.acc" => "__builtin_HEXAGON_V6_vtmpyhb_acc", + "V6.vtmpyhb.acc.128B" => "__builtin_HEXAGON_V6_vtmpyhb_acc_128B", + "V6.vunpackb" => "__builtin_HEXAGON_V6_vunpackb", + "V6.vunpackb.128B" => "__builtin_HEXAGON_V6_vunpackb_128B", + "V6.vunpackh" => "__builtin_HEXAGON_V6_vunpackh", + "V6.vunpackh.128B" => "__builtin_HEXAGON_V6_vunpackh_128B", + "V6.vunpackob" => "__builtin_HEXAGON_V6_vunpackob", + "V6.vunpackob.128B" => "__builtin_HEXAGON_V6_vunpackob_128B", + "V6.vunpackoh" => "__builtin_HEXAGON_V6_vunpackoh", + "V6.vunpackoh.128B" => "__builtin_HEXAGON_V6_vunpackoh_128B", + "V6.vunpackub" => "__builtin_HEXAGON_V6_vunpackub", + "V6.vunpackub.128B" => "__builtin_HEXAGON_V6_vunpackub_128B", + "V6.vunpackuh" => "__builtin_HEXAGON_V6_vunpackuh", + "V6.vunpackuh.128B" => "__builtin_HEXAGON_V6_vunpackuh_128B", + "V6.vxor" => "__builtin_HEXAGON_V6_vxor", + "V6.vxor.128B" => "__builtin_HEXAGON_V6_vxor_128B", + "V6.vzb" => "__builtin_HEXAGON_V6_vzb", + "V6.vzb.128B" => "__builtin_HEXAGON_V6_vzb_128B", + "V6.vzh" => "__builtin_HEXAGON_V6_vzh", + "V6.vzh.128B" => "__builtin_HEXAGON_V6_vzh_128B", + "Y2.dccleana" => "__builtin_HEXAGON_Y2_dccleana", + "Y2.dccleaninva" => "__builtin_HEXAGON_Y2_dccleaninva", + "Y2.dcfetch" => "__builtin_HEXAGON_Y2_dcfetch", + "Y2.dcinva" => "__builtin_HEXAGON_Y2_dcinva", + "Y2.dczeroa" => "__builtin_HEXAGON_Y2_dczeroa", + "Y4.l2fetch" => "__builtin_HEXAGON_Y4_l2fetch", + "Y5.l2fetch" => "__builtin_HEXAGON_Y5_l2fetch", + "Y6.dmlink" => "__builtin_HEXAGON_Y6_dmlink", + "Y6.dmpause" => "__builtin_HEXAGON_Y6_dmpause", + "Y6.dmpoll" => "__builtin_HEXAGON_Y6_dmpoll", + "Y6.dmresume" => "__builtin_HEXAGON_Y6_dmresume", + "Y6.dmstart" => "__builtin_HEXAGON_Y6_dmstart", + "Y6.dmwait" => "__builtin_HEXAGON_Y6_dmwait", + "brev.ldb" => "__builtin_brev_ldb", + "brev.ldd" => "__builtin_brev_ldd", + "brev.ldh" => "__builtin_brev_ldh", + "brev.ldub" => "__builtin_brev_ldub", + "brev.lduh" => "__builtin_brev_lduh", + "brev.ldw" => "__builtin_brev_ldw", + "brev.stb" => "__builtin_brev_stb", + "brev.std" => "__builtin_brev_std", + "brev.sth" => "__builtin_brev_sth", + "brev.sthhi" => "__builtin_brev_sthhi", + "brev.stw" => "__builtin_brev_stw", + "circ.ldb" => "__builtin_circ_ldb", + "circ.ldd" => "__builtin_circ_ldd", + "circ.ldh" => "__builtin_circ_ldh", + "circ.ldub" => "__builtin_circ_ldub", + "circ.lduh" => "__builtin_circ_lduh", + "circ.ldw" => "__builtin_circ_ldw", + "circ.stb" => "__builtin_circ_stb", + "circ.std" => "__builtin_circ_std", + "circ.sth" => "__builtin_circ_sth", + "circ.sthhi" => "__builtin_circ_sthhi", + "circ.stw" => "__builtin_circ_stw", + "mm256i.vaddw" => "__builtin__mm256i_vaddw", + "prefetch" => "__builtin_HEXAGON_prefetch", + "vmemcpy" => "__builtin_hexagon_vmemcpy", + "vmemset" => "__builtin_hexagon_vmemset", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + hexagon(name, full_name) + } + "loongarch" => { + #[allow(non_snake_case)] + fn loongarch(name: &str, full_name: &str) -> &'static str { + match name { + // loongarch + "asrtgt.d" => "__builtin_loongarch_asrtgt_d", + "asrtle.d" => "__builtin_loongarch_asrtle_d", + "break" => "__builtin_loongarch_break", + "cacop.d" => "__builtin_loongarch_cacop_d", + "cacop.w" => "__builtin_loongarch_cacop_w", + "cpucfg" => "__builtin_loongarch_cpucfg", + "crc.w.b.w" => "__builtin_loongarch_crc_w_b_w", + "crc.w.d.w" => "__builtin_loongarch_crc_w_d_w", + "crc.w.h.w" => "__builtin_loongarch_crc_w_h_w", + "crc.w.w.w" => "__builtin_loongarch_crc_w_w_w", + "crcc.w.b.w" => "__builtin_loongarch_crcc_w_b_w", + "crcc.w.d.w" => "__builtin_loongarch_crcc_w_d_w", + "crcc.w.h.w" => "__builtin_loongarch_crcc_w_h_w", + "crcc.w.w.w" => "__builtin_loongarch_crcc_w_w_w", + "csrrd.d" => "__builtin_loongarch_csrrd_d", + "csrrd.w" => "__builtin_loongarch_csrrd_w", + "csrwr.d" => "__builtin_loongarch_csrwr_d", + "csrwr.w" => "__builtin_loongarch_csrwr_w", + "csrxchg.d" => "__builtin_loongarch_csrxchg_d", + "csrxchg.w" => "__builtin_loongarch_csrxchg_w", + "dbar" => "__builtin_loongarch_dbar", + "frecipe.d" => "__builtin_loongarch_frecipe_d", + "frecipe.s" => "__builtin_loongarch_frecipe_s", + "frsqrte.d" => "__builtin_loongarch_frsqrte_d", + "frsqrte.s" => "__builtin_loongarch_frsqrte_s", + "ibar" => "__builtin_loongarch_ibar", + "iocsrrd.b" => "__builtin_loongarch_iocsrrd_b", + "iocsrrd.d" => "__builtin_loongarch_iocsrrd_d", + "iocsrrd.h" => "__builtin_loongarch_iocsrrd_h", + "iocsrrd.w" => "__builtin_loongarch_iocsrrd_w", + "iocsrwr.b" => "__builtin_loongarch_iocsrwr_b", + "iocsrwr.d" => "__builtin_loongarch_iocsrwr_d", + "iocsrwr.h" => "__builtin_loongarch_iocsrwr_h", + "iocsrwr.w" => "__builtin_loongarch_iocsrwr_w", + "lasx.vext2xv.d.b" => "__builtin_lasx_vext2xv_d_b", + "lasx.vext2xv.d.h" => "__builtin_lasx_vext2xv_d_h", + "lasx.vext2xv.d.w" => "__builtin_lasx_vext2xv_d_w", + "lasx.vext2xv.du.bu" => "__builtin_lasx_vext2xv_du_bu", + "lasx.vext2xv.du.hu" => "__builtin_lasx_vext2xv_du_hu", + "lasx.vext2xv.du.wu" => "__builtin_lasx_vext2xv_du_wu", + "lasx.vext2xv.h.b" => "__builtin_lasx_vext2xv_h_b", + "lasx.vext2xv.hu.bu" => "__builtin_lasx_vext2xv_hu_bu", + "lasx.vext2xv.w.b" => "__builtin_lasx_vext2xv_w_b", + "lasx.vext2xv.w.h" => "__builtin_lasx_vext2xv_w_h", + "lasx.vext2xv.wu.bu" => "__builtin_lasx_vext2xv_wu_bu", + "lasx.vext2xv.wu.hu" => "__builtin_lasx_vext2xv_wu_hu", + "lasx.xbnz.b" => "__builtin_lasx_xbnz_b", + "lasx.xbnz.d" => "__builtin_lasx_xbnz_d", + "lasx.xbnz.h" => "__builtin_lasx_xbnz_h", + "lasx.xbnz.v" => "__builtin_lasx_xbnz_v", + "lasx.xbnz.w" => "__builtin_lasx_xbnz_w", + "lasx.xbz.b" => "__builtin_lasx_xbz_b", + "lasx.xbz.d" => "__builtin_lasx_xbz_d", + "lasx.xbz.h" => "__builtin_lasx_xbz_h", + "lasx.xbz.v" => "__builtin_lasx_xbz_v", + "lasx.xbz.w" => "__builtin_lasx_xbz_w", + "lasx.xvabsd.b" => "__builtin_lasx_xvabsd_b", + "lasx.xvabsd.bu" => "__builtin_lasx_xvabsd_bu", + "lasx.xvabsd.d" => "__builtin_lasx_xvabsd_d", + "lasx.xvabsd.du" => "__builtin_lasx_xvabsd_du", + "lasx.xvabsd.h" => "__builtin_lasx_xvabsd_h", + "lasx.xvabsd.hu" => "__builtin_lasx_xvabsd_hu", + "lasx.xvabsd.w" => "__builtin_lasx_xvabsd_w", + "lasx.xvabsd.wu" => "__builtin_lasx_xvabsd_wu", + "lasx.xvadd.b" => "__builtin_lasx_xvadd_b", + "lasx.xvadd.d" => "__builtin_lasx_xvadd_d", + "lasx.xvadd.h" => "__builtin_lasx_xvadd_h", + "lasx.xvadd.q" => "__builtin_lasx_xvadd_q", + "lasx.xvadd.w" => "__builtin_lasx_xvadd_w", + "lasx.xvadda.b" => "__builtin_lasx_xvadda_b", + "lasx.xvadda.d" => "__builtin_lasx_xvadda_d", + "lasx.xvadda.h" => "__builtin_lasx_xvadda_h", + "lasx.xvadda.w" => "__builtin_lasx_xvadda_w", + "lasx.xvaddi.bu" => "__builtin_lasx_xvaddi_bu", + "lasx.xvaddi.du" => "__builtin_lasx_xvaddi_du", + "lasx.xvaddi.hu" => "__builtin_lasx_xvaddi_hu", + "lasx.xvaddi.wu" => "__builtin_lasx_xvaddi_wu", + "lasx.xvaddwev.d.w" => "__builtin_lasx_xvaddwev_d_w", + "lasx.xvaddwev.d.wu" => "__builtin_lasx_xvaddwev_d_wu", + "lasx.xvaddwev.d.wu.w" => "__builtin_lasx_xvaddwev_d_wu_w", + "lasx.xvaddwev.h.b" => "__builtin_lasx_xvaddwev_h_b", + "lasx.xvaddwev.h.bu" => "__builtin_lasx_xvaddwev_h_bu", + "lasx.xvaddwev.h.bu.b" => "__builtin_lasx_xvaddwev_h_bu_b", + "lasx.xvaddwev.q.d" => "__builtin_lasx_xvaddwev_q_d", + "lasx.xvaddwev.q.du" => "__builtin_lasx_xvaddwev_q_du", + "lasx.xvaddwev.q.du.d" => "__builtin_lasx_xvaddwev_q_du_d", + "lasx.xvaddwev.w.h" => "__builtin_lasx_xvaddwev_w_h", + "lasx.xvaddwev.w.hu" => "__builtin_lasx_xvaddwev_w_hu", + "lasx.xvaddwev.w.hu.h" => "__builtin_lasx_xvaddwev_w_hu_h", + "lasx.xvaddwod.d.w" => "__builtin_lasx_xvaddwod_d_w", + "lasx.xvaddwod.d.wu" => "__builtin_lasx_xvaddwod_d_wu", + "lasx.xvaddwod.d.wu.w" => "__builtin_lasx_xvaddwod_d_wu_w", + "lasx.xvaddwod.h.b" => "__builtin_lasx_xvaddwod_h_b", + "lasx.xvaddwod.h.bu" => "__builtin_lasx_xvaddwod_h_bu", + "lasx.xvaddwod.h.bu.b" => "__builtin_lasx_xvaddwod_h_bu_b", + "lasx.xvaddwod.q.d" => "__builtin_lasx_xvaddwod_q_d", + "lasx.xvaddwod.q.du" => "__builtin_lasx_xvaddwod_q_du", + "lasx.xvaddwod.q.du.d" => "__builtin_lasx_xvaddwod_q_du_d", + "lasx.xvaddwod.w.h" => "__builtin_lasx_xvaddwod_w_h", + "lasx.xvaddwod.w.hu" => "__builtin_lasx_xvaddwod_w_hu", + "lasx.xvaddwod.w.hu.h" => "__builtin_lasx_xvaddwod_w_hu_h", + "lasx.xvand.v" => "__builtin_lasx_xvand_v", + "lasx.xvandi.b" => "__builtin_lasx_xvandi_b", + "lasx.xvandn.v" => "__builtin_lasx_xvandn_v", + "lasx.xvavg.b" => "__builtin_lasx_xvavg_b", + "lasx.xvavg.bu" => "__builtin_lasx_xvavg_bu", + "lasx.xvavg.d" => "__builtin_lasx_xvavg_d", + "lasx.xvavg.du" => "__builtin_lasx_xvavg_du", + "lasx.xvavg.h" => "__builtin_lasx_xvavg_h", + "lasx.xvavg.hu" => "__builtin_lasx_xvavg_hu", + "lasx.xvavg.w" => "__builtin_lasx_xvavg_w", + "lasx.xvavg.wu" => "__builtin_lasx_xvavg_wu", + "lasx.xvavgr.b" => "__builtin_lasx_xvavgr_b", + "lasx.xvavgr.bu" => "__builtin_lasx_xvavgr_bu", + "lasx.xvavgr.d" => "__builtin_lasx_xvavgr_d", + "lasx.xvavgr.du" => "__builtin_lasx_xvavgr_du", + "lasx.xvavgr.h" => "__builtin_lasx_xvavgr_h", + "lasx.xvavgr.hu" => "__builtin_lasx_xvavgr_hu", + "lasx.xvavgr.w" => "__builtin_lasx_xvavgr_w", + "lasx.xvavgr.wu" => "__builtin_lasx_xvavgr_wu", + "lasx.xvbitclr.b" => "__builtin_lasx_xvbitclr_b", + "lasx.xvbitclr.d" => "__builtin_lasx_xvbitclr_d", + "lasx.xvbitclr.h" => "__builtin_lasx_xvbitclr_h", + "lasx.xvbitclr.w" => "__builtin_lasx_xvbitclr_w", + "lasx.xvbitclri.b" => "__builtin_lasx_xvbitclri_b", + "lasx.xvbitclri.d" => "__builtin_lasx_xvbitclri_d", + "lasx.xvbitclri.h" => "__builtin_lasx_xvbitclri_h", + "lasx.xvbitclri.w" => "__builtin_lasx_xvbitclri_w", + "lasx.xvbitrev.b" => "__builtin_lasx_xvbitrev_b", + "lasx.xvbitrev.d" => "__builtin_lasx_xvbitrev_d", + "lasx.xvbitrev.h" => "__builtin_lasx_xvbitrev_h", + "lasx.xvbitrev.w" => "__builtin_lasx_xvbitrev_w", + "lasx.xvbitrevi.b" => "__builtin_lasx_xvbitrevi_b", + "lasx.xvbitrevi.d" => "__builtin_lasx_xvbitrevi_d", + "lasx.xvbitrevi.h" => "__builtin_lasx_xvbitrevi_h", + "lasx.xvbitrevi.w" => "__builtin_lasx_xvbitrevi_w", + "lasx.xvbitsel.v" => "__builtin_lasx_xvbitsel_v", + "lasx.xvbitseli.b" => "__builtin_lasx_xvbitseli_b", + "lasx.xvbitset.b" => "__builtin_lasx_xvbitset_b", + "lasx.xvbitset.d" => "__builtin_lasx_xvbitset_d", + "lasx.xvbitset.h" => "__builtin_lasx_xvbitset_h", + "lasx.xvbitset.w" => "__builtin_lasx_xvbitset_w", + "lasx.xvbitseti.b" => "__builtin_lasx_xvbitseti_b", + "lasx.xvbitseti.d" => "__builtin_lasx_xvbitseti_d", + "lasx.xvbitseti.h" => "__builtin_lasx_xvbitseti_h", + "lasx.xvbitseti.w" => "__builtin_lasx_xvbitseti_w", + "lasx.xvbsll.v" => "__builtin_lasx_xvbsll_v", + "lasx.xvbsrl.v" => "__builtin_lasx_xvbsrl_v", + "lasx.xvclo.b" => "__builtin_lasx_xvclo_b", + "lasx.xvclo.d" => "__builtin_lasx_xvclo_d", + "lasx.xvclo.h" => "__builtin_lasx_xvclo_h", + "lasx.xvclo.w" => "__builtin_lasx_xvclo_w", + "lasx.xvclz.b" => "__builtin_lasx_xvclz_b", + "lasx.xvclz.d" => "__builtin_lasx_xvclz_d", + "lasx.xvclz.h" => "__builtin_lasx_xvclz_h", + "lasx.xvclz.w" => "__builtin_lasx_xvclz_w", + "lasx.xvdiv.b" => "__builtin_lasx_xvdiv_b", + "lasx.xvdiv.bu" => "__builtin_lasx_xvdiv_bu", + "lasx.xvdiv.d" => "__builtin_lasx_xvdiv_d", + "lasx.xvdiv.du" => "__builtin_lasx_xvdiv_du", + "lasx.xvdiv.h" => "__builtin_lasx_xvdiv_h", + "lasx.xvdiv.hu" => "__builtin_lasx_xvdiv_hu", + "lasx.xvdiv.w" => "__builtin_lasx_xvdiv_w", + "lasx.xvdiv.wu" => "__builtin_lasx_xvdiv_wu", + "lasx.xvexth.d.w" => "__builtin_lasx_xvexth_d_w", + "lasx.xvexth.du.wu" => "__builtin_lasx_xvexth_du_wu", + "lasx.xvexth.h.b" => "__builtin_lasx_xvexth_h_b", + "lasx.xvexth.hu.bu" => "__builtin_lasx_xvexth_hu_bu", + "lasx.xvexth.q.d" => "__builtin_lasx_xvexth_q_d", + "lasx.xvexth.qu.du" => "__builtin_lasx_xvexth_qu_du", + "lasx.xvexth.w.h" => "__builtin_lasx_xvexth_w_h", + "lasx.xvexth.wu.hu" => "__builtin_lasx_xvexth_wu_hu", + "lasx.xvextl.q.d" => "__builtin_lasx_xvextl_q_d", + "lasx.xvextl.qu.du" => "__builtin_lasx_xvextl_qu_du", + "lasx.xvextrins.b" => "__builtin_lasx_xvextrins_b", + "lasx.xvextrins.d" => "__builtin_lasx_xvextrins_d", + "lasx.xvextrins.h" => "__builtin_lasx_xvextrins_h", + "lasx.xvextrins.w" => "__builtin_lasx_xvextrins_w", + "lasx.xvfadd.d" => "__builtin_lasx_xvfadd_d", + "lasx.xvfadd.s" => "__builtin_lasx_xvfadd_s", + "lasx.xvfclass.d" => "__builtin_lasx_xvfclass_d", + "lasx.xvfclass.s" => "__builtin_lasx_xvfclass_s", + "lasx.xvfcmp.caf.d" => "__builtin_lasx_xvfcmp_caf_d", + "lasx.xvfcmp.caf.s" => "__builtin_lasx_xvfcmp_caf_s", + "lasx.xvfcmp.ceq.d" => "__builtin_lasx_xvfcmp_ceq_d", + "lasx.xvfcmp.ceq.s" => "__builtin_lasx_xvfcmp_ceq_s", + "lasx.xvfcmp.cle.d" => "__builtin_lasx_xvfcmp_cle_d", + "lasx.xvfcmp.cle.s" => "__builtin_lasx_xvfcmp_cle_s", + "lasx.xvfcmp.clt.d" => "__builtin_lasx_xvfcmp_clt_d", + "lasx.xvfcmp.clt.s" => "__builtin_lasx_xvfcmp_clt_s", + "lasx.xvfcmp.cne.d" => "__builtin_lasx_xvfcmp_cne_d", + "lasx.xvfcmp.cne.s" => "__builtin_lasx_xvfcmp_cne_s", + "lasx.xvfcmp.cor.d" => "__builtin_lasx_xvfcmp_cor_d", + "lasx.xvfcmp.cor.s" => "__builtin_lasx_xvfcmp_cor_s", + "lasx.xvfcmp.cueq.d" => "__builtin_lasx_xvfcmp_cueq_d", + "lasx.xvfcmp.cueq.s" => "__builtin_lasx_xvfcmp_cueq_s", + "lasx.xvfcmp.cule.d" => "__builtin_lasx_xvfcmp_cule_d", + "lasx.xvfcmp.cule.s" => "__builtin_lasx_xvfcmp_cule_s", + "lasx.xvfcmp.cult.d" => "__builtin_lasx_xvfcmp_cult_d", + "lasx.xvfcmp.cult.s" => "__builtin_lasx_xvfcmp_cult_s", + "lasx.xvfcmp.cun.d" => "__builtin_lasx_xvfcmp_cun_d", + "lasx.xvfcmp.cun.s" => "__builtin_lasx_xvfcmp_cun_s", + "lasx.xvfcmp.cune.d" => "__builtin_lasx_xvfcmp_cune_d", + "lasx.xvfcmp.cune.s" => "__builtin_lasx_xvfcmp_cune_s", + "lasx.xvfcmp.saf.d" => "__builtin_lasx_xvfcmp_saf_d", + "lasx.xvfcmp.saf.s" => "__builtin_lasx_xvfcmp_saf_s", + "lasx.xvfcmp.seq.d" => "__builtin_lasx_xvfcmp_seq_d", + "lasx.xvfcmp.seq.s" => "__builtin_lasx_xvfcmp_seq_s", + "lasx.xvfcmp.sle.d" => "__builtin_lasx_xvfcmp_sle_d", + "lasx.xvfcmp.sle.s" => "__builtin_lasx_xvfcmp_sle_s", + "lasx.xvfcmp.slt.d" => "__builtin_lasx_xvfcmp_slt_d", + "lasx.xvfcmp.slt.s" => "__builtin_lasx_xvfcmp_slt_s", + "lasx.xvfcmp.sne.d" => "__builtin_lasx_xvfcmp_sne_d", + "lasx.xvfcmp.sne.s" => "__builtin_lasx_xvfcmp_sne_s", + "lasx.xvfcmp.sor.d" => "__builtin_lasx_xvfcmp_sor_d", + "lasx.xvfcmp.sor.s" => "__builtin_lasx_xvfcmp_sor_s", + "lasx.xvfcmp.sueq.d" => "__builtin_lasx_xvfcmp_sueq_d", + "lasx.xvfcmp.sueq.s" => "__builtin_lasx_xvfcmp_sueq_s", + "lasx.xvfcmp.sule.d" => "__builtin_lasx_xvfcmp_sule_d", + "lasx.xvfcmp.sule.s" => "__builtin_lasx_xvfcmp_sule_s", + "lasx.xvfcmp.sult.d" => "__builtin_lasx_xvfcmp_sult_d", + "lasx.xvfcmp.sult.s" => "__builtin_lasx_xvfcmp_sult_s", + "lasx.xvfcmp.sun.d" => "__builtin_lasx_xvfcmp_sun_d", + "lasx.xvfcmp.sun.s" => "__builtin_lasx_xvfcmp_sun_s", + "lasx.xvfcmp.sune.d" => "__builtin_lasx_xvfcmp_sune_d", + "lasx.xvfcmp.sune.s" => "__builtin_lasx_xvfcmp_sune_s", + "lasx.xvfcvt.h.s" => "__builtin_lasx_xvfcvt_h_s", + "lasx.xvfcvt.s.d" => "__builtin_lasx_xvfcvt_s_d", + "lasx.xvfcvth.d.s" => "__builtin_lasx_xvfcvth_d_s", + "lasx.xvfcvth.s.h" => "__builtin_lasx_xvfcvth_s_h", + "lasx.xvfcvtl.d.s" => "__builtin_lasx_xvfcvtl_d_s", + "lasx.xvfcvtl.s.h" => "__builtin_lasx_xvfcvtl_s_h", + "lasx.xvfdiv.d" => "__builtin_lasx_xvfdiv_d", + "lasx.xvfdiv.s" => "__builtin_lasx_xvfdiv_s", + "lasx.xvffint.d.l" => "__builtin_lasx_xvffint_d_l", + "lasx.xvffint.d.lu" => "__builtin_lasx_xvffint_d_lu", + "lasx.xvffint.s.l" => "__builtin_lasx_xvffint_s_l", + "lasx.xvffint.s.w" => "__builtin_lasx_xvffint_s_w", + "lasx.xvffint.s.wu" => "__builtin_lasx_xvffint_s_wu", + "lasx.xvffinth.d.w" => "__builtin_lasx_xvffinth_d_w", + "lasx.xvffintl.d.w" => "__builtin_lasx_xvffintl_d_w", + "lasx.xvflogb.d" => "__builtin_lasx_xvflogb_d", + "lasx.xvflogb.s" => "__builtin_lasx_xvflogb_s", + "lasx.xvfmadd.d" => "__builtin_lasx_xvfmadd_d", + "lasx.xvfmadd.s" => "__builtin_lasx_xvfmadd_s", + "lasx.xvfmax.d" => "__builtin_lasx_xvfmax_d", + "lasx.xvfmax.s" => "__builtin_lasx_xvfmax_s", + "lasx.xvfmaxa.d" => "__builtin_lasx_xvfmaxa_d", + "lasx.xvfmaxa.s" => "__builtin_lasx_xvfmaxa_s", + "lasx.xvfmin.d" => "__builtin_lasx_xvfmin_d", + "lasx.xvfmin.s" => "__builtin_lasx_xvfmin_s", + "lasx.xvfmina.d" => "__builtin_lasx_xvfmina_d", + "lasx.xvfmina.s" => "__builtin_lasx_xvfmina_s", + "lasx.xvfmsub.d" => "__builtin_lasx_xvfmsub_d", + "lasx.xvfmsub.s" => "__builtin_lasx_xvfmsub_s", + "lasx.xvfmul.d" => "__builtin_lasx_xvfmul_d", + "lasx.xvfmul.s" => "__builtin_lasx_xvfmul_s", + "lasx.xvfnmadd.d" => "__builtin_lasx_xvfnmadd_d", + "lasx.xvfnmadd.s" => "__builtin_lasx_xvfnmadd_s", + "lasx.xvfnmsub.d" => "__builtin_lasx_xvfnmsub_d", + "lasx.xvfnmsub.s" => "__builtin_lasx_xvfnmsub_s", + "lasx.xvfrecip.d" => "__builtin_lasx_xvfrecip_d", + "lasx.xvfrecip.s" => "__builtin_lasx_xvfrecip_s", + "lasx.xvfrecipe.d" => "__builtin_lasx_xvfrecipe_d", + "lasx.xvfrecipe.s" => "__builtin_lasx_xvfrecipe_s", + "lasx.xvfrint.d" => "__builtin_lasx_xvfrint_d", + "lasx.xvfrint.s" => "__builtin_lasx_xvfrint_s", + "lasx.xvfrintrm.d" => "__builtin_lasx_xvfrintrm_d", + "lasx.xvfrintrm.s" => "__builtin_lasx_xvfrintrm_s", + "lasx.xvfrintrne.d" => "__builtin_lasx_xvfrintrne_d", + "lasx.xvfrintrne.s" => "__builtin_lasx_xvfrintrne_s", + "lasx.xvfrintrp.d" => "__builtin_lasx_xvfrintrp_d", + "lasx.xvfrintrp.s" => "__builtin_lasx_xvfrintrp_s", + "lasx.xvfrintrz.d" => "__builtin_lasx_xvfrintrz_d", + "lasx.xvfrintrz.s" => "__builtin_lasx_xvfrintrz_s", + "lasx.xvfrsqrt.d" => "__builtin_lasx_xvfrsqrt_d", + "lasx.xvfrsqrt.s" => "__builtin_lasx_xvfrsqrt_s", + "lasx.xvfrsqrte.d" => "__builtin_lasx_xvfrsqrte_d", + "lasx.xvfrsqrte.s" => "__builtin_lasx_xvfrsqrte_s", + "lasx.xvfrstp.b" => "__builtin_lasx_xvfrstp_b", + "lasx.xvfrstp.h" => "__builtin_lasx_xvfrstp_h", + "lasx.xvfrstpi.b" => "__builtin_lasx_xvfrstpi_b", + "lasx.xvfrstpi.h" => "__builtin_lasx_xvfrstpi_h", + "lasx.xvfsqrt.d" => "__builtin_lasx_xvfsqrt_d", + "lasx.xvfsqrt.s" => "__builtin_lasx_xvfsqrt_s", + "lasx.xvfsub.d" => "__builtin_lasx_xvfsub_d", + "lasx.xvfsub.s" => "__builtin_lasx_xvfsub_s", + "lasx.xvftint.l.d" => "__builtin_lasx_xvftint_l_d", + "lasx.xvftint.lu.d" => "__builtin_lasx_xvftint_lu_d", + "lasx.xvftint.w.d" => "__builtin_lasx_xvftint_w_d", + "lasx.xvftint.w.s" => "__builtin_lasx_xvftint_w_s", + "lasx.xvftint.wu.s" => "__builtin_lasx_xvftint_wu_s", + "lasx.xvftinth.l.s" => "__builtin_lasx_xvftinth_l_s", + "lasx.xvftintl.l.s" => "__builtin_lasx_xvftintl_l_s", + "lasx.xvftintrm.l.d" => "__builtin_lasx_xvftintrm_l_d", + "lasx.xvftintrm.w.d" => "__builtin_lasx_xvftintrm_w_d", + "lasx.xvftintrm.w.s" => "__builtin_lasx_xvftintrm_w_s", + "lasx.xvftintrmh.l.s" => "__builtin_lasx_xvftintrmh_l_s", + "lasx.xvftintrml.l.s" => "__builtin_lasx_xvftintrml_l_s", + "lasx.xvftintrne.l.d" => "__builtin_lasx_xvftintrne_l_d", + "lasx.xvftintrne.w.d" => "__builtin_lasx_xvftintrne_w_d", + "lasx.xvftintrne.w.s" => "__builtin_lasx_xvftintrne_w_s", + "lasx.xvftintrneh.l.s" => "__builtin_lasx_xvftintrneh_l_s", + "lasx.xvftintrnel.l.s" => "__builtin_lasx_xvftintrnel_l_s", + "lasx.xvftintrp.l.d" => "__builtin_lasx_xvftintrp_l_d", + "lasx.xvftintrp.w.d" => "__builtin_lasx_xvftintrp_w_d", + "lasx.xvftintrp.w.s" => "__builtin_lasx_xvftintrp_w_s", + "lasx.xvftintrph.l.s" => "__builtin_lasx_xvftintrph_l_s", + "lasx.xvftintrpl.l.s" => "__builtin_lasx_xvftintrpl_l_s", + "lasx.xvftintrz.l.d" => "__builtin_lasx_xvftintrz_l_d", + "lasx.xvftintrz.lu.d" => "__builtin_lasx_xvftintrz_lu_d", + "lasx.xvftintrz.w.d" => "__builtin_lasx_xvftintrz_w_d", + "lasx.xvftintrz.w.s" => "__builtin_lasx_xvftintrz_w_s", + "lasx.xvftintrz.wu.s" => "__builtin_lasx_xvftintrz_wu_s", + "lasx.xvftintrzh.l.s" => "__builtin_lasx_xvftintrzh_l_s", + "lasx.xvftintrzl.l.s" => "__builtin_lasx_xvftintrzl_l_s", + "lasx.xvhaddw.d.w" => "__builtin_lasx_xvhaddw_d_w", + "lasx.xvhaddw.du.wu" => "__builtin_lasx_xvhaddw_du_wu", + "lasx.xvhaddw.h.b" => "__builtin_lasx_xvhaddw_h_b", + "lasx.xvhaddw.hu.bu" => "__builtin_lasx_xvhaddw_hu_bu", + "lasx.xvhaddw.q.d" => "__builtin_lasx_xvhaddw_q_d", + "lasx.xvhaddw.qu.du" => "__builtin_lasx_xvhaddw_qu_du", + "lasx.xvhaddw.w.h" => "__builtin_lasx_xvhaddw_w_h", + "lasx.xvhaddw.wu.hu" => "__builtin_lasx_xvhaddw_wu_hu", + "lasx.xvhsubw.d.w" => "__builtin_lasx_xvhsubw_d_w", + "lasx.xvhsubw.du.wu" => "__builtin_lasx_xvhsubw_du_wu", + "lasx.xvhsubw.h.b" => "__builtin_lasx_xvhsubw_h_b", + "lasx.xvhsubw.hu.bu" => "__builtin_lasx_xvhsubw_hu_bu", + "lasx.xvhsubw.q.d" => "__builtin_lasx_xvhsubw_q_d", + "lasx.xvhsubw.qu.du" => "__builtin_lasx_xvhsubw_qu_du", + "lasx.xvhsubw.w.h" => "__builtin_lasx_xvhsubw_w_h", + "lasx.xvhsubw.wu.hu" => "__builtin_lasx_xvhsubw_wu_hu", + "lasx.xvilvh.b" => "__builtin_lasx_xvilvh_b", + "lasx.xvilvh.d" => "__builtin_lasx_xvilvh_d", + "lasx.xvilvh.h" => "__builtin_lasx_xvilvh_h", + "lasx.xvilvh.w" => "__builtin_lasx_xvilvh_w", + "lasx.xvilvl.b" => "__builtin_lasx_xvilvl_b", + "lasx.xvilvl.d" => "__builtin_lasx_xvilvl_d", + "lasx.xvilvl.h" => "__builtin_lasx_xvilvl_h", + "lasx.xvilvl.w" => "__builtin_lasx_xvilvl_w", + "lasx.xvinsgr2vr.d" => "__builtin_lasx_xvinsgr2vr_d", + "lasx.xvinsgr2vr.w" => "__builtin_lasx_xvinsgr2vr_w", + "lasx.xvinsve0.d" => "__builtin_lasx_xvinsve0_d", + "lasx.xvinsve0.w" => "__builtin_lasx_xvinsve0_w", + "lasx.xvld" => "__builtin_lasx_xvld", + "lasx.xvldi" => "__builtin_lasx_xvldi", + "lasx.xvldrepl.b" => "__builtin_lasx_xvldrepl_b", + "lasx.xvldrepl.d" => "__builtin_lasx_xvldrepl_d", + "lasx.xvldrepl.h" => "__builtin_lasx_xvldrepl_h", + "lasx.xvldrepl.w" => "__builtin_lasx_xvldrepl_w", + "lasx.xvldx" => "__builtin_lasx_xvldx", + "lasx.xvmadd.b" => "__builtin_lasx_xvmadd_b", + "lasx.xvmadd.d" => "__builtin_lasx_xvmadd_d", + "lasx.xvmadd.h" => "__builtin_lasx_xvmadd_h", + "lasx.xvmadd.w" => "__builtin_lasx_xvmadd_w", + "lasx.xvmaddwev.d.w" => "__builtin_lasx_xvmaddwev_d_w", + "lasx.xvmaddwev.d.wu" => "__builtin_lasx_xvmaddwev_d_wu", + "lasx.xvmaddwev.d.wu.w" => "__builtin_lasx_xvmaddwev_d_wu_w", + "lasx.xvmaddwev.h.b" => "__builtin_lasx_xvmaddwev_h_b", + "lasx.xvmaddwev.h.bu" => "__builtin_lasx_xvmaddwev_h_bu", + "lasx.xvmaddwev.h.bu.b" => "__builtin_lasx_xvmaddwev_h_bu_b", + "lasx.xvmaddwev.q.d" => "__builtin_lasx_xvmaddwev_q_d", + "lasx.xvmaddwev.q.du" => "__builtin_lasx_xvmaddwev_q_du", + "lasx.xvmaddwev.q.du.d" => "__builtin_lasx_xvmaddwev_q_du_d", + "lasx.xvmaddwev.w.h" => "__builtin_lasx_xvmaddwev_w_h", + "lasx.xvmaddwev.w.hu" => "__builtin_lasx_xvmaddwev_w_hu", + "lasx.xvmaddwev.w.hu.h" => "__builtin_lasx_xvmaddwev_w_hu_h", + "lasx.xvmaddwod.d.w" => "__builtin_lasx_xvmaddwod_d_w", + "lasx.xvmaddwod.d.wu" => "__builtin_lasx_xvmaddwod_d_wu", + "lasx.xvmaddwod.d.wu.w" => "__builtin_lasx_xvmaddwod_d_wu_w", + "lasx.xvmaddwod.h.b" => "__builtin_lasx_xvmaddwod_h_b", + "lasx.xvmaddwod.h.bu" => "__builtin_lasx_xvmaddwod_h_bu", + "lasx.xvmaddwod.h.bu.b" => "__builtin_lasx_xvmaddwod_h_bu_b", + "lasx.xvmaddwod.q.d" => "__builtin_lasx_xvmaddwod_q_d", + "lasx.xvmaddwod.q.du" => "__builtin_lasx_xvmaddwod_q_du", + "lasx.xvmaddwod.q.du.d" => "__builtin_lasx_xvmaddwod_q_du_d", + "lasx.xvmaddwod.w.h" => "__builtin_lasx_xvmaddwod_w_h", + "lasx.xvmaddwod.w.hu" => "__builtin_lasx_xvmaddwod_w_hu", + "lasx.xvmaddwod.w.hu.h" => "__builtin_lasx_xvmaddwod_w_hu_h", + "lasx.xvmax.b" => "__builtin_lasx_xvmax_b", + "lasx.xvmax.bu" => "__builtin_lasx_xvmax_bu", + "lasx.xvmax.d" => "__builtin_lasx_xvmax_d", + "lasx.xvmax.du" => "__builtin_lasx_xvmax_du", + "lasx.xvmax.h" => "__builtin_lasx_xvmax_h", + "lasx.xvmax.hu" => "__builtin_lasx_xvmax_hu", + "lasx.xvmax.w" => "__builtin_lasx_xvmax_w", + "lasx.xvmax.wu" => "__builtin_lasx_xvmax_wu", + "lasx.xvmaxi.b" => "__builtin_lasx_xvmaxi_b", + "lasx.xvmaxi.bu" => "__builtin_lasx_xvmaxi_bu", + "lasx.xvmaxi.d" => "__builtin_lasx_xvmaxi_d", + "lasx.xvmaxi.du" => "__builtin_lasx_xvmaxi_du", + "lasx.xvmaxi.h" => "__builtin_lasx_xvmaxi_h", + "lasx.xvmaxi.hu" => "__builtin_lasx_xvmaxi_hu", + "lasx.xvmaxi.w" => "__builtin_lasx_xvmaxi_w", + "lasx.xvmaxi.wu" => "__builtin_lasx_xvmaxi_wu", + "lasx.xvmin.b" => "__builtin_lasx_xvmin_b", + "lasx.xvmin.bu" => "__builtin_lasx_xvmin_bu", + "lasx.xvmin.d" => "__builtin_lasx_xvmin_d", + "lasx.xvmin.du" => "__builtin_lasx_xvmin_du", + "lasx.xvmin.h" => "__builtin_lasx_xvmin_h", + "lasx.xvmin.hu" => "__builtin_lasx_xvmin_hu", + "lasx.xvmin.w" => "__builtin_lasx_xvmin_w", + "lasx.xvmin.wu" => "__builtin_lasx_xvmin_wu", + "lasx.xvmini.b" => "__builtin_lasx_xvmini_b", + "lasx.xvmini.bu" => "__builtin_lasx_xvmini_bu", + "lasx.xvmini.d" => "__builtin_lasx_xvmini_d", + "lasx.xvmini.du" => "__builtin_lasx_xvmini_du", + "lasx.xvmini.h" => "__builtin_lasx_xvmini_h", + "lasx.xvmini.hu" => "__builtin_lasx_xvmini_hu", + "lasx.xvmini.w" => "__builtin_lasx_xvmini_w", + "lasx.xvmini.wu" => "__builtin_lasx_xvmini_wu", + "lasx.xvmod.b" => "__builtin_lasx_xvmod_b", + "lasx.xvmod.bu" => "__builtin_lasx_xvmod_bu", + "lasx.xvmod.d" => "__builtin_lasx_xvmod_d", + "lasx.xvmod.du" => "__builtin_lasx_xvmod_du", + "lasx.xvmod.h" => "__builtin_lasx_xvmod_h", + "lasx.xvmod.hu" => "__builtin_lasx_xvmod_hu", + "lasx.xvmod.w" => "__builtin_lasx_xvmod_w", + "lasx.xvmod.wu" => "__builtin_lasx_xvmod_wu", + "lasx.xvmskgez.b" => "__builtin_lasx_xvmskgez_b", + "lasx.xvmskltz.b" => "__builtin_lasx_xvmskltz_b", + "lasx.xvmskltz.d" => "__builtin_lasx_xvmskltz_d", + "lasx.xvmskltz.h" => "__builtin_lasx_xvmskltz_h", + "lasx.xvmskltz.w" => "__builtin_lasx_xvmskltz_w", + "lasx.xvmsknz.b" => "__builtin_lasx_xvmsknz_b", + "lasx.xvmsub.b" => "__builtin_lasx_xvmsub_b", + "lasx.xvmsub.d" => "__builtin_lasx_xvmsub_d", + "lasx.xvmsub.h" => "__builtin_lasx_xvmsub_h", + "lasx.xvmsub.w" => "__builtin_lasx_xvmsub_w", + "lasx.xvmuh.b" => "__builtin_lasx_xvmuh_b", + "lasx.xvmuh.bu" => "__builtin_lasx_xvmuh_bu", + "lasx.xvmuh.d" => "__builtin_lasx_xvmuh_d", + "lasx.xvmuh.du" => "__builtin_lasx_xvmuh_du", + "lasx.xvmuh.h" => "__builtin_lasx_xvmuh_h", + "lasx.xvmuh.hu" => "__builtin_lasx_xvmuh_hu", + "lasx.xvmuh.w" => "__builtin_lasx_xvmuh_w", + "lasx.xvmuh.wu" => "__builtin_lasx_xvmuh_wu", + "lasx.xvmul.b" => "__builtin_lasx_xvmul_b", + "lasx.xvmul.d" => "__builtin_lasx_xvmul_d", + "lasx.xvmul.h" => "__builtin_lasx_xvmul_h", + "lasx.xvmul.w" => "__builtin_lasx_xvmul_w", + "lasx.xvmulwev.d.w" => "__builtin_lasx_xvmulwev_d_w", + "lasx.xvmulwev.d.wu" => "__builtin_lasx_xvmulwev_d_wu", + "lasx.xvmulwev.d.wu.w" => "__builtin_lasx_xvmulwev_d_wu_w", + "lasx.xvmulwev.h.b" => "__builtin_lasx_xvmulwev_h_b", + "lasx.xvmulwev.h.bu" => "__builtin_lasx_xvmulwev_h_bu", + "lasx.xvmulwev.h.bu.b" => "__builtin_lasx_xvmulwev_h_bu_b", + "lasx.xvmulwev.q.d" => "__builtin_lasx_xvmulwev_q_d", + "lasx.xvmulwev.q.du" => "__builtin_lasx_xvmulwev_q_du", + "lasx.xvmulwev.q.du.d" => "__builtin_lasx_xvmulwev_q_du_d", + "lasx.xvmulwev.w.h" => "__builtin_lasx_xvmulwev_w_h", + "lasx.xvmulwev.w.hu" => "__builtin_lasx_xvmulwev_w_hu", + "lasx.xvmulwev.w.hu.h" => "__builtin_lasx_xvmulwev_w_hu_h", + "lasx.xvmulwod.d.w" => "__builtin_lasx_xvmulwod_d_w", + "lasx.xvmulwod.d.wu" => "__builtin_lasx_xvmulwod_d_wu", + "lasx.xvmulwod.d.wu.w" => "__builtin_lasx_xvmulwod_d_wu_w", + "lasx.xvmulwod.h.b" => "__builtin_lasx_xvmulwod_h_b", + "lasx.xvmulwod.h.bu" => "__builtin_lasx_xvmulwod_h_bu", + "lasx.xvmulwod.h.bu.b" => "__builtin_lasx_xvmulwod_h_bu_b", + "lasx.xvmulwod.q.d" => "__builtin_lasx_xvmulwod_q_d", + "lasx.xvmulwod.q.du" => "__builtin_lasx_xvmulwod_q_du", + "lasx.xvmulwod.q.du.d" => "__builtin_lasx_xvmulwod_q_du_d", + "lasx.xvmulwod.w.h" => "__builtin_lasx_xvmulwod_w_h", + "lasx.xvmulwod.w.hu" => "__builtin_lasx_xvmulwod_w_hu", + "lasx.xvmulwod.w.hu.h" => "__builtin_lasx_xvmulwod_w_hu_h", + "lasx.xvneg.b" => "__builtin_lasx_xvneg_b", + "lasx.xvneg.d" => "__builtin_lasx_xvneg_d", + "lasx.xvneg.h" => "__builtin_lasx_xvneg_h", + "lasx.xvneg.w" => "__builtin_lasx_xvneg_w", + "lasx.xvnor.v" => "__builtin_lasx_xvnor_v", + "lasx.xvnori.b" => "__builtin_lasx_xvnori_b", + "lasx.xvor.v" => "__builtin_lasx_xvor_v", + "lasx.xvori.b" => "__builtin_lasx_xvori_b", + "lasx.xvorn.v" => "__builtin_lasx_xvorn_v", + "lasx.xvpackev.b" => "__builtin_lasx_xvpackev_b", + "lasx.xvpackev.d" => "__builtin_lasx_xvpackev_d", + "lasx.xvpackev.h" => "__builtin_lasx_xvpackev_h", + "lasx.xvpackev.w" => "__builtin_lasx_xvpackev_w", + "lasx.xvpackod.b" => "__builtin_lasx_xvpackod_b", + "lasx.xvpackod.d" => "__builtin_lasx_xvpackod_d", + "lasx.xvpackod.h" => "__builtin_lasx_xvpackod_h", + "lasx.xvpackod.w" => "__builtin_lasx_xvpackod_w", + "lasx.xvpcnt.b" => "__builtin_lasx_xvpcnt_b", + "lasx.xvpcnt.d" => "__builtin_lasx_xvpcnt_d", + "lasx.xvpcnt.h" => "__builtin_lasx_xvpcnt_h", + "lasx.xvpcnt.w" => "__builtin_lasx_xvpcnt_w", + "lasx.xvperm.w" => "__builtin_lasx_xvperm_w", + "lasx.xvpermi.d" => "__builtin_lasx_xvpermi_d", + "lasx.xvpermi.q" => "__builtin_lasx_xvpermi_q", + "lasx.xvpermi.w" => "__builtin_lasx_xvpermi_w", + "lasx.xvpickev.b" => "__builtin_lasx_xvpickev_b", + "lasx.xvpickev.d" => "__builtin_lasx_xvpickev_d", + "lasx.xvpickev.h" => "__builtin_lasx_xvpickev_h", + "lasx.xvpickev.w" => "__builtin_lasx_xvpickev_w", + "lasx.xvpickod.b" => "__builtin_lasx_xvpickod_b", + "lasx.xvpickod.d" => "__builtin_lasx_xvpickod_d", + "lasx.xvpickod.h" => "__builtin_lasx_xvpickod_h", + "lasx.xvpickod.w" => "__builtin_lasx_xvpickod_w", + "lasx.xvpickve.d" => "__builtin_lasx_xvpickve_d", + "lasx.xvpickve.d.f" => "__builtin_lasx_xvpickve_d_f", + "lasx.xvpickve.w" => "__builtin_lasx_xvpickve_w", + "lasx.xvpickve.w.f" => "__builtin_lasx_xvpickve_w_f", + "lasx.xvpickve2gr.d" => "__builtin_lasx_xvpickve2gr_d", + "lasx.xvpickve2gr.du" => "__builtin_lasx_xvpickve2gr_du", + "lasx.xvpickve2gr.w" => "__builtin_lasx_xvpickve2gr_w", + "lasx.xvpickve2gr.wu" => "__builtin_lasx_xvpickve2gr_wu", + "lasx.xvrepl128vei.b" => "__builtin_lasx_xvrepl128vei_b", + "lasx.xvrepl128vei.d" => "__builtin_lasx_xvrepl128vei_d", + "lasx.xvrepl128vei.h" => "__builtin_lasx_xvrepl128vei_h", + "lasx.xvrepl128vei.w" => "__builtin_lasx_xvrepl128vei_w", + "lasx.xvreplgr2vr.b" => "__builtin_lasx_xvreplgr2vr_b", + "lasx.xvreplgr2vr.d" => "__builtin_lasx_xvreplgr2vr_d", + "lasx.xvreplgr2vr.h" => "__builtin_lasx_xvreplgr2vr_h", + "lasx.xvreplgr2vr.w" => "__builtin_lasx_xvreplgr2vr_w", + "lasx.xvrepli.b" => "__builtin_lasx_xvrepli_b", + "lasx.xvrepli.d" => "__builtin_lasx_xvrepli_d", + "lasx.xvrepli.h" => "__builtin_lasx_xvrepli_h", + "lasx.xvrepli.w" => "__builtin_lasx_xvrepli_w", + "lasx.xvreplve.b" => "__builtin_lasx_xvreplve_b", + "lasx.xvreplve.d" => "__builtin_lasx_xvreplve_d", + "lasx.xvreplve.h" => "__builtin_lasx_xvreplve_h", + "lasx.xvreplve.w" => "__builtin_lasx_xvreplve_w", + "lasx.xvreplve0.b" => "__builtin_lasx_xvreplve0_b", + "lasx.xvreplve0.d" => "__builtin_lasx_xvreplve0_d", + "lasx.xvreplve0.h" => "__builtin_lasx_xvreplve0_h", + "lasx.xvreplve0.q" => "__builtin_lasx_xvreplve0_q", + "lasx.xvreplve0.w" => "__builtin_lasx_xvreplve0_w", + "lasx.xvrotr.b" => "__builtin_lasx_xvrotr_b", + "lasx.xvrotr.d" => "__builtin_lasx_xvrotr_d", + "lasx.xvrotr.h" => "__builtin_lasx_xvrotr_h", + "lasx.xvrotr.w" => "__builtin_lasx_xvrotr_w", + "lasx.xvrotri.b" => "__builtin_lasx_xvrotri_b", + "lasx.xvrotri.d" => "__builtin_lasx_xvrotri_d", + "lasx.xvrotri.h" => "__builtin_lasx_xvrotri_h", + "lasx.xvrotri.w" => "__builtin_lasx_xvrotri_w", + "lasx.xvsadd.b" => "__builtin_lasx_xvsadd_b", + "lasx.xvsadd.bu" => "__builtin_lasx_xvsadd_bu", + "lasx.xvsadd.d" => "__builtin_lasx_xvsadd_d", + "lasx.xvsadd.du" => "__builtin_lasx_xvsadd_du", + "lasx.xvsadd.h" => "__builtin_lasx_xvsadd_h", + "lasx.xvsadd.hu" => "__builtin_lasx_xvsadd_hu", + "lasx.xvsadd.w" => "__builtin_lasx_xvsadd_w", + "lasx.xvsadd.wu" => "__builtin_lasx_xvsadd_wu", + "lasx.xvsat.b" => "__builtin_lasx_xvsat_b", + "lasx.xvsat.bu" => "__builtin_lasx_xvsat_bu", + "lasx.xvsat.d" => "__builtin_lasx_xvsat_d", + "lasx.xvsat.du" => "__builtin_lasx_xvsat_du", + "lasx.xvsat.h" => "__builtin_lasx_xvsat_h", + "lasx.xvsat.hu" => "__builtin_lasx_xvsat_hu", + "lasx.xvsat.w" => "__builtin_lasx_xvsat_w", + "lasx.xvsat.wu" => "__builtin_lasx_xvsat_wu", + "lasx.xvseq.b" => "__builtin_lasx_xvseq_b", + "lasx.xvseq.d" => "__builtin_lasx_xvseq_d", + "lasx.xvseq.h" => "__builtin_lasx_xvseq_h", + "lasx.xvseq.w" => "__builtin_lasx_xvseq_w", + "lasx.xvseqi.b" => "__builtin_lasx_xvseqi_b", + "lasx.xvseqi.d" => "__builtin_lasx_xvseqi_d", + "lasx.xvseqi.h" => "__builtin_lasx_xvseqi_h", + "lasx.xvseqi.w" => "__builtin_lasx_xvseqi_w", + "lasx.xvshuf.b" => "__builtin_lasx_xvshuf_b", + "lasx.xvshuf.d" => "__builtin_lasx_xvshuf_d", + "lasx.xvshuf.h" => "__builtin_lasx_xvshuf_h", + "lasx.xvshuf.w" => "__builtin_lasx_xvshuf_w", + "lasx.xvshuf4i.b" => "__builtin_lasx_xvshuf4i_b", + "lasx.xvshuf4i.d" => "__builtin_lasx_xvshuf4i_d", + "lasx.xvshuf4i.h" => "__builtin_lasx_xvshuf4i_h", + "lasx.xvshuf4i.w" => "__builtin_lasx_xvshuf4i_w", + "lasx.xvsigncov.b" => "__builtin_lasx_xvsigncov_b", + "lasx.xvsigncov.d" => "__builtin_lasx_xvsigncov_d", + "lasx.xvsigncov.h" => "__builtin_lasx_xvsigncov_h", + "lasx.xvsigncov.w" => "__builtin_lasx_xvsigncov_w", + "lasx.xvsle.b" => "__builtin_lasx_xvsle_b", + "lasx.xvsle.bu" => "__builtin_lasx_xvsle_bu", + "lasx.xvsle.d" => "__builtin_lasx_xvsle_d", + "lasx.xvsle.du" => "__builtin_lasx_xvsle_du", + "lasx.xvsle.h" => "__builtin_lasx_xvsle_h", + "lasx.xvsle.hu" => "__builtin_lasx_xvsle_hu", + "lasx.xvsle.w" => "__builtin_lasx_xvsle_w", + "lasx.xvsle.wu" => "__builtin_lasx_xvsle_wu", + "lasx.xvslei.b" => "__builtin_lasx_xvslei_b", + "lasx.xvslei.bu" => "__builtin_lasx_xvslei_bu", + "lasx.xvslei.d" => "__builtin_lasx_xvslei_d", + "lasx.xvslei.du" => "__builtin_lasx_xvslei_du", + "lasx.xvslei.h" => "__builtin_lasx_xvslei_h", + "lasx.xvslei.hu" => "__builtin_lasx_xvslei_hu", + "lasx.xvslei.w" => "__builtin_lasx_xvslei_w", + "lasx.xvslei.wu" => "__builtin_lasx_xvslei_wu", + "lasx.xvsll.b" => "__builtin_lasx_xvsll_b", + "lasx.xvsll.d" => "__builtin_lasx_xvsll_d", + "lasx.xvsll.h" => "__builtin_lasx_xvsll_h", + "lasx.xvsll.w" => "__builtin_lasx_xvsll_w", + "lasx.xvslli.b" => "__builtin_lasx_xvslli_b", + "lasx.xvslli.d" => "__builtin_lasx_xvslli_d", + "lasx.xvslli.h" => "__builtin_lasx_xvslli_h", + "lasx.xvslli.w" => "__builtin_lasx_xvslli_w", + "lasx.xvsllwil.d.w" => "__builtin_lasx_xvsllwil_d_w", + "lasx.xvsllwil.du.wu" => "__builtin_lasx_xvsllwil_du_wu", + "lasx.xvsllwil.h.b" => "__builtin_lasx_xvsllwil_h_b", + "lasx.xvsllwil.hu.bu" => "__builtin_lasx_xvsllwil_hu_bu", + "lasx.xvsllwil.w.h" => "__builtin_lasx_xvsllwil_w_h", + "lasx.xvsllwil.wu.hu" => "__builtin_lasx_xvsllwil_wu_hu", + "lasx.xvslt.b" => "__builtin_lasx_xvslt_b", + "lasx.xvslt.bu" => "__builtin_lasx_xvslt_bu", + "lasx.xvslt.d" => "__builtin_lasx_xvslt_d", + "lasx.xvslt.du" => "__builtin_lasx_xvslt_du", + "lasx.xvslt.h" => "__builtin_lasx_xvslt_h", + "lasx.xvslt.hu" => "__builtin_lasx_xvslt_hu", + "lasx.xvslt.w" => "__builtin_lasx_xvslt_w", + "lasx.xvslt.wu" => "__builtin_lasx_xvslt_wu", + "lasx.xvslti.b" => "__builtin_lasx_xvslti_b", + "lasx.xvslti.bu" => "__builtin_lasx_xvslti_bu", + "lasx.xvslti.d" => "__builtin_lasx_xvslti_d", + "lasx.xvslti.du" => "__builtin_lasx_xvslti_du", + "lasx.xvslti.h" => "__builtin_lasx_xvslti_h", + "lasx.xvslti.hu" => "__builtin_lasx_xvslti_hu", + "lasx.xvslti.w" => "__builtin_lasx_xvslti_w", + "lasx.xvslti.wu" => "__builtin_lasx_xvslti_wu", + "lasx.xvsra.b" => "__builtin_lasx_xvsra_b", + "lasx.xvsra.d" => "__builtin_lasx_xvsra_d", + "lasx.xvsra.h" => "__builtin_lasx_xvsra_h", + "lasx.xvsra.w" => "__builtin_lasx_xvsra_w", + "lasx.xvsrai.b" => "__builtin_lasx_xvsrai_b", + "lasx.xvsrai.d" => "__builtin_lasx_xvsrai_d", + "lasx.xvsrai.h" => "__builtin_lasx_xvsrai_h", + "lasx.xvsrai.w" => "__builtin_lasx_xvsrai_w", + "lasx.xvsran.b.h" => "__builtin_lasx_xvsran_b_h", + "lasx.xvsran.h.w" => "__builtin_lasx_xvsran_h_w", + "lasx.xvsran.w.d" => "__builtin_lasx_xvsran_w_d", + "lasx.xvsrani.b.h" => "__builtin_lasx_xvsrani_b_h", + "lasx.xvsrani.d.q" => "__builtin_lasx_xvsrani_d_q", + "lasx.xvsrani.h.w" => "__builtin_lasx_xvsrani_h_w", + "lasx.xvsrani.w.d" => "__builtin_lasx_xvsrani_w_d", + "lasx.xvsrar.b" => "__builtin_lasx_xvsrar_b", + "lasx.xvsrar.d" => "__builtin_lasx_xvsrar_d", + "lasx.xvsrar.h" => "__builtin_lasx_xvsrar_h", + "lasx.xvsrar.w" => "__builtin_lasx_xvsrar_w", + "lasx.xvsrari.b" => "__builtin_lasx_xvsrari_b", + "lasx.xvsrari.d" => "__builtin_lasx_xvsrari_d", + "lasx.xvsrari.h" => "__builtin_lasx_xvsrari_h", + "lasx.xvsrari.w" => "__builtin_lasx_xvsrari_w", + "lasx.xvsrarn.b.h" => "__builtin_lasx_xvsrarn_b_h", + "lasx.xvsrarn.h.w" => "__builtin_lasx_xvsrarn_h_w", + "lasx.xvsrarn.w.d" => "__builtin_lasx_xvsrarn_w_d", + "lasx.xvsrarni.b.h" => "__builtin_lasx_xvsrarni_b_h", + "lasx.xvsrarni.d.q" => "__builtin_lasx_xvsrarni_d_q", + "lasx.xvsrarni.h.w" => "__builtin_lasx_xvsrarni_h_w", + "lasx.xvsrarni.w.d" => "__builtin_lasx_xvsrarni_w_d", + "lasx.xvsrl.b" => "__builtin_lasx_xvsrl_b", + "lasx.xvsrl.d" => "__builtin_lasx_xvsrl_d", + "lasx.xvsrl.h" => "__builtin_lasx_xvsrl_h", + "lasx.xvsrl.w" => "__builtin_lasx_xvsrl_w", + "lasx.xvsrli.b" => "__builtin_lasx_xvsrli_b", + "lasx.xvsrli.d" => "__builtin_lasx_xvsrli_d", + "lasx.xvsrli.h" => "__builtin_lasx_xvsrli_h", + "lasx.xvsrli.w" => "__builtin_lasx_xvsrli_w", + "lasx.xvsrln.b.h" => "__builtin_lasx_xvsrln_b_h", + "lasx.xvsrln.h.w" => "__builtin_lasx_xvsrln_h_w", + "lasx.xvsrln.w.d" => "__builtin_lasx_xvsrln_w_d", + "lasx.xvsrlni.b.h" => "__builtin_lasx_xvsrlni_b_h", + "lasx.xvsrlni.d.q" => "__builtin_lasx_xvsrlni_d_q", + "lasx.xvsrlni.h.w" => "__builtin_lasx_xvsrlni_h_w", + "lasx.xvsrlni.w.d" => "__builtin_lasx_xvsrlni_w_d", + "lasx.xvsrlr.b" => "__builtin_lasx_xvsrlr_b", + "lasx.xvsrlr.d" => "__builtin_lasx_xvsrlr_d", + "lasx.xvsrlr.h" => "__builtin_lasx_xvsrlr_h", + "lasx.xvsrlr.w" => "__builtin_lasx_xvsrlr_w", + "lasx.xvsrlri.b" => "__builtin_lasx_xvsrlri_b", + "lasx.xvsrlri.d" => "__builtin_lasx_xvsrlri_d", + "lasx.xvsrlri.h" => "__builtin_lasx_xvsrlri_h", + "lasx.xvsrlri.w" => "__builtin_lasx_xvsrlri_w", + "lasx.xvsrlrn.b.h" => "__builtin_lasx_xvsrlrn_b_h", + "lasx.xvsrlrn.h.w" => "__builtin_lasx_xvsrlrn_h_w", + "lasx.xvsrlrn.w.d" => "__builtin_lasx_xvsrlrn_w_d", + "lasx.xvsrlrni.b.h" => "__builtin_lasx_xvsrlrni_b_h", + "lasx.xvsrlrni.d.q" => "__builtin_lasx_xvsrlrni_d_q", + "lasx.xvsrlrni.h.w" => "__builtin_lasx_xvsrlrni_h_w", + "lasx.xvsrlrni.w.d" => "__builtin_lasx_xvsrlrni_w_d", + "lasx.xvssran.b.h" => "__builtin_lasx_xvssran_b_h", + "lasx.xvssran.bu.h" => "__builtin_lasx_xvssran_bu_h", + "lasx.xvssran.h.w" => "__builtin_lasx_xvssran_h_w", + "lasx.xvssran.hu.w" => "__builtin_lasx_xvssran_hu_w", + "lasx.xvssran.w.d" => "__builtin_lasx_xvssran_w_d", + "lasx.xvssran.wu.d" => "__builtin_lasx_xvssran_wu_d", + "lasx.xvssrani.b.h" => "__builtin_lasx_xvssrani_b_h", + "lasx.xvssrani.bu.h" => "__builtin_lasx_xvssrani_bu_h", + "lasx.xvssrani.d.q" => "__builtin_lasx_xvssrani_d_q", + "lasx.xvssrani.du.q" => "__builtin_lasx_xvssrani_du_q", + "lasx.xvssrani.h.w" => "__builtin_lasx_xvssrani_h_w", + "lasx.xvssrani.hu.w" => "__builtin_lasx_xvssrani_hu_w", + "lasx.xvssrani.w.d" => "__builtin_lasx_xvssrani_w_d", + "lasx.xvssrani.wu.d" => "__builtin_lasx_xvssrani_wu_d", + "lasx.xvssrarn.b.h" => "__builtin_lasx_xvssrarn_b_h", + "lasx.xvssrarn.bu.h" => "__builtin_lasx_xvssrarn_bu_h", + "lasx.xvssrarn.h.w" => "__builtin_lasx_xvssrarn_h_w", + "lasx.xvssrarn.hu.w" => "__builtin_lasx_xvssrarn_hu_w", + "lasx.xvssrarn.w.d" => "__builtin_lasx_xvssrarn_w_d", + "lasx.xvssrarn.wu.d" => "__builtin_lasx_xvssrarn_wu_d", + "lasx.xvssrarni.b.h" => "__builtin_lasx_xvssrarni_b_h", + "lasx.xvssrarni.bu.h" => "__builtin_lasx_xvssrarni_bu_h", + "lasx.xvssrarni.d.q" => "__builtin_lasx_xvssrarni_d_q", + "lasx.xvssrarni.du.q" => "__builtin_lasx_xvssrarni_du_q", + "lasx.xvssrarni.h.w" => "__builtin_lasx_xvssrarni_h_w", + "lasx.xvssrarni.hu.w" => "__builtin_lasx_xvssrarni_hu_w", + "lasx.xvssrarni.w.d" => "__builtin_lasx_xvssrarni_w_d", + "lasx.xvssrarni.wu.d" => "__builtin_lasx_xvssrarni_wu_d", + "lasx.xvssrln.b.h" => "__builtin_lasx_xvssrln_b_h", + "lasx.xvssrln.bu.h" => "__builtin_lasx_xvssrln_bu_h", + "lasx.xvssrln.h.w" => "__builtin_lasx_xvssrln_h_w", + "lasx.xvssrln.hu.w" => "__builtin_lasx_xvssrln_hu_w", + "lasx.xvssrln.w.d" => "__builtin_lasx_xvssrln_w_d", + "lasx.xvssrln.wu.d" => "__builtin_lasx_xvssrln_wu_d", + "lasx.xvssrlni.b.h" => "__builtin_lasx_xvssrlni_b_h", + "lasx.xvssrlni.bu.h" => "__builtin_lasx_xvssrlni_bu_h", + "lasx.xvssrlni.d.q" => "__builtin_lasx_xvssrlni_d_q", + "lasx.xvssrlni.du.q" => "__builtin_lasx_xvssrlni_du_q", + "lasx.xvssrlni.h.w" => "__builtin_lasx_xvssrlni_h_w", + "lasx.xvssrlni.hu.w" => "__builtin_lasx_xvssrlni_hu_w", + "lasx.xvssrlni.w.d" => "__builtin_lasx_xvssrlni_w_d", + "lasx.xvssrlni.wu.d" => "__builtin_lasx_xvssrlni_wu_d", + "lasx.xvssrlrn.b.h" => "__builtin_lasx_xvssrlrn_b_h", + "lasx.xvssrlrn.bu.h" => "__builtin_lasx_xvssrlrn_bu_h", + "lasx.xvssrlrn.h.w" => "__builtin_lasx_xvssrlrn_h_w", + "lasx.xvssrlrn.hu.w" => "__builtin_lasx_xvssrlrn_hu_w", + "lasx.xvssrlrn.w.d" => "__builtin_lasx_xvssrlrn_w_d", + "lasx.xvssrlrn.wu.d" => "__builtin_lasx_xvssrlrn_wu_d", + "lasx.xvssrlrni.b.h" => "__builtin_lasx_xvssrlrni_b_h", + "lasx.xvssrlrni.bu.h" => "__builtin_lasx_xvssrlrni_bu_h", + "lasx.xvssrlrni.d.q" => "__builtin_lasx_xvssrlrni_d_q", + "lasx.xvssrlrni.du.q" => "__builtin_lasx_xvssrlrni_du_q", + "lasx.xvssrlrni.h.w" => "__builtin_lasx_xvssrlrni_h_w", + "lasx.xvssrlrni.hu.w" => "__builtin_lasx_xvssrlrni_hu_w", + "lasx.xvssrlrni.w.d" => "__builtin_lasx_xvssrlrni_w_d", + "lasx.xvssrlrni.wu.d" => "__builtin_lasx_xvssrlrni_wu_d", + "lasx.xvssub.b" => "__builtin_lasx_xvssub_b", + "lasx.xvssub.bu" => "__builtin_lasx_xvssub_bu", + "lasx.xvssub.d" => "__builtin_lasx_xvssub_d", + "lasx.xvssub.du" => "__builtin_lasx_xvssub_du", + "lasx.xvssub.h" => "__builtin_lasx_xvssub_h", + "lasx.xvssub.hu" => "__builtin_lasx_xvssub_hu", + "lasx.xvssub.w" => "__builtin_lasx_xvssub_w", + "lasx.xvssub.wu" => "__builtin_lasx_xvssub_wu", + "lasx.xvst" => "__builtin_lasx_xvst", + "lasx.xvstelm.b" => "__builtin_lasx_xvstelm_b", + "lasx.xvstelm.d" => "__builtin_lasx_xvstelm_d", + "lasx.xvstelm.h" => "__builtin_lasx_xvstelm_h", + "lasx.xvstelm.w" => "__builtin_lasx_xvstelm_w", + "lasx.xvstx" => "__builtin_lasx_xvstx", + "lasx.xvsub.b" => "__builtin_lasx_xvsub_b", + "lasx.xvsub.d" => "__builtin_lasx_xvsub_d", + "lasx.xvsub.h" => "__builtin_lasx_xvsub_h", + "lasx.xvsub.q" => "__builtin_lasx_xvsub_q", + "lasx.xvsub.w" => "__builtin_lasx_xvsub_w", + "lasx.xvsubi.bu" => "__builtin_lasx_xvsubi_bu", + "lasx.xvsubi.du" => "__builtin_lasx_xvsubi_du", + "lasx.xvsubi.hu" => "__builtin_lasx_xvsubi_hu", + "lasx.xvsubi.wu" => "__builtin_lasx_xvsubi_wu", + "lasx.xvsubwev.d.w" => "__builtin_lasx_xvsubwev_d_w", + "lasx.xvsubwev.d.wu" => "__builtin_lasx_xvsubwev_d_wu", + "lasx.xvsubwev.h.b" => "__builtin_lasx_xvsubwev_h_b", + "lasx.xvsubwev.h.bu" => "__builtin_lasx_xvsubwev_h_bu", + "lasx.xvsubwev.q.d" => "__builtin_lasx_xvsubwev_q_d", + "lasx.xvsubwev.q.du" => "__builtin_lasx_xvsubwev_q_du", + "lasx.xvsubwev.w.h" => "__builtin_lasx_xvsubwev_w_h", + "lasx.xvsubwev.w.hu" => "__builtin_lasx_xvsubwev_w_hu", + "lasx.xvsubwod.d.w" => "__builtin_lasx_xvsubwod_d_w", + "lasx.xvsubwod.d.wu" => "__builtin_lasx_xvsubwod_d_wu", + "lasx.xvsubwod.h.b" => "__builtin_lasx_xvsubwod_h_b", + "lasx.xvsubwod.h.bu" => "__builtin_lasx_xvsubwod_h_bu", + "lasx.xvsubwod.q.d" => "__builtin_lasx_xvsubwod_q_d", + "lasx.xvsubwod.q.du" => "__builtin_lasx_xvsubwod_q_du", + "lasx.xvsubwod.w.h" => "__builtin_lasx_xvsubwod_w_h", + "lasx.xvsubwod.w.hu" => "__builtin_lasx_xvsubwod_w_hu", + "lasx.xvxor.v" => "__builtin_lasx_xvxor_v", + "lasx.xvxori.b" => "__builtin_lasx_xvxori_b", + "lddir.d" => "__builtin_loongarch_lddir_d", + "ldpte.d" => "__builtin_loongarch_ldpte_d", + "lsx.bnz.b" => "__builtin_lsx_bnz_b", + "lsx.bnz.d" => "__builtin_lsx_bnz_d", + "lsx.bnz.h" => "__builtin_lsx_bnz_h", + "lsx.bnz.v" => "__builtin_lsx_bnz_v", + "lsx.bnz.w" => "__builtin_lsx_bnz_w", + "lsx.bz.b" => "__builtin_lsx_bz_b", + "lsx.bz.d" => "__builtin_lsx_bz_d", + "lsx.bz.h" => "__builtin_lsx_bz_h", + "lsx.bz.v" => "__builtin_lsx_bz_v", + "lsx.bz.w" => "__builtin_lsx_bz_w", + "lsx.vabsd.b" => "__builtin_lsx_vabsd_b", + "lsx.vabsd.bu" => "__builtin_lsx_vabsd_bu", + "lsx.vabsd.d" => "__builtin_lsx_vabsd_d", + "lsx.vabsd.du" => "__builtin_lsx_vabsd_du", + "lsx.vabsd.h" => "__builtin_lsx_vabsd_h", + "lsx.vabsd.hu" => "__builtin_lsx_vabsd_hu", + "lsx.vabsd.w" => "__builtin_lsx_vabsd_w", + "lsx.vabsd.wu" => "__builtin_lsx_vabsd_wu", + "lsx.vadd.b" => "__builtin_lsx_vadd_b", + "lsx.vadd.d" => "__builtin_lsx_vadd_d", + "lsx.vadd.h" => "__builtin_lsx_vadd_h", + "lsx.vadd.q" => "__builtin_lsx_vadd_q", + "lsx.vadd.w" => "__builtin_lsx_vadd_w", + "lsx.vadda.b" => "__builtin_lsx_vadda_b", + "lsx.vadda.d" => "__builtin_lsx_vadda_d", + "lsx.vadda.h" => "__builtin_lsx_vadda_h", + "lsx.vadda.w" => "__builtin_lsx_vadda_w", + "lsx.vaddi.bu" => "__builtin_lsx_vaddi_bu", + "lsx.vaddi.du" => "__builtin_lsx_vaddi_du", + "lsx.vaddi.hu" => "__builtin_lsx_vaddi_hu", + "lsx.vaddi.wu" => "__builtin_lsx_vaddi_wu", + "lsx.vaddwev.d.w" => "__builtin_lsx_vaddwev_d_w", + "lsx.vaddwev.d.wu" => "__builtin_lsx_vaddwev_d_wu", + "lsx.vaddwev.d.wu.w" => "__builtin_lsx_vaddwev_d_wu_w", + "lsx.vaddwev.h.b" => "__builtin_lsx_vaddwev_h_b", + "lsx.vaddwev.h.bu" => "__builtin_lsx_vaddwev_h_bu", + "lsx.vaddwev.h.bu.b" => "__builtin_lsx_vaddwev_h_bu_b", + "lsx.vaddwev.q.d" => "__builtin_lsx_vaddwev_q_d", + "lsx.vaddwev.q.du" => "__builtin_lsx_vaddwev_q_du", + "lsx.vaddwev.q.du.d" => "__builtin_lsx_vaddwev_q_du_d", + "lsx.vaddwev.w.h" => "__builtin_lsx_vaddwev_w_h", + "lsx.vaddwev.w.hu" => "__builtin_lsx_vaddwev_w_hu", + "lsx.vaddwev.w.hu.h" => "__builtin_lsx_vaddwev_w_hu_h", + "lsx.vaddwod.d.w" => "__builtin_lsx_vaddwod_d_w", + "lsx.vaddwod.d.wu" => "__builtin_lsx_vaddwod_d_wu", + "lsx.vaddwod.d.wu.w" => "__builtin_lsx_vaddwod_d_wu_w", + "lsx.vaddwod.h.b" => "__builtin_lsx_vaddwod_h_b", + "lsx.vaddwod.h.bu" => "__builtin_lsx_vaddwod_h_bu", + "lsx.vaddwod.h.bu.b" => "__builtin_lsx_vaddwod_h_bu_b", + "lsx.vaddwod.q.d" => "__builtin_lsx_vaddwod_q_d", + "lsx.vaddwod.q.du" => "__builtin_lsx_vaddwod_q_du", + "lsx.vaddwod.q.du.d" => "__builtin_lsx_vaddwod_q_du_d", + "lsx.vaddwod.w.h" => "__builtin_lsx_vaddwod_w_h", + "lsx.vaddwod.w.hu" => "__builtin_lsx_vaddwod_w_hu", + "lsx.vaddwod.w.hu.h" => "__builtin_lsx_vaddwod_w_hu_h", + "lsx.vand.v" => "__builtin_lsx_vand_v", + "lsx.vandi.b" => "__builtin_lsx_vandi_b", + "lsx.vandn.v" => "__builtin_lsx_vandn_v", + "lsx.vavg.b" => "__builtin_lsx_vavg_b", + "lsx.vavg.bu" => "__builtin_lsx_vavg_bu", + "lsx.vavg.d" => "__builtin_lsx_vavg_d", + "lsx.vavg.du" => "__builtin_lsx_vavg_du", + "lsx.vavg.h" => "__builtin_lsx_vavg_h", + "lsx.vavg.hu" => "__builtin_lsx_vavg_hu", + "lsx.vavg.w" => "__builtin_lsx_vavg_w", + "lsx.vavg.wu" => "__builtin_lsx_vavg_wu", + "lsx.vavgr.b" => "__builtin_lsx_vavgr_b", + "lsx.vavgr.bu" => "__builtin_lsx_vavgr_bu", + "lsx.vavgr.d" => "__builtin_lsx_vavgr_d", + "lsx.vavgr.du" => "__builtin_lsx_vavgr_du", + "lsx.vavgr.h" => "__builtin_lsx_vavgr_h", + "lsx.vavgr.hu" => "__builtin_lsx_vavgr_hu", + "lsx.vavgr.w" => "__builtin_lsx_vavgr_w", + "lsx.vavgr.wu" => "__builtin_lsx_vavgr_wu", + "lsx.vbitclr.b" => "__builtin_lsx_vbitclr_b", + "lsx.vbitclr.d" => "__builtin_lsx_vbitclr_d", + "lsx.vbitclr.h" => "__builtin_lsx_vbitclr_h", + "lsx.vbitclr.w" => "__builtin_lsx_vbitclr_w", + "lsx.vbitclri.b" => "__builtin_lsx_vbitclri_b", + "lsx.vbitclri.d" => "__builtin_lsx_vbitclri_d", + "lsx.vbitclri.h" => "__builtin_lsx_vbitclri_h", + "lsx.vbitclri.w" => "__builtin_lsx_vbitclri_w", + "lsx.vbitrev.b" => "__builtin_lsx_vbitrev_b", + "lsx.vbitrev.d" => "__builtin_lsx_vbitrev_d", + "lsx.vbitrev.h" => "__builtin_lsx_vbitrev_h", + "lsx.vbitrev.w" => "__builtin_lsx_vbitrev_w", + "lsx.vbitrevi.b" => "__builtin_lsx_vbitrevi_b", + "lsx.vbitrevi.d" => "__builtin_lsx_vbitrevi_d", + "lsx.vbitrevi.h" => "__builtin_lsx_vbitrevi_h", + "lsx.vbitrevi.w" => "__builtin_lsx_vbitrevi_w", + "lsx.vbitsel.v" => "__builtin_lsx_vbitsel_v", + "lsx.vbitseli.b" => "__builtin_lsx_vbitseli_b", + "lsx.vbitset.b" => "__builtin_lsx_vbitset_b", + "lsx.vbitset.d" => "__builtin_lsx_vbitset_d", + "lsx.vbitset.h" => "__builtin_lsx_vbitset_h", + "lsx.vbitset.w" => "__builtin_lsx_vbitset_w", + "lsx.vbitseti.b" => "__builtin_lsx_vbitseti_b", + "lsx.vbitseti.d" => "__builtin_lsx_vbitseti_d", + "lsx.vbitseti.h" => "__builtin_lsx_vbitseti_h", + "lsx.vbitseti.w" => "__builtin_lsx_vbitseti_w", + "lsx.vbsll.v" => "__builtin_lsx_vbsll_v", + "lsx.vbsrl.v" => "__builtin_lsx_vbsrl_v", + "lsx.vclo.b" => "__builtin_lsx_vclo_b", + "lsx.vclo.d" => "__builtin_lsx_vclo_d", + "lsx.vclo.h" => "__builtin_lsx_vclo_h", + "lsx.vclo.w" => "__builtin_lsx_vclo_w", + "lsx.vclz.b" => "__builtin_lsx_vclz_b", + "lsx.vclz.d" => "__builtin_lsx_vclz_d", + "lsx.vclz.h" => "__builtin_lsx_vclz_h", + "lsx.vclz.w" => "__builtin_lsx_vclz_w", + "lsx.vdiv.b" => "__builtin_lsx_vdiv_b", + "lsx.vdiv.bu" => "__builtin_lsx_vdiv_bu", + "lsx.vdiv.d" => "__builtin_lsx_vdiv_d", + "lsx.vdiv.du" => "__builtin_lsx_vdiv_du", + "lsx.vdiv.h" => "__builtin_lsx_vdiv_h", + "lsx.vdiv.hu" => "__builtin_lsx_vdiv_hu", + "lsx.vdiv.w" => "__builtin_lsx_vdiv_w", + "lsx.vdiv.wu" => "__builtin_lsx_vdiv_wu", + "lsx.vexth.d.w" => "__builtin_lsx_vexth_d_w", + "lsx.vexth.du.wu" => "__builtin_lsx_vexth_du_wu", + "lsx.vexth.h.b" => "__builtin_lsx_vexth_h_b", + "lsx.vexth.hu.bu" => "__builtin_lsx_vexth_hu_bu", + "lsx.vexth.q.d" => "__builtin_lsx_vexth_q_d", + "lsx.vexth.qu.du" => "__builtin_lsx_vexth_qu_du", + "lsx.vexth.w.h" => "__builtin_lsx_vexth_w_h", + "lsx.vexth.wu.hu" => "__builtin_lsx_vexth_wu_hu", + "lsx.vextl.q.d" => "__builtin_lsx_vextl_q_d", + "lsx.vextl.qu.du" => "__builtin_lsx_vextl_qu_du", + "lsx.vextrins.b" => "__builtin_lsx_vextrins_b", + "lsx.vextrins.d" => "__builtin_lsx_vextrins_d", + "lsx.vextrins.h" => "__builtin_lsx_vextrins_h", + "lsx.vextrins.w" => "__builtin_lsx_vextrins_w", + "lsx.vfadd.d" => "__builtin_lsx_vfadd_d", + "lsx.vfadd.s" => "__builtin_lsx_vfadd_s", + "lsx.vfclass.d" => "__builtin_lsx_vfclass_d", + "lsx.vfclass.s" => "__builtin_lsx_vfclass_s", + "lsx.vfcmp.caf.d" => "__builtin_lsx_vfcmp_caf_d", + "lsx.vfcmp.caf.s" => "__builtin_lsx_vfcmp_caf_s", + "lsx.vfcmp.ceq.d" => "__builtin_lsx_vfcmp_ceq_d", + "lsx.vfcmp.ceq.s" => "__builtin_lsx_vfcmp_ceq_s", + "lsx.vfcmp.cle.d" => "__builtin_lsx_vfcmp_cle_d", + "lsx.vfcmp.cle.s" => "__builtin_lsx_vfcmp_cle_s", + "lsx.vfcmp.clt.d" => "__builtin_lsx_vfcmp_clt_d", + "lsx.vfcmp.clt.s" => "__builtin_lsx_vfcmp_clt_s", + "lsx.vfcmp.cne.d" => "__builtin_lsx_vfcmp_cne_d", + "lsx.vfcmp.cne.s" => "__builtin_lsx_vfcmp_cne_s", + "lsx.vfcmp.cor.d" => "__builtin_lsx_vfcmp_cor_d", + "lsx.vfcmp.cor.s" => "__builtin_lsx_vfcmp_cor_s", + "lsx.vfcmp.cueq.d" => "__builtin_lsx_vfcmp_cueq_d", + "lsx.vfcmp.cueq.s" => "__builtin_lsx_vfcmp_cueq_s", + "lsx.vfcmp.cule.d" => "__builtin_lsx_vfcmp_cule_d", + "lsx.vfcmp.cule.s" => "__builtin_lsx_vfcmp_cule_s", + "lsx.vfcmp.cult.d" => "__builtin_lsx_vfcmp_cult_d", + "lsx.vfcmp.cult.s" => "__builtin_lsx_vfcmp_cult_s", + "lsx.vfcmp.cun.d" => "__builtin_lsx_vfcmp_cun_d", + "lsx.vfcmp.cun.s" => "__builtin_lsx_vfcmp_cun_s", + "lsx.vfcmp.cune.d" => "__builtin_lsx_vfcmp_cune_d", + "lsx.vfcmp.cune.s" => "__builtin_lsx_vfcmp_cune_s", + "lsx.vfcmp.saf.d" => "__builtin_lsx_vfcmp_saf_d", + "lsx.vfcmp.saf.s" => "__builtin_lsx_vfcmp_saf_s", + "lsx.vfcmp.seq.d" => "__builtin_lsx_vfcmp_seq_d", + "lsx.vfcmp.seq.s" => "__builtin_lsx_vfcmp_seq_s", + "lsx.vfcmp.sle.d" => "__builtin_lsx_vfcmp_sle_d", + "lsx.vfcmp.sle.s" => "__builtin_lsx_vfcmp_sle_s", + "lsx.vfcmp.slt.d" => "__builtin_lsx_vfcmp_slt_d", + "lsx.vfcmp.slt.s" => "__builtin_lsx_vfcmp_slt_s", + "lsx.vfcmp.sne.d" => "__builtin_lsx_vfcmp_sne_d", + "lsx.vfcmp.sne.s" => "__builtin_lsx_vfcmp_sne_s", + "lsx.vfcmp.sor.d" => "__builtin_lsx_vfcmp_sor_d", + "lsx.vfcmp.sor.s" => "__builtin_lsx_vfcmp_sor_s", + "lsx.vfcmp.sueq.d" => "__builtin_lsx_vfcmp_sueq_d", + "lsx.vfcmp.sueq.s" => "__builtin_lsx_vfcmp_sueq_s", + "lsx.vfcmp.sule.d" => "__builtin_lsx_vfcmp_sule_d", + "lsx.vfcmp.sule.s" => "__builtin_lsx_vfcmp_sule_s", + "lsx.vfcmp.sult.d" => "__builtin_lsx_vfcmp_sult_d", + "lsx.vfcmp.sult.s" => "__builtin_lsx_vfcmp_sult_s", + "lsx.vfcmp.sun.d" => "__builtin_lsx_vfcmp_sun_d", + "lsx.vfcmp.sun.s" => "__builtin_lsx_vfcmp_sun_s", + "lsx.vfcmp.sune.d" => "__builtin_lsx_vfcmp_sune_d", + "lsx.vfcmp.sune.s" => "__builtin_lsx_vfcmp_sune_s", + "lsx.vfcvt.h.s" => "__builtin_lsx_vfcvt_h_s", + "lsx.vfcvt.s.d" => "__builtin_lsx_vfcvt_s_d", + "lsx.vfcvth.d.s" => "__builtin_lsx_vfcvth_d_s", + "lsx.vfcvth.s.h" => "__builtin_lsx_vfcvth_s_h", + "lsx.vfcvtl.d.s" => "__builtin_lsx_vfcvtl_d_s", + "lsx.vfcvtl.s.h" => "__builtin_lsx_vfcvtl_s_h", + "lsx.vfdiv.d" => "__builtin_lsx_vfdiv_d", + "lsx.vfdiv.s" => "__builtin_lsx_vfdiv_s", + "lsx.vffint.d.l" => "__builtin_lsx_vffint_d_l", + "lsx.vffint.d.lu" => "__builtin_lsx_vffint_d_lu", + "lsx.vffint.s.l" => "__builtin_lsx_vffint_s_l", + "lsx.vffint.s.w" => "__builtin_lsx_vffint_s_w", + "lsx.vffint.s.wu" => "__builtin_lsx_vffint_s_wu", + "lsx.vffinth.d.w" => "__builtin_lsx_vffinth_d_w", + "lsx.vffintl.d.w" => "__builtin_lsx_vffintl_d_w", + "lsx.vflogb.d" => "__builtin_lsx_vflogb_d", + "lsx.vflogb.s" => "__builtin_lsx_vflogb_s", + "lsx.vfmadd.d" => "__builtin_lsx_vfmadd_d", + "lsx.vfmadd.s" => "__builtin_lsx_vfmadd_s", + "lsx.vfmax.d" => "__builtin_lsx_vfmax_d", + "lsx.vfmax.s" => "__builtin_lsx_vfmax_s", + "lsx.vfmaxa.d" => "__builtin_lsx_vfmaxa_d", + "lsx.vfmaxa.s" => "__builtin_lsx_vfmaxa_s", + "lsx.vfmin.d" => "__builtin_lsx_vfmin_d", + "lsx.vfmin.s" => "__builtin_lsx_vfmin_s", + "lsx.vfmina.d" => "__builtin_lsx_vfmina_d", + "lsx.vfmina.s" => "__builtin_lsx_vfmina_s", + "lsx.vfmsub.d" => "__builtin_lsx_vfmsub_d", + "lsx.vfmsub.s" => "__builtin_lsx_vfmsub_s", + "lsx.vfmul.d" => "__builtin_lsx_vfmul_d", + "lsx.vfmul.s" => "__builtin_lsx_vfmul_s", + "lsx.vfnmadd.d" => "__builtin_lsx_vfnmadd_d", + "lsx.vfnmadd.s" => "__builtin_lsx_vfnmadd_s", + "lsx.vfnmsub.d" => "__builtin_lsx_vfnmsub_d", + "lsx.vfnmsub.s" => "__builtin_lsx_vfnmsub_s", + "lsx.vfrecip.d" => "__builtin_lsx_vfrecip_d", + "lsx.vfrecip.s" => "__builtin_lsx_vfrecip_s", + "lsx.vfrecipe.d" => "__builtin_lsx_vfrecipe_d", + "lsx.vfrecipe.s" => "__builtin_lsx_vfrecipe_s", + "lsx.vfrint.d" => "__builtin_lsx_vfrint_d", + "lsx.vfrint.s" => "__builtin_lsx_vfrint_s", + "lsx.vfrintrm.d" => "__builtin_lsx_vfrintrm_d", + "lsx.vfrintrm.s" => "__builtin_lsx_vfrintrm_s", + "lsx.vfrintrne.d" => "__builtin_lsx_vfrintrne_d", + "lsx.vfrintrne.s" => "__builtin_lsx_vfrintrne_s", + "lsx.vfrintrp.d" => "__builtin_lsx_vfrintrp_d", + "lsx.vfrintrp.s" => "__builtin_lsx_vfrintrp_s", + "lsx.vfrintrz.d" => "__builtin_lsx_vfrintrz_d", + "lsx.vfrintrz.s" => "__builtin_lsx_vfrintrz_s", + "lsx.vfrsqrt.d" => "__builtin_lsx_vfrsqrt_d", + "lsx.vfrsqrt.s" => "__builtin_lsx_vfrsqrt_s", + "lsx.vfrsqrte.d" => "__builtin_lsx_vfrsqrte_d", + "lsx.vfrsqrte.s" => "__builtin_lsx_vfrsqrte_s", + "lsx.vfrstp.b" => "__builtin_lsx_vfrstp_b", + "lsx.vfrstp.h" => "__builtin_lsx_vfrstp_h", + "lsx.vfrstpi.b" => "__builtin_lsx_vfrstpi_b", + "lsx.vfrstpi.h" => "__builtin_lsx_vfrstpi_h", + "lsx.vfsqrt.d" => "__builtin_lsx_vfsqrt_d", + "lsx.vfsqrt.s" => "__builtin_lsx_vfsqrt_s", + "lsx.vfsub.d" => "__builtin_lsx_vfsub_d", + "lsx.vfsub.s" => "__builtin_lsx_vfsub_s", + "lsx.vftint.l.d" => "__builtin_lsx_vftint_l_d", + "lsx.vftint.lu.d" => "__builtin_lsx_vftint_lu_d", + "lsx.vftint.w.d" => "__builtin_lsx_vftint_w_d", + "lsx.vftint.w.s" => "__builtin_lsx_vftint_w_s", + "lsx.vftint.wu.s" => "__builtin_lsx_vftint_wu_s", + "lsx.vftinth.l.s" => "__builtin_lsx_vftinth_l_s", + "lsx.vftintl.l.s" => "__builtin_lsx_vftintl_l_s", + "lsx.vftintrm.l.d" => "__builtin_lsx_vftintrm_l_d", + "lsx.vftintrm.w.d" => "__builtin_lsx_vftintrm_w_d", + "lsx.vftintrm.w.s" => "__builtin_lsx_vftintrm_w_s", + "lsx.vftintrmh.l.s" => "__builtin_lsx_vftintrmh_l_s", + "lsx.vftintrml.l.s" => "__builtin_lsx_vftintrml_l_s", + "lsx.vftintrne.l.d" => "__builtin_lsx_vftintrne_l_d", + "lsx.vftintrne.w.d" => "__builtin_lsx_vftintrne_w_d", + "lsx.vftintrne.w.s" => "__builtin_lsx_vftintrne_w_s", + "lsx.vftintrneh.l.s" => "__builtin_lsx_vftintrneh_l_s", + "lsx.vftintrnel.l.s" => "__builtin_lsx_vftintrnel_l_s", + "lsx.vftintrp.l.d" => "__builtin_lsx_vftintrp_l_d", + "lsx.vftintrp.w.d" => "__builtin_lsx_vftintrp_w_d", + "lsx.vftintrp.w.s" => "__builtin_lsx_vftintrp_w_s", + "lsx.vftintrph.l.s" => "__builtin_lsx_vftintrph_l_s", + "lsx.vftintrpl.l.s" => "__builtin_lsx_vftintrpl_l_s", + "lsx.vftintrz.l.d" => "__builtin_lsx_vftintrz_l_d", + "lsx.vftintrz.lu.d" => "__builtin_lsx_vftintrz_lu_d", + "lsx.vftintrz.w.d" => "__builtin_lsx_vftintrz_w_d", + "lsx.vftintrz.w.s" => "__builtin_lsx_vftintrz_w_s", + "lsx.vftintrz.wu.s" => "__builtin_lsx_vftintrz_wu_s", + "lsx.vftintrzh.l.s" => "__builtin_lsx_vftintrzh_l_s", + "lsx.vftintrzl.l.s" => "__builtin_lsx_vftintrzl_l_s", + "lsx.vhaddw.d.w" => "__builtin_lsx_vhaddw_d_w", + "lsx.vhaddw.du.wu" => "__builtin_lsx_vhaddw_du_wu", + "lsx.vhaddw.h.b" => "__builtin_lsx_vhaddw_h_b", + "lsx.vhaddw.hu.bu" => "__builtin_lsx_vhaddw_hu_bu", + "lsx.vhaddw.q.d" => "__builtin_lsx_vhaddw_q_d", + "lsx.vhaddw.qu.du" => "__builtin_lsx_vhaddw_qu_du", + "lsx.vhaddw.w.h" => "__builtin_lsx_vhaddw_w_h", + "lsx.vhaddw.wu.hu" => "__builtin_lsx_vhaddw_wu_hu", + "lsx.vhsubw.d.w" => "__builtin_lsx_vhsubw_d_w", + "lsx.vhsubw.du.wu" => "__builtin_lsx_vhsubw_du_wu", + "lsx.vhsubw.h.b" => "__builtin_lsx_vhsubw_h_b", + "lsx.vhsubw.hu.bu" => "__builtin_lsx_vhsubw_hu_bu", + "lsx.vhsubw.q.d" => "__builtin_lsx_vhsubw_q_d", + "lsx.vhsubw.qu.du" => "__builtin_lsx_vhsubw_qu_du", + "lsx.vhsubw.w.h" => "__builtin_lsx_vhsubw_w_h", + "lsx.vhsubw.wu.hu" => "__builtin_lsx_vhsubw_wu_hu", + "lsx.vilvh.b" => "__builtin_lsx_vilvh_b", + "lsx.vilvh.d" => "__builtin_lsx_vilvh_d", + "lsx.vilvh.h" => "__builtin_lsx_vilvh_h", + "lsx.vilvh.w" => "__builtin_lsx_vilvh_w", + "lsx.vilvl.b" => "__builtin_lsx_vilvl_b", + "lsx.vilvl.d" => "__builtin_lsx_vilvl_d", + "lsx.vilvl.h" => "__builtin_lsx_vilvl_h", + "lsx.vilvl.w" => "__builtin_lsx_vilvl_w", + "lsx.vinsgr2vr.b" => "__builtin_lsx_vinsgr2vr_b", + "lsx.vinsgr2vr.d" => "__builtin_lsx_vinsgr2vr_d", + "lsx.vinsgr2vr.h" => "__builtin_lsx_vinsgr2vr_h", + "lsx.vinsgr2vr.w" => "__builtin_lsx_vinsgr2vr_w", + "lsx.vld" => "__builtin_lsx_vld", + "lsx.vldi" => "__builtin_lsx_vldi", + "lsx.vldrepl.b" => "__builtin_lsx_vldrepl_b", + "lsx.vldrepl.d" => "__builtin_lsx_vldrepl_d", + "lsx.vldrepl.h" => "__builtin_lsx_vldrepl_h", + "lsx.vldrepl.w" => "__builtin_lsx_vldrepl_w", + "lsx.vldx" => "__builtin_lsx_vldx", + "lsx.vmadd.b" => "__builtin_lsx_vmadd_b", + "lsx.vmadd.d" => "__builtin_lsx_vmadd_d", + "lsx.vmadd.h" => "__builtin_lsx_vmadd_h", + "lsx.vmadd.w" => "__builtin_lsx_vmadd_w", + "lsx.vmaddwev.d.w" => "__builtin_lsx_vmaddwev_d_w", + "lsx.vmaddwev.d.wu" => "__builtin_lsx_vmaddwev_d_wu", + "lsx.vmaddwev.d.wu.w" => "__builtin_lsx_vmaddwev_d_wu_w", + "lsx.vmaddwev.h.b" => "__builtin_lsx_vmaddwev_h_b", + "lsx.vmaddwev.h.bu" => "__builtin_lsx_vmaddwev_h_bu", + "lsx.vmaddwev.h.bu.b" => "__builtin_lsx_vmaddwev_h_bu_b", + "lsx.vmaddwev.q.d" => "__builtin_lsx_vmaddwev_q_d", + "lsx.vmaddwev.q.du" => "__builtin_lsx_vmaddwev_q_du", + "lsx.vmaddwev.q.du.d" => "__builtin_lsx_vmaddwev_q_du_d", + "lsx.vmaddwev.w.h" => "__builtin_lsx_vmaddwev_w_h", + "lsx.vmaddwev.w.hu" => "__builtin_lsx_vmaddwev_w_hu", + "lsx.vmaddwev.w.hu.h" => "__builtin_lsx_vmaddwev_w_hu_h", + "lsx.vmaddwod.d.w" => "__builtin_lsx_vmaddwod_d_w", + "lsx.vmaddwod.d.wu" => "__builtin_lsx_vmaddwod_d_wu", + "lsx.vmaddwod.d.wu.w" => "__builtin_lsx_vmaddwod_d_wu_w", + "lsx.vmaddwod.h.b" => "__builtin_lsx_vmaddwod_h_b", + "lsx.vmaddwod.h.bu" => "__builtin_lsx_vmaddwod_h_bu", + "lsx.vmaddwod.h.bu.b" => "__builtin_lsx_vmaddwod_h_bu_b", + "lsx.vmaddwod.q.d" => "__builtin_lsx_vmaddwod_q_d", + "lsx.vmaddwod.q.du" => "__builtin_lsx_vmaddwod_q_du", + "lsx.vmaddwod.q.du.d" => "__builtin_lsx_vmaddwod_q_du_d", + "lsx.vmaddwod.w.h" => "__builtin_lsx_vmaddwod_w_h", + "lsx.vmaddwod.w.hu" => "__builtin_lsx_vmaddwod_w_hu", + "lsx.vmaddwod.w.hu.h" => "__builtin_lsx_vmaddwod_w_hu_h", + "lsx.vmax.b" => "__builtin_lsx_vmax_b", + "lsx.vmax.bu" => "__builtin_lsx_vmax_bu", + "lsx.vmax.d" => "__builtin_lsx_vmax_d", + "lsx.vmax.du" => "__builtin_lsx_vmax_du", + "lsx.vmax.h" => "__builtin_lsx_vmax_h", + "lsx.vmax.hu" => "__builtin_lsx_vmax_hu", + "lsx.vmax.w" => "__builtin_lsx_vmax_w", + "lsx.vmax.wu" => "__builtin_lsx_vmax_wu", + "lsx.vmaxi.b" => "__builtin_lsx_vmaxi_b", + "lsx.vmaxi.bu" => "__builtin_lsx_vmaxi_bu", + "lsx.vmaxi.d" => "__builtin_lsx_vmaxi_d", + "lsx.vmaxi.du" => "__builtin_lsx_vmaxi_du", + "lsx.vmaxi.h" => "__builtin_lsx_vmaxi_h", + "lsx.vmaxi.hu" => "__builtin_lsx_vmaxi_hu", + "lsx.vmaxi.w" => "__builtin_lsx_vmaxi_w", + "lsx.vmaxi.wu" => "__builtin_lsx_vmaxi_wu", + "lsx.vmin.b" => "__builtin_lsx_vmin_b", + "lsx.vmin.bu" => "__builtin_lsx_vmin_bu", + "lsx.vmin.d" => "__builtin_lsx_vmin_d", + "lsx.vmin.du" => "__builtin_lsx_vmin_du", + "lsx.vmin.h" => "__builtin_lsx_vmin_h", + "lsx.vmin.hu" => "__builtin_lsx_vmin_hu", + "lsx.vmin.w" => "__builtin_lsx_vmin_w", + "lsx.vmin.wu" => "__builtin_lsx_vmin_wu", + "lsx.vmini.b" => "__builtin_lsx_vmini_b", + "lsx.vmini.bu" => "__builtin_lsx_vmini_bu", + "lsx.vmini.d" => "__builtin_lsx_vmini_d", + "lsx.vmini.du" => "__builtin_lsx_vmini_du", + "lsx.vmini.h" => "__builtin_lsx_vmini_h", + "lsx.vmini.hu" => "__builtin_lsx_vmini_hu", + "lsx.vmini.w" => "__builtin_lsx_vmini_w", + "lsx.vmini.wu" => "__builtin_lsx_vmini_wu", + "lsx.vmod.b" => "__builtin_lsx_vmod_b", + "lsx.vmod.bu" => "__builtin_lsx_vmod_bu", + "lsx.vmod.d" => "__builtin_lsx_vmod_d", + "lsx.vmod.du" => "__builtin_lsx_vmod_du", + "lsx.vmod.h" => "__builtin_lsx_vmod_h", + "lsx.vmod.hu" => "__builtin_lsx_vmod_hu", + "lsx.vmod.w" => "__builtin_lsx_vmod_w", + "lsx.vmod.wu" => "__builtin_lsx_vmod_wu", + "lsx.vmskgez.b" => "__builtin_lsx_vmskgez_b", + "lsx.vmskltz.b" => "__builtin_lsx_vmskltz_b", + "lsx.vmskltz.d" => "__builtin_lsx_vmskltz_d", + "lsx.vmskltz.h" => "__builtin_lsx_vmskltz_h", + "lsx.vmskltz.w" => "__builtin_lsx_vmskltz_w", + "lsx.vmsknz.b" => "__builtin_lsx_vmsknz_b", + "lsx.vmsub.b" => "__builtin_lsx_vmsub_b", + "lsx.vmsub.d" => "__builtin_lsx_vmsub_d", + "lsx.vmsub.h" => "__builtin_lsx_vmsub_h", + "lsx.vmsub.w" => "__builtin_lsx_vmsub_w", + "lsx.vmuh.b" => "__builtin_lsx_vmuh_b", + "lsx.vmuh.bu" => "__builtin_lsx_vmuh_bu", + "lsx.vmuh.d" => "__builtin_lsx_vmuh_d", + "lsx.vmuh.du" => "__builtin_lsx_vmuh_du", + "lsx.vmuh.h" => "__builtin_lsx_vmuh_h", + "lsx.vmuh.hu" => "__builtin_lsx_vmuh_hu", + "lsx.vmuh.w" => "__builtin_lsx_vmuh_w", + "lsx.vmuh.wu" => "__builtin_lsx_vmuh_wu", + "lsx.vmul.b" => "__builtin_lsx_vmul_b", + "lsx.vmul.d" => "__builtin_lsx_vmul_d", + "lsx.vmul.h" => "__builtin_lsx_vmul_h", + "lsx.vmul.w" => "__builtin_lsx_vmul_w", + "lsx.vmulwev.d.w" => "__builtin_lsx_vmulwev_d_w", + "lsx.vmulwev.d.wu" => "__builtin_lsx_vmulwev_d_wu", + "lsx.vmulwev.d.wu.w" => "__builtin_lsx_vmulwev_d_wu_w", + "lsx.vmulwev.h.b" => "__builtin_lsx_vmulwev_h_b", + "lsx.vmulwev.h.bu" => "__builtin_lsx_vmulwev_h_bu", + "lsx.vmulwev.h.bu.b" => "__builtin_lsx_vmulwev_h_bu_b", + "lsx.vmulwev.q.d" => "__builtin_lsx_vmulwev_q_d", + "lsx.vmulwev.q.du" => "__builtin_lsx_vmulwev_q_du", + "lsx.vmulwev.q.du.d" => "__builtin_lsx_vmulwev_q_du_d", + "lsx.vmulwev.w.h" => "__builtin_lsx_vmulwev_w_h", + "lsx.vmulwev.w.hu" => "__builtin_lsx_vmulwev_w_hu", + "lsx.vmulwev.w.hu.h" => "__builtin_lsx_vmulwev_w_hu_h", + "lsx.vmulwod.d.w" => "__builtin_lsx_vmulwod_d_w", + "lsx.vmulwod.d.wu" => "__builtin_lsx_vmulwod_d_wu", + "lsx.vmulwod.d.wu.w" => "__builtin_lsx_vmulwod_d_wu_w", + "lsx.vmulwod.h.b" => "__builtin_lsx_vmulwod_h_b", + "lsx.vmulwod.h.bu" => "__builtin_lsx_vmulwod_h_bu", + "lsx.vmulwod.h.bu.b" => "__builtin_lsx_vmulwod_h_bu_b", + "lsx.vmulwod.q.d" => "__builtin_lsx_vmulwod_q_d", + "lsx.vmulwod.q.du" => "__builtin_lsx_vmulwod_q_du", + "lsx.vmulwod.q.du.d" => "__builtin_lsx_vmulwod_q_du_d", + "lsx.vmulwod.w.h" => "__builtin_lsx_vmulwod_w_h", + "lsx.vmulwod.w.hu" => "__builtin_lsx_vmulwod_w_hu", + "lsx.vmulwod.w.hu.h" => "__builtin_lsx_vmulwod_w_hu_h", + "lsx.vneg.b" => "__builtin_lsx_vneg_b", + "lsx.vneg.d" => "__builtin_lsx_vneg_d", + "lsx.vneg.h" => "__builtin_lsx_vneg_h", + "lsx.vneg.w" => "__builtin_lsx_vneg_w", + "lsx.vnor.v" => "__builtin_lsx_vnor_v", + "lsx.vnori.b" => "__builtin_lsx_vnori_b", + "lsx.vor.v" => "__builtin_lsx_vor_v", + "lsx.vori.b" => "__builtin_lsx_vori_b", + "lsx.vorn.v" => "__builtin_lsx_vorn_v", + "lsx.vpackev.b" => "__builtin_lsx_vpackev_b", + "lsx.vpackev.d" => "__builtin_lsx_vpackev_d", + "lsx.vpackev.h" => "__builtin_lsx_vpackev_h", + "lsx.vpackev.w" => "__builtin_lsx_vpackev_w", + "lsx.vpackod.b" => "__builtin_lsx_vpackod_b", + "lsx.vpackod.d" => "__builtin_lsx_vpackod_d", + "lsx.vpackod.h" => "__builtin_lsx_vpackod_h", + "lsx.vpackod.w" => "__builtin_lsx_vpackod_w", + "lsx.vpcnt.b" => "__builtin_lsx_vpcnt_b", + "lsx.vpcnt.d" => "__builtin_lsx_vpcnt_d", + "lsx.vpcnt.h" => "__builtin_lsx_vpcnt_h", + "lsx.vpcnt.w" => "__builtin_lsx_vpcnt_w", + "lsx.vpermi.w" => "__builtin_lsx_vpermi_w", + "lsx.vpickev.b" => "__builtin_lsx_vpickev_b", + "lsx.vpickev.d" => "__builtin_lsx_vpickev_d", + "lsx.vpickev.h" => "__builtin_lsx_vpickev_h", + "lsx.vpickev.w" => "__builtin_lsx_vpickev_w", + "lsx.vpickod.b" => "__builtin_lsx_vpickod_b", + "lsx.vpickod.d" => "__builtin_lsx_vpickod_d", + "lsx.vpickod.h" => "__builtin_lsx_vpickod_h", + "lsx.vpickod.w" => "__builtin_lsx_vpickod_w", + "lsx.vpickve2gr.b" => "__builtin_lsx_vpickve2gr_b", + "lsx.vpickve2gr.bu" => "__builtin_lsx_vpickve2gr_bu", + "lsx.vpickve2gr.d" => "__builtin_lsx_vpickve2gr_d", + "lsx.vpickve2gr.du" => "__builtin_lsx_vpickve2gr_du", + "lsx.vpickve2gr.h" => "__builtin_lsx_vpickve2gr_h", + "lsx.vpickve2gr.hu" => "__builtin_lsx_vpickve2gr_hu", + "lsx.vpickve2gr.w" => "__builtin_lsx_vpickve2gr_w", + "lsx.vpickve2gr.wu" => "__builtin_lsx_vpickve2gr_wu", + "lsx.vreplgr2vr.b" => "__builtin_lsx_vreplgr2vr_b", + "lsx.vreplgr2vr.d" => "__builtin_lsx_vreplgr2vr_d", + "lsx.vreplgr2vr.h" => "__builtin_lsx_vreplgr2vr_h", + "lsx.vreplgr2vr.w" => "__builtin_lsx_vreplgr2vr_w", + "lsx.vrepli.b" => "__builtin_lsx_vrepli_b", + "lsx.vrepli.d" => "__builtin_lsx_vrepli_d", + "lsx.vrepli.h" => "__builtin_lsx_vrepli_h", + "lsx.vrepli.w" => "__builtin_lsx_vrepli_w", + "lsx.vreplve.b" => "__builtin_lsx_vreplve_b", + "lsx.vreplve.d" => "__builtin_lsx_vreplve_d", + "lsx.vreplve.h" => "__builtin_lsx_vreplve_h", + "lsx.vreplve.w" => "__builtin_lsx_vreplve_w", + "lsx.vreplvei.b" => "__builtin_lsx_vreplvei_b", + "lsx.vreplvei.d" => "__builtin_lsx_vreplvei_d", + "lsx.vreplvei.h" => "__builtin_lsx_vreplvei_h", + "lsx.vreplvei.w" => "__builtin_lsx_vreplvei_w", + "lsx.vrotr.b" => "__builtin_lsx_vrotr_b", + "lsx.vrotr.d" => "__builtin_lsx_vrotr_d", + "lsx.vrotr.h" => "__builtin_lsx_vrotr_h", + "lsx.vrotr.w" => "__builtin_lsx_vrotr_w", + "lsx.vrotri.b" => "__builtin_lsx_vrotri_b", + "lsx.vrotri.d" => "__builtin_lsx_vrotri_d", + "lsx.vrotri.h" => "__builtin_lsx_vrotri_h", + "lsx.vrotri.w" => "__builtin_lsx_vrotri_w", + "lsx.vsadd.b" => "__builtin_lsx_vsadd_b", + "lsx.vsadd.bu" => "__builtin_lsx_vsadd_bu", + "lsx.vsadd.d" => "__builtin_lsx_vsadd_d", + "lsx.vsadd.du" => "__builtin_lsx_vsadd_du", + "lsx.vsadd.h" => "__builtin_lsx_vsadd_h", + "lsx.vsadd.hu" => "__builtin_lsx_vsadd_hu", + "lsx.vsadd.w" => "__builtin_lsx_vsadd_w", + "lsx.vsadd.wu" => "__builtin_lsx_vsadd_wu", + "lsx.vsat.b" => "__builtin_lsx_vsat_b", + "lsx.vsat.bu" => "__builtin_lsx_vsat_bu", + "lsx.vsat.d" => "__builtin_lsx_vsat_d", + "lsx.vsat.du" => "__builtin_lsx_vsat_du", + "lsx.vsat.h" => "__builtin_lsx_vsat_h", + "lsx.vsat.hu" => "__builtin_lsx_vsat_hu", + "lsx.vsat.w" => "__builtin_lsx_vsat_w", + "lsx.vsat.wu" => "__builtin_lsx_vsat_wu", + "lsx.vseq.b" => "__builtin_lsx_vseq_b", + "lsx.vseq.d" => "__builtin_lsx_vseq_d", + "lsx.vseq.h" => "__builtin_lsx_vseq_h", + "lsx.vseq.w" => "__builtin_lsx_vseq_w", + "lsx.vseqi.b" => "__builtin_lsx_vseqi_b", + "lsx.vseqi.d" => "__builtin_lsx_vseqi_d", + "lsx.vseqi.h" => "__builtin_lsx_vseqi_h", + "lsx.vseqi.w" => "__builtin_lsx_vseqi_w", + "lsx.vshuf.b" => "__builtin_lsx_vshuf_b", + "lsx.vshuf.d" => "__builtin_lsx_vshuf_d", + "lsx.vshuf.h" => "__builtin_lsx_vshuf_h", + "lsx.vshuf.w" => "__builtin_lsx_vshuf_w", + "lsx.vshuf4i.b" => "__builtin_lsx_vshuf4i_b", + "lsx.vshuf4i.d" => "__builtin_lsx_vshuf4i_d", + "lsx.vshuf4i.h" => "__builtin_lsx_vshuf4i_h", + "lsx.vshuf4i.w" => "__builtin_lsx_vshuf4i_w", + "lsx.vsigncov.b" => "__builtin_lsx_vsigncov_b", + "lsx.vsigncov.d" => "__builtin_lsx_vsigncov_d", + "lsx.vsigncov.h" => "__builtin_lsx_vsigncov_h", + "lsx.vsigncov.w" => "__builtin_lsx_vsigncov_w", + "lsx.vsle.b" => "__builtin_lsx_vsle_b", + "lsx.vsle.bu" => "__builtin_lsx_vsle_bu", + "lsx.vsle.d" => "__builtin_lsx_vsle_d", + "lsx.vsle.du" => "__builtin_lsx_vsle_du", + "lsx.vsle.h" => "__builtin_lsx_vsle_h", + "lsx.vsle.hu" => "__builtin_lsx_vsle_hu", + "lsx.vsle.w" => "__builtin_lsx_vsle_w", + "lsx.vsle.wu" => "__builtin_lsx_vsle_wu", + "lsx.vslei.b" => "__builtin_lsx_vslei_b", + "lsx.vslei.bu" => "__builtin_lsx_vslei_bu", + "lsx.vslei.d" => "__builtin_lsx_vslei_d", + "lsx.vslei.du" => "__builtin_lsx_vslei_du", + "lsx.vslei.h" => "__builtin_lsx_vslei_h", + "lsx.vslei.hu" => "__builtin_lsx_vslei_hu", + "lsx.vslei.w" => "__builtin_lsx_vslei_w", + "lsx.vslei.wu" => "__builtin_lsx_vslei_wu", + "lsx.vsll.b" => "__builtin_lsx_vsll_b", + "lsx.vsll.d" => "__builtin_lsx_vsll_d", + "lsx.vsll.h" => "__builtin_lsx_vsll_h", + "lsx.vsll.w" => "__builtin_lsx_vsll_w", + "lsx.vslli.b" => "__builtin_lsx_vslli_b", + "lsx.vslli.d" => "__builtin_lsx_vslli_d", + "lsx.vslli.h" => "__builtin_lsx_vslli_h", + "lsx.vslli.w" => "__builtin_lsx_vslli_w", + "lsx.vsllwil.d.w" => "__builtin_lsx_vsllwil_d_w", + "lsx.vsllwil.du.wu" => "__builtin_lsx_vsllwil_du_wu", + "lsx.vsllwil.h.b" => "__builtin_lsx_vsllwil_h_b", + "lsx.vsllwil.hu.bu" => "__builtin_lsx_vsllwil_hu_bu", + "lsx.vsllwil.w.h" => "__builtin_lsx_vsllwil_w_h", + "lsx.vsllwil.wu.hu" => "__builtin_lsx_vsllwil_wu_hu", + "lsx.vslt.b" => "__builtin_lsx_vslt_b", + "lsx.vslt.bu" => "__builtin_lsx_vslt_bu", + "lsx.vslt.d" => "__builtin_lsx_vslt_d", + "lsx.vslt.du" => "__builtin_lsx_vslt_du", + "lsx.vslt.h" => "__builtin_lsx_vslt_h", + "lsx.vslt.hu" => "__builtin_lsx_vslt_hu", + "lsx.vslt.w" => "__builtin_lsx_vslt_w", + "lsx.vslt.wu" => "__builtin_lsx_vslt_wu", + "lsx.vslti.b" => "__builtin_lsx_vslti_b", + "lsx.vslti.bu" => "__builtin_lsx_vslti_bu", + "lsx.vslti.d" => "__builtin_lsx_vslti_d", + "lsx.vslti.du" => "__builtin_lsx_vslti_du", + "lsx.vslti.h" => "__builtin_lsx_vslti_h", + "lsx.vslti.hu" => "__builtin_lsx_vslti_hu", + "lsx.vslti.w" => "__builtin_lsx_vslti_w", + "lsx.vslti.wu" => "__builtin_lsx_vslti_wu", + "lsx.vsra.b" => "__builtin_lsx_vsra_b", + "lsx.vsra.d" => "__builtin_lsx_vsra_d", + "lsx.vsra.h" => "__builtin_lsx_vsra_h", + "lsx.vsra.w" => "__builtin_lsx_vsra_w", + "lsx.vsrai.b" => "__builtin_lsx_vsrai_b", + "lsx.vsrai.d" => "__builtin_lsx_vsrai_d", + "lsx.vsrai.h" => "__builtin_lsx_vsrai_h", + "lsx.vsrai.w" => "__builtin_lsx_vsrai_w", + "lsx.vsran.b.h" => "__builtin_lsx_vsran_b_h", + "lsx.vsran.h.w" => "__builtin_lsx_vsran_h_w", + "lsx.vsran.w.d" => "__builtin_lsx_vsran_w_d", + "lsx.vsrani.b.h" => "__builtin_lsx_vsrani_b_h", + "lsx.vsrani.d.q" => "__builtin_lsx_vsrani_d_q", + "lsx.vsrani.h.w" => "__builtin_lsx_vsrani_h_w", + "lsx.vsrani.w.d" => "__builtin_lsx_vsrani_w_d", + "lsx.vsrar.b" => "__builtin_lsx_vsrar_b", + "lsx.vsrar.d" => "__builtin_lsx_vsrar_d", + "lsx.vsrar.h" => "__builtin_lsx_vsrar_h", + "lsx.vsrar.w" => "__builtin_lsx_vsrar_w", + "lsx.vsrari.b" => "__builtin_lsx_vsrari_b", + "lsx.vsrari.d" => "__builtin_lsx_vsrari_d", + "lsx.vsrari.h" => "__builtin_lsx_vsrari_h", + "lsx.vsrari.w" => "__builtin_lsx_vsrari_w", + "lsx.vsrarn.b.h" => "__builtin_lsx_vsrarn_b_h", + "lsx.vsrarn.h.w" => "__builtin_lsx_vsrarn_h_w", + "lsx.vsrarn.w.d" => "__builtin_lsx_vsrarn_w_d", + "lsx.vsrarni.b.h" => "__builtin_lsx_vsrarni_b_h", + "lsx.vsrarni.d.q" => "__builtin_lsx_vsrarni_d_q", + "lsx.vsrarni.h.w" => "__builtin_lsx_vsrarni_h_w", + "lsx.vsrarni.w.d" => "__builtin_lsx_vsrarni_w_d", + "lsx.vsrl.b" => "__builtin_lsx_vsrl_b", + "lsx.vsrl.d" => "__builtin_lsx_vsrl_d", + "lsx.vsrl.h" => "__builtin_lsx_vsrl_h", + "lsx.vsrl.w" => "__builtin_lsx_vsrl_w", + "lsx.vsrli.b" => "__builtin_lsx_vsrli_b", + "lsx.vsrli.d" => "__builtin_lsx_vsrli_d", + "lsx.vsrli.h" => "__builtin_lsx_vsrli_h", + "lsx.vsrli.w" => "__builtin_lsx_vsrli_w", + "lsx.vsrln.b.h" => "__builtin_lsx_vsrln_b_h", + "lsx.vsrln.h.w" => "__builtin_lsx_vsrln_h_w", + "lsx.vsrln.w.d" => "__builtin_lsx_vsrln_w_d", + "lsx.vsrlni.b.h" => "__builtin_lsx_vsrlni_b_h", + "lsx.vsrlni.d.q" => "__builtin_lsx_vsrlni_d_q", + "lsx.vsrlni.h.w" => "__builtin_lsx_vsrlni_h_w", + "lsx.vsrlni.w.d" => "__builtin_lsx_vsrlni_w_d", + "lsx.vsrlr.b" => "__builtin_lsx_vsrlr_b", + "lsx.vsrlr.d" => "__builtin_lsx_vsrlr_d", + "lsx.vsrlr.h" => "__builtin_lsx_vsrlr_h", + "lsx.vsrlr.w" => "__builtin_lsx_vsrlr_w", + "lsx.vsrlri.b" => "__builtin_lsx_vsrlri_b", + "lsx.vsrlri.d" => "__builtin_lsx_vsrlri_d", + "lsx.vsrlri.h" => "__builtin_lsx_vsrlri_h", + "lsx.vsrlri.w" => "__builtin_lsx_vsrlri_w", + "lsx.vsrlrn.b.h" => "__builtin_lsx_vsrlrn_b_h", + "lsx.vsrlrn.h.w" => "__builtin_lsx_vsrlrn_h_w", + "lsx.vsrlrn.w.d" => "__builtin_lsx_vsrlrn_w_d", + "lsx.vsrlrni.b.h" => "__builtin_lsx_vsrlrni_b_h", + "lsx.vsrlrni.d.q" => "__builtin_lsx_vsrlrni_d_q", + "lsx.vsrlrni.h.w" => "__builtin_lsx_vsrlrni_h_w", + "lsx.vsrlrni.w.d" => "__builtin_lsx_vsrlrni_w_d", + "lsx.vssran.b.h" => "__builtin_lsx_vssran_b_h", + "lsx.vssran.bu.h" => "__builtin_lsx_vssran_bu_h", + "lsx.vssran.h.w" => "__builtin_lsx_vssran_h_w", + "lsx.vssran.hu.w" => "__builtin_lsx_vssran_hu_w", + "lsx.vssran.w.d" => "__builtin_lsx_vssran_w_d", + "lsx.vssran.wu.d" => "__builtin_lsx_vssran_wu_d", + "lsx.vssrani.b.h" => "__builtin_lsx_vssrani_b_h", + "lsx.vssrani.bu.h" => "__builtin_lsx_vssrani_bu_h", + "lsx.vssrani.d.q" => "__builtin_lsx_vssrani_d_q", + "lsx.vssrani.du.q" => "__builtin_lsx_vssrani_du_q", + "lsx.vssrani.h.w" => "__builtin_lsx_vssrani_h_w", + "lsx.vssrani.hu.w" => "__builtin_lsx_vssrani_hu_w", + "lsx.vssrani.w.d" => "__builtin_lsx_vssrani_w_d", + "lsx.vssrani.wu.d" => "__builtin_lsx_vssrani_wu_d", + "lsx.vssrarn.b.h" => "__builtin_lsx_vssrarn_b_h", + "lsx.vssrarn.bu.h" => "__builtin_lsx_vssrarn_bu_h", + "lsx.vssrarn.h.w" => "__builtin_lsx_vssrarn_h_w", + "lsx.vssrarn.hu.w" => "__builtin_lsx_vssrarn_hu_w", + "lsx.vssrarn.w.d" => "__builtin_lsx_vssrarn_w_d", + "lsx.vssrarn.wu.d" => "__builtin_lsx_vssrarn_wu_d", + "lsx.vssrarni.b.h" => "__builtin_lsx_vssrarni_b_h", + "lsx.vssrarni.bu.h" => "__builtin_lsx_vssrarni_bu_h", + "lsx.vssrarni.d.q" => "__builtin_lsx_vssrarni_d_q", + "lsx.vssrarni.du.q" => "__builtin_lsx_vssrarni_du_q", + "lsx.vssrarni.h.w" => "__builtin_lsx_vssrarni_h_w", + "lsx.vssrarni.hu.w" => "__builtin_lsx_vssrarni_hu_w", + "lsx.vssrarni.w.d" => "__builtin_lsx_vssrarni_w_d", + "lsx.vssrarni.wu.d" => "__builtin_lsx_vssrarni_wu_d", + "lsx.vssrln.b.h" => "__builtin_lsx_vssrln_b_h", + "lsx.vssrln.bu.h" => "__builtin_lsx_vssrln_bu_h", + "lsx.vssrln.h.w" => "__builtin_lsx_vssrln_h_w", + "lsx.vssrln.hu.w" => "__builtin_lsx_vssrln_hu_w", + "lsx.vssrln.w.d" => "__builtin_lsx_vssrln_w_d", + "lsx.vssrln.wu.d" => "__builtin_lsx_vssrln_wu_d", + "lsx.vssrlni.b.h" => "__builtin_lsx_vssrlni_b_h", + "lsx.vssrlni.bu.h" => "__builtin_lsx_vssrlni_bu_h", + "lsx.vssrlni.d.q" => "__builtin_lsx_vssrlni_d_q", + "lsx.vssrlni.du.q" => "__builtin_lsx_vssrlni_du_q", + "lsx.vssrlni.h.w" => "__builtin_lsx_vssrlni_h_w", + "lsx.vssrlni.hu.w" => "__builtin_lsx_vssrlni_hu_w", + "lsx.vssrlni.w.d" => "__builtin_lsx_vssrlni_w_d", + "lsx.vssrlni.wu.d" => "__builtin_lsx_vssrlni_wu_d", + "lsx.vssrlrn.b.h" => "__builtin_lsx_vssrlrn_b_h", + "lsx.vssrlrn.bu.h" => "__builtin_lsx_vssrlrn_bu_h", + "lsx.vssrlrn.h.w" => "__builtin_lsx_vssrlrn_h_w", + "lsx.vssrlrn.hu.w" => "__builtin_lsx_vssrlrn_hu_w", + "lsx.vssrlrn.w.d" => "__builtin_lsx_vssrlrn_w_d", + "lsx.vssrlrn.wu.d" => "__builtin_lsx_vssrlrn_wu_d", + "lsx.vssrlrni.b.h" => "__builtin_lsx_vssrlrni_b_h", + "lsx.vssrlrni.bu.h" => "__builtin_lsx_vssrlrni_bu_h", + "lsx.vssrlrni.d.q" => "__builtin_lsx_vssrlrni_d_q", + "lsx.vssrlrni.du.q" => "__builtin_lsx_vssrlrni_du_q", + "lsx.vssrlrni.h.w" => "__builtin_lsx_vssrlrni_h_w", + "lsx.vssrlrni.hu.w" => "__builtin_lsx_vssrlrni_hu_w", + "lsx.vssrlrni.w.d" => "__builtin_lsx_vssrlrni_w_d", + "lsx.vssrlrni.wu.d" => "__builtin_lsx_vssrlrni_wu_d", + "lsx.vssub.b" => "__builtin_lsx_vssub_b", + "lsx.vssub.bu" => "__builtin_lsx_vssub_bu", + "lsx.vssub.d" => "__builtin_lsx_vssub_d", + "lsx.vssub.du" => "__builtin_lsx_vssub_du", + "lsx.vssub.h" => "__builtin_lsx_vssub_h", + "lsx.vssub.hu" => "__builtin_lsx_vssub_hu", + "lsx.vssub.w" => "__builtin_lsx_vssub_w", + "lsx.vssub.wu" => "__builtin_lsx_vssub_wu", + "lsx.vst" => "__builtin_lsx_vst", + "lsx.vstelm.b" => "__builtin_lsx_vstelm_b", + "lsx.vstelm.d" => "__builtin_lsx_vstelm_d", + "lsx.vstelm.h" => "__builtin_lsx_vstelm_h", + "lsx.vstelm.w" => "__builtin_lsx_vstelm_w", + "lsx.vstx" => "__builtin_lsx_vstx", + "lsx.vsub.b" => "__builtin_lsx_vsub_b", + "lsx.vsub.d" => "__builtin_lsx_vsub_d", + "lsx.vsub.h" => "__builtin_lsx_vsub_h", + "lsx.vsub.q" => "__builtin_lsx_vsub_q", + "lsx.vsub.w" => "__builtin_lsx_vsub_w", + "lsx.vsubi.bu" => "__builtin_lsx_vsubi_bu", + "lsx.vsubi.du" => "__builtin_lsx_vsubi_du", + "lsx.vsubi.hu" => "__builtin_lsx_vsubi_hu", + "lsx.vsubi.wu" => "__builtin_lsx_vsubi_wu", + "lsx.vsubwev.d.w" => "__builtin_lsx_vsubwev_d_w", + "lsx.vsubwev.d.wu" => "__builtin_lsx_vsubwev_d_wu", + "lsx.vsubwev.h.b" => "__builtin_lsx_vsubwev_h_b", + "lsx.vsubwev.h.bu" => "__builtin_lsx_vsubwev_h_bu", + "lsx.vsubwev.q.d" => "__builtin_lsx_vsubwev_q_d", + "lsx.vsubwev.q.du" => "__builtin_lsx_vsubwev_q_du", + "lsx.vsubwev.w.h" => "__builtin_lsx_vsubwev_w_h", + "lsx.vsubwev.w.hu" => "__builtin_lsx_vsubwev_w_hu", + "lsx.vsubwod.d.w" => "__builtin_lsx_vsubwod_d_w", + "lsx.vsubwod.d.wu" => "__builtin_lsx_vsubwod_d_wu", + "lsx.vsubwod.h.b" => "__builtin_lsx_vsubwod_h_b", + "lsx.vsubwod.h.bu" => "__builtin_lsx_vsubwod_h_bu", + "lsx.vsubwod.q.d" => "__builtin_lsx_vsubwod_q_d", + "lsx.vsubwod.q.du" => "__builtin_lsx_vsubwod_q_du", + "lsx.vsubwod.w.h" => "__builtin_lsx_vsubwod_w_h", + "lsx.vsubwod.w.hu" => "__builtin_lsx_vsubwod_w_hu", + "lsx.vxor.v" => "__builtin_lsx_vxor_v", + "lsx.vxori.b" => "__builtin_lsx_vxori_b", + "movfcsr2gr" => "__builtin_loongarch_movfcsr2gr", + "movgr2fcsr" => "__builtin_loongarch_movgr2fcsr", + "syscall" => "__builtin_loongarch_syscall", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + loongarch(name, full_name) + } + "mips" => { + #[allow(non_snake_case)] + fn mips(name: &str, full_name: &str) -> &'static str { + match name { + // mips + "absq.s.ph" => "__builtin_mips_absq_s_ph", + "absq.s.qb" => "__builtin_mips_absq_s_qb", + "absq.s.w" => "__builtin_mips_absq_s_w", + "add.a.b" => "__builtin_msa_add_a_b", + "add.a.d" => "__builtin_msa_add_a_d", + "add.a.h" => "__builtin_msa_add_a_h", + "add.a.w" => "__builtin_msa_add_a_w", + "addq.ph" => "__builtin_mips_addq_ph", + "addq.s.ph" => "__builtin_mips_addq_s_ph", + "addq.s.w" => "__builtin_mips_addq_s_w", + "addqh.ph" => "__builtin_mips_addqh_ph", + "addqh.r.ph" => "__builtin_mips_addqh_r_ph", + "addqh.r.w" => "__builtin_mips_addqh_r_w", + "addqh.w" => "__builtin_mips_addqh_w", + "adds.a.b" => "__builtin_msa_adds_a_b", + "adds.a.d" => "__builtin_msa_adds_a_d", + "adds.a.h" => "__builtin_msa_adds_a_h", + "adds.a.w" => "__builtin_msa_adds_a_w", + "adds.s.b" => "__builtin_msa_adds_s_b", + "adds.s.d" => "__builtin_msa_adds_s_d", + "adds.s.h" => "__builtin_msa_adds_s_h", + "adds.s.w" => "__builtin_msa_adds_s_w", + "adds.u.b" => "__builtin_msa_adds_u_b", + "adds.u.d" => "__builtin_msa_adds_u_d", + "adds.u.h" => "__builtin_msa_adds_u_h", + "adds.u.w" => "__builtin_msa_adds_u_w", + "addsc" => "__builtin_mips_addsc", + "addu.ph" => "__builtin_mips_addu_ph", + "addu.qb" => "__builtin_mips_addu_qb", + "addu.s.ph" => "__builtin_mips_addu_s_ph", + "addu.s.qb" => "__builtin_mips_addu_s_qb", + "adduh.qb" => "__builtin_mips_adduh_qb", + "adduh.r.qb" => "__builtin_mips_adduh_r_qb", + "addv.b" => "__builtin_msa_addv_b", + "addv.d" => "__builtin_msa_addv_d", + "addv.h" => "__builtin_msa_addv_h", + "addv.w" => "__builtin_msa_addv_w", + "addvi.b" => "__builtin_msa_addvi_b", + "addvi.d" => "__builtin_msa_addvi_d", + "addvi.h" => "__builtin_msa_addvi_h", + "addvi.w" => "__builtin_msa_addvi_w", + "addwc" => "__builtin_mips_addwc", + "and.v" => "__builtin_msa_and_v", + "andi.b" => "__builtin_msa_andi_b", + "append" => "__builtin_mips_append", + "asub.s.b" => "__builtin_msa_asub_s_b", + "asub.s.d" => "__builtin_msa_asub_s_d", + "asub.s.h" => "__builtin_msa_asub_s_h", + "asub.s.w" => "__builtin_msa_asub_s_w", + "asub.u.b" => "__builtin_msa_asub_u_b", + "asub.u.d" => "__builtin_msa_asub_u_d", + "asub.u.h" => "__builtin_msa_asub_u_h", + "asub.u.w" => "__builtin_msa_asub_u_w", + "ave.s.b" => "__builtin_msa_ave_s_b", + "ave.s.d" => "__builtin_msa_ave_s_d", + "ave.s.h" => "__builtin_msa_ave_s_h", + "ave.s.w" => "__builtin_msa_ave_s_w", + "ave.u.b" => "__builtin_msa_ave_u_b", + "ave.u.d" => "__builtin_msa_ave_u_d", + "ave.u.h" => "__builtin_msa_ave_u_h", + "ave.u.w" => "__builtin_msa_ave_u_w", + "aver.s.b" => "__builtin_msa_aver_s_b", + "aver.s.d" => "__builtin_msa_aver_s_d", + "aver.s.h" => "__builtin_msa_aver_s_h", + "aver.s.w" => "__builtin_msa_aver_s_w", + "aver.u.b" => "__builtin_msa_aver_u_b", + "aver.u.d" => "__builtin_msa_aver_u_d", + "aver.u.h" => "__builtin_msa_aver_u_h", + "aver.u.w" => "__builtin_msa_aver_u_w", + "balign" => "__builtin_mips_balign", + "bclr.b" => "__builtin_msa_bclr_b", + "bclr.d" => "__builtin_msa_bclr_d", + "bclr.h" => "__builtin_msa_bclr_h", + "bclr.w" => "__builtin_msa_bclr_w", + "bclri.b" => "__builtin_msa_bclri_b", + "bclri.d" => "__builtin_msa_bclri_d", + "bclri.h" => "__builtin_msa_bclri_h", + "bclri.w" => "__builtin_msa_bclri_w", + "binsl.b" => "__builtin_msa_binsl_b", + "binsl.d" => "__builtin_msa_binsl_d", + "binsl.h" => "__builtin_msa_binsl_h", + "binsl.w" => "__builtin_msa_binsl_w", + "binsli.b" => "__builtin_msa_binsli_b", + "binsli.d" => "__builtin_msa_binsli_d", + "binsli.h" => "__builtin_msa_binsli_h", + "binsli.w" => "__builtin_msa_binsli_w", + "binsr.b" => "__builtin_msa_binsr_b", + "binsr.d" => "__builtin_msa_binsr_d", + "binsr.h" => "__builtin_msa_binsr_h", + "binsr.w" => "__builtin_msa_binsr_w", + "binsri.b" => "__builtin_msa_binsri_b", + "binsri.d" => "__builtin_msa_binsri_d", + "binsri.h" => "__builtin_msa_binsri_h", + "binsri.w" => "__builtin_msa_binsri_w", + "bitrev" => "__builtin_mips_bitrev", + "bmnz.v" => "__builtin_msa_bmnz_v", + "bmnzi.b" => "__builtin_msa_bmnzi_b", + "bmz.v" => "__builtin_msa_bmz_v", + "bmzi.b" => "__builtin_msa_bmzi_b", + "bneg.b" => "__builtin_msa_bneg_b", + "bneg.d" => "__builtin_msa_bneg_d", + "bneg.h" => "__builtin_msa_bneg_h", + "bneg.w" => "__builtin_msa_bneg_w", + "bnegi.b" => "__builtin_msa_bnegi_b", + "bnegi.d" => "__builtin_msa_bnegi_d", + "bnegi.h" => "__builtin_msa_bnegi_h", + "bnegi.w" => "__builtin_msa_bnegi_w", + "bnz.b" => "__builtin_msa_bnz_b", + "bnz.d" => "__builtin_msa_bnz_d", + "bnz.h" => "__builtin_msa_bnz_h", + "bnz.v" => "__builtin_msa_bnz_v", + "bnz.w" => "__builtin_msa_bnz_w", + "bposge32" => "__builtin_mips_bposge32", + "bsel.v" => "__builtin_msa_bsel_v", + "bseli.b" => "__builtin_msa_bseli_b", + "bset.b" => "__builtin_msa_bset_b", + "bset.d" => "__builtin_msa_bset_d", + "bset.h" => "__builtin_msa_bset_h", + "bset.w" => "__builtin_msa_bset_w", + "bseti.b" => "__builtin_msa_bseti_b", + "bseti.d" => "__builtin_msa_bseti_d", + "bseti.h" => "__builtin_msa_bseti_h", + "bseti.w" => "__builtin_msa_bseti_w", + "bz.b" => "__builtin_msa_bz_b", + "bz.d" => "__builtin_msa_bz_d", + "bz.h" => "__builtin_msa_bz_h", + "bz.v" => "__builtin_msa_bz_v", + "bz.w" => "__builtin_msa_bz_w", + "ceq.b" => "__builtin_msa_ceq_b", + "ceq.d" => "__builtin_msa_ceq_d", + "ceq.h" => "__builtin_msa_ceq_h", + "ceq.w" => "__builtin_msa_ceq_w", + "ceqi.b" => "__builtin_msa_ceqi_b", + "ceqi.d" => "__builtin_msa_ceqi_d", + "ceqi.h" => "__builtin_msa_ceqi_h", + "ceqi.w" => "__builtin_msa_ceqi_w", + "cfcmsa" => "__builtin_msa_cfcmsa", + "cle.s.b" => "__builtin_msa_cle_s_b", + "cle.s.d" => "__builtin_msa_cle_s_d", + "cle.s.h" => "__builtin_msa_cle_s_h", + "cle.s.w" => "__builtin_msa_cle_s_w", + "cle.u.b" => "__builtin_msa_cle_u_b", + "cle.u.d" => "__builtin_msa_cle_u_d", + "cle.u.h" => "__builtin_msa_cle_u_h", + "cle.u.w" => "__builtin_msa_cle_u_w", + "clei.s.b" => "__builtin_msa_clei_s_b", + "clei.s.d" => "__builtin_msa_clei_s_d", + "clei.s.h" => "__builtin_msa_clei_s_h", + "clei.s.w" => "__builtin_msa_clei_s_w", + "clei.u.b" => "__builtin_msa_clei_u_b", + "clei.u.d" => "__builtin_msa_clei_u_d", + "clei.u.h" => "__builtin_msa_clei_u_h", + "clei.u.w" => "__builtin_msa_clei_u_w", + "clt.s.b" => "__builtin_msa_clt_s_b", + "clt.s.d" => "__builtin_msa_clt_s_d", + "clt.s.h" => "__builtin_msa_clt_s_h", + "clt.s.w" => "__builtin_msa_clt_s_w", + "clt.u.b" => "__builtin_msa_clt_u_b", + "clt.u.d" => "__builtin_msa_clt_u_d", + "clt.u.h" => "__builtin_msa_clt_u_h", + "clt.u.w" => "__builtin_msa_clt_u_w", + "clti.s.b" => "__builtin_msa_clti_s_b", + "clti.s.d" => "__builtin_msa_clti_s_d", + "clti.s.h" => "__builtin_msa_clti_s_h", + "clti.s.w" => "__builtin_msa_clti_s_w", + "clti.u.b" => "__builtin_msa_clti_u_b", + "clti.u.d" => "__builtin_msa_clti_u_d", + "clti.u.h" => "__builtin_msa_clti_u_h", + "clti.u.w" => "__builtin_msa_clti_u_w", + "cmp.eq.ph" => "__builtin_mips_cmp_eq_ph", + "cmp.le.ph" => "__builtin_mips_cmp_le_ph", + "cmp.lt.ph" => "__builtin_mips_cmp_lt_ph", + "cmpgdu.eq.qb" => "__builtin_mips_cmpgdu_eq_qb", + "cmpgdu.le.qb" => "__builtin_mips_cmpgdu_le_qb", + "cmpgdu.lt.qb" => "__builtin_mips_cmpgdu_lt_qb", + "cmpgu.eq.qb" => "__builtin_mips_cmpgu_eq_qb", + "cmpgu.le.qb" => "__builtin_mips_cmpgu_le_qb", + "cmpgu.lt.qb" => "__builtin_mips_cmpgu_lt_qb", + "cmpu.eq.qb" => "__builtin_mips_cmpu_eq_qb", + "cmpu.le.qb" => "__builtin_mips_cmpu_le_qb", + "cmpu.lt.qb" => "__builtin_mips_cmpu_lt_qb", + "copy.s.b" => "__builtin_msa_copy_s_b", + "copy.s.d" => "__builtin_msa_copy_s_d", + "copy.s.h" => "__builtin_msa_copy_s_h", + "copy.s.w" => "__builtin_msa_copy_s_w", + "copy.u.b" => "__builtin_msa_copy_u_b", + "copy.u.d" => "__builtin_msa_copy_u_d", + "copy.u.h" => "__builtin_msa_copy_u_h", + "copy.u.w" => "__builtin_msa_copy_u_w", + "ctcmsa" => "__builtin_msa_ctcmsa", + "div.s.b" => "__builtin_msa_div_s_b", + "div.s.d" => "__builtin_msa_div_s_d", + "div.s.h" => "__builtin_msa_div_s_h", + "div.s.w" => "__builtin_msa_div_s_w", + "div.u.b" => "__builtin_msa_div_u_b", + "div.u.d" => "__builtin_msa_div_u_d", + "div.u.h" => "__builtin_msa_div_u_h", + "div.u.w" => "__builtin_msa_div_u_w", + "dlsa" => "__builtin_mips_dlsa", + "dotp.s.d" => "__builtin_msa_dotp_s_d", + "dotp.s.h" => "__builtin_msa_dotp_s_h", + "dotp.s.w" => "__builtin_msa_dotp_s_w", + "dotp.u.d" => "__builtin_msa_dotp_u_d", + "dotp.u.h" => "__builtin_msa_dotp_u_h", + "dotp.u.w" => "__builtin_msa_dotp_u_w", + "dpa.w.ph" => "__builtin_mips_dpa_w_ph", + "dpadd.s.d" => "__builtin_msa_dpadd_s_d", + "dpadd.s.h" => "__builtin_msa_dpadd_s_h", + "dpadd.s.w" => "__builtin_msa_dpadd_s_w", + "dpadd.u.d" => "__builtin_msa_dpadd_u_d", + "dpadd.u.h" => "__builtin_msa_dpadd_u_h", + "dpadd.u.w" => "__builtin_msa_dpadd_u_w", + "dpaq.s.w.ph" => "__builtin_mips_dpaq_s_w_ph", + "dpaq.sa.l.w" => "__builtin_mips_dpaq_sa_l_w", + "dpaqx.s.w.ph" => "__builtin_mips_dpaqx_s_w_ph", + "dpaqx.sa.w.ph" => "__builtin_mips_dpaqx_sa_w_ph", + "dpau.h.qbl" => "__builtin_mips_dpau_h_qbl", + "dpau.h.qbr" => "__builtin_mips_dpau_h_qbr", + "dpax.w.ph" => "__builtin_mips_dpax_w_ph", + "dps.w.ph" => "__builtin_mips_dps_w_ph", + "dpsq.s.w.ph" => "__builtin_mips_dpsq_s_w_ph", + "dpsq.sa.l.w" => "__builtin_mips_dpsq_sa_l_w", + "dpsqx.s.w.ph" => "__builtin_mips_dpsqx_s_w_ph", + "dpsqx.sa.w.ph" => "__builtin_mips_dpsqx_sa_w_ph", + "dpsu.h.qbl" => "__builtin_mips_dpsu_h_qbl", + "dpsu.h.qbr" => "__builtin_mips_dpsu_h_qbr", + "dpsub.s.d" => "__builtin_msa_dpsub_s_d", + "dpsub.s.h" => "__builtin_msa_dpsub_s_h", + "dpsub.s.w" => "__builtin_msa_dpsub_s_w", + "dpsub.u.d" => "__builtin_msa_dpsub_u_d", + "dpsub.u.h" => "__builtin_msa_dpsub_u_h", + "dpsub.u.w" => "__builtin_msa_dpsub_u_w", + "dpsx.w.ph" => "__builtin_mips_dpsx_w_ph", + "extp" => "__builtin_mips_extp", + "extpdp" => "__builtin_mips_extpdp", + "extr.r.w" => "__builtin_mips_extr_r_w", + "extr.rs.w" => "__builtin_mips_extr_rs_w", + "extr.s.h" => "__builtin_mips_extr_s_h", + "extr.w" => "__builtin_mips_extr_w", + "fadd.d" => "__builtin_msa_fadd_d", + "fadd.w" => "__builtin_msa_fadd_w", + "fcaf.d" => "__builtin_msa_fcaf_d", + "fcaf.w" => "__builtin_msa_fcaf_w", + "fceq.d" => "__builtin_msa_fceq_d", + "fceq.w" => "__builtin_msa_fceq_w", + "fclass.d" => "__builtin_msa_fclass_d", + "fclass.w" => "__builtin_msa_fclass_w", + "fcle.d" => "__builtin_msa_fcle_d", + "fcle.w" => "__builtin_msa_fcle_w", + "fclt.d" => "__builtin_msa_fclt_d", + "fclt.w" => "__builtin_msa_fclt_w", + "fcne.d" => "__builtin_msa_fcne_d", + "fcne.w" => "__builtin_msa_fcne_w", + "fcor.d" => "__builtin_msa_fcor_d", + "fcor.w" => "__builtin_msa_fcor_w", + "fcueq.d" => "__builtin_msa_fcueq_d", + "fcueq.w" => "__builtin_msa_fcueq_w", + "fcule.d" => "__builtin_msa_fcule_d", + "fcule.w" => "__builtin_msa_fcule_w", + "fcult.d" => "__builtin_msa_fcult_d", + "fcult.w" => "__builtin_msa_fcult_w", + "fcun.d" => "__builtin_msa_fcun_d", + "fcun.w" => "__builtin_msa_fcun_w", + "fcune.d" => "__builtin_msa_fcune_d", + "fcune.w" => "__builtin_msa_fcune_w", + "fdiv.d" => "__builtin_msa_fdiv_d", + "fdiv.w" => "__builtin_msa_fdiv_w", + "fexdo.h" => "__builtin_msa_fexdo_h", + "fexdo.w" => "__builtin_msa_fexdo_w", + "fexp2.d" => "__builtin_msa_fexp2_d", + "fexp2.w" => "__builtin_msa_fexp2_w", + "fexupl.d" => "__builtin_msa_fexupl_d", + "fexupl.w" => "__builtin_msa_fexupl_w", + "fexupr.d" => "__builtin_msa_fexupr_d", + "fexupr.w" => "__builtin_msa_fexupr_w", + "ffint.s.d" => "__builtin_msa_ffint_s_d", + "ffint.s.w" => "__builtin_msa_ffint_s_w", + "ffint.u.d" => "__builtin_msa_ffint_u_d", + "ffint.u.w" => "__builtin_msa_ffint_u_w", + "ffql.d" => "__builtin_msa_ffql_d", + "ffql.w" => "__builtin_msa_ffql_w", + "ffqr.d" => "__builtin_msa_ffqr_d", + "ffqr.w" => "__builtin_msa_ffqr_w", + "fill.b" => "__builtin_msa_fill_b", + "fill.d" => "__builtin_msa_fill_d", + "fill.h" => "__builtin_msa_fill_h", + "fill.w" => "__builtin_msa_fill_w", + "flog2.d" => "__builtin_msa_flog2_d", + "flog2.w" => "__builtin_msa_flog2_w", + "fmadd.d" => "__builtin_msa_fmadd_d", + "fmadd.w" => "__builtin_msa_fmadd_w", + "fmax.a.d" => "__builtin_msa_fmax_a_d", + "fmax.a.w" => "__builtin_msa_fmax_a_w", + "fmax.d" => "__builtin_msa_fmax_d", + "fmax.w" => "__builtin_msa_fmax_w", + "fmin.a.d" => "__builtin_msa_fmin_a_d", + "fmin.a.w" => "__builtin_msa_fmin_a_w", + "fmin.d" => "__builtin_msa_fmin_d", + "fmin.w" => "__builtin_msa_fmin_w", + "fmsub.d" => "__builtin_msa_fmsub_d", + "fmsub.w" => "__builtin_msa_fmsub_w", + "fmul.d" => "__builtin_msa_fmul_d", + "fmul.w" => "__builtin_msa_fmul_w", + "frcp.d" => "__builtin_msa_frcp_d", + "frcp.w" => "__builtin_msa_frcp_w", + "frint.d" => "__builtin_msa_frint_d", + "frint.w" => "__builtin_msa_frint_w", + "frsqrt.d" => "__builtin_msa_frsqrt_d", + "frsqrt.w" => "__builtin_msa_frsqrt_w", + "fsaf.d" => "__builtin_msa_fsaf_d", + "fsaf.w" => "__builtin_msa_fsaf_w", + "fseq.d" => "__builtin_msa_fseq_d", + "fseq.w" => "__builtin_msa_fseq_w", + "fsle.d" => "__builtin_msa_fsle_d", + "fsle.w" => "__builtin_msa_fsle_w", + "fslt.d" => "__builtin_msa_fslt_d", + "fslt.w" => "__builtin_msa_fslt_w", + "fsne.d" => "__builtin_msa_fsne_d", + "fsne.w" => "__builtin_msa_fsne_w", + "fsor.d" => "__builtin_msa_fsor_d", + "fsor.w" => "__builtin_msa_fsor_w", + "fsqrt.d" => "__builtin_msa_fsqrt_d", + "fsqrt.w" => "__builtin_msa_fsqrt_w", + "fsub.d" => "__builtin_msa_fsub_d", + "fsub.w" => "__builtin_msa_fsub_w", + "fsueq.d" => "__builtin_msa_fsueq_d", + "fsueq.w" => "__builtin_msa_fsueq_w", + "fsule.d" => "__builtin_msa_fsule_d", + "fsule.w" => "__builtin_msa_fsule_w", + "fsult.d" => "__builtin_msa_fsult_d", + "fsult.w" => "__builtin_msa_fsult_w", + "fsun.d" => "__builtin_msa_fsun_d", + "fsun.w" => "__builtin_msa_fsun_w", + "fsune.d" => "__builtin_msa_fsune_d", + "fsune.w" => "__builtin_msa_fsune_w", + "ftint.s.d" => "__builtin_msa_ftint_s_d", + "ftint.s.w" => "__builtin_msa_ftint_s_w", + "ftint.u.d" => "__builtin_msa_ftint_u_d", + "ftint.u.w" => "__builtin_msa_ftint_u_w", + "ftq.h" => "__builtin_msa_ftq_h", + "ftq.w" => "__builtin_msa_ftq_w", + "ftrunc.s.d" => "__builtin_msa_ftrunc_s_d", + "ftrunc.s.w" => "__builtin_msa_ftrunc_s_w", + "ftrunc.u.d" => "__builtin_msa_ftrunc_u_d", + "ftrunc.u.w" => "__builtin_msa_ftrunc_u_w", + "hadd.s.d" => "__builtin_msa_hadd_s_d", + "hadd.s.h" => "__builtin_msa_hadd_s_h", + "hadd.s.w" => "__builtin_msa_hadd_s_w", + "hadd.u.d" => "__builtin_msa_hadd_u_d", + "hadd.u.h" => "__builtin_msa_hadd_u_h", + "hadd.u.w" => "__builtin_msa_hadd_u_w", + "hsub.s.d" => "__builtin_msa_hsub_s_d", + "hsub.s.h" => "__builtin_msa_hsub_s_h", + "hsub.s.w" => "__builtin_msa_hsub_s_w", + "hsub.u.d" => "__builtin_msa_hsub_u_d", + "hsub.u.h" => "__builtin_msa_hsub_u_h", + "hsub.u.w" => "__builtin_msa_hsub_u_w", + "ilvev.b" => "__builtin_msa_ilvev_b", + "ilvev.d" => "__builtin_msa_ilvev_d", + "ilvev.h" => "__builtin_msa_ilvev_h", + "ilvev.w" => "__builtin_msa_ilvev_w", + "ilvl.b" => "__builtin_msa_ilvl_b", + "ilvl.d" => "__builtin_msa_ilvl_d", + "ilvl.h" => "__builtin_msa_ilvl_h", + "ilvl.w" => "__builtin_msa_ilvl_w", + "ilvod.b" => "__builtin_msa_ilvod_b", + "ilvod.d" => "__builtin_msa_ilvod_d", + "ilvod.h" => "__builtin_msa_ilvod_h", + "ilvod.w" => "__builtin_msa_ilvod_w", + "ilvr.b" => "__builtin_msa_ilvr_b", + "ilvr.d" => "__builtin_msa_ilvr_d", + "ilvr.h" => "__builtin_msa_ilvr_h", + "ilvr.w" => "__builtin_msa_ilvr_w", + "insert.b" => "__builtin_msa_insert_b", + "insert.d" => "__builtin_msa_insert_d", + "insert.h" => "__builtin_msa_insert_h", + "insert.w" => "__builtin_msa_insert_w", + "insv" => "__builtin_mips_insv", + "insve.b" => "__builtin_msa_insve_b", + "insve.d" => "__builtin_msa_insve_d", + "insve.h" => "__builtin_msa_insve_h", + "insve.w" => "__builtin_msa_insve_w", + "lbux" => "__builtin_mips_lbux", + "ld.b" => "__builtin_msa_ld_b", + "ld.d" => "__builtin_msa_ld_d", + "ld.h" => "__builtin_msa_ld_h", + "ld.w" => "__builtin_msa_ld_w", + "ldi.b" => "__builtin_msa_ldi_b", + "ldi.d" => "__builtin_msa_ldi_d", + "ldi.h" => "__builtin_msa_ldi_h", + "ldi.w" => "__builtin_msa_ldi_w", + "ldr.d" => "__builtin_msa_ldr_d", + "ldr.w" => "__builtin_msa_ldr_w", + "lhx" => "__builtin_mips_lhx", + "lsa" => "__builtin_mips_lsa", + "lwx" => "__builtin_mips_lwx", + "madd" => "__builtin_mips_madd", + "madd.q.h" => "__builtin_msa_madd_q_h", + "madd.q.w" => "__builtin_msa_madd_q_w", + "maddr.q.h" => "__builtin_msa_maddr_q_h", + "maddr.q.w" => "__builtin_msa_maddr_q_w", + "maddu" => "__builtin_mips_maddu", + "maddv.b" => "__builtin_msa_maddv_b", + "maddv.d" => "__builtin_msa_maddv_d", + "maddv.h" => "__builtin_msa_maddv_h", + "maddv.w" => "__builtin_msa_maddv_w", + "maq.s.w.phl" => "__builtin_mips_maq_s_w_phl", + "maq.s.w.phr" => "__builtin_mips_maq_s_w_phr", + "maq.sa.w.phl" => "__builtin_mips_maq_sa_w_phl", + "maq.sa.w.phr" => "__builtin_mips_maq_sa_w_phr", + "max.a.b" => "__builtin_msa_max_a_b", + "max.a.d" => "__builtin_msa_max_a_d", + "max.a.h" => "__builtin_msa_max_a_h", + "max.a.w" => "__builtin_msa_max_a_w", + "max.s.b" => "__builtin_msa_max_s_b", + "max.s.d" => "__builtin_msa_max_s_d", + "max.s.h" => "__builtin_msa_max_s_h", + "max.s.w" => "__builtin_msa_max_s_w", + "max.u.b" => "__builtin_msa_max_u_b", + "max.u.d" => "__builtin_msa_max_u_d", + "max.u.h" => "__builtin_msa_max_u_h", + "max.u.w" => "__builtin_msa_max_u_w", + "maxi.s.b" => "__builtin_msa_maxi_s_b", + "maxi.s.d" => "__builtin_msa_maxi_s_d", + "maxi.s.h" => "__builtin_msa_maxi_s_h", + "maxi.s.w" => "__builtin_msa_maxi_s_w", + "maxi.u.b" => "__builtin_msa_maxi_u_b", + "maxi.u.d" => "__builtin_msa_maxi_u_d", + "maxi.u.h" => "__builtin_msa_maxi_u_h", + "maxi.u.w" => "__builtin_msa_maxi_u_w", + "min.a.b" => "__builtin_msa_min_a_b", + "min.a.d" => "__builtin_msa_min_a_d", + "min.a.h" => "__builtin_msa_min_a_h", + "min.a.w" => "__builtin_msa_min_a_w", + "min.s.b" => "__builtin_msa_min_s_b", + "min.s.d" => "__builtin_msa_min_s_d", + "min.s.h" => "__builtin_msa_min_s_h", + "min.s.w" => "__builtin_msa_min_s_w", + "min.u.b" => "__builtin_msa_min_u_b", + "min.u.d" => "__builtin_msa_min_u_d", + "min.u.h" => "__builtin_msa_min_u_h", + "min.u.w" => "__builtin_msa_min_u_w", + "mini.s.b" => "__builtin_msa_mini_s_b", + "mini.s.d" => "__builtin_msa_mini_s_d", + "mini.s.h" => "__builtin_msa_mini_s_h", + "mini.s.w" => "__builtin_msa_mini_s_w", + "mini.u.b" => "__builtin_msa_mini_u_b", + "mini.u.d" => "__builtin_msa_mini_u_d", + "mini.u.h" => "__builtin_msa_mini_u_h", + "mini.u.w" => "__builtin_msa_mini_u_w", + "mod.s.b" => "__builtin_msa_mod_s_b", + "mod.s.d" => "__builtin_msa_mod_s_d", + "mod.s.h" => "__builtin_msa_mod_s_h", + "mod.s.w" => "__builtin_msa_mod_s_w", + "mod.u.b" => "__builtin_msa_mod_u_b", + "mod.u.d" => "__builtin_msa_mod_u_d", + "mod.u.h" => "__builtin_msa_mod_u_h", + "mod.u.w" => "__builtin_msa_mod_u_w", + "modsub" => "__builtin_mips_modsub", + "move.v" => "__builtin_msa_move_v", + "msub" => "__builtin_mips_msub", + "msub.q.h" => "__builtin_msa_msub_q_h", + "msub.q.w" => "__builtin_msa_msub_q_w", + "msubr.q.h" => "__builtin_msa_msubr_q_h", + "msubr.q.w" => "__builtin_msa_msubr_q_w", + "msubu" => "__builtin_mips_msubu", + "msubv.b" => "__builtin_msa_msubv_b", + "msubv.d" => "__builtin_msa_msubv_d", + "msubv.h" => "__builtin_msa_msubv_h", + "msubv.w" => "__builtin_msa_msubv_w", + "mthlip" => "__builtin_mips_mthlip", + "mul.ph" => "__builtin_mips_mul_ph", + "mul.q.h" => "__builtin_msa_mul_q_h", + "mul.q.w" => "__builtin_msa_mul_q_w", + "mul.s.ph" => "__builtin_mips_mul_s_ph", + "muleq.s.w.phl" => "__builtin_mips_muleq_s_w_phl", + "muleq.s.w.phr" => "__builtin_mips_muleq_s_w_phr", + "muleu.s.ph.qbl" => "__builtin_mips_muleu_s_ph_qbl", + "muleu.s.ph.qbr" => "__builtin_mips_muleu_s_ph_qbr", + "mulq.rs.ph" => "__builtin_mips_mulq_rs_ph", + "mulq.rs.w" => "__builtin_mips_mulq_rs_w", + "mulq.s.ph" => "__builtin_mips_mulq_s_ph", + "mulq.s.w" => "__builtin_mips_mulq_s_w", + "mulr.q.h" => "__builtin_msa_mulr_q_h", + "mulr.q.w" => "__builtin_msa_mulr_q_w", + "mulsa.w.ph" => "__builtin_mips_mulsa_w_ph", + "mulsaq.s.w.ph" => "__builtin_mips_mulsaq_s_w_ph", + "mult" => "__builtin_mips_mult", + "multu" => "__builtin_mips_multu", + "mulv.b" => "__builtin_msa_mulv_b", + "mulv.d" => "__builtin_msa_mulv_d", + "mulv.h" => "__builtin_msa_mulv_h", + "mulv.w" => "__builtin_msa_mulv_w", + "nloc.b" => "__builtin_msa_nloc_b", + "nloc.d" => "__builtin_msa_nloc_d", + "nloc.h" => "__builtin_msa_nloc_h", + "nloc.w" => "__builtin_msa_nloc_w", + "nlzc.b" => "__builtin_msa_nlzc_b", + "nlzc.d" => "__builtin_msa_nlzc_d", + "nlzc.h" => "__builtin_msa_nlzc_h", + "nlzc.w" => "__builtin_msa_nlzc_w", + "nor.v" => "__builtin_msa_nor_v", + "nori.b" => "__builtin_msa_nori_b", + "or.v" => "__builtin_msa_or_v", + "ori.b" => "__builtin_msa_ori_b", + "packrl.ph" => "__builtin_mips_packrl_ph", + "pckev.b" => "__builtin_msa_pckev_b", + "pckev.d" => "__builtin_msa_pckev_d", + "pckev.h" => "__builtin_msa_pckev_h", + "pckev.w" => "__builtin_msa_pckev_w", + "pckod.b" => "__builtin_msa_pckod_b", + "pckod.d" => "__builtin_msa_pckod_d", + "pckod.h" => "__builtin_msa_pckod_h", + "pckod.w" => "__builtin_msa_pckod_w", + "pcnt.b" => "__builtin_msa_pcnt_b", + "pcnt.d" => "__builtin_msa_pcnt_d", + "pcnt.h" => "__builtin_msa_pcnt_h", + "pcnt.w" => "__builtin_msa_pcnt_w", + "pick.ph" => "__builtin_mips_pick_ph", + "pick.qb" => "__builtin_mips_pick_qb", + "preceq.w.phl" => "__builtin_mips_preceq_w_phl", + "preceq.w.phr" => "__builtin_mips_preceq_w_phr", + "precequ.ph.qbl" => "__builtin_mips_precequ_ph_qbl", + "precequ.ph.qbla" => "__builtin_mips_precequ_ph_qbla", + "precequ.ph.qbr" => "__builtin_mips_precequ_ph_qbr", + "precequ.ph.qbra" => "__builtin_mips_precequ_ph_qbra", + "preceu.ph.qbl" => "__builtin_mips_preceu_ph_qbl", + "preceu.ph.qbla" => "__builtin_mips_preceu_ph_qbla", + "preceu.ph.qbr" => "__builtin_mips_preceu_ph_qbr", + "preceu.ph.qbra" => "__builtin_mips_preceu_ph_qbra", + "precr.qb.ph" => "__builtin_mips_precr_qb_ph", + "precr.sra.ph.w" => "__builtin_mips_precr_sra_ph_w", + "precr.sra.r.ph.w" => "__builtin_mips_precr_sra_r_ph_w", + "precrq.ph.w" => "__builtin_mips_precrq_ph_w", + "precrq.qb.ph" => "__builtin_mips_precrq_qb_ph", + "precrq.rs.ph.w" => "__builtin_mips_precrq_rs_ph_w", + "precrqu.s.qb.ph" => "__builtin_mips_precrqu_s_qb_ph", + "prepend" => "__builtin_mips_prepend", + "raddu.w.qb" => "__builtin_mips_raddu_w_qb", + "rddsp" => "__builtin_mips_rddsp", + "repl.ph" => "__builtin_mips_repl_ph", + "repl.qb" => "__builtin_mips_repl_qb", + "sat.s.b" => "__builtin_msa_sat_s_b", + "sat.s.d" => "__builtin_msa_sat_s_d", + "sat.s.h" => "__builtin_msa_sat_s_h", + "sat.s.w" => "__builtin_msa_sat_s_w", + "sat.u.b" => "__builtin_msa_sat_u_b", + "sat.u.d" => "__builtin_msa_sat_u_d", + "sat.u.h" => "__builtin_msa_sat_u_h", + "sat.u.w" => "__builtin_msa_sat_u_w", + "shf.b" => "__builtin_msa_shf_b", + "shf.h" => "__builtin_msa_shf_h", + "shf.w" => "__builtin_msa_shf_w", + "shilo" => "__builtin_mips_shilo", + "shll.ph" => "__builtin_mips_shll_ph", + "shll.qb" => "__builtin_mips_shll_qb", + "shll.s.ph" => "__builtin_mips_shll_s_ph", + "shll.s.w" => "__builtin_mips_shll_s_w", + "shra.ph" => "__builtin_mips_shra_ph", + "shra.qb" => "__builtin_mips_shra_qb", + "shra.r.ph" => "__builtin_mips_shra_r_ph", + "shra.r.qb" => "__builtin_mips_shra_r_qb", + "shra.r.w" => "__builtin_mips_shra_r_w", + "shrl.ph" => "__builtin_mips_shrl_ph", + "shrl.qb" => "__builtin_mips_shrl_qb", + "sld.b" => "__builtin_msa_sld_b", + "sld.d" => "__builtin_msa_sld_d", + "sld.h" => "__builtin_msa_sld_h", + "sld.w" => "__builtin_msa_sld_w", + "sldi.b" => "__builtin_msa_sldi_b", + "sldi.d" => "__builtin_msa_sldi_d", + "sldi.h" => "__builtin_msa_sldi_h", + "sldi.w" => "__builtin_msa_sldi_w", + "sll.b" => "__builtin_msa_sll_b", + "sll.d" => "__builtin_msa_sll_d", + "sll.h" => "__builtin_msa_sll_h", + "sll.w" => "__builtin_msa_sll_w", + "slli.b" => "__builtin_msa_slli_b", + "slli.d" => "__builtin_msa_slli_d", + "slli.h" => "__builtin_msa_slli_h", + "slli.w" => "__builtin_msa_slli_w", + "splat.b" => "__builtin_msa_splat_b", + "splat.d" => "__builtin_msa_splat_d", + "splat.h" => "__builtin_msa_splat_h", + "splat.w" => "__builtin_msa_splat_w", + "splati.b" => "__builtin_msa_splati_b", + "splati.d" => "__builtin_msa_splati_d", + "splati.h" => "__builtin_msa_splati_h", + "splati.w" => "__builtin_msa_splati_w", + "sra.b" => "__builtin_msa_sra_b", + "sra.d" => "__builtin_msa_sra_d", + "sra.h" => "__builtin_msa_sra_h", + "sra.w" => "__builtin_msa_sra_w", + "srai.b" => "__builtin_msa_srai_b", + "srai.d" => "__builtin_msa_srai_d", + "srai.h" => "__builtin_msa_srai_h", + "srai.w" => "__builtin_msa_srai_w", + "srar.b" => "__builtin_msa_srar_b", + "srar.d" => "__builtin_msa_srar_d", + "srar.h" => "__builtin_msa_srar_h", + "srar.w" => "__builtin_msa_srar_w", + "srari.b" => "__builtin_msa_srari_b", + "srari.d" => "__builtin_msa_srari_d", + "srari.h" => "__builtin_msa_srari_h", + "srari.w" => "__builtin_msa_srari_w", + "srl.b" => "__builtin_msa_srl_b", + "srl.d" => "__builtin_msa_srl_d", + "srl.h" => "__builtin_msa_srl_h", + "srl.w" => "__builtin_msa_srl_w", + "srli.b" => "__builtin_msa_srli_b", + "srli.d" => "__builtin_msa_srli_d", + "srli.h" => "__builtin_msa_srli_h", + "srli.w" => "__builtin_msa_srli_w", + "srlr.b" => "__builtin_msa_srlr_b", + "srlr.d" => "__builtin_msa_srlr_d", + "srlr.h" => "__builtin_msa_srlr_h", + "srlr.w" => "__builtin_msa_srlr_w", + "srlri.b" => "__builtin_msa_srlri_b", + "srlri.d" => "__builtin_msa_srlri_d", + "srlri.h" => "__builtin_msa_srlri_h", + "srlri.w" => "__builtin_msa_srlri_w", + "st.b" => "__builtin_msa_st_b", + "st.d" => "__builtin_msa_st_d", + "st.h" => "__builtin_msa_st_h", + "st.w" => "__builtin_msa_st_w", + "str.d" => "__builtin_msa_str_d", + "str.w" => "__builtin_msa_str_w", + "subq.ph" => "__builtin_mips_subq_ph", + "subq.s.ph" => "__builtin_mips_subq_s_ph", + "subq.s.w" => "__builtin_mips_subq_s_w", + "subqh.ph" => "__builtin_mips_subqh_ph", + "subqh.r.ph" => "__builtin_mips_subqh_r_ph", + "subqh.r.w" => "__builtin_mips_subqh_r_w", + "subqh.w" => "__builtin_mips_subqh_w", + "subs.s.b" => "__builtin_msa_subs_s_b", + "subs.s.d" => "__builtin_msa_subs_s_d", + "subs.s.h" => "__builtin_msa_subs_s_h", + "subs.s.w" => "__builtin_msa_subs_s_w", + "subs.u.b" => "__builtin_msa_subs_u_b", + "subs.u.d" => "__builtin_msa_subs_u_d", + "subs.u.h" => "__builtin_msa_subs_u_h", + "subs.u.w" => "__builtin_msa_subs_u_w", + "subsus.u.b" => "__builtin_msa_subsus_u_b", + "subsus.u.d" => "__builtin_msa_subsus_u_d", + "subsus.u.h" => "__builtin_msa_subsus_u_h", + "subsus.u.w" => "__builtin_msa_subsus_u_w", + "subsuu.s.b" => "__builtin_msa_subsuu_s_b", + "subsuu.s.d" => "__builtin_msa_subsuu_s_d", + "subsuu.s.h" => "__builtin_msa_subsuu_s_h", + "subsuu.s.w" => "__builtin_msa_subsuu_s_w", + "subu.ph" => "__builtin_mips_subu_ph", + "subu.qb" => "__builtin_mips_subu_qb", + "subu.s.ph" => "__builtin_mips_subu_s_ph", + "subu.s.qb" => "__builtin_mips_subu_s_qb", + "subuh.qb" => "__builtin_mips_subuh_qb", + "subuh.r.qb" => "__builtin_mips_subuh_r_qb", + "subv.b" => "__builtin_msa_subv_b", + "subv.d" => "__builtin_msa_subv_d", + "subv.h" => "__builtin_msa_subv_h", + "subv.w" => "__builtin_msa_subv_w", + "subvi.b" => "__builtin_msa_subvi_b", + "subvi.d" => "__builtin_msa_subvi_d", + "subvi.h" => "__builtin_msa_subvi_h", + "subvi.w" => "__builtin_msa_subvi_w", + "vshf.b" => "__builtin_msa_vshf_b", + "vshf.d" => "__builtin_msa_vshf_d", + "vshf.h" => "__builtin_msa_vshf_h", + "vshf.w" => "__builtin_msa_vshf_w", + "wrdsp" => "__builtin_mips_wrdsp", + "xor.v" => "__builtin_msa_xor_v", + "xori.b" => "__builtin_msa_xori_b", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + mips(name, full_name) + } + "nvvm" => { + #[allow(non_snake_case)] + fn nvvm(name: &str, full_name: &str) -> &'static str { + match name { + // nvvm + "abs.i" => "__nvvm_abs_i", + "abs.ll" => "__nvvm_abs_ll", + "activemask" => "__nvvm_activemask", + "add.rm.d" => "__nvvm_add_rm_d", + "add.rm.f" => "__nvvm_add_rm_f", + "add.rm.ftz.f" => "__nvvm_add_rm_ftz_f", + "add.rn.d" => "__nvvm_add_rn_d", + "add.rn.f" => "__nvvm_add_rn_f", + "add.rn.ftz.f" => "__nvvm_add_rn_ftz_f", + "add.rp.d" => "__nvvm_add_rp_d", + "add.rp.f" => "__nvvm_add_rp_f", + "add.rp.ftz.f" => "__nvvm_add_rp_ftz_f", + "add.rz.d" => "__nvvm_add_rz_d", + "add.rz.f" => "__nvvm_add_rz_f", + "add.rz.ftz.f" => "__nvvm_add_rz_ftz_f", + "bar.sync" => "__nvvm_bar_sync", + "bar.warp.sync" => "__nvvm_bar_warp_sync", + "barrier0" => "__nvvm_bar0", + // [DUPLICATE]: "barrier0" => "__syncthreads", + "barrier0.and" => "__nvvm_bar0_and", + "barrier0.or" => "__nvvm_bar0_or", + "barrier0.popc" => "__nvvm_bar0_popc", + "bf16x2.to.ue8m0x2.rp" => "__nvvm_bf16x2_to_ue8m0x2_rp", + "bf16x2.to.ue8m0x2.rp.satfinite" => "__nvvm_bf16x2_to_ue8m0x2_rp_satfinite", + "bf16x2.to.ue8m0x2.rz" => "__nvvm_bf16x2_to_ue8m0x2_rz", + "bf16x2.to.ue8m0x2.rz.satfinite" => "__nvvm_bf16x2_to_ue8m0x2_rz_satfinite", + "bf2h.rn" => "__nvvm_bf2h_rn", + "bf2h.rn.ftz" => "__nvvm_bf2h_rn_ftz", + "bitcast.d2ll" => "__nvvm_bitcast_d2ll", + "bitcast.f2i" => "__nvvm_bitcast_f2i", + "bitcast.i2f" => "__nvvm_bitcast_i2f", + "bitcast.ll2d" => "__nvvm_bitcast_ll2d", + "brev32" => "__nvvm_brev32", + "brev64" => "__nvvm_brev64", + "ceil.d" => "__nvvm_ceil_d", + "ceil.f" => "__nvvm_ceil_f", + "ceil.ftz.f" => "__nvvm_ceil_ftz_f", + "clz.i" => "__nvvm_clz_i", + "clz.ll" => "__nvvm_clz_ll", + "cos.approx.f" => "__nvvm_cos_approx_f", + "cos.approx.ftz.f" => "__nvvm_cos_approx_ftz_f", + "cp.async.commit.group" => "__nvvm_cp_async_commit_group", + "cp.async.mbarrier.arrive" => "__nvvm_cp_async_mbarrier_arrive", + "cp.async.mbarrier.arrive.noinc" => "__nvvm_cp_async_mbarrier_arrive_noinc", + "cp.async.mbarrier.arrive.noinc.shared" => { + "__nvvm_cp_async_mbarrier_arrive_noinc_shared" + } + "cp.async.mbarrier.arrive.shared" => "__nvvm_cp_async_mbarrier_arrive_shared", + "cp.async.wait.all" => "__nvvm_cp_async_wait_all", + "cp.async.wait.group" => "__nvvm_cp_async_wait_group", + "d2f.rm" => "__nvvm_d2f_rm", + "d2f.rm.ftz" => "__nvvm_d2f_rm_ftz", + "d2f.rn" => "__nvvm_d2f_rn", + "d2f.rn.ftz" => "__nvvm_d2f_rn_ftz", + "d2f.rp" => "__nvvm_d2f_rp", + "d2f.rp.ftz" => "__nvvm_d2f_rp_ftz", + "d2f.rz" => "__nvvm_d2f_rz", + "d2f.rz.ftz" => "__nvvm_d2f_rz_ftz", + "d2i.hi" => "__nvvm_d2i_hi", + "d2i.lo" => "__nvvm_d2i_lo", + "d2i.rm" => "__nvvm_d2i_rm", + "d2i.rn" => "__nvvm_d2i_rn", + "d2i.rp" => "__nvvm_d2i_rp", + "d2i.rz" => "__nvvm_d2i_rz", + "d2ll.rm" => "__nvvm_d2ll_rm", + "d2ll.rn" => "__nvvm_d2ll_rn", + "d2ll.rp" => "__nvvm_d2ll_rp", + "d2ll.rz" => "__nvvm_d2ll_rz", + "d2ui.rm" => "__nvvm_d2ui_rm", + "d2ui.rn" => "__nvvm_d2ui_rn", + "d2ui.rp" => "__nvvm_d2ui_rp", + "d2ui.rz" => "__nvvm_d2ui_rz", + "d2ull.rm" => "__nvvm_d2ull_rm", + "d2ull.rn" => "__nvvm_d2ull_rn", + "d2ull.rp" => "__nvvm_d2ull_rp", + "d2ull.rz" => "__nvvm_d2ull_rz", + "div.approx.f" => "__nvvm_div_approx_f", + "div.approx.ftz.f" => "__nvvm_div_approx_ftz_f", + "div.full" => "__nvvm_div_full", + "div.full.ftz" => "__nvvm_div_full_ftz", + "div.rm.d" => "__nvvm_div_rm_d", + "div.rm.f" => "__nvvm_div_rm_f", + "div.rm.ftz.f" => "__nvvm_div_rm_ftz_f", + "div.rn.d" => "__nvvm_div_rn_d", + "div.rn.f" => "__nvvm_div_rn_f", + "div.rn.ftz.f" => "__nvvm_div_rn_ftz_f", + "div.rp.d" => "__nvvm_div_rp_d", + "div.rp.f" => "__nvvm_div_rp_f", + "div.rp.ftz.f" => "__nvvm_div_rp_ftz_f", + "div.rz.d" => "__nvvm_div_rz_d", + "div.rz.f" => "__nvvm_div_rz_f", + "div.rz.ftz.f" => "__nvvm_div_rz_ftz_f", + "e2m1x2.to.f16x2.rn" => "__nvvm_e2m1x2_to_f16x2_rn", + "e2m1x2.to.f16x2.rn.relu" => "__nvvm_e2m1x2_to_f16x2_rn_relu", + "e2m3x2.to.f16x2.rn" => "__nvvm_e2m3x2_to_f16x2_rn", + "e2m3x2.to.f16x2.rn.relu" => "__nvvm_e2m3x2_to_f16x2_rn_relu", + "e3m2x2.to.f16x2.rn" => "__nvvm_e3m2x2_to_f16x2_rn", + "e3m2x2.to.f16x2.rn.relu" => "__nvvm_e3m2x2_to_f16x2_rn_relu", + "e4m3x2.to.f16x2.rn" => "__nvvm_e4m3x2_to_f16x2_rn", + "e4m3x2.to.f16x2.rn.relu" => "__nvvm_e4m3x2_to_f16x2_rn_relu", + "e5m2x2.to.f16x2.rn" => "__nvvm_e5m2x2_to_f16x2_rn", + "e5m2x2.to.f16x2.rn.relu" => "__nvvm_e5m2x2_to_f16x2_rn_relu", + "ex2.approx.d" => "__nvvm_ex2_approx_d", + "ex2.approx.f" => "__nvvm_ex2_approx_f", + "ex2.approx.ftz.f" => "__nvvm_ex2_approx_ftz_f", + "exit" => "__nvvm_exit", + "f16x2.to.e4m3x2.rn" => "__nvvm_f16x2_to_e4m3x2_rn", + "f16x2.to.e4m3x2.rn.relu" => "__nvvm_f16x2_to_e4m3x2_rn_relu", + "f16x2.to.e5m2x2.rn" => "__nvvm_f16x2_to_e5m2x2_rn", + "f16x2.to.e5m2x2.rn.relu" => "__nvvm_f16x2_to_e5m2x2_rn_relu", + "f2bf16.rn" => "__nvvm_f2bf16_rn", + "f2bf16.rn.relu" => "__nvvm_f2bf16_rn_relu", + "f2bf16.rz" => "__nvvm_f2bf16_rz", + "f2bf16.rz.relu" => "__nvvm_f2bf16_rz_relu", + "f2h.rn" => "__nvvm_f2h_rn", + "f2h.rn.ftz" => "__nvvm_f2h_rn_ftz", + "f2i.rm" => "__nvvm_f2i_rm", + "f2i.rm.ftz" => "__nvvm_f2i_rm_ftz", + "f2i.rn" => "__nvvm_f2i_rn", + "f2i.rn.ftz" => "__nvvm_f2i_rn_ftz", + "f2i.rp" => "__nvvm_f2i_rp", + "f2i.rp.ftz" => "__nvvm_f2i_rp_ftz", + "f2i.rz" => "__nvvm_f2i_rz", + "f2i.rz.ftz" => "__nvvm_f2i_rz_ftz", + "f2ll.rm" => "__nvvm_f2ll_rm", + "f2ll.rm.ftz" => "__nvvm_f2ll_rm_ftz", + "f2ll.rn" => "__nvvm_f2ll_rn", + "f2ll.rn.ftz" => "__nvvm_f2ll_rn_ftz", + "f2ll.rp" => "__nvvm_f2ll_rp", + "f2ll.rp.ftz" => "__nvvm_f2ll_rp_ftz", + "f2ll.rz" => "__nvvm_f2ll_rz", + "f2ll.rz.ftz" => "__nvvm_f2ll_rz_ftz", + "f2tf32.rn" => "__nvvm_f2tf32_rn", + "f2tf32.rn.relu" => "__nvvm_f2tf32_rn_relu", + "f2tf32.rn.relu.satfinite" => "__nvvm_f2tf32_rn_relu_satfinite", + "f2tf32.rn.satfinite" => "__nvvm_f2tf32_rn_satfinite", + "f2tf32.rna" => "__nvvm_f2tf32_rna", + "f2tf32.rna.satfinite" => "__nvvm_f2tf32_rna_satfinite", + "f2tf32.rz" => "__nvvm_f2tf32_rz", + "f2tf32.rz.relu" => "__nvvm_f2tf32_rz_relu", + "f2tf32.rz.relu.satfinite" => "__nvvm_f2tf32_rz_relu_satfinite", + "f2tf32.rz.satfinite" => "__nvvm_f2tf32_rz_satfinite", + "f2ui.rm" => "__nvvm_f2ui_rm", + "f2ui.rm.ftz" => "__nvvm_f2ui_rm_ftz", + "f2ui.rn" => "__nvvm_f2ui_rn", + "f2ui.rn.ftz" => "__nvvm_f2ui_rn_ftz", + "f2ui.rp" => "__nvvm_f2ui_rp", + "f2ui.rp.ftz" => "__nvvm_f2ui_rp_ftz", + "f2ui.rz" => "__nvvm_f2ui_rz", + "f2ui.rz.ftz" => "__nvvm_f2ui_rz_ftz", + "f2ull.rm" => "__nvvm_f2ull_rm", + "f2ull.rm.ftz" => "__nvvm_f2ull_rm_ftz", + "f2ull.rn" => "__nvvm_f2ull_rn", + "f2ull.rn.ftz" => "__nvvm_f2ull_rn_ftz", + "f2ull.rp" => "__nvvm_f2ull_rp", + "f2ull.rp.ftz" => "__nvvm_f2ull_rp_ftz", + "f2ull.rz" => "__nvvm_f2ull_rz", + "f2ull.rz.ftz" => "__nvvm_f2ull_rz_ftz", + "fabs.d" => "__nvvm_fabs_d", + "fabs.f" => "__nvvm_fabs_f", + "fabs.ftz.f" => "__nvvm_fabs_ftz_f", + "ff.to.e2m1x2.rn.relu.satfinite" => "__nvvm_ff_to_e2m1x2_rn_relu_satfinite", + "ff.to.e2m1x2.rn.satfinite" => "__nvvm_ff_to_e2m1x2_rn_satfinite", + "ff.to.e2m3x2.rn.relu.satfinite" => "__nvvm_ff_to_e2m3x2_rn_relu_satfinite", + "ff.to.e2m3x2.rn.satfinite" => "__nvvm_ff_to_e2m3x2_rn_satfinite", + "ff.to.e3m2x2.rn.relu.satfinite" => "__nvvm_ff_to_e3m2x2_rn_relu_satfinite", + "ff.to.e3m2x2.rn.satfinite" => "__nvvm_ff_to_e3m2x2_rn_satfinite", + "ff.to.e4m3x2.rn" => "__nvvm_ff_to_e4m3x2_rn", + "ff.to.e4m3x2.rn.relu" => "__nvvm_ff_to_e4m3x2_rn_relu", + "ff.to.e5m2x2.rn" => "__nvvm_ff_to_e5m2x2_rn", + "ff.to.e5m2x2.rn.relu" => "__nvvm_ff_to_e5m2x2_rn_relu", + "ff.to.ue8m0x2.rp" => "__nvvm_ff_to_ue8m0x2_rp", + "ff.to.ue8m0x2.rp.satfinite" => "__nvvm_ff_to_ue8m0x2_rp_satfinite", + "ff.to.ue8m0x2.rz" => "__nvvm_ff_to_ue8m0x2_rz", + "ff.to.ue8m0x2.rz.satfinite" => "__nvvm_ff_to_ue8m0x2_rz_satfinite", + "ff2bf16x2.rn" => "__nvvm_ff2bf16x2_rn", + "ff2bf16x2.rn.relu" => "__nvvm_ff2bf16x2_rn_relu", + "ff2bf16x2.rz" => "__nvvm_ff2bf16x2_rz", + "ff2bf16x2.rz.relu" => "__nvvm_ff2bf16x2_rz_relu", + "ff2f16x2.rn" => "__nvvm_ff2f16x2_rn", + "ff2f16x2.rn.relu" => "__nvvm_ff2f16x2_rn_relu", + "ff2f16x2.rz" => "__nvvm_ff2f16x2_rz", + "ff2f16x2.rz.relu" => "__nvvm_ff2f16x2_rz_relu", + "floor.d" => "__nvvm_floor_d", + "floor.f" => "__nvvm_floor_f", + "floor.ftz.f" => "__nvvm_floor_ftz_f", + "fma.rm.d" => "__nvvm_fma_rm_d", + "fma.rm.f" => "__nvvm_fma_rm_f", + "fma.rm.ftz.f" => "__nvvm_fma_rm_ftz_f", + "fma.rn.bf16" => "__nvvm_fma_rn_bf16", + "fma.rn.bf16x2" => "__nvvm_fma_rn_bf16x2", + "fma.rn.d" => "__nvvm_fma_rn_d", + "fma.rn.f" => "__nvvm_fma_rn_f", + "fma.rn.ftz.bf16" => "__nvvm_fma_rn_ftz_bf16", + "fma.rn.ftz.bf16x2" => "__nvvm_fma_rn_ftz_bf16x2", + "fma.rn.ftz.f" => "__nvvm_fma_rn_ftz_f", + "fma.rn.ftz.relu.bf16" => "__nvvm_fma_rn_ftz_relu_bf16", + "fma.rn.ftz.relu.bf16x2" => "__nvvm_fma_rn_ftz_relu_bf16x2", + "fma.rn.ftz.sat.bf16" => "__nvvm_fma_rn_ftz_sat_bf16", + "fma.rn.ftz.sat.bf16x2" => "__nvvm_fma_rn_ftz_sat_bf16x2", + "fma.rn.relu.bf16" => "__nvvm_fma_rn_relu_bf16", + "fma.rn.relu.bf16x2" => "__nvvm_fma_rn_relu_bf16x2", + "fma.rn.sat.bf16" => "__nvvm_fma_rn_sat_bf16", + "fma.rn.sat.bf16x2" => "__nvvm_fma_rn_sat_bf16x2", + "fma.rp.d" => "__nvvm_fma_rp_d", + "fma.rp.f" => "__nvvm_fma_rp_f", + "fma.rp.ftz.f" => "__nvvm_fma_rp_ftz_f", + "fma.rz.d" => "__nvvm_fma_rz_d", + "fma.rz.f" => "__nvvm_fma_rz_f", + "fma.rz.ftz.f" => "__nvvm_fma_rz_ftz_f", + "fmax.bf16" => "__nvvm_fmax_bf16", + "fmax.bf16x2" => "__nvvm_fmax_bf16x2", + "fmax.d" => "__nvvm_fmax_d", + "fmax.f" => "__nvvm_fmax_f", + "fmax.ftz.bf16" => "__nvvm_fmax_ftz_bf16", + "fmax.ftz.bf16x2" => "__nvvm_fmax_ftz_bf16x2", + "fmax.ftz.f" => "__nvvm_fmax_ftz_f", + "fmax.ftz.nan.bf16" => "__nvvm_fmax_ftz_nan_bf16", + "fmax.ftz.nan.bf16x2" => "__nvvm_fmax_ftz_nan_bf16x2", + "fmax.ftz.nan.f" => "__nvvm_fmax_ftz_nan_f", + "fmax.ftz.nan.xorsign.abs.bf16" => "__nvvm_fmax_ftz_nan_xorsign_abs_bf16", + "fmax.ftz.nan.xorsign.abs.bf16x2" => "__nvvm_fmax_ftz_nan_xorsign_abs_bf16x2", + "fmax.ftz.nan.xorsign.abs.f" => "__nvvm_fmax_ftz_nan_xorsign_abs_f", + "fmax.ftz.xorsign.abs.bf16" => "__nvvm_fmax_ftz_xorsign_abs_bf16", + "fmax.ftz.xorsign.abs.bf16x2" => "__nvvm_fmax_ftz_xorsign_abs_bf16x2", + "fmax.ftz.xorsign.abs.f" => "__nvvm_fmax_ftz_xorsign_abs_f", + "fmax.nan.bf16" => "__nvvm_fmax_nan_bf16", + "fmax.nan.bf16x2" => "__nvvm_fmax_nan_bf16x2", + "fmax.nan.f" => "__nvvm_fmax_nan_f", + "fmax.nan.xorsign.abs.bf16" => "__nvvm_fmax_nan_xorsign_abs_bf16", + "fmax.nan.xorsign.abs.bf16x2" => "__nvvm_fmax_nan_xorsign_abs_bf16x2", + "fmax.nan.xorsign.abs.f" => "__nvvm_fmax_nan_xorsign_abs_f", + "fmax.xorsign.abs.bf16" => "__nvvm_fmax_xorsign_abs_bf16", + "fmax.xorsign.abs.bf16x2" => "__nvvm_fmax_xorsign_abs_bf16x2", + "fmax.xorsign.abs.f" => "__nvvm_fmax_xorsign_abs_f", + "fmin.bf16" => "__nvvm_fmin_bf16", + "fmin.bf16x2" => "__nvvm_fmin_bf16x2", + "fmin.d" => "__nvvm_fmin_d", + "fmin.f" => "__nvvm_fmin_f", + "fmin.ftz.bf16" => "__nvvm_fmin_ftz_bf16", + "fmin.ftz.bf16x2" => "__nvvm_fmin_ftz_bf16x2", + "fmin.ftz.f" => "__nvvm_fmin_ftz_f", + "fmin.ftz.nan.bf16" => "__nvvm_fmin_ftz_nan_bf16", + "fmin.ftz.nan.bf16x2" => "__nvvm_fmin_ftz_nan_bf16x2", + "fmin.ftz.nan.f" => "__nvvm_fmin_ftz_nan_f", + "fmin.ftz.nan.xorsign.abs.bf16" => "__nvvm_fmin_ftz_nan_xorsign_abs_bf16", + "fmin.ftz.nan.xorsign.abs.bf16x2" => "__nvvm_fmin_ftz_nan_xorsign_abs_bf16x2", + "fmin.ftz.nan.xorsign.abs.f" => "__nvvm_fmin_ftz_nan_xorsign_abs_f", + "fmin.ftz.xorsign.abs.bf16" => "__nvvm_fmin_ftz_xorsign_abs_bf16", + "fmin.ftz.xorsign.abs.bf16x2" => "__nvvm_fmin_ftz_xorsign_abs_bf16x2", + "fmin.ftz.xorsign.abs.f" => "__nvvm_fmin_ftz_xorsign_abs_f", + "fmin.nan.bf16" => "__nvvm_fmin_nan_bf16", + "fmin.nan.bf16x2" => "__nvvm_fmin_nan_bf16x2", + "fmin.nan.f" => "__nvvm_fmin_nan_f", + "fmin.nan.xorsign.abs.bf16" => "__nvvm_fmin_nan_xorsign_abs_bf16", + "fmin.nan.xorsign.abs.bf16x2" => "__nvvm_fmin_nan_xorsign_abs_bf16x2", + "fmin.nan.xorsign.abs.f" => "__nvvm_fmin_nan_xorsign_abs_f", + "fmin.xorsign.abs.bf16" => "__nvvm_fmin_xorsign_abs_bf16", + "fmin.xorsign.abs.bf16x2" => "__nvvm_fmin_xorsign_abs_bf16x2", + "fmin.xorsign.abs.f" => "__nvvm_fmin_xorsign_abs_f", + "fns" => "__nvvm_fns", + "h2f" => "__nvvm_h2f", + "i2d.rm" => "__nvvm_i2d_rm", + "i2d.rn" => "__nvvm_i2d_rn", + "i2d.rp" => "__nvvm_i2d_rp", + "i2d.rz" => "__nvvm_i2d_rz", + "i2f.rm" => "__nvvm_i2f_rm", + "i2f.rn" => "__nvvm_i2f_rn", + "i2f.rp" => "__nvvm_i2f_rp", + "i2f.rz" => "__nvvm_i2f_rz", + "isspacep.const" => "__nvvm_isspacep_const", + "isspacep.global" => "__nvvm_isspacep_global", + "isspacep.local" => "__nvvm_isspacep_local", + "isspacep.shared" => "__nvvm_isspacep_shared", + "isspacep.shared.cluster" => "__nvvm_isspacep_shared_cluster", + "istypep.sampler" => "__nvvm_istypep_sampler", + "istypep.surface" => "__nvvm_istypep_surface", + "istypep.texture" => "__nvvm_istypep_texture", + "lg2.approx.d" => "__nvvm_lg2_approx_d", + "lg2.approx.f" => "__nvvm_lg2_approx_f", + "lg2.approx.ftz.f" => "__nvvm_lg2_approx_ftz_f", + "ll2d.rm" => "__nvvm_ll2d_rm", + "ll2d.rn" => "__nvvm_ll2d_rn", + "ll2d.rp" => "__nvvm_ll2d_rp", + "ll2d.rz" => "__nvvm_ll2d_rz", + "ll2f.rm" => "__nvvm_ll2f_rm", + "ll2f.rn" => "__nvvm_ll2f_rn", + "ll2f.rp" => "__nvvm_ll2f_rp", + "ll2f.rz" => "__nvvm_ll2f_rz", + "lohi.i2d" => "__nvvm_lohi_i2d", + "match.any.sync.i32" => "__nvvm_match_any_sync_i32", + "match.any.sync.i64" => "__nvvm_match_any_sync_i64", + "max.i" => "__nvvm_max_i", + "max.ll" => "__nvvm_max_ll", + "max.ui" => "__nvvm_max_ui", + "max.ull" => "__nvvm_max_ull", + "mbarrier.arrive" => "__nvvm_mbarrier_arrive", + "mbarrier.arrive.drop" => "__nvvm_mbarrier_arrive_drop", + "mbarrier.arrive.drop.noComplete" => "__nvvm_mbarrier_arrive_drop_noComplete", + "mbarrier.arrive.drop.noComplete.shared" => { + "__nvvm_mbarrier_arrive_drop_noComplete_shared" + } + "mbarrier.arrive.drop.shared" => "__nvvm_mbarrier_arrive_drop_shared", + "mbarrier.arrive.noComplete" => "__nvvm_mbarrier_arrive_noComplete", + "mbarrier.arrive.noComplete.shared" => { + "__nvvm_mbarrier_arrive_noComplete_shared" + } + "mbarrier.arrive.shared" => "__nvvm_mbarrier_arrive_shared", + "mbarrier.init" => "__nvvm_mbarrier_init", + "mbarrier.init.shared" => "__nvvm_mbarrier_init_shared", + "mbarrier.inval" => "__nvvm_mbarrier_inval", + "mbarrier.inval.shared" => "__nvvm_mbarrier_inval_shared", + "mbarrier.pending.count" => "__nvvm_mbarrier_pending_count", + "mbarrier.test.wait" => "__nvvm_mbarrier_test_wait", + "mbarrier.test.wait.shared" => "__nvvm_mbarrier_test_wait_shared", + "membar.cta" => "__nvvm_membar_cta", + "membar.gl" => "__nvvm_membar_gl", + "membar.sys" => "__nvvm_membar_sys", + "min.i" => "__nvvm_min_i", + "min.ll" => "__nvvm_min_ll", + "min.ui" => "__nvvm_min_ui", + "min.ull" => "__nvvm_min_ull", + "mul.rm.d" => "__nvvm_mul_rm_d", + "mul.rm.f" => "__nvvm_mul_rm_f", + "mul.rm.ftz.f" => "__nvvm_mul_rm_ftz_f", + "mul.rn.d" => "__nvvm_mul_rn_d", + "mul.rn.f" => "__nvvm_mul_rn_f", + "mul.rn.ftz.f" => "__nvvm_mul_rn_ftz_f", + "mul.rp.d" => "__nvvm_mul_rp_d", + "mul.rp.f" => "__nvvm_mul_rp_f", + "mul.rp.ftz.f" => "__nvvm_mul_rp_ftz_f", + "mul.rz.d" => "__nvvm_mul_rz_d", + "mul.rz.f" => "__nvvm_mul_rz_f", + "mul.rz.ftz.f" => "__nvvm_mul_rz_ftz_f", + "mul24.i" => "__nvvm_mul24_i", + "mul24.ui" => "__nvvm_mul24_ui", + "mulhi.i" => "__nvvm_mulhi_i", + "mulhi.ll" => "__nvvm_mulhi_ll", + "mulhi.s" => "__nvvm_mulhi_s", + "mulhi.ui" => "__nvvm_mulhi_ui", + "mulhi.ull" => "__nvvm_mulhi_ull", + "mulhi.us" => "__nvvm_mulhi_us", + "nanosleep" => "__nvvm_nanosleep", + "neg.bf16" => "__nvvm_neg_bf16", + "neg.bf16x2" => "__nvvm_neg_bf16x2", + "pm.event.mask" => "__nvvm_pm_event_mask", + "popc.i" => "__nvvm_popc_i", + "popc.ll" => "__nvvm_popc_ll", + "prmt" => "__nvvm_prmt", + "rcp.approx.ftz.d" => "__nvvm_rcp_approx_ftz_d", + "rcp.approx.ftz.f" => "__nvvm_rcp_approx_ftz_f", + "rcp.rm.d" => "__nvvm_rcp_rm_d", + "rcp.rm.f" => "__nvvm_rcp_rm_f", + "rcp.rm.ftz.f" => "__nvvm_rcp_rm_ftz_f", + "rcp.rn.d" => "__nvvm_rcp_rn_d", + "rcp.rn.f" => "__nvvm_rcp_rn_f", + "rcp.rn.ftz.f" => "__nvvm_rcp_rn_ftz_f", + "rcp.rp.d" => "__nvvm_rcp_rp_d", + "rcp.rp.f" => "__nvvm_rcp_rp_f", + "rcp.rp.ftz.f" => "__nvvm_rcp_rp_ftz_f", + "rcp.rz.d" => "__nvvm_rcp_rz_d", + "rcp.rz.f" => "__nvvm_rcp_rz_f", + "rcp.rz.ftz.f" => "__nvvm_rcp_rz_ftz_f", + "read.ptx.sreg.clock" => "__nvvm_read_ptx_sreg_clock", + // [DUPLICATE]: "read.ptx.sreg.clock" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.clock64" => "__nvvm_read_ptx_sreg_clock64", + // [DUPLICATE]: "read.ptx.sreg.clock64" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.ctaid.w" => "__nvvm_read_ptx_sreg_ctaid_w", + "read.ptx.sreg.ctaid.x" => "__nvvm_read_ptx_sreg_ctaid_x", + "read.ptx.sreg.ctaid.y" => "__nvvm_read_ptx_sreg_ctaid_y", + "read.ptx.sreg.ctaid.z" => "__nvvm_read_ptx_sreg_ctaid_z", + "read.ptx.sreg.envreg0" => "__nvvm_read_ptx_sreg_envreg0", + "read.ptx.sreg.envreg1" => "__nvvm_read_ptx_sreg_envreg1", + "read.ptx.sreg.envreg10" => "__nvvm_read_ptx_sreg_envreg10", + "read.ptx.sreg.envreg11" => "__nvvm_read_ptx_sreg_envreg11", + "read.ptx.sreg.envreg12" => "__nvvm_read_ptx_sreg_envreg12", + "read.ptx.sreg.envreg13" => "__nvvm_read_ptx_sreg_envreg13", + "read.ptx.sreg.envreg14" => "__nvvm_read_ptx_sreg_envreg14", + "read.ptx.sreg.envreg15" => "__nvvm_read_ptx_sreg_envreg15", + "read.ptx.sreg.envreg16" => "__nvvm_read_ptx_sreg_envreg16", + "read.ptx.sreg.envreg17" => "__nvvm_read_ptx_sreg_envreg17", + "read.ptx.sreg.envreg18" => "__nvvm_read_ptx_sreg_envreg18", + "read.ptx.sreg.envreg19" => "__nvvm_read_ptx_sreg_envreg19", + "read.ptx.sreg.envreg2" => "__nvvm_read_ptx_sreg_envreg2", + "read.ptx.sreg.envreg20" => "__nvvm_read_ptx_sreg_envreg20", + "read.ptx.sreg.envreg21" => "__nvvm_read_ptx_sreg_envreg21", + "read.ptx.sreg.envreg22" => "__nvvm_read_ptx_sreg_envreg22", + "read.ptx.sreg.envreg23" => "__nvvm_read_ptx_sreg_envreg23", + "read.ptx.sreg.envreg24" => "__nvvm_read_ptx_sreg_envreg24", + "read.ptx.sreg.envreg25" => "__nvvm_read_ptx_sreg_envreg25", + "read.ptx.sreg.envreg26" => "__nvvm_read_ptx_sreg_envreg26", + "read.ptx.sreg.envreg27" => "__nvvm_read_ptx_sreg_envreg27", + "read.ptx.sreg.envreg28" => "__nvvm_read_ptx_sreg_envreg28", + "read.ptx.sreg.envreg29" => "__nvvm_read_ptx_sreg_envreg29", + "read.ptx.sreg.envreg3" => "__nvvm_read_ptx_sreg_envreg3", + "read.ptx.sreg.envreg30" => "__nvvm_read_ptx_sreg_envreg30", + "read.ptx.sreg.envreg31" => "__nvvm_read_ptx_sreg_envreg31", + "read.ptx.sreg.envreg4" => "__nvvm_read_ptx_sreg_envreg4", + "read.ptx.sreg.envreg5" => "__nvvm_read_ptx_sreg_envreg5", + "read.ptx.sreg.envreg6" => "__nvvm_read_ptx_sreg_envreg6", + "read.ptx.sreg.envreg7" => "__nvvm_read_ptx_sreg_envreg7", + "read.ptx.sreg.envreg8" => "__nvvm_read_ptx_sreg_envreg8", + "read.ptx.sreg.envreg9" => "__nvvm_read_ptx_sreg_envreg9", + "read.ptx.sreg.globaltimer" => "__nvvm_read_ptx_sreg_globaltimer", + "read.ptx.sreg.gridid" => "__nvvm_read_ptx_sreg_gridid", + // [DUPLICATE]: "read.ptx.sreg.gridid" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.laneid" => "__nvvm_read_ptx_sreg_laneid", + // [DUPLICATE]: "read.ptx.sreg.laneid" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.lanemask.eq" => "__nvvm_read_ptx_sreg_lanemask_eq", + // [DUPLICATE]: "read.ptx.sreg.lanemask.eq" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.lanemask.ge" => "__nvvm_read_ptx_sreg_lanemask_ge", + // [DUPLICATE]: "read.ptx.sreg.lanemask.ge" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.lanemask.gt" => "__nvvm_read_ptx_sreg_lanemask_gt", + // [DUPLICATE]: "read.ptx.sreg.lanemask.gt" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.lanemask.le" => "__nvvm_read_ptx_sreg_lanemask_le", + // [DUPLICATE]: "read.ptx.sreg.lanemask.le" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.lanemask.lt" => "__nvvm_read_ptx_sreg_lanemask_lt", + // [DUPLICATE]: "read.ptx.sreg.lanemask.lt" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.nctaid.w" => "__nvvm_read_ptx_sreg_nctaid_w", + "read.ptx.sreg.nctaid.x" => "__nvvm_read_ptx_sreg_nctaid_x", + "read.ptx.sreg.nctaid.y" => "__nvvm_read_ptx_sreg_nctaid_y", + "read.ptx.sreg.nctaid.z" => "__nvvm_read_ptx_sreg_nctaid_z", + "read.ptx.sreg.nsmid" => "__nvvm_read_ptx_sreg_nsmid", + // [DUPLICATE]: "read.ptx.sreg.nsmid" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.ntid.w" => "__nvvm_read_ptx_sreg_ntid_w", + "read.ptx.sreg.ntid.x" => "__nvvm_read_ptx_sreg_ntid_x", + "read.ptx.sreg.ntid.y" => "__nvvm_read_ptx_sreg_ntid_y", + "read.ptx.sreg.ntid.z" => "__nvvm_read_ptx_sreg_ntid_z", + "read.ptx.sreg.nwarpid" => "__nvvm_read_ptx_sreg_nwarpid", + // [DUPLICATE]: "read.ptx.sreg.nwarpid" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.pm0" => "__nvvm_read_ptx_sreg_pm0", + // [DUPLICATE]: "read.ptx.sreg.pm0" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.pm1" => "__nvvm_read_ptx_sreg_pm1", + // [DUPLICATE]: "read.ptx.sreg.pm1" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.pm2" => "__nvvm_read_ptx_sreg_pm2", + // [DUPLICATE]: "read.ptx.sreg.pm2" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.pm3" => "__nvvm_read_ptx_sreg_pm3", + // [DUPLICATE]: "read.ptx.sreg.pm3" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.smid" => "__nvvm_read_ptx_sreg_smid", + // [DUPLICATE]: "read.ptx.sreg.smid" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.tid.w" => "__nvvm_read_ptx_sreg_tid_w", + "read.ptx.sreg.tid.x" => "__nvvm_read_ptx_sreg_tid_x", + "read.ptx.sreg.tid.y" => "__nvvm_read_ptx_sreg_tid_y", + "read.ptx.sreg.tid.z" => "__nvvm_read_ptx_sreg_tid_z", + "read.ptx.sreg.warpid" => "__nvvm_read_ptx_sreg_warpid", + // [DUPLICATE]: "read.ptx.sreg.warpid" => "__nvvm_read_ptx_sreg_", + "read.ptx.sreg.warpsize" => "__nvvm_read_ptx_sreg_warpsize", + // [DUPLICATE]: "read.ptx.sreg.warpsize" => "__nvvm_read_ptx_sreg_", + "redux.sync.add" => "__nvvm_redux_sync_add", + "redux.sync.and" => "__nvvm_redux_sync_and", + "redux.sync.fmax" => "__nvvm_redux_sync_fmax", + "redux.sync.fmax.NaN" => "__nvvm_redux_sync_fmax_NaN", + "redux.sync.fmax.abs" => "__nvvm_redux_sync_fmax_abs", + "redux.sync.fmax.abs.NaN" => "__nvvm_redux_sync_fmax_abs_NaN", + "redux.sync.fmin" => "__nvvm_redux_sync_fmin", + "redux.sync.fmin.NaN" => "__nvvm_redux_sync_fmin_NaN", + "redux.sync.fmin.abs" => "__nvvm_redux_sync_fmin_abs", + "redux.sync.fmin.abs.NaN" => "__nvvm_redux_sync_fmin_abs_NaN", + "redux.sync.max" => "__nvvm_redux_sync_max", + "redux.sync.min" => "__nvvm_redux_sync_min", + "redux.sync.or" => "__nvvm_redux_sync_or", + "redux.sync.umax" => "__nvvm_redux_sync_umax", + "redux.sync.umin" => "__nvvm_redux_sync_umin", + "redux.sync.xor" => "__nvvm_redux_sync_xor", + "reflect" => "__nvvm_reflect", + "rotate.b32" => "__nvvm_rotate_b32", + "rotate.b64" => "__nvvm_rotate_b64", + "rotate.right.b64" => "__nvvm_rotate_right_b64", + "round.d" => "__nvvm_round_d", + "round.f" => "__nvvm_round_f", + "round.ftz.f" => "__nvvm_round_ftz_f", + "rsqrt.approx.d" => "__nvvm_rsqrt_approx_d", + "rsqrt.approx.f" => "__nvvm_rsqrt_approx_f", + "rsqrt.approx.ftz.d" => "__nvvm_rsqrt_approx_ftz_d", + "rsqrt.approx.ftz.f" => "__nvvm_rsqrt_approx_ftz_f", + "sad.i" => "__nvvm_sad_i", + "sad.ll" => "__nvvm_sad_ll", + "sad.s" => "__nvvm_sad_s", + "sad.ui" => "__nvvm_sad_ui", + "sad.ull" => "__nvvm_sad_ull", + "sad.us" => "__nvvm_sad_us", + "saturate.d" => "__nvvm_saturate_d", + "saturate.f" => "__nvvm_saturate_f", + "saturate.ftz.f" => "__nvvm_saturate_ftz_f", + "shfl.bfly.f32" => "__nvvm_shfl_bfly_f32", + "shfl.bfly.i32" => "__nvvm_shfl_bfly_i32", + "shfl.down.f32" => "__nvvm_shfl_down_f32", + "shfl.down.i32" => "__nvvm_shfl_down_i32", + "shfl.idx.f32" => "__nvvm_shfl_idx_f32", + "shfl.idx.i32" => "__nvvm_shfl_idx_i32", + "shfl.sync.bfly.f32" => "__nvvm_shfl_sync_bfly_f32", + "shfl.sync.bfly.i32" => "__nvvm_shfl_sync_bfly_i32", + "shfl.sync.down.f32" => "__nvvm_shfl_sync_down_f32", + "shfl.sync.down.i32" => "__nvvm_shfl_sync_down_i32", + "shfl.sync.idx.f32" => "__nvvm_shfl_sync_idx_f32", + "shfl.sync.idx.i32" => "__nvvm_shfl_sync_idx_i32", + "shfl.sync.up.f32" => "__nvvm_shfl_sync_up_f32", + "shfl.sync.up.i32" => "__nvvm_shfl_sync_up_i32", + "shfl.up.f32" => "__nvvm_shfl_up_f32", + "shfl.up.i32" => "__nvvm_shfl_up_i32", + "sin.approx.f" => "__nvvm_sin_approx_f", + "sin.approx.ftz.f" => "__nvvm_sin_approx_ftz_f", + "sqrt.approx.f" => "__nvvm_sqrt_approx_f", + "sqrt.approx.ftz.f" => "__nvvm_sqrt_approx_ftz_f", + "sqrt.f" => "__nvvm_sqrt_f", + "sqrt.rm.d" => "__nvvm_sqrt_rm_d", + "sqrt.rm.f" => "__nvvm_sqrt_rm_f", + "sqrt.rm.ftz.f" => "__nvvm_sqrt_rm_ftz_f", + "sqrt.rn.d" => "__nvvm_sqrt_rn_d", + "sqrt.rn.f" => "__nvvm_sqrt_rn_f", + "sqrt.rn.ftz.f" => "__nvvm_sqrt_rn_ftz_f", + "sqrt.rp.d" => "__nvvm_sqrt_rp_d", + "sqrt.rp.f" => "__nvvm_sqrt_rp_f", + "sqrt.rp.ftz.f" => "__nvvm_sqrt_rp_ftz_f", + "sqrt.rz.d" => "__nvvm_sqrt_rz_d", + "sqrt.rz.f" => "__nvvm_sqrt_rz_f", + "sqrt.rz.ftz.f" => "__nvvm_sqrt_rz_ftz_f", + "suq.array.size" => "__nvvm_suq_array_size", + "suq.channel.data.type" => "__nvvm_suq_channel_data_type", + "suq.channel.order" => "__nvvm_suq_channel_order", + "suq.depth" => "__nvvm_suq_depth", + "suq.height" => "__nvvm_suq_height", + "suq.width" => "__nvvm_suq_width", + "sust.b.1d.array.i16.clamp" => "__nvvm_sust_b_1d_array_i16_clamp", + "sust.b.1d.array.i16.trap" => "__nvvm_sust_b_1d_array_i16_trap", + "sust.b.1d.array.i16.zero" => "__nvvm_sust_b_1d_array_i16_zero", + "sust.b.1d.array.i32.clamp" => "__nvvm_sust_b_1d_array_i32_clamp", + "sust.b.1d.array.i32.trap" => "__nvvm_sust_b_1d_array_i32_trap", + "sust.b.1d.array.i32.zero" => "__nvvm_sust_b_1d_array_i32_zero", + "sust.b.1d.array.i64.clamp" => "__nvvm_sust_b_1d_array_i64_clamp", + "sust.b.1d.array.i64.trap" => "__nvvm_sust_b_1d_array_i64_trap", + "sust.b.1d.array.i64.zero" => "__nvvm_sust_b_1d_array_i64_zero", + "sust.b.1d.array.i8.clamp" => "__nvvm_sust_b_1d_array_i8_clamp", + "sust.b.1d.array.i8.trap" => "__nvvm_sust_b_1d_array_i8_trap", + "sust.b.1d.array.i8.zero" => "__nvvm_sust_b_1d_array_i8_zero", + "sust.b.1d.array.v2i16.clamp" => "__nvvm_sust_b_1d_array_v2i16_clamp", + "sust.b.1d.array.v2i16.trap" => "__nvvm_sust_b_1d_array_v2i16_trap", + "sust.b.1d.array.v2i16.zero" => "__nvvm_sust_b_1d_array_v2i16_zero", + "sust.b.1d.array.v2i32.clamp" => "__nvvm_sust_b_1d_array_v2i32_clamp", + "sust.b.1d.array.v2i32.trap" => "__nvvm_sust_b_1d_array_v2i32_trap", + "sust.b.1d.array.v2i32.zero" => "__nvvm_sust_b_1d_array_v2i32_zero", + "sust.b.1d.array.v2i64.clamp" => "__nvvm_sust_b_1d_array_v2i64_clamp", + "sust.b.1d.array.v2i64.trap" => "__nvvm_sust_b_1d_array_v2i64_trap", + "sust.b.1d.array.v2i64.zero" => "__nvvm_sust_b_1d_array_v2i64_zero", + "sust.b.1d.array.v2i8.clamp" => "__nvvm_sust_b_1d_array_v2i8_clamp", + "sust.b.1d.array.v2i8.trap" => "__nvvm_sust_b_1d_array_v2i8_trap", + "sust.b.1d.array.v2i8.zero" => "__nvvm_sust_b_1d_array_v2i8_zero", + "sust.b.1d.array.v4i16.clamp" => "__nvvm_sust_b_1d_array_v4i16_clamp", + "sust.b.1d.array.v4i16.trap" => "__nvvm_sust_b_1d_array_v4i16_trap", + "sust.b.1d.array.v4i16.zero" => "__nvvm_sust_b_1d_array_v4i16_zero", + "sust.b.1d.array.v4i32.clamp" => "__nvvm_sust_b_1d_array_v4i32_clamp", + "sust.b.1d.array.v4i32.trap" => "__nvvm_sust_b_1d_array_v4i32_trap", + "sust.b.1d.array.v4i32.zero" => "__nvvm_sust_b_1d_array_v4i32_zero", + "sust.b.1d.array.v4i8.clamp" => "__nvvm_sust_b_1d_array_v4i8_clamp", + "sust.b.1d.array.v4i8.trap" => "__nvvm_sust_b_1d_array_v4i8_trap", + "sust.b.1d.array.v4i8.zero" => "__nvvm_sust_b_1d_array_v4i8_zero", + "sust.b.1d.i16.clamp" => "__nvvm_sust_b_1d_i16_clamp", + "sust.b.1d.i16.trap" => "__nvvm_sust_b_1d_i16_trap", + "sust.b.1d.i16.zero" => "__nvvm_sust_b_1d_i16_zero", + "sust.b.1d.i32.clamp" => "__nvvm_sust_b_1d_i32_clamp", + "sust.b.1d.i32.trap" => "__nvvm_sust_b_1d_i32_trap", + "sust.b.1d.i32.zero" => "__nvvm_sust_b_1d_i32_zero", + "sust.b.1d.i64.clamp" => "__nvvm_sust_b_1d_i64_clamp", + "sust.b.1d.i64.trap" => "__nvvm_sust_b_1d_i64_trap", + "sust.b.1d.i64.zero" => "__nvvm_sust_b_1d_i64_zero", + "sust.b.1d.i8.clamp" => "__nvvm_sust_b_1d_i8_clamp", + "sust.b.1d.i8.trap" => "__nvvm_sust_b_1d_i8_trap", + "sust.b.1d.i8.zero" => "__nvvm_sust_b_1d_i8_zero", + "sust.b.1d.v2i16.clamp" => "__nvvm_sust_b_1d_v2i16_clamp", + "sust.b.1d.v2i16.trap" => "__nvvm_sust_b_1d_v2i16_trap", + "sust.b.1d.v2i16.zero" => "__nvvm_sust_b_1d_v2i16_zero", + "sust.b.1d.v2i32.clamp" => "__nvvm_sust_b_1d_v2i32_clamp", + "sust.b.1d.v2i32.trap" => "__nvvm_sust_b_1d_v2i32_trap", + "sust.b.1d.v2i32.zero" => "__nvvm_sust_b_1d_v2i32_zero", + "sust.b.1d.v2i64.clamp" => "__nvvm_sust_b_1d_v2i64_clamp", + "sust.b.1d.v2i64.trap" => "__nvvm_sust_b_1d_v2i64_trap", + "sust.b.1d.v2i64.zero" => "__nvvm_sust_b_1d_v2i64_zero", + "sust.b.1d.v2i8.clamp" => "__nvvm_sust_b_1d_v2i8_clamp", + "sust.b.1d.v2i8.trap" => "__nvvm_sust_b_1d_v2i8_trap", + "sust.b.1d.v2i8.zero" => "__nvvm_sust_b_1d_v2i8_zero", + "sust.b.1d.v4i16.clamp" => "__nvvm_sust_b_1d_v4i16_clamp", + "sust.b.1d.v4i16.trap" => "__nvvm_sust_b_1d_v4i16_trap", + "sust.b.1d.v4i16.zero" => "__nvvm_sust_b_1d_v4i16_zero", + "sust.b.1d.v4i32.clamp" => "__nvvm_sust_b_1d_v4i32_clamp", + "sust.b.1d.v4i32.trap" => "__nvvm_sust_b_1d_v4i32_trap", + "sust.b.1d.v4i32.zero" => "__nvvm_sust_b_1d_v4i32_zero", + "sust.b.1d.v4i8.clamp" => "__nvvm_sust_b_1d_v4i8_clamp", + "sust.b.1d.v4i8.trap" => "__nvvm_sust_b_1d_v4i8_trap", + "sust.b.1d.v4i8.zero" => "__nvvm_sust_b_1d_v4i8_zero", + "sust.b.2d.array.i16.clamp" => "__nvvm_sust_b_2d_array_i16_clamp", + "sust.b.2d.array.i16.trap" => "__nvvm_sust_b_2d_array_i16_trap", + "sust.b.2d.array.i16.zero" => "__nvvm_sust_b_2d_array_i16_zero", + "sust.b.2d.array.i32.clamp" => "__nvvm_sust_b_2d_array_i32_clamp", + "sust.b.2d.array.i32.trap" => "__nvvm_sust_b_2d_array_i32_trap", + "sust.b.2d.array.i32.zero" => "__nvvm_sust_b_2d_array_i32_zero", + "sust.b.2d.array.i64.clamp" => "__nvvm_sust_b_2d_array_i64_clamp", + "sust.b.2d.array.i64.trap" => "__nvvm_sust_b_2d_array_i64_trap", + "sust.b.2d.array.i64.zero" => "__nvvm_sust_b_2d_array_i64_zero", + "sust.b.2d.array.i8.clamp" => "__nvvm_sust_b_2d_array_i8_clamp", + "sust.b.2d.array.i8.trap" => "__nvvm_sust_b_2d_array_i8_trap", + "sust.b.2d.array.i8.zero" => "__nvvm_sust_b_2d_array_i8_zero", + "sust.b.2d.array.v2i16.clamp" => "__nvvm_sust_b_2d_array_v2i16_clamp", + "sust.b.2d.array.v2i16.trap" => "__nvvm_sust_b_2d_array_v2i16_trap", + "sust.b.2d.array.v2i16.zero" => "__nvvm_sust_b_2d_array_v2i16_zero", + "sust.b.2d.array.v2i32.clamp" => "__nvvm_sust_b_2d_array_v2i32_clamp", + "sust.b.2d.array.v2i32.trap" => "__nvvm_sust_b_2d_array_v2i32_trap", + "sust.b.2d.array.v2i32.zero" => "__nvvm_sust_b_2d_array_v2i32_zero", + "sust.b.2d.array.v2i64.clamp" => "__nvvm_sust_b_2d_array_v2i64_clamp", + "sust.b.2d.array.v2i64.trap" => "__nvvm_sust_b_2d_array_v2i64_trap", + "sust.b.2d.array.v2i64.zero" => "__nvvm_sust_b_2d_array_v2i64_zero", + "sust.b.2d.array.v2i8.clamp" => "__nvvm_sust_b_2d_array_v2i8_clamp", + "sust.b.2d.array.v2i8.trap" => "__nvvm_sust_b_2d_array_v2i8_trap", + "sust.b.2d.array.v2i8.zero" => "__nvvm_sust_b_2d_array_v2i8_zero", + "sust.b.2d.array.v4i16.clamp" => "__nvvm_sust_b_2d_array_v4i16_clamp", + "sust.b.2d.array.v4i16.trap" => "__nvvm_sust_b_2d_array_v4i16_trap", + "sust.b.2d.array.v4i16.zero" => "__nvvm_sust_b_2d_array_v4i16_zero", + "sust.b.2d.array.v4i32.clamp" => "__nvvm_sust_b_2d_array_v4i32_clamp", + "sust.b.2d.array.v4i32.trap" => "__nvvm_sust_b_2d_array_v4i32_trap", + "sust.b.2d.array.v4i32.zero" => "__nvvm_sust_b_2d_array_v4i32_zero", + "sust.b.2d.array.v4i8.clamp" => "__nvvm_sust_b_2d_array_v4i8_clamp", + "sust.b.2d.array.v4i8.trap" => "__nvvm_sust_b_2d_array_v4i8_trap", + "sust.b.2d.array.v4i8.zero" => "__nvvm_sust_b_2d_array_v4i8_zero", + "sust.b.2d.i16.clamp" => "__nvvm_sust_b_2d_i16_clamp", + "sust.b.2d.i16.trap" => "__nvvm_sust_b_2d_i16_trap", + "sust.b.2d.i16.zero" => "__nvvm_sust_b_2d_i16_zero", + "sust.b.2d.i32.clamp" => "__nvvm_sust_b_2d_i32_clamp", + "sust.b.2d.i32.trap" => "__nvvm_sust_b_2d_i32_trap", + "sust.b.2d.i32.zero" => "__nvvm_sust_b_2d_i32_zero", + "sust.b.2d.i64.clamp" => "__nvvm_sust_b_2d_i64_clamp", + "sust.b.2d.i64.trap" => "__nvvm_sust_b_2d_i64_trap", + "sust.b.2d.i64.zero" => "__nvvm_sust_b_2d_i64_zero", + "sust.b.2d.i8.clamp" => "__nvvm_sust_b_2d_i8_clamp", + "sust.b.2d.i8.trap" => "__nvvm_sust_b_2d_i8_trap", + "sust.b.2d.i8.zero" => "__nvvm_sust_b_2d_i8_zero", + "sust.b.2d.v2i16.clamp" => "__nvvm_sust_b_2d_v2i16_clamp", + "sust.b.2d.v2i16.trap" => "__nvvm_sust_b_2d_v2i16_trap", + "sust.b.2d.v2i16.zero" => "__nvvm_sust_b_2d_v2i16_zero", + "sust.b.2d.v2i32.clamp" => "__nvvm_sust_b_2d_v2i32_clamp", + "sust.b.2d.v2i32.trap" => "__nvvm_sust_b_2d_v2i32_trap", + "sust.b.2d.v2i32.zero" => "__nvvm_sust_b_2d_v2i32_zero", + "sust.b.2d.v2i64.clamp" => "__nvvm_sust_b_2d_v2i64_clamp", + "sust.b.2d.v2i64.trap" => "__nvvm_sust_b_2d_v2i64_trap", + "sust.b.2d.v2i64.zero" => "__nvvm_sust_b_2d_v2i64_zero", + "sust.b.2d.v2i8.clamp" => "__nvvm_sust_b_2d_v2i8_clamp", + "sust.b.2d.v2i8.trap" => "__nvvm_sust_b_2d_v2i8_trap", + "sust.b.2d.v2i8.zero" => "__nvvm_sust_b_2d_v2i8_zero", + "sust.b.2d.v4i16.clamp" => "__nvvm_sust_b_2d_v4i16_clamp", + "sust.b.2d.v4i16.trap" => "__nvvm_sust_b_2d_v4i16_trap", + "sust.b.2d.v4i16.zero" => "__nvvm_sust_b_2d_v4i16_zero", + "sust.b.2d.v4i32.clamp" => "__nvvm_sust_b_2d_v4i32_clamp", + "sust.b.2d.v4i32.trap" => "__nvvm_sust_b_2d_v4i32_trap", + "sust.b.2d.v4i32.zero" => "__nvvm_sust_b_2d_v4i32_zero", + "sust.b.2d.v4i8.clamp" => "__nvvm_sust_b_2d_v4i8_clamp", + "sust.b.2d.v4i8.trap" => "__nvvm_sust_b_2d_v4i8_trap", + "sust.b.2d.v4i8.zero" => "__nvvm_sust_b_2d_v4i8_zero", + "sust.b.3d.i16.clamp" => "__nvvm_sust_b_3d_i16_clamp", + "sust.b.3d.i16.trap" => "__nvvm_sust_b_3d_i16_trap", + "sust.b.3d.i16.zero" => "__nvvm_sust_b_3d_i16_zero", + "sust.b.3d.i32.clamp" => "__nvvm_sust_b_3d_i32_clamp", + "sust.b.3d.i32.trap" => "__nvvm_sust_b_3d_i32_trap", + "sust.b.3d.i32.zero" => "__nvvm_sust_b_3d_i32_zero", + "sust.b.3d.i64.clamp" => "__nvvm_sust_b_3d_i64_clamp", + "sust.b.3d.i64.trap" => "__nvvm_sust_b_3d_i64_trap", + "sust.b.3d.i64.zero" => "__nvvm_sust_b_3d_i64_zero", + "sust.b.3d.i8.clamp" => "__nvvm_sust_b_3d_i8_clamp", + "sust.b.3d.i8.trap" => "__nvvm_sust_b_3d_i8_trap", + "sust.b.3d.i8.zero" => "__nvvm_sust_b_3d_i8_zero", + "sust.b.3d.v2i16.clamp" => "__nvvm_sust_b_3d_v2i16_clamp", + "sust.b.3d.v2i16.trap" => "__nvvm_sust_b_3d_v2i16_trap", + "sust.b.3d.v2i16.zero" => "__nvvm_sust_b_3d_v2i16_zero", + "sust.b.3d.v2i32.clamp" => "__nvvm_sust_b_3d_v2i32_clamp", + "sust.b.3d.v2i32.trap" => "__nvvm_sust_b_3d_v2i32_trap", + "sust.b.3d.v2i32.zero" => "__nvvm_sust_b_3d_v2i32_zero", + "sust.b.3d.v2i64.clamp" => "__nvvm_sust_b_3d_v2i64_clamp", + "sust.b.3d.v2i64.trap" => "__nvvm_sust_b_3d_v2i64_trap", + "sust.b.3d.v2i64.zero" => "__nvvm_sust_b_3d_v2i64_zero", + "sust.b.3d.v2i8.clamp" => "__nvvm_sust_b_3d_v2i8_clamp", + "sust.b.3d.v2i8.trap" => "__nvvm_sust_b_3d_v2i8_trap", + "sust.b.3d.v2i8.zero" => "__nvvm_sust_b_3d_v2i8_zero", + "sust.b.3d.v4i16.clamp" => "__nvvm_sust_b_3d_v4i16_clamp", + "sust.b.3d.v4i16.trap" => "__nvvm_sust_b_3d_v4i16_trap", + "sust.b.3d.v4i16.zero" => "__nvvm_sust_b_3d_v4i16_zero", + "sust.b.3d.v4i32.clamp" => "__nvvm_sust_b_3d_v4i32_clamp", + "sust.b.3d.v4i32.trap" => "__nvvm_sust_b_3d_v4i32_trap", + "sust.b.3d.v4i32.zero" => "__nvvm_sust_b_3d_v4i32_zero", + "sust.b.3d.v4i8.clamp" => "__nvvm_sust_b_3d_v4i8_clamp", + "sust.b.3d.v4i8.trap" => "__nvvm_sust_b_3d_v4i8_trap", + "sust.b.3d.v4i8.zero" => "__nvvm_sust_b_3d_v4i8_zero", + "sust.p.1d.array.i16.trap" => "__nvvm_sust_p_1d_array_i16_trap", + "sust.p.1d.array.i32.trap" => "__nvvm_sust_p_1d_array_i32_trap", + "sust.p.1d.array.i8.trap" => "__nvvm_sust_p_1d_array_i8_trap", + "sust.p.1d.array.v2i16.trap" => "__nvvm_sust_p_1d_array_v2i16_trap", + "sust.p.1d.array.v2i32.trap" => "__nvvm_sust_p_1d_array_v2i32_trap", + "sust.p.1d.array.v2i8.trap" => "__nvvm_sust_p_1d_array_v2i8_trap", + "sust.p.1d.array.v4i16.trap" => "__nvvm_sust_p_1d_array_v4i16_trap", + "sust.p.1d.array.v4i32.trap" => "__nvvm_sust_p_1d_array_v4i32_trap", + "sust.p.1d.array.v4i8.trap" => "__nvvm_sust_p_1d_array_v4i8_trap", + "sust.p.1d.i16.trap" => "__nvvm_sust_p_1d_i16_trap", + "sust.p.1d.i32.trap" => "__nvvm_sust_p_1d_i32_trap", + "sust.p.1d.i8.trap" => "__nvvm_sust_p_1d_i8_trap", + "sust.p.1d.v2i16.trap" => "__nvvm_sust_p_1d_v2i16_trap", + "sust.p.1d.v2i32.trap" => "__nvvm_sust_p_1d_v2i32_trap", + "sust.p.1d.v2i8.trap" => "__nvvm_sust_p_1d_v2i8_trap", + "sust.p.1d.v4i16.trap" => "__nvvm_sust_p_1d_v4i16_trap", + "sust.p.1d.v4i32.trap" => "__nvvm_sust_p_1d_v4i32_trap", + "sust.p.1d.v4i8.trap" => "__nvvm_sust_p_1d_v4i8_trap", + "sust.p.2d.array.i16.trap" => "__nvvm_sust_p_2d_array_i16_trap", + "sust.p.2d.array.i32.trap" => "__nvvm_sust_p_2d_array_i32_trap", + "sust.p.2d.array.i8.trap" => "__nvvm_sust_p_2d_array_i8_trap", + "sust.p.2d.array.v2i16.trap" => "__nvvm_sust_p_2d_array_v2i16_trap", + "sust.p.2d.array.v2i32.trap" => "__nvvm_sust_p_2d_array_v2i32_trap", + "sust.p.2d.array.v2i8.trap" => "__nvvm_sust_p_2d_array_v2i8_trap", + "sust.p.2d.array.v4i16.trap" => "__nvvm_sust_p_2d_array_v4i16_trap", + "sust.p.2d.array.v4i32.trap" => "__nvvm_sust_p_2d_array_v4i32_trap", + "sust.p.2d.array.v4i8.trap" => "__nvvm_sust_p_2d_array_v4i8_trap", + "sust.p.2d.i16.trap" => "__nvvm_sust_p_2d_i16_trap", + "sust.p.2d.i32.trap" => "__nvvm_sust_p_2d_i32_trap", + "sust.p.2d.i8.trap" => "__nvvm_sust_p_2d_i8_trap", + "sust.p.2d.v2i16.trap" => "__nvvm_sust_p_2d_v2i16_trap", + "sust.p.2d.v2i32.trap" => "__nvvm_sust_p_2d_v2i32_trap", + "sust.p.2d.v2i8.trap" => "__nvvm_sust_p_2d_v2i8_trap", + "sust.p.2d.v4i16.trap" => "__nvvm_sust_p_2d_v4i16_trap", + "sust.p.2d.v4i32.trap" => "__nvvm_sust_p_2d_v4i32_trap", + "sust.p.2d.v4i8.trap" => "__nvvm_sust_p_2d_v4i8_trap", + "sust.p.3d.i16.trap" => "__nvvm_sust_p_3d_i16_trap", + "sust.p.3d.i32.trap" => "__nvvm_sust_p_3d_i32_trap", + "sust.p.3d.i8.trap" => "__nvvm_sust_p_3d_i8_trap", + "sust.p.3d.v2i16.trap" => "__nvvm_sust_p_3d_v2i16_trap", + "sust.p.3d.v2i32.trap" => "__nvvm_sust_p_3d_v2i32_trap", + "sust.p.3d.v2i8.trap" => "__nvvm_sust_p_3d_v2i8_trap", + "sust.p.3d.v4i16.trap" => "__nvvm_sust_p_3d_v4i16_trap", + "sust.p.3d.v4i32.trap" => "__nvvm_sust_p_3d_v4i32_trap", + "sust.p.3d.v4i8.trap" => "__nvvm_sust_p_3d_v4i8_trap", + "swap.lo.hi.b64" => "__nvvm_swap_lo_hi_b64", + "trunc.d" => "__nvvm_trunc_d", + "trunc.f" => "__nvvm_trunc_f", + "trunc.ftz.f" => "__nvvm_trunc_ftz_f", + "txq.array.size" => "__nvvm_txq_array_size", + "txq.channel.data.type" => "__nvvm_txq_channel_data_type", + "txq.channel.order" => "__nvvm_txq_channel_order", + "txq.depth" => "__nvvm_txq_depth", + "txq.height" => "__nvvm_txq_height", + "txq.num.mipmap.levels" => "__nvvm_txq_num_mipmap_levels", + "txq.num.samples" => "__nvvm_txq_num_samples", + "txq.width" => "__nvvm_txq_width", + "ue8m0x2.to.bf16x2" => "__nvvm_ue8m0x2_to_bf16x2", + "ui2d.rm" => "__nvvm_ui2d_rm", + "ui2d.rn" => "__nvvm_ui2d_rn", + "ui2d.rp" => "__nvvm_ui2d_rp", + "ui2d.rz" => "__nvvm_ui2d_rz", + "ui2f.rm" => "__nvvm_ui2f_rm", + "ui2f.rn" => "__nvvm_ui2f_rn", + "ui2f.rp" => "__nvvm_ui2f_rp", + "ui2f.rz" => "__nvvm_ui2f_rz", + "ull2d.rm" => "__nvvm_ull2d_rm", + "ull2d.rn" => "__nvvm_ull2d_rn", + "ull2d.rp" => "__nvvm_ull2d_rp", + "ull2d.rz" => "__nvvm_ull2d_rz", + "ull2f.rm" => "__nvvm_ull2f_rm", + "ull2f.rn" => "__nvvm_ull2f_rn", + "ull2f.rp" => "__nvvm_ull2f_rp", + "ull2f.rz" => "__nvvm_ull2f_rz", + "vote.all" => "__nvvm_vote_all", + "vote.all.sync" => "__nvvm_vote_all_sync", + "vote.any" => "__nvvm_vote_any", + "vote.any.sync" => "__nvvm_vote_any_sync", + "vote.ballot" => "__nvvm_vote_ballot", + "vote.ballot.sync" => "__nvvm_vote_ballot_sync", + "vote.uni" => "__nvvm_vote_uni", + "vote.uni.sync" => "__nvvm_vote_uni_sync", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + nvvm(name, full_name) + } + "ppc" => { + #[allow(non_snake_case)] + fn ppc(name: &str, full_name: &str) -> &'static str { + match name { + // ppc + "addex" => "__builtin_ppc_addex", + "addf128.round.to.odd" => "__builtin_addf128_round_to_odd", + "addg6s" => "__builtin_addg6s", + "addg6sd" => "__builtin_ppc_addg6s", + "altivec.crypto.vcipher" => "__builtin_altivec_crypto_vcipher", + "altivec.crypto.vcipherlast" => "__builtin_altivec_crypto_vcipherlast", + "altivec.crypto.vncipher" => "__builtin_altivec_crypto_vncipher", + "altivec.crypto.vncipherlast" => "__builtin_altivec_crypto_vncipherlast", + "altivec.crypto.vpermxor" => "__builtin_altivec_crypto_vpermxor", + "altivec.crypto.vpermxor.be" => "__builtin_altivec_crypto_vpermxor_be", + "altivec.crypto.vpmsumb" => "__builtin_altivec_crypto_vpmsumb", + "altivec.crypto.vpmsumd" => "__builtin_altivec_crypto_vpmsumd", + "altivec.crypto.vpmsumh" => "__builtin_altivec_crypto_vpmsumh", + "altivec.crypto.vpmsumw" => "__builtin_altivec_crypto_vpmsumw", + "altivec.crypto.vsbox" => "__builtin_altivec_crypto_vsbox", + "altivec.crypto.vshasigmad" => "__builtin_altivec_crypto_vshasigmad", + "altivec.crypto.vshasigmaw" => "__builtin_altivec_crypto_vshasigmaw", + "altivec.dss" => "__builtin_altivec_dss", + "altivec.dssall" => "__builtin_altivec_dssall", + "altivec.dst" => "__builtin_altivec_dst", + "altivec.dstst" => "__builtin_altivec_dstst", + "altivec.dststt" => "__builtin_altivec_dststt", + "altivec.dstt" => "__builtin_altivec_dstt", + "altivec.mfvscr" => "__builtin_altivec_mfvscr", + "altivec.mtvscr" => "__builtin_altivec_mtvscr", + "altivec.mtvsrbm" => "__builtin_altivec_mtvsrbm", + "altivec.mtvsrdm" => "__builtin_altivec_mtvsrdm", + "altivec.mtvsrhm" => "__builtin_altivec_mtvsrhm", + "altivec.mtvsrqm" => "__builtin_altivec_mtvsrqm", + "altivec.mtvsrwm" => "__builtin_altivec_mtvsrwm", + "altivec.vabsdub" => "__builtin_altivec_vabsdub", + "altivec.vabsduh" => "__builtin_altivec_vabsduh", + "altivec.vabsduw" => "__builtin_altivec_vabsduw", + "altivec.vaddcuq" => "__builtin_altivec_vaddcuq", + "altivec.vaddcuw" => "__builtin_altivec_vaddcuw", + "altivec.vaddecuq" => "__builtin_altivec_vaddecuq", + "altivec.vaddeuqm" => "__builtin_altivec_vaddeuqm", + "altivec.vaddsbs" => "__builtin_altivec_vaddsbs", + "altivec.vaddshs" => "__builtin_altivec_vaddshs", + "altivec.vaddsws" => "__builtin_altivec_vaddsws", + "altivec.vaddubs" => "__builtin_altivec_vaddubs", + "altivec.vadduhs" => "__builtin_altivec_vadduhs", + "altivec.vadduws" => "__builtin_altivec_vadduws", + "altivec.vavgsb" => "__builtin_altivec_vavgsb", + "altivec.vavgsh" => "__builtin_altivec_vavgsh", + "altivec.vavgsw" => "__builtin_altivec_vavgsw", + "altivec.vavgub" => "__builtin_altivec_vavgub", + "altivec.vavguh" => "__builtin_altivec_vavguh", + "altivec.vavguw" => "__builtin_altivec_vavguw", + "altivec.vbpermd" => "__builtin_altivec_vbpermd", + "altivec.vbpermq" => "__builtin_altivec_vbpermq", + "altivec.vcfsx" => "__builtin_altivec_vcfsx", + "altivec.vcfuged" => "__builtin_altivec_vcfuged", + "altivec.vcfux" => "__builtin_altivec_vcfux", + "altivec.vclrlb" => "__builtin_altivec_vclrlb", + "altivec.vclrrb" => "__builtin_altivec_vclrrb", + "altivec.vclzdm" => "__builtin_altivec_vclzdm", + "altivec.vclzlsbb" => "__builtin_altivec_vclzlsbb", + "altivec.vcmpbfp" => "__builtin_altivec_vcmpbfp", + "altivec.vcmpbfp.p" => "__builtin_altivec_vcmpbfp_p", + "altivec.vcmpeqfp" => "__builtin_altivec_vcmpeqfp", + "altivec.vcmpeqfp.p" => "__builtin_altivec_vcmpeqfp_p", + "altivec.vcmpequb" => "__builtin_altivec_vcmpequb", + "altivec.vcmpequb.p" => "__builtin_altivec_vcmpequb_p", + "altivec.vcmpequd" => "__builtin_altivec_vcmpequd", + "altivec.vcmpequd.p" => "__builtin_altivec_vcmpequd_p", + "altivec.vcmpequh" => "__builtin_altivec_vcmpequh", + "altivec.vcmpequh.p" => "__builtin_altivec_vcmpequh_p", + "altivec.vcmpequq" => "__builtin_altivec_vcmpequq", + "altivec.vcmpequq.p" => "__builtin_altivec_vcmpequq_p", + "altivec.vcmpequw" => "__builtin_altivec_vcmpequw", + "altivec.vcmpequw.p" => "__builtin_altivec_vcmpequw_p", + "altivec.vcmpgefp" => "__builtin_altivec_vcmpgefp", + "altivec.vcmpgefp.p" => "__builtin_altivec_vcmpgefp_p", + "altivec.vcmpgtfp" => "__builtin_altivec_vcmpgtfp", + "altivec.vcmpgtfp.p" => "__builtin_altivec_vcmpgtfp_p", + "altivec.vcmpgtsb" => "__builtin_altivec_vcmpgtsb", + "altivec.vcmpgtsb.p" => "__builtin_altivec_vcmpgtsb_p", + "altivec.vcmpgtsd" => "__builtin_altivec_vcmpgtsd", + "altivec.vcmpgtsd.p" => "__builtin_altivec_vcmpgtsd_p", + "altivec.vcmpgtsh" => "__builtin_altivec_vcmpgtsh", + "altivec.vcmpgtsh.p" => "__builtin_altivec_vcmpgtsh_p", + "altivec.vcmpgtsq" => "__builtin_altivec_vcmpgtsq", + "altivec.vcmpgtsq.p" => "__builtin_altivec_vcmpgtsq_p", + "altivec.vcmpgtsw" => "__builtin_altivec_vcmpgtsw", + "altivec.vcmpgtsw.p" => "__builtin_altivec_vcmpgtsw_p", + "altivec.vcmpgtub" => "__builtin_altivec_vcmpgtub", + "altivec.vcmpgtub.p" => "__builtin_altivec_vcmpgtub_p", + "altivec.vcmpgtud" => "__builtin_altivec_vcmpgtud", + "altivec.vcmpgtud.p" => "__builtin_altivec_vcmpgtud_p", + "altivec.vcmpgtuh" => "__builtin_altivec_vcmpgtuh", + "altivec.vcmpgtuh.p" => "__builtin_altivec_vcmpgtuh_p", + "altivec.vcmpgtuq" => "__builtin_altivec_vcmpgtuq", + "altivec.vcmpgtuq.p" => "__builtin_altivec_vcmpgtuq_p", + "altivec.vcmpgtuw" => "__builtin_altivec_vcmpgtuw", + "altivec.vcmpgtuw.p" => "__builtin_altivec_vcmpgtuw_p", + "altivec.vcmpneb" => "__builtin_altivec_vcmpneb", + "altivec.vcmpneb.p" => "__builtin_altivec_vcmpneb_p", + "altivec.vcmpneh" => "__builtin_altivec_vcmpneh", + "altivec.vcmpneh.p" => "__builtin_altivec_vcmpneh_p", + "altivec.vcmpnew" => "__builtin_altivec_vcmpnew", + "altivec.vcmpnew.p" => "__builtin_altivec_vcmpnew_p", + "altivec.vcmpnezb" => "__builtin_altivec_vcmpnezb", + "altivec.vcmpnezb.p" => "__builtin_altivec_vcmpnezb_p", + "altivec.vcmpnezh" => "__builtin_altivec_vcmpnezh", + "altivec.vcmpnezh.p" => "__builtin_altivec_vcmpnezh_p", + "altivec.vcmpnezw" => "__builtin_altivec_vcmpnezw", + "altivec.vcmpnezw.p" => "__builtin_altivec_vcmpnezw_p", + "altivec.vcntmbb" => "__builtin_altivec_vcntmbb", + "altivec.vcntmbd" => "__builtin_altivec_vcntmbd", + "altivec.vcntmbh" => "__builtin_altivec_vcntmbh", + "altivec.vcntmbw" => "__builtin_altivec_vcntmbw", + "altivec.vctsxs" => "__builtin_altivec_vctsxs", + "altivec.vctuxs" => "__builtin_altivec_vctuxs", + "altivec.vctzdm" => "__builtin_altivec_vctzdm", + "altivec.vctzlsbb" => "__builtin_altivec_vctzlsbb", + "altivec.vdivesd" => "__builtin_altivec_vdivesd", + "altivec.vdivesq" => "__builtin_altivec_vdivesq", + "altivec.vdivesw" => "__builtin_altivec_vdivesw", + "altivec.vdiveud" => "__builtin_altivec_vdiveud", + "altivec.vdiveuq" => "__builtin_altivec_vdiveuq", + "altivec.vdiveuw" => "__builtin_altivec_vdiveuw", + "altivec.vexpandbm" => "__builtin_altivec_vexpandbm", + "altivec.vexpanddm" => "__builtin_altivec_vexpanddm", + "altivec.vexpandhm" => "__builtin_altivec_vexpandhm", + "altivec.vexpandqm" => "__builtin_altivec_vexpandqm", + "altivec.vexpandwm" => "__builtin_altivec_vexpandwm", + "altivec.vexptefp" => "__builtin_altivec_vexptefp", + "altivec.vextddvlx" => "__builtin_altivec_vextddvlx", + "altivec.vextddvrx" => "__builtin_altivec_vextddvrx", + "altivec.vextdubvlx" => "__builtin_altivec_vextdubvlx", + "altivec.vextdubvrx" => "__builtin_altivec_vextdubvrx", + "altivec.vextduhvlx" => "__builtin_altivec_vextduhvlx", + "altivec.vextduhvrx" => "__builtin_altivec_vextduhvrx", + "altivec.vextduwvlx" => "__builtin_altivec_vextduwvlx", + "altivec.vextduwvrx" => "__builtin_altivec_vextduwvrx", + "altivec.vextractbm" => "__builtin_altivec_vextractbm", + "altivec.vextractdm" => "__builtin_altivec_vextractdm", + "altivec.vextracthm" => "__builtin_altivec_vextracthm", + "altivec.vextractqm" => "__builtin_altivec_vextractqm", + "altivec.vextractwm" => "__builtin_altivec_vextractwm", + "altivec.vextsb2d" => "__builtin_altivec_vextsb2d", + "altivec.vextsb2w" => "__builtin_altivec_vextsb2w", + "altivec.vextsd2q" => "__builtin_altivec_vextsd2q", + "altivec.vextsh2d" => "__builtin_altivec_vextsh2d", + "altivec.vextsh2w" => "__builtin_altivec_vextsh2w", + "altivec.vextsw2d" => "__builtin_altivec_vextsw2d", + "altivec.vgbbd" => "__builtin_altivec_vgbbd", + "altivec.vgnb" => "__builtin_altivec_vgnb", + "altivec.vinsblx" => "__builtin_altivec_vinsblx", + "altivec.vinsbrx" => "__builtin_altivec_vinsbrx", + "altivec.vinsbvlx" => "__builtin_altivec_vinsbvlx", + "altivec.vinsbvrx" => "__builtin_altivec_vinsbvrx", + "altivec.vinsdlx" => "__builtin_altivec_vinsdlx", + "altivec.vinsdrx" => "__builtin_altivec_vinsdrx", + "altivec.vinshlx" => "__builtin_altivec_vinshlx", + "altivec.vinshrx" => "__builtin_altivec_vinshrx", + "altivec.vinshvlx" => "__builtin_altivec_vinshvlx", + "altivec.vinshvrx" => "__builtin_altivec_vinshvrx", + "altivec.vinswlx" => "__builtin_altivec_vinswlx", + "altivec.vinswrx" => "__builtin_altivec_vinswrx", + "altivec.vinswvlx" => "__builtin_altivec_vinswvlx", + "altivec.vinswvrx" => "__builtin_altivec_vinswvrx", + "altivec.vlogefp" => "__builtin_altivec_vlogefp", + "altivec.vmaddfp" => "__builtin_altivec_vmaddfp", + "altivec.vmaxfp" => "__builtin_altivec_vmaxfp", + "altivec.vmaxsb" => "__builtin_altivec_vmaxsb", + "altivec.vmaxsd" => "__builtin_altivec_vmaxsd", + "altivec.vmaxsh" => "__builtin_altivec_vmaxsh", + "altivec.vmaxsw" => "__builtin_altivec_vmaxsw", + "altivec.vmaxub" => "__builtin_altivec_vmaxub", + "altivec.vmaxud" => "__builtin_altivec_vmaxud", + "altivec.vmaxuh" => "__builtin_altivec_vmaxuh", + "altivec.vmaxuw" => "__builtin_altivec_vmaxuw", + "altivec.vmhaddshs" => "__builtin_altivec_vmhaddshs", + "altivec.vmhraddshs" => "__builtin_altivec_vmhraddshs", + "altivec.vminfp" => "__builtin_altivec_vminfp", + "altivec.vminsb" => "__builtin_altivec_vminsb", + "altivec.vminsd" => "__builtin_altivec_vminsd", + "altivec.vminsh" => "__builtin_altivec_vminsh", + "altivec.vminsw" => "__builtin_altivec_vminsw", + "altivec.vminub" => "__builtin_altivec_vminub", + "altivec.vminud" => "__builtin_altivec_vminud", + "altivec.vminuh" => "__builtin_altivec_vminuh", + "altivec.vminuw" => "__builtin_altivec_vminuw", + "altivec.vmladduhm" => "__builtin_altivec_vmladduhm", + "altivec.vmsumcud" => "__builtin_altivec_vmsumcud", + "altivec.vmsummbm" => "__builtin_altivec_vmsummbm", + "altivec.vmsumshm" => "__builtin_altivec_vmsumshm", + "altivec.vmsumshs" => "__builtin_altivec_vmsumshs", + "altivec.vmsumubm" => "__builtin_altivec_vmsumubm", + "altivec.vmsumudm" => "__builtin_altivec_vmsumudm", + "altivec.vmsumuhm" => "__builtin_altivec_vmsumuhm", + "altivec.vmsumuhs" => "__builtin_altivec_vmsumuhs", + "altivec.vmulesb" => "__builtin_altivec_vmulesb", + "altivec.vmulesd" => "__builtin_altivec_vmulesd", + "altivec.vmulesh" => "__builtin_altivec_vmulesh", + "altivec.vmulesw" => "__builtin_altivec_vmulesw", + "altivec.vmuleub" => "__builtin_altivec_vmuleub", + "altivec.vmuleud" => "__builtin_altivec_vmuleud", + "altivec.vmuleuh" => "__builtin_altivec_vmuleuh", + "altivec.vmuleuw" => "__builtin_altivec_vmuleuw", + "altivec.vmulhsd" => "__builtin_altivec_vmulhsd", + "altivec.vmulhsw" => "__builtin_altivec_vmulhsw", + "altivec.vmulhud" => "__builtin_altivec_vmulhud", + "altivec.vmulhuw" => "__builtin_altivec_vmulhuw", + "altivec.vmulosb" => "__builtin_altivec_vmulosb", + "altivec.vmulosd" => "__builtin_altivec_vmulosd", + "altivec.vmulosh" => "__builtin_altivec_vmulosh", + "altivec.vmulosw" => "__builtin_altivec_vmulosw", + "altivec.vmuloub" => "__builtin_altivec_vmuloub", + "altivec.vmuloud" => "__builtin_altivec_vmuloud", + "altivec.vmulouh" => "__builtin_altivec_vmulouh", + "altivec.vmulouw" => "__builtin_altivec_vmulouw", + "altivec.vnmsubfp" => "__builtin_altivec_vnmsubfp", + "altivec.vpdepd" => "__builtin_altivec_vpdepd", + "altivec.vperm" => "__builtin_altivec_vperm_4si", + "altivec.vpextd" => "__builtin_altivec_vpextd", + "altivec.vpkpx" => "__builtin_altivec_vpkpx", + "altivec.vpksdss" => "__builtin_altivec_vpksdss", + "altivec.vpksdus" => "__builtin_altivec_vpksdus", + "altivec.vpkshss" => "__builtin_altivec_vpkshss", + "altivec.vpkshus" => "__builtin_altivec_vpkshus", + "altivec.vpkswss" => "__builtin_altivec_vpkswss", + "altivec.vpkswus" => "__builtin_altivec_vpkswus", + "altivec.vpkudus" => "__builtin_altivec_vpkudus", + "altivec.vpkuhus" => "__builtin_altivec_vpkuhus", + "altivec.vpkuwus" => "__builtin_altivec_vpkuwus", + "altivec.vprtybd" => "__builtin_altivec_vprtybd", + "altivec.vprtybq" => "__builtin_altivec_vprtybq", + "altivec.vprtybw" => "__builtin_altivec_vprtybw", + "altivec.vrefp" => "__builtin_altivec_vrefp", + "altivec.vrfim" => "__builtin_altivec_vrfim", + "altivec.vrfin" => "__builtin_altivec_vrfin", + "altivec.vrfip" => "__builtin_altivec_vrfip", + "altivec.vrfiz" => "__builtin_altivec_vrfiz", + "altivec.vrlb" => "__builtin_altivec_vrlb", + "altivec.vrld" => "__builtin_altivec_vrld", + "altivec.vrldmi" => "__builtin_altivec_vrldmi", + "altivec.vrldnm" => "__builtin_altivec_vrldnm", + "altivec.vrlh" => "__builtin_altivec_vrlh", + "altivec.vrlqmi" => "__builtin_altivec_vrlqmi", + "altivec.vrlqnm" => "__builtin_altivec_vrlqnm", + "altivec.vrlw" => "__builtin_altivec_vrlw", + "altivec.vrlwmi" => "__builtin_altivec_vrlwmi", + "altivec.vrlwnm" => "__builtin_altivec_vrlwnm", + "altivec.vrsqrtefp" => "__builtin_altivec_vrsqrtefp", + "altivec.vsel" => "__builtin_altivec_vsel_4si", + "altivec.vsl" => "__builtin_altivec_vsl", + "altivec.vslb" => "__builtin_altivec_vslb", + "altivec.vsldbi" => "__builtin_altivec_vsldbi", + "altivec.vslh" => "__builtin_altivec_vslh", + "altivec.vslo" => "__builtin_altivec_vslo", + "altivec.vslv" => "__builtin_altivec_vslv", + "altivec.vslw" => "__builtin_altivec_vslw", + "altivec.vsr" => "__builtin_altivec_vsr", + "altivec.vsrab" => "__builtin_altivec_vsrab", + "altivec.vsrah" => "__builtin_altivec_vsrah", + "altivec.vsraw" => "__builtin_altivec_vsraw", + "altivec.vsrb" => "__builtin_altivec_vsrb", + "altivec.vsrdbi" => "__builtin_altivec_vsrdbi", + "altivec.vsrh" => "__builtin_altivec_vsrh", + "altivec.vsro" => "__builtin_altivec_vsro", + "altivec.vsrv" => "__builtin_altivec_vsrv", + "altivec.vsrw" => "__builtin_altivec_vsrw", + "altivec.vstribl" => "__builtin_altivec_vstribl", + "altivec.vstribl.p" => "__builtin_altivec_vstribl_p", + "altivec.vstribr" => "__builtin_altivec_vstribr", + "altivec.vstribr.p" => "__builtin_altivec_vstribr_p", + "altivec.vstrihl" => "__builtin_altivec_vstrihl", + "altivec.vstrihl.p" => "__builtin_altivec_vstrihl_p", + "altivec.vstrihr" => "__builtin_altivec_vstrihr", + "altivec.vstrihr.p" => "__builtin_altivec_vstrihr_p", + "altivec.vsubcuq" => "__builtin_altivec_vsubcuq", + "altivec.vsubcuw" => "__builtin_altivec_vsubcuw", + "altivec.vsubecuq" => "__builtin_altivec_vsubecuq", + "altivec.vsubeuqm" => "__builtin_altivec_vsubeuqm", + "altivec.vsubsbs" => "__builtin_altivec_vsubsbs", + "altivec.vsubshs" => "__builtin_altivec_vsubshs", + "altivec.vsubsws" => "__builtin_altivec_vsubsws", + "altivec.vsububs" => "__builtin_altivec_vsububs", + "altivec.vsubuhs" => "__builtin_altivec_vsubuhs", + "altivec.vsubuws" => "__builtin_altivec_vsubuws", + "altivec.vsum2sws" => "__builtin_altivec_vsum2sws", + "altivec.vsum4sbs" => "__builtin_altivec_vsum4sbs", + "altivec.vsum4shs" => "__builtin_altivec_vsum4shs", + "altivec.vsum4ubs" => "__builtin_altivec_vsum4ubs", + "altivec.vsumsws" => "__builtin_altivec_vsumsws", + "altivec.vupkhpx" => "__builtin_altivec_vupkhpx", + "altivec.vupkhsb" => "__builtin_altivec_vupkhsb", + "altivec.vupkhsh" => "__builtin_altivec_vupkhsh", + "altivec.vupkhsw" => "__builtin_altivec_vupkhsw", + "altivec.vupklpx" => "__builtin_altivec_vupklpx", + "altivec.vupklsb" => "__builtin_altivec_vupklsb", + "altivec.vupklsh" => "__builtin_altivec_vupklsh", + "altivec.vupklsw" => "__builtin_altivec_vupklsw", + "bcdadd" => "__builtin_ppc_bcdadd", + "bcdadd.p" => "__builtin_ppc_bcdadd_p", + "bcdsub" => "__builtin_ppc_bcdsub", + "bcdsub.p" => "__builtin_ppc_bcdsub_p", + "bpermd" => "__builtin_bpermd", + "cbcdtd" => "__builtin_cbcdtd", + "cbcdtdd" => "__builtin_ppc_cbcdtd", + "cdtbcd" => "__builtin_cdtbcd", + "cdtbcdd" => "__builtin_ppc_cdtbcd", + "cfuged" => "__builtin_cfuged", + "cmpeqb" => "__builtin_ppc_cmpeqb", + "cmprb" => "__builtin_ppc_cmprb", + "cntlzdm" => "__builtin_cntlzdm", + "cnttzdm" => "__builtin_cnttzdm", + "compare.exp.eq" => "__builtin_ppc_compare_exp_eq", + "compare.exp.gt" => "__builtin_ppc_compare_exp_gt", + "compare.exp.lt" => "__builtin_ppc_compare_exp_lt", + "compare.exp.uo" => "__builtin_ppc_compare_exp_uo", + "darn" => "__builtin_darn", + "darn32" => "__builtin_darn_32", + "darnraw" => "__builtin_darn_raw", + "dcbf" => "__builtin_dcbf", + "dcbfl" => "__builtin_ppc_dcbfl", + "dcbflp" => "__builtin_ppc_dcbflp", + "dcbst" => "__builtin_ppc_dcbst", + "dcbt" => "__builtin_ppc_dcbt", + "dcbtst" => "__builtin_ppc_dcbtst", + "dcbtstt" => "__builtin_ppc_dcbtstt", + "dcbtt" => "__builtin_ppc_dcbtt", + "dcbz" => "__builtin_ppc_dcbz", + "divde" => "__builtin_divde", + "divdeu" => "__builtin_divdeu", + "divf128.round.to.odd" => "__builtin_divf128_round_to_odd", + "divwe" => "__builtin_divwe", + "divweu" => "__builtin_divweu", + "eieio" => "__builtin_ppc_eieio", + "extract.exp" => "__builtin_ppc_extract_exp", + "extract.sig" => "__builtin_ppc_extract_sig", + "fcfid" => "__builtin_ppc_fcfid", + "fcfud" => "__builtin_ppc_fcfud", + "fctid" => "__builtin_ppc_fctid", + "fctidz" => "__builtin_ppc_fctidz", + "fctiw" => "__builtin_ppc_fctiw", + "fctiwz" => "__builtin_ppc_fctiwz", + "fctudz" => "__builtin_ppc_fctudz", + "fctuwz" => "__builtin_ppc_fctuwz", + "fence" => "__builtin_ppc_fence", + "fmaf128.round.to.odd" => "__builtin_fmaf128_round_to_odd", + "fmsub" => "__builtin_ppc_fmsub", + "fmsubs" => "__builtin_ppc_fmsubs", + "fnabs" => "__builtin_ppc_fnabs", + "fnabss" => "__builtin_ppc_fnabss", + "fnmadd" => "__builtin_ppc_fnmadd", + "fnmadds" => "__builtin_ppc_fnmadds", + "fre" => "__builtin_ppc_fre", + "fres" => "__builtin_ppc_fres", + "frsqrte" => "__builtin_ppc_frsqrte", + "frsqrtes" => "__builtin_ppc_frsqrtes", + "fsel" => "__builtin_ppc_fsel", + "fsels" => "__builtin_ppc_fsels", + "get.texasr" => "__builtin_get_texasr", + "get.texasru" => "__builtin_get_texasru", + "get.tfhar" => "__builtin_get_tfhar", + "get.tfiar" => "__builtin_get_tfiar", + "icbt" => "__builtin_ppc_icbt", + "insert.exp" => "__builtin_ppc_insert_exp", + "iospace.eieio" => "__builtin_ppc_iospace_eieio", + "iospace.lwsync" => "__builtin_ppc_iospace_lwsync", + "iospace.sync" => "__builtin_ppc_iospace_sync", + "isync" => "__builtin_ppc_isync", + "load4r" => "__builtin_ppc_load4r", + "load8r" => "__builtin_ppc_load8r", + "lwsync" => "__builtin_ppc_lwsync", + "maddhd" => "__builtin_ppc_maddhd", + "maddhdu" => "__builtin_ppc_maddhdu", + "maddld" => "__builtin_ppc_maddld", + "mffsl" => "__builtin_ppc_mffsl", + "mfmsr" => "__builtin_ppc_mfmsr", + "mftbu" => "__builtin_ppc_mftbu", + "mtfsb0" => "__builtin_ppc_mtfsb0", + "mtfsb1" => "__builtin_ppc_mtfsb1", + "mtfsfi" => "__builtin_ppc_mtfsfi", + "mtmsr" => "__builtin_ppc_mtmsr", + "mulf128.round.to.odd" => "__builtin_mulf128_round_to_odd", + "mulhd" => "__builtin_ppc_mulhd", + "mulhdu" => "__builtin_ppc_mulhdu", + "mulhw" => "__builtin_ppc_mulhw", + "mulhwu" => "__builtin_ppc_mulhwu", + "national2packed" => "__builtin_ppc_national2packed", + "pack.longdouble" => "__builtin_pack_longdouble", + "packed2national" => "__builtin_ppc_packed2national", + "packed2zoned" => "__builtin_ppc_packed2zoned", + "pdepd" => "__builtin_pdepd", + "pextd" => "__builtin_pextd", + "qpx.qvfabs" => "__builtin_qpx_qvfabs", + "qpx.qvfadd" => "__builtin_qpx_qvfadd", + "qpx.qvfadds" => "__builtin_qpx_qvfadds", + "qpx.qvfcfid" => "__builtin_qpx_qvfcfid", + "qpx.qvfcfids" => "__builtin_qpx_qvfcfids", + "qpx.qvfcfidu" => "__builtin_qpx_qvfcfidu", + "qpx.qvfcfidus" => "__builtin_qpx_qvfcfidus", + "qpx.qvfcmpeq" => "__builtin_qpx_qvfcmpeq", + "qpx.qvfcmpgt" => "__builtin_qpx_qvfcmpgt", + "qpx.qvfcmplt" => "__builtin_qpx_qvfcmplt", + "qpx.qvfcpsgn" => "__builtin_qpx_qvfcpsgn", + "qpx.qvfctid" => "__builtin_qpx_qvfctid", + "qpx.qvfctidu" => "__builtin_qpx_qvfctidu", + "qpx.qvfctiduz" => "__builtin_qpx_qvfctiduz", + "qpx.qvfctidz" => "__builtin_qpx_qvfctidz", + "qpx.qvfctiw" => "__builtin_qpx_qvfctiw", + "qpx.qvfctiwu" => "__builtin_qpx_qvfctiwu", + "qpx.qvfctiwuz" => "__builtin_qpx_qvfctiwuz", + "qpx.qvfctiwz" => "__builtin_qpx_qvfctiwz", + "qpx.qvflogical" => "__builtin_qpx_qvflogical", + "qpx.qvfmadd" => "__builtin_qpx_qvfmadd", + "qpx.qvfmadds" => "__builtin_qpx_qvfmadds", + "qpx.qvfmsub" => "__builtin_qpx_qvfmsub", + "qpx.qvfmsubs" => "__builtin_qpx_qvfmsubs", + "qpx.qvfmul" => "__builtin_qpx_qvfmul", + "qpx.qvfmuls" => "__builtin_qpx_qvfmuls", + "qpx.qvfnabs" => "__builtin_qpx_qvfnabs", + "qpx.qvfneg" => "__builtin_qpx_qvfneg", + "qpx.qvfnmadd" => "__builtin_qpx_qvfnmadd", + "qpx.qvfnmadds" => "__builtin_qpx_qvfnmadds", + "qpx.qvfnmsub" => "__builtin_qpx_qvfnmsub", + "qpx.qvfnmsubs" => "__builtin_qpx_qvfnmsubs", + "qpx.qvfperm" => "__builtin_qpx_qvfperm", + "qpx.qvfre" => "__builtin_qpx_qvfre", + "qpx.qvfres" => "__builtin_qpx_qvfres", + "qpx.qvfrim" => "__builtin_qpx_qvfrim", + "qpx.qvfrin" => "__builtin_qpx_qvfrin", + "qpx.qvfrip" => "__builtin_qpx_qvfrip", + "qpx.qvfriz" => "__builtin_qpx_qvfriz", + "qpx.qvfrsp" => "__builtin_qpx_qvfrsp", + "qpx.qvfrsqrte" => "__builtin_qpx_qvfrsqrte", + "qpx.qvfrsqrtes" => "__builtin_qpx_qvfrsqrtes", + "qpx.qvfsel" => "__builtin_qpx_qvfsel", + "qpx.qvfsub" => "__builtin_qpx_qvfsub", + "qpx.qvfsubs" => "__builtin_qpx_qvfsubs", + "qpx.qvftstnan" => "__builtin_qpx_qvftstnan", + "qpx.qvfxmadd" => "__builtin_qpx_qvfxmadd", + "qpx.qvfxmadds" => "__builtin_qpx_qvfxmadds", + "qpx.qvfxmul" => "__builtin_qpx_qvfxmul", + "qpx.qvfxmuls" => "__builtin_qpx_qvfxmuls", + "qpx.qvfxxcpnmadd" => "__builtin_qpx_qvfxxcpnmadd", + "qpx.qvfxxcpnmadds" => "__builtin_qpx_qvfxxcpnmadds", + "qpx.qvfxxmadd" => "__builtin_qpx_qvfxxmadd", + "qpx.qvfxxmadds" => "__builtin_qpx_qvfxxmadds", + "qpx.qvfxxnpmadd" => "__builtin_qpx_qvfxxnpmadd", + "qpx.qvfxxnpmadds" => "__builtin_qpx_qvfxxnpmadds", + "qpx.qvgpci" => "__builtin_qpx_qvgpci", + "qpx.qvlfcd" => "__builtin_qpx_qvlfcd", + "qpx.qvlfcda" => "__builtin_qpx_qvlfcda", + "qpx.qvlfcs" => "__builtin_qpx_qvlfcs", + "qpx.qvlfcsa" => "__builtin_qpx_qvlfcsa", + "qpx.qvlfd" => "__builtin_qpx_qvlfd", + "qpx.qvlfda" => "__builtin_qpx_qvlfda", + "qpx.qvlfiwa" => "__builtin_qpx_qvlfiwa", + "qpx.qvlfiwaa" => "__builtin_qpx_qvlfiwaa", + "qpx.qvlfiwz" => "__builtin_qpx_qvlfiwz", + "qpx.qvlfiwza" => "__builtin_qpx_qvlfiwza", + "qpx.qvlfs" => "__builtin_qpx_qvlfs", + "qpx.qvlfsa" => "__builtin_qpx_qvlfsa", + "qpx.qvlpcld" => "__builtin_qpx_qvlpcld", + "qpx.qvlpcls" => "__builtin_qpx_qvlpcls", + "qpx.qvlpcrd" => "__builtin_qpx_qvlpcrd", + "qpx.qvlpcrs" => "__builtin_qpx_qvlpcrs", + "qpx.qvstfcd" => "__builtin_qpx_qvstfcd", + "qpx.qvstfcda" => "__builtin_qpx_qvstfcda", + "qpx.qvstfcs" => "__builtin_qpx_qvstfcs", + "qpx.qvstfcsa" => "__builtin_qpx_qvstfcsa", + "qpx.qvstfd" => "__builtin_qpx_qvstfd", + "qpx.qvstfda" => "__builtin_qpx_qvstfda", + "qpx.qvstfiw" => "__builtin_qpx_qvstfiw", + "qpx.qvstfiwa" => "__builtin_qpx_qvstfiwa", + "qpx.qvstfs" => "__builtin_qpx_qvstfs", + "qpx.qvstfsa" => "__builtin_qpx_qvstfsa", + "readflm" => "__builtin_readflm", + "rlwimi" => "__builtin_ppc_rlwimi", + "rlwnm" => "__builtin_ppc_rlwnm", + "scalar.extract.expq" => "__builtin_vsx_scalar_extract_expq", + "scalar.insert.exp.qp" => "__builtin_vsx_scalar_insert_exp_qp", + "set.texasr" => "__builtin_set_texasr", + "set.texasru" => "__builtin_set_texasru", + "set.tfhar" => "__builtin_set_tfhar", + "set.tfiar" => "__builtin_set_tfiar", + "setb" => "__builtin_ppc_setb", + "setflm" => "__builtin_setflm", + "setrnd" => "__builtin_setrnd", + "sqrtf128.round.to.odd" => "__builtin_sqrtf128_round_to_odd", + "stbcx" => "__builtin_ppc_stbcx", + "stdcx" => "__builtin_ppc_stdcx", + "stfiw" => "__builtin_ppc_stfiw", + "store2r" => "__builtin_ppc_store2r", + "store4r" => "__builtin_ppc_store4r", + "store8r" => "__builtin_ppc_store8r", + "stwcx" => "__builtin_ppc_stwcx", + "subf128.round.to.odd" => "__builtin_subf128_round_to_odd", + "sync" => "__builtin_ppc_sync", + "tabort" => "__builtin_tabort", + "tabortdc" => "__builtin_tabortdc", + "tabortdci" => "__builtin_tabortdci", + "tabortwc" => "__builtin_tabortwc", + "tabortwci" => "__builtin_tabortwci", + "tbegin" => "__builtin_tbegin", + "tcheck" => "__builtin_tcheck", + "tdw" => "__builtin_ppc_tdw", + "tend" => "__builtin_tend", + "tendall" => "__builtin_tendall", + "trap" => "__builtin_ppc_trap", + "trapd" => "__builtin_ppc_trapd", + "trechkpt" => "__builtin_trechkpt", + "treclaim" => "__builtin_treclaim", + "tresume" => "__builtin_tresume", + "truncf128.round.to.odd" => "__builtin_truncf128_round_to_odd", + "tsr" => "__builtin_tsr", + "tsuspend" => "__builtin_tsuspend", + "ttest" => "__builtin_ttest", + "tw" => "__builtin_ppc_tw", + "unpack.longdouble" => "__builtin_unpack_longdouble", + "vsx.xsmaxdp" => "__builtin_vsx_xsmaxdp", + "vsx.xsmindp" => "__builtin_vsx_xsmindp", + "vsx.xvcmpeqdp" => "__builtin_vsx_xvcmpeqdp", + "vsx.xvcmpeqdp.p" => "__builtin_vsx_xvcmpeqdp_p", + "vsx.xvcmpeqsp" => "__builtin_vsx_xvcmpeqsp", + "vsx.xvcmpeqsp.p" => "__builtin_vsx_xvcmpeqsp_p", + "vsx.xvcmpgedp" => "__builtin_vsx_xvcmpgedp", + "vsx.xvcmpgedp.p" => "__builtin_vsx_xvcmpgedp_p", + "vsx.xvcmpgesp" => "__builtin_vsx_xvcmpgesp", + "vsx.xvcmpgesp.p" => "__builtin_vsx_xvcmpgesp_p", + "vsx.xvcmpgtdp" => "__builtin_vsx_xvcmpgtdp", + "vsx.xvcmpgtdp.p" => "__builtin_vsx_xvcmpgtdp_p", + "vsx.xvcmpgtsp" => "__builtin_vsx_xvcmpgtsp", + "vsx.xvcmpgtsp.p" => "__builtin_vsx_xvcmpgtsp_p", + "vsx.xvcvbf16spn" => "__builtin_vsx_xvcvbf16spn", + "vsx.xvcvdpsp" => "__builtin_vsx_xvcvdpsp", + "vsx.xvcvdpsxws" => "__builtin_vsx_xvcvdpsxws", + "vsx.xvcvdpuxws" => "__builtin_vsx_xvcvdpuxws", + "vsx.xvcvhpsp" => "__builtin_vsx_xvcvhpsp", + "vsx.xvcvspbf16" => "__builtin_vsx_xvcvspbf16", + "vsx.xvcvspdp" => "__builtin_vsx_xvcvspdp", + "vsx.xvcvsphp" => "__builtin_vsx_xvcvsphp", + "vsx.xvcvspsxds" => "__builtin_vsx_xvcvspsxds", + "vsx.xvcvspuxds" => "__builtin_vsx_xvcvspuxds", + "vsx.xvcvsxdsp" => "__builtin_vsx_xvcvsxdsp", + "vsx.xvcvsxwdp" => "__builtin_vsx_xvcvsxwdp", + "vsx.xvcvuxdsp" => "__builtin_vsx_xvcvuxdsp", + "vsx.xvcvuxwdp" => "__builtin_vsx_xvcvuxwdp", + "vsx.xvdivdp" => "__builtin_vsx_xvdivdp", + "vsx.xvdivsp" => "__builtin_vsx_xvdivsp", + "vsx.xviexpdp" => "__builtin_vsx_xviexpdp", + "vsx.xviexpsp" => "__builtin_vsx_xviexpsp", + "vsx.xvmaxdp" => "__builtin_vsx_xvmaxdp", + "vsx.xvmaxsp" => "__builtin_vsx_xvmaxsp", + "vsx.xvmindp" => "__builtin_vsx_xvmindp", + "vsx.xvminsp" => "__builtin_vsx_xvminsp", + "vsx.xvredp" => "__builtin_vsx_xvredp", + "vsx.xvresp" => "__builtin_vsx_xvresp", + "vsx.xvrsqrtedp" => "__builtin_vsx_xvrsqrtedp", + "vsx.xvrsqrtesp" => "__builtin_vsx_xvrsqrtesp", + "vsx.xvtdivdp" => "__builtin_vsx_xvtdivdp", + "vsx.xvtdivsp" => "__builtin_vsx_xvtdivsp", + "vsx.xvtlsbb" => "__builtin_vsx_xvtlsbb", + "vsx.xvtsqrtdp" => "__builtin_vsx_xvtsqrtdp", + "vsx.xvtsqrtsp" => "__builtin_vsx_xvtsqrtsp", + "vsx.xvtstdcdp" => "__builtin_vsx_xvtstdcdp", + "vsx.xvtstdcsp" => "__builtin_vsx_xvtstdcsp", + "vsx.xvxexpdp" => "__builtin_vsx_xvxexpdp", + "vsx.xvxexpsp" => "__builtin_vsx_xvxexpsp", + "vsx.xvxsigdp" => "__builtin_vsx_xvxsigdp", + "vsx.xvxsigsp" => "__builtin_vsx_xvxsigsp", + "vsx.xxblendvb" => "__builtin_vsx_xxblendvb", + "vsx.xxblendvd" => "__builtin_vsx_xxblendvd", + "vsx.xxblendvh" => "__builtin_vsx_xxblendvh", + "vsx.xxblendvw" => "__builtin_vsx_xxblendvw", + "vsx.xxeval" => "__builtin_vsx_xxeval", + "vsx.xxextractuw" => "__builtin_vsx_xxextractuw", + "vsx.xxgenpcvbm" => "__builtin_vsx_xxgenpcvbm", + "vsx.xxgenpcvdm" => "__builtin_vsx_xxgenpcvdm", + "vsx.xxgenpcvhm" => "__builtin_vsx_xxgenpcvhm", + "vsx.xxgenpcvwm" => "__builtin_vsx_xxgenpcvwm", + "vsx.xxinsertw" => "__builtin_vsx_xxinsertw", + "vsx.xxleqv" => "__builtin_vsx_xxleqv", + "vsx.xxpermx" => "__builtin_vsx_xxpermx", + "zoned2packed" => "__builtin_ppc_zoned2packed", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + ppc(name, full_name) + } + "ptx" => { + #[allow(non_snake_case)] + fn ptx(name: &str, full_name: &str) -> &'static str { + match name { + // ptx + "bar.sync" => "__builtin_ptx_bar_sync", + "read.clock" => "__builtin_ptx_read_clock", + "read.clock64" => "__builtin_ptx_read_clock64", + "read.gridid" => "__builtin_ptx_read_gridid", + "read.laneid" => "__builtin_ptx_read_laneid", + "read.lanemask.eq" => "__builtin_ptx_read_lanemask_eq", + "read.lanemask.ge" => "__builtin_ptx_read_lanemask_ge", + "read.lanemask.gt" => "__builtin_ptx_read_lanemask_gt", + "read.lanemask.le" => "__builtin_ptx_read_lanemask_le", + "read.lanemask.lt" => "__builtin_ptx_read_lanemask_lt", + "read.nsmid" => "__builtin_ptx_read_nsmid", + "read.nwarpid" => "__builtin_ptx_read_nwarpid", + "read.pm0" => "__builtin_ptx_read_pm0", + "read.pm1" => "__builtin_ptx_read_pm1", + "read.pm2" => "__builtin_ptx_read_pm2", + "read.pm3" => "__builtin_ptx_read_pm3", + "read.smid" => "__builtin_ptx_read_smid", + "read.warpid" => "__builtin_ptx_read_warpid", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + ptx(name, full_name) + } + "r600" => { + #[allow(non_snake_case)] + fn r600(name: &str, full_name: &str) -> &'static str { + match name { + // r600 + "group.barrier" => "__builtin_r600_group_barrier", + "implicitarg.ptr" => "__builtin_r600_implicitarg_ptr", + "rat.store.typed" => "__builtin_r600_rat_store_typed", + "read.global.size.x" => "__builtin_r600_read_global_size_x", + "read.global.size.y" => "__builtin_r600_read_global_size_y", + "read.global.size.z" => "__builtin_r600_read_global_size_z", + "read.ngroups.x" => "__builtin_r600_read_ngroups_x", + "read.ngroups.y" => "__builtin_r600_read_ngroups_y", + "read.ngroups.z" => "__builtin_r600_read_ngroups_z", + "read.tgid.x" => "__builtin_r600_read_tgid_x", + "read.tgid.y" => "__builtin_r600_read_tgid_y", + "read.tgid.z" => "__builtin_r600_read_tgid_z", + "read.tidig.x" => "__builtin_r600_read_tidig_x", + "read.tidig.y" => "__builtin_r600_read_tidig_y", + "read.tidig.z" => "__builtin_r600_read_tidig_z", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + r600(name, full_name) + } + "riscv" => { + #[allow(non_snake_case)] + fn riscv(name: &str, full_name: &str) -> &'static str { + match name { + // riscv + "aes32dsi" => "__builtin_riscv_aes32dsi", + "aes32dsmi" => "__builtin_riscv_aes32dsmi", + "aes32esi" => "__builtin_riscv_aes32esi", + "aes32esmi" => "__builtin_riscv_aes32esmi", + "aes64ds" => "__builtin_riscv_aes64ds", + "aes64dsm" => "__builtin_riscv_aes64dsm", + "aes64es" => "__builtin_riscv_aes64es", + "aes64esm" => "__builtin_riscv_aes64esm", + "aes64im" => "__builtin_riscv_aes64im", + "aes64ks1i" => "__builtin_riscv_aes64ks1i", + "aes64ks2" => "__builtin_riscv_aes64ks2", + "sha512sig0" => "__builtin_riscv_sha512sig0", + "sha512sig0h" => "__builtin_riscv_sha512sig0h", + "sha512sig0l" => "__builtin_riscv_sha512sig0l", + "sha512sig1" => "__builtin_riscv_sha512sig1", + "sha512sig1h" => "__builtin_riscv_sha512sig1h", + "sha512sig1l" => "__builtin_riscv_sha512sig1l", + "sha512sum0" => "__builtin_riscv_sha512sum0", + "sha512sum0r" => "__builtin_riscv_sha512sum0r", + "sha512sum1" => "__builtin_riscv_sha512sum1", + "sha512sum1r" => "__builtin_riscv_sha512sum1r", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + riscv(name, full_name) + } + "s390" => { + #[allow(non_snake_case)] + fn s390(name: &str, full_name: &str) -> &'static str { + match name { + // s390 + "bdepg" => "__builtin_s390_bdepg", + "bextg" => "__builtin_s390_bextg", + "efpc" => "__builtin_s390_efpc", + "etnd" => "__builtin_tx_nesting_depth", + "lcbb" => "__builtin_s390_lcbb", + "ppa.txassist" => "__builtin_tx_assist", + "sfpc" => "__builtin_s390_sfpc", + "tend" => "__builtin_tend", + "vaccb" => "__builtin_s390_vaccb", + "vacccq" => "__builtin_s390_vacccq", + "vaccf" => "__builtin_s390_vaccf", + "vaccg" => "__builtin_s390_vaccg", + "vacch" => "__builtin_s390_vacch", + "vaccq" => "__builtin_s390_vaccq", + "vacq" => "__builtin_s390_vacq", + "vaq" => "__builtin_s390_vaq", + "vavgb" => "__builtin_s390_vavgb", + "vavgf" => "__builtin_s390_vavgf", + "vavgg" => "__builtin_s390_vavgg", + "vavgh" => "__builtin_s390_vavgh", + "vavglb" => "__builtin_s390_vavglb", + "vavglf" => "__builtin_s390_vavglf", + "vavglg" => "__builtin_s390_vavglg", + "vavglh" => "__builtin_s390_vavglh", + "vavglq" => "__builtin_s390_vavglq", + "vavgq" => "__builtin_s390_vavgq", + "vbperm" => "__builtin_s390_vbperm", + "vcfn" => "__builtin_s390_vcfn", + "vcksm" => "__builtin_s390_vcksm", + "vclfnhs" => "__builtin_s390_vclfnhs", + "vclfnls" => "__builtin_s390_vclfnls", + "vcnf" => "__builtin_s390_vcnf", + "vcrnfs" => "__builtin_s390_vcrnfs", + "verimb" => "__builtin_s390_verimb", + "verimf" => "__builtin_s390_verimf", + "verimg" => "__builtin_s390_verimg", + "verimh" => "__builtin_s390_verimh", + "veval" => "__builtin_s390_veval", + "vfaeb" => "__builtin_s390_vfaeb", + "vfaef" => "__builtin_s390_vfaef", + "vfaeh" => "__builtin_s390_vfaeh", + "vfaezb" => "__builtin_s390_vfaezb", + "vfaezf" => "__builtin_s390_vfaezf", + "vfaezh" => "__builtin_s390_vfaezh", + "vfeeb" => "__builtin_s390_vfeeb", + "vfeef" => "__builtin_s390_vfeef", + "vfeeh" => "__builtin_s390_vfeeh", + "vfeezb" => "__builtin_s390_vfeezb", + "vfeezf" => "__builtin_s390_vfeezf", + "vfeezh" => "__builtin_s390_vfeezh", + "vfeneb" => "__builtin_s390_vfeneb", + "vfenef" => "__builtin_s390_vfenef", + "vfeneh" => "__builtin_s390_vfeneh", + "vfenezb" => "__builtin_s390_vfenezb", + "vfenezf" => "__builtin_s390_vfenezf", + "vfenezh" => "__builtin_s390_vfenezh", + "vgemb" => "__builtin_s390_vgemb", + "vgemf" => "__builtin_s390_vgemf", + "vgemg" => "__builtin_s390_vgemg", + "vgemh" => "__builtin_s390_vgemh", + "vgemq" => "__builtin_s390_vgemq", + "vgfmab" => "__builtin_s390_vgfmab", + "vgfmaf" => "__builtin_s390_vgfmaf", + "vgfmag" => "__builtin_s390_vgfmag", + "vgfmah" => "__builtin_s390_vgfmah", + "vgfmb" => "__builtin_s390_vgfmb", + "vgfmf" => "__builtin_s390_vgfmf", + "vgfmg" => "__builtin_s390_vgfmg", + "vgfmh" => "__builtin_s390_vgfmh", + "vistrb" => "__builtin_s390_vistrb", + "vistrf" => "__builtin_s390_vistrf", + "vistrh" => "__builtin_s390_vistrh", + "vlbb" => "__builtin_s390_vlbb", + "vll" => "__builtin_s390_vll", + "vlrl" => "__builtin_s390_vlrlr", + "vmaeb" => "__builtin_s390_vmaeb", + "vmaef" => "__builtin_s390_vmaef", + "vmaeg" => "__builtin_s390_vmaeg", + "vmaeh" => "__builtin_s390_vmaeh", + "vmahb" => "__builtin_s390_vmahb", + "vmahf" => "__builtin_s390_vmahf", + "vmahg" => "__builtin_s390_vmahg", + "vmahh" => "__builtin_s390_vmahh", + "vmahq" => "__builtin_s390_vmahq", + "vmaleb" => "__builtin_s390_vmaleb", + "vmalef" => "__builtin_s390_vmalef", + "vmaleg" => "__builtin_s390_vmaleg", + "vmaleh" => "__builtin_s390_vmaleh", + "vmalhb" => "__builtin_s390_vmalhb", + "vmalhf" => "__builtin_s390_vmalhf", + "vmalhg" => "__builtin_s390_vmalhg", + "vmalhh" => "__builtin_s390_vmalhh", + "vmalhq" => "__builtin_s390_vmalhq", + "vmalob" => "__builtin_s390_vmalob", + "vmalof" => "__builtin_s390_vmalof", + "vmalog" => "__builtin_s390_vmalog", + "vmaloh" => "__builtin_s390_vmaloh", + "vmaob" => "__builtin_s390_vmaob", + "vmaof" => "__builtin_s390_vmaof", + "vmaog" => "__builtin_s390_vmaog", + "vmaoh" => "__builtin_s390_vmaoh", + "vmeb" => "__builtin_s390_vmeb", + "vmef" => "__builtin_s390_vmef", + "vmeg" => "__builtin_s390_vmeg", + "vmeh" => "__builtin_s390_vmeh", + "vmhb" => "__builtin_s390_vmhb", + "vmhf" => "__builtin_s390_vmhf", + "vmhg" => "__builtin_s390_vmhg", + "vmhh" => "__builtin_s390_vmhh", + "vmhq" => "__builtin_s390_vmhq", + "vmleb" => "__builtin_s390_vmleb", + "vmlef" => "__builtin_s390_vmlef", + "vmleg" => "__builtin_s390_vmleg", + "vmleh" => "__builtin_s390_vmleh", + "vmlhb" => "__builtin_s390_vmlhb", + "vmlhf" => "__builtin_s390_vmlhf", + "vmlhg" => "__builtin_s390_vmlhg", + "vmlhh" => "__builtin_s390_vmlhh", + "vmlhq" => "__builtin_s390_vmlhq", + "vmlob" => "__builtin_s390_vmlob", + "vmlof" => "__builtin_s390_vmlof", + "vmlog" => "__builtin_s390_vmlog", + "vmloh" => "__builtin_s390_vmloh", + "vmob" => "__builtin_s390_vmob", + "vmof" => "__builtin_s390_vmof", + "vmog" => "__builtin_s390_vmog", + "vmoh" => "__builtin_s390_vmoh", + "vmslg" => "__builtin_s390_vmslg", + "vpdi" => "__builtin_s390_vpdi", + "vperm" => "__builtin_s390_vperm", + "vpklsf" => "__builtin_s390_vpklsf", + "vpklsg" => "__builtin_s390_vpklsg", + "vpklsh" => "__builtin_s390_vpklsh", + "vpksf" => "__builtin_s390_vpksf", + "vpksg" => "__builtin_s390_vpksg", + "vpksh" => "__builtin_s390_vpksh", + "vsbcbiq" => "__builtin_s390_vsbcbiq", + "vsbiq" => "__builtin_s390_vsbiq", + "vscbib" => "__builtin_s390_vscbib", + "vscbif" => "__builtin_s390_vscbif", + "vscbig" => "__builtin_s390_vscbig", + "vscbih" => "__builtin_s390_vscbih", + "vscbiq" => "__builtin_s390_vscbiq", + "vsl" => "__builtin_s390_vsl", + "vslb" => "__builtin_s390_vslb", + "vsld" => "__builtin_s390_vsld", + "vsldb" => "__builtin_s390_vsldb", + "vsq" => "__builtin_s390_vsq", + "vsra" => "__builtin_s390_vsra", + "vsrab" => "__builtin_s390_vsrab", + "vsrd" => "__builtin_s390_vsrd", + "vsrl" => "__builtin_s390_vsrl", + "vsrlb" => "__builtin_s390_vsrlb", + "vstl" => "__builtin_s390_vstl", + "vstrcb" => "__builtin_s390_vstrcb", + "vstrcf" => "__builtin_s390_vstrcf", + "vstrch" => "__builtin_s390_vstrch", + "vstrczb" => "__builtin_s390_vstrczb", + "vstrczf" => "__builtin_s390_vstrczf", + "vstrczh" => "__builtin_s390_vstrczh", + "vstrl" => "__builtin_s390_vstrlr", + "vsumb" => "__builtin_s390_vsumb", + "vsumgf" => "__builtin_s390_vsumgf", + "vsumgh" => "__builtin_s390_vsumgh", + "vsumh" => "__builtin_s390_vsumh", + "vsumqf" => "__builtin_s390_vsumqf", + "vsumqg" => "__builtin_s390_vsumqg", + "vtm" => "__builtin_s390_vtm", + "vuphb" => "__builtin_s390_vuphb", + "vuphf" => "__builtin_s390_vuphf", + "vuphg" => "__builtin_s390_vuphg", + "vuphh" => "__builtin_s390_vuphh", + "vuplb" => "__builtin_s390_vuplb", + "vuplf" => "__builtin_s390_vuplf", + "vuplg" => "__builtin_s390_vuplg", + "vuplhb" => "__builtin_s390_vuplhb", + "vuplhf" => "__builtin_s390_vuplhf", + "vuplhg" => "__builtin_s390_vuplhg", + "vuplhh" => "__builtin_s390_vuplhh", + "vuplhw" => "__builtin_s390_vuplhw", + "vupllb" => "__builtin_s390_vupllb", + "vupllf" => "__builtin_s390_vupllf", + "vupllg" => "__builtin_s390_vupllg", + "vupllh" => "__builtin_s390_vupllh", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + s390(name, full_name) + } + "spv" => { + #[allow(non_snake_case)] + fn spv(name: &str, full_name: &str) -> &'static str { + match name { + // spv + "num.subgroups" => "__builtin_spirv_num_subgroups", + "subgroup.id" => "__builtin_spirv_subgroup_id", + "subgroup.local.invocation.id" => { + "__builtin_spirv_subgroup_local_invocation_id" + } + "subgroup.max.size" => "__builtin_spirv_subgroup_max_size", + "subgroup.size" => "__builtin_spirv_subgroup_size", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + spv(name, full_name) + } + "ve" => { + #[allow(non_snake_case)] + fn ve(name: &str, full_name: &str) -> &'static str { + match name { + // ve + "vl.andm.MMM" => "__builtin_ve_vl_andm_MMM", + "vl.andm.mmm" => "__builtin_ve_vl_andm_mmm", + "vl.eqvm.MMM" => "__builtin_ve_vl_eqvm_MMM", + "vl.eqvm.mmm" => "__builtin_ve_vl_eqvm_mmm", + "vl.extract.vm512l" => "__builtin_ve_vl_extract_vm512l", + "vl.extract.vm512u" => "__builtin_ve_vl_extract_vm512u", + "vl.fencec.s" => "__builtin_ve_vl_fencec_s", + "vl.fencei" => "__builtin_ve_vl_fencei", + "vl.fencem.s" => "__builtin_ve_vl_fencem_s", + "vl.fidcr.sss" => "__builtin_ve_vl_fidcr_sss", + "vl.insert.vm512l" => "__builtin_ve_vl_insert_vm512l", + "vl.insert.vm512u" => "__builtin_ve_vl_insert_vm512u", + "vl.lcr.sss" => "__builtin_ve_vl_lcr_sss", + "vl.lsv.vvss" => "__builtin_ve_vl_lsv_vvss", + "vl.lvm.MMss" => "__builtin_ve_vl_lvm_MMss", + "vl.lvm.mmss" => "__builtin_ve_vl_lvm_mmss", + "vl.lvsd.svs" => "__builtin_ve_vl_lvsd_svs", + "vl.lvsl.svs" => "__builtin_ve_vl_lvsl_svs", + "vl.lvss.svs" => "__builtin_ve_vl_lvss_svs", + "vl.lzvm.sml" => "__builtin_ve_vl_lzvm_sml", + "vl.negm.MM" => "__builtin_ve_vl_negm_MM", + "vl.negm.mm" => "__builtin_ve_vl_negm_mm", + "vl.nndm.MMM" => "__builtin_ve_vl_nndm_MMM", + "vl.nndm.mmm" => "__builtin_ve_vl_nndm_mmm", + "vl.orm.MMM" => "__builtin_ve_vl_orm_MMM", + "vl.orm.mmm" => "__builtin_ve_vl_orm_mmm", + "vl.pack.f32a" => "__builtin_ve_vl_pack_f32a", + "vl.pack.f32p" => "__builtin_ve_vl_pack_f32p", + "vl.pcvm.sml" => "__builtin_ve_vl_pcvm_sml", + "vl.pfchv.ssl" => "__builtin_ve_vl_pfchv_ssl", + "vl.pfchvnc.ssl" => "__builtin_ve_vl_pfchvnc_ssl", + "vl.pvadds.vsvMvl" => "__builtin_ve_vl_pvadds_vsvMvl", + "vl.pvadds.vsvl" => "__builtin_ve_vl_pvadds_vsvl", + "vl.pvadds.vsvvl" => "__builtin_ve_vl_pvadds_vsvvl", + "vl.pvadds.vvvMvl" => "__builtin_ve_vl_pvadds_vvvMvl", + "vl.pvadds.vvvl" => "__builtin_ve_vl_pvadds_vvvl", + "vl.pvadds.vvvvl" => "__builtin_ve_vl_pvadds_vvvvl", + "vl.pvaddu.vsvMvl" => "__builtin_ve_vl_pvaddu_vsvMvl", + "vl.pvaddu.vsvl" => "__builtin_ve_vl_pvaddu_vsvl", + "vl.pvaddu.vsvvl" => "__builtin_ve_vl_pvaddu_vsvvl", + "vl.pvaddu.vvvMvl" => "__builtin_ve_vl_pvaddu_vvvMvl", + "vl.pvaddu.vvvl" => "__builtin_ve_vl_pvaddu_vvvl", + "vl.pvaddu.vvvvl" => "__builtin_ve_vl_pvaddu_vvvvl", + "vl.pvand.vsvMvl" => "__builtin_ve_vl_pvand_vsvMvl", + "vl.pvand.vsvl" => "__builtin_ve_vl_pvand_vsvl", + "vl.pvand.vsvvl" => "__builtin_ve_vl_pvand_vsvvl", + "vl.pvand.vvvMvl" => "__builtin_ve_vl_pvand_vvvMvl", + "vl.pvand.vvvl" => "__builtin_ve_vl_pvand_vvvl", + "vl.pvand.vvvvl" => "__builtin_ve_vl_pvand_vvvvl", + "vl.pvbrd.vsMvl" => "__builtin_ve_vl_pvbrd_vsMvl", + "vl.pvbrd.vsl" => "__builtin_ve_vl_pvbrd_vsl", + "vl.pvbrd.vsvl" => "__builtin_ve_vl_pvbrd_vsvl", + "vl.pvbrv.vvMvl" => "__builtin_ve_vl_pvbrv_vvMvl", + "vl.pvbrv.vvl" => "__builtin_ve_vl_pvbrv_vvl", + "vl.pvbrv.vvvl" => "__builtin_ve_vl_pvbrv_vvvl", + "vl.pvbrvlo.vvl" => "__builtin_ve_vl_pvbrvlo_vvl", + "vl.pvbrvlo.vvmvl" => "__builtin_ve_vl_pvbrvlo_vvmvl", + "vl.pvbrvlo.vvvl" => "__builtin_ve_vl_pvbrvlo_vvvl", + "vl.pvbrvup.vvl" => "__builtin_ve_vl_pvbrvup_vvl", + "vl.pvbrvup.vvmvl" => "__builtin_ve_vl_pvbrvup_vvmvl", + "vl.pvbrvup.vvvl" => "__builtin_ve_vl_pvbrvup_vvvl", + "vl.pvcmps.vsvMvl" => "__builtin_ve_vl_pvcmps_vsvMvl", + "vl.pvcmps.vsvl" => "__builtin_ve_vl_pvcmps_vsvl", + "vl.pvcmps.vsvvl" => "__builtin_ve_vl_pvcmps_vsvvl", + "vl.pvcmps.vvvMvl" => "__builtin_ve_vl_pvcmps_vvvMvl", + "vl.pvcmps.vvvl" => "__builtin_ve_vl_pvcmps_vvvl", + "vl.pvcmps.vvvvl" => "__builtin_ve_vl_pvcmps_vvvvl", + "vl.pvcmpu.vsvMvl" => "__builtin_ve_vl_pvcmpu_vsvMvl", + "vl.pvcmpu.vsvl" => "__builtin_ve_vl_pvcmpu_vsvl", + "vl.pvcmpu.vsvvl" => "__builtin_ve_vl_pvcmpu_vsvvl", + "vl.pvcmpu.vvvMvl" => "__builtin_ve_vl_pvcmpu_vvvMvl", + "vl.pvcmpu.vvvl" => "__builtin_ve_vl_pvcmpu_vvvl", + "vl.pvcmpu.vvvvl" => "__builtin_ve_vl_pvcmpu_vvvvl", + "vl.pvcvtsw.vvl" => "__builtin_ve_vl_pvcvtsw_vvl", + "vl.pvcvtsw.vvvl" => "__builtin_ve_vl_pvcvtsw_vvvl", + "vl.pvcvtws.vvMvl" => "__builtin_ve_vl_pvcvtws_vvMvl", + "vl.pvcvtws.vvl" => "__builtin_ve_vl_pvcvtws_vvl", + "vl.pvcvtws.vvvl" => "__builtin_ve_vl_pvcvtws_vvvl", + "vl.pvcvtwsrz.vvMvl" => "__builtin_ve_vl_pvcvtwsrz_vvMvl", + "vl.pvcvtwsrz.vvl" => "__builtin_ve_vl_pvcvtwsrz_vvl", + "vl.pvcvtwsrz.vvvl" => "__builtin_ve_vl_pvcvtwsrz_vvvl", + "vl.pveqv.vsvMvl" => "__builtin_ve_vl_pveqv_vsvMvl", + "vl.pveqv.vsvl" => "__builtin_ve_vl_pveqv_vsvl", + "vl.pveqv.vsvvl" => "__builtin_ve_vl_pveqv_vsvvl", + "vl.pveqv.vvvMvl" => "__builtin_ve_vl_pveqv_vvvMvl", + "vl.pveqv.vvvl" => "__builtin_ve_vl_pveqv_vvvl", + "vl.pveqv.vvvvl" => "__builtin_ve_vl_pveqv_vvvvl", + "vl.pvfadd.vsvMvl" => "__builtin_ve_vl_pvfadd_vsvMvl", + "vl.pvfadd.vsvl" => "__builtin_ve_vl_pvfadd_vsvl", + "vl.pvfadd.vsvvl" => "__builtin_ve_vl_pvfadd_vsvvl", + "vl.pvfadd.vvvMvl" => "__builtin_ve_vl_pvfadd_vvvMvl", + "vl.pvfadd.vvvl" => "__builtin_ve_vl_pvfadd_vvvl", + "vl.pvfadd.vvvvl" => "__builtin_ve_vl_pvfadd_vvvvl", + "vl.pvfcmp.vsvMvl" => "__builtin_ve_vl_pvfcmp_vsvMvl", + "vl.pvfcmp.vsvl" => "__builtin_ve_vl_pvfcmp_vsvl", + "vl.pvfcmp.vsvvl" => "__builtin_ve_vl_pvfcmp_vsvvl", + "vl.pvfcmp.vvvMvl" => "__builtin_ve_vl_pvfcmp_vvvMvl", + "vl.pvfcmp.vvvl" => "__builtin_ve_vl_pvfcmp_vvvl", + "vl.pvfcmp.vvvvl" => "__builtin_ve_vl_pvfcmp_vvvvl", + "vl.pvfmad.vsvvMvl" => "__builtin_ve_vl_pvfmad_vsvvMvl", + "vl.pvfmad.vsvvl" => "__builtin_ve_vl_pvfmad_vsvvl", + "vl.pvfmad.vsvvvl" => "__builtin_ve_vl_pvfmad_vsvvvl", + "vl.pvfmad.vvsvMvl" => "__builtin_ve_vl_pvfmad_vvsvMvl", + "vl.pvfmad.vvsvl" => "__builtin_ve_vl_pvfmad_vvsvl", + "vl.pvfmad.vvsvvl" => "__builtin_ve_vl_pvfmad_vvsvvl", + "vl.pvfmad.vvvvMvl" => "__builtin_ve_vl_pvfmad_vvvvMvl", + "vl.pvfmad.vvvvl" => "__builtin_ve_vl_pvfmad_vvvvl", + "vl.pvfmad.vvvvvl" => "__builtin_ve_vl_pvfmad_vvvvvl", + "vl.pvfmax.vsvMvl" => "__builtin_ve_vl_pvfmax_vsvMvl", + "vl.pvfmax.vsvl" => "__builtin_ve_vl_pvfmax_vsvl", + "vl.pvfmax.vsvvl" => "__builtin_ve_vl_pvfmax_vsvvl", + "vl.pvfmax.vvvMvl" => "__builtin_ve_vl_pvfmax_vvvMvl", + "vl.pvfmax.vvvl" => "__builtin_ve_vl_pvfmax_vvvl", + "vl.pvfmax.vvvvl" => "__builtin_ve_vl_pvfmax_vvvvl", + "vl.pvfmin.vsvMvl" => "__builtin_ve_vl_pvfmin_vsvMvl", + "vl.pvfmin.vsvl" => "__builtin_ve_vl_pvfmin_vsvl", + "vl.pvfmin.vsvvl" => "__builtin_ve_vl_pvfmin_vsvvl", + "vl.pvfmin.vvvMvl" => "__builtin_ve_vl_pvfmin_vvvMvl", + "vl.pvfmin.vvvl" => "__builtin_ve_vl_pvfmin_vvvl", + "vl.pvfmin.vvvvl" => "__builtin_ve_vl_pvfmin_vvvvl", + "vl.pvfmkaf.Ml" => "__builtin_ve_vl_pvfmkaf_Ml", + "vl.pvfmkat.Ml" => "__builtin_ve_vl_pvfmkat_Ml", + "vl.pvfmkseq.MvMl" => "__builtin_ve_vl_pvfmkseq_MvMl", + "vl.pvfmkseq.Mvl" => "__builtin_ve_vl_pvfmkseq_Mvl", + "vl.pvfmkseqnan.MvMl" => "__builtin_ve_vl_pvfmkseqnan_MvMl", + "vl.pvfmkseqnan.Mvl" => "__builtin_ve_vl_pvfmkseqnan_Mvl", + "vl.pvfmksge.MvMl" => "__builtin_ve_vl_pvfmksge_MvMl", + "vl.pvfmksge.Mvl" => "__builtin_ve_vl_pvfmksge_Mvl", + "vl.pvfmksgenan.MvMl" => "__builtin_ve_vl_pvfmksgenan_MvMl", + "vl.pvfmksgenan.Mvl" => "__builtin_ve_vl_pvfmksgenan_Mvl", + "vl.pvfmksgt.MvMl" => "__builtin_ve_vl_pvfmksgt_MvMl", + "vl.pvfmksgt.Mvl" => "__builtin_ve_vl_pvfmksgt_Mvl", + "vl.pvfmksgtnan.MvMl" => "__builtin_ve_vl_pvfmksgtnan_MvMl", + "vl.pvfmksgtnan.Mvl" => "__builtin_ve_vl_pvfmksgtnan_Mvl", + "vl.pvfmksle.MvMl" => "__builtin_ve_vl_pvfmksle_MvMl", + "vl.pvfmksle.Mvl" => "__builtin_ve_vl_pvfmksle_Mvl", + "vl.pvfmkslenan.MvMl" => "__builtin_ve_vl_pvfmkslenan_MvMl", + "vl.pvfmkslenan.Mvl" => "__builtin_ve_vl_pvfmkslenan_Mvl", + "vl.pvfmksloeq.mvl" => "__builtin_ve_vl_pvfmksloeq_mvl", + "vl.pvfmksloeq.mvml" => "__builtin_ve_vl_pvfmksloeq_mvml", + "vl.pvfmksloeqnan.mvl" => "__builtin_ve_vl_pvfmksloeqnan_mvl", + "vl.pvfmksloeqnan.mvml" => "__builtin_ve_vl_pvfmksloeqnan_mvml", + "vl.pvfmksloge.mvl" => "__builtin_ve_vl_pvfmksloge_mvl", + "vl.pvfmksloge.mvml" => "__builtin_ve_vl_pvfmksloge_mvml", + "vl.pvfmkslogenan.mvl" => "__builtin_ve_vl_pvfmkslogenan_mvl", + "vl.pvfmkslogenan.mvml" => "__builtin_ve_vl_pvfmkslogenan_mvml", + "vl.pvfmkslogt.mvl" => "__builtin_ve_vl_pvfmkslogt_mvl", + "vl.pvfmkslogt.mvml" => "__builtin_ve_vl_pvfmkslogt_mvml", + "vl.pvfmkslogtnan.mvl" => "__builtin_ve_vl_pvfmkslogtnan_mvl", + "vl.pvfmkslogtnan.mvml" => "__builtin_ve_vl_pvfmkslogtnan_mvml", + "vl.pvfmkslole.mvl" => "__builtin_ve_vl_pvfmkslole_mvl", + "vl.pvfmkslole.mvml" => "__builtin_ve_vl_pvfmkslole_mvml", + "vl.pvfmkslolenan.mvl" => "__builtin_ve_vl_pvfmkslolenan_mvl", + "vl.pvfmkslolenan.mvml" => "__builtin_ve_vl_pvfmkslolenan_mvml", + "vl.pvfmkslolt.mvl" => "__builtin_ve_vl_pvfmkslolt_mvl", + "vl.pvfmkslolt.mvml" => "__builtin_ve_vl_pvfmkslolt_mvml", + "vl.pvfmksloltnan.mvl" => "__builtin_ve_vl_pvfmksloltnan_mvl", + "vl.pvfmksloltnan.mvml" => "__builtin_ve_vl_pvfmksloltnan_mvml", + "vl.pvfmkslonan.mvl" => "__builtin_ve_vl_pvfmkslonan_mvl", + "vl.pvfmkslonan.mvml" => "__builtin_ve_vl_pvfmkslonan_mvml", + "vl.pvfmkslone.mvl" => "__builtin_ve_vl_pvfmkslone_mvl", + "vl.pvfmkslone.mvml" => "__builtin_ve_vl_pvfmkslone_mvml", + "vl.pvfmkslonenan.mvl" => "__builtin_ve_vl_pvfmkslonenan_mvl", + "vl.pvfmkslonenan.mvml" => "__builtin_ve_vl_pvfmkslonenan_mvml", + "vl.pvfmkslonum.mvl" => "__builtin_ve_vl_pvfmkslonum_mvl", + "vl.pvfmkslonum.mvml" => "__builtin_ve_vl_pvfmkslonum_mvml", + "vl.pvfmkslt.MvMl" => "__builtin_ve_vl_pvfmkslt_MvMl", + "vl.pvfmkslt.Mvl" => "__builtin_ve_vl_pvfmkslt_Mvl", + "vl.pvfmksltnan.MvMl" => "__builtin_ve_vl_pvfmksltnan_MvMl", + "vl.pvfmksltnan.Mvl" => "__builtin_ve_vl_pvfmksltnan_Mvl", + "vl.pvfmksnan.MvMl" => "__builtin_ve_vl_pvfmksnan_MvMl", + "vl.pvfmksnan.Mvl" => "__builtin_ve_vl_pvfmksnan_Mvl", + "vl.pvfmksne.MvMl" => "__builtin_ve_vl_pvfmksne_MvMl", + "vl.pvfmksne.Mvl" => "__builtin_ve_vl_pvfmksne_Mvl", + "vl.pvfmksnenan.MvMl" => "__builtin_ve_vl_pvfmksnenan_MvMl", + "vl.pvfmksnenan.Mvl" => "__builtin_ve_vl_pvfmksnenan_Mvl", + "vl.pvfmksnum.MvMl" => "__builtin_ve_vl_pvfmksnum_MvMl", + "vl.pvfmksnum.Mvl" => "__builtin_ve_vl_pvfmksnum_Mvl", + "vl.pvfmksupeq.mvl" => "__builtin_ve_vl_pvfmksupeq_mvl", + "vl.pvfmksupeq.mvml" => "__builtin_ve_vl_pvfmksupeq_mvml", + "vl.pvfmksupeqnan.mvl" => "__builtin_ve_vl_pvfmksupeqnan_mvl", + "vl.pvfmksupeqnan.mvml" => "__builtin_ve_vl_pvfmksupeqnan_mvml", + "vl.pvfmksupge.mvl" => "__builtin_ve_vl_pvfmksupge_mvl", + "vl.pvfmksupge.mvml" => "__builtin_ve_vl_pvfmksupge_mvml", + "vl.pvfmksupgenan.mvl" => "__builtin_ve_vl_pvfmksupgenan_mvl", + "vl.pvfmksupgenan.mvml" => "__builtin_ve_vl_pvfmksupgenan_mvml", + "vl.pvfmksupgt.mvl" => "__builtin_ve_vl_pvfmksupgt_mvl", + "vl.pvfmksupgt.mvml" => "__builtin_ve_vl_pvfmksupgt_mvml", + "vl.pvfmksupgtnan.mvl" => "__builtin_ve_vl_pvfmksupgtnan_mvl", + "vl.pvfmksupgtnan.mvml" => "__builtin_ve_vl_pvfmksupgtnan_mvml", + "vl.pvfmksuple.mvl" => "__builtin_ve_vl_pvfmksuple_mvl", + "vl.pvfmksuple.mvml" => "__builtin_ve_vl_pvfmksuple_mvml", + "vl.pvfmksuplenan.mvl" => "__builtin_ve_vl_pvfmksuplenan_mvl", + "vl.pvfmksuplenan.mvml" => "__builtin_ve_vl_pvfmksuplenan_mvml", + "vl.pvfmksuplt.mvl" => "__builtin_ve_vl_pvfmksuplt_mvl", + "vl.pvfmksuplt.mvml" => "__builtin_ve_vl_pvfmksuplt_mvml", + "vl.pvfmksupltnan.mvl" => "__builtin_ve_vl_pvfmksupltnan_mvl", + "vl.pvfmksupltnan.mvml" => "__builtin_ve_vl_pvfmksupltnan_mvml", + "vl.pvfmksupnan.mvl" => "__builtin_ve_vl_pvfmksupnan_mvl", + "vl.pvfmksupnan.mvml" => "__builtin_ve_vl_pvfmksupnan_mvml", + "vl.pvfmksupne.mvl" => "__builtin_ve_vl_pvfmksupne_mvl", + "vl.pvfmksupne.mvml" => "__builtin_ve_vl_pvfmksupne_mvml", + "vl.pvfmksupnenan.mvl" => "__builtin_ve_vl_pvfmksupnenan_mvl", + "vl.pvfmksupnenan.mvml" => "__builtin_ve_vl_pvfmksupnenan_mvml", + "vl.pvfmksupnum.mvl" => "__builtin_ve_vl_pvfmksupnum_mvl", + "vl.pvfmksupnum.mvml" => "__builtin_ve_vl_pvfmksupnum_mvml", + "vl.pvfmkweq.MvMl" => "__builtin_ve_vl_pvfmkweq_MvMl", + "vl.pvfmkweq.Mvl" => "__builtin_ve_vl_pvfmkweq_Mvl", + "vl.pvfmkweqnan.MvMl" => "__builtin_ve_vl_pvfmkweqnan_MvMl", + "vl.pvfmkweqnan.Mvl" => "__builtin_ve_vl_pvfmkweqnan_Mvl", + "vl.pvfmkwge.MvMl" => "__builtin_ve_vl_pvfmkwge_MvMl", + "vl.pvfmkwge.Mvl" => "__builtin_ve_vl_pvfmkwge_Mvl", + "vl.pvfmkwgenan.MvMl" => "__builtin_ve_vl_pvfmkwgenan_MvMl", + "vl.pvfmkwgenan.Mvl" => "__builtin_ve_vl_pvfmkwgenan_Mvl", + "vl.pvfmkwgt.MvMl" => "__builtin_ve_vl_pvfmkwgt_MvMl", + "vl.pvfmkwgt.Mvl" => "__builtin_ve_vl_pvfmkwgt_Mvl", + "vl.pvfmkwgtnan.MvMl" => "__builtin_ve_vl_pvfmkwgtnan_MvMl", + "vl.pvfmkwgtnan.Mvl" => "__builtin_ve_vl_pvfmkwgtnan_Mvl", + "vl.pvfmkwle.MvMl" => "__builtin_ve_vl_pvfmkwle_MvMl", + "vl.pvfmkwle.Mvl" => "__builtin_ve_vl_pvfmkwle_Mvl", + "vl.pvfmkwlenan.MvMl" => "__builtin_ve_vl_pvfmkwlenan_MvMl", + "vl.pvfmkwlenan.Mvl" => "__builtin_ve_vl_pvfmkwlenan_Mvl", + "vl.pvfmkwloeq.mvl" => "__builtin_ve_vl_pvfmkwloeq_mvl", + "vl.pvfmkwloeq.mvml" => "__builtin_ve_vl_pvfmkwloeq_mvml", + "vl.pvfmkwloeqnan.mvl" => "__builtin_ve_vl_pvfmkwloeqnan_mvl", + "vl.pvfmkwloeqnan.mvml" => "__builtin_ve_vl_pvfmkwloeqnan_mvml", + "vl.pvfmkwloge.mvl" => "__builtin_ve_vl_pvfmkwloge_mvl", + "vl.pvfmkwloge.mvml" => "__builtin_ve_vl_pvfmkwloge_mvml", + "vl.pvfmkwlogenan.mvl" => "__builtin_ve_vl_pvfmkwlogenan_mvl", + "vl.pvfmkwlogenan.mvml" => "__builtin_ve_vl_pvfmkwlogenan_mvml", + "vl.pvfmkwlogt.mvl" => "__builtin_ve_vl_pvfmkwlogt_mvl", + "vl.pvfmkwlogt.mvml" => "__builtin_ve_vl_pvfmkwlogt_mvml", + "vl.pvfmkwlogtnan.mvl" => "__builtin_ve_vl_pvfmkwlogtnan_mvl", + "vl.pvfmkwlogtnan.mvml" => "__builtin_ve_vl_pvfmkwlogtnan_mvml", + "vl.pvfmkwlole.mvl" => "__builtin_ve_vl_pvfmkwlole_mvl", + "vl.pvfmkwlole.mvml" => "__builtin_ve_vl_pvfmkwlole_mvml", + "vl.pvfmkwlolenan.mvl" => "__builtin_ve_vl_pvfmkwlolenan_mvl", + "vl.pvfmkwlolenan.mvml" => "__builtin_ve_vl_pvfmkwlolenan_mvml", + "vl.pvfmkwlolt.mvl" => "__builtin_ve_vl_pvfmkwlolt_mvl", + "vl.pvfmkwlolt.mvml" => "__builtin_ve_vl_pvfmkwlolt_mvml", + "vl.pvfmkwloltnan.mvl" => "__builtin_ve_vl_pvfmkwloltnan_mvl", + "vl.pvfmkwloltnan.mvml" => "__builtin_ve_vl_pvfmkwloltnan_mvml", + "vl.pvfmkwlonan.mvl" => "__builtin_ve_vl_pvfmkwlonan_mvl", + "vl.pvfmkwlonan.mvml" => "__builtin_ve_vl_pvfmkwlonan_mvml", + "vl.pvfmkwlone.mvl" => "__builtin_ve_vl_pvfmkwlone_mvl", + "vl.pvfmkwlone.mvml" => "__builtin_ve_vl_pvfmkwlone_mvml", + "vl.pvfmkwlonenan.mvl" => "__builtin_ve_vl_pvfmkwlonenan_mvl", + "vl.pvfmkwlonenan.mvml" => "__builtin_ve_vl_pvfmkwlonenan_mvml", + "vl.pvfmkwlonum.mvl" => "__builtin_ve_vl_pvfmkwlonum_mvl", + "vl.pvfmkwlonum.mvml" => "__builtin_ve_vl_pvfmkwlonum_mvml", + "vl.pvfmkwlt.MvMl" => "__builtin_ve_vl_pvfmkwlt_MvMl", + "vl.pvfmkwlt.Mvl" => "__builtin_ve_vl_pvfmkwlt_Mvl", + "vl.pvfmkwltnan.MvMl" => "__builtin_ve_vl_pvfmkwltnan_MvMl", + "vl.pvfmkwltnan.Mvl" => "__builtin_ve_vl_pvfmkwltnan_Mvl", + "vl.pvfmkwnan.MvMl" => "__builtin_ve_vl_pvfmkwnan_MvMl", + "vl.pvfmkwnan.Mvl" => "__builtin_ve_vl_pvfmkwnan_Mvl", + "vl.pvfmkwne.MvMl" => "__builtin_ve_vl_pvfmkwne_MvMl", + "vl.pvfmkwne.Mvl" => "__builtin_ve_vl_pvfmkwne_Mvl", + "vl.pvfmkwnenan.MvMl" => "__builtin_ve_vl_pvfmkwnenan_MvMl", + "vl.pvfmkwnenan.Mvl" => "__builtin_ve_vl_pvfmkwnenan_Mvl", + "vl.pvfmkwnum.MvMl" => "__builtin_ve_vl_pvfmkwnum_MvMl", + "vl.pvfmkwnum.Mvl" => "__builtin_ve_vl_pvfmkwnum_Mvl", + "vl.pvfmkwupeq.mvl" => "__builtin_ve_vl_pvfmkwupeq_mvl", + "vl.pvfmkwupeq.mvml" => "__builtin_ve_vl_pvfmkwupeq_mvml", + "vl.pvfmkwupeqnan.mvl" => "__builtin_ve_vl_pvfmkwupeqnan_mvl", + "vl.pvfmkwupeqnan.mvml" => "__builtin_ve_vl_pvfmkwupeqnan_mvml", + "vl.pvfmkwupge.mvl" => "__builtin_ve_vl_pvfmkwupge_mvl", + "vl.pvfmkwupge.mvml" => "__builtin_ve_vl_pvfmkwupge_mvml", + "vl.pvfmkwupgenan.mvl" => "__builtin_ve_vl_pvfmkwupgenan_mvl", + "vl.pvfmkwupgenan.mvml" => "__builtin_ve_vl_pvfmkwupgenan_mvml", + "vl.pvfmkwupgt.mvl" => "__builtin_ve_vl_pvfmkwupgt_mvl", + "vl.pvfmkwupgt.mvml" => "__builtin_ve_vl_pvfmkwupgt_mvml", + "vl.pvfmkwupgtnan.mvl" => "__builtin_ve_vl_pvfmkwupgtnan_mvl", + "vl.pvfmkwupgtnan.mvml" => "__builtin_ve_vl_pvfmkwupgtnan_mvml", + "vl.pvfmkwuple.mvl" => "__builtin_ve_vl_pvfmkwuple_mvl", + "vl.pvfmkwuple.mvml" => "__builtin_ve_vl_pvfmkwuple_mvml", + "vl.pvfmkwuplenan.mvl" => "__builtin_ve_vl_pvfmkwuplenan_mvl", + "vl.pvfmkwuplenan.mvml" => "__builtin_ve_vl_pvfmkwuplenan_mvml", + "vl.pvfmkwuplt.mvl" => "__builtin_ve_vl_pvfmkwuplt_mvl", + "vl.pvfmkwuplt.mvml" => "__builtin_ve_vl_pvfmkwuplt_mvml", + "vl.pvfmkwupltnan.mvl" => "__builtin_ve_vl_pvfmkwupltnan_mvl", + "vl.pvfmkwupltnan.mvml" => "__builtin_ve_vl_pvfmkwupltnan_mvml", + "vl.pvfmkwupnan.mvl" => "__builtin_ve_vl_pvfmkwupnan_mvl", + "vl.pvfmkwupnan.mvml" => "__builtin_ve_vl_pvfmkwupnan_mvml", + "vl.pvfmkwupne.mvl" => "__builtin_ve_vl_pvfmkwupne_mvl", + "vl.pvfmkwupne.mvml" => "__builtin_ve_vl_pvfmkwupne_mvml", + "vl.pvfmkwupnenan.mvl" => "__builtin_ve_vl_pvfmkwupnenan_mvl", + "vl.pvfmkwupnenan.mvml" => "__builtin_ve_vl_pvfmkwupnenan_mvml", + "vl.pvfmkwupnum.mvl" => "__builtin_ve_vl_pvfmkwupnum_mvl", + "vl.pvfmkwupnum.mvml" => "__builtin_ve_vl_pvfmkwupnum_mvml", + "vl.pvfmsb.vsvvMvl" => "__builtin_ve_vl_pvfmsb_vsvvMvl", + "vl.pvfmsb.vsvvl" => "__builtin_ve_vl_pvfmsb_vsvvl", + "vl.pvfmsb.vsvvvl" => "__builtin_ve_vl_pvfmsb_vsvvvl", + "vl.pvfmsb.vvsvMvl" => "__builtin_ve_vl_pvfmsb_vvsvMvl", + "vl.pvfmsb.vvsvl" => "__builtin_ve_vl_pvfmsb_vvsvl", + "vl.pvfmsb.vvsvvl" => "__builtin_ve_vl_pvfmsb_vvsvvl", + "vl.pvfmsb.vvvvMvl" => "__builtin_ve_vl_pvfmsb_vvvvMvl", + "vl.pvfmsb.vvvvl" => "__builtin_ve_vl_pvfmsb_vvvvl", + "vl.pvfmsb.vvvvvl" => "__builtin_ve_vl_pvfmsb_vvvvvl", + "vl.pvfmul.vsvMvl" => "__builtin_ve_vl_pvfmul_vsvMvl", + "vl.pvfmul.vsvl" => "__builtin_ve_vl_pvfmul_vsvl", + "vl.pvfmul.vsvvl" => "__builtin_ve_vl_pvfmul_vsvvl", + "vl.pvfmul.vvvMvl" => "__builtin_ve_vl_pvfmul_vvvMvl", + "vl.pvfmul.vvvl" => "__builtin_ve_vl_pvfmul_vvvl", + "vl.pvfmul.vvvvl" => "__builtin_ve_vl_pvfmul_vvvvl", + "vl.pvfnmad.vsvvMvl" => "__builtin_ve_vl_pvfnmad_vsvvMvl", + "vl.pvfnmad.vsvvl" => "__builtin_ve_vl_pvfnmad_vsvvl", + "vl.pvfnmad.vsvvvl" => "__builtin_ve_vl_pvfnmad_vsvvvl", + "vl.pvfnmad.vvsvMvl" => "__builtin_ve_vl_pvfnmad_vvsvMvl", + "vl.pvfnmad.vvsvl" => "__builtin_ve_vl_pvfnmad_vvsvl", + "vl.pvfnmad.vvsvvl" => "__builtin_ve_vl_pvfnmad_vvsvvl", + "vl.pvfnmad.vvvvMvl" => "__builtin_ve_vl_pvfnmad_vvvvMvl", + "vl.pvfnmad.vvvvl" => "__builtin_ve_vl_pvfnmad_vvvvl", + "vl.pvfnmad.vvvvvl" => "__builtin_ve_vl_pvfnmad_vvvvvl", + "vl.pvfnmsb.vsvvMvl" => "__builtin_ve_vl_pvfnmsb_vsvvMvl", + "vl.pvfnmsb.vsvvl" => "__builtin_ve_vl_pvfnmsb_vsvvl", + "vl.pvfnmsb.vsvvvl" => "__builtin_ve_vl_pvfnmsb_vsvvvl", + "vl.pvfnmsb.vvsvMvl" => "__builtin_ve_vl_pvfnmsb_vvsvMvl", + "vl.pvfnmsb.vvsvl" => "__builtin_ve_vl_pvfnmsb_vvsvl", + "vl.pvfnmsb.vvsvvl" => "__builtin_ve_vl_pvfnmsb_vvsvvl", + "vl.pvfnmsb.vvvvMvl" => "__builtin_ve_vl_pvfnmsb_vvvvMvl", + "vl.pvfnmsb.vvvvl" => "__builtin_ve_vl_pvfnmsb_vvvvl", + "vl.pvfnmsb.vvvvvl" => "__builtin_ve_vl_pvfnmsb_vvvvvl", + "vl.pvfsub.vsvMvl" => "__builtin_ve_vl_pvfsub_vsvMvl", + "vl.pvfsub.vsvl" => "__builtin_ve_vl_pvfsub_vsvl", + "vl.pvfsub.vsvvl" => "__builtin_ve_vl_pvfsub_vsvvl", + "vl.pvfsub.vvvMvl" => "__builtin_ve_vl_pvfsub_vvvMvl", + "vl.pvfsub.vvvl" => "__builtin_ve_vl_pvfsub_vvvl", + "vl.pvfsub.vvvvl" => "__builtin_ve_vl_pvfsub_vvvvl", + "vl.pvldz.vvMvl" => "__builtin_ve_vl_pvldz_vvMvl", + "vl.pvldz.vvl" => "__builtin_ve_vl_pvldz_vvl", + "vl.pvldz.vvvl" => "__builtin_ve_vl_pvldz_vvvl", + "vl.pvldzlo.vvl" => "__builtin_ve_vl_pvldzlo_vvl", + "vl.pvldzlo.vvmvl" => "__builtin_ve_vl_pvldzlo_vvmvl", + "vl.pvldzlo.vvvl" => "__builtin_ve_vl_pvldzlo_vvvl", + "vl.pvldzup.vvl" => "__builtin_ve_vl_pvldzup_vvl", + "vl.pvldzup.vvmvl" => "__builtin_ve_vl_pvldzup_vvmvl", + "vl.pvldzup.vvvl" => "__builtin_ve_vl_pvldzup_vvvl", + "vl.pvmaxs.vsvMvl" => "__builtin_ve_vl_pvmaxs_vsvMvl", + "vl.pvmaxs.vsvl" => "__builtin_ve_vl_pvmaxs_vsvl", + "vl.pvmaxs.vsvvl" => "__builtin_ve_vl_pvmaxs_vsvvl", + "vl.pvmaxs.vvvMvl" => "__builtin_ve_vl_pvmaxs_vvvMvl", + "vl.pvmaxs.vvvl" => "__builtin_ve_vl_pvmaxs_vvvl", + "vl.pvmaxs.vvvvl" => "__builtin_ve_vl_pvmaxs_vvvvl", + "vl.pvmins.vsvMvl" => "__builtin_ve_vl_pvmins_vsvMvl", + "vl.pvmins.vsvl" => "__builtin_ve_vl_pvmins_vsvl", + "vl.pvmins.vsvvl" => "__builtin_ve_vl_pvmins_vsvvl", + "vl.pvmins.vvvMvl" => "__builtin_ve_vl_pvmins_vvvMvl", + "vl.pvmins.vvvl" => "__builtin_ve_vl_pvmins_vvvl", + "vl.pvmins.vvvvl" => "__builtin_ve_vl_pvmins_vvvvl", + "vl.pvor.vsvMvl" => "__builtin_ve_vl_pvor_vsvMvl", + "vl.pvor.vsvl" => "__builtin_ve_vl_pvor_vsvl", + "vl.pvor.vsvvl" => "__builtin_ve_vl_pvor_vsvvl", + "vl.pvor.vvvMvl" => "__builtin_ve_vl_pvor_vvvMvl", + "vl.pvor.vvvl" => "__builtin_ve_vl_pvor_vvvl", + "vl.pvor.vvvvl" => "__builtin_ve_vl_pvor_vvvvl", + "vl.pvpcnt.vvMvl" => "__builtin_ve_vl_pvpcnt_vvMvl", + "vl.pvpcnt.vvl" => "__builtin_ve_vl_pvpcnt_vvl", + "vl.pvpcnt.vvvl" => "__builtin_ve_vl_pvpcnt_vvvl", + "vl.pvpcntlo.vvl" => "__builtin_ve_vl_pvpcntlo_vvl", + "vl.pvpcntlo.vvmvl" => "__builtin_ve_vl_pvpcntlo_vvmvl", + "vl.pvpcntlo.vvvl" => "__builtin_ve_vl_pvpcntlo_vvvl", + "vl.pvpcntup.vvl" => "__builtin_ve_vl_pvpcntup_vvl", + "vl.pvpcntup.vvmvl" => "__builtin_ve_vl_pvpcntup_vvmvl", + "vl.pvpcntup.vvvl" => "__builtin_ve_vl_pvpcntup_vvvl", + "vl.pvrcp.vvl" => "__builtin_ve_vl_pvrcp_vvl", + "vl.pvrcp.vvvl" => "__builtin_ve_vl_pvrcp_vvvl", + "vl.pvrsqrt.vvl" => "__builtin_ve_vl_pvrsqrt_vvl", + "vl.pvrsqrt.vvvl" => "__builtin_ve_vl_pvrsqrt_vvvl", + "vl.pvrsqrtnex.vvl" => "__builtin_ve_vl_pvrsqrtnex_vvl", + "vl.pvrsqrtnex.vvvl" => "__builtin_ve_vl_pvrsqrtnex_vvvl", + "vl.pvseq.vl" => "__builtin_ve_vl_pvseq_vl", + "vl.pvseq.vvl" => "__builtin_ve_vl_pvseq_vvl", + "vl.pvseqlo.vl" => "__builtin_ve_vl_pvseqlo_vl", + "vl.pvseqlo.vvl" => "__builtin_ve_vl_pvseqlo_vvl", + "vl.pvsequp.vl" => "__builtin_ve_vl_pvsequp_vl", + "vl.pvsequp.vvl" => "__builtin_ve_vl_pvsequp_vvl", + "vl.pvsla.vvsMvl" => "__builtin_ve_vl_pvsla_vvsMvl", + "vl.pvsla.vvsl" => "__builtin_ve_vl_pvsla_vvsl", + "vl.pvsla.vvsvl" => "__builtin_ve_vl_pvsla_vvsvl", + "vl.pvsla.vvvMvl" => "__builtin_ve_vl_pvsla_vvvMvl", + "vl.pvsla.vvvl" => "__builtin_ve_vl_pvsla_vvvl", + "vl.pvsla.vvvvl" => "__builtin_ve_vl_pvsla_vvvvl", + "vl.pvsll.vvsMvl" => "__builtin_ve_vl_pvsll_vvsMvl", + "vl.pvsll.vvsl" => "__builtin_ve_vl_pvsll_vvsl", + "vl.pvsll.vvsvl" => "__builtin_ve_vl_pvsll_vvsvl", + "vl.pvsll.vvvMvl" => "__builtin_ve_vl_pvsll_vvvMvl", + "vl.pvsll.vvvl" => "__builtin_ve_vl_pvsll_vvvl", + "vl.pvsll.vvvvl" => "__builtin_ve_vl_pvsll_vvvvl", + "vl.pvsra.vvsMvl" => "__builtin_ve_vl_pvsra_vvsMvl", + "vl.pvsra.vvsl" => "__builtin_ve_vl_pvsra_vvsl", + "vl.pvsra.vvsvl" => "__builtin_ve_vl_pvsra_vvsvl", + "vl.pvsra.vvvMvl" => "__builtin_ve_vl_pvsra_vvvMvl", + "vl.pvsra.vvvl" => "__builtin_ve_vl_pvsra_vvvl", + "vl.pvsra.vvvvl" => "__builtin_ve_vl_pvsra_vvvvl", + "vl.pvsrl.vvsMvl" => "__builtin_ve_vl_pvsrl_vvsMvl", + "vl.pvsrl.vvsl" => "__builtin_ve_vl_pvsrl_vvsl", + "vl.pvsrl.vvsvl" => "__builtin_ve_vl_pvsrl_vvsvl", + "vl.pvsrl.vvvMvl" => "__builtin_ve_vl_pvsrl_vvvMvl", + "vl.pvsrl.vvvl" => "__builtin_ve_vl_pvsrl_vvvl", + "vl.pvsrl.vvvvl" => "__builtin_ve_vl_pvsrl_vvvvl", + "vl.pvsubs.vsvMvl" => "__builtin_ve_vl_pvsubs_vsvMvl", + "vl.pvsubs.vsvl" => "__builtin_ve_vl_pvsubs_vsvl", + "vl.pvsubs.vsvvl" => "__builtin_ve_vl_pvsubs_vsvvl", + "vl.pvsubs.vvvMvl" => "__builtin_ve_vl_pvsubs_vvvMvl", + "vl.pvsubs.vvvl" => "__builtin_ve_vl_pvsubs_vvvl", + "vl.pvsubs.vvvvl" => "__builtin_ve_vl_pvsubs_vvvvl", + "vl.pvsubu.vsvMvl" => "__builtin_ve_vl_pvsubu_vsvMvl", + "vl.pvsubu.vsvl" => "__builtin_ve_vl_pvsubu_vsvl", + "vl.pvsubu.vsvvl" => "__builtin_ve_vl_pvsubu_vsvvl", + "vl.pvsubu.vvvMvl" => "__builtin_ve_vl_pvsubu_vvvMvl", + "vl.pvsubu.vvvl" => "__builtin_ve_vl_pvsubu_vvvl", + "vl.pvsubu.vvvvl" => "__builtin_ve_vl_pvsubu_vvvvl", + "vl.pvxor.vsvMvl" => "__builtin_ve_vl_pvxor_vsvMvl", + "vl.pvxor.vsvl" => "__builtin_ve_vl_pvxor_vsvl", + "vl.pvxor.vsvvl" => "__builtin_ve_vl_pvxor_vsvvl", + "vl.pvxor.vvvMvl" => "__builtin_ve_vl_pvxor_vvvMvl", + "vl.pvxor.vvvl" => "__builtin_ve_vl_pvxor_vvvl", + "vl.pvxor.vvvvl" => "__builtin_ve_vl_pvxor_vvvvl", + "vl.scr.sss" => "__builtin_ve_vl_scr_sss", + "vl.svm.sMs" => "__builtin_ve_vl_svm_sMs", + "vl.svm.sms" => "__builtin_ve_vl_svm_sms", + "vl.svob" => "__builtin_ve_vl_svob", + "vl.tovm.sml" => "__builtin_ve_vl_tovm_sml", + "vl.tscr.ssss" => "__builtin_ve_vl_tscr_ssss", + "vl.vaddsl.vsvl" => "__builtin_ve_vl_vaddsl_vsvl", + "vl.vaddsl.vsvmvl" => "__builtin_ve_vl_vaddsl_vsvmvl", + "vl.vaddsl.vsvvl" => "__builtin_ve_vl_vaddsl_vsvvl", + "vl.vaddsl.vvvl" => "__builtin_ve_vl_vaddsl_vvvl", + "vl.vaddsl.vvvmvl" => "__builtin_ve_vl_vaddsl_vvvmvl", + "vl.vaddsl.vvvvl" => "__builtin_ve_vl_vaddsl_vvvvl", + "vl.vaddswsx.vsvl" => "__builtin_ve_vl_vaddswsx_vsvl", + "vl.vaddswsx.vsvmvl" => "__builtin_ve_vl_vaddswsx_vsvmvl", + "vl.vaddswsx.vsvvl" => "__builtin_ve_vl_vaddswsx_vsvvl", + "vl.vaddswsx.vvvl" => "__builtin_ve_vl_vaddswsx_vvvl", + "vl.vaddswsx.vvvmvl" => "__builtin_ve_vl_vaddswsx_vvvmvl", + "vl.vaddswsx.vvvvl" => "__builtin_ve_vl_vaddswsx_vvvvl", + "vl.vaddswzx.vsvl" => "__builtin_ve_vl_vaddswzx_vsvl", + "vl.vaddswzx.vsvmvl" => "__builtin_ve_vl_vaddswzx_vsvmvl", + "vl.vaddswzx.vsvvl" => "__builtin_ve_vl_vaddswzx_vsvvl", + "vl.vaddswzx.vvvl" => "__builtin_ve_vl_vaddswzx_vvvl", + "vl.vaddswzx.vvvmvl" => "__builtin_ve_vl_vaddswzx_vvvmvl", + "vl.vaddswzx.vvvvl" => "__builtin_ve_vl_vaddswzx_vvvvl", + "vl.vaddul.vsvl" => "__builtin_ve_vl_vaddul_vsvl", + "vl.vaddul.vsvmvl" => "__builtin_ve_vl_vaddul_vsvmvl", + "vl.vaddul.vsvvl" => "__builtin_ve_vl_vaddul_vsvvl", + "vl.vaddul.vvvl" => "__builtin_ve_vl_vaddul_vvvl", + "vl.vaddul.vvvmvl" => "__builtin_ve_vl_vaddul_vvvmvl", + "vl.vaddul.vvvvl" => "__builtin_ve_vl_vaddul_vvvvl", + "vl.vadduw.vsvl" => "__builtin_ve_vl_vadduw_vsvl", + "vl.vadduw.vsvmvl" => "__builtin_ve_vl_vadduw_vsvmvl", + "vl.vadduw.vsvvl" => "__builtin_ve_vl_vadduw_vsvvl", + "vl.vadduw.vvvl" => "__builtin_ve_vl_vadduw_vvvl", + "vl.vadduw.vvvmvl" => "__builtin_ve_vl_vadduw_vvvmvl", + "vl.vadduw.vvvvl" => "__builtin_ve_vl_vadduw_vvvvl", + "vl.vand.vsvl" => "__builtin_ve_vl_vand_vsvl", + "vl.vand.vsvmvl" => "__builtin_ve_vl_vand_vsvmvl", + "vl.vand.vsvvl" => "__builtin_ve_vl_vand_vsvvl", + "vl.vand.vvvl" => "__builtin_ve_vl_vand_vvvl", + "vl.vand.vvvmvl" => "__builtin_ve_vl_vand_vvvmvl", + "vl.vand.vvvvl" => "__builtin_ve_vl_vand_vvvvl", + "vl.vbrdd.vsl" => "__builtin_ve_vl_vbrdd_vsl", + "vl.vbrdd.vsmvl" => "__builtin_ve_vl_vbrdd_vsmvl", + "vl.vbrdd.vsvl" => "__builtin_ve_vl_vbrdd_vsvl", + "vl.vbrdl.vsl" => "__builtin_ve_vl_vbrdl_vsl", + "vl.vbrdl.vsmvl" => "__builtin_ve_vl_vbrdl_vsmvl", + "vl.vbrdl.vsvl" => "__builtin_ve_vl_vbrdl_vsvl", + "vl.vbrds.vsl" => "__builtin_ve_vl_vbrds_vsl", + "vl.vbrds.vsmvl" => "__builtin_ve_vl_vbrds_vsmvl", + "vl.vbrds.vsvl" => "__builtin_ve_vl_vbrds_vsvl", + "vl.vbrdw.vsl" => "__builtin_ve_vl_vbrdw_vsl", + "vl.vbrdw.vsmvl" => "__builtin_ve_vl_vbrdw_vsmvl", + "vl.vbrdw.vsvl" => "__builtin_ve_vl_vbrdw_vsvl", + "vl.vbrv.vvl" => "__builtin_ve_vl_vbrv_vvl", + "vl.vbrv.vvmvl" => "__builtin_ve_vl_vbrv_vvmvl", + "vl.vbrv.vvvl" => "__builtin_ve_vl_vbrv_vvvl", + "vl.vcmpsl.vsvl" => "__builtin_ve_vl_vcmpsl_vsvl", + "vl.vcmpsl.vsvmvl" => "__builtin_ve_vl_vcmpsl_vsvmvl", + "vl.vcmpsl.vsvvl" => "__builtin_ve_vl_vcmpsl_vsvvl", + "vl.vcmpsl.vvvl" => "__builtin_ve_vl_vcmpsl_vvvl", + "vl.vcmpsl.vvvmvl" => "__builtin_ve_vl_vcmpsl_vvvmvl", + "vl.vcmpsl.vvvvl" => "__builtin_ve_vl_vcmpsl_vvvvl", + "vl.vcmpswsx.vsvl" => "__builtin_ve_vl_vcmpswsx_vsvl", + "vl.vcmpswsx.vsvmvl" => "__builtin_ve_vl_vcmpswsx_vsvmvl", + "vl.vcmpswsx.vsvvl" => "__builtin_ve_vl_vcmpswsx_vsvvl", + "vl.vcmpswsx.vvvl" => "__builtin_ve_vl_vcmpswsx_vvvl", + "vl.vcmpswsx.vvvmvl" => "__builtin_ve_vl_vcmpswsx_vvvmvl", + "vl.vcmpswsx.vvvvl" => "__builtin_ve_vl_vcmpswsx_vvvvl", + "vl.vcmpswzx.vsvl" => "__builtin_ve_vl_vcmpswzx_vsvl", + "vl.vcmpswzx.vsvmvl" => "__builtin_ve_vl_vcmpswzx_vsvmvl", + "vl.vcmpswzx.vsvvl" => "__builtin_ve_vl_vcmpswzx_vsvvl", + "vl.vcmpswzx.vvvl" => "__builtin_ve_vl_vcmpswzx_vvvl", + "vl.vcmpswzx.vvvmvl" => "__builtin_ve_vl_vcmpswzx_vvvmvl", + "vl.vcmpswzx.vvvvl" => "__builtin_ve_vl_vcmpswzx_vvvvl", + "vl.vcmpul.vsvl" => "__builtin_ve_vl_vcmpul_vsvl", + "vl.vcmpul.vsvmvl" => "__builtin_ve_vl_vcmpul_vsvmvl", + "vl.vcmpul.vsvvl" => "__builtin_ve_vl_vcmpul_vsvvl", + "vl.vcmpul.vvvl" => "__builtin_ve_vl_vcmpul_vvvl", + "vl.vcmpul.vvvmvl" => "__builtin_ve_vl_vcmpul_vvvmvl", + "vl.vcmpul.vvvvl" => "__builtin_ve_vl_vcmpul_vvvvl", + "vl.vcmpuw.vsvl" => "__builtin_ve_vl_vcmpuw_vsvl", + "vl.vcmpuw.vsvmvl" => "__builtin_ve_vl_vcmpuw_vsvmvl", + "vl.vcmpuw.vsvvl" => "__builtin_ve_vl_vcmpuw_vsvvl", + "vl.vcmpuw.vvvl" => "__builtin_ve_vl_vcmpuw_vvvl", + "vl.vcmpuw.vvvmvl" => "__builtin_ve_vl_vcmpuw_vvvmvl", + "vl.vcmpuw.vvvvl" => "__builtin_ve_vl_vcmpuw_vvvvl", + "vl.vcp.vvmvl" => "__builtin_ve_vl_vcp_vvmvl", + "vl.vcvtdl.vvl" => "__builtin_ve_vl_vcvtdl_vvl", + "vl.vcvtdl.vvvl" => "__builtin_ve_vl_vcvtdl_vvvl", + "vl.vcvtds.vvl" => "__builtin_ve_vl_vcvtds_vvl", + "vl.vcvtds.vvvl" => "__builtin_ve_vl_vcvtds_vvvl", + "vl.vcvtdw.vvl" => "__builtin_ve_vl_vcvtdw_vvl", + "vl.vcvtdw.vvvl" => "__builtin_ve_vl_vcvtdw_vvvl", + "vl.vcvtld.vvl" => "__builtin_ve_vl_vcvtld_vvl", + "vl.vcvtld.vvmvl" => "__builtin_ve_vl_vcvtld_vvmvl", + "vl.vcvtld.vvvl" => "__builtin_ve_vl_vcvtld_vvvl", + "vl.vcvtldrz.vvl" => "__builtin_ve_vl_vcvtldrz_vvl", + "vl.vcvtldrz.vvmvl" => "__builtin_ve_vl_vcvtldrz_vvmvl", + "vl.vcvtldrz.vvvl" => "__builtin_ve_vl_vcvtldrz_vvvl", + "vl.vcvtsd.vvl" => "__builtin_ve_vl_vcvtsd_vvl", + "vl.vcvtsd.vvvl" => "__builtin_ve_vl_vcvtsd_vvvl", + "vl.vcvtsw.vvl" => "__builtin_ve_vl_vcvtsw_vvl", + "vl.vcvtsw.vvvl" => "__builtin_ve_vl_vcvtsw_vvvl", + "vl.vcvtwdsx.vvl" => "__builtin_ve_vl_vcvtwdsx_vvl", + "vl.vcvtwdsx.vvmvl" => "__builtin_ve_vl_vcvtwdsx_vvmvl", + "vl.vcvtwdsx.vvvl" => "__builtin_ve_vl_vcvtwdsx_vvvl", + "vl.vcvtwdsxrz.vvl" => "__builtin_ve_vl_vcvtwdsxrz_vvl", + "vl.vcvtwdsxrz.vvmvl" => "__builtin_ve_vl_vcvtwdsxrz_vvmvl", + "vl.vcvtwdsxrz.vvvl" => "__builtin_ve_vl_vcvtwdsxrz_vvvl", + "vl.vcvtwdzx.vvl" => "__builtin_ve_vl_vcvtwdzx_vvl", + "vl.vcvtwdzx.vvmvl" => "__builtin_ve_vl_vcvtwdzx_vvmvl", + "vl.vcvtwdzx.vvvl" => "__builtin_ve_vl_vcvtwdzx_vvvl", + "vl.vcvtwdzxrz.vvl" => "__builtin_ve_vl_vcvtwdzxrz_vvl", + "vl.vcvtwdzxrz.vvmvl" => "__builtin_ve_vl_vcvtwdzxrz_vvmvl", + "vl.vcvtwdzxrz.vvvl" => "__builtin_ve_vl_vcvtwdzxrz_vvvl", + "vl.vcvtwssx.vvl" => "__builtin_ve_vl_vcvtwssx_vvl", + "vl.vcvtwssx.vvmvl" => "__builtin_ve_vl_vcvtwssx_vvmvl", + "vl.vcvtwssx.vvvl" => "__builtin_ve_vl_vcvtwssx_vvvl", + "vl.vcvtwssxrz.vvl" => "__builtin_ve_vl_vcvtwssxrz_vvl", + "vl.vcvtwssxrz.vvmvl" => "__builtin_ve_vl_vcvtwssxrz_vvmvl", + "vl.vcvtwssxrz.vvvl" => "__builtin_ve_vl_vcvtwssxrz_vvvl", + "vl.vcvtwszx.vvl" => "__builtin_ve_vl_vcvtwszx_vvl", + "vl.vcvtwszx.vvmvl" => "__builtin_ve_vl_vcvtwszx_vvmvl", + "vl.vcvtwszx.vvvl" => "__builtin_ve_vl_vcvtwszx_vvvl", + "vl.vcvtwszxrz.vvl" => "__builtin_ve_vl_vcvtwszxrz_vvl", + "vl.vcvtwszxrz.vvmvl" => "__builtin_ve_vl_vcvtwszxrz_vvmvl", + "vl.vcvtwszxrz.vvvl" => "__builtin_ve_vl_vcvtwszxrz_vvvl", + "vl.vdivsl.vsvl" => "__builtin_ve_vl_vdivsl_vsvl", + "vl.vdivsl.vsvmvl" => "__builtin_ve_vl_vdivsl_vsvmvl", + "vl.vdivsl.vsvvl" => "__builtin_ve_vl_vdivsl_vsvvl", + "vl.vdivsl.vvsl" => "__builtin_ve_vl_vdivsl_vvsl", + "vl.vdivsl.vvsmvl" => "__builtin_ve_vl_vdivsl_vvsmvl", + "vl.vdivsl.vvsvl" => "__builtin_ve_vl_vdivsl_vvsvl", + "vl.vdivsl.vvvl" => "__builtin_ve_vl_vdivsl_vvvl", + "vl.vdivsl.vvvmvl" => "__builtin_ve_vl_vdivsl_vvvmvl", + "vl.vdivsl.vvvvl" => "__builtin_ve_vl_vdivsl_vvvvl", + "vl.vdivswsx.vsvl" => "__builtin_ve_vl_vdivswsx_vsvl", + "vl.vdivswsx.vsvmvl" => "__builtin_ve_vl_vdivswsx_vsvmvl", + "vl.vdivswsx.vsvvl" => "__builtin_ve_vl_vdivswsx_vsvvl", + "vl.vdivswsx.vvsl" => "__builtin_ve_vl_vdivswsx_vvsl", + "vl.vdivswsx.vvsmvl" => "__builtin_ve_vl_vdivswsx_vvsmvl", + "vl.vdivswsx.vvsvl" => "__builtin_ve_vl_vdivswsx_vvsvl", + "vl.vdivswsx.vvvl" => "__builtin_ve_vl_vdivswsx_vvvl", + "vl.vdivswsx.vvvmvl" => "__builtin_ve_vl_vdivswsx_vvvmvl", + "vl.vdivswsx.vvvvl" => "__builtin_ve_vl_vdivswsx_vvvvl", + "vl.vdivswzx.vsvl" => "__builtin_ve_vl_vdivswzx_vsvl", + "vl.vdivswzx.vsvmvl" => "__builtin_ve_vl_vdivswzx_vsvmvl", + "vl.vdivswzx.vsvvl" => "__builtin_ve_vl_vdivswzx_vsvvl", + "vl.vdivswzx.vvsl" => "__builtin_ve_vl_vdivswzx_vvsl", + "vl.vdivswzx.vvsmvl" => "__builtin_ve_vl_vdivswzx_vvsmvl", + "vl.vdivswzx.vvsvl" => "__builtin_ve_vl_vdivswzx_vvsvl", + "vl.vdivswzx.vvvl" => "__builtin_ve_vl_vdivswzx_vvvl", + "vl.vdivswzx.vvvmvl" => "__builtin_ve_vl_vdivswzx_vvvmvl", + "vl.vdivswzx.vvvvl" => "__builtin_ve_vl_vdivswzx_vvvvl", + "vl.vdivul.vsvl" => "__builtin_ve_vl_vdivul_vsvl", + "vl.vdivul.vsvmvl" => "__builtin_ve_vl_vdivul_vsvmvl", + "vl.vdivul.vsvvl" => "__builtin_ve_vl_vdivul_vsvvl", + "vl.vdivul.vvsl" => "__builtin_ve_vl_vdivul_vvsl", + "vl.vdivul.vvsmvl" => "__builtin_ve_vl_vdivul_vvsmvl", + "vl.vdivul.vvsvl" => "__builtin_ve_vl_vdivul_vvsvl", + "vl.vdivul.vvvl" => "__builtin_ve_vl_vdivul_vvvl", + "vl.vdivul.vvvmvl" => "__builtin_ve_vl_vdivul_vvvmvl", + "vl.vdivul.vvvvl" => "__builtin_ve_vl_vdivul_vvvvl", + "vl.vdivuw.vsvl" => "__builtin_ve_vl_vdivuw_vsvl", + "vl.vdivuw.vsvmvl" => "__builtin_ve_vl_vdivuw_vsvmvl", + "vl.vdivuw.vsvvl" => "__builtin_ve_vl_vdivuw_vsvvl", + "vl.vdivuw.vvsl" => "__builtin_ve_vl_vdivuw_vvsl", + "vl.vdivuw.vvsmvl" => "__builtin_ve_vl_vdivuw_vvsmvl", + "vl.vdivuw.vvsvl" => "__builtin_ve_vl_vdivuw_vvsvl", + "vl.vdivuw.vvvl" => "__builtin_ve_vl_vdivuw_vvvl", + "vl.vdivuw.vvvmvl" => "__builtin_ve_vl_vdivuw_vvvmvl", + "vl.vdivuw.vvvvl" => "__builtin_ve_vl_vdivuw_vvvvl", + "vl.veqv.vsvl" => "__builtin_ve_vl_veqv_vsvl", + "vl.veqv.vsvmvl" => "__builtin_ve_vl_veqv_vsvmvl", + "vl.veqv.vsvvl" => "__builtin_ve_vl_veqv_vsvvl", + "vl.veqv.vvvl" => "__builtin_ve_vl_veqv_vvvl", + "vl.veqv.vvvmvl" => "__builtin_ve_vl_veqv_vvvmvl", + "vl.veqv.vvvvl" => "__builtin_ve_vl_veqv_vvvvl", + "vl.vex.vvmvl" => "__builtin_ve_vl_vex_vvmvl", + "vl.vfaddd.vsvl" => "__builtin_ve_vl_vfaddd_vsvl", + "vl.vfaddd.vsvmvl" => "__builtin_ve_vl_vfaddd_vsvmvl", + "vl.vfaddd.vsvvl" => "__builtin_ve_vl_vfaddd_vsvvl", + "vl.vfaddd.vvvl" => "__builtin_ve_vl_vfaddd_vvvl", + "vl.vfaddd.vvvmvl" => "__builtin_ve_vl_vfaddd_vvvmvl", + "vl.vfaddd.vvvvl" => "__builtin_ve_vl_vfaddd_vvvvl", + "vl.vfadds.vsvl" => "__builtin_ve_vl_vfadds_vsvl", + "vl.vfadds.vsvmvl" => "__builtin_ve_vl_vfadds_vsvmvl", + "vl.vfadds.vsvvl" => "__builtin_ve_vl_vfadds_vsvvl", + "vl.vfadds.vvvl" => "__builtin_ve_vl_vfadds_vvvl", + "vl.vfadds.vvvmvl" => "__builtin_ve_vl_vfadds_vvvmvl", + "vl.vfadds.vvvvl" => "__builtin_ve_vl_vfadds_vvvvl", + "vl.vfcmpd.vsvl" => "__builtin_ve_vl_vfcmpd_vsvl", + "vl.vfcmpd.vsvmvl" => "__builtin_ve_vl_vfcmpd_vsvmvl", + "vl.vfcmpd.vsvvl" => "__builtin_ve_vl_vfcmpd_vsvvl", + "vl.vfcmpd.vvvl" => "__builtin_ve_vl_vfcmpd_vvvl", + "vl.vfcmpd.vvvmvl" => "__builtin_ve_vl_vfcmpd_vvvmvl", + "vl.vfcmpd.vvvvl" => "__builtin_ve_vl_vfcmpd_vvvvl", + "vl.vfcmps.vsvl" => "__builtin_ve_vl_vfcmps_vsvl", + "vl.vfcmps.vsvmvl" => "__builtin_ve_vl_vfcmps_vsvmvl", + "vl.vfcmps.vsvvl" => "__builtin_ve_vl_vfcmps_vsvvl", + "vl.vfcmps.vvvl" => "__builtin_ve_vl_vfcmps_vvvl", + "vl.vfcmps.vvvmvl" => "__builtin_ve_vl_vfcmps_vvvmvl", + "vl.vfcmps.vvvvl" => "__builtin_ve_vl_vfcmps_vvvvl", + "vl.vfdivd.vsvl" => "__builtin_ve_vl_vfdivd_vsvl", + "vl.vfdivd.vsvmvl" => "__builtin_ve_vl_vfdivd_vsvmvl", + "vl.vfdivd.vsvvl" => "__builtin_ve_vl_vfdivd_vsvvl", + "vl.vfdivd.vvvl" => "__builtin_ve_vl_vfdivd_vvvl", + "vl.vfdivd.vvvmvl" => "__builtin_ve_vl_vfdivd_vvvmvl", + "vl.vfdivd.vvvvl" => "__builtin_ve_vl_vfdivd_vvvvl", + "vl.vfdivs.vsvl" => "__builtin_ve_vl_vfdivs_vsvl", + "vl.vfdivs.vsvmvl" => "__builtin_ve_vl_vfdivs_vsvmvl", + "vl.vfdivs.vsvvl" => "__builtin_ve_vl_vfdivs_vsvvl", + "vl.vfdivs.vvvl" => "__builtin_ve_vl_vfdivs_vvvl", + "vl.vfdivs.vvvmvl" => "__builtin_ve_vl_vfdivs_vvvmvl", + "vl.vfdivs.vvvvl" => "__builtin_ve_vl_vfdivs_vvvvl", + "vl.vfmadd.vsvvl" => "__builtin_ve_vl_vfmadd_vsvvl", + "vl.vfmadd.vsvvmvl" => "__builtin_ve_vl_vfmadd_vsvvmvl", + "vl.vfmadd.vsvvvl" => "__builtin_ve_vl_vfmadd_vsvvvl", + "vl.vfmadd.vvsvl" => "__builtin_ve_vl_vfmadd_vvsvl", + "vl.vfmadd.vvsvmvl" => "__builtin_ve_vl_vfmadd_vvsvmvl", + "vl.vfmadd.vvsvvl" => "__builtin_ve_vl_vfmadd_vvsvvl", + "vl.vfmadd.vvvvl" => "__builtin_ve_vl_vfmadd_vvvvl", + "vl.vfmadd.vvvvmvl" => "__builtin_ve_vl_vfmadd_vvvvmvl", + "vl.vfmadd.vvvvvl" => "__builtin_ve_vl_vfmadd_vvvvvl", + "vl.vfmads.vsvvl" => "__builtin_ve_vl_vfmads_vsvvl", + "vl.vfmads.vsvvmvl" => "__builtin_ve_vl_vfmads_vsvvmvl", + "vl.vfmads.vsvvvl" => "__builtin_ve_vl_vfmads_vsvvvl", + "vl.vfmads.vvsvl" => "__builtin_ve_vl_vfmads_vvsvl", + "vl.vfmads.vvsvmvl" => "__builtin_ve_vl_vfmads_vvsvmvl", + "vl.vfmads.vvsvvl" => "__builtin_ve_vl_vfmads_vvsvvl", + "vl.vfmads.vvvvl" => "__builtin_ve_vl_vfmads_vvvvl", + "vl.vfmads.vvvvmvl" => "__builtin_ve_vl_vfmads_vvvvmvl", + "vl.vfmads.vvvvvl" => "__builtin_ve_vl_vfmads_vvvvvl", + "vl.vfmaxd.vsvl" => "__builtin_ve_vl_vfmaxd_vsvl", + "vl.vfmaxd.vsvmvl" => "__builtin_ve_vl_vfmaxd_vsvmvl", + "vl.vfmaxd.vsvvl" => "__builtin_ve_vl_vfmaxd_vsvvl", + "vl.vfmaxd.vvvl" => "__builtin_ve_vl_vfmaxd_vvvl", + "vl.vfmaxd.vvvmvl" => "__builtin_ve_vl_vfmaxd_vvvmvl", + "vl.vfmaxd.vvvvl" => "__builtin_ve_vl_vfmaxd_vvvvl", + "vl.vfmaxs.vsvl" => "__builtin_ve_vl_vfmaxs_vsvl", + "vl.vfmaxs.vsvmvl" => "__builtin_ve_vl_vfmaxs_vsvmvl", + "vl.vfmaxs.vsvvl" => "__builtin_ve_vl_vfmaxs_vsvvl", + "vl.vfmaxs.vvvl" => "__builtin_ve_vl_vfmaxs_vvvl", + "vl.vfmaxs.vvvmvl" => "__builtin_ve_vl_vfmaxs_vvvmvl", + "vl.vfmaxs.vvvvl" => "__builtin_ve_vl_vfmaxs_vvvvl", + "vl.vfmind.vsvl" => "__builtin_ve_vl_vfmind_vsvl", + "vl.vfmind.vsvmvl" => "__builtin_ve_vl_vfmind_vsvmvl", + "vl.vfmind.vsvvl" => "__builtin_ve_vl_vfmind_vsvvl", + "vl.vfmind.vvvl" => "__builtin_ve_vl_vfmind_vvvl", + "vl.vfmind.vvvmvl" => "__builtin_ve_vl_vfmind_vvvmvl", + "vl.vfmind.vvvvl" => "__builtin_ve_vl_vfmind_vvvvl", + "vl.vfmins.vsvl" => "__builtin_ve_vl_vfmins_vsvl", + "vl.vfmins.vsvmvl" => "__builtin_ve_vl_vfmins_vsvmvl", + "vl.vfmins.vsvvl" => "__builtin_ve_vl_vfmins_vsvvl", + "vl.vfmins.vvvl" => "__builtin_ve_vl_vfmins_vvvl", + "vl.vfmins.vvvmvl" => "__builtin_ve_vl_vfmins_vvvmvl", + "vl.vfmins.vvvvl" => "__builtin_ve_vl_vfmins_vvvvl", + "vl.vfmkdeq.mvl" => "__builtin_ve_vl_vfmkdeq_mvl", + "vl.vfmkdeq.mvml" => "__builtin_ve_vl_vfmkdeq_mvml", + "vl.vfmkdeqnan.mvl" => "__builtin_ve_vl_vfmkdeqnan_mvl", + "vl.vfmkdeqnan.mvml" => "__builtin_ve_vl_vfmkdeqnan_mvml", + "vl.vfmkdge.mvl" => "__builtin_ve_vl_vfmkdge_mvl", + "vl.vfmkdge.mvml" => "__builtin_ve_vl_vfmkdge_mvml", + "vl.vfmkdgenan.mvl" => "__builtin_ve_vl_vfmkdgenan_mvl", + "vl.vfmkdgenan.mvml" => "__builtin_ve_vl_vfmkdgenan_mvml", + "vl.vfmkdgt.mvl" => "__builtin_ve_vl_vfmkdgt_mvl", + "vl.vfmkdgt.mvml" => "__builtin_ve_vl_vfmkdgt_mvml", + "vl.vfmkdgtnan.mvl" => "__builtin_ve_vl_vfmkdgtnan_mvl", + "vl.vfmkdgtnan.mvml" => "__builtin_ve_vl_vfmkdgtnan_mvml", + "vl.vfmkdle.mvl" => "__builtin_ve_vl_vfmkdle_mvl", + "vl.vfmkdle.mvml" => "__builtin_ve_vl_vfmkdle_mvml", + "vl.vfmkdlenan.mvl" => "__builtin_ve_vl_vfmkdlenan_mvl", + "vl.vfmkdlenan.mvml" => "__builtin_ve_vl_vfmkdlenan_mvml", + "vl.vfmkdlt.mvl" => "__builtin_ve_vl_vfmkdlt_mvl", + "vl.vfmkdlt.mvml" => "__builtin_ve_vl_vfmkdlt_mvml", + "vl.vfmkdltnan.mvl" => "__builtin_ve_vl_vfmkdltnan_mvl", + "vl.vfmkdltnan.mvml" => "__builtin_ve_vl_vfmkdltnan_mvml", + "vl.vfmkdnan.mvl" => "__builtin_ve_vl_vfmkdnan_mvl", + "vl.vfmkdnan.mvml" => "__builtin_ve_vl_vfmkdnan_mvml", + "vl.vfmkdne.mvl" => "__builtin_ve_vl_vfmkdne_mvl", + "vl.vfmkdne.mvml" => "__builtin_ve_vl_vfmkdne_mvml", + "vl.vfmkdnenan.mvl" => "__builtin_ve_vl_vfmkdnenan_mvl", + "vl.vfmkdnenan.mvml" => "__builtin_ve_vl_vfmkdnenan_mvml", + "vl.vfmkdnum.mvl" => "__builtin_ve_vl_vfmkdnum_mvl", + "vl.vfmkdnum.mvml" => "__builtin_ve_vl_vfmkdnum_mvml", + "vl.vfmklaf.ml" => "__builtin_ve_vl_vfmklaf_ml", + "vl.vfmklat.ml" => "__builtin_ve_vl_vfmklat_ml", + "vl.vfmkleq.mvl" => "__builtin_ve_vl_vfmkleq_mvl", + "vl.vfmkleq.mvml" => "__builtin_ve_vl_vfmkleq_mvml", + "vl.vfmkleqnan.mvl" => "__builtin_ve_vl_vfmkleqnan_mvl", + "vl.vfmkleqnan.mvml" => "__builtin_ve_vl_vfmkleqnan_mvml", + "vl.vfmklge.mvl" => "__builtin_ve_vl_vfmklge_mvl", + "vl.vfmklge.mvml" => "__builtin_ve_vl_vfmklge_mvml", + "vl.vfmklgenan.mvl" => "__builtin_ve_vl_vfmklgenan_mvl", + "vl.vfmklgenan.mvml" => "__builtin_ve_vl_vfmklgenan_mvml", + "vl.vfmklgt.mvl" => "__builtin_ve_vl_vfmklgt_mvl", + "vl.vfmklgt.mvml" => "__builtin_ve_vl_vfmklgt_mvml", + "vl.vfmklgtnan.mvl" => "__builtin_ve_vl_vfmklgtnan_mvl", + "vl.vfmklgtnan.mvml" => "__builtin_ve_vl_vfmklgtnan_mvml", + "vl.vfmklle.mvl" => "__builtin_ve_vl_vfmklle_mvl", + "vl.vfmklle.mvml" => "__builtin_ve_vl_vfmklle_mvml", + "vl.vfmkllenan.mvl" => "__builtin_ve_vl_vfmkllenan_mvl", + "vl.vfmkllenan.mvml" => "__builtin_ve_vl_vfmkllenan_mvml", + "vl.vfmkllt.mvl" => "__builtin_ve_vl_vfmkllt_mvl", + "vl.vfmkllt.mvml" => "__builtin_ve_vl_vfmkllt_mvml", + "vl.vfmklltnan.mvl" => "__builtin_ve_vl_vfmklltnan_mvl", + "vl.vfmklltnan.mvml" => "__builtin_ve_vl_vfmklltnan_mvml", + "vl.vfmklnan.mvl" => "__builtin_ve_vl_vfmklnan_mvl", + "vl.vfmklnan.mvml" => "__builtin_ve_vl_vfmklnan_mvml", + "vl.vfmklne.mvl" => "__builtin_ve_vl_vfmklne_mvl", + "vl.vfmklne.mvml" => "__builtin_ve_vl_vfmklne_mvml", + "vl.vfmklnenan.mvl" => "__builtin_ve_vl_vfmklnenan_mvl", + "vl.vfmklnenan.mvml" => "__builtin_ve_vl_vfmklnenan_mvml", + "vl.vfmklnum.mvl" => "__builtin_ve_vl_vfmklnum_mvl", + "vl.vfmklnum.mvml" => "__builtin_ve_vl_vfmklnum_mvml", + "vl.vfmkseq.mvl" => "__builtin_ve_vl_vfmkseq_mvl", + "vl.vfmkseq.mvml" => "__builtin_ve_vl_vfmkseq_mvml", + "vl.vfmkseqnan.mvl" => "__builtin_ve_vl_vfmkseqnan_mvl", + "vl.vfmkseqnan.mvml" => "__builtin_ve_vl_vfmkseqnan_mvml", + "vl.vfmksge.mvl" => "__builtin_ve_vl_vfmksge_mvl", + "vl.vfmksge.mvml" => "__builtin_ve_vl_vfmksge_mvml", + "vl.vfmksgenan.mvl" => "__builtin_ve_vl_vfmksgenan_mvl", + "vl.vfmksgenan.mvml" => "__builtin_ve_vl_vfmksgenan_mvml", + "vl.vfmksgt.mvl" => "__builtin_ve_vl_vfmksgt_mvl", + "vl.vfmksgt.mvml" => "__builtin_ve_vl_vfmksgt_mvml", + "vl.vfmksgtnan.mvl" => "__builtin_ve_vl_vfmksgtnan_mvl", + "vl.vfmksgtnan.mvml" => "__builtin_ve_vl_vfmksgtnan_mvml", + "vl.vfmksle.mvl" => "__builtin_ve_vl_vfmksle_mvl", + "vl.vfmksle.mvml" => "__builtin_ve_vl_vfmksle_mvml", + "vl.vfmkslenan.mvl" => "__builtin_ve_vl_vfmkslenan_mvl", + "vl.vfmkslenan.mvml" => "__builtin_ve_vl_vfmkslenan_mvml", + "vl.vfmkslt.mvl" => "__builtin_ve_vl_vfmkslt_mvl", + "vl.vfmkslt.mvml" => "__builtin_ve_vl_vfmkslt_mvml", + "vl.vfmksltnan.mvl" => "__builtin_ve_vl_vfmksltnan_mvl", + "vl.vfmksltnan.mvml" => "__builtin_ve_vl_vfmksltnan_mvml", + "vl.vfmksnan.mvl" => "__builtin_ve_vl_vfmksnan_mvl", + "vl.vfmksnan.mvml" => "__builtin_ve_vl_vfmksnan_mvml", + "vl.vfmksne.mvl" => "__builtin_ve_vl_vfmksne_mvl", + "vl.vfmksne.mvml" => "__builtin_ve_vl_vfmksne_mvml", + "vl.vfmksnenan.mvl" => "__builtin_ve_vl_vfmksnenan_mvl", + "vl.vfmksnenan.mvml" => "__builtin_ve_vl_vfmksnenan_mvml", + "vl.vfmksnum.mvl" => "__builtin_ve_vl_vfmksnum_mvl", + "vl.vfmksnum.mvml" => "__builtin_ve_vl_vfmksnum_mvml", + "vl.vfmkweq.mvl" => "__builtin_ve_vl_vfmkweq_mvl", + "vl.vfmkweq.mvml" => "__builtin_ve_vl_vfmkweq_mvml", + "vl.vfmkweqnan.mvl" => "__builtin_ve_vl_vfmkweqnan_mvl", + "vl.vfmkweqnan.mvml" => "__builtin_ve_vl_vfmkweqnan_mvml", + "vl.vfmkwge.mvl" => "__builtin_ve_vl_vfmkwge_mvl", + "vl.vfmkwge.mvml" => "__builtin_ve_vl_vfmkwge_mvml", + "vl.vfmkwgenan.mvl" => "__builtin_ve_vl_vfmkwgenan_mvl", + "vl.vfmkwgenan.mvml" => "__builtin_ve_vl_vfmkwgenan_mvml", + "vl.vfmkwgt.mvl" => "__builtin_ve_vl_vfmkwgt_mvl", + "vl.vfmkwgt.mvml" => "__builtin_ve_vl_vfmkwgt_mvml", + "vl.vfmkwgtnan.mvl" => "__builtin_ve_vl_vfmkwgtnan_mvl", + "vl.vfmkwgtnan.mvml" => "__builtin_ve_vl_vfmkwgtnan_mvml", + "vl.vfmkwle.mvl" => "__builtin_ve_vl_vfmkwle_mvl", + "vl.vfmkwle.mvml" => "__builtin_ve_vl_vfmkwle_mvml", + "vl.vfmkwlenan.mvl" => "__builtin_ve_vl_vfmkwlenan_mvl", + "vl.vfmkwlenan.mvml" => "__builtin_ve_vl_vfmkwlenan_mvml", + "vl.vfmkwlt.mvl" => "__builtin_ve_vl_vfmkwlt_mvl", + "vl.vfmkwlt.mvml" => "__builtin_ve_vl_vfmkwlt_mvml", + "vl.vfmkwltnan.mvl" => "__builtin_ve_vl_vfmkwltnan_mvl", + "vl.vfmkwltnan.mvml" => "__builtin_ve_vl_vfmkwltnan_mvml", + "vl.vfmkwnan.mvl" => "__builtin_ve_vl_vfmkwnan_mvl", + "vl.vfmkwnan.mvml" => "__builtin_ve_vl_vfmkwnan_mvml", + "vl.vfmkwne.mvl" => "__builtin_ve_vl_vfmkwne_mvl", + "vl.vfmkwne.mvml" => "__builtin_ve_vl_vfmkwne_mvml", + "vl.vfmkwnenan.mvl" => "__builtin_ve_vl_vfmkwnenan_mvl", + "vl.vfmkwnenan.mvml" => "__builtin_ve_vl_vfmkwnenan_mvml", + "vl.vfmkwnum.mvl" => "__builtin_ve_vl_vfmkwnum_mvl", + "vl.vfmkwnum.mvml" => "__builtin_ve_vl_vfmkwnum_mvml", + "vl.vfmsbd.vsvvl" => "__builtin_ve_vl_vfmsbd_vsvvl", + "vl.vfmsbd.vsvvmvl" => "__builtin_ve_vl_vfmsbd_vsvvmvl", + "vl.vfmsbd.vsvvvl" => "__builtin_ve_vl_vfmsbd_vsvvvl", + "vl.vfmsbd.vvsvl" => "__builtin_ve_vl_vfmsbd_vvsvl", + "vl.vfmsbd.vvsvmvl" => "__builtin_ve_vl_vfmsbd_vvsvmvl", + "vl.vfmsbd.vvsvvl" => "__builtin_ve_vl_vfmsbd_vvsvvl", + "vl.vfmsbd.vvvvl" => "__builtin_ve_vl_vfmsbd_vvvvl", + "vl.vfmsbd.vvvvmvl" => "__builtin_ve_vl_vfmsbd_vvvvmvl", + "vl.vfmsbd.vvvvvl" => "__builtin_ve_vl_vfmsbd_vvvvvl", + "vl.vfmsbs.vsvvl" => "__builtin_ve_vl_vfmsbs_vsvvl", + "vl.vfmsbs.vsvvmvl" => "__builtin_ve_vl_vfmsbs_vsvvmvl", + "vl.vfmsbs.vsvvvl" => "__builtin_ve_vl_vfmsbs_vsvvvl", + "vl.vfmsbs.vvsvl" => "__builtin_ve_vl_vfmsbs_vvsvl", + "vl.vfmsbs.vvsvmvl" => "__builtin_ve_vl_vfmsbs_vvsvmvl", + "vl.vfmsbs.vvsvvl" => "__builtin_ve_vl_vfmsbs_vvsvvl", + "vl.vfmsbs.vvvvl" => "__builtin_ve_vl_vfmsbs_vvvvl", + "vl.vfmsbs.vvvvmvl" => "__builtin_ve_vl_vfmsbs_vvvvmvl", + "vl.vfmsbs.vvvvvl" => "__builtin_ve_vl_vfmsbs_vvvvvl", + "vl.vfmuld.vsvl" => "__builtin_ve_vl_vfmuld_vsvl", + "vl.vfmuld.vsvmvl" => "__builtin_ve_vl_vfmuld_vsvmvl", + "vl.vfmuld.vsvvl" => "__builtin_ve_vl_vfmuld_vsvvl", + "vl.vfmuld.vvvl" => "__builtin_ve_vl_vfmuld_vvvl", + "vl.vfmuld.vvvmvl" => "__builtin_ve_vl_vfmuld_vvvmvl", + "vl.vfmuld.vvvvl" => "__builtin_ve_vl_vfmuld_vvvvl", + "vl.vfmuls.vsvl" => "__builtin_ve_vl_vfmuls_vsvl", + "vl.vfmuls.vsvmvl" => "__builtin_ve_vl_vfmuls_vsvmvl", + "vl.vfmuls.vsvvl" => "__builtin_ve_vl_vfmuls_vsvvl", + "vl.vfmuls.vvvl" => "__builtin_ve_vl_vfmuls_vvvl", + "vl.vfmuls.vvvmvl" => "__builtin_ve_vl_vfmuls_vvvmvl", + "vl.vfmuls.vvvvl" => "__builtin_ve_vl_vfmuls_vvvvl", + "vl.vfnmadd.vsvvl" => "__builtin_ve_vl_vfnmadd_vsvvl", + "vl.vfnmadd.vsvvmvl" => "__builtin_ve_vl_vfnmadd_vsvvmvl", + "vl.vfnmadd.vsvvvl" => "__builtin_ve_vl_vfnmadd_vsvvvl", + "vl.vfnmadd.vvsvl" => "__builtin_ve_vl_vfnmadd_vvsvl", + "vl.vfnmadd.vvsvmvl" => "__builtin_ve_vl_vfnmadd_vvsvmvl", + "vl.vfnmadd.vvsvvl" => "__builtin_ve_vl_vfnmadd_vvsvvl", + "vl.vfnmadd.vvvvl" => "__builtin_ve_vl_vfnmadd_vvvvl", + "vl.vfnmadd.vvvvmvl" => "__builtin_ve_vl_vfnmadd_vvvvmvl", + "vl.vfnmadd.vvvvvl" => "__builtin_ve_vl_vfnmadd_vvvvvl", + "vl.vfnmads.vsvvl" => "__builtin_ve_vl_vfnmads_vsvvl", + "vl.vfnmads.vsvvmvl" => "__builtin_ve_vl_vfnmads_vsvvmvl", + "vl.vfnmads.vsvvvl" => "__builtin_ve_vl_vfnmads_vsvvvl", + "vl.vfnmads.vvsvl" => "__builtin_ve_vl_vfnmads_vvsvl", + "vl.vfnmads.vvsvmvl" => "__builtin_ve_vl_vfnmads_vvsvmvl", + "vl.vfnmads.vvsvvl" => "__builtin_ve_vl_vfnmads_vvsvvl", + "vl.vfnmads.vvvvl" => "__builtin_ve_vl_vfnmads_vvvvl", + "vl.vfnmads.vvvvmvl" => "__builtin_ve_vl_vfnmads_vvvvmvl", + "vl.vfnmads.vvvvvl" => "__builtin_ve_vl_vfnmads_vvvvvl", + "vl.vfnmsbd.vsvvl" => "__builtin_ve_vl_vfnmsbd_vsvvl", + "vl.vfnmsbd.vsvvmvl" => "__builtin_ve_vl_vfnmsbd_vsvvmvl", + "vl.vfnmsbd.vsvvvl" => "__builtin_ve_vl_vfnmsbd_vsvvvl", + "vl.vfnmsbd.vvsvl" => "__builtin_ve_vl_vfnmsbd_vvsvl", + "vl.vfnmsbd.vvsvmvl" => "__builtin_ve_vl_vfnmsbd_vvsvmvl", + "vl.vfnmsbd.vvsvvl" => "__builtin_ve_vl_vfnmsbd_vvsvvl", + "vl.vfnmsbd.vvvvl" => "__builtin_ve_vl_vfnmsbd_vvvvl", + "vl.vfnmsbd.vvvvmvl" => "__builtin_ve_vl_vfnmsbd_vvvvmvl", + "vl.vfnmsbd.vvvvvl" => "__builtin_ve_vl_vfnmsbd_vvvvvl", + "vl.vfnmsbs.vsvvl" => "__builtin_ve_vl_vfnmsbs_vsvvl", + "vl.vfnmsbs.vsvvmvl" => "__builtin_ve_vl_vfnmsbs_vsvvmvl", + "vl.vfnmsbs.vsvvvl" => "__builtin_ve_vl_vfnmsbs_vsvvvl", + "vl.vfnmsbs.vvsvl" => "__builtin_ve_vl_vfnmsbs_vvsvl", + "vl.vfnmsbs.vvsvmvl" => "__builtin_ve_vl_vfnmsbs_vvsvmvl", + "vl.vfnmsbs.vvsvvl" => "__builtin_ve_vl_vfnmsbs_vvsvvl", + "vl.vfnmsbs.vvvvl" => "__builtin_ve_vl_vfnmsbs_vvvvl", + "vl.vfnmsbs.vvvvmvl" => "__builtin_ve_vl_vfnmsbs_vvvvmvl", + "vl.vfnmsbs.vvvvvl" => "__builtin_ve_vl_vfnmsbs_vvvvvl", + "vl.vfrmaxdfst.vvl" => "__builtin_ve_vl_vfrmaxdfst_vvl", + "vl.vfrmaxdfst.vvvl" => "__builtin_ve_vl_vfrmaxdfst_vvvl", + "vl.vfrmaxdlst.vvl" => "__builtin_ve_vl_vfrmaxdlst_vvl", + "vl.vfrmaxdlst.vvvl" => "__builtin_ve_vl_vfrmaxdlst_vvvl", + "vl.vfrmaxsfst.vvl" => "__builtin_ve_vl_vfrmaxsfst_vvl", + "vl.vfrmaxsfst.vvvl" => "__builtin_ve_vl_vfrmaxsfst_vvvl", + "vl.vfrmaxslst.vvl" => "__builtin_ve_vl_vfrmaxslst_vvl", + "vl.vfrmaxslst.vvvl" => "__builtin_ve_vl_vfrmaxslst_vvvl", + "vl.vfrmindfst.vvl" => "__builtin_ve_vl_vfrmindfst_vvl", + "vl.vfrmindfst.vvvl" => "__builtin_ve_vl_vfrmindfst_vvvl", + "vl.vfrmindlst.vvl" => "__builtin_ve_vl_vfrmindlst_vvl", + "vl.vfrmindlst.vvvl" => "__builtin_ve_vl_vfrmindlst_vvvl", + "vl.vfrminsfst.vvl" => "__builtin_ve_vl_vfrminsfst_vvl", + "vl.vfrminsfst.vvvl" => "__builtin_ve_vl_vfrminsfst_vvvl", + "vl.vfrminslst.vvl" => "__builtin_ve_vl_vfrminslst_vvl", + "vl.vfrminslst.vvvl" => "__builtin_ve_vl_vfrminslst_vvvl", + "vl.vfsqrtd.vvl" => "__builtin_ve_vl_vfsqrtd_vvl", + "vl.vfsqrtd.vvvl" => "__builtin_ve_vl_vfsqrtd_vvvl", + "vl.vfsqrts.vvl" => "__builtin_ve_vl_vfsqrts_vvl", + "vl.vfsqrts.vvvl" => "__builtin_ve_vl_vfsqrts_vvvl", + "vl.vfsubd.vsvl" => "__builtin_ve_vl_vfsubd_vsvl", + "vl.vfsubd.vsvmvl" => "__builtin_ve_vl_vfsubd_vsvmvl", + "vl.vfsubd.vsvvl" => "__builtin_ve_vl_vfsubd_vsvvl", + "vl.vfsubd.vvvl" => "__builtin_ve_vl_vfsubd_vvvl", + "vl.vfsubd.vvvmvl" => "__builtin_ve_vl_vfsubd_vvvmvl", + "vl.vfsubd.vvvvl" => "__builtin_ve_vl_vfsubd_vvvvl", + "vl.vfsubs.vsvl" => "__builtin_ve_vl_vfsubs_vsvl", + "vl.vfsubs.vsvmvl" => "__builtin_ve_vl_vfsubs_vsvmvl", + "vl.vfsubs.vsvvl" => "__builtin_ve_vl_vfsubs_vsvvl", + "vl.vfsubs.vvvl" => "__builtin_ve_vl_vfsubs_vvvl", + "vl.vfsubs.vvvmvl" => "__builtin_ve_vl_vfsubs_vvvmvl", + "vl.vfsubs.vvvvl" => "__builtin_ve_vl_vfsubs_vvvvl", + "vl.vfsumd.vvl" => "__builtin_ve_vl_vfsumd_vvl", + "vl.vfsumd.vvml" => "__builtin_ve_vl_vfsumd_vvml", + "vl.vfsums.vvl" => "__builtin_ve_vl_vfsums_vvl", + "vl.vfsums.vvml" => "__builtin_ve_vl_vfsums_vvml", + "vl.vgt.vvssl" => "__builtin_ve_vl_vgt_vvssl", + "vl.vgt.vvssml" => "__builtin_ve_vl_vgt_vvssml", + "vl.vgt.vvssmvl" => "__builtin_ve_vl_vgt_vvssmvl", + "vl.vgt.vvssvl" => "__builtin_ve_vl_vgt_vvssvl", + "vl.vgtlsx.vvssl" => "__builtin_ve_vl_vgtlsx_vvssl", + "vl.vgtlsx.vvssml" => "__builtin_ve_vl_vgtlsx_vvssml", + "vl.vgtlsx.vvssmvl" => "__builtin_ve_vl_vgtlsx_vvssmvl", + "vl.vgtlsx.vvssvl" => "__builtin_ve_vl_vgtlsx_vvssvl", + "vl.vgtlsxnc.vvssl" => "__builtin_ve_vl_vgtlsxnc_vvssl", + "vl.vgtlsxnc.vvssml" => "__builtin_ve_vl_vgtlsxnc_vvssml", + "vl.vgtlsxnc.vvssmvl" => "__builtin_ve_vl_vgtlsxnc_vvssmvl", + "vl.vgtlsxnc.vvssvl" => "__builtin_ve_vl_vgtlsxnc_vvssvl", + "vl.vgtlzx.vvssl" => "__builtin_ve_vl_vgtlzx_vvssl", + "vl.vgtlzx.vvssml" => "__builtin_ve_vl_vgtlzx_vvssml", + "vl.vgtlzx.vvssmvl" => "__builtin_ve_vl_vgtlzx_vvssmvl", + "vl.vgtlzx.vvssvl" => "__builtin_ve_vl_vgtlzx_vvssvl", + "vl.vgtlzxnc.vvssl" => "__builtin_ve_vl_vgtlzxnc_vvssl", + "vl.vgtlzxnc.vvssml" => "__builtin_ve_vl_vgtlzxnc_vvssml", + "vl.vgtlzxnc.vvssmvl" => "__builtin_ve_vl_vgtlzxnc_vvssmvl", + "vl.vgtlzxnc.vvssvl" => "__builtin_ve_vl_vgtlzxnc_vvssvl", + "vl.vgtnc.vvssl" => "__builtin_ve_vl_vgtnc_vvssl", + "vl.vgtnc.vvssml" => "__builtin_ve_vl_vgtnc_vvssml", + "vl.vgtnc.vvssmvl" => "__builtin_ve_vl_vgtnc_vvssmvl", + "vl.vgtnc.vvssvl" => "__builtin_ve_vl_vgtnc_vvssvl", + "vl.vgtu.vvssl" => "__builtin_ve_vl_vgtu_vvssl", + "vl.vgtu.vvssml" => "__builtin_ve_vl_vgtu_vvssml", + "vl.vgtu.vvssmvl" => "__builtin_ve_vl_vgtu_vvssmvl", + "vl.vgtu.vvssvl" => "__builtin_ve_vl_vgtu_vvssvl", + "vl.vgtunc.vvssl" => "__builtin_ve_vl_vgtunc_vvssl", + "vl.vgtunc.vvssml" => "__builtin_ve_vl_vgtunc_vvssml", + "vl.vgtunc.vvssmvl" => "__builtin_ve_vl_vgtunc_vvssmvl", + "vl.vgtunc.vvssvl" => "__builtin_ve_vl_vgtunc_vvssvl", + "vl.vld.vssl" => "__builtin_ve_vl_vld_vssl", + "vl.vld.vssvl" => "__builtin_ve_vl_vld_vssvl", + "vl.vld2d.vssl" => "__builtin_ve_vl_vld2d_vssl", + "vl.vld2d.vssvl" => "__builtin_ve_vl_vld2d_vssvl", + "vl.vld2dnc.vssl" => "__builtin_ve_vl_vld2dnc_vssl", + "vl.vld2dnc.vssvl" => "__builtin_ve_vl_vld2dnc_vssvl", + "vl.vldl2dsx.vssl" => "__builtin_ve_vl_vldl2dsx_vssl", + "vl.vldl2dsx.vssvl" => "__builtin_ve_vl_vldl2dsx_vssvl", + "vl.vldl2dsxnc.vssl" => "__builtin_ve_vl_vldl2dsxnc_vssl", + "vl.vldl2dsxnc.vssvl" => "__builtin_ve_vl_vldl2dsxnc_vssvl", + "vl.vldl2dzx.vssl" => "__builtin_ve_vl_vldl2dzx_vssl", + "vl.vldl2dzx.vssvl" => "__builtin_ve_vl_vldl2dzx_vssvl", + "vl.vldl2dzxnc.vssl" => "__builtin_ve_vl_vldl2dzxnc_vssl", + "vl.vldl2dzxnc.vssvl" => "__builtin_ve_vl_vldl2dzxnc_vssvl", + "vl.vldlsx.vssl" => "__builtin_ve_vl_vldlsx_vssl", + "vl.vldlsx.vssvl" => "__builtin_ve_vl_vldlsx_vssvl", + "vl.vldlsxnc.vssl" => "__builtin_ve_vl_vldlsxnc_vssl", + "vl.vldlsxnc.vssvl" => "__builtin_ve_vl_vldlsxnc_vssvl", + "vl.vldlzx.vssl" => "__builtin_ve_vl_vldlzx_vssl", + "vl.vldlzx.vssvl" => "__builtin_ve_vl_vldlzx_vssvl", + "vl.vldlzxnc.vssl" => "__builtin_ve_vl_vldlzxnc_vssl", + "vl.vldlzxnc.vssvl" => "__builtin_ve_vl_vldlzxnc_vssvl", + "vl.vldnc.vssl" => "__builtin_ve_vl_vldnc_vssl", + "vl.vldnc.vssvl" => "__builtin_ve_vl_vldnc_vssvl", + "vl.vldu.vssl" => "__builtin_ve_vl_vldu_vssl", + "vl.vldu.vssvl" => "__builtin_ve_vl_vldu_vssvl", + "vl.vldu2d.vssl" => "__builtin_ve_vl_vldu2d_vssl", + "vl.vldu2d.vssvl" => "__builtin_ve_vl_vldu2d_vssvl", + "vl.vldu2dnc.vssl" => "__builtin_ve_vl_vldu2dnc_vssl", + "vl.vldu2dnc.vssvl" => "__builtin_ve_vl_vldu2dnc_vssvl", + "vl.vldunc.vssl" => "__builtin_ve_vl_vldunc_vssl", + "vl.vldunc.vssvl" => "__builtin_ve_vl_vldunc_vssvl", + "vl.vldz.vvl" => "__builtin_ve_vl_vldz_vvl", + "vl.vldz.vvmvl" => "__builtin_ve_vl_vldz_vvmvl", + "vl.vldz.vvvl" => "__builtin_ve_vl_vldz_vvvl", + "vl.vmaxsl.vsvl" => "__builtin_ve_vl_vmaxsl_vsvl", + "vl.vmaxsl.vsvmvl" => "__builtin_ve_vl_vmaxsl_vsvmvl", + "vl.vmaxsl.vsvvl" => "__builtin_ve_vl_vmaxsl_vsvvl", + "vl.vmaxsl.vvvl" => "__builtin_ve_vl_vmaxsl_vvvl", + "vl.vmaxsl.vvvmvl" => "__builtin_ve_vl_vmaxsl_vvvmvl", + "vl.vmaxsl.vvvvl" => "__builtin_ve_vl_vmaxsl_vvvvl", + "vl.vmaxswsx.vsvl" => "__builtin_ve_vl_vmaxswsx_vsvl", + "vl.vmaxswsx.vsvmvl" => "__builtin_ve_vl_vmaxswsx_vsvmvl", + "vl.vmaxswsx.vsvvl" => "__builtin_ve_vl_vmaxswsx_vsvvl", + "vl.vmaxswsx.vvvl" => "__builtin_ve_vl_vmaxswsx_vvvl", + "vl.vmaxswsx.vvvmvl" => "__builtin_ve_vl_vmaxswsx_vvvmvl", + "vl.vmaxswsx.vvvvl" => "__builtin_ve_vl_vmaxswsx_vvvvl", + "vl.vmaxswzx.vsvl" => "__builtin_ve_vl_vmaxswzx_vsvl", + "vl.vmaxswzx.vsvmvl" => "__builtin_ve_vl_vmaxswzx_vsvmvl", + "vl.vmaxswzx.vsvvl" => "__builtin_ve_vl_vmaxswzx_vsvvl", + "vl.vmaxswzx.vvvl" => "__builtin_ve_vl_vmaxswzx_vvvl", + "vl.vmaxswzx.vvvmvl" => "__builtin_ve_vl_vmaxswzx_vvvmvl", + "vl.vmaxswzx.vvvvl" => "__builtin_ve_vl_vmaxswzx_vvvvl", + "vl.vminsl.vsvl" => "__builtin_ve_vl_vminsl_vsvl", + "vl.vminsl.vsvmvl" => "__builtin_ve_vl_vminsl_vsvmvl", + "vl.vminsl.vsvvl" => "__builtin_ve_vl_vminsl_vsvvl", + "vl.vminsl.vvvl" => "__builtin_ve_vl_vminsl_vvvl", + "vl.vminsl.vvvmvl" => "__builtin_ve_vl_vminsl_vvvmvl", + "vl.vminsl.vvvvl" => "__builtin_ve_vl_vminsl_vvvvl", + "vl.vminswsx.vsvl" => "__builtin_ve_vl_vminswsx_vsvl", + "vl.vminswsx.vsvmvl" => "__builtin_ve_vl_vminswsx_vsvmvl", + "vl.vminswsx.vsvvl" => "__builtin_ve_vl_vminswsx_vsvvl", + "vl.vminswsx.vvvl" => "__builtin_ve_vl_vminswsx_vvvl", + "vl.vminswsx.vvvmvl" => "__builtin_ve_vl_vminswsx_vvvmvl", + "vl.vminswsx.vvvvl" => "__builtin_ve_vl_vminswsx_vvvvl", + "vl.vminswzx.vsvl" => "__builtin_ve_vl_vminswzx_vsvl", + "vl.vminswzx.vsvmvl" => "__builtin_ve_vl_vminswzx_vsvmvl", + "vl.vminswzx.vsvvl" => "__builtin_ve_vl_vminswzx_vsvvl", + "vl.vminswzx.vvvl" => "__builtin_ve_vl_vminswzx_vvvl", + "vl.vminswzx.vvvmvl" => "__builtin_ve_vl_vminswzx_vvvmvl", + "vl.vminswzx.vvvvl" => "__builtin_ve_vl_vminswzx_vvvvl", + "vl.vmrg.vsvml" => "__builtin_ve_vl_vmrg_vsvml", + "vl.vmrg.vsvmvl" => "__builtin_ve_vl_vmrg_vsvmvl", + "vl.vmrg.vvvml" => "__builtin_ve_vl_vmrg_vvvml", + "vl.vmrg.vvvmvl" => "__builtin_ve_vl_vmrg_vvvmvl", + "vl.vmrgw.vsvMl" => "__builtin_ve_vl_vmrgw_vsvMl", + "vl.vmrgw.vsvMvl" => "__builtin_ve_vl_vmrgw_vsvMvl", + "vl.vmrgw.vvvMl" => "__builtin_ve_vl_vmrgw_vvvMl", + "vl.vmrgw.vvvMvl" => "__builtin_ve_vl_vmrgw_vvvMvl", + "vl.vmulsl.vsvl" => "__builtin_ve_vl_vmulsl_vsvl", + "vl.vmulsl.vsvmvl" => "__builtin_ve_vl_vmulsl_vsvmvl", + "vl.vmulsl.vsvvl" => "__builtin_ve_vl_vmulsl_vsvvl", + "vl.vmulsl.vvvl" => "__builtin_ve_vl_vmulsl_vvvl", + "vl.vmulsl.vvvmvl" => "__builtin_ve_vl_vmulsl_vvvmvl", + "vl.vmulsl.vvvvl" => "__builtin_ve_vl_vmulsl_vvvvl", + "vl.vmulslw.vsvl" => "__builtin_ve_vl_vmulslw_vsvl", + "vl.vmulslw.vsvvl" => "__builtin_ve_vl_vmulslw_vsvvl", + "vl.vmulslw.vvvl" => "__builtin_ve_vl_vmulslw_vvvl", + "vl.vmulslw.vvvvl" => "__builtin_ve_vl_vmulslw_vvvvl", + "vl.vmulswsx.vsvl" => "__builtin_ve_vl_vmulswsx_vsvl", + "vl.vmulswsx.vsvmvl" => "__builtin_ve_vl_vmulswsx_vsvmvl", + "vl.vmulswsx.vsvvl" => "__builtin_ve_vl_vmulswsx_vsvvl", + "vl.vmulswsx.vvvl" => "__builtin_ve_vl_vmulswsx_vvvl", + "vl.vmulswsx.vvvmvl" => "__builtin_ve_vl_vmulswsx_vvvmvl", + "vl.vmulswsx.vvvvl" => "__builtin_ve_vl_vmulswsx_vvvvl", + "vl.vmulswzx.vsvl" => "__builtin_ve_vl_vmulswzx_vsvl", + "vl.vmulswzx.vsvmvl" => "__builtin_ve_vl_vmulswzx_vsvmvl", + "vl.vmulswzx.vsvvl" => "__builtin_ve_vl_vmulswzx_vsvvl", + "vl.vmulswzx.vvvl" => "__builtin_ve_vl_vmulswzx_vvvl", + "vl.vmulswzx.vvvmvl" => "__builtin_ve_vl_vmulswzx_vvvmvl", + "vl.vmulswzx.vvvvl" => "__builtin_ve_vl_vmulswzx_vvvvl", + "vl.vmulul.vsvl" => "__builtin_ve_vl_vmulul_vsvl", + "vl.vmulul.vsvmvl" => "__builtin_ve_vl_vmulul_vsvmvl", + "vl.vmulul.vsvvl" => "__builtin_ve_vl_vmulul_vsvvl", + "vl.vmulul.vvvl" => "__builtin_ve_vl_vmulul_vvvl", + "vl.vmulul.vvvmvl" => "__builtin_ve_vl_vmulul_vvvmvl", + "vl.vmulul.vvvvl" => "__builtin_ve_vl_vmulul_vvvvl", + "vl.vmuluw.vsvl" => "__builtin_ve_vl_vmuluw_vsvl", + "vl.vmuluw.vsvmvl" => "__builtin_ve_vl_vmuluw_vsvmvl", + "vl.vmuluw.vsvvl" => "__builtin_ve_vl_vmuluw_vsvvl", + "vl.vmuluw.vvvl" => "__builtin_ve_vl_vmuluw_vvvl", + "vl.vmuluw.vvvmvl" => "__builtin_ve_vl_vmuluw_vvvmvl", + "vl.vmuluw.vvvvl" => "__builtin_ve_vl_vmuluw_vvvvl", + "vl.vmv.vsvl" => "__builtin_ve_vl_vmv_vsvl", + "vl.vmv.vsvmvl" => "__builtin_ve_vl_vmv_vsvmvl", + "vl.vmv.vsvvl" => "__builtin_ve_vl_vmv_vsvvl", + "vl.vor.vsvl" => "__builtin_ve_vl_vor_vsvl", + "vl.vor.vsvmvl" => "__builtin_ve_vl_vor_vsvmvl", + "vl.vor.vsvvl" => "__builtin_ve_vl_vor_vsvvl", + "vl.vor.vvvl" => "__builtin_ve_vl_vor_vvvl", + "vl.vor.vvvmvl" => "__builtin_ve_vl_vor_vvvmvl", + "vl.vor.vvvvl" => "__builtin_ve_vl_vor_vvvvl", + "vl.vpcnt.vvl" => "__builtin_ve_vl_vpcnt_vvl", + "vl.vpcnt.vvmvl" => "__builtin_ve_vl_vpcnt_vvmvl", + "vl.vpcnt.vvvl" => "__builtin_ve_vl_vpcnt_vvvl", + "vl.vrand.vvl" => "__builtin_ve_vl_vrand_vvl", + "vl.vrand.vvml" => "__builtin_ve_vl_vrand_vvml", + "vl.vrcpd.vvl" => "__builtin_ve_vl_vrcpd_vvl", + "vl.vrcpd.vvvl" => "__builtin_ve_vl_vrcpd_vvvl", + "vl.vrcps.vvl" => "__builtin_ve_vl_vrcps_vvl", + "vl.vrcps.vvvl" => "__builtin_ve_vl_vrcps_vvvl", + "vl.vrmaxslfst.vvl" => "__builtin_ve_vl_vrmaxslfst_vvl", + "vl.vrmaxslfst.vvvl" => "__builtin_ve_vl_vrmaxslfst_vvvl", + "vl.vrmaxsllst.vvl" => "__builtin_ve_vl_vrmaxsllst_vvl", + "vl.vrmaxsllst.vvvl" => "__builtin_ve_vl_vrmaxsllst_vvvl", + "vl.vrmaxswfstsx.vvl" => "__builtin_ve_vl_vrmaxswfstsx_vvl", + "vl.vrmaxswfstsx.vvvl" => "__builtin_ve_vl_vrmaxswfstsx_vvvl", + "vl.vrmaxswfstzx.vvl" => "__builtin_ve_vl_vrmaxswfstzx_vvl", + "vl.vrmaxswfstzx.vvvl" => "__builtin_ve_vl_vrmaxswfstzx_vvvl", + "vl.vrmaxswlstsx.vvl" => "__builtin_ve_vl_vrmaxswlstsx_vvl", + "vl.vrmaxswlstsx.vvvl" => "__builtin_ve_vl_vrmaxswlstsx_vvvl", + "vl.vrmaxswlstzx.vvl" => "__builtin_ve_vl_vrmaxswlstzx_vvl", + "vl.vrmaxswlstzx.vvvl" => "__builtin_ve_vl_vrmaxswlstzx_vvvl", + "vl.vrminslfst.vvl" => "__builtin_ve_vl_vrminslfst_vvl", + "vl.vrminslfst.vvvl" => "__builtin_ve_vl_vrminslfst_vvvl", + "vl.vrminsllst.vvl" => "__builtin_ve_vl_vrminsllst_vvl", + "vl.vrminsllst.vvvl" => "__builtin_ve_vl_vrminsllst_vvvl", + "vl.vrminswfstsx.vvl" => "__builtin_ve_vl_vrminswfstsx_vvl", + "vl.vrminswfstsx.vvvl" => "__builtin_ve_vl_vrminswfstsx_vvvl", + "vl.vrminswfstzx.vvl" => "__builtin_ve_vl_vrminswfstzx_vvl", + "vl.vrminswfstzx.vvvl" => "__builtin_ve_vl_vrminswfstzx_vvvl", + "vl.vrminswlstsx.vvl" => "__builtin_ve_vl_vrminswlstsx_vvl", + "vl.vrminswlstsx.vvvl" => "__builtin_ve_vl_vrminswlstsx_vvvl", + "vl.vrminswlstzx.vvl" => "__builtin_ve_vl_vrminswlstzx_vvl", + "vl.vrminswlstzx.vvvl" => "__builtin_ve_vl_vrminswlstzx_vvvl", + "vl.vror.vvl" => "__builtin_ve_vl_vror_vvl", + "vl.vror.vvml" => "__builtin_ve_vl_vror_vvml", + "vl.vrsqrtd.vvl" => "__builtin_ve_vl_vrsqrtd_vvl", + "vl.vrsqrtd.vvvl" => "__builtin_ve_vl_vrsqrtd_vvvl", + "vl.vrsqrtdnex.vvl" => "__builtin_ve_vl_vrsqrtdnex_vvl", + "vl.vrsqrtdnex.vvvl" => "__builtin_ve_vl_vrsqrtdnex_vvvl", + "vl.vrsqrts.vvl" => "__builtin_ve_vl_vrsqrts_vvl", + "vl.vrsqrts.vvvl" => "__builtin_ve_vl_vrsqrts_vvvl", + "vl.vrsqrtsnex.vvl" => "__builtin_ve_vl_vrsqrtsnex_vvl", + "vl.vrsqrtsnex.vvvl" => "__builtin_ve_vl_vrsqrtsnex_vvvl", + "vl.vrxor.vvl" => "__builtin_ve_vl_vrxor_vvl", + "vl.vrxor.vvml" => "__builtin_ve_vl_vrxor_vvml", + "vl.vsc.vvssl" => "__builtin_ve_vl_vsc_vvssl", + "vl.vsc.vvssml" => "__builtin_ve_vl_vsc_vvssml", + "vl.vscl.vvssl" => "__builtin_ve_vl_vscl_vvssl", + "vl.vscl.vvssml" => "__builtin_ve_vl_vscl_vvssml", + "vl.vsclnc.vvssl" => "__builtin_ve_vl_vsclnc_vvssl", + "vl.vsclnc.vvssml" => "__builtin_ve_vl_vsclnc_vvssml", + "vl.vsclncot.vvssl" => "__builtin_ve_vl_vsclncot_vvssl", + "vl.vsclncot.vvssml" => "__builtin_ve_vl_vsclncot_vvssml", + "vl.vsclot.vvssl" => "__builtin_ve_vl_vsclot_vvssl", + "vl.vsclot.vvssml" => "__builtin_ve_vl_vsclot_vvssml", + "vl.vscnc.vvssl" => "__builtin_ve_vl_vscnc_vvssl", + "vl.vscnc.vvssml" => "__builtin_ve_vl_vscnc_vvssml", + "vl.vscncot.vvssl" => "__builtin_ve_vl_vscncot_vvssl", + "vl.vscncot.vvssml" => "__builtin_ve_vl_vscncot_vvssml", + "vl.vscot.vvssl" => "__builtin_ve_vl_vscot_vvssl", + "vl.vscot.vvssml" => "__builtin_ve_vl_vscot_vvssml", + "vl.vscu.vvssl" => "__builtin_ve_vl_vscu_vvssl", + "vl.vscu.vvssml" => "__builtin_ve_vl_vscu_vvssml", + "vl.vscunc.vvssl" => "__builtin_ve_vl_vscunc_vvssl", + "vl.vscunc.vvssml" => "__builtin_ve_vl_vscunc_vvssml", + "vl.vscuncot.vvssl" => "__builtin_ve_vl_vscuncot_vvssl", + "vl.vscuncot.vvssml" => "__builtin_ve_vl_vscuncot_vvssml", + "vl.vscuot.vvssl" => "__builtin_ve_vl_vscuot_vvssl", + "vl.vscuot.vvssml" => "__builtin_ve_vl_vscuot_vvssml", + "vl.vseq.vl" => "__builtin_ve_vl_vseq_vl", + "vl.vseq.vvl" => "__builtin_ve_vl_vseq_vvl", + "vl.vsfa.vvssl" => "__builtin_ve_vl_vsfa_vvssl", + "vl.vsfa.vvssmvl" => "__builtin_ve_vl_vsfa_vvssmvl", + "vl.vsfa.vvssvl" => "__builtin_ve_vl_vsfa_vvssvl", + "vl.vshf.vvvsl" => "__builtin_ve_vl_vshf_vvvsl", + "vl.vshf.vvvsvl" => "__builtin_ve_vl_vshf_vvvsvl", + "vl.vslal.vvsl" => "__builtin_ve_vl_vslal_vvsl", + "vl.vslal.vvsmvl" => "__builtin_ve_vl_vslal_vvsmvl", + "vl.vslal.vvsvl" => "__builtin_ve_vl_vslal_vvsvl", + "vl.vslal.vvvl" => "__builtin_ve_vl_vslal_vvvl", + "vl.vslal.vvvmvl" => "__builtin_ve_vl_vslal_vvvmvl", + "vl.vslal.vvvvl" => "__builtin_ve_vl_vslal_vvvvl", + "vl.vslawsx.vvsl" => "__builtin_ve_vl_vslawsx_vvsl", + "vl.vslawsx.vvsmvl" => "__builtin_ve_vl_vslawsx_vvsmvl", + "vl.vslawsx.vvsvl" => "__builtin_ve_vl_vslawsx_vvsvl", + "vl.vslawsx.vvvl" => "__builtin_ve_vl_vslawsx_vvvl", + "vl.vslawsx.vvvmvl" => "__builtin_ve_vl_vslawsx_vvvmvl", + "vl.vslawsx.vvvvl" => "__builtin_ve_vl_vslawsx_vvvvl", + "vl.vslawzx.vvsl" => "__builtin_ve_vl_vslawzx_vvsl", + "vl.vslawzx.vvsmvl" => "__builtin_ve_vl_vslawzx_vvsmvl", + "vl.vslawzx.vvsvl" => "__builtin_ve_vl_vslawzx_vvsvl", + "vl.vslawzx.vvvl" => "__builtin_ve_vl_vslawzx_vvvl", + "vl.vslawzx.vvvmvl" => "__builtin_ve_vl_vslawzx_vvvmvl", + "vl.vslawzx.vvvvl" => "__builtin_ve_vl_vslawzx_vvvvl", + "vl.vsll.vvsl" => "__builtin_ve_vl_vsll_vvsl", + "vl.vsll.vvsmvl" => "__builtin_ve_vl_vsll_vvsmvl", + "vl.vsll.vvsvl" => "__builtin_ve_vl_vsll_vvsvl", + "vl.vsll.vvvl" => "__builtin_ve_vl_vsll_vvvl", + "vl.vsll.vvvmvl" => "__builtin_ve_vl_vsll_vvvmvl", + "vl.vsll.vvvvl" => "__builtin_ve_vl_vsll_vvvvl", + "vl.vsral.vvsl" => "__builtin_ve_vl_vsral_vvsl", + "vl.vsral.vvsmvl" => "__builtin_ve_vl_vsral_vvsmvl", + "vl.vsral.vvsvl" => "__builtin_ve_vl_vsral_vvsvl", + "vl.vsral.vvvl" => "__builtin_ve_vl_vsral_vvvl", + "vl.vsral.vvvmvl" => "__builtin_ve_vl_vsral_vvvmvl", + "vl.vsral.vvvvl" => "__builtin_ve_vl_vsral_vvvvl", + "vl.vsrawsx.vvsl" => "__builtin_ve_vl_vsrawsx_vvsl", + "vl.vsrawsx.vvsmvl" => "__builtin_ve_vl_vsrawsx_vvsmvl", + "vl.vsrawsx.vvsvl" => "__builtin_ve_vl_vsrawsx_vvsvl", + "vl.vsrawsx.vvvl" => "__builtin_ve_vl_vsrawsx_vvvl", + "vl.vsrawsx.vvvmvl" => "__builtin_ve_vl_vsrawsx_vvvmvl", + "vl.vsrawsx.vvvvl" => "__builtin_ve_vl_vsrawsx_vvvvl", + "vl.vsrawzx.vvsl" => "__builtin_ve_vl_vsrawzx_vvsl", + "vl.vsrawzx.vvsmvl" => "__builtin_ve_vl_vsrawzx_vvsmvl", + "vl.vsrawzx.vvsvl" => "__builtin_ve_vl_vsrawzx_vvsvl", + "vl.vsrawzx.vvvl" => "__builtin_ve_vl_vsrawzx_vvvl", + "vl.vsrawzx.vvvmvl" => "__builtin_ve_vl_vsrawzx_vvvmvl", + "vl.vsrawzx.vvvvl" => "__builtin_ve_vl_vsrawzx_vvvvl", + "vl.vsrl.vvsl" => "__builtin_ve_vl_vsrl_vvsl", + "vl.vsrl.vvsmvl" => "__builtin_ve_vl_vsrl_vvsmvl", + "vl.vsrl.vvsvl" => "__builtin_ve_vl_vsrl_vvsvl", + "vl.vsrl.vvvl" => "__builtin_ve_vl_vsrl_vvvl", + "vl.vsrl.vvvmvl" => "__builtin_ve_vl_vsrl_vvvmvl", + "vl.vsrl.vvvvl" => "__builtin_ve_vl_vsrl_vvvvl", + "vl.vst.vssl" => "__builtin_ve_vl_vst_vssl", + "vl.vst.vssml" => "__builtin_ve_vl_vst_vssml", + "vl.vst2d.vssl" => "__builtin_ve_vl_vst2d_vssl", + "vl.vst2d.vssml" => "__builtin_ve_vl_vst2d_vssml", + "vl.vst2dnc.vssl" => "__builtin_ve_vl_vst2dnc_vssl", + "vl.vst2dnc.vssml" => "__builtin_ve_vl_vst2dnc_vssml", + "vl.vst2dncot.vssl" => "__builtin_ve_vl_vst2dncot_vssl", + "vl.vst2dncot.vssml" => "__builtin_ve_vl_vst2dncot_vssml", + "vl.vst2dot.vssl" => "__builtin_ve_vl_vst2dot_vssl", + "vl.vst2dot.vssml" => "__builtin_ve_vl_vst2dot_vssml", + "vl.vstl.vssl" => "__builtin_ve_vl_vstl_vssl", + "vl.vstl.vssml" => "__builtin_ve_vl_vstl_vssml", + "vl.vstl2d.vssl" => "__builtin_ve_vl_vstl2d_vssl", + "vl.vstl2d.vssml" => "__builtin_ve_vl_vstl2d_vssml", + "vl.vstl2dnc.vssl" => "__builtin_ve_vl_vstl2dnc_vssl", + "vl.vstl2dnc.vssml" => "__builtin_ve_vl_vstl2dnc_vssml", + "vl.vstl2dncot.vssl" => "__builtin_ve_vl_vstl2dncot_vssl", + "vl.vstl2dncot.vssml" => "__builtin_ve_vl_vstl2dncot_vssml", + "vl.vstl2dot.vssl" => "__builtin_ve_vl_vstl2dot_vssl", + "vl.vstl2dot.vssml" => "__builtin_ve_vl_vstl2dot_vssml", + "vl.vstlnc.vssl" => "__builtin_ve_vl_vstlnc_vssl", + "vl.vstlnc.vssml" => "__builtin_ve_vl_vstlnc_vssml", + "vl.vstlncot.vssl" => "__builtin_ve_vl_vstlncot_vssl", + "vl.vstlncot.vssml" => "__builtin_ve_vl_vstlncot_vssml", + "vl.vstlot.vssl" => "__builtin_ve_vl_vstlot_vssl", + "vl.vstlot.vssml" => "__builtin_ve_vl_vstlot_vssml", + "vl.vstnc.vssl" => "__builtin_ve_vl_vstnc_vssl", + "vl.vstnc.vssml" => "__builtin_ve_vl_vstnc_vssml", + "vl.vstncot.vssl" => "__builtin_ve_vl_vstncot_vssl", + "vl.vstncot.vssml" => "__builtin_ve_vl_vstncot_vssml", + "vl.vstot.vssl" => "__builtin_ve_vl_vstot_vssl", + "vl.vstot.vssml" => "__builtin_ve_vl_vstot_vssml", + "vl.vstu.vssl" => "__builtin_ve_vl_vstu_vssl", + "vl.vstu.vssml" => "__builtin_ve_vl_vstu_vssml", + "vl.vstu2d.vssl" => "__builtin_ve_vl_vstu2d_vssl", + "vl.vstu2d.vssml" => "__builtin_ve_vl_vstu2d_vssml", + "vl.vstu2dnc.vssl" => "__builtin_ve_vl_vstu2dnc_vssl", + "vl.vstu2dnc.vssml" => "__builtin_ve_vl_vstu2dnc_vssml", + "vl.vstu2dncot.vssl" => "__builtin_ve_vl_vstu2dncot_vssl", + "vl.vstu2dncot.vssml" => "__builtin_ve_vl_vstu2dncot_vssml", + "vl.vstu2dot.vssl" => "__builtin_ve_vl_vstu2dot_vssl", + "vl.vstu2dot.vssml" => "__builtin_ve_vl_vstu2dot_vssml", + "vl.vstunc.vssl" => "__builtin_ve_vl_vstunc_vssl", + "vl.vstunc.vssml" => "__builtin_ve_vl_vstunc_vssml", + "vl.vstuncot.vssl" => "__builtin_ve_vl_vstuncot_vssl", + "vl.vstuncot.vssml" => "__builtin_ve_vl_vstuncot_vssml", + "vl.vstuot.vssl" => "__builtin_ve_vl_vstuot_vssl", + "vl.vstuot.vssml" => "__builtin_ve_vl_vstuot_vssml", + "vl.vsubsl.vsvl" => "__builtin_ve_vl_vsubsl_vsvl", + "vl.vsubsl.vsvmvl" => "__builtin_ve_vl_vsubsl_vsvmvl", + "vl.vsubsl.vsvvl" => "__builtin_ve_vl_vsubsl_vsvvl", + "vl.vsubsl.vvvl" => "__builtin_ve_vl_vsubsl_vvvl", + "vl.vsubsl.vvvmvl" => "__builtin_ve_vl_vsubsl_vvvmvl", + "vl.vsubsl.vvvvl" => "__builtin_ve_vl_vsubsl_vvvvl", + "vl.vsubswsx.vsvl" => "__builtin_ve_vl_vsubswsx_vsvl", + "vl.vsubswsx.vsvmvl" => "__builtin_ve_vl_vsubswsx_vsvmvl", + "vl.vsubswsx.vsvvl" => "__builtin_ve_vl_vsubswsx_vsvvl", + "vl.vsubswsx.vvvl" => "__builtin_ve_vl_vsubswsx_vvvl", + "vl.vsubswsx.vvvmvl" => "__builtin_ve_vl_vsubswsx_vvvmvl", + "vl.vsubswsx.vvvvl" => "__builtin_ve_vl_vsubswsx_vvvvl", + "vl.vsubswzx.vsvl" => "__builtin_ve_vl_vsubswzx_vsvl", + "vl.vsubswzx.vsvmvl" => "__builtin_ve_vl_vsubswzx_vsvmvl", + "vl.vsubswzx.vsvvl" => "__builtin_ve_vl_vsubswzx_vsvvl", + "vl.vsubswzx.vvvl" => "__builtin_ve_vl_vsubswzx_vvvl", + "vl.vsubswzx.vvvmvl" => "__builtin_ve_vl_vsubswzx_vvvmvl", + "vl.vsubswzx.vvvvl" => "__builtin_ve_vl_vsubswzx_vvvvl", + "vl.vsubul.vsvl" => "__builtin_ve_vl_vsubul_vsvl", + "vl.vsubul.vsvmvl" => "__builtin_ve_vl_vsubul_vsvmvl", + "vl.vsubul.vsvvl" => "__builtin_ve_vl_vsubul_vsvvl", + "vl.vsubul.vvvl" => "__builtin_ve_vl_vsubul_vvvl", + "vl.vsubul.vvvmvl" => "__builtin_ve_vl_vsubul_vvvmvl", + "vl.vsubul.vvvvl" => "__builtin_ve_vl_vsubul_vvvvl", + "vl.vsubuw.vsvl" => "__builtin_ve_vl_vsubuw_vsvl", + "vl.vsubuw.vsvmvl" => "__builtin_ve_vl_vsubuw_vsvmvl", + "vl.vsubuw.vsvvl" => "__builtin_ve_vl_vsubuw_vsvvl", + "vl.vsubuw.vvvl" => "__builtin_ve_vl_vsubuw_vvvl", + "vl.vsubuw.vvvmvl" => "__builtin_ve_vl_vsubuw_vvvmvl", + "vl.vsubuw.vvvvl" => "__builtin_ve_vl_vsubuw_vvvvl", + "vl.vsuml.vvl" => "__builtin_ve_vl_vsuml_vvl", + "vl.vsuml.vvml" => "__builtin_ve_vl_vsuml_vvml", + "vl.vsumwsx.vvl" => "__builtin_ve_vl_vsumwsx_vvl", + "vl.vsumwsx.vvml" => "__builtin_ve_vl_vsumwsx_vvml", + "vl.vsumwzx.vvl" => "__builtin_ve_vl_vsumwzx_vvl", + "vl.vsumwzx.vvml" => "__builtin_ve_vl_vsumwzx_vvml", + "vl.vxor.vsvl" => "__builtin_ve_vl_vxor_vsvl", + "vl.vxor.vsvmvl" => "__builtin_ve_vl_vxor_vsvmvl", + "vl.vxor.vsvvl" => "__builtin_ve_vl_vxor_vsvvl", + "vl.vxor.vvvl" => "__builtin_ve_vl_vxor_vvvl", + "vl.vxor.vvvmvl" => "__builtin_ve_vl_vxor_vvvmvl", + "vl.vxor.vvvvl" => "__builtin_ve_vl_vxor_vvvvl", + "vl.xorm.MMM" => "__builtin_ve_vl_xorm_MMM", + "vl.xorm.mmm" => "__builtin_ve_vl_xorm_mmm", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + ve(name, full_name) + } + "x86" => { + #[allow(non_snake_case)] + fn x86(name: &str, full_name: &str) -> &'static str { + match name { + // x86 + "aadd32" => "__builtin_ia32_aadd32", + "aadd64" => "__builtin_ia32_aadd64", + "aand32" => "__builtin_ia32_aand32", + "aand64" => "__builtin_ia32_aand64", + "addcarry.u32" => "__builtin_ia32_addcarry_u32", + "addcarry.u64" => "__builtin_ia32_addcarry_u64", + "addcarryx.u32" => "__builtin_ia32_addcarryx_u32", + "addcarryx.u64" => "__builtin_ia32_addcarryx_u64", + "aesni.aesdec" => "__builtin_ia32_aesdec128", + "aesni.aesdec.256" => "__builtin_ia32_aesdec256", + "aesni.aesdec.512" => "__builtin_ia32_aesdec512", + "aesni.aesdeclast" => "__builtin_ia32_aesdeclast128", + "aesni.aesdeclast.256" => "__builtin_ia32_aesdeclast256", + "aesni.aesdeclast.512" => "__builtin_ia32_aesdeclast512", + "aesni.aesenc" => "__builtin_ia32_aesenc128", + "aesni.aesenc.256" => "__builtin_ia32_aesenc256", + "aesni.aesenc.512" => "__builtin_ia32_aesenc512", + "aesni.aesenclast" => "__builtin_ia32_aesenclast128", + "aesni.aesenclast.256" => "__builtin_ia32_aesenclast256", + "aesni.aesenclast.512" => "__builtin_ia32_aesenclast512", + "aesni.aesimc" => "__builtin_ia32_aesimc128", + "aesni.aeskeygenassist" => "__builtin_ia32_aeskeygenassist128", + "aor32" => "__builtin_ia32_aor32", + "aor64" => "__builtin_ia32_aor64", + "avx.addsub.pd.256" => "__builtin_ia32_addsubpd256", + "avx.addsub.ps.256" => "__builtin_ia32_addsubps256", + "avx.blend.pd.256" => "__builtin_ia32_blendpd256", + "avx.blend.ps.256" => "__builtin_ia32_blendps256", + "avx.blendv.pd.256" => "__builtin_ia32_blendvpd256", + "avx.blendv.ps.256" => "__builtin_ia32_blendvps256", + "avx.cmp.pd.256" => "__builtin_ia32_cmppd256", + "avx.cmp.ps.256" => "__builtin_ia32_cmpps256", + "avx.cvt.pd2.ps.256" => "__builtin_ia32_cvtpd2ps256", + "avx.cvt.pd2dq.256" => "__builtin_ia32_cvtpd2dq256", + "avx.cvt.ps2.pd.256" => "__builtin_ia32_cvtps2pd256", + "avx.cvt.ps2dq.256" => "__builtin_ia32_cvtps2dq256", + "avx.cvtdq2.pd.256" => "__builtin_ia32_cvtdq2pd256", + "avx.cvtdq2.ps.256" => "__builtin_ia32_cvtdq2ps256", + "avx.cvtt.pd2dq.256" => "__builtin_ia32_cvttpd2dq256", + "avx.cvtt.ps2dq.256" => "__builtin_ia32_cvttps2dq256", + "avx.dp.ps.256" => "__builtin_ia32_dpps256", + "avx.hadd.pd.256" => "__builtin_ia32_haddpd256", + "avx.hadd.ps.256" => "__builtin_ia32_haddps256", + "avx.hsub.pd.256" => "__builtin_ia32_hsubpd256", + "avx.hsub.ps.256" => "__builtin_ia32_hsubps256", + "avx.ldu.dq.256" => "__builtin_ia32_lddqu256", + "avx.maskload.pd" => "__builtin_ia32_maskloadpd", + "avx.maskload.pd.256" => "__builtin_ia32_maskloadpd256", + "avx.maskload.ps" => "__builtin_ia32_maskloadps", + "avx.maskload.ps.256" => "__builtin_ia32_maskloadps256", + "avx.maskstore.pd" => "__builtin_ia32_maskstorepd", + "avx.maskstore.pd.256" => "__builtin_ia32_maskstorepd256", + "avx.maskstore.ps" => "__builtin_ia32_maskstoreps", + "avx.maskstore.ps.256" => "__builtin_ia32_maskstoreps256", + "avx.max.pd.256" => "__builtin_ia32_maxpd256", + "avx.max.ps.256" => "__builtin_ia32_maxps256", + "avx.min.pd.256" => "__builtin_ia32_minpd256", + "avx.min.ps.256" => "__builtin_ia32_minps256", + "avx.movmsk.pd.256" => "__builtin_ia32_movmskpd256", + "avx.movmsk.ps.256" => "__builtin_ia32_movmskps256", + "avx.ptestc.256" => "__builtin_ia32_ptestc256", + "avx.ptestnzc.256" => "__builtin_ia32_ptestnzc256", + "avx.ptestz.256" => "__builtin_ia32_ptestz256", + "avx.rcp.ps.256" => "__builtin_ia32_rcpps256", + "avx.round.pd.256" => "__builtin_ia32_roundpd256", + "avx.round.ps.256" => "__builtin_ia32_roundps256", + "avx.rsqrt.ps.256" => "__builtin_ia32_rsqrtps256", + "avx.sqrt.pd.256" => "__builtin_ia32_sqrtpd256", + "avx.sqrt.ps.256" => "__builtin_ia32_sqrtps256", + "avx.storeu.dq.256" => "__builtin_ia32_storedqu256", + "avx.storeu.pd.256" => "__builtin_ia32_storeupd256", + "avx.storeu.ps.256" => "__builtin_ia32_storeups256", + "avx.vbroadcastf128.pd.256" => "__builtin_ia32_vbroadcastf128_pd256", + "avx.vbroadcastf128.ps.256" => "__builtin_ia32_vbroadcastf128_ps256", + "avx.vextractf128.pd.256" => "__builtin_ia32_vextractf128_pd256", + "avx.vextractf128.ps.256" => "__builtin_ia32_vextractf128_ps256", + "avx.vextractf128.si.256" => "__builtin_ia32_vextractf128_si256", + "avx.vinsertf128.pd.256" => "__builtin_ia32_vinsertf128_pd256", + "avx.vinsertf128.ps.256" => "__builtin_ia32_vinsertf128_ps256", + "avx.vinsertf128.si.256" => "__builtin_ia32_vinsertf128_si256", + "avx.vperm2f128.pd.256" => "__builtin_ia32_vperm2f128_pd256", + "avx.vperm2f128.ps.256" => "__builtin_ia32_vperm2f128_ps256", + "avx.vperm2f128.si.256" => "__builtin_ia32_vperm2f128_si256", + "avx.vpermilvar.pd" => "__builtin_ia32_vpermilvarpd", + "avx.vpermilvar.pd.256" => "__builtin_ia32_vpermilvarpd256", + "avx.vpermilvar.ps" => "__builtin_ia32_vpermilvarps", + "avx.vpermilvar.ps.256" => "__builtin_ia32_vpermilvarps256", + "avx.vtestc.pd" => "__builtin_ia32_vtestcpd", + "avx.vtestc.pd.256" => "__builtin_ia32_vtestcpd256", + "avx.vtestc.ps" => "__builtin_ia32_vtestcps", + "avx.vtestc.ps.256" => "__builtin_ia32_vtestcps256", + "avx.vtestnzc.pd" => "__builtin_ia32_vtestnzcpd", + "avx.vtestnzc.pd.256" => "__builtin_ia32_vtestnzcpd256", + "avx.vtestnzc.ps" => "__builtin_ia32_vtestnzcps", + "avx.vtestnzc.ps.256" => "__builtin_ia32_vtestnzcps256", + "avx.vtestz.pd" => "__builtin_ia32_vtestzpd", + "avx.vtestz.pd.256" => "__builtin_ia32_vtestzpd256", + "avx.vtestz.ps" => "__builtin_ia32_vtestzps", + "avx.vtestz.ps.256" => "__builtin_ia32_vtestzps256", + "avx.vzeroall" => "__builtin_ia32_vzeroall", + "avx.vzeroupper" => "__builtin_ia32_vzeroupper", + "avx10.mask.getexp.bf16.128" => "__builtin_ia32_vgetexpbf16128_mask", + "avx10.mask.getexp.bf16.256" => "__builtin_ia32_vgetexpbf16256_mask", + "avx10.mask.getexp.bf16.512" => "__builtin_ia32_vgetexpbf16512_mask", + "avx10.mask.getmant.bf16.128" => "__builtin_ia32_vgetmantbf16128_mask", + "avx10.mask.getmant.bf16.256" => "__builtin_ia32_vgetmantbf16256_mask", + "avx10.mask.getmant.bf16.512" => "__builtin_ia32_vgetmantbf16512_mask", + "avx10.mask.rcp.bf16.128" => "__builtin_ia32_vrcpbf16128_mask", + "avx10.mask.rcp.bf16.256" => "__builtin_ia32_vrcpbf16256_mask", + "avx10.mask.rcp.bf16.512" => "__builtin_ia32_vrcpbf16512_mask", + "avx10.mask.reduce.bf16.128" => "__builtin_ia32_vreducebf16128_mask", + "avx10.mask.reduce.bf16.256" => "__builtin_ia32_vreducebf16256_mask", + "avx10.mask.reduce.bf16.512" => "__builtin_ia32_vreducebf16512_mask", + "avx10.mask.rndscale.bf16.128" => "__builtin_ia32_vrndscalebf16_128_mask", + "avx10.mask.rndscale.bf16.256" => "__builtin_ia32_vrndscalebf16_256_mask", + "avx10.mask.rndscale.bf16.512" => "__builtin_ia32_vrndscalebf16_mask", + "avx10.mask.rsqrt.bf16.128" => "__builtin_ia32_vrsqrtbf16128_mask", + "avx10.mask.rsqrt.bf16.256" => "__builtin_ia32_vrsqrtbf16256_mask", + "avx10.mask.rsqrt.bf16.512" => "__builtin_ia32_vrsqrtbf16512_mask", + "avx10.mask.scalef.bf16.128" => "__builtin_ia32_vscalefbf16128_mask", + "avx10.mask.scalef.bf16.256" => "__builtin_ia32_vscalefbf16256_mask", + "avx10.mask.scalef.bf16.512" => "__builtin_ia32_vscalefbf16512_mask", + "avx10.mask.vcvt2ps2phx.128" => "__builtin_ia32_vcvt2ps2phx128_mask", + "avx10.mask.vcvt2ps2phx.256" => "__builtin_ia32_vcvt2ps2phx256_mask", + "avx10.mask.vcvt2ps2phx.512" => "__builtin_ia32_vcvt2ps2phx512_mask", + "avx10.mask.vcvtbiasph2bf8128" => "__builtin_ia32_vcvtbiasph2bf8_128_mask", + "avx10.mask.vcvtbiasph2bf8256" => "__builtin_ia32_vcvtbiasph2bf8_256_mask", + "avx10.mask.vcvtbiasph2bf8512" => "__builtin_ia32_vcvtbiasph2bf8_512_mask", + "avx10.mask.vcvtbiasph2bf8s128" => "__builtin_ia32_vcvtbiasph2bf8s_128_mask", + "avx10.mask.vcvtbiasph2bf8s256" => "__builtin_ia32_vcvtbiasph2bf8s_256_mask", + "avx10.mask.vcvtbiasph2bf8s512" => "__builtin_ia32_vcvtbiasph2bf8s_512_mask", + "avx10.mask.vcvtbiasph2hf8128" => "__builtin_ia32_vcvtbiasph2hf8_128_mask", + "avx10.mask.vcvtbiasph2hf8256" => "__builtin_ia32_vcvtbiasph2hf8_256_mask", + "avx10.mask.vcvtbiasph2hf8512" => "__builtin_ia32_vcvtbiasph2hf8_512_mask", + "avx10.mask.vcvtbiasph2hf8s128" => "__builtin_ia32_vcvtbiasph2hf8s_128_mask", + "avx10.mask.vcvtbiasph2hf8s256" => "__builtin_ia32_vcvtbiasph2hf8s_256_mask", + "avx10.mask.vcvtbiasph2hf8s512" => "__builtin_ia32_vcvtbiasph2hf8s_512_mask", + "avx10.mask.vcvthf82ph128" => "__builtin_ia32_vcvthf8_2ph128_mask", + "avx10.mask.vcvthf82ph256" => "__builtin_ia32_vcvthf8_2ph256_mask", + "avx10.mask.vcvthf82ph512" => "__builtin_ia32_vcvthf8_2ph512_mask", + "avx10.mask.vcvtph2bf8128" => "__builtin_ia32_vcvtph2bf8_128_mask", + "avx10.mask.vcvtph2bf8256" => "__builtin_ia32_vcvtph2bf8_256_mask", + "avx10.mask.vcvtph2bf8512" => "__builtin_ia32_vcvtph2bf8_512_mask", + "avx10.mask.vcvtph2bf8s128" => "__builtin_ia32_vcvtph2bf8s_128_mask", + "avx10.mask.vcvtph2bf8s256" => "__builtin_ia32_vcvtph2bf8s_256_mask", + "avx10.mask.vcvtph2bf8s512" => "__builtin_ia32_vcvtph2bf8s_512_mask", + "avx10.mask.vcvtph2hf8128" => "__builtin_ia32_vcvtph2hf8_128_mask", + "avx10.mask.vcvtph2hf8256" => "__builtin_ia32_vcvtph2hf8_256_mask", + "avx10.mask.vcvtph2hf8512" => "__builtin_ia32_vcvtph2hf8_512_mask", + "avx10.mask.vcvtph2hf8s128" => "__builtin_ia32_vcvtph2hf8s_128_mask", + "avx10.mask.vcvtph2hf8s256" => "__builtin_ia32_vcvtph2hf8s_256_mask", + "avx10.mask.vcvtph2hf8s512" => "__builtin_ia32_vcvtph2hf8s_512_mask", + "avx10.mask.vcvtph2ibs128" => "__builtin_ia32_vcvtph2ibs128_mask", + "avx10.mask.vcvtph2ibs256" => "__builtin_ia32_vcvtph2ibs256_mask", + "avx10.mask.vcvtph2ibs512" => "__builtin_ia32_vcvtph2ibs512_mask", + "avx10.mask.vcvtph2iubs128" => "__builtin_ia32_vcvtph2iubs128_mask", + "avx10.mask.vcvtph2iubs256" => "__builtin_ia32_vcvtph2iubs256_mask", + "avx10.mask.vcvtph2iubs512" => "__builtin_ia32_vcvtph2iubs512_mask", + "avx10.mask.vcvtps2ibs128" => "__builtin_ia32_vcvtps2ibs128_mask", + "avx10.mask.vcvtps2ibs256" => "__builtin_ia32_vcvtps2ibs256_mask", + "avx10.mask.vcvtps2ibs512" => "__builtin_ia32_vcvtps2ibs512_mask", + "avx10.mask.vcvtps2iubs128" => "__builtin_ia32_vcvtps2iubs128_mask", + "avx10.mask.vcvtps2iubs256" => "__builtin_ia32_vcvtps2iubs256_mask", + "avx10.mask.vcvtps2iubs512" => "__builtin_ia32_vcvtps2iubs512_mask", + "avx10.mask.vcvttpd2dqs.128" => "__builtin_ia32_vcvttpd2dqs128_mask", + "avx10.mask.vcvttpd2dqs.256" => "__builtin_ia32_vcvttpd2dqs256_mask", + // [INVALID CONVERSION]: "avx10.mask.vcvttpd2dqs.round.512" => "__builtin_ia32_vcvttpd2dqs512_round_mask", + "avx10.mask.vcvttpd2qqs.128" => "__builtin_ia32_vcvttpd2qqs128_mask", + "avx10.mask.vcvttpd2qqs.256" => "__builtin_ia32_vcvttpd2qqs256_mask", + // [INVALID CONVERSION]: "avx10.mask.vcvttpd2qqs.round.512" => "__builtin_ia32_vcvttpd2qqs512_round_mask", + "avx10.mask.vcvttpd2udqs.128" => "__builtin_ia32_vcvttpd2udqs128_mask", + "avx10.mask.vcvttpd2udqs.256" => "__builtin_ia32_vcvttpd2udqs256_mask", + // [INVALID CONVERSION]: "avx10.mask.vcvttpd2udqs.round.512" => "__builtin_ia32_vcvttpd2udqs512_round_mask", + "avx10.mask.vcvttpd2uqqs.128" => "__builtin_ia32_vcvttpd2uqqs128_mask", + "avx10.mask.vcvttpd2uqqs.256" => "__builtin_ia32_vcvttpd2uqqs256_mask", + // [INVALID CONVERSION]: "avx10.mask.vcvttpd2uqqs.round.512" => "__builtin_ia32_vcvttpd2uqqs512_round_mask", + "avx10.mask.vcvttph2ibs128" => "__builtin_ia32_vcvttph2ibs128_mask", + "avx10.mask.vcvttph2ibs256" => "__builtin_ia32_vcvttph2ibs256_mask", + "avx10.mask.vcvttph2ibs512" => "__builtin_ia32_vcvttph2ibs512_mask", + "avx10.mask.vcvttph2iubs128" => "__builtin_ia32_vcvttph2iubs128_mask", + "avx10.mask.vcvttph2iubs256" => "__builtin_ia32_vcvttph2iubs256_mask", + "avx10.mask.vcvttph2iubs512" => "__builtin_ia32_vcvttph2iubs512_mask", + "avx10.mask.vcvttps2dqs.128" => "__builtin_ia32_vcvttps2dqs128_mask", + "avx10.mask.vcvttps2dqs.256" => "__builtin_ia32_vcvttps2dqs256_mask", + // [INVALID CONVERSION]: "avx10.mask.vcvttps2dqs.round.512" => "__builtin_ia32_vcvttps2dqs512_round_mask", + "avx10.mask.vcvttps2ibs128" => "__builtin_ia32_vcvttps2ibs128_mask", + "avx10.mask.vcvttps2ibs256" => "__builtin_ia32_vcvttps2ibs256_mask", + "avx10.mask.vcvttps2ibs512" => "__builtin_ia32_vcvttps2ibs512_mask", + "avx10.mask.vcvttps2iubs128" => "__builtin_ia32_vcvttps2iubs128_mask", + "avx10.mask.vcvttps2iubs256" => "__builtin_ia32_vcvttps2iubs256_mask", + "avx10.mask.vcvttps2iubs512" => "__builtin_ia32_vcvttps2iubs512_mask", + "avx10.mask.vcvttps2qqs.128" => "__builtin_ia32_vcvttps2qqs128_mask", + "avx10.mask.vcvttps2qqs.256" => "__builtin_ia32_vcvttps2qqs256_mask", + // [INVALID CONVERSION]: "avx10.mask.vcvttps2qqs.round.512" => "__builtin_ia32_vcvttps2qqs512_round_mask", + "avx10.mask.vcvttps2udqs.128" => "__builtin_ia32_vcvttps2udqs128_mask", + "avx10.mask.vcvttps2udqs.256" => "__builtin_ia32_vcvttps2udqs256_mask", + // [INVALID CONVERSION]: "avx10.mask.vcvttps2udqs.round.512" => "__builtin_ia32_vcvttps2udqs512_round_mask", + "avx10.mask.vcvttps2uqqs.128" => "__builtin_ia32_vcvttps2uqqs128_mask", + "avx10.mask.vcvttps2uqqs.256" => "__builtin_ia32_vcvttps2uqqs256_mask", + // [INVALID CONVERSION]: "avx10.mask.vcvttps2uqqs.round.512" => "__builtin_ia32_vcvttps2uqqs512_round_mask", + // [INVALID CONVERSION]: "avx10.mask.vminmaxpd.round" => "__builtin_ia32_vminmaxpd512_round_mask", + "avx10.mask.vminmaxpd128" => "__builtin_ia32_vminmaxpd128_mask", + "avx10.mask.vminmaxpd256" => "__builtin_ia32_vminmaxpd256_mask", + // [INVALID CONVERSION]: "avx10.mask.vminmaxph.round" => "__builtin_ia32_vminmaxph512_round_mask", + "avx10.mask.vminmaxph128" => "__builtin_ia32_vminmaxph128_mask", + "avx10.mask.vminmaxph256" => "__builtin_ia32_vminmaxph256_mask", + // [INVALID CONVERSION]: "avx10.mask.vminmaxps.round" => "__builtin_ia32_vminmaxps512_round_mask", + "avx10.mask.vminmaxps128" => "__builtin_ia32_vminmaxps128_mask", + "avx10.mask.vminmaxps256" => "__builtin_ia32_vminmaxps256_mask", + // [INVALID CONVERSION]: "avx10.mask.vminmaxsd.round" => "__builtin_ia32_vminmaxsd_round_mask", + // [INVALID CONVERSION]: "avx10.mask.vminmaxsh.round" => "__builtin_ia32_vminmaxsh_round_mask", + // [INVALID CONVERSION]: "avx10.mask.vminmaxss.round" => "__builtin_ia32_vminmaxss_round_mask", + "avx10.vaddbf16128" => "__builtin_ia32_vaddbf16128", + "avx10.vaddbf16256" => "__builtin_ia32_vaddbf16256", + "avx10.vaddbf16512" => "__builtin_ia32_vaddbf16512", + "avx10.vaddpd256" => "__builtin_ia32_vaddpd256_round", + "avx10.vaddph256" => "__builtin_ia32_vaddph256_round", + "avx10.vaddps256" => "__builtin_ia32_vaddps256_round", + "avx10.vcomisbf16eq" => "__builtin_ia32_vcomisbf16eq", + "avx10.vcomisbf16ge" => "__builtin_ia32_vcomisbf16ge", + "avx10.vcomisbf16gt" => "__builtin_ia32_vcomisbf16gt", + "avx10.vcomisbf16le" => "__builtin_ia32_vcomisbf16le", + "avx10.vcomisbf16lt" => "__builtin_ia32_vcomisbf16lt", + "avx10.vcomisbf16neq" => "__builtin_ia32_vcomisbf16neq", + "avx10.vcvt2ph2bf8128" => "__builtin_ia32_vcvt2ph2bf8_128", + "avx10.vcvt2ph2bf8256" => "__builtin_ia32_vcvt2ph2bf8_256", + "avx10.vcvt2ph2bf8512" => "__builtin_ia32_vcvt2ph2bf8_512", + "avx10.vcvt2ph2bf8s128" => "__builtin_ia32_vcvt2ph2bf8s_128", + "avx10.vcvt2ph2bf8s256" => "__builtin_ia32_vcvt2ph2bf8s_256", + "avx10.vcvt2ph2bf8s512" => "__builtin_ia32_vcvt2ph2bf8s_512", + "avx10.vcvt2ph2hf8128" => "__builtin_ia32_vcvt2ph2hf8_128", + "avx10.vcvt2ph2hf8256" => "__builtin_ia32_vcvt2ph2hf8_256", + "avx10.vcvt2ph2hf8512" => "__builtin_ia32_vcvt2ph2hf8_512", + "avx10.vcvt2ph2hf8s128" => "__builtin_ia32_vcvt2ph2hf8s_128", + "avx10.vcvt2ph2hf8s256" => "__builtin_ia32_vcvt2ph2hf8s_256", + "avx10.vcvt2ph2hf8s512" => "__builtin_ia32_vcvt2ph2hf8s_512", + "avx10.vcvtbf162ibs128" => "__builtin_ia32_vcvtbf162ibs128", + "avx10.vcvtbf162ibs256" => "__builtin_ia32_vcvtbf162ibs256", + "avx10.vcvtbf162ibs512" => "__builtin_ia32_vcvtbf162ibs512", + "avx10.vcvtbf162iubs128" => "__builtin_ia32_vcvtbf162iubs128", + "avx10.vcvtbf162iubs256" => "__builtin_ia32_vcvtbf162iubs256", + "avx10.vcvtbf162iubs512" => "__builtin_ia32_vcvtbf162iubs512", + "avx10.vcvttbf162ibs128" => "__builtin_ia32_vcvttbf162ibs128", + "avx10.vcvttbf162ibs256" => "__builtin_ia32_vcvttbf162ibs256", + "avx10.vcvttbf162ibs512" => "__builtin_ia32_vcvttbf162ibs512", + "avx10.vcvttbf162iubs128" => "__builtin_ia32_vcvttbf162iubs128", + "avx10.vcvttbf162iubs256" => "__builtin_ia32_vcvttbf162iubs256", + "avx10.vcvttbf162iubs512" => "__builtin_ia32_vcvttbf162iubs512", + "avx10.vcvttsd2sis" => "__builtin_ia32_vcvttsd2sis32", + "avx10.vcvttsd2sis64" => "__builtin_ia32_vcvttsd2sis64", + "avx10.vcvttsd2usis" => "__builtin_ia32_vcvttsd2usis32", + "avx10.vcvttsd2usis64" => "__builtin_ia32_vcvttsd2usis64", + "avx10.vcvttss2sis" => "__builtin_ia32_vcvttss2sis32", + "avx10.vcvttss2sis64" => "__builtin_ia32_vcvttss2sis64", + "avx10.vcvttss2usis" => "__builtin_ia32_vcvttss2usis32", + "avx10.vcvttss2usis64" => "__builtin_ia32_vcvttss2usis64", + "avx10.vdivbf16128" => "__builtin_ia32_vdivbf16128", + "avx10.vdivbf16256" => "__builtin_ia32_vdivbf16256", + "avx10.vdivbf16512" => "__builtin_ia32_vdivbf16512", + "avx10.vdpphps.128" => "__builtin_ia32_vdpphps128", + "avx10.vdpphps.256" => "__builtin_ia32_vdpphps256", + "avx10.vdpphps.512" => "__builtin_ia32_vdpphps512", + "avx10.vfmadd132bf16128" => "__builtin_ia32_vfmadd132bf16128", + "avx10.vfmadd132bf16256" => "__builtin_ia32_vfmadd132bf16256", + "avx10.vfmadd132bf16512" => "__builtin_ia32_vfmadd132bf16512", + "avx10.vfmadd213bf16128" => "__builtin_ia32_vfmadd213bf16128", + "avx10.vfmadd213bf16256" => "__builtin_ia32_vfmadd213bf16256", + "avx10.vfmadd231bf16128" => "__builtin_ia32_vfmadd231bf16128", + "avx10.vfmadd231bf16256" => "__builtin_ia32_vfmadd231bf16256", + "avx10.vfmadd231bf16512" => "__builtin_ia32_vfmadd231bf16512", + "avx10.vfmsub132bf16128" => "__builtin_ia32_vfmsub132bf16128", + "avx10.vfmsub132bf16256" => "__builtin_ia32_vfmsub132bf16256", + "avx10.vfmsub132bf16512" => "__builtin_ia32_vfmsub132bf16512", + "avx10.vfmsub213bf16128" => "__builtin_ia32_vfmsub213bf16128", + "avx10.vfmsub213bf16256" => "__builtin_ia32_vfmsub213bf16256", + "avx10.vfmsub213bf16512" => "__builtin_ia32_vfmsub213bf16512", + "avx10.vfmsub231bf16128" => "__builtin_ia32_vfmsub231bf16128", + "avx10.vfmsub231bf16256" => "__builtin_ia32_vfmsub231bf16256", + "avx10.vfmsub231bf16512" => "__builtin_ia32_vfmsub231bf16512", + "avx10.vfnmadd132bf16128" => "__builtin_ia32_vfnmadd132bf16128", + "avx10.vfnmadd132bf16256" => "__builtin_ia32_vfnmadd132bf16256", + "avx10.vfnmadd132bf16512" => "__builtin_ia32_vfnmadd132bf16512", + "avx10.vfnmadd213bf16128" => "__builtin_ia32_vfnmadd213bf16128", + "avx10.vfnmadd213bf16256" => "__builtin_ia32_vfnmadd213bf16256", + "avx10.vfnmadd213bf16512" => "__builtin_ia32_vfnmadd213bf16512", + "avx10.vfnmadd231bf16128" => "__builtin_ia32_vfnmadd231bf16128", + "avx10.vfnmadd231bf16256" => "__builtin_ia32_vfnmadd231bf16256", + "avx10.vfnmadd231bf16512" => "__builtin_ia32_vfnmadd231bf16512", + "avx10.vfnmsub132bf16128" => "__builtin_ia32_vfnmsub132bf16128", + "avx10.vfnmsub132bf16256" => "__builtin_ia32_vfnmsub132bf16256", + "avx10.vfnmsub132bf16512" => "__builtin_ia32_vfnmsub132bf16512", + "avx10.vfnmsub213bf16128" => "__builtin_ia32_vfnmsub213bf16128", + "avx10.vfnmsub213bf16256" => "__builtin_ia32_vfnmsub213bf16256", + "avx10.vfnmsub213bf16512" => "__builtin_ia32_vfnmsub213bf16512", + "avx10.vfnmsub231bf16128" => "__builtin_ia32_vfnmsub231bf16128", + "avx10.vfnmsub231bf16256" => "__builtin_ia32_vfnmsub231bf16256", + "avx10.vfnmsub231bf16512" => "__builtin_ia32_vfnmsub231bf16512", + "avx10.vmaxbf16128" => "__builtin_ia32_vmaxbf16128", + "avx10.vmaxbf16256" => "__builtin_ia32_vmaxbf16256", + "avx10.vmaxbf16512" => "__builtin_ia32_vmaxbf16512", + "avx10.vminbf16128" => "__builtin_ia32_vminbf16128", + "avx10.vminbf16256" => "__builtin_ia32_vminbf16256", + "avx10.vminbf16512" => "__builtin_ia32_vminbf16512", + "avx10.vminmaxbf16128" => "__builtin_ia32_vminmaxbf16128", + "avx10.vminmaxbf16256" => "__builtin_ia32_vminmaxbf16256", + "avx10.vminmaxbf16512" => "__builtin_ia32_vminmaxbf16512", + "avx10.vminmaxpd128" => "__builtin_ia32_vminmaxpd128", + "avx10.vminmaxpd256" => "__builtin_ia32_vminmaxpd256", + "avx10.vminmaxph128" => "__builtin_ia32_vminmaxph128", + "avx10.vminmaxph256" => "__builtin_ia32_vminmaxph256", + "avx10.vminmaxps128" => "__builtin_ia32_vminmaxps128", + "avx10.vminmaxps256" => "__builtin_ia32_vminmaxps256", + "avx10.vmovrsb128" => "__builtin_ia32_vmovrsb128", + "avx10.vmovrsb256" => "__builtin_ia32_vmovrsb256", + "avx10.vmovrsb512" => "__builtin_ia32_vmovrsb512", + "avx10.vmovrsd128" => "__builtin_ia32_vmovrsd128", + "avx10.vmovrsd256" => "__builtin_ia32_vmovrsd256", + "avx10.vmovrsd512" => "__builtin_ia32_vmovrsd512", + "avx10.vmovrsq128" => "__builtin_ia32_vmovrsq128", + "avx10.vmovrsq256" => "__builtin_ia32_vmovrsq256", + "avx10.vmovrsq512" => "__builtin_ia32_vmovrsq512", + "avx10.vmovrsw128" => "__builtin_ia32_vmovrsw128", + "avx10.vmovrsw256" => "__builtin_ia32_vmovrsw256", + "avx10.vmovrsw512" => "__builtin_ia32_vmovrsw512", + "avx10.vmpsadbw.512" => "__builtin_ia32_mpsadbw512", + "avx10.vmulbf16128" => "__builtin_ia32_vmulbf16128", + "avx10.vmulbf16256" => "__builtin_ia32_vmulbf16256", + "avx10.vmulbf16512" => "__builtin_ia32_vmulbf16512", + "avx10.vpdpbssd.512" => "__builtin_ia32_vpdpbssd512", + "avx10.vpdpbssds.512" => "__builtin_ia32_vpdpbssds512", + "avx10.vpdpbsud.512" => "__builtin_ia32_vpdpbsud512", + "avx10.vpdpbsuds.512" => "__builtin_ia32_vpdpbsuds512", + "avx10.vpdpbuud.512" => "__builtin_ia32_vpdpbuud512", + "avx10.vpdpbuuds.512" => "__builtin_ia32_vpdpbuuds512", + "avx10.vpdpwsud.512" => "__builtin_ia32_vpdpwsud512", + "avx10.vpdpwsuds.512" => "__builtin_ia32_vpdpwsuds512", + "avx10.vpdpwusd.512" => "__builtin_ia32_vpdpwusd512", + "avx10.vpdpwusds.512" => "__builtin_ia32_vpdpwusds512", + "avx10.vpdpwuud.512" => "__builtin_ia32_vpdpwuud512", + "avx10.vpdpwuuds.512" => "__builtin_ia32_vpdpwuuds512", + "avx10.vsubbf16128" => "__builtin_ia32_vsubbf16128", + "avx10.vsubbf16256" => "__builtin_ia32_vsubbf16256", + "avx10.vsubbf16512" => "__builtin_ia32_vsubbf16512", + "avx2.gather.d.d" => "__builtin_ia32_gatherd_d", + "avx2.gather.d.d.256" => "__builtin_ia32_gatherd_d256", + "avx2.gather.d.pd" => "__builtin_ia32_gatherd_pd", + "avx2.gather.d.pd.256" => "__builtin_ia32_gatherd_pd256", + "avx2.gather.d.ps" => "__builtin_ia32_gatherd_ps", + "avx2.gather.d.ps.256" => "__builtin_ia32_gatherd_ps256", + "avx2.gather.d.q" => "__builtin_ia32_gatherd_q", + "avx2.gather.d.q.256" => "__builtin_ia32_gatherd_q256", + "avx2.gather.q.d" => "__builtin_ia32_gatherq_d", + "avx2.gather.q.d.256" => "__builtin_ia32_gatherq_d256", + "avx2.gather.q.pd" => "__builtin_ia32_gatherq_pd", + "avx2.gather.q.pd.256" => "__builtin_ia32_gatherq_pd256", + "avx2.gather.q.ps" => "__builtin_ia32_gatherq_ps", + "avx2.gather.q.ps.256" => "__builtin_ia32_gatherq_ps256", + "avx2.gather.q.q" => "__builtin_ia32_gatherq_q", + "avx2.gather.q.q.256" => "__builtin_ia32_gatherq_q256", + "avx2.maskload.d" => "__builtin_ia32_maskloadd", + "avx2.maskload.d.256" => "__builtin_ia32_maskloadd256", + "avx2.maskload.q" => "__builtin_ia32_maskloadq", + "avx2.maskload.q.256" => "__builtin_ia32_maskloadq256", + "avx2.maskstore.d" => "__builtin_ia32_maskstored", + "avx2.maskstore.d.256" => "__builtin_ia32_maskstored256", + "avx2.maskstore.q" => "__builtin_ia32_maskstoreq", + "avx2.maskstore.q.256" => "__builtin_ia32_maskstoreq256", + "avx2.movntdqa" => "__builtin_ia32_movntdqa256", + "avx2.mpsadbw" => "__builtin_ia32_mpsadbw256", + "avx2.pabs.b" => "__builtin_ia32_pabsb256", + "avx2.pabs.d" => "__builtin_ia32_pabsd256", + "avx2.pabs.w" => "__builtin_ia32_pabsw256", + "avx2.packssdw" => "__builtin_ia32_packssdw256", + "avx2.packsswb" => "__builtin_ia32_packsswb256", + "avx2.packusdw" => "__builtin_ia32_packusdw256", + "avx2.packuswb" => "__builtin_ia32_packuswb256", + "avx2.padds.b" => "__builtin_ia32_paddsb256", + "avx2.padds.w" => "__builtin_ia32_paddsw256", + "avx2.paddus.b" => "__builtin_ia32_paddusb256", + "avx2.paddus.w" => "__builtin_ia32_paddusw256", + "avx2.pavg.b" => "__builtin_ia32_pavgb256", + "avx2.pavg.w" => "__builtin_ia32_pavgw256", + "avx2.pblendd.128" => "__builtin_ia32_pblendd128", + "avx2.pblendd.256" => "__builtin_ia32_pblendd256", + "avx2.pblendvb" => "__builtin_ia32_pblendvb256", + "avx2.pblendw" => "__builtin_ia32_pblendw256", + "avx2.pbroadcastb.128" => "__builtin_ia32_pbroadcastb128", + "avx2.pbroadcastb.256" => "__builtin_ia32_pbroadcastb256", + "avx2.pbroadcastd.128" => "__builtin_ia32_pbroadcastd128", + "avx2.pbroadcastd.256" => "__builtin_ia32_pbroadcastd256", + "avx2.pbroadcastq.128" => "__builtin_ia32_pbroadcastq128", + "avx2.pbroadcastq.256" => "__builtin_ia32_pbroadcastq256", + "avx2.pbroadcastw.128" => "__builtin_ia32_pbroadcastw128", + "avx2.pbroadcastw.256" => "__builtin_ia32_pbroadcastw256", + "avx2.permd" => "__builtin_ia32_permvarsi256", + "avx2.permps" => "__builtin_ia32_permvarsf256", + "avx2.phadd.d" => "__builtin_ia32_phaddd256", + "avx2.phadd.sw" => "__builtin_ia32_phaddsw256", + "avx2.phadd.w" => "__builtin_ia32_phaddw256", + "avx2.phsub.d" => "__builtin_ia32_phsubd256", + "avx2.phsub.sw" => "__builtin_ia32_phsubsw256", + "avx2.phsub.w" => "__builtin_ia32_phsubw256", + "avx2.pmadd.ub.sw" => "__builtin_ia32_pmaddubsw256", + "avx2.pmadd.wd" => "__builtin_ia32_pmaddwd256", + "avx2.pmaxs.b" => "__builtin_ia32_pmaxsb256", + "avx2.pmaxs.d" => "__builtin_ia32_pmaxsd256", + "avx2.pmaxs.w" => "__builtin_ia32_pmaxsw256", + "avx2.pmaxu.b" => "__builtin_ia32_pmaxub256", + "avx2.pmaxu.d" => "__builtin_ia32_pmaxud256", + "avx2.pmaxu.w" => "__builtin_ia32_pmaxuw256", + "avx2.pmins.b" => "__builtin_ia32_pminsb256", + "avx2.pmins.d" => "__builtin_ia32_pminsd256", + "avx2.pmins.w" => "__builtin_ia32_pminsw256", + "avx2.pminu.b" => "__builtin_ia32_pminub256", + "avx2.pminu.d" => "__builtin_ia32_pminud256", + "avx2.pminu.w" => "__builtin_ia32_pminuw256", + "avx2.pmovmskb" => "__builtin_ia32_pmovmskb256", + "avx2.pmovsxbd" => "__builtin_ia32_pmovsxbd256", + "avx2.pmovsxbq" => "__builtin_ia32_pmovsxbq256", + "avx2.pmovsxbw" => "__builtin_ia32_pmovsxbw256", + "avx2.pmovsxdq" => "__builtin_ia32_pmovsxdq256", + "avx2.pmovsxwd" => "__builtin_ia32_pmovsxwd256", + "avx2.pmovsxwq" => "__builtin_ia32_pmovsxwq256", + "avx2.pmovzxbd" => "__builtin_ia32_pmovzxbd256", + "avx2.pmovzxbq" => "__builtin_ia32_pmovzxbq256", + "avx2.pmovzxbw" => "__builtin_ia32_pmovzxbw256", + "avx2.pmovzxdq" => "__builtin_ia32_pmovzxdq256", + "avx2.pmovzxwd" => "__builtin_ia32_pmovzxwd256", + "avx2.pmovzxwq" => "__builtin_ia32_pmovzxwq256", + "avx2.pmul.dq" => "__builtin_ia32_pmuldq256", + "avx2.pmul.hr.sw" => "__builtin_ia32_pmulhrsw256", + "avx2.pmulh.w" => "__builtin_ia32_pmulhw256", + "avx2.pmulhu.w" => "__builtin_ia32_pmulhuw256", + "avx2.pmulu.dq" => "__builtin_ia32_pmuludq256", + "avx2.psad.bw" => "__builtin_ia32_psadbw256", + "avx2.pshuf.b" => "__builtin_ia32_pshufb256", + "avx2.psign.b" => "__builtin_ia32_psignb256", + "avx2.psign.d" => "__builtin_ia32_psignd256", + "avx2.psign.w" => "__builtin_ia32_psignw256", + "avx2.psll.d" => "__builtin_ia32_pslld256", + "avx2.psll.dq" => "__builtin_ia32_pslldqi256", + "avx2.psll.dq.bs" => "__builtin_ia32_pslldqi256_byteshift", + "avx2.psll.q" => "__builtin_ia32_psllq256", + "avx2.psll.w" => "__builtin_ia32_psllw256", + "avx2.pslli.d" => "__builtin_ia32_pslldi256", + "avx2.pslli.q" => "__builtin_ia32_psllqi256", + "avx2.pslli.w" => "__builtin_ia32_psllwi256", + "avx2.psllv.d" => "__builtin_ia32_psllv4si", + "avx2.psllv.d.256" => "__builtin_ia32_psllv8si", + "avx2.psllv.q" => "__builtin_ia32_psllv2di", + "avx2.psllv.q.256" => "__builtin_ia32_psllv4di", + "avx2.psra.d" => "__builtin_ia32_psrad256", + "avx2.psra.w" => "__builtin_ia32_psraw256", + "avx2.psrai.d" => "__builtin_ia32_psradi256", + "avx2.psrai.w" => "__builtin_ia32_psrawi256", + "avx2.psrav.d" => "__builtin_ia32_psrav4si", + "avx2.psrav.d.256" => "__builtin_ia32_psrav8si", + "avx2.psrl.d" => "__builtin_ia32_psrld256", + "avx2.psrl.dq" => "__builtin_ia32_psrldqi256", + "avx2.psrl.dq.bs" => "__builtin_ia32_psrldqi256_byteshift", + "avx2.psrl.q" => "__builtin_ia32_psrlq256", + "avx2.psrl.w" => "__builtin_ia32_psrlw256", + "avx2.psrli.d" => "__builtin_ia32_psrldi256", + "avx2.psrli.q" => "__builtin_ia32_psrlqi256", + "avx2.psrli.w" => "__builtin_ia32_psrlwi256", + "avx2.psrlv.d" => "__builtin_ia32_psrlv4si", + "avx2.psrlv.d.256" => "__builtin_ia32_psrlv8si", + "avx2.psrlv.q" => "__builtin_ia32_psrlv2di", + "avx2.psrlv.q.256" => "__builtin_ia32_psrlv4di", + "avx2.psubs.b" => "__builtin_ia32_psubsb256", + "avx2.psubs.w" => "__builtin_ia32_psubsw256", + "avx2.psubus.b" => "__builtin_ia32_psubusb256", + "avx2.psubus.w" => "__builtin_ia32_psubusw256", + "avx2.vbroadcast.sd.pd.256" => "__builtin_ia32_vbroadcastsd_pd256", + "avx2.vbroadcast.ss.ps" => "__builtin_ia32_vbroadcastss_ps", + "avx2.vbroadcast.ss.ps.256" => "__builtin_ia32_vbroadcastss_ps256", + "avx2.vextracti128" => "__builtin_ia32_extract128i256", + "avx2.vinserti128" => "__builtin_ia32_insert128i256", + "avx2.vpdpbssd.128" => "__builtin_ia32_vpdpbssd128", + "avx2.vpdpbssd.256" => "__builtin_ia32_vpdpbssd256", + "avx2.vpdpbssds.128" => "__builtin_ia32_vpdpbssds128", + "avx2.vpdpbssds.256" => "__builtin_ia32_vpdpbssds256", + "avx2.vpdpbsud.128" => "__builtin_ia32_vpdpbsud128", + "avx2.vpdpbsud.256" => "__builtin_ia32_vpdpbsud256", + "avx2.vpdpbsuds.128" => "__builtin_ia32_vpdpbsuds128", + "avx2.vpdpbsuds.256" => "__builtin_ia32_vpdpbsuds256", + "avx2.vpdpbuud.128" => "__builtin_ia32_vpdpbuud128", + "avx2.vpdpbuud.256" => "__builtin_ia32_vpdpbuud256", + "avx2.vpdpbuuds.128" => "__builtin_ia32_vpdpbuuds128", + "avx2.vpdpbuuds.256" => "__builtin_ia32_vpdpbuuds256", + "avx2.vpdpwsud.128" => "__builtin_ia32_vpdpwsud128", + "avx2.vpdpwsud.256" => "__builtin_ia32_vpdpwsud256", + "avx2.vpdpwsuds.128" => "__builtin_ia32_vpdpwsuds128", + "avx2.vpdpwsuds.256" => "__builtin_ia32_vpdpwsuds256", + "avx2.vpdpwusd.128" => "__builtin_ia32_vpdpwusd128", + "avx2.vpdpwusd.256" => "__builtin_ia32_vpdpwusd256", + "avx2.vpdpwusds.128" => "__builtin_ia32_vpdpwusds128", + "avx2.vpdpwusds.256" => "__builtin_ia32_vpdpwusds256", + "avx2.vpdpwuud.128" => "__builtin_ia32_vpdpwuud128", + "avx2.vpdpwuud.256" => "__builtin_ia32_vpdpwuud256", + "avx2.vpdpwuuds.128" => "__builtin_ia32_vpdpwuuds128", + "avx2.vpdpwuuds.256" => "__builtin_ia32_vpdpwuuds256", + "avx2.vperm2i128" => "__builtin_ia32_permti256", + "avx512.add.pd.512" => "__builtin_ia32_addpd512", + "avx512.add.ps.512" => "__builtin_ia32_addps512", + "avx512.broadcastmb.128" => "__builtin_ia32_broadcastmb128", + "avx512.broadcastmb.256" => "__builtin_ia32_broadcastmb256", + "avx512.broadcastmb.512" => "__builtin_ia32_broadcastmb512", + "avx512.broadcastmw.128" => "__builtin_ia32_broadcastmw128", + "avx512.broadcastmw.256" => "__builtin_ia32_broadcastmw256", + "avx512.broadcastmw.512" => "__builtin_ia32_broadcastmw512", + "avx512.conflict.d.128" => "__builtin_ia32_vpconflictsi_128", + "avx512.conflict.d.256" => "__builtin_ia32_vpconflictsi_256", + "avx512.conflict.d.512" => "__builtin_ia32_vpconflictsi_512", + "avx512.conflict.q.128" => "__builtin_ia32_vpconflictdi_128", + "avx512.conflict.q.256" => "__builtin_ia32_vpconflictdi_256", + "avx512.conflict.q.512" => "__builtin_ia32_vpconflictdi_512", + "avx512.cvtb2mask.128" => "__builtin_ia32_cvtb2mask128", + "avx512.cvtb2mask.256" => "__builtin_ia32_cvtb2mask256", + "avx512.cvtb2mask.512" => "__builtin_ia32_cvtb2mask512", + "avx512.cvtd2mask.128" => "__builtin_ia32_cvtd2mask128", + "avx512.cvtd2mask.256" => "__builtin_ia32_cvtd2mask256", + "avx512.cvtd2mask.512" => "__builtin_ia32_cvtd2mask512", + "avx512.cvtmask2b.128" => "__builtin_ia32_cvtmask2b128", + "avx512.cvtmask2b.256" => "__builtin_ia32_cvtmask2b256", + "avx512.cvtmask2b.512" => "__builtin_ia32_cvtmask2b512", + "avx512.cvtmask2d.128" => "__builtin_ia32_cvtmask2d128", + "avx512.cvtmask2d.256" => "__builtin_ia32_cvtmask2d256", + "avx512.cvtmask2d.512" => "__builtin_ia32_cvtmask2d512", + "avx512.cvtmask2q.128" => "__builtin_ia32_cvtmask2q128", + "avx512.cvtmask2q.256" => "__builtin_ia32_cvtmask2q256", + "avx512.cvtmask2q.512" => "__builtin_ia32_cvtmask2q512", + "avx512.cvtmask2w.128" => "__builtin_ia32_cvtmask2w128", + "avx512.cvtmask2w.256" => "__builtin_ia32_cvtmask2w256", + "avx512.cvtmask2w.512" => "__builtin_ia32_cvtmask2w512", + "avx512.cvtq2mask.128" => "__builtin_ia32_cvtq2mask128", + "avx512.cvtq2mask.256" => "__builtin_ia32_cvtq2mask256", + "avx512.cvtq2mask.512" => "__builtin_ia32_cvtq2mask512", + "avx512.cvtsd2usi" => "__builtin_ia32_cvtsd2usi", + "avx512.cvtsd2usi64" => "__builtin_ia32_cvtsd2usi64", + "avx512.cvtsi2sd32" => "__builtin_ia32_cvtsi2sd32", + "avx512.cvtsi2sd64" => "__builtin_ia32_cvtsi2sd64", + "avx512.cvtsi2ss32" => "__builtin_ia32_cvtsi2ss32", + "avx512.cvtsi2ss64" => "__builtin_ia32_cvtsi2ss64", + "avx512.cvtss2usi" => "__builtin_ia32_cvtss2usi", + "avx512.cvtss2usi64" => "__builtin_ia32_cvtss2usi64", + "avx512.cvttsd2si" => "__builtin_ia32_vcvttsd2si32", + "avx512.cvttsd2si64" => "__builtin_ia32_vcvttsd2si64", + "avx512.cvttsd2usi" => "__builtin_ia32_vcvttsd2usi32", + // [DUPLICATE]: "avx512.cvttsd2usi" => "__builtin_ia32_cvttsd2usi", + "avx512.cvttsd2usi64" => "__builtin_ia32_vcvttsd2usi64", + // [DUPLICATE]: "avx512.cvttsd2usi64" => "__builtin_ia32_cvttsd2usi64", + "avx512.cvttss2si" => "__builtin_ia32_vcvttss2si32", + "avx512.cvttss2si64" => "__builtin_ia32_vcvttss2si64", + "avx512.cvttss2usi" => "__builtin_ia32_vcvttss2usi32", + // [DUPLICATE]: "avx512.cvttss2usi" => "__builtin_ia32_cvttss2usi", + "avx512.cvttss2usi64" => "__builtin_ia32_vcvttss2usi64", + // [DUPLICATE]: "avx512.cvttss2usi64" => "__builtin_ia32_cvttss2usi64", + "avx512.cvtusi2sd" => "__builtin_ia32_cvtusi2sd", + // [DUPLICATE]: "avx512.cvtusi2sd" => "__builtin_ia32_cvtusi2sd32", + "avx512.cvtusi2ss" => "__builtin_ia32_cvtusi2ss32", + // [DUPLICATE]: "avx512.cvtusi2ss" => "__builtin_ia32_cvtusi2ss", + "avx512.cvtusi642sd" => "__builtin_ia32_cvtusi2sd64", + // [DUPLICATE]: "avx512.cvtusi642sd" => "__builtin_ia32_cvtusi642sd", + "avx512.cvtusi642ss" => "__builtin_ia32_cvtusi2ss64", + // [DUPLICATE]: "avx512.cvtusi642ss" => "__builtin_ia32_cvtusi642ss", + "avx512.cvtw2mask.128" => "__builtin_ia32_cvtw2mask128", + "avx512.cvtw2mask.256" => "__builtin_ia32_cvtw2mask256", + "avx512.cvtw2mask.512" => "__builtin_ia32_cvtw2mask512", + "avx512.dbpsadbw.128" => "__builtin_ia32_dbpsadbw128", + "avx512.dbpsadbw.256" => "__builtin_ia32_dbpsadbw256", + "avx512.dbpsadbw.512" => "__builtin_ia32_dbpsadbw512", + "avx512.div.pd.512" => "__builtin_ia32_divpd512", + "avx512.div.ps.512" => "__builtin_ia32_divps512", + "avx512.exp2.pd" => "__builtin_ia32_exp2pd_mask", + "avx512.exp2.ps" => "__builtin_ia32_exp2ps_mask", + "avx512.gather.dpd.512" => "__builtin_ia32_gathersiv8df", + "avx512.gather.dpi.512" => "__builtin_ia32_gathersiv16si", + "avx512.gather.dpq.512" => "__builtin_ia32_gathersiv8di", + "avx512.gather.dps.512" => "__builtin_ia32_gathersiv16sf", + "avx512.gather.qpd.512" => "__builtin_ia32_gatherdiv8df", + "avx512.gather.qpi.512" => "__builtin_ia32_gatherdiv16si", + "avx512.gather.qpq.512" => "__builtin_ia32_gatherdiv8di", + "avx512.gather.qps.512" => "__builtin_ia32_gatherdiv16sf", + "avx512.gather3div2.df" => "__builtin_ia32_gather3div2df", + "avx512.gather3div2.di" => "__builtin_ia32_gather3div2di", + "avx512.gather3div4.df" => "__builtin_ia32_gather3div4df", + "avx512.gather3div4.di" => "__builtin_ia32_gather3div4di", + "avx512.gather3div4.sf" => "__builtin_ia32_gather3div4sf", + "avx512.gather3div4.si" => "__builtin_ia32_gather3div4si", + "avx512.gather3div8.sf" => "__builtin_ia32_gather3div8sf", + "avx512.gather3div8.si" => "__builtin_ia32_gather3div8si", + "avx512.gather3siv2.df" => "__builtin_ia32_gather3siv2df", + "avx512.gather3siv2.di" => "__builtin_ia32_gather3siv2di", + "avx512.gather3siv4.df" => "__builtin_ia32_gather3siv4df", + "avx512.gather3siv4.di" => "__builtin_ia32_gather3siv4di", + "avx512.gather3siv4.sf" => "__builtin_ia32_gather3siv4sf", + "avx512.gather3siv4.si" => "__builtin_ia32_gather3siv4si", + "avx512.gather3siv8.sf" => "__builtin_ia32_gather3siv8sf", + "avx512.gather3siv8.si" => "__builtin_ia32_gather3siv8si", + "avx512.gatherpf.dpd.512" => "__builtin_ia32_gatherpfdpd", + "avx512.gatherpf.dps.512" => "__builtin_ia32_gatherpfdps", + "avx512.gatherpf.qpd.512" => "__builtin_ia32_gatherpfqpd", + "avx512.gatherpf.qps.512" => "__builtin_ia32_gatherpfqps", + "avx512.kand.w" => "__builtin_ia32_kandhi", + "avx512.kandn.w" => "__builtin_ia32_kandnhi", + "avx512.knot.w" => "__builtin_ia32_knothi", + "avx512.kor.w" => "__builtin_ia32_korhi", + "avx512.kortestc.w" => "__builtin_ia32_kortestchi", + "avx512.kortestz.w" => "__builtin_ia32_kortestzhi", + "avx512.kunpck.bw" => "__builtin_ia32_kunpckhi", + "avx512.kunpck.dq" => "__builtin_ia32_kunpckdi", + "avx512.kunpck.wd" => "__builtin_ia32_kunpcksi", + "avx512.kxnor.w" => "__builtin_ia32_kxnorhi", + "avx512.kxor.w" => "__builtin_ia32_kxorhi", + "avx512.mask.add.pd.128" => "__builtin_ia32_addpd128_mask", + "avx512.mask.add.pd.256" => "__builtin_ia32_addpd256_mask", + "avx512.mask.add.pd.512" => "__builtin_ia32_addpd512_mask", + "avx512.mask.add.ps.128" => "__builtin_ia32_addps128_mask", + "avx512.mask.add.ps.256" => "__builtin_ia32_addps256_mask", + "avx512.mask.add.ps.512" => "__builtin_ia32_addps512_mask", + // [INVALID CONVERSION]: "avx512.mask.add.sd.round" => "__builtin_ia32_addsd_round_mask", + // [INVALID CONVERSION]: "avx512.mask.add.ss.round" => "__builtin_ia32_addss_round_mask", + "avx512.mask.and.pd.128" => "__builtin_ia32_andpd128_mask", + "avx512.mask.and.pd.256" => "__builtin_ia32_andpd256_mask", + "avx512.mask.and.pd.512" => "__builtin_ia32_andpd512_mask", + "avx512.mask.and.ps.128" => "__builtin_ia32_andps128_mask", + "avx512.mask.and.ps.256" => "__builtin_ia32_andps256_mask", + "avx512.mask.and.ps.512" => "__builtin_ia32_andps512_mask", + "avx512.mask.andn.pd.128" => "__builtin_ia32_andnpd128_mask", + "avx512.mask.andn.pd.256" => "__builtin_ia32_andnpd256_mask", + "avx512.mask.andn.pd.512" => "__builtin_ia32_andnpd512_mask", + "avx512.mask.andn.ps.128" => "__builtin_ia32_andnps128_mask", + "avx512.mask.andn.ps.256" => "__builtin_ia32_andnps256_mask", + "avx512.mask.andn.ps.512" => "__builtin_ia32_andnps512_mask", + "avx512.mask.blend.d.512" => "__builtin_ia32_blendmd_512_mask", + "avx512.mask.blend.pd.512" => "__builtin_ia32_blendmpd_512_mask", + "avx512.mask.blend.ps.512" => "__builtin_ia32_blendmps_512_mask", + "avx512.mask.blend.q.512" => "__builtin_ia32_blendmq_512_mask", + "avx512.mask.broadcastf32x2.256" => "__builtin_ia32_broadcastf32x2_256_mask", + "avx512.mask.broadcastf32x2.512" => "__builtin_ia32_broadcastf32x2_512_mask", + "avx512.mask.broadcastf32x4.256" => "__builtin_ia32_broadcastf32x4_256_mask", + "avx512.mask.broadcastf32x4.512" => "__builtin_ia32_broadcastf32x4_512", + "avx512.mask.broadcastf32x8.512" => "__builtin_ia32_broadcastf32x8_512_mask", + "avx512.mask.broadcastf64x2.256" => "__builtin_ia32_broadcastf64x2_256_mask", + "avx512.mask.broadcastf64x2.512" => "__builtin_ia32_broadcastf64x2_512_mask", + "avx512.mask.broadcastf64x4.512" => "__builtin_ia32_broadcastf64x4_512", + "avx512.mask.broadcasti32x2.128" => "__builtin_ia32_broadcasti32x2_128_mask", + "avx512.mask.broadcasti32x2.256" => "__builtin_ia32_broadcasti32x2_256_mask", + "avx512.mask.broadcasti32x2.512" => "__builtin_ia32_broadcasti32x2_512_mask", + "avx512.mask.broadcasti32x4.256" => "__builtin_ia32_broadcasti32x4_256_mask", + "avx512.mask.broadcasti32x4.512" => "__builtin_ia32_broadcasti32x4_512", + "avx512.mask.broadcasti32x8.512" => "__builtin_ia32_broadcasti32x8_512_mask", + "avx512.mask.broadcasti64x2.256" => "__builtin_ia32_broadcasti64x2_256_mask", + "avx512.mask.broadcasti64x2.512" => "__builtin_ia32_broadcasti64x2_512_mask", + "avx512.mask.broadcasti64x4.512" => "__builtin_ia32_broadcasti64x4_512", + "avx512.mask.cmp.pd.128" => "__builtin_ia32_cmppd128_mask", + "avx512.mask.cmp.pd.256" => "__builtin_ia32_cmppd256_mask", + "avx512.mask.cmp.pd.512" => "__builtin_ia32_cmppd512_mask", + "avx512.mask.cmp.ps.128" => "__builtin_ia32_cmpps128_mask", + "avx512.mask.cmp.ps.256" => "__builtin_ia32_cmpps256_mask", + "avx512.mask.cmp.ps.512" => "__builtin_ia32_cmpps512_mask", + "avx512.mask.cmp.sd" => "__builtin_ia32_cmpsd_mask", + "avx512.mask.cmp.ss" => "__builtin_ia32_cmpss_mask", + "avx512.mask.compress.d.128" => "__builtin_ia32_compresssi128_mask", + "avx512.mask.compress.d.256" => "__builtin_ia32_compresssi256_mask", + "avx512.mask.compress.d.512" => "__builtin_ia32_compresssi512_mask", + "avx512.mask.compress.pd.128" => "__builtin_ia32_compressdf128_mask", + "avx512.mask.compress.pd.256" => "__builtin_ia32_compressdf256_mask", + "avx512.mask.compress.pd.512" => "__builtin_ia32_compressdf512_mask", + "avx512.mask.compress.ps.128" => "__builtin_ia32_compresssf128_mask", + "avx512.mask.compress.ps.256" => "__builtin_ia32_compresssf256_mask", + "avx512.mask.compress.ps.512" => "__builtin_ia32_compresssf512_mask", + "avx512.mask.compress.q.128" => "__builtin_ia32_compressdi128_mask", + "avx512.mask.compress.q.256" => "__builtin_ia32_compressdi256_mask", + "avx512.mask.compress.q.512" => "__builtin_ia32_compressdi512_mask", + "avx512.mask.compress.store.d.128" => "__builtin_ia32_compressstoresi128_mask", + "avx512.mask.compress.store.d.256" => "__builtin_ia32_compressstoresi256_mask", + "avx512.mask.compress.store.d.512" => "__builtin_ia32_compressstoresi512_mask", + "avx512.mask.compress.store.pd.128" => "__builtin_ia32_compressstoredf128_mask", + "avx512.mask.compress.store.pd.256" => "__builtin_ia32_compressstoredf256_mask", + "avx512.mask.compress.store.pd.512" => "__builtin_ia32_compressstoredf512_mask", + "avx512.mask.compress.store.ps.128" => "__builtin_ia32_compressstoresf128_mask", + "avx512.mask.compress.store.ps.256" => "__builtin_ia32_compressstoresf256_mask", + "avx512.mask.compress.store.ps.512" => "__builtin_ia32_compressstoresf512_mask", + "avx512.mask.compress.store.q.128" => "__builtin_ia32_compressstoredi128_mask", + "avx512.mask.compress.store.q.256" => "__builtin_ia32_compressstoredi256_mask", + "avx512.mask.compress.store.q.512" => "__builtin_ia32_compressstoredi512_mask", + "avx512.mask.conflict.d.128" => "__builtin_ia32_vpconflictsi_128_mask", + "avx512.mask.conflict.d.256" => "__builtin_ia32_vpconflictsi_256_mask", + "avx512.mask.conflict.d.512" => "__builtin_ia32_vpconflictsi_512_mask", + "avx512.mask.conflict.q.128" => "__builtin_ia32_vpconflictdi_128_mask", + "avx512.mask.conflict.q.256" => "__builtin_ia32_vpconflictdi_256_mask", + "avx512.mask.conflict.q.512" => "__builtin_ia32_vpconflictdi_512_mask", + "avx512.mask.cvtdq2pd.128" => "__builtin_ia32_cvtdq2pd128_mask", + "avx512.mask.cvtdq2pd.256" => "__builtin_ia32_cvtdq2pd256_mask", + "avx512.mask.cvtdq2pd.512" => "__builtin_ia32_cvtdq2pd512_mask", + "avx512.mask.cvtdq2ps.128" => "__builtin_ia32_cvtdq2ps128_mask", + "avx512.mask.cvtdq2ps.256" => "__builtin_ia32_cvtdq2ps256_mask", + "avx512.mask.cvtdq2ps.512" => "__builtin_ia32_cvtdq2ps512_mask", + "avx512.mask.cvtpd2dq.128" => "__builtin_ia32_cvtpd2dq128_mask", + "avx512.mask.cvtpd2dq.256" => "__builtin_ia32_cvtpd2dq256_mask", + "avx512.mask.cvtpd2dq.512" => "__builtin_ia32_cvtpd2dq512_mask", + "avx512.mask.cvtpd2ps" => "__builtin_ia32_cvtpd2ps_mask", + "avx512.mask.cvtpd2ps.256" => "__builtin_ia32_cvtpd2ps256_mask", + "avx512.mask.cvtpd2ps.512" => "__builtin_ia32_cvtpd2ps512_mask", + "avx512.mask.cvtpd2qq.128" => "__builtin_ia32_cvtpd2qq128_mask", + "avx512.mask.cvtpd2qq.256" => "__builtin_ia32_cvtpd2qq256_mask", + "avx512.mask.cvtpd2qq.512" => "__builtin_ia32_cvtpd2qq512_mask", + "avx512.mask.cvtpd2udq.128" => "__builtin_ia32_cvtpd2udq128_mask", + "avx512.mask.cvtpd2udq.256" => "__builtin_ia32_cvtpd2udq256_mask", + "avx512.mask.cvtpd2udq.512" => "__builtin_ia32_cvtpd2udq512_mask", + "avx512.mask.cvtpd2uqq.128" => "__builtin_ia32_cvtpd2uqq128_mask", + "avx512.mask.cvtpd2uqq.256" => "__builtin_ia32_cvtpd2uqq256_mask", + "avx512.mask.cvtpd2uqq.512" => "__builtin_ia32_cvtpd2uqq512_mask", + "avx512.mask.cvtps2dq.128" => "__builtin_ia32_cvtps2dq128_mask", + "avx512.mask.cvtps2dq.256" => "__builtin_ia32_cvtps2dq256_mask", + "avx512.mask.cvtps2dq.512" => "__builtin_ia32_cvtps2dq512_mask", + "avx512.mask.cvtps2pd.128" => "__builtin_ia32_cvtps2pd128_mask", + "avx512.mask.cvtps2pd.256" => "__builtin_ia32_cvtps2pd256_mask", + "avx512.mask.cvtps2pd.512" => "__builtin_ia32_cvtps2pd512_mask", + "avx512.mask.cvtps2qq.128" => "__builtin_ia32_cvtps2qq128_mask", + "avx512.mask.cvtps2qq.256" => "__builtin_ia32_cvtps2qq256_mask", + "avx512.mask.cvtps2qq.512" => "__builtin_ia32_cvtps2qq512_mask", + "avx512.mask.cvtps2udq.128" => "__builtin_ia32_cvtps2udq128_mask", + "avx512.mask.cvtps2udq.256" => "__builtin_ia32_cvtps2udq256_mask", + "avx512.mask.cvtps2udq.512" => "__builtin_ia32_cvtps2udq512_mask", + "avx512.mask.cvtps2uqq.128" => "__builtin_ia32_cvtps2uqq128_mask", + "avx512.mask.cvtps2uqq.256" => "__builtin_ia32_cvtps2uqq256_mask", + "avx512.mask.cvtps2uqq.512" => "__builtin_ia32_cvtps2uqq512_mask", + "avx512.mask.cvtqq2pd.128" => "__builtin_ia32_cvtqq2pd128_mask", + "avx512.mask.cvtqq2pd.256" => "__builtin_ia32_cvtqq2pd256_mask", + "avx512.mask.cvtqq2pd.512" => "__builtin_ia32_cvtqq2pd512_mask", + "avx512.mask.cvtqq2ps.128" => "__builtin_ia32_cvtqq2ps128_mask", + "avx512.mask.cvtqq2ps.256" => "__builtin_ia32_cvtqq2ps256_mask", + "avx512.mask.cvtqq2ps.512" => "__builtin_ia32_cvtqq2ps512_mask", + // [INVALID CONVERSION]: "avx512.mask.cvtsd2ss.round" => "__builtin_ia32_cvtsd2ss_round_mask", + // [INVALID CONVERSION]: "avx512.mask.cvtss2sd.round" => "__builtin_ia32_cvtss2sd_round_mask", + "avx512.mask.cvttpd2dq.128" => "__builtin_ia32_cvttpd2dq128_mask", + "avx512.mask.cvttpd2dq.256" => "__builtin_ia32_cvttpd2dq256_mask", + "avx512.mask.cvttpd2dq.512" => "__builtin_ia32_cvttpd2dq512_mask", + "avx512.mask.cvttpd2qq.128" => "__builtin_ia32_cvttpd2qq128_mask", + "avx512.mask.cvttpd2qq.256" => "__builtin_ia32_cvttpd2qq256_mask", + "avx512.mask.cvttpd2qq.512" => "__builtin_ia32_cvttpd2qq512_mask", + "avx512.mask.cvttpd2udq.128" => "__builtin_ia32_cvttpd2udq128_mask", + "avx512.mask.cvttpd2udq.256" => "__builtin_ia32_cvttpd2udq256_mask", + "avx512.mask.cvttpd2udq.512" => "__builtin_ia32_cvttpd2udq512_mask", + "avx512.mask.cvttpd2uqq.128" => "__builtin_ia32_cvttpd2uqq128_mask", + "avx512.mask.cvttpd2uqq.256" => "__builtin_ia32_cvttpd2uqq256_mask", + "avx512.mask.cvttpd2uqq.512" => "__builtin_ia32_cvttpd2uqq512_mask", + "avx512.mask.cvttps2dq.128" => "__builtin_ia32_cvttps2dq128_mask", + "avx512.mask.cvttps2dq.256" => "__builtin_ia32_cvttps2dq256_mask", + "avx512.mask.cvttps2dq.512" => "__builtin_ia32_cvttps2dq512_mask", + "avx512.mask.cvttps2qq.128" => "__builtin_ia32_cvttps2qq128_mask", + "avx512.mask.cvttps2qq.256" => "__builtin_ia32_cvttps2qq256_mask", + "avx512.mask.cvttps2qq.512" => "__builtin_ia32_cvttps2qq512_mask", + "avx512.mask.cvttps2udq.128" => "__builtin_ia32_cvttps2udq128_mask", + "avx512.mask.cvttps2udq.256" => "__builtin_ia32_cvttps2udq256_mask", + "avx512.mask.cvttps2udq.512" => "__builtin_ia32_cvttps2udq512_mask", + "avx512.mask.cvttps2uqq.128" => "__builtin_ia32_cvttps2uqq128_mask", + "avx512.mask.cvttps2uqq.256" => "__builtin_ia32_cvttps2uqq256_mask", + "avx512.mask.cvttps2uqq.512" => "__builtin_ia32_cvttps2uqq512_mask", + "avx512.mask.cvtudq2pd.128" => "__builtin_ia32_cvtudq2pd128_mask", + "avx512.mask.cvtudq2pd.256" => "__builtin_ia32_cvtudq2pd256_mask", + "avx512.mask.cvtudq2pd.512" => "__builtin_ia32_cvtudq2pd512_mask", + "avx512.mask.cvtudq2ps.128" => "__builtin_ia32_cvtudq2ps128_mask", + "avx512.mask.cvtudq2ps.256" => "__builtin_ia32_cvtudq2ps256_mask", + "avx512.mask.cvtudq2ps.512" => "__builtin_ia32_cvtudq2ps512_mask", + "avx512.mask.cvtuqq2pd.128" => "__builtin_ia32_cvtuqq2pd128_mask", + "avx512.mask.cvtuqq2pd.256" => "__builtin_ia32_cvtuqq2pd256_mask", + "avx512.mask.cvtuqq2pd.512" => "__builtin_ia32_cvtuqq2pd512_mask", + "avx512.mask.cvtuqq2ps.128" => "__builtin_ia32_cvtuqq2ps128_mask", + "avx512.mask.cvtuqq2ps.256" => "__builtin_ia32_cvtuqq2ps256_mask", + "avx512.mask.cvtuqq2ps.512" => "__builtin_ia32_cvtuqq2ps512_mask", + "avx512.mask.dbpsadbw.128" => "__builtin_ia32_dbpsadbw128_mask", + "avx512.mask.dbpsadbw.256" => "__builtin_ia32_dbpsadbw256_mask", + "avx512.mask.dbpsadbw.512" => "__builtin_ia32_dbpsadbw512_mask", + "avx512.mask.div.pd.128" => "__builtin_ia32_divpd_mask", + "avx512.mask.div.pd.256" => "__builtin_ia32_divpd256_mask", + "avx512.mask.div.pd.512" => "__builtin_ia32_divpd512_mask", + "avx512.mask.div.ps.128" => "__builtin_ia32_divps_mask", + "avx512.mask.div.ps.256" => "__builtin_ia32_divps256_mask", + "avx512.mask.div.ps.512" => "__builtin_ia32_divps512_mask", + // [INVALID CONVERSION]: "avx512.mask.div.sd.round" => "__builtin_ia32_divsd_round_mask", + // [INVALID CONVERSION]: "avx512.mask.div.ss.round" => "__builtin_ia32_divss_round_mask", + "avx512.mask.expand.d.128" => "__builtin_ia32_expandsi128_mask", + "avx512.mask.expand.d.256" => "__builtin_ia32_expandsi256_mask", + "avx512.mask.expand.d.512" => "__builtin_ia32_expandsi512_mask", + "avx512.mask.expand.load.d.128" => "__builtin_ia32_expandloadsi128_mask", + "avx512.mask.expand.load.d.256" => "__builtin_ia32_expandloadsi256_mask", + "avx512.mask.expand.load.d.512" => "__builtin_ia32_expandloadsi512_mask", + "avx512.mask.expand.load.pd.128" => "__builtin_ia32_expandloaddf128_mask", + "avx512.mask.expand.load.pd.256" => "__builtin_ia32_expandloaddf256_mask", + "avx512.mask.expand.load.pd.512" => "__builtin_ia32_expandloaddf512_mask", + "avx512.mask.expand.load.ps.128" => "__builtin_ia32_expandloadsf128_mask", + "avx512.mask.expand.load.ps.256" => "__builtin_ia32_expandloadsf256_mask", + "avx512.mask.expand.load.ps.512" => "__builtin_ia32_expandloadsf512_mask", + "avx512.mask.expand.load.q.128" => "__builtin_ia32_expandloaddi128_mask", + "avx512.mask.expand.load.q.256" => "__builtin_ia32_expandloaddi256_mask", + "avx512.mask.expand.load.q.512" => "__builtin_ia32_expandloaddi512_mask", + "avx512.mask.expand.pd.128" => "__builtin_ia32_expanddf128_mask", + "avx512.mask.expand.pd.256" => "__builtin_ia32_expanddf256_mask", + "avx512.mask.expand.pd.512" => "__builtin_ia32_expanddf512_mask", + "avx512.mask.expand.ps.128" => "__builtin_ia32_expandsf128_mask", + "avx512.mask.expand.ps.256" => "__builtin_ia32_expandsf256_mask", + "avx512.mask.expand.ps.512" => "__builtin_ia32_expandsf512_mask", + "avx512.mask.expand.q.128" => "__builtin_ia32_expanddi128_mask", + "avx512.mask.expand.q.256" => "__builtin_ia32_expanddi256_mask", + "avx512.mask.expand.q.512" => "__builtin_ia32_expanddi512_mask", + "avx512.mask.fixupimm.pd.128" => "__builtin_ia32_fixupimmpd128_mask", + "avx512.mask.fixupimm.pd.256" => "__builtin_ia32_fixupimmpd256_mask", + "avx512.mask.fixupimm.pd.512" => "__builtin_ia32_fixupimmpd512_mask", + "avx512.mask.fixupimm.ps.128" => "__builtin_ia32_fixupimmps128_mask", + "avx512.mask.fixupimm.ps.256" => "__builtin_ia32_fixupimmps256_mask", + "avx512.mask.fixupimm.ps.512" => "__builtin_ia32_fixupimmps512_mask", + "avx512.mask.fixupimm.sd" => "__builtin_ia32_fixupimmsd_mask", + "avx512.mask.fixupimm.ss" => "__builtin_ia32_fixupimmss_mask", + "avx512.mask.fpclass.pd.128" => "__builtin_ia32_fpclasspd128_mask", + "avx512.mask.fpclass.pd.256" => "__builtin_ia32_fpclasspd256_mask", + "avx512.mask.fpclass.pd.512" => "__builtin_ia32_fpclasspd512_mask", + "avx512.mask.fpclass.ps.128" => "__builtin_ia32_fpclassps128_mask", + "avx512.mask.fpclass.ps.256" => "__builtin_ia32_fpclassps256_mask", + "avx512.mask.fpclass.ps.512" => "__builtin_ia32_fpclassps512_mask", + "avx512.mask.fpclass.sd" => "__builtin_ia32_fpclasssd_mask", + "avx512.mask.fpclass.ss" => "__builtin_ia32_fpclassss_mask", + "avx512.mask.getexp.pd.128" => "__builtin_ia32_getexppd128_mask", + "avx512.mask.getexp.pd.256" => "__builtin_ia32_getexppd256_mask", + "avx512.mask.getexp.pd.512" => "__builtin_ia32_getexppd512_mask", + "avx512.mask.getexp.ps.128" => "__builtin_ia32_getexpps128_mask", + "avx512.mask.getexp.ps.256" => "__builtin_ia32_getexpps256_mask", + "avx512.mask.getexp.ps.512" => "__builtin_ia32_getexpps512_mask", + // [INVALID CONVERSION]: "avx512.mask.getexp.sd" => "__builtin_ia32_getexpsd128_round_mask", + // [INVALID CONVERSION]: "avx512.mask.getexp.ss" => "__builtin_ia32_getexpss128_round_mask", + "avx512.mask.getmant.pd.128" => "__builtin_ia32_getmantpd128_mask", + "avx512.mask.getmant.pd.256" => "__builtin_ia32_getmantpd256_mask", + "avx512.mask.getmant.pd.512" => "__builtin_ia32_getmantpd512_mask", + "avx512.mask.getmant.ps.128" => "__builtin_ia32_getmantps128_mask", + "avx512.mask.getmant.ps.256" => "__builtin_ia32_getmantps256_mask", + "avx512.mask.getmant.ps.512" => "__builtin_ia32_getmantps512_mask", + // [INVALID CONVERSION]: "avx512.mask.getmant.sd" => "__builtin_ia32_getmantsd_round_mask", + // [INVALID CONVERSION]: "avx512.mask.getmant.ss" => "__builtin_ia32_getmantss_round_mask", + "avx512.mask.insertf32x4.256" => "__builtin_ia32_insertf32x4_256_mask", + "avx512.mask.insertf32x4.512" => "__builtin_ia32_insertf32x4_mask", + "avx512.mask.insertf32x8.512" => "__builtin_ia32_insertf32x8_mask", + "avx512.mask.insertf64x2.256" => "__builtin_ia32_insertf64x2_256_mask", + "avx512.mask.insertf64x2.512" => "__builtin_ia32_insertf64x2_512_mask", + "avx512.mask.insertf64x4.512" => "__builtin_ia32_insertf64x4_mask", + "avx512.mask.inserti32x4.256" => "__builtin_ia32_inserti32x4_256_mask", + "avx512.mask.inserti32x4.512" => "__builtin_ia32_inserti32x4_mask", + "avx512.mask.inserti32x8.512" => "__builtin_ia32_inserti32x8_mask", + "avx512.mask.inserti64x2.256" => "__builtin_ia32_inserti64x2_256_mask", + "avx512.mask.inserti64x2.512" => "__builtin_ia32_inserti64x2_512_mask", + "avx512.mask.inserti64x4.512" => "__builtin_ia32_inserti64x4_mask", + "avx512.mask.loadu.d.512" => "__builtin_ia32_loaddqusi512_mask", + "avx512.mask.loadu.pd.512" => "__builtin_ia32_loadupd512_mask", + "avx512.mask.loadu.ps.512" => "__builtin_ia32_loadups512_mask", + "avx512.mask.loadu.q.512" => "__builtin_ia32_loaddqudi512_mask", + "avx512.mask.lzcnt.d.512" => "__builtin_ia32_vplzcntd_512_mask", + "avx512.mask.lzcnt.q.512" => "__builtin_ia32_vplzcntq_512_mask", + "avx512.mask.max.pd.128" => "__builtin_ia32_maxpd_mask", + "avx512.mask.max.pd.256" => "__builtin_ia32_maxpd256_mask", + "avx512.mask.max.pd.512" => "__builtin_ia32_maxpd512_mask", + "avx512.mask.max.ps.128" => "__builtin_ia32_maxps_mask", + "avx512.mask.max.ps.256" => "__builtin_ia32_maxps256_mask", + "avx512.mask.max.ps.512" => "__builtin_ia32_maxps512_mask", + // [INVALID CONVERSION]: "avx512.mask.max.sd.round" => "__builtin_ia32_maxsd_round_mask", + // [INVALID CONVERSION]: "avx512.mask.max.ss.round" => "__builtin_ia32_maxss_round_mask", + "avx512.mask.min.pd.128" => "__builtin_ia32_minpd_mask", + "avx512.mask.min.pd.256" => "__builtin_ia32_minpd256_mask", + "avx512.mask.min.pd.512" => "__builtin_ia32_minpd512_mask", + "avx512.mask.min.ps.128" => "__builtin_ia32_minps_mask", + "avx512.mask.min.ps.256" => "__builtin_ia32_minps256_mask", + "avx512.mask.min.ps.512" => "__builtin_ia32_minps512_mask", + // [INVALID CONVERSION]: "avx512.mask.min.sd.round" => "__builtin_ia32_minsd_round_mask", + // [INVALID CONVERSION]: "avx512.mask.min.ss.round" => "__builtin_ia32_minss_round_mask", + "avx512.mask.move.sd" => "__builtin_ia32_movsd_mask", + "avx512.mask.move.ss" => "__builtin_ia32_movss_mask", + "avx512.mask.mul.pd.128" => "__builtin_ia32_mulpd_mask", + "avx512.mask.mul.pd.256" => "__builtin_ia32_mulpd256_mask", + "avx512.mask.mul.pd.512" => "__builtin_ia32_mulpd512_mask", + "avx512.mask.mul.ps.128" => "__builtin_ia32_mulps_mask", + "avx512.mask.mul.ps.256" => "__builtin_ia32_mulps256_mask", + "avx512.mask.mul.ps.512" => "__builtin_ia32_mulps512_mask", + // [INVALID CONVERSION]: "avx512.mask.mul.sd.round" => "__builtin_ia32_mulsd_round_mask", + // [INVALID CONVERSION]: "avx512.mask.mul.ss.round" => "__builtin_ia32_mulss_round_mask", + "avx512.mask.or.pd.128" => "__builtin_ia32_orpd128_mask", + "avx512.mask.or.pd.256" => "__builtin_ia32_orpd256_mask", + "avx512.mask.or.pd.512" => "__builtin_ia32_orpd512_mask", + "avx512.mask.or.ps.128" => "__builtin_ia32_orps128_mask", + "avx512.mask.or.ps.256" => "__builtin_ia32_orps256_mask", + "avx512.mask.or.ps.512" => "__builtin_ia32_orps512_mask", + "avx512.mask.pabs.b.128" => "__builtin_ia32_pabsb128_mask", + "avx512.mask.pabs.b.256" => "__builtin_ia32_pabsb256_mask", + "avx512.mask.pabs.b.512" => "__builtin_ia32_pabsb512_mask", + "avx512.mask.pabs.d.128" => "__builtin_ia32_pabsd128_mask", + "avx512.mask.pabs.d.256" => "__builtin_ia32_pabsd256_mask", + "avx512.mask.pabs.d.512" => "__builtin_ia32_pabsd512_mask", + "avx512.mask.pabs.q.128" => "__builtin_ia32_pabsq128_mask", + "avx512.mask.pabs.q.256" => "__builtin_ia32_pabsq256_mask", + "avx512.mask.pabs.q.512" => "__builtin_ia32_pabsq512_mask", + "avx512.mask.pabs.w.128" => "__builtin_ia32_pabsw128_mask", + "avx512.mask.pabs.w.256" => "__builtin_ia32_pabsw256_mask", + "avx512.mask.pabs.w.512" => "__builtin_ia32_pabsw512_mask", + "avx512.mask.packssdw.128" => "__builtin_ia32_packssdw128_mask", + "avx512.mask.packssdw.256" => "__builtin_ia32_packssdw256_mask", + "avx512.mask.packssdw.512" => "__builtin_ia32_packssdw512_mask", + "avx512.mask.packsswb.128" => "__builtin_ia32_packsswb128_mask", + "avx512.mask.packsswb.256" => "__builtin_ia32_packsswb256_mask", + "avx512.mask.packsswb.512" => "__builtin_ia32_packsswb512_mask", + "avx512.mask.packusdw.128" => "__builtin_ia32_packusdw128_mask", + "avx512.mask.packusdw.256" => "__builtin_ia32_packusdw256_mask", + "avx512.mask.packusdw.512" => "__builtin_ia32_packusdw512_mask", + "avx512.mask.packuswb.128" => "__builtin_ia32_packuswb128_mask", + "avx512.mask.packuswb.256" => "__builtin_ia32_packuswb256_mask", + "avx512.mask.packuswb.512" => "__builtin_ia32_packuswb512_mask", + "avx512.mask.padd.b.128" => "__builtin_ia32_paddb128_mask", + "avx512.mask.padd.b.256" => "__builtin_ia32_paddb256_mask", + "avx512.mask.padd.b.512" => "__builtin_ia32_paddb512_mask", + "avx512.mask.padd.d.128" => "__builtin_ia32_paddd128_mask", + "avx512.mask.padd.d.256" => "__builtin_ia32_paddd256_mask", + "avx512.mask.padd.d.512" => "__builtin_ia32_paddd512_mask", + "avx512.mask.padd.q.128" => "__builtin_ia32_paddq128_mask", + "avx512.mask.padd.q.256" => "__builtin_ia32_paddq256_mask", + "avx512.mask.padd.q.512" => "__builtin_ia32_paddq512_mask", + "avx512.mask.padd.w.128" => "__builtin_ia32_paddw128_mask", + "avx512.mask.padd.w.256" => "__builtin_ia32_paddw256_mask", + "avx512.mask.padd.w.512" => "__builtin_ia32_paddw512_mask", + "avx512.mask.padds.b.128" => "__builtin_ia32_paddsb128_mask", + "avx512.mask.padds.b.256" => "__builtin_ia32_paddsb256_mask", + "avx512.mask.padds.b.512" => "__builtin_ia32_paddsb512_mask", + "avx512.mask.padds.w.128" => "__builtin_ia32_paddsw128_mask", + "avx512.mask.padds.w.256" => "__builtin_ia32_paddsw256_mask", + "avx512.mask.padds.w.512" => "__builtin_ia32_paddsw512_mask", + "avx512.mask.paddus.b.128" => "__builtin_ia32_paddusb128_mask", + "avx512.mask.paddus.b.256" => "__builtin_ia32_paddusb256_mask", + "avx512.mask.paddus.b.512" => "__builtin_ia32_paddusb512_mask", + "avx512.mask.paddus.w.128" => "__builtin_ia32_paddusw128_mask", + "avx512.mask.paddus.w.256" => "__builtin_ia32_paddusw256_mask", + "avx512.mask.paddus.w.512" => "__builtin_ia32_paddusw512_mask", + "avx512.mask.pand.d.512" => "__builtin_ia32_pandd512_mask", + "avx512.mask.pand.q.512" => "__builtin_ia32_pandq512_mask", + "avx512.mask.pavg.b.128" => "__builtin_ia32_pavgb128_mask", + "avx512.mask.pavg.b.256" => "__builtin_ia32_pavgb256_mask", + "avx512.mask.pavg.b.512" => "__builtin_ia32_pavgb512_mask", + "avx512.mask.pavg.w.128" => "__builtin_ia32_pavgw128_mask", + "avx512.mask.pavg.w.256" => "__builtin_ia32_pavgw256_mask", + "avx512.mask.pavg.w.512" => "__builtin_ia32_pavgw512_mask", + "avx512.mask.pbroadcast.b.gpr.128" => "__builtin_ia32_pbroadcastb128_gpr_mask", + "avx512.mask.pbroadcast.b.gpr.256" => "__builtin_ia32_pbroadcastb256_gpr_mask", + "avx512.mask.pbroadcast.b.gpr.512" => "__builtin_ia32_pbroadcastb512_gpr_mask", + "avx512.mask.pbroadcast.d.gpr.128" => "__builtin_ia32_pbroadcastd128_gpr_mask", + "avx512.mask.pbroadcast.d.gpr.256" => "__builtin_ia32_pbroadcastd256_gpr_mask", + "avx512.mask.pbroadcast.d.gpr.512" => "__builtin_ia32_pbroadcastd512_gpr_mask", + "avx512.mask.pbroadcast.q.gpr.128" => "__builtin_ia32_pbroadcastq128_gpr_mask", + "avx512.mask.pbroadcast.q.gpr.256" => "__builtin_ia32_pbroadcastq256_gpr_mask", + "avx512.mask.pbroadcast.q.gpr.512" => "__builtin_ia32_pbroadcastq512_gpr_mask", + "avx512.mask.pbroadcast.q.mem.512" => "__builtin_ia32_pbroadcastq512_mem_mask", + "avx512.mask.pbroadcast.w.gpr.128" => "__builtin_ia32_pbroadcastw128_gpr_mask", + "avx512.mask.pbroadcast.w.gpr.256" => "__builtin_ia32_pbroadcastw256_gpr_mask", + "avx512.mask.pbroadcast.w.gpr.512" => "__builtin_ia32_pbroadcastw512_gpr_mask", + "avx512.mask.pcmpeq.b.128" => "__builtin_ia32_pcmpeqb128_mask", + "avx512.mask.pcmpeq.b.256" => "__builtin_ia32_pcmpeqb256_mask", + "avx512.mask.pcmpeq.b.512" => "__builtin_ia32_pcmpeqb512_mask", + "avx512.mask.pcmpeq.d.128" => "__builtin_ia32_pcmpeqd128_mask", + "avx512.mask.pcmpeq.d.256" => "__builtin_ia32_pcmpeqd256_mask", + "avx512.mask.pcmpeq.d.512" => "__builtin_ia32_pcmpeqd512_mask", + "avx512.mask.pcmpeq.q.128" => "__builtin_ia32_pcmpeqq128_mask", + "avx512.mask.pcmpeq.q.256" => "__builtin_ia32_pcmpeqq256_mask", + "avx512.mask.pcmpeq.q.512" => "__builtin_ia32_pcmpeqq512_mask", + "avx512.mask.pcmpeq.w.128" => "__builtin_ia32_pcmpeqw128_mask", + "avx512.mask.pcmpeq.w.256" => "__builtin_ia32_pcmpeqw256_mask", + "avx512.mask.pcmpeq.w.512" => "__builtin_ia32_pcmpeqw512_mask", + "avx512.mask.pcmpgt.b.128" => "__builtin_ia32_pcmpgtb128_mask", + "avx512.mask.pcmpgt.b.256" => "__builtin_ia32_pcmpgtb256_mask", + "avx512.mask.pcmpgt.b.512" => "__builtin_ia32_pcmpgtb512_mask", + "avx512.mask.pcmpgt.d.128" => "__builtin_ia32_pcmpgtd128_mask", + "avx512.mask.pcmpgt.d.256" => "__builtin_ia32_pcmpgtd256_mask", + "avx512.mask.pcmpgt.d.512" => "__builtin_ia32_pcmpgtd512_mask", + "avx512.mask.pcmpgt.q.128" => "__builtin_ia32_pcmpgtq128_mask", + "avx512.mask.pcmpgt.q.256" => "__builtin_ia32_pcmpgtq256_mask", + "avx512.mask.pcmpgt.q.512" => "__builtin_ia32_pcmpgtq512_mask", + "avx512.mask.pcmpgt.w.128" => "__builtin_ia32_pcmpgtw128_mask", + "avx512.mask.pcmpgt.w.256" => "__builtin_ia32_pcmpgtw256_mask", + "avx512.mask.pcmpgt.w.512" => "__builtin_ia32_pcmpgtw512_mask", + "avx512.mask.permvar.df.256" => "__builtin_ia32_permvardf256_mask", + "avx512.mask.permvar.df.512" => "__builtin_ia32_permvardf512_mask", + "avx512.mask.permvar.di.256" => "__builtin_ia32_permvardi256_mask", + "avx512.mask.permvar.di.512" => "__builtin_ia32_permvardi512_mask", + "avx512.mask.permvar.hi.128" => "__builtin_ia32_permvarhi128_mask", + "avx512.mask.permvar.hi.256" => "__builtin_ia32_permvarhi256_mask", + "avx512.mask.permvar.hi.512" => "__builtin_ia32_permvarhi512_mask", + "avx512.mask.permvar.qi.128" => "__builtin_ia32_permvarqi128_mask", + "avx512.mask.permvar.qi.256" => "__builtin_ia32_permvarqi256_mask", + "avx512.mask.permvar.qi.512" => "__builtin_ia32_permvarqi512_mask", + "avx512.mask.permvar.sf.256" => "__builtin_ia32_permvarsf256_mask", + "avx512.mask.permvar.sf.512" => "__builtin_ia32_permvarsf512_mask", + "avx512.mask.permvar.si.256" => "__builtin_ia32_permvarsi256_mask", + "avx512.mask.permvar.si.512" => "__builtin_ia32_permvarsi512_mask", + "avx512.mask.pmaddubs.w.128" => "__builtin_ia32_pmaddubsw128_mask", + "avx512.mask.pmaddubs.w.256" => "__builtin_ia32_pmaddubsw256_mask", + "avx512.mask.pmaddubs.w.512" => "__builtin_ia32_pmaddubsw512_mask", + "avx512.mask.pmaddw.d.128" => "__builtin_ia32_pmaddwd128_mask", + "avx512.mask.pmaddw.d.256" => "__builtin_ia32_pmaddwd256_mask", + "avx512.mask.pmaddw.d.512" => "__builtin_ia32_pmaddwd512_mask", + "avx512.mask.pmaxs.b.128" => "__builtin_ia32_pmaxsb128_mask", + "avx512.mask.pmaxs.b.256" => "__builtin_ia32_pmaxsb256_mask", + "avx512.mask.pmaxs.b.512" => "__builtin_ia32_pmaxsb512_mask", + "avx512.mask.pmaxs.d.128" => "__builtin_ia32_pmaxsd128_mask", + "avx512.mask.pmaxs.d.256" => "__builtin_ia32_pmaxsd256_mask", + "avx512.mask.pmaxs.d.512" => "__builtin_ia32_pmaxsd512_mask", + "avx512.mask.pmaxs.q.128" => "__builtin_ia32_pmaxsq128_mask", + "avx512.mask.pmaxs.q.256" => "__builtin_ia32_pmaxsq256_mask", + "avx512.mask.pmaxs.q.512" => "__builtin_ia32_pmaxsq512_mask", + "avx512.mask.pmaxs.w.128" => "__builtin_ia32_pmaxsw128_mask", + "avx512.mask.pmaxs.w.256" => "__builtin_ia32_pmaxsw256_mask", + "avx512.mask.pmaxs.w.512" => "__builtin_ia32_pmaxsw512_mask", + "avx512.mask.pmaxu.b.128" => "__builtin_ia32_pmaxub128_mask", + "avx512.mask.pmaxu.b.256" => "__builtin_ia32_pmaxub256_mask", + "avx512.mask.pmaxu.b.512" => "__builtin_ia32_pmaxub512_mask", + "avx512.mask.pmaxu.d.128" => "__builtin_ia32_pmaxud128_mask", + "avx512.mask.pmaxu.d.256" => "__builtin_ia32_pmaxud256_mask", + "avx512.mask.pmaxu.d.512" => "__builtin_ia32_pmaxud512_mask", + "avx512.mask.pmaxu.q.128" => "__builtin_ia32_pmaxuq128_mask", + "avx512.mask.pmaxu.q.256" => "__builtin_ia32_pmaxuq256_mask", + "avx512.mask.pmaxu.q.512" => "__builtin_ia32_pmaxuq512_mask", + "avx512.mask.pmaxu.w.128" => "__builtin_ia32_pmaxuw128_mask", + "avx512.mask.pmaxu.w.256" => "__builtin_ia32_pmaxuw256_mask", + "avx512.mask.pmaxu.w.512" => "__builtin_ia32_pmaxuw512_mask", + "avx512.mask.pmins.b.128" => "__builtin_ia32_pminsb128_mask", + "avx512.mask.pmins.b.256" => "__builtin_ia32_pminsb256_mask", + "avx512.mask.pmins.b.512" => "__builtin_ia32_pminsb512_mask", + "avx512.mask.pmins.d.128" => "__builtin_ia32_pminsd128_mask", + "avx512.mask.pmins.d.256" => "__builtin_ia32_pminsd256_mask", + "avx512.mask.pmins.d.512" => "__builtin_ia32_pminsd512_mask", + "avx512.mask.pmins.q.128" => "__builtin_ia32_pminsq128_mask", + "avx512.mask.pmins.q.256" => "__builtin_ia32_pminsq256_mask", + "avx512.mask.pmins.q.512" => "__builtin_ia32_pminsq512_mask", + "avx512.mask.pmins.w.128" => "__builtin_ia32_pminsw128_mask", + "avx512.mask.pmins.w.256" => "__builtin_ia32_pminsw256_mask", + "avx512.mask.pmins.w.512" => "__builtin_ia32_pminsw512_mask", + "avx512.mask.pminu.b.128" => "__builtin_ia32_pminub128_mask", + "avx512.mask.pminu.b.256" => "__builtin_ia32_pminub256_mask", + "avx512.mask.pminu.b.512" => "__builtin_ia32_pminub512_mask", + "avx512.mask.pminu.d.128" => "__builtin_ia32_pminud128_mask", + "avx512.mask.pminu.d.256" => "__builtin_ia32_pminud256_mask", + "avx512.mask.pminu.d.512" => "__builtin_ia32_pminud512_mask", + "avx512.mask.pminu.q.128" => "__builtin_ia32_pminuq128_mask", + "avx512.mask.pminu.q.256" => "__builtin_ia32_pminuq256_mask", + "avx512.mask.pminu.q.512" => "__builtin_ia32_pminuq512_mask", + "avx512.mask.pminu.w.128" => "__builtin_ia32_pminuw128_mask", + "avx512.mask.pminu.w.256" => "__builtin_ia32_pminuw256_mask", + "avx512.mask.pminu.w.512" => "__builtin_ia32_pminuw512_mask", + "avx512.mask.pmov.db.128" => "__builtin_ia32_pmovdb128_mask", + "avx512.mask.pmov.db.256" => "__builtin_ia32_pmovdb256_mask", + "avx512.mask.pmov.db.512" => "__builtin_ia32_pmovdb512_mask", + "avx512.mask.pmov.db.mem.128" => "__builtin_ia32_pmovdb128mem_mask", + "avx512.mask.pmov.db.mem.256" => "__builtin_ia32_pmovdb256mem_mask", + "avx512.mask.pmov.db.mem.512" => "__builtin_ia32_pmovdb512mem_mask", + "avx512.mask.pmov.dw.128" => "__builtin_ia32_pmovdw128_mask", + "avx512.mask.pmov.dw.256" => "__builtin_ia32_pmovdw256_mask", + "avx512.mask.pmov.dw.512" => "__builtin_ia32_pmovdw512_mask", + "avx512.mask.pmov.dw.mem.128" => "__builtin_ia32_pmovdw128mem_mask", + "avx512.mask.pmov.dw.mem.256" => "__builtin_ia32_pmovdw256mem_mask", + "avx512.mask.pmov.dw.mem.512" => "__builtin_ia32_pmovdw512mem_mask", + "avx512.mask.pmov.qb.128" => "__builtin_ia32_pmovqb128_mask", + "avx512.mask.pmov.qb.256" => "__builtin_ia32_pmovqb256_mask", + "avx512.mask.pmov.qb.512" => "__builtin_ia32_pmovqb512_mask", + "avx512.mask.pmov.qb.mem.128" => "__builtin_ia32_pmovqb128mem_mask", + "avx512.mask.pmov.qb.mem.256" => "__builtin_ia32_pmovqb256mem_mask", + "avx512.mask.pmov.qb.mem.512" => "__builtin_ia32_pmovqb512mem_mask", + "avx512.mask.pmov.qd.128" => "__builtin_ia32_pmovqd128_mask", + "avx512.mask.pmov.qd.256" => "__builtin_ia32_pmovqd256_mask", + "avx512.mask.pmov.qd.512" => "__builtin_ia32_pmovqd512_mask", + "avx512.mask.pmov.qd.mem.128" => "__builtin_ia32_pmovqd128mem_mask", + "avx512.mask.pmov.qd.mem.256" => "__builtin_ia32_pmovqd256mem_mask", + "avx512.mask.pmov.qd.mem.512" => "__builtin_ia32_pmovqd512mem_mask", + "avx512.mask.pmov.qw.128" => "__builtin_ia32_pmovqw128_mask", + "avx512.mask.pmov.qw.256" => "__builtin_ia32_pmovqw256_mask", + "avx512.mask.pmov.qw.512" => "__builtin_ia32_pmovqw512_mask", + "avx512.mask.pmov.qw.mem.128" => "__builtin_ia32_pmovqw128mem_mask", + "avx512.mask.pmov.qw.mem.256" => "__builtin_ia32_pmovqw256mem_mask", + "avx512.mask.pmov.qw.mem.512" => "__builtin_ia32_pmovqw512mem_mask", + "avx512.mask.pmov.wb.128" => "__builtin_ia32_pmovwb128_mask", + "avx512.mask.pmov.wb.256" => "__builtin_ia32_pmovwb256_mask", + "avx512.mask.pmov.wb.512" => "__builtin_ia32_pmovwb512_mask", + "avx512.mask.pmov.wb.mem.128" => "__builtin_ia32_pmovwb128mem_mask", + "avx512.mask.pmov.wb.mem.256" => "__builtin_ia32_pmovwb256mem_mask", + "avx512.mask.pmov.wb.mem.512" => "__builtin_ia32_pmovwb512mem_mask", + "avx512.mask.pmovs.db.128" => "__builtin_ia32_pmovsdb128_mask", + "avx512.mask.pmovs.db.256" => "__builtin_ia32_pmovsdb256_mask", + "avx512.mask.pmovs.db.512" => "__builtin_ia32_pmovsdb512_mask", + "avx512.mask.pmovs.db.mem.128" => "__builtin_ia32_pmovsdb128mem_mask", + "avx512.mask.pmovs.db.mem.256" => "__builtin_ia32_pmovsdb256mem_mask", + "avx512.mask.pmovs.db.mem.512" => "__builtin_ia32_pmovsdb512mem_mask", + "avx512.mask.pmovs.dw.128" => "__builtin_ia32_pmovsdw128_mask", + "avx512.mask.pmovs.dw.256" => "__builtin_ia32_pmovsdw256_mask", + "avx512.mask.pmovs.dw.512" => "__builtin_ia32_pmovsdw512_mask", + "avx512.mask.pmovs.dw.mem.128" => "__builtin_ia32_pmovsdw128mem_mask", + "avx512.mask.pmovs.dw.mem.256" => "__builtin_ia32_pmovsdw256mem_mask", + "avx512.mask.pmovs.dw.mem.512" => "__builtin_ia32_pmovsdw512mem_mask", + "avx512.mask.pmovs.qb.128" => "__builtin_ia32_pmovsqb128_mask", + "avx512.mask.pmovs.qb.256" => "__builtin_ia32_pmovsqb256_mask", + "avx512.mask.pmovs.qb.512" => "__builtin_ia32_pmovsqb512_mask", + "avx512.mask.pmovs.qb.mem.128" => "__builtin_ia32_pmovsqb128mem_mask", + "avx512.mask.pmovs.qb.mem.256" => "__builtin_ia32_pmovsqb256mem_mask", + "avx512.mask.pmovs.qb.mem.512" => "__builtin_ia32_pmovsqb512mem_mask", + "avx512.mask.pmovs.qd.128" => "__builtin_ia32_pmovsqd128_mask", + "avx512.mask.pmovs.qd.256" => "__builtin_ia32_pmovsqd256_mask", + "avx512.mask.pmovs.qd.512" => "__builtin_ia32_pmovsqd512_mask", + "avx512.mask.pmovs.qd.mem.128" => "__builtin_ia32_pmovsqd128mem_mask", + "avx512.mask.pmovs.qd.mem.256" => "__builtin_ia32_pmovsqd256mem_mask", + "avx512.mask.pmovs.qd.mem.512" => "__builtin_ia32_pmovsqd512mem_mask", + "avx512.mask.pmovs.qw.128" => "__builtin_ia32_pmovsqw128_mask", + "avx512.mask.pmovs.qw.256" => "__builtin_ia32_pmovsqw256_mask", + "avx512.mask.pmovs.qw.512" => "__builtin_ia32_pmovsqw512_mask", + "avx512.mask.pmovs.qw.mem.128" => "__builtin_ia32_pmovsqw128mem_mask", + "avx512.mask.pmovs.qw.mem.256" => "__builtin_ia32_pmovsqw256mem_mask", + "avx512.mask.pmovs.qw.mem.512" => "__builtin_ia32_pmovsqw512mem_mask", + "avx512.mask.pmovs.wb.128" => "__builtin_ia32_pmovswb128_mask", + "avx512.mask.pmovs.wb.256" => "__builtin_ia32_pmovswb256_mask", + "avx512.mask.pmovs.wb.512" => "__builtin_ia32_pmovswb512_mask", + "avx512.mask.pmovs.wb.mem.128" => "__builtin_ia32_pmovswb128mem_mask", + "avx512.mask.pmovs.wb.mem.256" => "__builtin_ia32_pmovswb256mem_mask", + "avx512.mask.pmovs.wb.mem.512" => "__builtin_ia32_pmovswb512mem_mask", + "avx512.mask.pmovsxb.d.128" => "__builtin_ia32_pmovsxbd128_mask", + "avx512.mask.pmovsxb.d.256" => "__builtin_ia32_pmovsxbd256_mask", + "avx512.mask.pmovsxb.d.512" => "__builtin_ia32_pmovsxbd512_mask", + "avx512.mask.pmovsxb.q.128" => "__builtin_ia32_pmovsxbq128_mask", + "avx512.mask.pmovsxb.q.256" => "__builtin_ia32_pmovsxbq256_mask", + "avx512.mask.pmovsxb.q.512" => "__builtin_ia32_pmovsxbq512_mask", + "avx512.mask.pmovsxb.w.128" => "__builtin_ia32_pmovsxbw128_mask", + "avx512.mask.pmovsxb.w.256" => "__builtin_ia32_pmovsxbw256_mask", + "avx512.mask.pmovsxb.w.512" => "__builtin_ia32_pmovsxbw512_mask", + "avx512.mask.pmovsxd.q.128" => "__builtin_ia32_pmovsxdq128_mask", + "avx512.mask.pmovsxd.q.256" => "__builtin_ia32_pmovsxdq256_mask", + "avx512.mask.pmovsxd.q.512" => "__builtin_ia32_pmovsxdq512_mask", + "avx512.mask.pmovsxw.d.128" => "__builtin_ia32_pmovsxwd128_mask", + "avx512.mask.pmovsxw.d.256" => "__builtin_ia32_pmovsxwd256_mask", + "avx512.mask.pmovsxw.d.512" => "__builtin_ia32_pmovsxwd512_mask", + "avx512.mask.pmovsxw.q.128" => "__builtin_ia32_pmovsxwq128_mask", + "avx512.mask.pmovsxw.q.256" => "__builtin_ia32_pmovsxwq256_mask", + "avx512.mask.pmovsxw.q.512" => "__builtin_ia32_pmovsxwq512_mask", + "avx512.mask.pmovus.db.128" => "__builtin_ia32_pmovusdb128_mask", + "avx512.mask.pmovus.db.256" => "__builtin_ia32_pmovusdb256_mask", + "avx512.mask.pmovus.db.512" => "__builtin_ia32_pmovusdb512_mask", + "avx512.mask.pmovus.db.mem.128" => "__builtin_ia32_pmovusdb128mem_mask", + "avx512.mask.pmovus.db.mem.256" => "__builtin_ia32_pmovusdb256mem_mask", + "avx512.mask.pmovus.db.mem.512" => "__builtin_ia32_pmovusdb512mem_mask", + "avx512.mask.pmovus.dw.128" => "__builtin_ia32_pmovusdw128_mask", + "avx512.mask.pmovus.dw.256" => "__builtin_ia32_pmovusdw256_mask", + "avx512.mask.pmovus.dw.512" => "__builtin_ia32_pmovusdw512_mask", + "avx512.mask.pmovus.dw.mem.128" => "__builtin_ia32_pmovusdw128mem_mask", + "avx512.mask.pmovus.dw.mem.256" => "__builtin_ia32_pmovusdw256mem_mask", + "avx512.mask.pmovus.dw.mem.512" => "__builtin_ia32_pmovusdw512mem_mask", + "avx512.mask.pmovus.qb.128" => "__builtin_ia32_pmovusqb128_mask", + "avx512.mask.pmovus.qb.256" => "__builtin_ia32_pmovusqb256_mask", + "avx512.mask.pmovus.qb.512" => "__builtin_ia32_pmovusqb512_mask", + "avx512.mask.pmovus.qb.mem.128" => "__builtin_ia32_pmovusqb128mem_mask", + "avx512.mask.pmovus.qb.mem.256" => "__builtin_ia32_pmovusqb256mem_mask", + "avx512.mask.pmovus.qb.mem.512" => "__builtin_ia32_pmovusqb512mem_mask", + "avx512.mask.pmovus.qd.128" => "__builtin_ia32_pmovusqd128_mask", + "avx512.mask.pmovus.qd.256" => "__builtin_ia32_pmovusqd256_mask", + "avx512.mask.pmovus.qd.512" => "__builtin_ia32_pmovusqd512_mask", + "avx512.mask.pmovus.qd.mem.128" => "__builtin_ia32_pmovusqd128mem_mask", + "avx512.mask.pmovus.qd.mem.256" => "__builtin_ia32_pmovusqd256mem_mask", + "avx512.mask.pmovus.qd.mem.512" => "__builtin_ia32_pmovusqd512mem_mask", + "avx512.mask.pmovus.qw.128" => "__builtin_ia32_pmovusqw128_mask", + "avx512.mask.pmovus.qw.256" => "__builtin_ia32_pmovusqw256_mask", + "avx512.mask.pmovus.qw.512" => "__builtin_ia32_pmovusqw512_mask", + "avx512.mask.pmovus.qw.mem.128" => "__builtin_ia32_pmovusqw128mem_mask", + "avx512.mask.pmovus.qw.mem.256" => "__builtin_ia32_pmovusqw256mem_mask", + "avx512.mask.pmovus.qw.mem.512" => "__builtin_ia32_pmovusqw512mem_mask", + "avx512.mask.pmovus.wb.128" => "__builtin_ia32_pmovuswb128_mask", + "avx512.mask.pmovus.wb.256" => "__builtin_ia32_pmovuswb256_mask", + "avx512.mask.pmovus.wb.512" => "__builtin_ia32_pmovuswb512_mask", + "avx512.mask.pmovus.wb.mem.128" => "__builtin_ia32_pmovuswb128mem_mask", + "avx512.mask.pmovus.wb.mem.256" => "__builtin_ia32_pmovuswb256mem_mask", + "avx512.mask.pmovus.wb.mem.512" => "__builtin_ia32_pmovuswb512mem_mask", + "avx512.mask.pmovzxb.d.128" => "__builtin_ia32_pmovzxbd128_mask", + "avx512.mask.pmovzxb.d.256" => "__builtin_ia32_pmovzxbd256_mask", + "avx512.mask.pmovzxb.d.512" => "__builtin_ia32_pmovzxbd512_mask", + "avx512.mask.pmovzxb.q.128" => "__builtin_ia32_pmovzxbq128_mask", + "avx512.mask.pmovzxb.q.256" => "__builtin_ia32_pmovzxbq256_mask", + "avx512.mask.pmovzxb.q.512" => "__builtin_ia32_pmovzxbq512_mask", + "avx512.mask.pmovzxb.w.128" => "__builtin_ia32_pmovzxbw128_mask", + "avx512.mask.pmovzxb.w.256" => "__builtin_ia32_pmovzxbw256_mask", + "avx512.mask.pmovzxb.w.512" => "__builtin_ia32_pmovzxbw512_mask", + "avx512.mask.pmovzxd.q.128" => "__builtin_ia32_pmovzxdq128_mask", + "avx512.mask.pmovzxd.q.256" => "__builtin_ia32_pmovzxdq256_mask", + "avx512.mask.pmovzxd.q.512" => "__builtin_ia32_pmovzxdq512_mask", + "avx512.mask.pmovzxw.d.128" => "__builtin_ia32_pmovzxwd128_mask", + "avx512.mask.pmovzxw.d.256" => "__builtin_ia32_pmovzxwd256_mask", + "avx512.mask.pmovzxw.d.512" => "__builtin_ia32_pmovzxwd512_mask", + "avx512.mask.pmovzxw.q.128" => "__builtin_ia32_pmovzxwq128_mask", + "avx512.mask.pmovzxw.q.256" => "__builtin_ia32_pmovzxwq256_mask", + "avx512.mask.pmovzxw.q.512" => "__builtin_ia32_pmovzxwq512_mask", + "avx512.mask.pmul.dq.128" => "__builtin_ia32_pmuldq128_mask", + "avx512.mask.pmul.dq.256" => "__builtin_ia32_pmuldq256_mask", + "avx512.mask.pmul.dq.512" => "__builtin_ia32_pmuldq512_mask", + "avx512.mask.pmul.hr.sw.128" => "__builtin_ia32_pmulhrsw128_mask", + "avx512.mask.pmul.hr.sw.256" => "__builtin_ia32_pmulhrsw256_mask", + "avx512.mask.pmul.hr.sw.512" => "__builtin_ia32_pmulhrsw512_mask", + "avx512.mask.pmulh.w.128" => "__builtin_ia32_pmulhw128_mask", + "avx512.mask.pmulh.w.256" => "__builtin_ia32_pmulhw256_mask", + "avx512.mask.pmulh.w.512" => "__builtin_ia32_pmulhw512_mask", + "avx512.mask.pmulhu.w.128" => "__builtin_ia32_pmulhuw128_mask", + "avx512.mask.pmulhu.w.256" => "__builtin_ia32_pmulhuw256_mask", + "avx512.mask.pmulhu.w.512" => "__builtin_ia32_pmulhuw512_mask", + "avx512.mask.pmull.d.128" => "__builtin_ia32_pmulld128_mask", + "avx512.mask.pmull.d.256" => "__builtin_ia32_pmulld256_mask", + "avx512.mask.pmull.d.512" => "__builtin_ia32_pmulld512_mask", + "avx512.mask.pmull.q.128" => "__builtin_ia32_pmullq128_mask", + "avx512.mask.pmull.q.256" => "__builtin_ia32_pmullq256_mask", + "avx512.mask.pmull.q.512" => "__builtin_ia32_pmullq512_mask", + "avx512.mask.pmull.w.128" => "__builtin_ia32_pmullw128_mask", + "avx512.mask.pmull.w.256" => "__builtin_ia32_pmullw256_mask", + "avx512.mask.pmull.w.512" => "__builtin_ia32_pmullw512_mask", + "avx512.mask.pmultishift.qb.128" => "__builtin_ia32_vpmultishiftqb128_mask", + "avx512.mask.pmultishift.qb.256" => "__builtin_ia32_vpmultishiftqb256_mask", + "avx512.mask.pmultishift.qb.512" => "__builtin_ia32_vpmultishiftqb512_mask", + "avx512.mask.pmulu.dq.128" => "__builtin_ia32_pmuludq128_mask", + "avx512.mask.pmulu.dq.256" => "__builtin_ia32_pmuludq256_mask", + "avx512.mask.pmulu.dq.512" => "__builtin_ia32_pmuludq512_mask", + "avx512.mask.prol.d.128" => "__builtin_ia32_prold128_mask", + "avx512.mask.prol.d.256" => "__builtin_ia32_prold256_mask", + "avx512.mask.prol.d.512" => "__builtin_ia32_prold512_mask", + "avx512.mask.prol.q.128" => "__builtin_ia32_prolq128_mask", + "avx512.mask.prol.q.256" => "__builtin_ia32_prolq256_mask", + "avx512.mask.prol.q.512" => "__builtin_ia32_prolq512_mask", + "avx512.mask.prolv.d.128" => "__builtin_ia32_prolvd128_mask", + "avx512.mask.prolv.d.256" => "__builtin_ia32_prolvd256_mask", + "avx512.mask.prolv.d.512" => "__builtin_ia32_prolvd512_mask", + "avx512.mask.prolv.q.128" => "__builtin_ia32_prolvq128_mask", + "avx512.mask.prolv.q.256" => "__builtin_ia32_prolvq256_mask", + "avx512.mask.prolv.q.512" => "__builtin_ia32_prolvq512_mask", + "avx512.mask.pror.d.128" => "__builtin_ia32_prord128_mask", + "avx512.mask.pror.d.256" => "__builtin_ia32_prord256_mask", + "avx512.mask.pror.d.512" => "__builtin_ia32_prord512_mask", + "avx512.mask.pror.q.128" => "__builtin_ia32_prorq128_mask", + "avx512.mask.pror.q.256" => "__builtin_ia32_prorq256_mask", + "avx512.mask.pror.q.512" => "__builtin_ia32_prorq512_mask", + "avx512.mask.prorv.d.128" => "__builtin_ia32_prorvd128_mask", + "avx512.mask.prorv.d.256" => "__builtin_ia32_prorvd256_mask", + "avx512.mask.prorv.d.512" => "__builtin_ia32_prorvd512_mask", + "avx512.mask.prorv.q.128" => "__builtin_ia32_prorvq128_mask", + "avx512.mask.prorv.q.256" => "__builtin_ia32_prorvq256_mask", + "avx512.mask.prorv.q.512" => "__builtin_ia32_prorvq512_mask", + "avx512.mask.pshuf.b.128" => "__builtin_ia32_pshufb128_mask", + "avx512.mask.pshuf.b.256" => "__builtin_ia32_pshufb256_mask", + "avx512.mask.pshuf.b.512" => "__builtin_ia32_pshufb512_mask", + "avx512.mask.psll.d" => "__builtin_ia32_pslld512_mask", + "avx512.mask.psll.d.128" => "__builtin_ia32_pslld128_mask", + "avx512.mask.psll.d.256" => "__builtin_ia32_pslld256_mask", + "avx512.mask.psll.di.128" => "__builtin_ia32_pslldi128_mask", + "avx512.mask.psll.di.256" => "__builtin_ia32_pslldi256_mask", + "avx512.mask.psll.di.512" => "__builtin_ia32_pslldi512_mask", + "avx512.mask.psll.q" => "__builtin_ia32_psllq512_mask", + "avx512.mask.psll.q.128" => "__builtin_ia32_psllq128_mask", + "avx512.mask.psll.q.256" => "__builtin_ia32_psllq256_mask", + "avx512.mask.psll.qi.128" => "__builtin_ia32_psllqi128_mask", + "avx512.mask.psll.qi.256" => "__builtin_ia32_psllqi256_mask", + "avx512.mask.psll.qi.512" => "__builtin_ia32_psllqi512_mask", + "avx512.mask.psll.w.128" => "__builtin_ia32_psllw128_mask", + "avx512.mask.psll.w.256" => "__builtin_ia32_psllw256_mask", + "avx512.mask.psll.w.512" => "__builtin_ia32_psllw512_mask", + "avx512.mask.psll.wi.128" => "__builtin_ia32_psllwi128_mask", + "avx512.mask.psll.wi.256" => "__builtin_ia32_psllwi256_mask", + "avx512.mask.psll.wi.512" => "__builtin_ia32_psllwi512_mask", + "avx512.mask.psllv.d" => "__builtin_ia32_psllv16si_mask", + "avx512.mask.psllv.q" => "__builtin_ia32_psllv8di_mask", + "avx512.mask.psllv16.hi" => "__builtin_ia32_psllv16hi_mask", + "avx512.mask.psllv2.di" => "__builtin_ia32_psllv2di_mask", + "avx512.mask.psllv32hi" => "__builtin_ia32_psllv32hi_mask", + "avx512.mask.psllv4.di" => "__builtin_ia32_psllv4di_mask", + "avx512.mask.psllv4.si" => "__builtin_ia32_psllv4si_mask", + "avx512.mask.psllv8.hi" => "__builtin_ia32_psllv8hi_mask", + "avx512.mask.psllv8.si" => "__builtin_ia32_psllv8si_mask", + "avx512.mask.psra.d" => "__builtin_ia32_psrad512_mask", + "avx512.mask.psra.d.128" => "__builtin_ia32_psrad128_mask", + "avx512.mask.psra.d.256" => "__builtin_ia32_psrad256_mask", + "avx512.mask.psra.di.128" => "__builtin_ia32_psradi128_mask", + "avx512.mask.psra.di.256" => "__builtin_ia32_psradi256_mask", + "avx512.mask.psra.di.512" => "__builtin_ia32_psradi512_mask", + "avx512.mask.psra.q" => "__builtin_ia32_psraq512_mask", + "avx512.mask.psra.q.128" => "__builtin_ia32_psraq128_mask", + "avx512.mask.psra.q.256" => "__builtin_ia32_psraq256_mask", + "avx512.mask.psra.qi.128" => "__builtin_ia32_psraqi128_mask", + "avx512.mask.psra.qi.256" => "__builtin_ia32_psraqi256_mask", + "avx512.mask.psra.qi.512" => "__builtin_ia32_psraqi512_mask", + "avx512.mask.psra.w.128" => "__builtin_ia32_psraw128_mask", + "avx512.mask.psra.w.256" => "__builtin_ia32_psraw256_mask", + "avx512.mask.psra.w.512" => "__builtin_ia32_psraw512_mask", + "avx512.mask.psra.wi.128" => "__builtin_ia32_psrawi128_mask", + "avx512.mask.psra.wi.256" => "__builtin_ia32_psrawi256_mask", + "avx512.mask.psra.wi.512" => "__builtin_ia32_psrawi512_mask", + "avx512.mask.psrav.d" => "__builtin_ia32_psrav16si_mask", + "avx512.mask.psrav.q" => "__builtin_ia32_psrav8di_mask", + "avx512.mask.psrav.q.128" => "__builtin_ia32_psravq128_mask", + "avx512.mask.psrav.q.256" => "__builtin_ia32_psravq256_mask", + "avx512.mask.psrav16.hi" => "__builtin_ia32_psrav16hi_mask", + "avx512.mask.psrav32.hi" => "__builtin_ia32_psrav32hi_mask", + "avx512.mask.psrav4.si" => "__builtin_ia32_psrav4si_mask", + "avx512.mask.psrav8.hi" => "__builtin_ia32_psrav8hi_mask", + "avx512.mask.psrav8.si" => "__builtin_ia32_psrav8si_mask", + "avx512.mask.psrl.d" => "__builtin_ia32_psrld512_mask", + "avx512.mask.psrl.d.128" => "__builtin_ia32_psrld128_mask", + "avx512.mask.psrl.d.256" => "__builtin_ia32_psrld256_mask", + "avx512.mask.psrl.di.128" => "__builtin_ia32_psrldi128_mask", + "avx512.mask.psrl.di.256" => "__builtin_ia32_psrldi256_mask", + "avx512.mask.psrl.di.512" => "__builtin_ia32_psrldi512_mask", + "avx512.mask.psrl.q" => "__builtin_ia32_psrlq512_mask", + "avx512.mask.psrl.q.128" => "__builtin_ia32_psrlq128_mask", + "avx512.mask.psrl.q.256" => "__builtin_ia32_psrlq256_mask", + "avx512.mask.psrl.qi.128" => "__builtin_ia32_psrlqi128_mask", + "avx512.mask.psrl.qi.256" => "__builtin_ia32_psrlqi256_mask", + "avx512.mask.psrl.qi.512" => "__builtin_ia32_psrlqi512_mask", + "avx512.mask.psrl.w.128" => "__builtin_ia32_psrlw128_mask", + "avx512.mask.psrl.w.256" => "__builtin_ia32_psrlw256_mask", + "avx512.mask.psrl.w.512" => "__builtin_ia32_psrlw512_mask", + "avx512.mask.psrl.wi.128" => "__builtin_ia32_psrlwi128_mask", + "avx512.mask.psrl.wi.256" => "__builtin_ia32_psrlwi256_mask", + "avx512.mask.psrl.wi.512" => "__builtin_ia32_psrlwi512_mask", + "avx512.mask.psrlv.d" => "__builtin_ia32_psrlv16si_mask", + "avx512.mask.psrlv.q" => "__builtin_ia32_psrlv8di_mask", + "avx512.mask.psrlv16.hi" => "__builtin_ia32_psrlv16hi_mask", + "avx512.mask.psrlv2.di" => "__builtin_ia32_psrlv2di_mask", + "avx512.mask.psrlv32hi" => "__builtin_ia32_psrlv32hi_mask", + "avx512.mask.psrlv4.di" => "__builtin_ia32_psrlv4di_mask", + "avx512.mask.psrlv4.si" => "__builtin_ia32_psrlv4si_mask", + "avx512.mask.psrlv8.hi" => "__builtin_ia32_psrlv8hi_mask", + "avx512.mask.psrlv8.si" => "__builtin_ia32_psrlv8si_mask", + "avx512.mask.psub.b.128" => "__builtin_ia32_psubb128_mask", + "avx512.mask.psub.b.256" => "__builtin_ia32_psubb256_mask", + "avx512.mask.psub.b.512" => "__builtin_ia32_psubb512_mask", + "avx512.mask.psub.d.128" => "__builtin_ia32_psubd128_mask", + "avx512.mask.psub.d.256" => "__builtin_ia32_psubd256_mask", + "avx512.mask.psub.d.512" => "__builtin_ia32_psubd512_mask", + "avx512.mask.psub.q.128" => "__builtin_ia32_psubq128_mask", + "avx512.mask.psub.q.256" => "__builtin_ia32_psubq256_mask", + "avx512.mask.psub.q.512" => "__builtin_ia32_psubq512_mask", + "avx512.mask.psub.w.128" => "__builtin_ia32_psubw128_mask", + "avx512.mask.psub.w.256" => "__builtin_ia32_psubw256_mask", + "avx512.mask.psub.w.512" => "__builtin_ia32_psubw512_mask", + "avx512.mask.psubs.b.128" => "__builtin_ia32_psubsb128_mask", + "avx512.mask.psubs.b.256" => "__builtin_ia32_psubsb256_mask", + "avx512.mask.psubs.b.512" => "__builtin_ia32_psubsb512_mask", + "avx512.mask.psubs.w.128" => "__builtin_ia32_psubsw128_mask", + "avx512.mask.psubs.w.256" => "__builtin_ia32_psubsw256_mask", + "avx512.mask.psubs.w.512" => "__builtin_ia32_psubsw512_mask", + "avx512.mask.psubus.b.128" => "__builtin_ia32_psubusb128_mask", + "avx512.mask.psubus.b.256" => "__builtin_ia32_psubusb256_mask", + "avx512.mask.psubus.b.512" => "__builtin_ia32_psubusb512_mask", + "avx512.mask.psubus.w.128" => "__builtin_ia32_psubusw128_mask", + "avx512.mask.psubus.w.256" => "__builtin_ia32_psubusw256_mask", + "avx512.mask.psubus.w.512" => "__builtin_ia32_psubusw512_mask", + "avx512.mask.pternlog.d.128" => "__builtin_ia32_pternlogd128_mask", + "avx512.mask.pternlog.d.256" => "__builtin_ia32_pternlogd256_mask", + "avx512.mask.pternlog.d.512" => "__builtin_ia32_pternlogd512_mask", + "avx512.mask.pternlog.q.128" => "__builtin_ia32_pternlogq128_mask", + "avx512.mask.pternlog.q.256" => "__builtin_ia32_pternlogq256_mask", + "avx512.mask.pternlog.q.512" => "__builtin_ia32_pternlogq512_mask", + "avx512.mask.ptestm.d.512" => "__builtin_ia32_ptestmd512", + "avx512.mask.ptestm.q.512" => "__builtin_ia32_ptestmq512", + "avx512.mask.range.pd.128" => "__builtin_ia32_rangepd128_mask", + "avx512.mask.range.pd.256" => "__builtin_ia32_rangepd256_mask", + "avx512.mask.range.pd.512" => "__builtin_ia32_rangepd512_mask", + "avx512.mask.range.ps.128" => "__builtin_ia32_rangeps128_mask", + "avx512.mask.range.ps.256" => "__builtin_ia32_rangeps256_mask", + "avx512.mask.range.ps.512" => "__builtin_ia32_rangeps512_mask", + // [INVALID CONVERSION]: "avx512.mask.range.sd" => "__builtin_ia32_rangesd128_round_mask", + // [INVALID CONVERSION]: "avx512.mask.range.ss" => "__builtin_ia32_rangess128_round_mask", + "avx512.mask.reduce.pd.128" => "__builtin_ia32_reducepd128_mask", + "avx512.mask.reduce.pd.256" => "__builtin_ia32_reducepd256_mask", + "avx512.mask.reduce.pd.512" => "__builtin_ia32_reducepd512_mask", + "avx512.mask.reduce.ps.128" => "__builtin_ia32_reduceps128_mask", + "avx512.mask.reduce.ps.256" => "__builtin_ia32_reduceps256_mask", + "avx512.mask.reduce.ps.512" => "__builtin_ia32_reduceps512_mask", + "avx512.mask.reduce.sd" => "__builtin_ia32_reducesd_mask", + "avx512.mask.reduce.ss" => "__builtin_ia32_reducess_mask", + "avx512.mask.rndscale.pd.128" => "__builtin_ia32_rndscalepd_128_mask", + "avx512.mask.rndscale.pd.256" => "__builtin_ia32_rndscalepd_256_mask", + "avx512.mask.rndscale.pd.512" => "__builtin_ia32_rndscalepd_mask", + "avx512.mask.rndscale.ps.128" => "__builtin_ia32_rndscaleps_128_mask", + "avx512.mask.rndscale.ps.256" => "__builtin_ia32_rndscaleps_256_mask", + "avx512.mask.rndscale.ps.512" => "__builtin_ia32_rndscaleps_mask", + // [INVALID CONVERSION]: "avx512.mask.rndscale.sd" => "__builtin_ia32_rndscalesd_round_mask", + // [INVALID CONVERSION]: "avx512.mask.rndscale.ss" => "__builtin_ia32_rndscaless_round_mask", + "avx512.mask.scalef.pd.128" => "__builtin_ia32_scalefpd128_mask", + "avx512.mask.scalef.pd.256" => "__builtin_ia32_scalefpd256_mask", + "avx512.mask.scalef.pd.512" => "__builtin_ia32_scalefpd512_mask", + "avx512.mask.scalef.ps.128" => "__builtin_ia32_scalefps128_mask", + "avx512.mask.scalef.ps.256" => "__builtin_ia32_scalefps256_mask", + "avx512.mask.scalef.ps.512" => "__builtin_ia32_scalefps512_mask", + // [INVALID CONVERSION]: "avx512.mask.scalef.sd" => "__builtin_ia32_scalefsd_round_mask", + // [INVALID CONVERSION]: "avx512.mask.scalef.ss" => "__builtin_ia32_scalefss_round_mask", + "avx512.mask.shuf.f32x4" => "__builtin_ia32_shuf_f32x4_mask", + "avx512.mask.shuf.f32x4.256" => "__builtin_ia32_shuf_f32x4_256_mask", + "avx512.mask.shuf.f64x2" => "__builtin_ia32_shuf_f64x2_mask", + "avx512.mask.shuf.f64x2.256" => "__builtin_ia32_shuf_f64x2_256_mask", + "avx512.mask.shuf.i32x4" => "__builtin_ia32_shuf_i32x4_mask", + "avx512.mask.shuf.i32x4.256" => "__builtin_ia32_shuf_i32x4_256_mask", + "avx512.mask.shuf.i64x2" => "__builtin_ia32_shuf_i64x2_mask", + "avx512.mask.shuf.i64x2.256" => "__builtin_ia32_shuf_i64x2_256_mask", + "avx512.mask.shuf.pd.128" => "__builtin_ia32_shufpd128_mask", + "avx512.mask.shuf.pd.256" => "__builtin_ia32_shufpd256_mask", + "avx512.mask.shuf.pd.512" => "__builtin_ia32_shufpd512_mask", + "avx512.mask.shuf.ps.128" => "__builtin_ia32_shufps128_mask", + "avx512.mask.shuf.ps.256" => "__builtin_ia32_shufps256_mask", + "avx512.mask.shuf.ps.512" => "__builtin_ia32_shufps512_mask", + "avx512.mask.sqrt.pd.128" => "__builtin_ia32_sqrtpd128_mask", + "avx512.mask.sqrt.pd.256" => "__builtin_ia32_sqrtpd256_mask", + "avx512.mask.sqrt.pd.512" => "__builtin_ia32_sqrtpd512_mask", + "avx512.mask.sqrt.ps.128" => "__builtin_ia32_sqrtps128_mask", + "avx512.mask.sqrt.ps.256" => "__builtin_ia32_sqrtps256_mask", + "avx512.mask.sqrt.ps.512" => "__builtin_ia32_sqrtps512_mask", + // [INVALID CONVERSION]: "avx512.mask.sqrt.sd" => "__builtin_ia32_sqrtsd_round_mask", + // [INVALID CONVERSION]: "avx512.mask.sqrt.ss" => "__builtin_ia32_sqrtss_round_mask", + "avx512.mask.store.ss" => "__builtin_ia32_storess_mask", + "avx512.mask.storeu.d.512" => "__builtin_ia32_storedqusi512_mask", + "avx512.mask.storeu.pd.512" => "__builtin_ia32_storeupd512_mask", + "avx512.mask.storeu.ps.512" => "__builtin_ia32_storeups512_mask", + "avx512.mask.storeu.q.512" => "__builtin_ia32_storedqudi512_mask", + "avx512.mask.sub.pd.128" => "__builtin_ia32_subpd128_mask", + "avx512.mask.sub.pd.256" => "__builtin_ia32_subpd256_mask", + "avx512.mask.sub.pd.512" => "__builtin_ia32_subpd512_mask", + "avx512.mask.sub.ps.128" => "__builtin_ia32_subps128_mask", + "avx512.mask.sub.ps.256" => "__builtin_ia32_subps256_mask", + "avx512.mask.sub.ps.512" => "__builtin_ia32_subps512_mask", + // [INVALID CONVERSION]: "avx512.mask.sub.sd.round" => "__builtin_ia32_subsd_round_mask", + // [INVALID CONVERSION]: "avx512.mask.sub.ss.round" => "__builtin_ia32_subss_round_mask", + "avx512.mask.valign.d.128" => "__builtin_ia32_alignd128_mask", + "avx512.mask.valign.d.256" => "__builtin_ia32_alignd256_mask", + "avx512.mask.valign.d.512" => "__builtin_ia32_alignd512_mask", + "avx512.mask.valign.q.128" => "__builtin_ia32_alignq128_mask", + "avx512.mask.valign.q.256" => "__builtin_ia32_alignq256_mask", + "avx512.mask.valign.q.512" => "__builtin_ia32_alignq512_mask", + "avx512.mask.vcvtph2ps.128" => "__builtin_ia32_vcvtph2ps_mask", + "avx512.mask.vcvtph2ps.256" => "__builtin_ia32_vcvtph2ps256_mask", + "avx512.mask.vcvtph2ps.512" => "__builtin_ia32_vcvtph2ps512_mask", + "avx512.mask.vcvtps2ph.128" => "__builtin_ia32_vcvtps2ph_mask", + "avx512.mask.vcvtps2ph.256" => "__builtin_ia32_vcvtps2ph256_mask", + "avx512.mask.vcvtps2ph.512" => "__builtin_ia32_vcvtps2ph512_mask", + "avx512.mask.vextractf32x4.256" => "__builtin_ia32_extractf32x4_256_mask", + "avx512.mask.vextractf32x4.512" => "__builtin_ia32_extractf32x4_mask", + "avx512.mask.vextractf32x8.512" => "__builtin_ia32_extractf32x8_mask", + "avx512.mask.vextractf64x2.256" => "__builtin_ia32_extractf64x2_256_mask", + "avx512.mask.vextractf64x2.512" => "__builtin_ia32_extractf64x2_512_mask", + "avx512.mask.vextractf64x4.512" => "__builtin_ia32_extractf64x4_mask", + "avx512.mask.vextracti32x4.256" => "__builtin_ia32_extracti32x4_256_mask", + "avx512.mask.vextracti32x4.512" => "__builtin_ia32_extracti32x4_mask", + "avx512.mask.vextracti32x8.512" => "__builtin_ia32_extracti32x8_mask", + "avx512.mask.vextracti64x2.256" => "__builtin_ia32_extracti64x2_256_mask", + "avx512.mask.vextracti64x2.512" => "__builtin_ia32_extracti64x2_512_mask", + "avx512.mask.vextracti64x4.512" => "__builtin_ia32_extracti64x4_mask", + "avx512.mask.vfmadd.pd.128" => "__builtin_ia32_vfmaddpd128_mask", + "avx512.mask.vfmadd.pd.256" => "__builtin_ia32_vfmaddpd256_mask", + "avx512.mask.vfmadd.pd.512" => "__builtin_ia32_vfmaddpd512_mask", + "avx512.mask.vfmadd.ps.128" => "__builtin_ia32_vfmaddps128_mask", + "avx512.mask.vfmadd.ps.256" => "__builtin_ia32_vfmaddps256_mask", + "avx512.mask.vfmadd.ps.512" => "__builtin_ia32_vfmaddps512_mask", + "avx512.mask.vfmadd.sd" => "__builtin_ia32_vfmaddsd3_mask", + "avx512.mask.vfmadd.ss" => "__builtin_ia32_vfmaddss3_mask", + "avx512.mask.vfmaddsub.pd.128" => "__builtin_ia32_vfmaddsubpd128_mask", + "avx512.mask.vfmaddsub.pd.256" => "__builtin_ia32_vfmaddsubpd256_mask", + "avx512.mask.vfmaddsub.pd.512" => "__builtin_ia32_vfmaddsubpd512_mask", + "avx512.mask.vfmaddsub.ps.128" => "__builtin_ia32_vfmaddsubps128_mask", + "avx512.mask.vfmaddsub.ps.256" => "__builtin_ia32_vfmaddsubps256_mask", + "avx512.mask.vfmaddsub.ps.512" => "__builtin_ia32_vfmaddsubps512_mask", + "avx512.mask.vfnmadd.pd.128" => "__builtin_ia32_vfnmaddpd128_mask", + "avx512.mask.vfnmadd.pd.256" => "__builtin_ia32_vfnmaddpd256_mask", + "avx512.mask.vfnmadd.pd.512" => "__builtin_ia32_vfnmaddpd512_mask", + "avx512.mask.vfnmadd.ps.128" => "__builtin_ia32_vfnmaddps128_mask", + "avx512.mask.vfnmadd.ps.256" => "__builtin_ia32_vfnmaddps256_mask", + "avx512.mask.vfnmadd.ps.512" => "__builtin_ia32_vfnmaddps512_mask", + "avx512.mask.vfnmsub.pd.128" => "__builtin_ia32_vfnmsubpd128_mask", + "avx512.mask.vfnmsub.pd.256" => "__builtin_ia32_vfnmsubpd256_mask", + "avx512.mask.vfnmsub.pd.512" => "__builtin_ia32_vfnmsubpd512_mask", + "avx512.mask.vfnmsub.ps.128" => "__builtin_ia32_vfnmsubps128_mask", + "avx512.mask.vfnmsub.ps.256" => "__builtin_ia32_vfnmsubps256_mask", + "avx512.mask.vfnmsub.ps.512" => "__builtin_ia32_vfnmsubps512_mask", + "avx512.mask.vpermi2var.d.128" => "__builtin_ia32_vpermi2vard128_mask", + "avx512.mask.vpermi2var.d.256" => "__builtin_ia32_vpermi2vard256_mask", + "avx512.mask.vpermi2var.d.512" => "__builtin_ia32_vpermi2vard512_mask", + "avx512.mask.vpermi2var.hi.128" => "__builtin_ia32_vpermi2varhi128_mask", + "avx512.mask.vpermi2var.hi.256" => "__builtin_ia32_vpermi2varhi256_mask", + "avx512.mask.vpermi2var.hi.512" => "__builtin_ia32_vpermi2varhi512_mask", + "avx512.mask.vpermi2var.pd.128" => "__builtin_ia32_vpermi2varpd128_mask", + "avx512.mask.vpermi2var.pd.256" => "__builtin_ia32_vpermi2varpd256_mask", + "avx512.mask.vpermi2var.pd.512" => "__builtin_ia32_vpermi2varpd512_mask", + "avx512.mask.vpermi2var.ps.128" => "__builtin_ia32_vpermi2varps128_mask", + "avx512.mask.vpermi2var.ps.256" => "__builtin_ia32_vpermi2varps256_mask", + "avx512.mask.vpermi2var.ps.512" => "__builtin_ia32_vpermi2varps512_mask", + "avx512.mask.vpermi2var.q.128" => "__builtin_ia32_vpermi2varq128_mask", + "avx512.mask.vpermi2var.q.256" => "__builtin_ia32_vpermi2varq256_mask", + "avx512.mask.vpermi2var.q.512" => "__builtin_ia32_vpermi2varq512_mask", + "avx512.mask.vpermi2var.qi.128" => "__builtin_ia32_vpermi2varqi128_mask", + "avx512.mask.vpermi2var.qi.256" => "__builtin_ia32_vpermi2varqi256_mask", + "avx512.mask.vpermi2var.qi.512" => "__builtin_ia32_vpermi2varqi512_mask", + "avx512.mask.vpermilvar.pd.128" => "__builtin_ia32_vpermilvarpd_mask", + "avx512.mask.vpermilvar.pd.256" => "__builtin_ia32_vpermilvarpd256_mask", + "avx512.mask.vpermilvar.pd.512" => "__builtin_ia32_vpermilvarpd512_mask", + "avx512.mask.vpermilvar.ps.128" => "__builtin_ia32_vpermilvarps_mask", + "avx512.mask.vpermilvar.ps.256" => "__builtin_ia32_vpermilvarps256_mask", + "avx512.mask.vpermilvar.ps.512" => "__builtin_ia32_vpermilvarps512_mask", + "avx512.mask.vpermt.d.512" => "__builtin_ia32_vpermt2vard512_mask", + "avx512.mask.vpermt.pd.512" => "__builtin_ia32_vpermt2varpd512_mask", + "avx512.mask.vpermt.ps.512" => "__builtin_ia32_vpermt2varps512_mask", + "avx512.mask.vpermt.q.512" => "__builtin_ia32_vpermt2varq512_mask", + "avx512.mask.vpermt2var.d.128" => "__builtin_ia32_vpermt2vard128_mask", + "avx512.mask.vpermt2var.d.256" => "__builtin_ia32_vpermt2vard256_mask", + "avx512.mask.vpermt2var.d.512" => "__builtin_ia32_vpermt2vard512_mask", + "avx512.mask.vpermt2var.hi.128" => "__builtin_ia32_vpermt2varhi128_mask", + "avx512.mask.vpermt2var.hi.256" => "__builtin_ia32_vpermt2varhi256_mask", + "avx512.mask.vpermt2var.hi.512" => "__builtin_ia32_vpermt2varhi512_mask", + "avx512.mask.vpermt2var.pd.128" => "__builtin_ia32_vpermt2varpd128_mask", + "avx512.mask.vpermt2var.pd.256" => "__builtin_ia32_vpermt2varpd256_mask", + "avx512.mask.vpermt2var.pd.512" => "__builtin_ia32_vpermt2varpd512_mask", + "avx512.mask.vpermt2var.ps.128" => "__builtin_ia32_vpermt2varps128_mask", + "avx512.mask.vpermt2var.ps.256" => "__builtin_ia32_vpermt2varps256_mask", + "avx512.mask.vpermt2var.ps.512" => "__builtin_ia32_vpermt2varps512_mask", + "avx512.mask.vpermt2var.q.128" => "__builtin_ia32_vpermt2varq128_mask", + "avx512.mask.vpermt2var.q.256" => "__builtin_ia32_vpermt2varq256_mask", + "avx512.mask.vpermt2var.q.512" => "__builtin_ia32_vpermt2varq512_mask", + "avx512.mask.vpermt2var.qi.128" => "__builtin_ia32_vpermt2varqi128_mask", + "avx512.mask.vpermt2var.qi.256" => "__builtin_ia32_vpermt2varqi256_mask", + "avx512.mask.vpermt2var.qi.512" => "__builtin_ia32_vpermt2varqi512_mask", + "avx512.mask.vpmadd52h.uq.128" => "__builtin_ia32_vpmadd52huq128_mask", + "avx512.mask.vpmadd52h.uq.256" => "__builtin_ia32_vpmadd52huq256_mask", + "avx512.mask.vpmadd52h.uq.512" => "__builtin_ia32_vpmadd52huq512_mask", + "avx512.mask.vpmadd52l.uq.128" => "__builtin_ia32_vpmadd52luq128_mask", + "avx512.mask.vpmadd52l.uq.256" => "__builtin_ia32_vpmadd52luq256_mask", + "avx512.mask.vpmadd52l.uq.512" => "__builtin_ia32_vpmadd52luq512_mask", + "avx512.mask.xor.pd.128" => "__builtin_ia32_xorpd128_mask", + "avx512.mask.xor.pd.256" => "__builtin_ia32_xorpd256_mask", + "avx512.mask.xor.pd.512" => "__builtin_ia32_xorpd512_mask", + "avx512.mask.xor.ps.128" => "__builtin_ia32_xorps128_mask", + "avx512.mask.xor.ps.256" => "__builtin_ia32_xorps256_mask", + "avx512.mask.xor.ps.512" => "__builtin_ia32_xorps512_mask", + "avx512.mask3.vfmadd.pd.128" => "__builtin_ia32_vfmaddpd128_mask3", + "avx512.mask3.vfmadd.pd.256" => "__builtin_ia32_vfmaddpd256_mask3", + "avx512.mask3.vfmadd.pd.512" => "__builtin_ia32_vfmaddpd512_mask3", + "avx512.mask3.vfmadd.ps.128" => "__builtin_ia32_vfmaddps128_mask3", + "avx512.mask3.vfmadd.ps.256" => "__builtin_ia32_vfmaddps256_mask3", + "avx512.mask3.vfmadd.ps.512" => "__builtin_ia32_vfmaddps512_mask3", + "avx512.mask3.vfmadd.sd" => "__builtin_ia32_vfmaddsd3_mask3", + "avx512.mask3.vfmadd.ss" => "__builtin_ia32_vfmaddss3_mask3", + "avx512.mask3.vfmaddsub.pd.128" => "__builtin_ia32_vfmaddsubpd128_mask3", + "avx512.mask3.vfmaddsub.pd.256" => "__builtin_ia32_vfmaddsubpd256_mask3", + "avx512.mask3.vfmaddsub.pd.512" => "__builtin_ia32_vfmaddsubpd512_mask3", + "avx512.mask3.vfmaddsub.ps.128" => "__builtin_ia32_vfmaddsubps128_mask3", + "avx512.mask3.vfmaddsub.ps.256" => "__builtin_ia32_vfmaddsubps256_mask3", + "avx512.mask3.vfmaddsub.ps.512" => "__builtin_ia32_vfmaddsubps512_mask3", + "avx512.mask3.vfmsub.pd.128" => "__builtin_ia32_vfmsubpd128_mask3", + "avx512.mask3.vfmsub.pd.256" => "__builtin_ia32_vfmsubpd256_mask3", + "avx512.mask3.vfmsub.pd.512" => "__builtin_ia32_vfmsubpd512_mask3", + "avx512.mask3.vfmsub.ps.128" => "__builtin_ia32_vfmsubps128_mask3", + "avx512.mask3.vfmsub.ps.256" => "__builtin_ia32_vfmsubps256_mask3", + "avx512.mask3.vfmsub.ps.512" => "__builtin_ia32_vfmsubps512_mask3", + "avx512.mask3.vfmsubadd.pd.128" => "__builtin_ia32_vfmsubaddpd128_mask3", + "avx512.mask3.vfmsubadd.pd.256" => "__builtin_ia32_vfmsubaddpd256_mask3", + "avx512.mask3.vfmsubadd.pd.512" => "__builtin_ia32_vfmsubaddpd512_mask3", + "avx512.mask3.vfmsubadd.ps.128" => "__builtin_ia32_vfmsubaddps128_mask3", + "avx512.mask3.vfmsubadd.ps.256" => "__builtin_ia32_vfmsubaddps256_mask3", + "avx512.mask3.vfmsubadd.ps.512" => "__builtin_ia32_vfmsubaddps512_mask3", + "avx512.mask3.vfnmsub.pd.128" => "__builtin_ia32_vfnmsubpd128_mask3", + "avx512.mask3.vfnmsub.pd.256" => "__builtin_ia32_vfnmsubpd256_mask3", + "avx512.mask3.vfnmsub.pd.512" => "__builtin_ia32_vfnmsubpd512_mask3", + "avx512.mask3.vfnmsub.ps.128" => "__builtin_ia32_vfnmsubps128_mask3", + "avx512.mask3.vfnmsub.ps.256" => "__builtin_ia32_vfnmsubps256_mask3", + "avx512.mask3.vfnmsub.ps.512" => "__builtin_ia32_vfnmsubps512_mask3", + "avx512.maskz.fixupimm.pd.128" => "__builtin_ia32_fixupimmpd128_maskz", + "avx512.maskz.fixupimm.pd.256" => "__builtin_ia32_fixupimmpd256_maskz", + "avx512.maskz.fixupimm.pd.512" => "__builtin_ia32_fixupimmpd512_maskz", + "avx512.maskz.fixupimm.ps.128" => "__builtin_ia32_fixupimmps128_maskz", + "avx512.maskz.fixupimm.ps.256" => "__builtin_ia32_fixupimmps256_maskz", + "avx512.maskz.fixupimm.ps.512" => "__builtin_ia32_fixupimmps512_maskz", + "avx512.maskz.fixupimm.sd" => "__builtin_ia32_fixupimmsd_maskz", + "avx512.maskz.fixupimm.ss" => "__builtin_ia32_fixupimmss_maskz", + "avx512.maskz.pternlog.d.128" => "__builtin_ia32_pternlogd128_maskz", + "avx512.maskz.pternlog.d.256" => "__builtin_ia32_pternlogd256_maskz", + "avx512.maskz.pternlog.d.512" => "__builtin_ia32_pternlogd512_maskz", + "avx512.maskz.pternlog.q.128" => "__builtin_ia32_pternlogq128_maskz", + "avx512.maskz.pternlog.q.256" => "__builtin_ia32_pternlogq256_maskz", + "avx512.maskz.pternlog.q.512" => "__builtin_ia32_pternlogq512_maskz", + "avx512.maskz.vfmadd.pd.128" => "__builtin_ia32_vfmaddpd128_maskz", + "avx512.maskz.vfmadd.pd.256" => "__builtin_ia32_vfmaddpd256_maskz", + "avx512.maskz.vfmadd.pd.512" => "__builtin_ia32_vfmaddpd512_maskz", + "avx512.maskz.vfmadd.ps.128" => "__builtin_ia32_vfmaddps128_maskz", + "avx512.maskz.vfmadd.ps.256" => "__builtin_ia32_vfmaddps256_maskz", + "avx512.maskz.vfmadd.ps.512" => "__builtin_ia32_vfmaddps512_maskz", + "avx512.maskz.vfmadd.sd" => "__builtin_ia32_vfmaddsd3_maskz", + "avx512.maskz.vfmadd.ss" => "__builtin_ia32_vfmaddss3_maskz", + "avx512.maskz.vfmaddsub.pd.128" => "__builtin_ia32_vfmaddsubpd128_maskz", + "avx512.maskz.vfmaddsub.pd.256" => "__builtin_ia32_vfmaddsubpd256_maskz", + "avx512.maskz.vfmaddsub.pd.512" => "__builtin_ia32_vfmaddsubpd512_maskz", + "avx512.maskz.vfmaddsub.ps.128" => "__builtin_ia32_vfmaddsubps128_maskz", + "avx512.maskz.vfmaddsub.ps.256" => "__builtin_ia32_vfmaddsubps256_maskz", + "avx512.maskz.vfmaddsub.ps.512" => "__builtin_ia32_vfmaddsubps512_maskz", + "avx512.maskz.vpermt2var.d.128" => "__builtin_ia32_vpermt2vard128_maskz", + "avx512.maskz.vpermt2var.d.256" => "__builtin_ia32_vpermt2vard256_maskz", + "avx512.maskz.vpermt2var.d.512" => "__builtin_ia32_vpermt2vard512_maskz", + "avx512.maskz.vpermt2var.hi.128" => "__builtin_ia32_vpermt2varhi128_maskz", + "avx512.maskz.vpermt2var.hi.256" => "__builtin_ia32_vpermt2varhi256_maskz", + "avx512.maskz.vpermt2var.hi.512" => "__builtin_ia32_vpermt2varhi512_maskz", + "avx512.maskz.vpermt2var.pd.128" => "__builtin_ia32_vpermt2varpd128_maskz", + "avx512.maskz.vpermt2var.pd.256" => "__builtin_ia32_vpermt2varpd256_maskz", + "avx512.maskz.vpermt2var.pd.512" => "__builtin_ia32_vpermt2varpd512_maskz", + "avx512.maskz.vpermt2var.ps.128" => "__builtin_ia32_vpermt2varps128_maskz", + "avx512.maskz.vpermt2var.ps.256" => "__builtin_ia32_vpermt2varps256_maskz", + "avx512.maskz.vpermt2var.ps.512" => "__builtin_ia32_vpermt2varps512_maskz", + "avx512.maskz.vpermt2var.q.128" => "__builtin_ia32_vpermt2varq128_maskz", + "avx512.maskz.vpermt2var.q.256" => "__builtin_ia32_vpermt2varq256_maskz", + "avx512.maskz.vpermt2var.q.512" => "__builtin_ia32_vpermt2varq512_maskz", + "avx512.maskz.vpermt2var.qi.128" => "__builtin_ia32_vpermt2varqi128_maskz", + "avx512.maskz.vpermt2var.qi.256" => "__builtin_ia32_vpermt2varqi256_maskz", + "avx512.maskz.vpermt2var.qi.512" => "__builtin_ia32_vpermt2varqi512_maskz", + "avx512.maskz.vpmadd52h.uq.128" => "__builtin_ia32_vpmadd52huq128_maskz", + "avx512.maskz.vpmadd52h.uq.256" => "__builtin_ia32_vpmadd52huq256_maskz", + "avx512.maskz.vpmadd52h.uq.512" => "__builtin_ia32_vpmadd52huq512_maskz", + "avx512.maskz.vpmadd52l.uq.128" => "__builtin_ia32_vpmadd52luq128_maskz", + "avx512.maskz.vpmadd52l.uq.256" => "__builtin_ia32_vpmadd52luq256_maskz", + "avx512.maskz.vpmadd52l.uq.512" => "__builtin_ia32_vpmadd52luq512_maskz", + "avx512.max.pd.512" => "__builtin_ia32_maxpd512", + "avx512.max.ps.512" => "__builtin_ia32_maxps512", + "avx512.min.pd.512" => "__builtin_ia32_minpd512", + "avx512.min.ps.512" => "__builtin_ia32_minps512", + "avx512.movntdqa" => "__builtin_ia32_movntdqa512", + "avx512.mul.pd.512" => "__builtin_ia32_mulpd512", + "avx512.mul.ps.512" => "__builtin_ia32_mulps512", + "avx512.packssdw.512" => "__builtin_ia32_packssdw512", + "avx512.packsswb.512" => "__builtin_ia32_packsswb512", + "avx512.packusdw.512" => "__builtin_ia32_packusdw512", + "avx512.packuswb.512" => "__builtin_ia32_packuswb512", + "avx512.pavg.b.512" => "__builtin_ia32_pavgb512", + "avx512.pavg.w.512" => "__builtin_ia32_pavgw512", + "avx512.pbroadcastd.512" => "__builtin_ia32_pbroadcastd512", + "avx512.pbroadcastq.512" => "__builtin_ia32_pbroadcastq512", + "avx512.permvar.df.256" => "__builtin_ia32_permvardf256", + "avx512.permvar.df.512" => "__builtin_ia32_permvardf512", + "avx512.permvar.di.256" => "__builtin_ia32_permvardi256", + "avx512.permvar.di.512" => "__builtin_ia32_permvardi512", + "avx512.permvar.hi.128" => "__builtin_ia32_permvarhi128", + "avx512.permvar.hi.256" => "__builtin_ia32_permvarhi256", + "avx512.permvar.hi.512" => "__builtin_ia32_permvarhi512", + "avx512.permvar.qi.128" => "__builtin_ia32_permvarqi128", + "avx512.permvar.qi.256" => "__builtin_ia32_permvarqi256", + "avx512.permvar.qi.512" => "__builtin_ia32_permvarqi512", + "avx512.permvar.sf.512" => "__builtin_ia32_permvarsf512", + "avx512.permvar.si.512" => "__builtin_ia32_permvarsi512", + "avx512.pmaddubs.w.512" => "__builtin_ia32_pmaddubsw512", + "avx512.pmaddw.d.512" => "__builtin_ia32_pmaddwd512", + "avx512.pmovzxbd" => "__builtin_ia32_pmovzxbd512", + "avx512.pmovzxbq" => "__builtin_ia32_pmovzxbq512", + "avx512.pmovzxdq" => "__builtin_ia32_pmovzxdq512", + "avx512.pmovzxwd" => "__builtin_ia32_pmovzxwd512", + "avx512.pmovzxwq" => "__builtin_ia32_pmovzxwq512", + "avx512.pmul.hr.sw.512" => "__builtin_ia32_pmulhrsw512", + "avx512.pmulh.w.512" => "__builtin_ia32_pmulhw512", + "avx512.pmulhu.w.512" => "__builtin_ia32_pmulhuw512", + "avx512.pmultishift.qb.128" => "__builtin_ia32_vpmultishiftqb128", + "avx512.pmultishift.qb.256" => "__builtin_ia32_vpmultishiftqb256", + "avx512.pmultishift.qb.512" => "__builtin_ia32_vpmultishiftqb512", + "avx512.psad.bw.512" => "__builtin_ia32_psadbw512", + "avx512.pshuf.b.512" => "__builtin_ia32_pshufb512", + "avx512.psll.d.512" => "__builtin_ia32_pslld512", + "avx512.psll.dq" => "__builtin_ia32_pslldqi512", + "avx512.psll.dq.bs" => "__builtin_ia32_pslldqi512_byteshift", + "avx512.psll.q.512" => "__builtin_ia32_psllq512", + "avx512.psll.w.512" => "__builtin_ia32_psllw512", + "avx512.pslli.d.512" => "__builtin_ia32_pslldi512", + "avx512.pslli.q.512" => "__builtin_ia32_psllqi512", + "avx512.pslli.w.512" => "__builtin_ia32_psllwi512", + "avx512.psllv.d.512" => "__builtin_ia32_psllv16si", + "avx512.psllv.q.512" => "__builtin_ia32_psllv8di", + "avx512.psllv.w.128" => "__builtin_ia32_psllv8hi", + "avx512.psllv.w.256" => "__builtin_ia32_psllv16hi", + "avx512.psllv.w.512" => "__builtin_ia32_psllv32hi", + "avx512.psra.d.512" => "__builtin_ia32_psrad512", + "avx512.psra.q.128" => "__builtin_ia32_psraq128", + "avx512.psra.q.256" => "__builtin_ia32_psraq256", + "avx512.psra.q.512" => "__builtin_ia32_psraq512", + "avx512.psra.w.512" => "__builtin_ia32_psraw512", + "avx512.psrai.d.512" => "__builtin_ia32_psradi512", + "avx512.psrai.q.128" => "__builtin_ia32_psraqi128", + "avx512.psrai.q.256" => "__builtin_ia32_psraqi256", + "avx512.psrai.q.512" => "__builtin_ia32_psraqi512", + "avx512.psrai.w.512" => "__builtin_ia32_psrawi512", + "avx512.psrav.d.512" => "__builtin_ia32_psrav16si", + "avx512.psrav.q.128" => "__builtin_ia32_psravq128", + "avx512.psrav.q.256" => "__builtin_ia32_psravq256", + "avx512.psrav.q.512" => "__builtin_ia32_psrav8di", + "avx512.psrav.w.128" => "__builtin_ia32_psrav8hi", + "avx512.psrav.w.256" => "__builtin_ia32_psrav16hi", + "avx512.psrav.w.512" => "__builtin_ia32_psrav32hi", + "avx512.psrl.d.512" => "__builtin_ia32_psrld512", + "avx512.psrl.dq" => "__builtin_ia32_psrldqi512", + "avx512.psrl.dq.bs" => "__builtin_ia32_psrldqi512_byteshift", + "avx512.psrl.q.512" => "__builtin_ia32_psrlq512", + "avx512.psrl.w.512" => "__builtin_ia32_psrlw512", + "avx512.psrli.d.512" => "__builtin_ia32_psrldi512", + "avx512.psrli.q.512" => "__builtin_ia32_psrlqi512", + "avx512.psrli.w.512" => "__builtin_ia32_psrlwi512", + "avx512.psrlv.d.512" => "__builtin_ia32_psrlv16si", + "avx512.psrlv.q.512" => "__builtin_ia32_psrlv8di", + "avx512.psrlv.w.128" => "__builtin_ia32_psrlv8hi", + "avx512.psrlv.w.256" => "__builtin_ia32_psrlv16hi", + "avx512.psrlv.w.512" => "__builtin_ia32_psrlv32hi", + "avx512.pternlog.d.128" => "__builtin_ia32_pternlogd128", + "avx512.pternlog.d.256" => "__builtin_ia32_pternlogd256", + "avx512.pternlog.d.512" => "__builtin_ia32_pternlogd512", + "avx512.pternlog.q.128" => "__builtin_ia32_pternlogq128", + "avx512.pternlog.q.256" => "__builtin_ia32_pternlogq256", + "avx512.pternlog.q.512" => "__builtin_ia32_pternlogq512", + "avx512.ptestm.b.128" => "__builtin_ia32_ptestmb128", + "avx512.ptestm.b.256" => "__builtin_ia32_ptestmb256", + "avx512.ptestm.b.512" => "__builtin_ia32_ptestmb512", + "avx512.ptestm.d.128" => "__builtin_ia32_ptestmd128", + "avx512.ptestm.d.256" => "__builtin_ia32_ptestmd256", + "avx512.ptestm.d.512" => "__builtin_ia32_ptestmd512", + "avx512.ptestm.q.128" => "__builtin_ia32_ptestmq128", + "avx512.ptestm.q.256" => "__builtin_ia32_ptestmq256", + "avx512.ptestm.q.512" => "__builtin_ia32_ptestmq512", + "avx512.ptestm.w.128" => "__builtin_ia32_ptestmw128", + "avx512.ptestm.w.256" => "__builtin_ia32_ptestmw256", + "avx512.ptestm.w.512" => "__builtin_ia32_ptestmw512", + "avx512.ptestnm.b.128" => "__builtin_ia32_ptestnmb128", + "avx512.ptestnm.b.256" => "__builtin_ia32_ptestnmb256", + "avx512.ptestnm.b.512" => "__builtin_ia32_ptestnmb512", + "avx512.ptestnm.d.128" => "__builtin_ia32_ptestnmd128", + "avx512.ptestnm.d.256" => "__builtin_ia32_ptestnmd256", + "avx512.ptestnm.d.512" => "__builtin_ia32_ptestnmd512", + "avx512.ptestnm.q.128" => "__builtin_ia32_ptestnmq128", + "avx512.ptestnm.q.256" => "__builtin_ia32_ptestnmq256", + "avx512.ptestnm.q.512" => "__builtin_ia32_ptestnmq512", + "avx512.ptestnm.w.128" => "__builtin_ia32_ptestnmw128", + "avx512.ptestnm.w.256" => "__builtin_ia32_ptestnmw256", + "avx512.ptestnm.w.512" => "__builtin_ia32_ptestnmw512", + "avx512.rcp14.pd.128" => "__builtin_ia32_rcp14pd128_mask", + "avx512.rcp14.pd.256" => "__builtin_ia32_rcp14pd256_mask", + "avx512.rcp14.pd.512" => "__builtin_ia32_rcp14pd512_mask", + "avx512.rcp14.ps.128" => "__builtin_ia32_rcp14ps128_mask", + "avx512.rcp14.ps.256" => "__builtin_ia32_rcp14ps256_mask", + "avx512.rcp14.ps.512" => "__builtin_ia32_rcp14ps512_mask", + "avx512.rcp14.sd" => "__builtin_ia32_rcp14sd_mask", + "avx512.rcp14.ss" => "__builtin_ia32_rcp14ss_mask", + "avx512.rcp28.pd" => "__builtin_ia32_rcp28pd_mask", + "avx512.rcp28.ps" => "__builtin_ia32_rcp28ps_mask", + "avx512.rcp28.sd" => "__builtin_ia32_rcp28sd_mask", + // [DUPLICATE]: "avx512.rcp28.sd" => "__builtin_ia32_rcp28sd_round_mask", + "avx512.rcp28.ss" => "__builtin_ia32_rcp28ss_mask", + // [DUPLICATE]: "avx512.rcp28.ss" => "__builtin_ia32_rcp28ss_round_mask", + "avx512.rndscale.sd" => "__builtin_ia32_rndscalesd", + "avx512.rndscale.ss" => "__builtin_ia32_rndscaless", + "avx512.rsqrt14.pd.128" => "__builtin_ia32_rsqrt14pd128_mask", + "avx512.rsqrt14.pd.256" => "__builtin_ia32_rsqrt14pd256_mask", + "avx512.rsqrt14.pd.512" => "__builtin_ia32_rsqrt14pd512_mask", + "avx512.rsqrt14.ps.128" => "__builtin_ia32_rsqrt14ps128_mask", + "avx512.rsqrt14.ps.256" => "__builtin_ia32_rsqrt14ps256_mask", + "avx512.rsqrt14.ps.512" => "__builtin_ia32_rsqrt14ps512_mask", + "avx512.rsqrt14.sd" => "__builtin_ia32_rsqrt14sd_mask", + "avx512.rsqrt14.ss" => "__builtin_ia32_rsqrt14ss_mask", + "avx512.rsqrt28.pd" => "__builtin_ia32_rsqrt28pd_mask", + "avx512.rsqrt28.ps" => "__builtin_ia32_rsqrt28ps_mask", + "avx512.rsqrt28.sd" => "__builtin_ia32_rsqrt28sd_mask", + // [DUPLICATE]: "avx512.rsqrt28.sd" => "__builtin_ia32_rsqrt28sd_round_mask", + "avx512.rsqrt28.ss" => "__builtin_ia32_rsqrt28ss_mask", + // [DUPLICATE]: "avx512.rsqrt28.ss" => "__builtin_ia32_rsqrt28ss_round_mask", + "avx512.scatter.dpd.512" => "__builtin_ia32_scattersiv8df", + "avx512.scatter.dpi.512" => "__builtin_ia32_scattersiv16si", + "avx512.scatter.dpq.512" => "__builtin_ia32_scattersiv8di", + "avx512.scatter.dps.512" => "__builtin_ia32_scattersiv16sf", + "avx512.scatter.qpd.512" => "__builtin_ia32_scatterdiv8df", + "avx512.scatter.qpi.512" => "__builtin_ia32_scatterdiv16si", + "avx512.scatter.qpq.512" => "__builtin_ia32_scatterdiv8di", + "avx512.scatter.qps.512" => "__builtin_ia32_scatterdiv16sf", + "avx512.scatterdiv2.df" => "__builtin_ia32_scatterdiv2df", + "avx512.scatterdiv2.di" => "__builtin_ia32_scatterdiv2di", + "avx512.scatterdiv4.df" => "__builtin_ia32_scatterdiv4df", + "avx512.scatterdiv4.di" => "__builtin_ia32_scatterdiv4di", + "avx512.scatterdiv4.sf" => "__builtin_ia32_scatterdiv4sf", + "avx512.scatterdiv4.si" => "__builtin_ia32_scatterdiv4si", + "avx512.scatterdiv8.sf" => "__builtin_ia32_scatterdiv8sf", + "avx512.scatterdiv8.si" => "__builtin_ia32_scatterdiv8si", + "avx512.scatterpf.dpd.512" => "__builtin_ia32_scatterpfdpd", + "avx512.scatterpf.dps.512" => "__builtin_ia32_scatterpfdps", + "avx512.scatterpf.qpd.512" => "__builtin_ia32_scatterpfqpd", + "avx512.scatterpf.qps.512" => "__builtin_ia32_scatterpfqps", + "avx512.scattersiv2.df" => "__builtin_ia32_scattersiv2df", + "avx512.scattersiv2.di" => "__builtin_ia32_scattersiv2di", + "avx512.scattersiv4.df" => "__builtin_ia32_scattersiv4df", + "avx512.scattersiv4.di" => "__builtin_ia32_scattersiv4di", + "avx512.scattersiv4.sf" => "__builtin_ia32_scattersiv4sf", + "avx512.scattersiv4.si" => "__builtin_ia32_scattersiv4si", + "avx512.scattersiv8.sf" => "__builtin_ia32_scattersiv8sf", + "avx512.scattersiv8.si" => "__builtin_ia32_scattersiv8si", + "avx512.sqrt.pd.512" => "__builtin_ia32_sqrtpd512_mask", + "avx512.sqrt.ps.512" => "__builtin_ia32_sqrtps512_mask", + "avx512.sqrt.sd" => "__builtin_ia32_sqrtrndsd", + "avx512.sqrt.ss" => "__builtin_ia32_sqrtrndss", + "avx512.sub.pd.512" => "__builtin_ia32_subpd512", + "avx512.sub.ps.512" => "__builtin_ia32_subps512", + "avx512.vbroadcast.sd.512" => "__builtin_ia32_vbroadcastsd512", + "avx512.vbroadcast.sd.pd.512" => "__builtin_ia32_vbroadcastsd_pd512", + "avx512.vbroadcast.ss.512" => "__builtin_ia32_vbroadcastss512", + "avx512.vbroadcast.ss.ps.512" => "__builtin_ia32_vbroadcastss_ps512", + "avx512.vcomi.sd" => "__builtin_ia32_vcomisd", + "avx512.vcomi.ss" => "__builtin_ia32_vcomiss", + "avx512.vcvtsd2si32" => "__builtin_ia32_vcvtsd2si32", + "avx512.vcvtsd2si64" => "__builtin_ia32_vcvtsd2si64", + "avx512.vcvtsd2usi32" => "__builtin_ia32_vcvtsd2usi32", + "avx512.vcvtsd2usi64" => "__builtin_ia32_vcvtsd2usi64", + "avx512.vcvtss2si32" => "__builtin_ia32_vcvtss2si32", + "avx512.vcvtss2si64" => "__builtin_ia32_vcvtss2si64", + "avx512.vcvtss2usi32" => "__builtin_ia32_vcvtss2usi32", + "avx512.vcvtss2usi64" => "__builtin_ia32_vcvtss2usi64", + "avx512.vpdpbusd.128" => "__builtin_ia32_vpdpbusd128", + "avx512.vpdpbusd.256" => "__builtin_ia32_vpdpbusd256", + "avx512.vpdpbusd.512" => "__builtin_ia32_vpdpbusd512", + "avx512.vpdpbusds.128" => "__builtin_ia32_vpdpbusds128", + "avx512.vpdpbusds.256" => "__builtin_ia32_vpdpbusds256", + "avx512.vpdpbusds.512" => "__builtin_ia32_vpdpbusds512", + "avx512.vpdpwssd.128" => "__builtin_ia32_vpdpwssd128", + "avx512.vpdpwssd.256" => "__builtin_ia32_vpdpwssd256", + "avx512.vpdpwssd.512" => "__builtin_ia32_vpdpwssd512", + "avx512.vpdpwssds.128" => "__builtin_ia32_vpdpwssds128", + "avx512.vpdpwssds.256" => "__builtin_ia32_vpdpwssds256", + "avx512.vpdpwssds.512" => "__builtin_ia32_vpdpwssds512", + "avx512.vpermi2var.d.128" => "__builtin_ia32_vpermi2vard128", + "avx512.vpermi2var.d.256" => "__builtin_ia32_vpermi2vard256", + "avx512.vpermi2var.d.512" => "__builtin_ia32_vpermi2vard512", + "avx512.vpermi2var.hi.128" => "__builtin_ia32_vpermi2varhi128", + "avx512.vpermi2var.hi.256" => "__builtin_ia32_vpermi2varhi256", + "avx512.vpermi2var.hi.512" => "__builtin_ia32_vpermi2varhi512", + "avx512.vpermi2var.pd.128" => "__builtin_ia32_vpermi2varpd128", + "avx512.vpermi2var.pd.256" => "__builtin_ia32_vpermi2varpd256", + "avx512.vpermi2var.pd.512" => "__builtin_ia32_vpermi2varpd512", + "avx512.vpermi2var.ps.128" => "__builtin_ia32_vpermi2varps128", + "avx512.vpermi2var.ps.256" => "__builtin_ia32_vpermi2varps256", + "avx512.vpermi2var.ps.512" => "__builtin_ia32_vpermi2varps512", + "avx512.vpermi2var.q.128" => "__builtin_ia32_vpermi2varq128", + "avx512.vpermi2var.q.256" => "__builtin_ia32_vpermi2varq256", + "avx512.vpermi2var.q.512" => "__builtin_ia32_vpermi2varq512", + "avx512.vpermi2var.qi.128" => "__builtin_ia32_vpermi2varqi128", + "avx512.vpermi2var.qi.256" => "__builtin_ia32_vpermi2varqi256", + "avx512.vpermi2var.qi.512" => "__builtin_ia32_vpermi2varqi512", + "avx512.vpermilvar.pd.512" => "__builtin_ia32_vpermilvarpd512", + "avx512.vpermilvar.ps.512" => "__builtin_ia32_vpermilvarps512", + "avx512.vpmadd52h.uq.128" => "__builtin_ia32_vpmadd52huq128", + "avx512.vpmadd52h.uq.256" => "__builtin_ia32_vpmadd52huq256", + "avx512.vpmadd52h.uq.512" => "__builtin_ia32_vpmadd52huq512", + "avx512.vpmadd52l.uq.128" => "__builtin_ia32_vpmadd52luq128", + "avx512.vpmadd52l.uq.256" => "__builtin_ia32_vpmadd52luq256", + "avx512.vpmadd52l.uq.512" => "__builtin_ia32_vpmadd52luq512", + "avx512bf16.cvtne2ps2bf16.128" => "__builtin_ia32_cvtne2ps2bf16_128", + "avx512bf16.cvtne2ps2bf16.256" => "__builtin_ia32_cvtne2ps2bf16_256", + "avx512bf16.cvtne2ps2bf16.512" => "__builtin_ia32_cvtne2ps2bf16_512", + "avx512bf16.cvtneps2bf16.256" => "__builtin_ia32_cvtneps2bf16_256", + "avx512bf16.cvtneps2bf16.512" => "__builtin_ia32_cvtneps2bf16_512", + "avx512bf16.dpbf16ps.128" => "__builtin_ia32_dpbf16ps_128", + "avx512bf16.dpbf16ps.256" => "__builtin_ia32_dpbf16ps_256", + "avx512bf16.dpbf16ps.512" => "__builtin_ia32_dpbf16ps_512", + "avx512fp16.add.ph.512" => "__builtin_ia32_addph512", + "avx512fp16.div.ph.512" => "__builtin_ia32_divph512", + // [INVALID CONVERSION]: "avx512fp16.mask.add.sh.round" => "__builtin_ia32_addsh_round_mask", + "avx512fp16.mask.cmp.sh" => "__builtin_ia32_cmpsh_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.div.sh.round" => "__builtin_ia32_divsh_round_mask", + "avx512fp16.mask.fpclass.sh" => "__builtin_ia32_fpclasssh_mask", + "avx512fp16.mask.getexp.ph.128" => "__builtin_ia32_getexpph128_mask", + "avx512fp16.mask.getexp.ph.256" => "__builtin_ia32_getexpph256_mask", + "avx512fp16.mask.getexp.ph.512" => "__builtin_ia32_getexpph512_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.getexp.sh" => "__builtin_ia32_getexpsh128_round_mask", + "avx512fp16.mask.getmant.ph.128" => "__builtin_ia32_getmantph128_mask", + "avx512fp16.mask.getmant.ph.256" => "__builtin_ia32_getmantph256_mask", + "avx512fp16.mask.getmant.ph.512" => "__builtin_ia32_getmantph512_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.getmant.sh" => "__builtin_ia32_getmantsh_round_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.max.sh.round" => "__builtin_ia32_maxsh_round_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.min.sh.round" => "__builtin_ia32_minsh_round_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.mul.sh.round" => "__builtin_ia32_mulsh_round_mask", + "avx512fp16.mask.rcp.ph.128" => "__builtin_ia32_rcpph128_mask", + "avx512fp16.mask.rcp.ph.256" => "__builtin_ia32_rcpph256_mask", + "avx512fp16.mask.rcp.ph.512" => "__builtin_ia32_rcpph512_mask", + "avx512fp16.mask.rcp.sh" => "__builtin_ia32_rcpsh_mask", + "avx512fp16.mask.reduce.ph.128" => "__builtin_ia32_reduceph128_mask", + "avx512fp16.mask.reduce.ph.256" => "__builtin_ia32_reduceph256_mask", + "avx512fp16.mask.reduce.ph.512" => "__builtin_ia32_reduceph512_mask", + "avx512fp16.mask.reduce.sh" => "__builtin_ia32_reducesh_mask", + "avx512fp16.mask.rndscale.ph.128" => "__builtin_ia32_rndscaleph_128_mask", + "avx512fp16.mask.rndscale.ph.256" => "__builtin_ia32_rndscaleph_256_mask", + "avx512fp16.mask.rndscale.ph.512" => "__builtin_ia32_rndscaleph_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.rndscale.sh" => "__builtin_ia32_rndscalesh_round_mask", + "avx512fp16.mask.rsqrt.ph.128" => "__builtin_ia32_rsqrtph128_mask", + "avx512fp16.mask.rsqrt.ph.256" => "__builtin_ia32_rsqrtph256_mask", + "avx512fp16.mask.rsqrt.ph.512" => "__builtin_ia32_rsqrtph512_mask", + "avx512fp16.mask.rsqrt.sh" => "__builtin_ia32_rsqrtsh_mask", + "avx512fp16.mask.scalef.ph.128" => "__builtin_ia32_scalefph128_mask", + "avx512fp16.mask.scalef.ph.256" => "__builtin_ia32_scalefph256_mask", + "avx512fp16.mask.scalef.ph.512" => "__builtin_ia32_scalefph512_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.scalef.sh" => "__builtin_ia32_scalefsh_round_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.sub.sh.round" => "__builtin_ia32_subsh_round_mask", + "avx512fp16.mask.vcvtdq2ph.128" => "__builtin_ia32_vcvtdq2ph128_mask", + "avx512fp16.mask.vcvtpd2ph.128" => "__builtin_ia32_vcvtpd2ph128_mask", + "avx512fp16.mask.vcvtpd2ph.256" => "__builtin_ia32_vcvtpd2ph256_mask", + "avx512fp16.mask.vcvtpd2ph.512" => "__builtin_ia32_vcvtpd2ph512_mask", + "avx512fp16.mask.vcvtph2dq.128" => "__builtin_ia32_vcvtph2dq128_mask", + "avx512fp16.mask.vcvtph2dq.256" => "__builtin_ia32_vcvtph2dq256_mask", + "avx512fp16.mask.vcvtph2dq.512" => "__builtin_ia32_vcvtph2dq512_mask", + "avx512fp16.mask.vcvtph2pd.128" => "__builtin_ia32_vcvtph2pd128_mask", + "avx512fp16.mask.vcvtph2pd.256" => "__builtin_ia32_vcvtph2pd256_mask", + "avx512fp16.mask.vcvtph2pd.512" => "__builtin_ia32_vcvtph2pd512_mask", + "avx512fp16.mask.vcvtph2psx.128" => "__builtin_ia32_vcvtph2psx128_mask", + "avx512fp16.mask.vcvtph2psx.256" => "__builtin_ia32_vcvtph2psx256_mask", + "avx512fp16.mask.vcvtph2psx.512" => "__builtin_ia32_vcvtph2psx512_mask", + "avx512fp16.mask.vcvtph2qq.128" => "__builtin_ia32_vcvtph2qq128_mask", + "avx512fp16.mask.vcvtph2qq.256" => "__builtin_ia32_vcvtph2qq256_mask", + "avx512fp16.mask.vcvtph2qq.512" => "__builtin_ia32_vcvtph2qq512_mask", + "avx512fp16.mask.vcvtph2udq.128" => "__builtin_ia32_vcvtph2udq128_mask", + "avx512fp16.mask.vcvtph2udq.256" => "__builtin_ia32_vcvtph2udq256_mask", + "avx512fp16.mask.vcvtph2udq.512" => "__builtin_ia32_vcvtph2udq512_mask", + "avx512fp16.mask.vcvtph2uqq.128" => "__builtin_ia32_vcvtph2uqq128_mask", + "avx512fp16.mask.vcvtph2uqq.256" => "__builtin_ia32_vcvtph2uqq256_mask", + "avx512fp16.mask.vcvtph2uqq.512" => "__builtin_ia32_vcvtph2uqq512_mask", + "avx512fp16.mask.vcvtph2uw.128" => "__builtin_ia32_vcvtph2uw128_mask", + "avx512fp16.mask.vcvtph2uw.256" => "__builtin_ia32_vcvtph2uw256_mask", + "avx512fp16.mask.vcvtph2uw.512" => "__builtin_ia32_vcvtph2uw512_mask", + "avx512fp16.mask.vcvtph2w.128" => "__builtin_ia32_vcvtph2w128_mask", + "avx512fp16.mask.vcvtph2w.256" => "__builtin_ia32_vcvtph2w256_mask", + "avx512fp16.mask.vcvtph2w.512" => "__builtin_ia32_vcvtph2w512_mask", + "avx512fp16.mask.vcvtps2phx.128" => "__builtin_ia32_vcvtps2phx128_mask", + "avx512fp16.mask.vcvtps2phx.256" => "__builtin_ia32_vcvtps2phx256_mask", + "avx512fp16.mask.vcvtps2phx.512" => "__builtin_ia32_vcvtps2phx512_mask", + "avx512fp16.mask.vcvtqq2ph.128" => "__builtin_ia32_vcvtqq2ph128_mask", + "avx512fp16.mask.vcvtqq2ph.256" => "__builtin_ia32_vcvtqq2ph256_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.vcvtsd2sh.round" => "__builtin_ia32_vcvtsd2sh_round_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.vcvtsh2sd.round" => "__builtin_ia32_vcvtsh2sd_round_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.vcvtsh2ss.round" => "__builtin_ia32_vcvtsh2ss_round_mask", + // [INVALID CONVERSION]: "avx512fp16.mask.vcvtss2sh.round" => "__builtin_ia32_vcvtss2sh_round_mask", + "avx512fp16.mask.vcvttph2dq.128" => "__builtin_ia32_vcvttph2dq128_mask", + "avx512fp16.mask.vcvttph2dq.256" => "__builtin_ia32_vcvttph2dq256_mask", + "avx512fp16.mask.vcvttph2dq.512" => "__builtin_ia32_vcvttph2dq512_mask", + "avx512fp16.mask.vcvttph2qq.128" => "__builtin_ia32_vcvttph2qq128_mask", + "avx512fp16.mask.vcvttph2qq.256" => "__builtin_ia32_vcvttph2qq256_mask", + "avx512fp16.mask.vcvttph2qq.512" => "__builtin_ia32_vcvttph2qq512_mask", + "avx512fp16.mask.vcvttph2udq.128" => "__builtin_ia32_vcvttph2udq128_mask", + "avx512fp16.mask.vcvttph2udq.256" => "__builtin_ia32_vcvttph2udq256_mask", + "avx512fp16.mask.vcvttph2udq.512" => "__builtin_ia32_vcvttph2udq512_mask", + "avx512fp16.mask.vcvttph2uqq.128" => "__builtin_ia32_vcvttph2uqq128_mask", + "avx512fp16.mask.vcvttph2uqq.256" => "__builtin_ia32_vcvttph2uqq256_mask", + "avx512fp16.mask.vcvttph2uqq.512" => "__builtin_ia32_vcvttph2uqq512_mask", + "avx512fp16.mask.vcvttph2uw.128" => "__builtin_ia32_vcvttph2uw128_mask", + "avx512fp16.mask.vcvttph2uw.256" => "__builtin_ia32_vcvttph2uw256_mask", + "avx512fp16.mask.vcvttph2uw.512" => "__builtin_ia32_vcvttph2uw512_mask", + "avx512fp16.mask.vcvttph2w.128" => "__builtin_ia32_vcvttph2w128_mask", + "avx512fp16.mask.vcvttph2w.256" => "__builtin_ia32_vcvttph2w256_mask", + "avx512fp16.mask.vcvttph2w.512" => "__builtin_ia32_vcvttph2w512_mask", + "avx512fp16.mask.vcvtudq2ph.128" => "__builtin_ia32_vcvtudq2ph128_mask", + "avx512fp16.mask.vcvtuqq2ph.128" => "__builtin_ia32_vcvtuqq2ph128_mask", + "avx512fp16.mask.vcvtuqq2ph.256" => "__builtin_ia32_vcvtuqq2ph256_mask", + "avx512fp16.mask.vfcmadd.cph.128" => "__builtin_ia32_vfcmaddcph128_mask", + "avx512fp16.mask.vfcmadd.cph.256" => "__builtin_ia32_vfcmaddcph256_mask", + "avx512fp16.mask.vfcmadd.cph.512" => "__builtin_ia32_vfcmaddcph512_mask3", + "avx512fp16.mask.vfcmadd.csh" => "__builtin_ia32_vfcmaddcsh_mask", + "avx512fp16.mask.vfcmul.cph.128" => "__builtin_ia32_vfcmulcph128_mask", + "avx512fp16.mask.vfcmul.cph.256" => "__builtin_ia32_vfcmulcph256_mask", + "avx512fp16.mask.vfcmul.cph.512" => "__builtin_ia32_vfcmulcph512_mask", + "avx512fp16.mask.vfcmul.csh" => "__builtin_ia32_vfcmulcsh_mask", + "avx512fp16.mask.vfmadd.cph.128" => "__builtin_ia32_vfmaddcph128_mask", + "avx512fp16.mask.vfmadd.cph.256" => "__builtin_ia32_vfmaddcph256_mask", + "avx512fp16.mask.vfmadd.cph.512" => "__builtin_ia32_vfmaddcph512_mask3", + "avx512fp16.mask.vfmadd.csh" => "__builtin_ia32_vfmaddcsh_mask", + "avx512fp16.mask.vfmul.cph.128" => "__builtin_ia32_vfmulcph128_mask", + "avx512fp16.mask.vfmul.cph.256" => "__builtin_ia32_vfmulcph256_mask", + "avx512fp16.mask.vfmul.cph.512" => "__builtin_ia32_vfmulcph512_mask", + "avx512fp16.mask.vfmul.csh" => "__builtin_ia32_vfmulcsh_mask", + "avx512fp16.maskz.vfcmadd.cph.128" => "__builtin_ia32_vfcmaddcph128_maskz", + "avx512fp16.maskz.vfcmadd.cph.256" => "__builtin_ia32_vfcmaddcph256_maskz", + "avx512fp16.maskz.vfcmadd.cph.512" => "__builtin_ia32_vfcmaddcph512_maskz", + "avx512fp16.maskz.vfcmadd.csh" => "__builtin_ia32_vfcmaddcsh_maskz", + "avx512fp16.maskz.vfmadd.cph.128" => "__builtin_ia32_vfmaddcph128_maskz", + "avx512fp16.maskz.vfmadd.cph.256" => "__builtin_ia32_vfmaddcph256_maskz", + "avx512fp16.maskz.vfmadd.cph.512" => "__builtin_ia32_vfmaddcph512_maskz", + "avx512fp16.maskz.vfmadd.csh" => "__builtin_ia32_vfmaddcsh_maskz", + "avx512fp16.max.ph.128" => "__builtin_ia32_maxph128", + "avx512fp16.max.ph.256" => "__builtin_ia32_maxph256", + "avx512fp16.max.ph.512" => "__builtin_ia32_maxph512", + "avx512fp16.min.ph.128" => "__builtin_ia32_minph128", + "avx512fp16.min.ph.256" => "__builtin_ia32_minph256", + "avx512fp16.min.ph.512" => "__builtin_ia32_minph512", + "avx512fp16.mul.ph.512" => "__builtin_ia32_mulph512", + "avx512fp16.sub.ph.512" => "__builtin_ia32_subph512", + "avx512fp16.vcomi.sh" => "__builtin_ia32_vcomish", + "avx512fp16.vcvtsh2si32" => "__builtin_ia32_vcvtsh2si32", + "avx512fp16.vcvtsh2si64" => "__builtin_ia32_vcvtsh2si64", + "avx512fp16.vcvtsh2usi32" => "__builtin_ia32_vcvtsh2usi32", + "avx512fp16.vcvtsh2usi64" => "__builtin_ia32_vcvtsh2usi64", + "avx512fp16.vcvtsi2sh" => "__builtin_ia32_vcvtsi2sh", + "avx512fp16.vcvtsi642sh" => "__builtin_ia32_vcvtsi642sh", + "avx512fp16.vcvttsh2si32" => "__builtin_ia32_vcvttsh2si32", + "avx512fp16.vcvttsh2si64" => "__builtin_ia32_vcvttsh2si64", + "avx512fp16.vcvttsh2usi32" => "__builtin_ia32_vcvttsh2usi32", + "avx512fp16.vcvttsh2usi64" => "__builtin_ia32_vcvttsh2usi64", + "avx512fp16.vcvtusi2sh" => "__builtin_ia32_vcvtusi2sh", + "avx512fp16.vcvtusi642sh" => "__builtin_ia32_vcvtusi642sh", + "avx512fp16.vfmaddsub.ph.128" => "__builtin_ia32_vfmaddsubph", + "avx512fp16.vfmaddsub.ph.256" => "__builtin_ia32_vfmaddsubph256", + "axor32" => "__builtin_ia32_axor32", + "axor64" => "__builtin_ia32_axor64", + "bmi.bextr.32" => "__builtin_ia32_bextr_u32", + "bmi.bextr.64" => "__builtin_ia32_bextr_u64", + "bmi.bzhi.32" => "__builtin_ia32_bzhi_si", + "bmi.bzhi.64" => "__builtin_ia32_bzhi_di", + "bmi.pdep.32" => "__builtin_ia32_pdep_si", + "bmi.pdep.64" => "__builtin_ia32_pdep_di", + "bmi.pext.32" => "__builtin_ia32_pext_si", + "bmi.pext.64" => "__builtin_ia32_pext_di", + "cldemote" => "__builtin_ia32_cldemote", + "clflushopt" => "__builtin_ia32_clflushopt", + "clrssbsy" => "__builtin_ia32_clrssbsy", + "clui" => "__builtin_ia32_clui", + "clwb" => "__builtin_ia32_clwb", + "clzero" => "__builtin_ia32_clzero", + "cmpccxadd32" => "__builtin_ia32_cmpccxadd32", + "cmpccxadd64" => "__builtin_ia32_cmpccxadd64", + "directstore32" => "__builtin_ia32_directstore_u32", + "directstore64" => "__builtin_ia32_directstore_u64", + "enqcmd" => "__builtin_ia32_enqcmd", + "enqcmds" => "__builtin_ia32_enqcmds", + "flags.read.u32" => "__builtin_ia32_readeflags_u32", + "flags.read.u64" => "__builtin_ia32_readeflags_u64", + "flags.write.u32" => "__builtin_ia32_writeeflags_u32", + "flags.write.u64" => "__builtin_ia32_writeeflags_u64", + "fma.mask.vfmadd.pd.512" => "__builtin_ia32_vfmaddpd512_mask", + "fma.mask.vfmadd.ps.512" => "__builtin_ia32_vfmaddps512_mask", + "fma.mask.vfmaddsub.pd.512" => "__builtin_ia32_vfmaddsubpd512_mask", + "fma.mask.vfmaddsub.ps.512" => "__builtin_ia32_vfmaddsubps512_mask", + "fma.mask.vfmsub.pd.512" => "__builtin_ia32_vfmsubpd512_mask", + "fma.mask.vfmsub.ps.512" => "__builtin_ia32_vfmsubps512_mask", + "fma.mask.vfmsubadd.pd.512" => "__builtin_ia32_vfmsubaddpd512_mask", + "fma.mask.vfmsubadd.ps.512" => "__builtin_ia32_vfmsubaddps512_mask", + "fma.mask.vfnmadd.pd.512" => "__builtin_ia32_vfnmaddpd512_mask", + "fma.mask.vfnmadd.ps.512" => "__builtin_ia32_vfnmaddps512_mask", + "fma.mask.vfnmsub.pd.512" => "__builtin_ia32_vfnmsubpd512_mask", + "fma.mask.vfnmsub.ps.512" => "__builtin_ia32_vfnmsubps512_mask", + "fma.vfmadd.pd" => "__builtin_ia32_vfmaddpd", + "fma.vfmadd.pd.256" => "__builtin_ia32_vfmaddpd256", + "fma.vfmadd.ps" => "__builtin_ia32_vfmaddps", + "fma.vfmadd.ps.256" => "__builtin_ia32_vfmaddps256", + "fma.vfmadd.sd" => "__builtin_ia32_vfmaddsd", + "fma.vfmadd.ss" => "__builtin_ia32_vfmaddss", + "fma.vfmaddsub.pd" => "__builtin_ia32_vfmaddsubpd", + "fma.vfmaddsub.pd.256" => "__builtin_ia32_vfmaddsubpd256", + "fma.vfmaddsub.ps" => "__builtin_ia32_vfmaddsubps", + "fma.vfmaddsub.ps.256" => "__builtin_ia32_vfmaddsubps256", + "fma.vfmsub.pd" => "__builtin_ia32_vfmsubpd", + "fma.vfmsub.pd.256" => "__builtin_ia32_vfmsubpd256", + "fma.vfmsub.ps" => "__builtin_ia32_vfmsubps", + "fma.vfmsub.ps.256" => "__builtin_ia32_vfmsubps256", + "fma.vfmsub.sd" => "__builtin_ia32_vfmsubsd", + "fma.vfmsub.ss" => "__builtin_ia32_vfmsubss", + "fma.vfmsubadd.pd" => "__builtin_ia32_vfmsubaddpd", + "fma.vfmsubadd.pd.256" => "__builtin_ia32_vfmsubaddpd256", + "fma.vfmsubadd.ps" => "__builtin_ia32_vfmsubaddps", + "fma.vfmsubadd.ps.256" => "__builtin_ia32_vfmsubaddps256", + "fma.vfnmadd.pd" => "__builtin_ia32_vfnmaddpd", + "fma.vfnmadd.pd.256" => "__builtin_ia32_vfnmaddpd256", + "fma.vfnmadd.ps" => "__builtin_ia32_vfnmaddps", + "fma.vfnmadd.ps.256" => "__builtin_ia32_vfnmaddps256", + "fma.vfnmadd.sd" => "__builtin_ia32_vfnmaddsd", + "fma.vfnmadd.ss" => "__builtin_ia32_vfnmaddss", + "fma.vfnmsub.pd" => "__builtin_ia32_vfnmsubpd", + "fma.vfnmsub.pd.256" => "__builtin_ia32_vfnmsubpd256", + "fma.vfnmsub.ps" => "__builtin_ia32_vfnmsubps", + "fma.vfnmsub.ps.256" => "__builtin_ia32_vfnmsubps256", + "fma.vfnmsub.sd" => "__builtin_ia32_vfnmsubsd", + "fma.vfnmsub.ss" => "__builtin_ia32_vfnmsubss", + "fxrstor" => "__builtin_ia32_fxrstor", + "fxrstor64" => "__builtin_ia32_fxrstor64", + "fxsave" => "__builtin_ia32_fxsave", + "fxsave64" => "__builtin_ia32_fxsave64", + "incsspd" => "__builtin_ia32_incsspd", + "incsspq" => "__builtin_ia32_incsspq", + "invpcid" => "__builtin_ia32_invpcid", + "ldtilecfg" => "__builtin_ia32_tile_loadconfig", + "ldtilecfg.internal" => "__builtin_ia32_tile_loadconfig_internal", + "llwpcb" => "__builtin_ia32_llwpcb", + "loadiwkey" => "__builtin_ia32_loadiwkey", + "lwpins32" => "__builtin_ia32_lwpins32", + "lwpins64" => "__builtin_ia32_lwpins64", + "lwpval32" => "__builtin_ia32_lwpval32", + "lwpval64" => "__builtin_ia32_lwpval64", + "mmx.emms" => "__builtin_ia32_emms", + "mmx.femms" => "__builtin_ia32_femms", + "monitorx" => "__builtin_ia32_monitorx", + "movdir64b" => "__builtin_ia32_movdir64b", + "movrsdi" => "__builtin_ia32_movrsdi", + "movrshi" => "__builtin_ia32_movrshi", + "movrsqi" => "__builtin_ia32_movrsqi", + "movrssi" => "__builtin_ia32_movrssi", + "mwaitx" => "__builtin_ia32_mwaitx", + "pclmulqdq" => "__builtin_ia32_pclmulqdq128", + "pclmulqdq.256" => "__builtin_ia32_pclmulqdq256", + "pclmulqdq.512" => "__builtin_ia32_pclmulqdq512", + "prefetchrs" => "__builtin_ia32_prefetchrs", + "ptwrite32" => "__builtin_ia32_ptwrite32", + "ptwrite64" => "__builtin_ia32_ptwrite64", + "rdfsbase.32" => "__builtin_ia32_rdfsbase32", + "rdfsbase.64" => "__builtin_ia32_rdfsbase64", + "rdgsbase.32" => "__builtin_ia32_rdgsbase32", + "rdgsbase.64" => "__builtin_ia32_rdgsbase64", + "rdpid" => "__builtin_ia32_rdpid", + "rdpkru" => "__builtin_ia32_rdpkru", + "rdpmc" => "__builtin_ia32_rdpmc", + "rdpru" => "__builtin_ia32_rdpru", + "rdsspd" => "__builtin_ia32_rdsspd", + "rdsspq" => "__builtin_ia32_rdsspq", + "rdtsc" => "__builtin_ia32_rdtsc", + "rdtscp" => "__builtin_ia32_rdtscp", + "rstorssp" => "__builtin_ia32_rstorssp", + "saveprevssp" => "__builtin_ia32_saveprevssp", + "senduipi" => "__builtin_ia32_senduipi", + "serialize" => "__builtin_ia32_serialize", + "setssbsy" => "__builtin_ia32_setssbsy", + "sha1msg1" => "__builtin_ia32_sha1msg1", + "sha1msg2" => "__builtin_ia32_sha1msg2", + "sha1nexte" => "__builtin_ia32_sha1nexte", + "sha1rnds4" => "__builtin_ia32_sha1rnds4", + "sha256msg1" => "__builtin_ia32_sha256msg1", + "sha256msg2" => "__builtin_ia32_sha256msg2", + "sha256rnds2" => "__builtin_ia32_sha256rnds2", + "slwpcb" => "__builtin_ia32_slwpcb", + "sse.add.ss" => "__builtin_ia32_addss", + "sse.cmp.ps" => "__builtin_ia32_cmpps", + "sse.cmp.ss" => "__builtin_ia32_cmpss", + "sse.comieq.ss" => "__builtin_ia32_comieq", + "sse.comige.ss" => "__builtin_ia32_comige", + "sse.comigt.ss" => "__builtin_ia32_comigt", + "sse.comile.ss" => "__builtin_ia32_comile", + "sse.comilt.ss" => "__builtin_ia32_comilt", + "sse.comineq.ss" => "__builtin_ia32_comineq", + "sse.cvtsi2ss" => "__builtin_ia32_cvtsi2ss", + "sse.cvtsi642ss" => "__builtin_ia32_cvtsi642ss", + "sse.cvtss2si" => "__builtin_ia32_cvtss2si", + "sse.cvtss2si64" => "__builtin_ia32_cvtss2si64", + "sse.cvttss2si" => "__builtin_ia32_cvttss2si", + "sse.cvttss2si64" => "__builtin_ia32_cvttss2si64", + "sse.div.ss" => "__builtin_ia32_divss", + "sse.max.ps" => "__builtin_ia32_maxps", + "sse.max.ss" => "__builtin_ia32_maxss", + "sse.min.ps" => "__builtin_ia32_minps", + "sse.min.ss" => "__builtin_ia32_minss", + "sse.movmsk.ps" => "__builtin_ia32_movmskps", + "sse.mul.ss" => "__builtin_ia32_mulss", + "sse.rcp.ps" => "__builtin_ia32_rcpps", + "sse.rcp.ss" => "__builtin_ia32_rcpss", + "sse.rsqrt.ps" => "__builtin_ia32_rsqrtps", + "sse.rsqrt.ss" => "__builtin_ia32_rsqrtss", + "sse.sfence" => "__builtin_ia32_sfence", + "sse.sqrt.ps" => "__builtin_ia32_sqrtps", + "sse.sqrt.ss" => "__builtin_ia32_sqrtss", + "sse.storeu.ps" => "__builtin_ia32_storeups", + "sse.sub.ss" => "__builtin_ia32_subss", + "sse.ucomieq.ss" => "__builtin_ia32_ucomieq", + "sse.ucomige.ss" => "__builtin_ia32_ucomige", + "sse.ucomigt.ss" => "__builtin_ia32_ucomigt", + "sse.ucomile.ss" => "__builtin_ia32_ucomile", + "sse.ucomilt.ss" => "__builtin_ia32_ucomilt", + "sse.ucomineq.ss" => "__builtin_ia32_ucomineq", + "sse2.add.sd" => "__builtin_ia32_addsd", + "sse2.clflush" => "__builtin_ia32_clflush", + "sse2.cmp.pd" => "__builtin_ia32_cmppd", + "sse2.cmp.sd" => "__builtin_ia32_cmpsd", + "sse2.comieq.sd" => "__builtin_ia32_comisdeq", + "sse2.comige.sd" => "__builtin_ia32_comisdge", + "sse2.comigt.sd" => "__builtin_ia32_comisdgt", + "sse2.comile.sd" => "__builtin_ia32_comisdle", + "sse2.comilt.sd" => "__builtin_ia32_comisdlt", + "sse2.comineq.sd" => "__builtin_ia32_comisdneq", + "sse2.cvtdq2pd" => "__builtin_ia32_cvtdq2pd", + "sse2.cvtdq2ps" => "__builtin_ia32_cvtdq2ps", + "sse2.cvtpd2dq" => "__builtin_ia32_cvtpd2dq", + "sse2.cvtpd2ps" => "__builtin_ia32_cvtpd2ps", + "sse2.cvtps2dq" => "__builtin_ia32_cvtps2dq", + "sse2.cvtps2pd" => "__builtin_ia32_cvtps2pd", + "sse2.cvtsd2si" => "__builtin_ia32_cvtsd2si", + "sse2.cvtsd2si64" => "__builtin_ia32_cvtsd2si64", + "sse2.cvtsd2ss" => "__builtin_ia32_cvtsd2ss", + "sse2.cvtsi2sd" => "__builtin_ia32_cvtsi2sd", + "sse2.cvtsi642sd" => "__builtin_ia32_cvtsi642sd", + "sse2.cvtss2sd" => "__builtin_ia32_cvtss2sd", + "sse2.cvttpd2dq" => "__builtin_ia32_cvttpd2dq", + "sse2.cvttps2dq" => "__builtin_ia32_cvttps2dq", + "sse2.cvttsd2si" => "__builtin_ia32_cvttsd2si", + "sse2.cvttsd2si64" => "__builtin_ia32_cvttsd2si64", + "sse2.div.sd" => "__builtin_ia32_divsd", + "sse2.lfence" => "__builtin_ia32_lfence", + "sse2.maskmov.dqu" => "__builtin_ia32_maskmovdqu", + "sse2.max.pd" => "__builtin_ia32_maxpd", + "sse2.max.sd" => "__builtin_ia32_maxsd", + "sse2.mfence" => "__builtin_ia32_mfence", + "sse2.min.pd" => "__builtin_ia32_minpd", + "sse2.min.sd" => "__builtin_ia32_minsd", + "sse2.movmsk.pd" => "__builtin_ia32_movmskpd", + "sse2.mul.sd" => "__builtin_ia32_mulsd", + "sse2.packssdw.128" => "__builtin_ia32_packssdw128", + "sse2.packsswb.128" => "__builtin_ia32_packsswb128", + "sse2.packuswb.128" => "__builtin_ia32_packuswb128", + "sse2.padds.b" => "__builtin_ia32_paddsb128", + "sse2.padds.w" => "__builtin_ia32_paddsw128", + "sse2.paddus.b" => "__builtin_ia32_paddusb128", + "sse2.paddus.w" => "__builtin_ia32_paddusw128", + "sse2.pause" => "__builtin_ia32_pause", + "sse2.pavg.b" => "__builtin_ia32_pavgb128", + "sse2.pavg.w" => "__builtin_ia32_pavgw128", + "sse2.pmadd.wd" => "__builtin_ia32_pmaddwd128", + "sse2.pmaxs.w" => "__builtin_ia32_pmaxsw128", + "sse2.pmaxu.b" => "__builtin_ia32_pmaxub128", + "sse2.pmins.w" => "__builtin_ia32_pminsw128", + "sse2.pminu.b" => "__builtin_ia32_pminub128", + "sse2.pmovmskb.128" => "__builtin_ia32_pmovmskb128", + "sse2.pmulh.w" => "__builtin_ia32_pmulhw128", + "sse2.pmulhu.w" => "__builtin_ia32_pmulhuw128", + "sse2.pmulu.dq" => "__builtin_ia32_pmuludq128", + "sse2.psad.bw" => "__builtin_ia32_psadbw128", + "sse2.pshuf.d" => "__builtin_ia32_pshufd", + "sse2.pshufh.w" => "__builtin_ia32_pshufhw", + "sse2.pshufl.w" => "__builtin_ia32_pshuflw", + "sse2.psll.d" => "__builtin_ia32_pslld128", + "sse2.psll.dq" => "__builtin_ia32_pslldqi128", + "sse2.psll.dq.bs" => "__builtin_ia32_pslldqi128_byteshift", + "sse2.psll.q" => "__builtin_ia32_psllq128", + "sse2.psll.w" => "__builtin_ia32_psllw128", + "sse2.pslli.d" => "__builtin_ia32_pslldi128", + "sse2.pslli.q" => "__builtin_ia32_psllqi128", + "sse2.pslli.w" => "__builtin_ia32_psllwi128", + "sse2.psra.d" => "__builtin_ia32_psrad128", + "sse2.psra.w" => "__builtin_ia32_psraw128", + "sse2.psrai.d" => "__builtin_ia32_psradi128", + "sse2.psrai.w" => "__builtin_ia32_psrawi128", + "sse2.psrl.d" => "__builtin_ia32_psrld128", + "sse2.psrl.dq" => "__builtin_ia32_psrldqi128", + "sse2.psrl.dq.bs" => "__builtin_ia32_psrldqi128_byteshift", + "sse2.psrl.q" => "__builtin_ia32_psrlq128", + "sse2.psrl.w" => "__builtin_ia32_psrlw128", + "sse2.psrli.d" => "__builtin_ia32_psrldi128", + "sse2.psrli.q" => "__builtin_ia32_psrlqi128", + "sse2.psrli.w" => "__builtin_ia32_psrlwi128", + "sse2.psubs.b" => "__builtin_ia32_psubsb128", + "sse2.psubs.w" => "__builtin_ia32_psubsw128", + "sse2.psubus.b" => "__builtin_ia32_psubusb128", + "sse2.psubus.w" => "__builtin_ia32_psubusw128", + "sse2.sqrt.pd" => "__builtin_ia32_sqrtpd", + "sse2.sqrt.sd" => "__builtin_ia32_sqrtsd", + "sse2.storel.dq" => "__builtin_ia32_storelv4si", + "sse2.storeu.dq" => "__builtin_ia32_storedqu", + "sse2.storeu.pd" => "__builtin_ia32_storeupd", + "sse2.sub.sd" => "__builtin_ia32_subsd", + "sse2.ucomieq.sd" => "__builtin_ia32_ucomisdeq", + "sse2.ucomige.sd" => "__builtin_ia32_ucomisdge", + "sse2.ucomigt.sd" => "__builtin_ia32_ucomisdgt", + "sse2.ucomile.sd" => "__builtin_ia32_ucomisdle", + "sse2.ucomilt.sd" => "__builtin_ia32_ucomisdlt", + "sse2.ucomineq.sd" => "__builtin_ia32_ucomisdneq", + "sse3.addsub.pd" => "__builtin_ia32_addsubpd", + "sse3.addsub.ps" => "__builtin_ia32_addsubps", + "sse3.hadd.pd" => "__builtin_ia32_haddpd", + "sse3.hadd.ps" => "__builtin_ia32_haddps", + "sse3.hsub.pd" => "__builtin_ia32_hsubpd", + "sse3.hsub.ps" => "__builtin_ia32_hsubps", + "sse3.ldu.dq" => "__builtin_ia32_lddqu", + "sse3.monitor" => "__builtin_ia32_monitor", + "sse3.mwait" => "__builtin_ia32_mwait", + "sse41.blendpd" => "__builtin_ia32_blendpd", + "sse41.blendps" => "__builtin_ia32_blendps", + "sse41.blendvpd" => "__builtin_ia32_blendvpd", + "sse41.blendvps" => "__builtin_ia32_blendvps", + "sse41.dppd" => "__builtin_ia32_dppd", + "sse41.dpps" => "__builtin_ia32_dpps", + "sse41.extractps" => "__builtin_ia32_extractps128", + "sse41.insertps" => "__builtin_ia32_insertps128", + "sse41.movntdqa" => "__builtin_ia32_movntdqa", + "sse41.mpsadbw" => "__builtin_ia32_mpsadbw128", + "sse41.packusdw" => "__builtin_ia32_packusdw128", + "sse41.pblendvb" => "__builtin_ia32_pblendvb128", + "sse41.pblendw" => "__builtin_ia32_pblendw128", + "sse41.phminposuw" => "__builtin_ia32_phminposuw128", + "sse41.pmaxsb" => "__builtin_ia32_pmaxsb128", + "sse41.pmaxsd" => "__builtin_ia32_pmaxsd128", + "sse41.pmaxud" => "__builtin_ia32_pmaxud128", + "sse41.pmaxuw" => "__builtin_ia32_pmaxuw128", + "sse41.pminsb" => "__builtin_ia32_pminsb128", + "sse41.pminsd" => "__builtin_ia32_pminsd128", + "sse41.pminud" => "__builtin_ia32_pminud128", + "sse41.pminuw" => "__builtin_ia32_pminuw128", + "sse41.pmovsxbd" => "__builtin_ia32_pmovsxbd128", + "sse41.pmovsxbq" => "__builtin_ia32_pmovsxbq128", + "sse41.pmovsxbw" => "__builtin_ia32_pmovsxbw128", + "sse41.pmovsxdq" => "__builtin_ia32_pmovsxdq128", + "sse41.pmovsxwd" => "__builtin_ia32_pmovsxwd128", + "sse41.pmovsxwq" => "__builtin_ia32_pmovsxwq128", + "sse41.pmovzxbd" => "__builtin_ia32_pmovzxbd128", + "sse41.pmovzxbq" => "__builtin_ia32_pmovzxbq128", + "sse41.pmovzxbw" => "__builtin_ia32_pmovzxbw128", + "sse41.pmovzxdq" => "__builtin_ia32_pmovzxdq128", + "sse41.pmovzxwd" => "__builtin_ia32_pmovzxwd128", + "sse41.pmovzxwq" => "__builtin_ia32_pmovzxwq128", + "sse41.pmuldq" => "__builtin_ia32_pmuldq128", + "sse41.ptestc" => "__builtin_ia32_ptestc128", + "sse41.ptestnzc" => "__builtin_ia32_ptestnzc128", + "sse41.ptestz" => "__builtin_ia32_ptestz128", + "sse41.round.pd" => "__builtin_ia32_roundpd", + "sse41.round.ps" => "__builtin_ia32_roundps", + "sse41.round.sd" => "__builtin_ia32_roundsd", + "sse41.round.ss" => "__builtin_ia32_roundss", + "sse42.crc32.32.16" => "__builtin_ia32_crc32hi", + "sse42.crc32.32.32" => "__builtin_ia32_crc32si", + "sse42.crc32.32.8" => "__builtin_ia32_crc32qi", + "sse42.crc32.64.64" => "__builtin_ia32_crc32di", + "sse42.pcmpestri128" => "__builtin_ia32_pcmpestri128", + "sse42.pcmpestria128" => "__builtin_ia32_pcmpestria128", + "sse42.pcmpestric128" => "__builtin_ia32_pcmpestric128", + "sse42.pcmpestrio128" => "__builtin_ia32_pcmpestrio128", + "sse42.pcmpestris128" => "__builtin_ia32_pcmpestris128", + "sse42.pcmpestriz128" => "__builtin_ia32_pcmpestriz128", + "sse42.pcmpestrm128" => "__builtin_ia32_pcmpestrm128", + "sse42.pcmpistri128" => "__builtin_ia32_pcmpistri128", + "sse42.pcmpistria128" => "__builtin_ia32_pcmpistria128", + "sse42.pcmpistric128" => "__builtin_ia32_pcmpistric128", + "sse42.pcmpistrio128" => "__builtin_ia32_pcmpistrio128", + "sse42.pcmpistris128" => "__builtin_ia32_pcmpistris128", + "sse42.pcmpistriz128" => "__builtin_ia32_pcmpistriz128", + "sse42.pcmpistrm128" => "__builtin_ia32_pcmpistrm128", + "sse4a.extrq" => "__builtin_ia32_extrq", + "sse4a.extrqi" => "__builtin_ia32_extrqi", + "sse4a.insertq" => "__builtin_ia32_insertq", + "sse4a.insertqi" => "__builtin_ia32_insertqi", + "sse4a.movnt.sd" => "__builtin_ia32_movntsd", + "sse4a.movnt.ss" => "__builtin_ia32_movntss", + "ssse3.pabs.b.128" => "__builtin_ia32_pabsb128", + "ssse3.pabs.d.128" => "__builtin_ia32_pabsd128", + "ssse3.pabs.w.128" => "__builtin_ia32_pabsw128", + "ssse3.phadd.d.128" => "__builtin_ia32_phaddd128", + "ssse3.phadd.sw.128" => "__builtin_ia32_phaddsw128", + "ssse3.phadd.w.128" => "__builtin_ia32_phaddw128", + "ssse3.phsub.d.128" => "__builtin_ia32_phsubd128", + "ssse3.phsub.sw.128" => "__builtin_ia32_phsubsw128", + "ssse3.phsub.w.128" => "__builtin_ia32_phsubw128", + "ssse3.pmadd.ub.sw.128" => "__builtin_ia32_pmaddubsw128", + "ssse3.pmul.hr.sw.128" => "__builtin_ia32_pmulhrsw128", + "ssse3.pshuf.b.128" => "__builtin_ia32_pshufb128", + "ssse3.psign.b.128" => "__builtin_ia32_psignb128", + "ssse3.psign.d.128" => "__builtin_ia32_psignd128", + "ssse3.psign.w.128" => "__builtin_ia32_psignw128", + "sttilecfg" => "__builtin_ia32_tile_storeconfig", + "stui" => "__builtin_ia32_stui", + "subborrow.u32" => "__builtin_ia32_subborrow_u32", + "subborrow.u64" => "__builtin_ia32_subborrow_u64", + "t2rpntlvwz0" => "__builtin_ia32_t2rpntlvwz0", + "t2rpntlvwz0rs" => "__builtin_ia32_t2rpntlvwz0rs", + "t2rpntlvwz0rst1" => "__builtin_ia32_t2rpntlvwz0rst1", + "t2rpntlvwz0t1" => "__builtin_ia32_t2rpntlvwz0t1", + "t2rpntlvwz1" => "__builtin_ia32_t2rpntlvwz1", + "t2rpntlvwz1rs" => "__builtin_ia32_t2rpntlvwz1rs", + "t2rpntlvwz1rst1" => "__builtin_ia32_t2rpntlvwz1rst1", + "t2rpntlvwz1t1" => "__builtin_ia32_t2rpntlvwz1t1", + "tbm.bextri.u32" => "__builtin_ia32_bextri_u32", + "tbm.bextri.u64" => "__builtin_ia32_bextri_u64", + "tcmmimfp16ps" => "__builtin_ia32_tcmmimfp16ps", + "tcmmimfp16ps.internal" => "__builtin_ia32_tcmmimfp16ps_internal", + "tcmmrlfp16ps" => "__builtin_ia32_tcmmrlfp16ps", + "tcmmrlfp16ps.internal" => "__builtin_ia32_tcmmrlfp16ps_internal", + "tconjtcmmimfp16ps" => "__builtin_ia32_tconjtcmmimfp16ps", + "tconjtcmmimfp16ps.internal" => "__builtin_ia32_tconjtcmmimfp16ps_internal", + "tconjtfp16" => "__builtin_ia32_tconjtfp16", + "tconjtfp16.internal" => "__builtin_ia32_tconjtfp16_internal", + "tcvtrowd2ps" => "__builtin_ia32_tcvtrowd2ps", + "tcvtrowd2ps.internal" => "__builtin_ia32_tcvtrowd2ps_internal", + "tcvtrowps2bf16h" => "__builtin_ia32_tcvtrowps2bf16h", + "tcvtrowps2bf16h.internal" => "__builtin_ia32_tcvtrowps2bf16h_internal", + "tcvtrowps2bf16l" => "__builtin_ia32_tcvtrowps2bf16l", + "tcvtrowps2bf16l.internal" => "__builtin_ia32_tcvtrowps2bf16l_internal", + "tcvtrowps2phh" => "__builtin_ia32_tcvtrowps2phh", + "tcvtrowps2phh.internal" => "__builtin_ia32_tcvtrowps2phh_internal", + "tcvtrowps2phl" => "__builtin_ia32_tcvtrowps2phl", + "tcvtrowps2phl.internal" => "__builtin_ia32_tcvtrowps2phl_internal", + "tdpbf16ps" => "__builtin_ia32_tdpbf16ps", + "tdpbf16ps.internal" => "__builtin_ia32_tdpbf16ps_internal", + "tdpbf8ps" => "__builtin_ia32_tdpbf8ps", + "tdpbf8ps.internal" => "__builtin_ia32_tdpbf8ps_internal", + "tdpbhf8ps" => "__builtin_ia32_tdpbhf8ps", + "tdpbhf8ps.internal" => "__builtin_ia32_tdpbhf8ps_internal", + "tdpbssd" => "__builtin_ia32_tdpbssd", + "tdpbssd.internal" => "__builtin_ia32_tdpbssd_internal", + "tdpbsud" => "__builtin_ia32_tdpbsud", + "tdpbsud.internal" => "__builtin_ia32_tdpbsud_internal", + "tdpbusd" => "__builtin_ia32_tdpbusd", + "tdpbusd.internal" => "__builtin_ia32_tdpbusd_internal", + "tdpbuud" => "__builtin_ia32_tdpbuud", + "tdpbuud.internal" => "__builtin_ia32_tdpbuud_internal", + "tdpfp16ps" => "__builtin_ia32_tdpfp16ps", + "tdpfp16ps.internal" => "__builtin_ia32_tdpfp16ps_internal", + "tdphbf8ps" => "__builtin_ia32_tdphbf8ps", + "tdphbf8ps.internal" => "__builtin_ia32_tdphbf8ps_internal", + "tdphf8ps" => "__builtin_ia32_tdphf8ps", + "tdphf8ps.internal" => "__builtin_ia32_tdphf8ps_internal", + "testui" => "__builtin_ia32_testui", + "tileloadd64" => "__builtin_ia32_tileloadd64", + "tileloadd64.internal" => "__builtin_ia32_tileloadd64_internal", + "tileloaddrs64" => "__builtin_ia32_tileloaddrs64", + "tileloaddrs64.internal" => "__builtin_ia32_tileloaddrs64_internal", + "tileloaddrst164" => "__builtin_ia32_tileloaddrst164", + "tileloaddrst164.internal" => "__builtin_ia32_tileloaddrst164_internal", + "tileloaddt164" => "__builtin_ia32_tileloaddt164", + "tileloaddt164.internal" => "__builtin_ia32_tileloaddt164_internal", + "tilemovrow" => "__builtin_ia32_tilemovrow", + "tilemovrow.internal" => "__builtin_ia32_tilemovrow_internal", + "tilerelease" => "__builtin_ia32_tilerelease", + "tilestored64" => "__builtin_ia32_tilestored64", + "tilestored64.internal" => "__builtin_ia32_tilestored64_internal", + "tilezero" => "__builtin_ia32_tilezero", + "tilezero.internal" => "__builtin_ia32_tilezero_internal", + "tmmultf32ps" => "__builtin_ia32_tmmultf32ps", + "tmmultf32ps.internal" => "__builtin_ia32_tmmultf32ps_internal", + "tpause" => "__builtin_ia32_tpause", + "ttcmmimfp16ps" => "__builtin_ia32_ttcmmimfp16ps", + "ttcmmimfp16ps.internal" => "__builtin_ia32_ttcmmimfp16ps_internal", + "ttcmmrlfp16ps" => "__builtin_ia32_ttcmmrlfp16ps", + "ttcmmrlfp16ps.internal" => "__builtin_ia32_ttcmmrlfp16ps_internal", + "ttdpbf16ps" => "__builtin_ia32_ttdpbf16ps", + "ttdpbf16ps.internal" => "__builtin_ia32_ttdpbf16ps_internal", + "ttdpfp16ps" => "__builtin_ia32_ttdpfp16ps", + "ttdpfp16ps.internal" => "__builtin_ia32_ttdpfp16ps_internal", + "ttmmultf32ps" => "__builtin_ia32_ttmmultf32ps", + "ttmmultf32ps.internal" => "__builtin_ia32_ttmmultf32ps_internal", + "ttransposed" => "__builtin_ia32_ttransposed", + "ttransposed.internal" => "__builtin_ia32_ttransposed_internal", + "umonitor" => "__builtin_ia32_umonitor", + "umwait" => "__builtin_ia32_umwait", + "urdmsr" => "__builtin_ia32_urdmsr", + "uwrmsr" => "__builtin_ia32_uwrmsr", + "vbcstnebf162ps128" => "__builtin_ia32_vbcstnebf162ps128", + "vbcstnebf162ps256" => "__builtin_ia32_vbcstnebf162ps256", + "vbcstnesh2ps128" => "__builtin_ia32_vbcstnesh2ps128", + "vbcstnesh2ps256" => "__builtin_ia32_vbcstnesh2ps256", + "vcvtneebf162ps128" => "__builtin_ia32_vcvtneebf162ps128", + "vcvtneebf162ps256" => "__builtin_ia32_vcvtneebf162ps256", + "vcvtneeph2ps128" => "__builtin_ia32_vcvtneeph2ps128", + "vcvtneeph2ps256" => "__builtin_ia32_vcvtneeph2ps256", + "vcvtneobf162ps128" => "__builtin_ia32_vcvtneobf162ps128", + "vcvtneobf162ps256" => "__builtin_ia32_vcvtneobf162ps256", + "vcvtneoph2ps128" => "__builtin_ia32_vcvtneoph2ps128", + "vcvtneoph2ps256" => "__builtin_ia32_vcvtneoph2ps256", + "vcvtneps2bf16128" => "__builtin_ia32_vcvtneps2bf16128", + "vcvtneps2bf16256" => "__builtin_ia32_vcvtneps2bf16256", + "vcvtph2ps.128" => "__builtin_ia32_vcvtph2ps", + "vcvtph2ps.256" => "__builtin_ia32_vcvtph2ps256", + "vcvtps2ph.128" => "__builtin_ia32_vcvtps2ph", + "vcvtps2ph.256" => "__builtin_ia32_vcvtps2ph256", + "vgf2p8affineinvqb.128" => "__builtin_ia32_vgf2p8affineinvqb_v16qi", + "vgf2p8affineinvqb.256" => "__builtin_ia32_vgf2p8affineinvqb_v32qi", + "vgf2p8affineinvqb.512" => "__builtin_ia32_vgf2p8affineinvqb_v64qi", + "vgf2p8affineqb.128" => "__builtin_ia32_vgf2p8affineqb_v16qi", + "vgf2p8affineqb.256" => "__builtin_ia32_vgf2p8affineqb_v32qi", + "vgf2p8affineqb.512" => "__builtin_ia32_vgf2p8affineqb_v64qi", + "vgf2p8mulb.128" => "__builtin_ia32_vgf2p8mulb_v16qi", + "vgf2p8mulb.256" => "__builtin_ia32_vgf2p8mulb_v32qi", + "vgf2p8mulb.512" => "__builtin_ia32_vgf2p8mulb_v64qi", + "vsha512msg1" => "__builtin_ia32_vsha512msg1", + "vsha512msg2" => "__builtin_ia32_vsha512msg2", + "vsha512rnds2" => "__builtin_ia32_vsha512rnds2", + "vsm3msg1" => "__builtin_ia32_vsm3msg1", + "vsm3msg2" => "__builtin_ia32_vsm3msg2", + "vsm3rnds2" => "__builtin_ia32_vsm3rnds2", + "vsm4key4128" => "__builtin_ia32_vsm4key4128", + "vsm4key4256" => "__builtin_ia32_vsm4key4256", + "vsm4key4512" => "__builtin_ia32_vsm4key4512", + "vsm4rnds4128" => "__builtin_ia32_vsm4rnds4128", + "vsm4rnds4256" => "__builtin_ia32_vsm4rnds4256", + "vsm4rnds4512" => "__builtin_ia32_vsm4rnds4512", + "wbinvd" => "__builtin_ia32_wbinvd", + "wbnoinvd" => "__builtin_ia32_wbnoinvd", + "wrfsbase.32" => "__builtin_ia32_wrfsbase32", + "wrfsbase.64" => "__builtin_ia32_wrfsbase64", + "wrgsbase.32" => "__builtin_ia32_wrgsbase32", + "wrgsbase.64" => "__builtin_ia32_wrgsbase64", + "wrpkru" => "__builtin_ia32_wrpkru", + "wrssd" => "__builtin_ia32_wrssd", + "wrssq" => "__builtin_ia32_wrssq", + "wrussd" => "__builtin_ia32_wrussd", + "wrussq" => "__builtin_ia32_wrussq", + "xabort" => "__builtin_ia32_xabort", + "xbegin" => "__builtin_ia32_xbegin", + "xend" => "__builtin_ia32_xend", + "xop.vfrcz.pd" => "__builtin_ia32_vfrczpd", + "xop.vfrcz.pd.256" => "__builtin_ia32_vfrczpd256", + "xop.vfrcz.ps" => "__builtin_ia32_vfrczps", + "xop.vfrcz.ps.256" => "__builtin_ia32_vfrczps256", + "xop.vfrcz.sd" => "__builtin_ia32_vfrczsd", + "xop.vfrcz.ss" => "__builtin_ia32_vfrczss", + "xop.vpcmov" => "__builtin_ia32_vpcmov", + "xop.vpcmov.256" => "__builtin_ia32_vpcmov_256", + "xop.vpcomb" => "__builtin_ia32_vpcomb", + "xop.vpcomd" => "__builtin_ia32_vpcomd", + "xop.vpcomq" => "__builtin_ia32_vpcomq", + "xop.vpcomub" => "__builtin_ia32_vpcomub", + "xop.vpcomud" => "__builtin_ia32_vpcomud", + "xop.vpcomuq" => "__builtin_ia32_vpcomuq", + "xop.vpcomuw" => "__builtin_ia32_vpcomuw", + "xop.vpcomw" => "__builtin_ia32_vpcomw", + "xop.vpermil2pd" => "__builtin_ia32_vpermil2pd", + "xop.vpermil2pd.256" => "__builtin_ia32_vpermil2pd256", + "xop.vpermil2ps" => "__builtin_ia32_vpermil2ps", + "xop.vpermil2ps.256" => "__builtin_ia32_vpermil2ps256", + "xop.vphaddbd" => "__builtin_ia32_vphaddbd", + "xop.vphaddbq" => "__builtin_ia32_vphaddbq", + "xop.vphaddbw" => "__builtin_ia32_vphaddbw", + "xop.vphadddq" => "__builtin_ia32_vphadddq", + "xop.vphaddubd" => "__builtin_ia32_vphaddubd", + "xop.vphaddubq" => "__builtin_ia32_vphaddubq", + "xop.vphaddubw" => "__builtin_ia32_vphaddubw", + "xop.vphaddudq" => "__builtin_ia32_vphaddudq", + "xop.vphadduwd" => "__builtin_ia32_vphadduwd", + "xop.vphadduwq" => "__builtin_ia32_vphadduwq", + "xop.vphaddwd" => "__builtin_ia32_vphaddwd", + "xop.vphaddwq" => "__builtin_ia32_vphaddwq", + "xop.vphsubbw" => "__builtin_ia32_vphsubbw", + "xop.vphsubdq" => "__builtin_ia32_vphsubdq", + "xop.vphsubwd" => "__builtin_ia32_vphsubwd", + "xop.vpmacsdd" => "__builtin_ia32_vpmacsdd", + "xop.vpmacsdqh" => "__builtin_ia32_vpmacsdqh", + "xop.vpmacsdql" => "__builtin_ia32_vpmacsdql", + "xop.vpmacssdd" => "__builtin_ia32_vpmacssdd", + "xop.vpmacssdqh" => "__builtin_ia32_vpmacssdqh", + "xop.vpmacssdql" => "__builtin_ia32_vpmacssdql", + "xop.vpmacsswd" => "__builtin_ia32_vpmacsswd", + "xop.vpmacssww" => "__builtin_ia32_vpmacssww", + "xop.vpmacswd" => "__builtin_ia32_vpmacswd", + "xop.vpmacsww" => "__builtin_ia32_vpmacsww", + "xop.vpmadcsswd" => "__builtin_ia32_vpmadcsswd", + "xop.vpmadcswd" => "__builtin_ia32_vpmadcswd", + "xop.vpperm" => "__builtin_ia32_vpperm", + "xop.vprotb" => "__builtin_ia32_vprotb", + "xop.vprotbi" => "__builtin_ia32_vprotbi", + "xop.vprotd" => "__builtin_ia32_vprotd", + "xop.vprotdi" => "__builtin_ia32_vprotdi", + "xop.vprotq" => "__builtin_ia32_vprotq", + "xop.vprotqi" => "__builtin_ia32_vprotqi", + "xop.vprotw" => "__builtin_ia32_vprotw", + "xop.vprotwi" => "__builtin_ia32_vprotwi", + "xop.vpshab" => "__builtin_ia32_vpshab", + "xop.vpshad" => "__builtin_ia32_vpshad", + "xop.vpshaq" => "__builtin_ia32_vpshaq", + "xop.vpshaw" => "__builtin_ia32_vpshaw", + "xop.vpshlb" => "__builtin_ia32_vpshlb", + "xop.vpshld" => "__builtin_ia32_vpshld", + "xop.vpshlq" => "__builtin_ia32_vpshlq", + "xop.vpshlw" => "__builtin_ia32_vpshlw", + "xresldtrk" => "__builtin_ia32_xresldtrk", + "xsusldtrk" => "__builtin_ia32_xsusldtrk", + "xtest" => "__builtin_ia32_xtest", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + x86(name, full_name) + } + "xcore" => { + #[allow(non_snake_case)] + fn xcore(name: &str, full_name: &str) -> &'static str { + match name { + // xcore + "bitrev" => "__builtin_bitrev", + "getid" => "__builtin_getid", + "getps" => "__builtin_getps", + "setps" => "__builtin_setps", + _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), + } + } + xcore(name, full_name) + } + _ => unimplemented!("***** unsupported LLVM architecture {arch}, intrinsic:{full_name}"), + } +} diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/llvm.rs b/compiler/rustc_codegen_gcc/src/intrinsic/llvm.rs new file mode 100644 index 00000000000..39dba28b24c --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/intrinsic/llvm.rs @@ -0,0 +1,1597 @@ +use std::borrow::Cow; + +use gccjit::{CType, Context, Field, Function, FunctionPtrType, RValue, ToRValue, Type}; +use rustc_codegen_ssa::traits::BuilderMethods; + +use crate::builder::Builder; +use crate::context::CodegenCx; + +fn encode_key_128_type<'a, 'gcc, 'tcx>( + builder: &Builder<'a, 'gcc, 'tcx>, +) -> (Type<'gcc>, Field<'gcc>, Field<'gcc>) { + let m128i = builder.context.new_vector_type(builder.i64_type, 2); + let field1 = builder.context.new_field(None, builder.u32_type, "field1"); + let field2 = builder.context.new_field(None, m128i, "field2"); + let field3 = builder.context.new_field(None, m128i, "field3"); + let field4 = builder.context.new_field(None, m128i, "field4"); + let field5 = builder.context.new_field(None, m128i, "field5"); + let field6 = builder.context.new_field(None, m128i, "field6"); + let field7 = builder.context.new_field(None, m128i, "field7"); + let encode_type = builder.context.new_struct_type( + None, + "EncodeKey128Output", + &[field1, field2, field3, field4, field5, field6, field7], + ); + #[cfg(feature = "master")] + encode_type.as_type().set_packed(); + (encode_type.as_type(), field1, field2) +} + +fn encode_key_256_type<'a, 'gcc, 'tcx>( + builder: &Builder<'a, 'gcc, 'tcx>, +) -> (Type<'gcc>, Field<'gcc>, Field<'gcc>) { + let m128i = builder.context.new_vector_type(builder.i64_type, 2); + let field1 = builder.context.new_field(None, builder.u32_type, "field1"); + let field2 = builder.context.new_field(None, m128i, "field2"); + let field3 = builder.context.new_field(None, m128i, "field3"); + let field4 = builder.context.new_field(None, m128i, "field4"); + let field5 = builder.context.new_field(None, m128i, "field5"); + let field6 = builder.context.new_field(None, m128i, "field6"); + let field7 = builder.context.new_field(None, m128i, "field7"); + let field8 = builder.context.new_field(None, m128i, "field8"); + let encode_type = builder.context.new_struct_type( + None, + "EncodeKey256Output", + &[field1, field2, field3, field4, field5, field6, field7, field8], + ); + #[cfg(feature = "master")] + encode_type.as_type().set_packed(); + (encode_type.as_type(), field1, field2) +} + +fn aes_output_type<'a, 'gcc, 'tcx>( + builder: &Builder<'a, 'gcc, 'tcx>, +) -> (Type<'gcc>, Field<'gcc>, Field<'gcc>) { + let m128i = builder.context.new_vector_type(builder.i64_type, 2); + let field1 = builder.context.new_field(None, builder.u8_type, "field1"); + let field2 = builder.context.new_field(None, m128i, "field2"); + let aes_output_type = builder.context.new_struct_type(None, "AesOutput", &[field1, field2]); + let typ = aes_output_type.as_type(); + #[cfg(feature = "master")] + typ.set_packed(); + (typ, field1, field2) +} + +fn wide_aes_output_type<'a, 'gcc, 'tcx>( + builder: &Builder<'a, 'gcc, 'tcx>, +) -> (Type<'gcc>, Field<'gcc>, Field<'gcc>) { + let m128i = builder.context.new_vector_type(builder.i64_type, 2); + let field1 = builder.context.new_field(None, builder.u8_type, "field1"); + let field2 = builder.context.new_field(None, m128i, "field2"); + let field3 = builder.context.new_field(None, m128i, "field3"); + let field4 = builder.context.new_field(None, m128i, "field4"); + let field5 = builder.context.new_field(None, m128i, "field5"); + let field6 = builder.context.new_field(None, m128i, "field6"); + let field7 = builder.context.new_field(None, m128i, "field7"); + let field8 = builder.context.new_field(None, m128i, "field8"); + let field9 = builder.context.new_field(None, m128i, "field9"); + let aes_output_type = builder.context.new_struct_type( + None, + "WideAesOutput", + &[field1, field2, field3, field4, field5, field6, field7, field8, field9], + ); + #[cfg(feature = "master")] + aes_output_type.as_type().set_packed(); + (aes_output_type.as_type(), field1, field2) +} + +#[cfg_attr(not(feature = "master"), allow(unused_variables))] +pub fn adjust_function<'gcc>( + context: &'gcc Context<'gcc>, + func_name: &str, + func_ptr: RValue<'gcc>, + args: &[RValue<'gcc>], +) -> RValue<'gcc> { + // FIXME: we should not need this hack: this is required because both _mm_fcmadd_sch + // and _mm_mask3_fcmadd_round_sch calls llvm.x86.avx512fp16.mask.vfcmadd.csh and we + // seem to need to map this one LLVM intrinsic to 2 different GCC builtins. + #[cfg(feature = "master")] + match func_name { + "__builtin_ia32_vfcmaddcsh_mask3_round" => { + if format!("{:?}", args[3]).ends_with("255") { + return context + .get_target_builtin_function("__builtin_ia32_vfcmaddcsh_mask_round") + .get_address(None); + } + } + "__builtin_ia32_vfmaddcsh_mask3_round" => { + if format!("{:?}", args[3]).ends_with("255") { + return context + .get_target_builtin_function("__builtin_ia32_vfmaddcsh_mask_round") + .get_address(None); + } + } + _ => (), + } + + func_ptr +} + +pub fn adjust_intrinsic_arguments<'a, 'b, 'gcc, 'tcx>( + builder: &Builder<'a, 'gcc, 'tcx>, + gcc_func: FunctionPtrType<'gcc>, + mut args: Cow<'b, [RValue<'gcc>]>, + func_name: &str, +) -> Cow<'b, [RValue<'gcc>]> { + // TODO: this might not be a good way to workaround the missing tile builtins. + if func_name == "__builtin_trap" { + return vec![].into(); + } + + // Some LLVM intrinsics do not map 1-to-1 to GCC intrinsics, so we add the missing + // arguments here. + if gcc_func.get_param_count() != args.len() { + match func_name { + // NOTE: the following intrinsics have a different number of parameters in LLVM and GCC. + "__builtin_ia32_prold512_mask" + | "__builtin_ia32_pmuldq512_mask" + | "__builtin_ia32_pmuludq512_mask" + | "__builtin_ia32_pmaxsd512_mask" + | "__builtin_ia32_pmaxsq512_mask" + | "__builtin_ia32_pmaxsq256_mask" + | "__builtin_ia32_pmaxsq128_mask" + | "__builtin_ia32_pmaxud512_mask" + | "__builtin_ia32_pmaxuq512_mask" + | "__builtin_ia32_pminsd512_mask" + | "__builtin_ia32_pminsq512_mask" + | "__builtin_ia32_pminsq256_mask" + | "__builtin_ia32_pminsq128_mask" + | "__builtin_ia32_pminud512_mask" + | "__builtin_ia32_pminuq512_mask" + | "__builtin_ia32_prolq512_mask" + | "__builtin_ia32_prorq512_mask" + | "__builtin_ia32_pslldi512_mask" + | "__builtin_ia32_psrldi512_mask" + | "__builtin_ia32_psllqi512_mask" + | "__builtin_ia32_psrlqi512_mask" + | "__builtin_ia32_pslld512_mask" + | "__builtin_ia32_psrld512_mask" + | "__builtin_ia32_psllq512_mask" + | "__builtin_ia32_psrlq512_mask" + | "__builtin_ia32_psrad512_mask" + | "__builtin_ia32_psraq512_mask" + | "__builtin_ia32_psradi512_mask" + | "__builtin_ia32_psraqi512_mask" + | "__builtin_ia32_psrav16si_mask" + | "__builtin_ia32_psrav8di_mask" + | "__builtin_ia32_prolvd512_mask" + | "__builtin_ia32_prorvd512_mask" + | "__builtin_ia32_prolvq512_mask" + | "__builtin_ia32_prorvq512_mask" + | "__builtin_ia32_psllv16si_mask" + | "__builtin_ia32_psrlv16si_mask" + | "__builtin_ia32_psllv8di_mask" + | "__builtin_ia32_psrlv8di_mask" + | "__builtin_ia32_permvarsi512_mask" + | "__builtin_ia32_vpermilvarps512_mask" + | "__builtin_ia32_vpermilvarpd512_mask" + | "__builtin_ia32_permvardi512_mask" + | "__builtin_ia32_permvarsf512_mask" + | "__builtin_ia32_permvarqi512_mask" + | "__builtin_ia32_permvarqi256_mask" + | "__builtin_ia32_permvarqi128_mask" + | "__builtin_ia32_vpmultishiftqb512_mask" + | "__builtin_ia32_vpmultishiftqb256_mask" + | "__builtin_ia32_vpmultishiftqb128_mask" => { + let mut new_args = args.to_vec(); + let arg3_type = gcc_func.get_param_type(2); + let first_arg = builder + .current_func() + .new_local(None, arg3_type, "undefined_for_intrinsic") + .to_rvalue(); + new_args.push(first_arg); + let arg4_type = gcc_func.get_param_type(3); + let minus_one = builder.context.new_rvalue_from_int(arg4_type, -1); + new_args.push(minus_one); + args = new_args.into(); + } + "__builtin_ia32_pmaxuq256_mask" + | "__builtin_ia32_pmaxuq128_mask" + | "__builtin_ia32_pminuq256_mask" + | "__builtin_ia32_pminuq128_mask" + | "__builtin_ia32_prold256_mask" + | "__builtin_ia32_prold128_mask" + | "__builtin_ia32_prord512_mask" + | "__builtin_ia32_prord256_mask" + | "__builtin_ia32_prord128_mask" + | "__builtin_ia32_prolq256_mask" + | "__builtin_ia32_prolq128_mask" + | "__builtin_ia32_prorq256_mask" + | "__builtin_ia32_prorq128_mask" + | "__builtin_ia32_psraq256_mask" + | "__builtin_ia32_psraq128_mask" + | "__builtin_ia32_psraqi256_mask" + | "__builtin_ia32_psraqi128_mask" + | "__builtin_ia32_psravq256_mask" + | "__builtin_ia32_psravq128_mask" + | "__builtin_ia32_prolvd256_mask" + | "__builtin_ia32_prolvd128_mask" + | "__builtin_ia32_prorvd256_mask" + | "__builtin_ia32_prorvd128_mask" + | "__builtin_ia32_prolvq256_mask" + | "__builtin_ia32_prolvq128_mask" + | "__builtin_ia32_prorvq256_mask" + | "__builtin_ia32_prorvq128_mask" + | "__builtin_ia32_permvardi256_mask" + | "__builtin_ia32_permvardf512_mask" + | "__builtin_ia32_permvardf256_mask" + | "__builtin_ia32_pmulhuw512_mask" + | "__builtin_ia32_pmulhw512_mask" + | "__builtin_ia32_pmulhrsw512_mask" + | "__builtin_ia32_pmaxuw512_mask" + | "__builtin_ia32_pmaxub512_mask" + | "__builtin_ia32_pmaxsw512_mask" + | "__builtin_ia32_pmaxsb512_mask" + | "__builtin_ia32_pminuw512_mask" + | "__builtin_ia32_pminub512_mask" + | "__builtin_ia32_pminsw512_mask" + | "__builtin_ia32_pminsb512_mask" + | "__builtin_ia32_pmaddwd512_mask" + | "__builtin_ia32_pmaddubsw512_mask" + | "__builtin_ia32_packssdw512_mask" + | "__builtin_ia32_packsswb512_mask" + | "__builtin_ia32_packusdw512_mask" + | "__builtin_ia32_packuswb512_mask" + | "__builtin_ia32_pavgw512_mask" + | "__builtin_ia32_pavgb512_mask" + | "__builtin_ia32_psllw512_mask" + | "__builtin_ia32_psllwi512_mask" + | "__builtin_ia32_psllv32hi_mask" + | "__builtin_ia32_psrlw512_mask" + | "__builtin_ia32_psrlwi512_mask" + | "__builtin_ia32_psllv16hi_mask" + | "__builtin_ia32_psllv8hi_mask" + | "__builtin_ia32_psrlv32hi_mask" + | "__builtin_ia32_psraw512_mask" + | "__builtin_ia32_psrawi512_mask" + | "__builtin_ia32_psrlv16hi_mask" + | "__builtin_ia32_psrlv8hi_mask" + | "__builtin_ia32_psrav32hi_mask" + | "__builtin_ia32_permvarhi512_mask" + | "__builtin_ia32_pshufb512_mask" + | "__builtin_ia32_psrav16hi_mask" + | "__builtin_ia32_psrav8hi_mask" + | "__builtin_ia32_permvarhi256_mask" + | "__builtin_ia32_permvarhi128_mask" + | "__builtin_ia32_maxph128_mask" + | "__builtin_ia32_maxph256_mask" + | "__builtin_ia32_minph128_mask" + | "__builtin_ia32_minph256_mask" => { + let mut new_args = args.to_vec(); + let arg3_type = gcc_func.get_param_type(2); + let vector_type = arg3_type.dyncast_vector().expect("vector type"); + let zero = builder.context.new_rvalue_zero(vector_type.get_element_type()); + let num_units = vector_type.get_num_units(); + let first_arg = + builder.context.new_rvalue_from_vector(None, arg3_type, &vec![zero; num_units]); + new_args.push(first_arg); + let arg4_type = gcc_func.get_param_type(3); + let minus_one = builder.context.new_rvalue_from_int(arg4_type, -1); + new_args.push(minus_one); + args = new_args.into(); + } + "__builtin_ia32_dbpsadbw512_mask" + | "__builtin_ia32_dbpsadbw256_mask" + | "__builtin_ia32_dbpsadbw128_mask" => { + let mut new_args = args.to_vec(); + let arg4_type = gcc_func.get_param_type(3); + let vector_type = arg4_type.dyncast_vector().expect("vector type"); + let zero = builder.context.new_rvalue_zero(vector_type.get_element_type()); + let num_units = vector_type.get_num_units(); + let first_arg = + builder.context.new_rvalue_from_vector(None, arg4_type, &vec![zero; num_units]); + new_args.push(first_arg); + let arg5_type = gcc_func.get_param_type(4); + let minus_one = builder.context.new_rvalue_from_int(arg5_type, -1); + new_args.push(minus_one); + args = new_args.into(); + } + "__builtin_ia32_vplzcntd_512_mask" + | "__builtin_ia32_vplzcntd_256_mask" + | "__builtin_ia32_vplzcntd_128_mask" + | "__builtin_ia32_vplzcntq_512_mask" + | "__builtin_ia32_vplzcntq_256_mask" + | "__builtin_ia32_vplzcntq_128_mask" + | "__builtin_ia32_cvtqq2pd128_mask" + | "__builtin_ia32_cvtqq2pd256_mask" + | "__builtin_ia32_cvtqq2ps256_mask" + | "__builtin_ia32_cvtuqq2pd128_mask" + | "__builtin_ia32_cvtuqq2pd256_mask" + | "__builtin_ia32_cvtuqq2ps256_mask" + | "__builtin_ia32_vcvtw2ph128_mask" + | "__builtin_ia32_vcvtw2ph256_mask" + | "__builtin_ia32_vcvtuw2ph128_mask" + | "__builtin_ia32_vcvtuw2ph256_mask" + | "__builtin_ia32_vcvtdq2ph256_mask" + | "__builtin_ia32_vcvtudq2ph256_mask" => { + let mut new_args = args.to_vec(); + // Remove last arg as it doesn't seem to be used in GCC and is always false. + new_args.pop(); + let arg2_type = gcc_func.get_param_type(1); + let vector_type = arg2_type.dyncast_vector().expect("vector type"); + let zero = builder.context.new_rvalue_zero(vector_type.get_element_type()); + let num_units = vector_type.get_num_units(); + let first_arg = + builder.context.new_rvalue_from_vector(None, arg2_type, &vec![zero; num_units]); + new_args.push(first_arg); + let arg3_type = gcc_func.get_param_type(2); + let minus_one = builder.context.new_rvalue_from_int(arg3_type, -1); + new_args.push(minus_one); + args = new_args.into(); + } + "__builtin_ia32_vpconflictsi_512_mask" + | "__builtin_ia32_vpconflictsi_256_mask" + | "__builtin_ia32_vpconflictsi_128_mask" + | "__builtin_ia32_vpconflictdi_512_mask" + | "__builtin_ia32_vpconflictdi_256_mask" + | "__builtin_ia32_vpconflictdi_128_mask" => { + let mut new_args = args.to_vec(); + let arg2_type = gcc_func.get_param_type(1); + let vector_type = arg2_type.dyncast_vector().expect("vector type"); + let zero = builder.context.new_rvalue_zero(vector_type.get_element_type()); + let num_units = vector_type.get_num_units(); + let first_arg = + builder.context.new_rvalue_from_vector(None, arg2_type, &vec![zero; num_units]); + new_args.push(first_arg); + let arg3_type = gcc_func.get_param_type(2); + let minus_one = builder.context.new_rvalue_from_int(arg3_type, -1); + new_args.push(minus_one); + args = new_args.into(); + } + "__builtin_ia32_pternlogd512_mask" + | "__builtin_ia32_pternlogd256_mask" + | "__builtin_ia32_pternlogd128_mask" + | "__builtin_ia32_pternlogq512_mask" + | "__builtin_ia32_pternlogq256_mask" + | "__builtin_ia32_pternlogq128_mask" => { + let mut new_args = args.to_vec(); + let arg5_type = gcc_func.get_param_type(4); + let minus_one = builder.context.new_rvalue_from_int(arg5_type, -1); + new_args.push(minus_one); + args = new_args.into(); + } + "__builtin_ia32_vfmaddps512_mask" | "__builtin_ia32_vfmaddpd512_mask" => { + let mut new_args = args.to_vec(); + + let mut last_arg = None; + if args.len() == 4 { + last_arg = new_args.pop(); + } + + let arg4_type = gcc_func.get_param_type(3); + let minus_one = builder.context.new_rvalue_from_int(arg4_type, -1); + new_args.push(minus_one); + + if args.len() == 3 { + // Both llvm.fma.v16f32 and llvm.x86.avx512.vfmadd.ps.512 maps to + // the same GCC intrinsic, but the former has 3 parameters and the + // latter has 4 so it doesn't require this additional argument. + let arg5_type = gcc_func.get_param_type(4); + new_args.push(builder.context.new_rvalue_from_int(arg5_type, 4)); + } + + if let Some(last_arg) = last_arg { + new_args.push(last_arg); + } + + args = new_args.into(); + } + "__builtin_ia32_addps512_mask" + | "__builtin_ia32_addpd512_mask" + | "__builtin_ia32_subps512_mask" + | "__builtin_ia32_subpd512_mask" + | "__builtin_ia32_mulps512_mask" + | "__builtin_ia32_mulpd512_mask" + | "__builtin_ia32_divps512_mask" + | "__builtin_ia32_divpd512_mask" + | "__builtin_ia32_maxps512_mask" + | "__builtin_ia32_maxpd512_mask" + | "__builtin_ia32_minps512_mask" + | "__builtin_ia32_minpd512_mask" => { + let mut new_args = args.to_vec(); + let last_arg = new_args.pop().expect("last arg"); + let arg3_type = gcc_func.get_param_type(2); + let undefined = builder + .current_func() + .new_local(None, arg3_type, "undefined_for_intrinsic") + .to_rvalue(); + new_args.push(undefined); + let arg4_type = gcc_func.get_param_type(3); + let minus_one = builder.context.new_rvalue_from_int(arg4_type, -1); + new_args.push(minus_one); + new_args.push(last_arg); + args = new_args.into(); + } + "__builtin_ia32_vfmaddsubps512_mask" + | "__builtin_ia32_vfmaddsubpd512_mask" + | "__builtin_ia32_cmpsh_mask_round" + | "__builtin_ia32_vfmaddph512_mask" + | "__builtin_ia32_vfmaddsubph512_mask" => { + let mut new_args = args.to_vec(); + let last_arg = new_args.pop().expect("last arg"); + let arg4_type = gcc_func.get_param_type(3); + let minus_one = builder.context.new_rvalue_from_int(arg4_type, -1); + new_args.push(minus_one); + new_args.push(last_arg); + args = new_args.into(); + } + "__builtin_ia32_vpermi2vard512_mask" + | "__builtin_ia32_vpermi2vard256_mask" + | "__builtin_ia32_vpermi2vard128_mask" + | "__builtin_ia32_vpermi2varq512_mask" + | "__builtin_ia32_vpermi2varq256_mask" + | "__builtin_ia32_vpermi2varq128_mask" + | "__builtin_ia32_vpermi2varps512_mask" + | "__builtin_ia32_vpermi2varps256_mask" + | "__builtin_ia32_vpermi2varps128_mask" + | "__builtin_ia32_vpermi2varpd512_mask" + | "__builtin_ia32_vpermi2varpd256_mask" + | "__builtin_ia32_vpermi2varpd128_mask" + | "__builtin_ia32_vpmadd52huq512_mask" + | "__builtin_ia32_vpmadd52luq512_mask" + | "__builtin_ia32_vfmaddsubph128_mask" + | "__builtin_ia32_vfmaddsubph256_mask" => { + let mut new_args = args.to_vec(); + let arg4_type = gcc_func.get_param_type(3); + let minus_one = builder.context.new_rvalue_from_int(arg4_type, -1); + new_args.push(minus_one); + args = new_args.into(); + } + "__builtin_ia32_cvtdq2ps512_mask" + | "__builtin_ia32_cvtudq2ps512_mask" + | "__builtin_ia32_sqrtps512_mask" + | "__builtin_ia32_sqrtpd512_mask" => { + let mut new_args = args.to_vec(); + let last_arg = new_args.pop().expect("last arg"); + let arg2_type = gcc_func.get_param_type(1); + let undefined = builder + .current_func() + .new_local(None, arg2_type, "undefined_for_intrinsic") + .to_rvalue(); + new_args.push(undefined); + let arg3_type = gcc_func.get_param_type(2); + let minus_one = builder.context.new_rvalue_from_int(arg3_type, -1); + new_args.push(minus_one); + new_args.push(last_arg); + args = new_args.into(); + } + "__builtin_ia32_stmxcsr" => { + args = vec![].into(); + } + "__builtin_ia32_addcarryx_u64" + | "__builtin_ia32_sbb_u64" + | "__builtin_ia32_addcarryx_u32" + | "__builtin_ia32_sbb_u32" => { + let mut new_args = args.to_vec(); + let arg2_type = gcc_func.get_param_type(1); + let variable = builder.current_func().new_local(None, arg2_type, "addcarryResult"); + new_args.push(variable.get_address(None)); + args = new_args.into(); + } + "__builtin_ia32_vpermt2varqi512_mask" + | "__builtin_ia32_vpermt2varqi256_mask" + | "__builtin_ia32_vpermt2varqi128_mask" + | "__builtin_ia32_vpermt2varhi512_mask" + | "__builtin_ia32_vpermt2varhi256_mask" + | "__builtin_ia32_vpermt2varhi128_mask" => { + let new_args = args.to_vec(); + let arg4_type = gcc_func.get_param_type(3); + let minus_one = builder.context.new_rvalue_from_int(arg4_type, -1); + args = vec![new_args[1], new_args[0], new_args[2], minus_one].into(); + } + "__builtin_ia32_xrstor" + | "__builtin_ia32_xrstor64" + | "__builtin_ia32_xsavec" + | "__builtin_ia32_xsavec64" + | "__builtin_ia32_xsave" + | "__builtin_ia32_xsave64" + | "__builtin_ia32_xsaveopt" + | "__builtin_ia32_xsaveopt64" => { + let new_args = args.to_vec(); + let thirty_two = builder.context.new_rvalue_from_int(new_args[1].get_type(), 32); + let arg2 = (new_args[1] << thirty_two) | new_args[2]; + let arg2_type = gcc_func.get_param_type(1); + let arg2 = builder.context.new_cast(None, arg2, arg2_type); + args = vec![new_args[0], arg2].into(); + } + // These builtins are sent one more argument than needed. + "__builtin_prefetch" => { + let mut new_args = args.to_vec(); + new_args.pop(); + args = new_args.into(); + } + // The GCC version returns one value of the tuple through a pointer. + "__builtin_ia32_rdrand64_step" => { + let arg = builder.current_func().new_local( + None, + builder.ulonglong_type, + "return_rdrand_arg", + ); + args = vec![arg.get_address(None)].into(); + } + "__builtin_ia32_cvtqq2pd512_mask" + | "__builtin_ia32_cvtqq2ps512_mask" + | "__builtin_ia32_cvtuqq2pd512_mask" + | "__builtin_ia32_cvtuqq2ps512_mask" + | "__builtin_ia32_sqrtph512_mask_round" + | "__builtin_ia32_vcvtw2ph512_mask_round" + | "__builtin_ia32_vcvtuw2ph512_mask_round" + | "__builtin_ia32_vcvtdq2ph512_mask_round" + | "__builtin_ia32_vcvtudq2ph512_mask_round" + | "__builtin_ia32_vcvtqq2ph512_mask_round" + | "__builtin_ia32_vcvtuqq2ph512_mask_round" => { + let mut old_args = args.to_vec(); + let mut new_args = vec![]; + new_args.push(old_args.swap_remove(0)); + let arg2_type = gcc_func.get_param_type(1); + let vector_type = arg2_type.dyncast_vector().expect("vector type"); + let zero = builder.context.new_rvalue_zero(vector_type.get_element_type()); + let num_units = vector_type.get_num_units(); + let first_arg = + builder.context.new_rvalue_from_vector(None, arg2_type, &vec![zero; num_units]); + new_args.push(first_arg); + let arg3_type = gcc_func.get_param_type(2); + let minus_one = builder.context.new_rvalue_from_int(arg3_type, -1); + new_args.push(minus_one); + new_args.push(old_args.swap_remove(0)); + args = new_args.into(); + } + "__builtin_ia32_addph512_mask_round" + | "__builtin_ia32_subph512_mask_round" + | "__builtin_ia32_mulph512_mask_round" + | "__builtin_ia32_divph512_mask_round" + | "__builtin_ia32_maxph512_mask_round" + | "__builtin_ia32_minph512_mask_round" => { + let mut new_args = args.to_vec(); + let last_arg = new_args.pop().expect("last arg"); + + let arg3_type = gcc_func.get_param_type(2); + let vector_type = arg3_type.dyncast_vector().expect("vector type"); + let zero = builder.context.new_rvalue_zero(vector_type.get_element_type()); + let num_units = vector_type.get_num_units(); + let first_arg = + builder.context.new_rvalue_from_vector(None, arg3_type, &vec![zero; num_units]); + new_args.push(first_arg); + + let arg4_type = gcc_func.get_param_type(3); + let minus_one = builder.context.new_rvalue_from_int(arg4_type, -1); + new_args.push(minus_one); + new_args.push(last_arg); + args = new_args.into(); + } + // NOTE: the LLVM intrinsics receive 3 floats, but the GCC builtin requires 3 vectors. + "__builtin_ia32_vfmaddsh3_mask" => { + let new_args = args.to_vec(); + let arg1_type = gcc_func.get_param_type(0); + let arg2_type = gcc_func.get_param_type(1); + let arg3_type = gcc_func.get_param_type(2); + let arg4_type = gcc_func.get_param_type(3); + let a = builder.context.new_rvalue_from_vector(None, arg1_type, &[new_args[0]; 8]); + let b = builder.context.new_rvalue_from_vector(None, arg2_type, &[new_args[1]; 8]); + let c = builder.context.new_rvalue_from_vector(None, arg3_type, &[new_args[2]; 8]); + let arg4 = builder.context.new_rvalue_from_int(arg4_type, -1); + args = vec![a, b, c, arg4, new_args[3]].into(); + } + "__builtin_ia32_encodekey128_u32" => { + let mut new_args = args.to_vec(); + let m128i = builder.context.new_vector_type(builder.i64_type, 2); + let array_type = builder.context.new_array_type(None, m128i, 6); + let result = builder.current_func().new_local(None, array_type, "result"); + new_args.push(result.get_address(None)); + args = new_args.into(); + } + "__builtin_ia32_encodekey256_u32" => { + let mut new_args = args.to_vec(); + let m128i = builder.context.new_vector_type(builder.i64_type, 2); + let array_type = builder.context.new_array_type(None, m128i, 7); + let result = builder.current_func().new_local(None, array_type, "result"); + new_args.push(result.get_address(None)); + args = new_args.into(); + } + "__builtin_ia32_aesenc128kl_u8" + | "__builtin_ia32_aesdec128kl_u8" + | "__builtin_ia32_aesenc256kl_u8" + | "__builtin_ia32_aesdec256kl_u8" => { + let mut new_args = vec![]; + let m128i = builder.context.new_vector_type(builder.i64_type, 2); + let result = builder.current_func().new_local(None, m128i, "result"); + new_args.push(result.get_address(None)); + new_args.extend(args.to_vec()); + args = new_args.into(); + } + "__builtin_ia32_aesencwide128kl_u8" + | "__builtin_ia32_aesdecwide128kl_u8" + | "__builtin_ia32_aesencwide256kl_u8" + | "__builtin_ia32_aesdecwide256kl_u8" => { + let mut new_args = vec![]; + + let mut old_args = args.to_vec(); + let handle = old_args.swap_remove(0); // Called __P in GCC. + let first_value = old_args.swap_remove(0); + + let element_type = first_value.get_type(); + let array_type = builder.context.new_array_type(None, element_type, 8); + let result = builder.current_func().new_local(None, array_type, "result"); + new_args.push(result.get_address(None)); + + let array = builder.current_func().new_local(None, array_type, "array"); + let input = builder.context.new_array_constructor( + None, + array_type, + &[ + first_value, + old_args.swap_remove(0), + old_args.swap_remove(0), + old_args.swap_remove(0), + old_args.swap_remove(0), + old_args.swap_remove(0), + old_args.swap_remove(0), + old_args.swap_remove(0), + ], + ); + builder.llbb().add_assignment(None, array, input); + let input_ptr = array.get_address(None); + let arg2_type = gcc_func.get_param_type(1); + let input_ptr = builder.context.new_cast(None, input_ptr, arg2_type); + new_args.push(input_ptr); + + new_args.push(handle); + args = new_args.into(); + } + "__builtin_ia32_rdtscp" => { + let result = builder.current_func().new_local(None, builder.u32_type, "result"); + let new_args = vec![result.get_address(None).to_rvalue()]; + args = new_args.into(); + } + _ => (), + } + } else { + match func_name { + "__builtin_ia32_rndscaless_mask_round" + | "__builtin_ia32_rndscalesd_mask_round" + | "__builtin_ia32_reducesh_mask_round" => { + let new_args = args.to_vec(); + let arg3_type = gcc_func.get_param_type(2); + let arg3 = builder.context.new_cast(None, new_args[4], arg3_type); + let arg4_type = gcc_func.get_param_type(3); + let arg4 = builder.context.new_bitcast(None, new_args[2], arg4_type); + args = vec![new_args[0], new_args[1], arg3, arg4, new_args[3], new_args[5]].into(); + } + // NOTE: the LLVM intrinsics receive 3 floats, but the GCC builtin requires 3 vectors. + // FIXME: the intrinsics like _mm_mask_fmadd_sd should probably directly call the GCC + // intrinsic to avoid this. + "__builtin_ia32_vfmaddss3_round" => { + let new_args = args.to_vec(); + let arg1_type = gcc_func.get_param_type(0); + let arg2_type = gcc_func.get_param_type(1); + let arg3_type = gcc_func.get_param_type(2); + let a = builder.context.new_rvalue_from_vector(None, arg1_type, &[new_args[0]; 4]); + let b = builder.context.new_rvalue_from_vector(None, arg2_type, &[new_args[1]; 4]); + let c = builder.context.new_rvalue_from_vector(None, arg3_type, &[new_args[2]; 4]); + args = vec![a, b, c, new_args[3]].into(); + } + "__builtin_ia32_vfmaddsd3_round" => { + let new_args = args.to_vec(); + let arg1_type = gcc_func.get_param_type(0); + let arg2_type = gcc_func.get_param_type(1); + let arg3_type = gcc_func.get_param_type(2); + let a = builder.context.new_rvalue_from_vector(None, arg1_type, &[new_args[0]; 2]); + let b = builder.context.new_rvalue_from_vector(None, arg2_type, &[new_args[1]; 2]); + let c = builder.context.new_rvalue_from_vector(None, arg3_type, &[new_args[2]; 2]); + args = vec![a, b, c, new_args[3]].into(); + } + "__builtin_ia32_ldmxcsr" => { + // The builtin __builtin_ia32_ldmxcsr takes an integer value while llvm.x86.sse.ldmxcsr takes a pointer, + // so dereference the pointer. + let mut new_args = args.to_vec(); + let uint_ptr_type = builder.uint_type.make_pointer(); + let arg1 = builder.context.new_cast(None, args[0], uint_ptr_type); + new_args[0] = arg1.dereference(None).to_rvalue(); + args = new_args.into(); + } + "__builtin_ia32_rcp14sd_mask" + | "__builtin_ia32_rcp14ss_mask" + | "__builtin_ia32_rsqrt14sd_mask" + | "__builtin_ia32_rsqrt14ss_mask" => { + let new_args = args.to_vec(); + args = vec![new_args[1], new_args[0], new_args[2], new_args[3]].into(); + } + "__builtin_ia32_sqrtsd_mask_round" | "__builtin_ia32_sqrtss_mask_round" => { + let new_args = args.to_vec(); + args = vec![new_args[1], new_args[0], new_args[2], new_args[3], new_args[4]].into(); + } + "__builtin_ia32_vpshrdv_v8di" + | "__builtin_ia32_vpshrdv_v4di" + | "__builtin_ia32_vpshrdv_v2di" + | "__builtin_ia32_vpshrdv_v16si" + | "__builtin_ia32_vpshrdv_v8si" + | "__builtin_ia32_vpshrdv_v4si" + | "__builtin_ia32_vpshrdv_v32hi" + | "__builtin_ia32_vpshrdv_v16hi" + | "__builtin_ia32_vpshrdv_v8hi" => { + // The first two arguments are reversed, compared to LLVM. + let new_args = args.to_vec(); + args = vec![new_args[1], new_args[0], new_args[2]].into(); + } + "__builtin_ia32_rangesd128_mask_round" + | "__builtin_ia32_rangess128_mask_round" + | "__builtin_ia32_reducesd_mask_round" + | "__builtin_ia32_reducess_mask_round" => { + let new_args = args.to_vec(); + args = vec![ + new_args[0], + new_args[1], + new_args[4], + new_args[2], + new_args[3], + new_args[5], + ] + .into(); + } + "__builtin_ia32_rndscalesh_mask_round" => { + let new_args = args.to_vec(); + args = vec![ + new_args[0], + new_args[1], + new_args[4], + new_args[2], + new_args[3], + new_args[5], + ] + .into(); + } + "fma" => { + let mut new_args = args.to_vec(); + new_args[0] = builder.context.new_cast(None, new_args[0], builder.double_type); + new_args[1] = builder.context.new_cast(None, new_args[1], builder.double_type); + new_args[2] = builder.context.new_cast(None, new_args[2], builder.double_type); + args = new_args.into(); + } + "__builtin_ia32_sqrtsh_mask_round" + | "__builtin_ia32_vcvtss2sh_mask_round" + | "__builtin_ia32_vcvtsd2sh_mask_round" + | "__builtin_ia32_vcvtsh2ss_mask_round" + | "__builtin_ia32_vcvtsh2sd_mask_round" + | "__builtin_ia32_rcpsh_mask" + | "__builtin_ia32_rsqrtsh_mask" => { + // The first two arguments are inverted, so swap them. + let mut new_args = args.to_vec(); + new_args.swap(0, 1); + args = new_args.into(); + } + "__builtin_ia32_dpps256" => { + let mut new_args = args.to_vec(); + // NOTE: without this cast to u8 (and it needs to be a u8 to fix the issue), we + // would get the following error: + // the last argument must be an 8-bit immediate + new_args[2] = builder.context.new_cast(None, new_args[2], builder.cx.type_u8()); + args = new_args.into(); + } + _ => (), + } + } + + args +} + +pub fn adjust_intrinsic_return_value<'a, 'gcc, 'tcx>( + builder: &Builder<'a, 'gcc, 'tcx>, + mut return_value: RValue<'gcc>, + func_name: &str, + args: &[RValue<'gcc>], + args_adjusted: bool, + orig_args: &[RValue<'gcc>], +) -> RValue<'gcc> { + match func_name { + "__builtin_ia32_vfmaddss3_round" + | "__builtin_ia32_vfmaddsd3_round" + | "__builtin_ia32_vfmaddsh3_mask" => { + #[cfg(feature = "master")] + { + let zero = builder.context.new_rvalue_zero(builder.int_type); + return_value = + builder.context.new_vector_access(None, return_value, zero).to_rvalue(); + } + } + "__builtin_ia32_addcarryx_u64" + | "__builtin_ia32_sbb_u64" + | "__builtin_ia32_addcarryx_u32" + | "__builtin_ia32_sbb_u32" => { + // Both llvm.x86.addcarry.32 and llvm.x86.addcarryx.u32 points to the same GCC builtin, + // but only the former requires adjusting the return value. + // Those 2 LLVM intrinsics differ by their argument count, that's why we check if the + // arguments were adjusted. + if args_adjusted { + let last_arg = args.last().expect("last arg"); + let field1 = builder.context.new_field(None, builder.u8_type, "carryFlag"); + let field2 = builder.context.new_field(None, args[1].get_type(), "carryResult"); + let struct_type = + builder.context.new_struct_type(None, "addcarryResult", &[field1, field2]); + return_value = builder.context.new_struct_constructor( + None, + struct_type.as_type(), + None, + &[return_value, last_arg.dereference(None).to_rvalue()], + ); + } + } + "__builtin_ia32_stmxcsr" => { + // The builtin __builtin_ia32_stmxcsr returns a value while llvm.x86.sse.stmxcsr writes + // the result in its pointer argument. + // We removed the argument since __builtin_ia32_stmxcsr takes no arguments, so we need + // to get back the original argument to get the pointer we need to write the result to. + let uint_ptr_type = builder.uint_type.make_pointer(); + let ptr = builder.context.new_cast(None, orig_args[0], uint_ptr_type); + builder.llbb().add_assignment(None, ptr.dereference(None), return_value); + // The return value was assigned to the result pointer above. In order to not call the + // builtin twice, we overwrite the return value with a dummy value. + return_value = builder.context.new_rvalue_zero(builder.int_type); + } + "__builtin_ia32_rdrand64_step" => { + let random_number = args[0].dereference(None).to_rvalue(); + let success_variable = + builder.current_func().new_local(None, return_value.get_type(), "success"); + builder.llbb().add_assignment(None, success_variable, return_value); + + let field1 = builder.context.new_field(None, random_number.get_type(), "random_number"); + let field2 = builder.context.new_field(None, return_value.get_type(), "success"); + let struct_type = + builder.context.new_struct_type(None, "rdrand_result", &[field1, field2]); + return_value = builder.context.new_struct_constructor( + None, + struct_type.as_type(), + None, + &[random_number, success_variable.to_rvalue()], + ); + } + "fma" => { + let f16_type = builder.context.new_c_type(CType::Float16); + return_value = builder.context.new_cast(None, return_value, f16_type); + } + "__builtin_ia32_encodekey128_u32" => { + // The builtin __builtin_ia32_encodekey128_u32 writes the result in its pointer argument while + // llvm.x86.encodekey128 returns a value. + // We added a result pointer argument and now need to assign its value to the return_value expected by + // the LLVM intrinsic. + let (encode_type, field1, field2) = encode_key_128_type(builder); + let result = builder.current_func().new_local(None, encode_type, "result"); + let field1 = result.access_field(None, field1); + builder.llbb().add_assignment(None, field1, return_value); + let field2 = result.access_field(None, field2); + let field2_type = field2.to_rvalue().get_type(); + let array_type = builder.context.new_array_type(None, field2_type, 6); + let ptr = builder.context.new_cast(None, args[2], array_type.make_pointer()); + let field2_ptr = + builder.context.new_cast(None, field2.get_address(None), array_type.make_pointer()); + builder.llbb().add_assignment( + None, + field2_ptr.dereference(None), + ptr.dereference(None), + ); + return_value = result.to_rvalue(); + } + "__builtin_ia32_encodekey256_u32" => { + // The builtin __builtin_ia32_encodekey256_u32 writes the result in its pointer argument while + // llvm.x86.encodekey256 returns a value. + // We added a result pointer argument and now need to assign its value to the return_value expected by + // the LLVM intrinsic. + let (encode_type, field1, field2) = encode_key_256_type(builder); + let result = builder.current_func().new_local(None, encode_type, "result"); + let field1 = result.access_field(None, field1); + builder.llbb().add_assignment(None, field1, return_value); + let field2 = result.access_field(None, field2); + let field2_type = field2.to_rvalue().get_type(); + let array_type = builder.context.new_array_type(None, field2_type, 7); + let ptr = builder.context.new_cast(None, args[3], array_type.make_pointer()); + let field2_ptr = + builder.context.new_cast(None, field2.get_address(None), array_type.make_pointer()); + builder.llbb().add_assignment( + None, + field2_ptr.dereference(None), + ptr.dereference(None), + ); + return_value = result.to_rvalue(); + } + "__builtin_ia32_aesdec128kl_u8" + | "__builtin_ia32_aesenc128kl_u8" + | "__builtin_ia32_aesdec256kl_u8" + | "__builtin_ia32_aesenc256kl_u8" => { + // The builtin for aesdec/aesenc writes the result in its pointer argument while + // llvm.x86.aesdec128kl returns a value. + // We added a result pointer argument and now need to assign its value to the return_value expected by + // the LLVM intrinsic. + let (aes_output_type, field1, field2) = aes_output_type(builder); + let result = builder.current_func().new_local(None, aes_output_type, "result"); + let field1 = result.access_field(None, field1); + builder.llbb().add_assignment(None, field1, return_value); + let field2 = result.access_field(None, field2); + let ptr = builder.context.new_cast( + None, + args[0], + field2.to_rvalue().get_type().make_pointer(), + ); + builder.llbb().add_assignment(None, field2, ptr.dereference(None)); + return_value = result.to_rvalue(); + } + "__builtin_ia32_aesencwide128kl_u8" + | "__builtin_ia32_aesdecwide128kl_u8" + | "__builtin_ia32_aesencwide256kl_u8" + | "__builtin_ia32_aesdecwide256kl_u8" => { + // The builtin for aesdecwide/aesencwide writes the result in its pointer argument while + // llvm.x86.aesencwide128kl returns a value. + // We added a result pointer argument and now need to assign its value to the return_value expected by + // the LLVM intrinsic. + let (aes_output_type, field1, field2) = wide_aes_output_type(builder); + let result = builder.current_func().new_local(None, aes_output_type, "result"); + let field1 = result.access_field(None, field1); + builder.llbb().add_assignment(None, field1, return_value); + let field2 = result.access_field(None, field2); + let field2_type = field2.to_rvalue().get_type(); + let array_type = builder.context.new_array_type(None, field2_type, 8); + let ptr = builder.context.new_cast(None, args[0], array_type.make_pointer()); + let field2_ptr = + builder.context.new_cast(None, field2.get_address(None), array_type.make_pointer()); + builder.llbb().add_assignment( + None, + field2_ptr.dereference(None), + ptr.dereference(None), + ); + return_value = result.to_rvalue(); + } + "__builtin_ia32_rdtscp" => { + let field1 = builder.context.new_field(None, return_value.get_type(), "rdtscpField1"); + let return2 = args[0].dereference(None).to_rvalue(); + let field2 = builder.context.new_field(None, return2.get_type(), "rdtscpField2"); + let struct_type = + builder.context.new_struct_type(None, "rdtscpResult", &[field1, field2]); + return_value = builder.context.new_struct_constructor( + None, + struct_type.as_type(), + None, + &[return_value, return2], + ); + } + _ => (), + } + + return_value +} + +pub fn ignore_arg_cast(func_name: &str, index: usize, args_len: usize) -> bool { + // FIXME(antoyo): find a way to refactor in order to avoid this hack. + match func_name { + // NOTE: these intrinsics have missing parameters before the last one, so ignore the + // last argument type check. + "__builtin_ia32_maxps512_mask" + | "__builtin_ia32_maxpd512_mask" + | "__builtin_ia32_minps512_mask" + | "__builtin_ia32_minpd512_mask" + | "__builtin_ia32_sqrtps512_mask" + | "__builtin_ia32_sqrtpd512_mask" + | "__builtin_ia32_addps512_mask" + | "__builtin_ia32_addpd512_mask" + | "__builtin_ia32_subps512_mask" + | "__builtin_ia32_subpd512_mask" + | "__builtin_ia32_mulps512_mask" + | "__builtin_ia32_mulpd512_mask" + | "__builtin_ia32_divps512_mask" + | "__builtin_ia32_divpd512_mask" + | "__builtin_ia32_vfmaddsubps512_mask" + | "__builtin_ia32_vfmaddsubpd512_mask" + | "__builtin_ia32_cvtdq2ps512_mask" + | "__builtin_ia32_cvtudq2ps512_mask" => { + if index == args_len - 1 { + return true; + } + } + "__builtin_ia32_rndscaless_mask_round" | "__builtin_ia32_rndscalesd_mask_round" => { + if index == 2 || index == 3 { + return true; + } + } + "__builtin_ia32_vfmaddps512_mask" | "__builtin_ia32_vfmaddpd512_mask" => { + // Since there are two LLVM intrinsics that map to each of these GCC builtins and only + // one of them has a missing parameter before the last one, we check the number of + // arguments to distinguish those cases. + if args_len == 4 && index == args_len - 1 { + return true; + } + } + // NOTE: the LLVM intrinsic receives 3 floats, but the GCC builtin requires 3 vectors. + "__builtin_ia32_vfmaddss3_round" | "__builtin_ia32_vfmaddsd3_round" => return true, + "__builtin_ia32_vplzcntd_512_mask" + | "__builtin_ia32_vplzcntd_256_mask" + | "__builtin_ia32_vplzcntd_128_mask" + | "__builtin_ia32_vplzcntq_512_mask" + | "__builtin_ia32_vplzcntq_256_mask" + | "__builtin_ia32_vplzcntq_128_mask" => { + if index == args_len - 1 { + return true; + } + } + _ => (), + } + + false +} + +#[cfg(not(feature = "master"))] +pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function<'gcc> { + let gcc_name = match name { + "llvm.x86.sse2.pause" => { + // NOTE: pause is only a hint, so we use a dummy built-in because target built-ins + // are not supported in libgccjit 12. + "__builtin_inff" + } + "llvm.x86.xgetbv" => "__builtin_trap", + _ => unimplemented!("unsupported LLVM intrinsic {}", name), + }; + let func = cx.context.get_builtin_function(gcc_name); + cx.functions.borrow_mut().insert(gcc_name.to_string(), func); + func +} + +#[cfg(feature = "master")] +pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function<'gcc> { + let gcc_name = match name { + "llvm.prefetch" => { + let gcc_name = "__builtin_prefetch"; + let func = cx.context.get_builtin_function(gcc_name); + cx.functions.borrow_mut().insert(gcc_name.to_string(), func); + return func; + } + + "llvm.aarch64.isb" => { + // FIXME: GCC doesn't support __builtin_arm_isb yet, check if this builtin is OK. + let gcc_name = "__atomic_thread_fence"; + let func = cx.context.get_builtin_function(gcc_name); + cx.functions.borrow_mut().insert(gcc_name.to_string(), func); + return func; + } + + "llvm.x86.xgetbv" => "__builtin_ia32_xgetbv", + // NOTE: this doc specifies the equivalent GCC builtins: http://huonw.github.io/llvmint/llvmint/x86/index.html + "llvm.sqrt.v2f64" => "__builtin_ia32_sqrtpd", + "llvm.x86.avx512.pmul.dq.512" => "__builtin_ia32_pmuldq512_mask", + "llvm.x86.avx512.pmulu.dq.512" => "__builtin_ia32_pmuludq512_mask", + "llvm.x86.avx512.max.ps.512" => "__builtin_ia32_maxps512_mask", + "llvm.x86.avx512.max.pd.512" => "__builtin_ia32_maxpd512_mask", + "llvm.x86.avx512.min.ps.512" => "__builtin_ia32_minps512_mask", + "llvm.x86.avx512.min.pd.512" => "__builtin_ia32_minpd512_mask", + "llvm.fma.v16f32" => "__builtin_ia32_vfmaddps512_mask", + "llvm.fma.v8f64" => "__builtin_ia32_vfmaddpd512_mask", + "llvm.x86.avx512.vfmaddsub.ps.512" => "__builtin_ia32_vfmaddsubps512_mask", + "llvm.x86.avx512.vfmaddsub.pd.512" => "__builtin_ia32_vfmaddsubpd512_mask", + "llvm.x86.avx512.pternlog.d.512" => "__builtin_ia32_pternlogd512_mask", + "llvm.x86.avx512.pternlog.d.256" => "__builtin_ia32_pternlogd256_mask", + "llvm.x86.avx512.pternlog.d.128" => "__builtin_ia32_pternlogd128_mask", + "llvm.x86.avx512.pternlog.q.512" => "__builtin_ia32_pternlogq512_mask", + "llvm.x86.avx512.pternlog.q.256" => "__builtin_ia32_pternlogq256_mask", + "llvm.x86.avx512.pternlog.q.128" => "__builtin_ia32_pternlogq128_mask", + "llvm.x86.avx512.add.ps.512" => "__builtin_ia32_addps512_mask", + "llvm.x86.avx512.add.pd.512" => "__builtin_ia32_addpd512_mask", + "llvm.x86.avx512.sub.ps.512" => "__builtin_ia32_subps512_mask", + "llvm.x86.avx512.sub.pd.512" => "__builtin_ia32_subpd512_mask", + "llvm.x86.avx512.mul.ps.512" => "__builtin_ia32_mulps512_mask", + "llvm.x86.avx512.mul.pd.512" => "__builtin_ia32_mulpd512_mask", + "llvm.x86.avx512.div.ps.512" => "__builtin_ia32_divps512_mask", + "llvm.x86.avx512.div.pd.512" => "__builtin_ia32_divpd512_mask", + "llvm.x86.avx512.vfmadd.ps.512" => "__builtin_ia32_vfmaddps512_mask", + "llvm.x86.avx512.vfmadd.pd.512" => "__builtin_ia32_vfmaddpd512_mask", + "llvm.x86.avx512.sitofp.round.v16f32.v16i32" => "__builtin_ia32_cvtdq2ps512_mask", + "llvm.x86.avx512.uitofp.round.v16f32.v16i32" => "__builtin_ia32_cvtudq2ps512_mask", + "llvm.x86.avx512.mask.ucmp.d.512" => "__builtin_ia32_ucmpd512_mask", + "llvm.x86.avx512.mask.ucmp.d.256" => "__builtin_ia32_ucmpd256_mask", + "llvm.x86.avx512.mask.ucmp.d.128" => "__builtin_ia32_ucmpd128_mask", + "llvm.x86.avx512.mask.cmp.d.512" => "__builtin_ia32_cmpd512_mask", + "llvm.x86.avx512.mask.cmp.d.256" => "__builtin_ia32_cmpd256_mask", + "llvm.x86.avx512.mask.cmp.d.128" => "__builtin_ia32_cmpd128_mask", + "llvm.x86.avx512.mask.ucmp.q.512" => "__builtin_ia32_ucmpq512_mask", + "llvm.x86.avx512.mask.ucmp.q.256" => "__builtin_ia32_ucmpq256_mask", + "llvm.x86.avx512.mask.ucmp.q.128" => "__builtin_ia32_ucmpq128_mask", + "llvm.x86.avx512.mask.cmp.q.512" => "__builtin_ia32_cmpq512_mask", + "llvm.x86.avx512.mask.cmp.q.256" => "__builtin_ia32_cmpq256_mask", + "llvm.x86.avx512.mask.cmp.q.128" => "__builtin_ia32_cmpq128_mask", + "llvm.x86.avx512.mask.max.ss.round" => "__builtin_ia32_maxss_mask_round", + "llvm.x86.avx512.mask.max.sd.round" => "__builtin_ia32_maxsd_mask_round", + "llvm.x86.avx512.mask.min.ss.round" => "__builtin_ia32_minss_mask_round", + "llvm.x86.avx512.mask.min.sd.round" => "__builtin_ia32_minsd_mask_round", + "llvm.x86.avx512.mask.sqrt.ss" => "__builtin_ia32_sqrtss_mask_round", + "llvm.x86.avx512.mask.sqrt.sd" => "__builtin_ia32_sqrtsd_mask_round", + "llvm.x86.avx512.mask.getexp.ss" => "__builtin_ia32_getexpss_mask_round", + "llvm.x86.avx512.mask.getexp.sd" => "__builtin_ia32_getexpsd_mask_round", + "llvm.x86.avx512.mask.getmant.ss" => "__builtin_ia32_getmantss_mask_round", + "llvm.x86.avx512.mask.getmant.sd" => "__builtin_ia32_getmantsd_mask_round", + "llvm.x86.avx512.mask.rndscale.ss" => "__builtin_ia32_rndscaless_mask_round", + "llvm.x86.avx512.mask.rndscale.sd" => "__builtin_ia32_rndscalesd_mask_round", + "llvm.x86.avx512.mask.scalef.ss" => "__builtin_ia32_scalefss_mask_round", + "llvm.x86.avx512.mask.scalef.sd" => "__builtin_ia32_scalefsd_mask_round", + "llvm.x86.avx512.vfmadd.f32" => "__builtin_ia32_vfmaddss3_round", + "llvm.x86.avx512.vfmadd.f64" => "__builtin_ia32_vfmaddsd3_round", + "llvm.ceil.v4f64" => "__builtin_ia32_ceilpd256", + "llvm.ceil.v8f32" => "__builtin_ia32_ceilps256", + "llvm.floor.v4f64" => "__builtin_ia32_floorpd256", + "llvm.floor.v8f32" => "__builtin_ia32_floorps256", + "llvm.sqrt.v4f64" => "__builtin_ia32_sqrtpd256", + "llvm.x86.sse.stmxcsr" => "__builtin_ia32_stmxcsr", + "llvm.x86.sse.ldmxcsr" => "__builtin_ia32_ldmxcsr", + "llvm.ctpop.v16i32" => "__builtin_ia32_vpopcountd_v16si", + "llvm.ctpop.v8i32" => "__builtin_ia32_vpopcountd_v8si", + "llvm.ctpop.v4i32" => "__builtin_ia32_vpopcountd_v4si", + "llvm.ctpop.v8i64" => "__builtin_ia32_vpopcountq_v8di", + "llvm.ctpop.v4i64" => "__builtin_ia32_vpopcountq_v4di", + "llvm.ctpop.v2i64" => "__builtin_ia32_vpopcountq_v2di", + "llvm.x86.addcarry.64" => "__builtin_ia32_addcarryx_u64", + "llvm.x86.subborrow.64" => "__builtin_ia32_sbb_u64", + "llvm.floor.v2f64" => "__builtin_ia32_floorpd", + "llvm.floor.v4f32" => "__builtin_ia32_floorps", + "llvm.ceil.v2f64" => "__builtin_ia32_ceilpd", + "llvm.ceil.v4f32" => "__builtin_ia32_ceilps", + "llvm.fma.v2f64" => "__builtin_ia32_vfmaddpd", + "llvm.fma.v4f64" => "__builtin_ia32_vfmaddpd256", + "llvm.fma.v4f32" => "__builtin_ia32_vfmaddps", + "llvm.fma.v8f32" => "__builtin_ia32_vfmaddps256", + "llvm.ctlz.v16i32" => "__builtin_ia32_vplzcntd_512_mask", + "llvm.ctlz.v8i32" => "__builtin_ia32_vplzcntd_256_mask", + "llvm.ctlz.v4i32" => "__builtin_ia32_vplzcntd_128_mask", + "llvm.ctlz.v8i64" => "__builtin_ia32_vplzcntq_512_mask", + "llvm.ctlz.v4i64" => "__builtin_ia32_vplzcntq_256_mask", + "llvm.ctlz.v2i64" => "__builtin_ia32_vplzcntq_128_mask", + "llvm.ctpop.v32i16" => "__builtin_ia32_vpopcountw_v32hi", + "llvm.x86.avx512.conflict.d.512" => "__builtin_ia32_vpconflictsi_512_mask", + "llvm.x86.avx512.conflict.d.256" => "__builtin_ia32_vpconflictsi_256_mask", + "llvm.x86.avx512.conflict.d.128" => "__builtin_ia32_vpconflictsi_128_mask", + "llvm.x86.avx512.conflict.q.512" => "__builtin_ia32_vpconflictdi_512_mask", + "llvm.x86.avx512.conflict.q.256" => "__builtin_ia32_vpconflictdi_256_mask", + "llvm.x86.avx512.conflict.q.128" => "__builtin_ia32_vpconflictdi_128_mask", + "llvm.x86.avx512.vpermi2var.qi.512" => "__builtin_ia32_vpermt2varqi512_mask", + "llvm.x86.avx512.vpermi2var.qi.256" => "__builtin_ia32_vpermt2varqi256_mask", + "llvm.x86.avx512.vpermi2var.qi.128" => "__builtin_ia32_vpermt2varqi128_mask", + "llvm.x86.avx512.permvar.qi.512" => "__builtin_ia32_permvarqi512_mask", + "llvm.x86.avx512.permvar.qi.256" => "__builtin_ia32_permvarqi256_mask", + "llvm.x86.avx512.permvar.qi.128" => "__builtin_ia32_permvarqi128_mask", + "llvm.x86.avx512.pmultishift.qb.512" => "__builtin_ia32_vpmultishiftqb512_mask", + "llvm.x86.avx512.pmultishift.qb.256" => "__builtin_ia32_vpmultishiftqb256_mask", + "llvm.x86.avx512.pmultishift.qb.128" => "__builtin_ia32_vpmultishiftqb128_mask", + "llvm.ctpop.v16i16" => "__builtin_ia32_vpopcountw_v16hi", + "llvm.ctpop.v8i16" => "__builtin_ia32_vpopcountw_v8hi", + "llvm.ctpop.v64i8" => "__builtin_ia32_vpopcountb_v64qi", + "llvm.ctpop.v32i8" => "__builtin_ia32_vpopcountb_v32qi", + "llvm.ctpop.v16i8" => "__builtin_ia32_vpopcountb_v16qi", + "llvm.x86.avx512.mask.vpshufbitqmb.512" => "__builtin_ia32_vpshufbitqmb512_mask", + "llvm.x86.avx512.mask.vpshufbitqmb.256" => "__builtin_ia32_vpshufbitqmb256_mask", + "llvm.x86.avx512.mask.vpshufbitqmb.128" => "__builtin_ia32_vpshufbitqmb128_mask", + "llvm.x86.avx512.mask.ucmp.w.512" => "__builtin_ia32_ucmpw512_mask", + "llvm.x86.avx512.mask.ucmp.w.256" => "__builtin_ia32_ucmpw256_mask", + "llvm.x86.avx512.mask.ucmp.w.128" => "__builtin_ia32_ucmpw128_mask", + "llvm.x86.avx512.mask.ucmp.b.512" => "__builtin_ia32_ucmpb512_mask", + "llvm.x86.avx512.mask.ucmp.b.256" => "__builtin_ia32_ucmpb256_mask", + "llvm.x86.avx512.mask.ucmp.b.128" => "__builtin_ia32_ucmpb128_mask", + "llvm.x86.avx512.mask.cmp.w.512" => "__builtin_ia32_cmpw512_mask", + "llvm.x86.avx512.mask.cmp.w.256" => "__builtin_ia32_cmpw256_mask", + "llvm.x86.avx512.mask.cmp.w.128" => "__builtin_ia32_cmpw128_mask", + "llvm.x86.avx512.mask.cmp.b.512" => "__builtin_ia32_cmpb512_mask", + "llvm.x86.avx512.mask.cmp.b.256" => "__builtin_ia32_cmpb256_mask", + "llvm.x86.avx512.mask.cmp.b.128" => "__builtin_ia32_cmpb128_mask", + "llvm.x86.xrstor" => "__builtin_ia32_xrstor", + "llvm.x86.xrstor64" => "__builtin_ia32_xrstor64", + "llvm.x86.xsavec" => "__builtin_ia32_xsavec", + "llvm.x86.xsavec64" => "__builtin_ia32_xsavec64", + "llvm.x86.addcarry.32" => "__builtin_ia32_addcarryx_u32", + "llvm.x86.subborrow.32" => "__builtin_ia32_sbb_u32", + "llvm.x86.avx512.mask.compress.store.w.512" => "__builtin_ia32_compressstoreuhi512_mask", + "llvm.x86.avx512.mask.compress.store.w.256" => "__builtin_ia32_compressstoreuhi256_mask", + "llvm.x86.avx512.mask.compress.store.w.128" => "__builtin_ia32_compressstoreuhi128_mask", + "llvm.x86.avx512.mask.compress.store.b.512" => "__builtin_ia32_compressstoreuqi512_mask", + "llvm.x86.avx512.mask.compress.store.b.256" => "__builtin_ia32_compressstoreuqi256_mask", + "llvm.x86.avx512.mask.compress.store.b.128" => "__builtin_ia32_compressstoreuqi128_mask", + "llvm.x86.avx512.mask.compress.w.512" => "__builtin_ia32_compresshi512_mask", + "llvm.x86.avx512.mask.compress.w.256" => "__builtin_ia32_compresshi256_mask", + "llvm.x86.avx512.mask.compress.w.128" => "__builtin_ia32_compresshi128_mask", + "llvm.x86.avx512.mask.compress.b.512" => "__builtin_ia32_compressqi512_mask", + "llvm.x86.avx512.mask.compress.b.256" => "__builtin_ia32_compressqi256_mask", + "llvm.x86.avx512.mask.compress.b.128" => "__builtin_ia32_compressqi128_mask", + "llvm.x86.avx512.mask.expand.w.512" => "__builtin_ia32_expandhi512_mask", + "llvm.x86.avx512.mask.expand.w.256" => "__builtin_ia32_expandhi256_mask", + "llvm.x86.avx512.mask.expand.w.128" => "__builtin_ia32_expandhi128_mask", + "llvm.x86.avx512.mask.expand.b.512" => "__builtin_ia32_expandqi512_mask", + "llvm.x86.avx512.mask.expand.b.256" => "__builtin_ia32_expandqi256_mask", + "llvm.x86.avx512.mask.expand.b.128" => "__builtin_ia32_expandqi128_mask", + "llvm.fshl.v8i64" => "__builtin_ia32_vpshldv_v8di", + "llvm.fshl.v4i64" => "__builtin_ia32_vpshldv_v4di", + "llvm.fshl.v2i64" => "__builtin_ia32_vpshldv_v2di", + "llvm.fshl.v16i32" => "__builtin_ia32_vpshldv_v16si", + "llvm.fshl.v8i32" => "__builtin_ia32_vpshldv_v8si", + "llvm.fshl.v4i32" => "__builtin_ia32_vpshldv_v4si", + "llvm.fshl.v32i16" => "__builtin_ia32_vpshldv_v32hi", + "llvm.fshl.v16i16" => "__builtin_ia32_vpshldv_v16hi", + "llvm.fshl.v8i16" => "__builtin_ia32_vpshldv_v8hi", + "llvm.fshr.v8i64" => "__builtin_ia32_vpshrdv_v8di", + "llvm.fshr.v4i64" => "__builtin_ia32_vpshrdv_v4di", + "llvm.fshr.v2i64" => "__builtin_ia32_vpshrdv_v2di", + "llvm.fshr.v16i32" => "__builtin_ia32_vpshrdv_v16si", + "llvm.fshr.v8i32" => "__builtin_ia32_vpshrdv_v8si", + "llvm.fshr.v4i32" => "__builtin_ia32_vpshrdv_v4si", + "llvm.fshr.v32i16" => "__builtin_ia32_vpshrdv_v32hi", + "llvm.fshr.v16i16" => "__builtin_ia32_vpshrdv_v16hi", + "llvm.fshr.v8i16" => "__builtin_ia32_vpshrdv_v8hi", + "llvm.x86.rdrand.64" => "__builtin_ia32_rdrand64_step", + + // The above doc points to unknown builtins for the following, so override them: + "llvm.x86.avx2.gather.d.d" => "__builtin_ia32_gathersiv4si", + "llvm.x86.avx2.gather.d.d.256" => "__builtin_ia32_gathersiv8si", + "llvm.x86.avx2.gather.d.ps" => "__builtin_ia32_gathersiv4sf", + "llvm.x86.avx2.gather.d.ps.256" => "__builtin_ia32_gathersiv8sf", + "llvm.x86.avx2.gather.d.q" => "__builtin_ia32_gathersiv2di", + "llvm.x86.avx2.gather.d.q.256" => "__builtin_ia32_gathersiv4di", + "llvm.x86.avx2.gather.d.pd" => "__builtin_ia32_gathersiv2df", + "llvm.x86.avx2.gather.d.pd.256" => "__builtin_ia32_gathersiv4df", + "llvm.x86.avx2.gather.q.d" => "__builtin_ia32_gatherdiv4si", + "llvm.x86.avx2.gather.q.d.256" => "__builtin_ia32_gatherdiv4si256", + "llvm.x86.avx2.gather.q.ps" => "__builtin_ia32_gatherdiv4sf", + "llvm.x86.avx2.gather.q.ps.256" => "__builtin_ia32_gatherdiv4sf256", + "llvm.x86.avx2.gather.q.q" => "__builtin_ia32_gatherdiv2di", + "llvm.x86.avx2.gather.q.q.256" => "__builtin_ia32_gatherdiv4di", + "llvm.x86.avx2.gather.q.pd" => "__builtin_ia32_gatherdiv2df", + "llvm.x86.avx2.gather.q.pd.256" => "__builtin_ia32_gatherdiv4df", + "llvm.x86.avx512.pslli.d.512" => "__builtin_ia32_pslldi512_mask", + "llvm.x86.avx512.psrli.d.512" => "__builtin_ia32_psrldi512_mask", + "llvm.x86.avx512.pslli.q.512" => "__builtin_ia32_psllqi512_mask", + "llvm.x86.avx512.psrli.q.512" => "__builtin_ia32_psrlqi512_mask", + "llvm.x86.avx512.psll.d.512" => "__builtin_ia32_pslld512_mask", + "llvm.x86.avx512.psrl.d.512" => "__builtin_ia32_psrld512_mask", + "llvm.x86.avx512.psll.q.512" => "__builtin_ia32_psllq512_mask", + "llvm.x86.avx512.psrl.q.512" => "__builtin_ia32_psrlq512_mask", + "llvm.x86.avx512.psra.d.512" => "__builtin_ia32_psrad512_mask", + "llvm.x86.avx512.psra.q.512" => "__builtin_ia32_psraq512_mask", + "llvm.x86.avx512.psra.q.256" => "__builtin_ia32_psraq256_mask", + "llvm.x86.avx512.psra.q.128" => "__builtin_ia32_psraq128_mask", + "llvm.x86.avx512.psrai.d.512" => "__builtin_ia32_psradi512_mask", + "llvm.x86.avx512.psrai.q.512" => "__builtin_ia32_psraqi512_mask", + "llvm.x86.avx512.psrai.q.256" => "__builtin_ia32_psraqi256_mask", + "llvm.x86.avx512.psrai.q.128" => "__builtin_ia32_psraqi128_mask", + "llvm.x86.avx512.psrav.d.512" => "__builtin_ia32_psrav16si_mask", + "llvm.x86.avx512.psrav.q.512" => "__builtin_ia32_psrav8di_mask", + "llvm.x86.avx512.psrav.q.256" => "__builtin_ia32_psravq256_mask", + "llvm.x86.avx512.psrav.q.128" => "__builtin_ia32_psravq128_mask", + "llvm.x86.avx512.psllv.d.512" => "__builtin_ia32_psllv16si_mask", + "llvm.x86.avx512.psrlv.d.512" => "__builtin_ia32_psrlv16si_mask", + "llvm.x86.avx512.psllv.q.512" => "__builtin_ia32_psllv8di_mask", + "llvm.x86.avx512.psrlv.q.512" => "__builtin_ia32_psrlv8di_mask", + "llvm.x86.avx512.permvar.si.512" => "__builtin_ia32_permvarsi512_mask", + "llvm.x86.avx512.vpermilvar.ps.512" => "__builtin_ia32_vpermilvarps512_mask", + "llvm.x86.avx512.vpermilvar.pd.512" => "__builtin_ia32_vpermilvarpd512_mask", + "llvm.x86.avx512.permvar.di.512" => "__builtin_ia32_permvardi512_mask", + "llvm.x86.avx512.permvar.di.256" => "__builtin_ia32_permvardi256_mask", + "llvm.x86.avx512.permvar.sf.512" => "__builtin_ia32_permvarsf512_mask", + "llvm.x86.avx512.permvar.df.512" => "__builtin_ia32_permvardf512_mask", + "llvm.x86.avx512.permvar.df.256" => "__builtin_ia32_permvardf256_mask", + "llvm.x86.avx512.vpermi2var.d.512" => "__builtin_ia32_vpermi2vard512_mask", + "llvm.x86.avx512.vpermi2var.d.256" => "__builtin_ia32_vpermi2vard256_mask", + "llvm.x86.avx512.vpermi2var.d.128" => "__builtin_ia32_vpermi2vard128_mask", + "llvm.x86.avx512.vpermi2var.q.512" => "__builtin_ia32_vpermi2varq512_mask", + "llvm.x86.avx512.vpermi2var.q.256" => "__builtin_ia32_vpermi2varq256_mask", + "llvm.x86.avx512.vpermi2var.q.128" => "__builtin_ia32_vpermi2varq128_mask", + "llvm.x86.avx512.vpermi2var.ps.512" => "__builtin_ia32_vpermi2varps512_mask", + "llvm.x86.avx512.vpermi2var.ps.256" => "__builtin_ia32_vpermi2varps256_mask", + "llvm.x86.avx512.vpermi2var.ps.128" => "__builtin_ia32_vpermi2varps128_mask", + "llvm.x86.avx512.vpermi2var.pd.512" => "__builtin_ia32_vpermi2varpd512_mask", + "llvm.x86.avx512.vpermi2var.pd.256" => "__builtin_ia32_vpermi2varpd256_mask", + "llvm.x86.avx512.vpermi2var.pd.128" => "__builtin_ia32_vpermi2varpd128_mask", + "llvm.x86.avx512.mask.add.ss.round" => "__builtin_ia32_addss_mask_round", + "llvm.x86.avx512.mask.add.sd.round" => "__builtin_ia32_addsd_mask_round", + "llvm.x86.avx512.mask.sub.ss.round" => "__builtin_ia32_subss_mask_round", + "llvm.x86.avx512.mask.sub.sd.round" => "__builtin_ia32_subsd_mask_round", + "llvm.x86.avx512.mask.mul.ss.round" => "__builtin_ia32_mulss_mask_round", + "llvm.x86.avx512.mask.mul.sd.round" => "__builtin_ia32_mulsd_mask_round", + "llvm.x86.avx512.mask.div.ss.round" => "__builtin_ia32_divss_mask_round", + "llvm.x86.avx512.mask.div.sd.round" => "__builtin_ia32_divsd_mask_round", + "llvm.x86.avx512.mask.cvtss2sd.round" => "__builtin_ia32_cvtss2sd_mask_round", + "llvm.x86.avx512.mask.cvtsd2ss.round" => "__builtin_ia32_cvtsd2ss_mask_round", + "llvm.x86.avx512.mask.range.ss" => "__builtin_ia32_rangess128_mask_round", + "llvm.x86.avx512.mask.range.sd" => "__builtin_ia32_rangesd128_mask_round", + "llvm.x86.avx512.rcp28.ss" => "__builtin_ia32_rcp28ss_mask_round", + "llvm.x86.avx512.rcp28.sd" => "__builtin_ia32_rcp28sd_mask_round", + "llvm.x86.avx512.rsqrt28.ss" => "__builtin_ia32_rsqrt28ss_mask_round", + "llvm.x86.avx512.rsqrt28.sd" => "__builtin_ia32_rsqrt28sd_mask_round", + "llvm.x86.avx512fp16.mask.add.sh.round" => "__builtin_ia32_addsh_mask_round", + "llvm.x86.avx512fp16.mask.div.sh.round" => "__builtin_ia32_divsh_mask_round", + "llvm.x86.avx512fp16.mask.getmant.sh" => "__builtin_ia32_getmantsh_mask_round", + "llvm.x86.avx512fp16.mask.max.sh.round" => "__builtin_ia32_maxsh_mask_round", + "llvm.x86.avx512fp16.mask.min.sh.round" => "__builtin_ia32_minsh_mask_round", + "llvm.x86.avx512fp16.mask.mul.sh.round" => "__builtin_ia32_mulsh_mask_round", + "llvm.x86.avx512fp16.mask.rndscale.sh" => "__builtin_ia32_rndscalesh_mask_round", + "llvm.x86.avx512fp16.mask.scalef.sh" => "__builtin_ia32_scalefsh_mask_round", + "llvm.x86.avx512fp16.mask.sub.sh.round" => "__builtin_ia32_subsh_mask_round", + "llvm.x86.avx512fp16.mask.vcvtsd2sh.round" => "__builtin_ia32_vcvtsd2sh_mask_round", + "llvm.x86.avx512fp16.mask.vcvtsh2sd.round" => "__builtin_ia32_vcvtsh2sd_mask_round", + "llvm.x86.avx512fp16.mask.vcvtsh2ss.round" => "__builtin_ia32_vcvtsh2ss_mask_round", + "llvm.x86.avx512fp16.mask.vcvtss2sh.round" => "__builtin_ia32_vcvtss2sh_mask_round", + "llvm.x86.aesni.aesenc.256" => "__builtin_ia32_vaesenc_v32qi", + "llvm.x86.aesni.aesenclast.256" => "__builtin_ia32_vaesenclast_v32qi", + "llvm.x86.aesni.aesdec.256" => "__builtin_ia32_vaesdec_v32qi", + "llvm.x86.aesni.aesdeclast.256" => "__builtin_ia32_vaesdeclast_v32qi", + "llvm.x86.aesni.aesenc.512" => "__builtin_ia32_vaesenc_v64qi", + "llvm.x86.aesni.aesenclast.512" => "__builtin_ia32_vaesenclast_v64qi", + "llvm.x86.aesni.aesdec.512" => "__builtin_ia32_vaesdec_v64qi", + "llvm.x86.aesni.aesdeclast.512" => "__builtin_ia32_vaesdeclast_v64qi", + "llvm.x86.avx512bf16.cvtne2ps2bf16.128" => "__builtin_ia32_cvtne2ps2bf16_v8bf", + "llvm.x86.avx512bf16.cvtne2ps2bf16.256" => "__builtin_ia32_cvtne2ps2bf16_v16bf", + "llvm.x86.avx512bf16.cvtne2ps2bf16.512" => "__builtin_ia32_cvtne2ps2bf16_v32bf", + "llvm.x86.avx512bf16.cvtneps2bf16.256" => "__builtin_ia32_cvtneps2bf16_v8sf", + "llvm.x86.avx512bf16.cvtneps2bf16.512" => "__builtin_ia32_cvtneps2bf16_v16sf", + "llvm.x86.avx512bf16.dpbf16ps.128" => "__builtin_ia32_dpbf16ps_v4sf", + "llvm.x86.avx512bf16.dpbf16ps.256" => "__builtin_ia32_dpbf16ps_v8sf", + "llvm.x86.avx512bf16.dpbf16ps.512" => "__builtin_ia32_dpbf16ps_v16sf", + "llvm.x86.pclmulqdq.512" => "__builtin_ia32_vpclmulqdq_v8di", + "llvm.x86.pclmulqdq.256" => "__builtin_ia32_vpclmulqdq_v4di", + "llvm.x86.avx512.pmulhu.w.512" => "__builtin_ia32_pmulhuw512_mask", + "llvm.x86.avx512.pmulh.w.512" => "__builtin_ia32_pmulhw512_mask", + "llvm.x86.avx512.pmul.hr.sw.512" => "__builtin_ia32_pmulhrsw512_mask", + "llvm.x86.avx512.pmaddw.d.512" => "__builtin_ia32_pmaddwd512_mask", + "llvm.x86.avx512.pmaddubs.w.512" => "__builtin_ia32_pmaddubsw512_mask", + "llvm.x86.avx512.packssdw.512" => "__builtin_ia32_packssdw512_mask", + "llvm.x86.avx512.packsswb.512" => "__builtin_ia32_packsswb512_mask", + "llvm.x86.avx512.packusdw.512" => "__builtin_ia32_packusdw512_mask", + "llvm.x86.avx512.packuswb.512" => "__builtin_ia32_packuswb512_mask", + "llvm.x86.avx512.pavg.w.512" => "__builtin_ia32_pavgw512_mask", + "llvm.x86.avx512.pavg.b.512" => "__builtin_ia32_pavgb512_mask", + "llvm.x86.avx512.psll.w.512" => "__builtin_ia32_psllw512_mask", + "llvm.x86.avx512.pslli.w.512" => "__builtin_ia32_psllwi512_mask", + "llvm.x86.avx512.psllv.w.512" => "__builtin_ia32_psllv32hi_mask", + "llvm.x86.avx512.psllv.w.256" => "__builtin_ia32_psllv16hi_mask", + "llvm.x86.avx512.psllv.w.128" => "__builtin_ia32_psllv8hi_mask", + "llvm.x86.avx512.psrl.w.512" => "__builtin_ia32_psrlw512_mask", + "llvm.x86.avx512.psrli.w.512" => "__builtin_ia32_psrlwi512_mask", + "llvm.x86.avx512.psrlv.w.512" => "__builtin_ia32_psrlv32hi_mask", + "llvm.x86.avx512.psrlv.w.256" => "__builtin_ia32_psrlv16hi_mask", + "llvm.x86.avx512.psrlv.w.128" => "__builtin_ia32_psrlv8hi_mask", + "llvm.x86.avx512.psra.w.512" => "__builtin_ia32_psraw512_mask", + "llvm.x86.avx512.psrai.w.512" => "__builtin_ia32_psrawi512_mask", + "llvm.x86.avx512.psrav.w.512" => "__builtin_ia32_psrav32hi_mask", + "llvm.x86.avx512.psrav.w.256" => "__builtin_ia32_psrav16hi_mask", + "llvm.x86.avx512.psrav.w.128" => "__builtin_ia32_psrav8hi_mask", + "llvm.x86.avx512.vpermi2var.hi.512" => "__builtin_ia32_vpermt2varhi512_mask", + "llvm.x86.avx512.vpermi2var.hi.256" => "__builtin_ia32_vpermt2varhi256_mask", + "llvm.x86.avx512.vpermi2var.hi.128" => "__builtin_ia32_vpermt2varhi128_mask", + "llvm.x86.avx512.permvar.hi.512" => "__builtin_ia32_permvarhi512_mask", + "llvm.x86.avx512.permvar.hi.256" => "__builtin_ia32_permvarhi256_mask", + "llvm.x86.avx512.permvar.hi.128" => "__builtin_ia32_permvarhi128_mask", + "llvm.x86.avx512.pshuf.b.512" => "__builtin_ia32_pshufb512_mask", + "llvm.x86.avx512.dbpsadbw.512" => "__builtin_ia32_dbpsadbw512_mask", + "llvm.x86.avx512.dbpsadbw.256" => "__builtin_ia32_dbpsadbw256_mask", + "llvm.x86.avx512.dbpsadbw.128" => "__builtin_ia32_dbpsadbw128_mask", + "llvm.x86.avx512.vpmadd52h.uq.512" => "__builtin_ia32_vpmadd52huq512_mask", + "llvm.x86.avx512.vpmadd52l.uq.512" => "__builtin_ia32_vpmadd52luq512_mask", + "llvm.x86.avx512.vpmadd52h.uq.256" => "__builtin_ia32_vpmadd52huq256", + "llvm.x86.avx512.vpmadd52l.uq.256" => "__builtin_ia32_vpmadd52luq256", + "llvm.x86.avx512.vpmadd52h.uq.128" => "__builtin_ia32_vpmadd52huq128", + "llvm.x86.avx512.vpdpwssd.512" => "__builtin_ia32_vpdpwssd_v16si", + "llvm.x86.avx512.vpdpwssd.256" => "__builtin_ia32_vpdpwssd_v8si", + "llvm.x86.avx512.vpdpwssd.128" => "__builtin_ia32_vpdpwssd_v4si", + "llvm.x86.avx512.vpdpwssds.512" => "__builtin_ia32_vpdpwssds_v16si", + "llvm.x86.avx512.vpdpwssds.256" => "__builtin_ia32_vpdpwssds_v8si", + "llvm.x86.avx512.vpdpwssds.128" => "__builtin_ia32_vpdpwssds_v4si", + "llvm.x86.avx512.vpdpbusd.512" => "__builtin_ia32_vpdpbusd_v16si", + "llvm.x86.avx512.vpdpbusd.256" => "__builtin_ia32_vpdpbusd_v8si", + "llvm.x86.avx512.vpdpbusd.128" => "__builtin_ia32_vpdpbusd_v4si", + "llvm.x86.avx512.vpdpbusds.512" => "__builtin_ia32_vpdpbusds_v16si", + "llvm.x86.avx512.vpdpbusds.256" => "__builtin_ia32_vpdpbusds_v8si", + "llvm.x86.avx512.vpdpbusds.128" => "__builtin_ia32_vpdpbusds_v4si", + "llvm.x86.xsave" => "__builtin_ia32_xsave", + "llvm.x86.xsave64" => "__builtin_ia32_xsave64", + "llvm.x86.xsaveopt" => "__builtin_ia32_xsaveopt", + "llvm.x86.xsaveopt64" => "__builtin_ia32_xsaveopt64", + "llvm.x86.avx512.mask.loadu.w.512" => "__builtin_ia32_loaddquhi512_mask", + "llvm.x86.avx512.mask.loadu.b.512" => "__builtin_ia32_loaddquqi512_mask", + "llvm.x86.avx512.mask.loadu.w.256" => "__builtin_ia32_loaddquhi256_mask", + "llvm.x86.avx512.mask.loadu.b.256" => "__builtin_ia32_loaddquqi256_mask", + "llvm.x86.avx512.mask.loadu.w.128" => "__builtin_ia32_loaddquhi128_mask", + "llvm.x86.avx512.mask.loadu.b.128" => "__builtin_ia32_loaddquqi128_mask", + "llvm.x86.avx512.mask.storeu.w.512" => "__builtin_ia32_storedquhi512_mask", + "llvm.x86.avx512.mask.storeu.b.512" => "__builtin_ia32_storedquqi512_mask", + "llvm.x86.avx512.mask.storeu.w.256" => "__builtin_ia32_storedquhi256_mask", + "llvm.x86.avx512.mask.storeu.b.256" => "__builtin_ia32_storedquqi256_mask", + "llvm.x86.avx512.mask.storeu.w.128" => "__builtin_ia32_storedquhi128_mask", + "llvm.x86.avx512.mask.storeu.b.128" => "__builtin_ia32_storedquqi128_mask", + "llvm.x86.avx512.mask.expand.load.w.512" => "__builtin_ia32_expandloadhi512_mask", + "llvm.x86.avx512.mask.expand.load.w.256" => "__builtin_ia32_expandloadhi256_mask", + "llvm.x86.avx512.mask.expand.load.w.128" => "__builtin_ia32_expandloadhi128_mask", + "llvm.x86.avx512.mask.expand.load.b.512" => "__builtin_ia32_expandloadqi512_mask", + "llvm.x86.avx512.mask.expand.load.b.256" => "__builtin_ia32_expandloadqi256_mask", + "llvm.x86.avx512.mask.expand.load.b.128" => "__builtin_ia32_expandloadqi128_mask", + "llvm.x86.avx512.sitofp.round.v8f64.v8i64" => "__builtin_ia32_cvtqq2pd512_mask", + "llvm.x86.avx512.sitofp.round.v2f64.v2i64" => "__builtin_ia32_cvtqq2pd128_mask", + "llvm.x86.avx512.sitofp.round.v4f64.v4i64" => "__builtin_ia32_cvtqq2pd256_mask", + "llvm.x86.avx512.sitofp.round.v8f32.v8i64" => "__builtin_ia32_cvtqq2ps512_mask", + "llvm.x86.avx512.sitofp.round.v4f32.v4i64" => "__builtin_ia32_cvtqq2ps256_mask", + "llvm.x86.avx512.uitofp.round.v8f64.v8u64" => "__builtin_ia32_cvtuqq2pd512_mask", + "llvm.x86.avx512.uitofp.round.v2f64.v2u64" => "__builtin_ia32_cvtuqq2pd128_mask", + "llvm.x86.avx512.uitofp.round.v4f64.v4u64" => "__builtin_ia32_cvtuqq2pd256_mask", + "llvm.x86.avx512.uitofp.round.v8f32.v8u64" => "__builtin_ia32_cvtuqq2ps512_mask", + "llvm.x86.avx512.uitofp.round.v4f32.v4u64" => "__builtin_ia32_cvtuqq2ps256_mask", + "llvm.x86.avx512.mask.reduce.pd.512" => "__builtin_ia32_reducepd512_mask_round", + "llvm.x86.avx512.mask.reduce.ps.512" => "__builtin_ia32_reduceps512_mask_round", + "llvm.x86.avx512.mask.reduce.sd" => "__builtin_ia32_reducesd_mask_round", + "llvm.x86.avx512.mask.reduce.ss" => "__builtin_ia32_reducess_mask_round", + "llvm.x86.avx512.mask.loadu.d.256" => "__builtin_ia32_loaddqusi256_mask", + "llvm.x86.avx512.mask.loadu.q.256" => "__builtin_ia32_loaddqudi256_mask", + "llvm.x86.avx512.mask.loadu.ps.256" => "__builtin_ia32_loadups256_mask", + "llvm.x86.avx512.mask.loadu.pd.256" => "__builtin_ia32_loadupd256_mask", + "llvm.x86.avx512.mask.loadu.d.128" => "__builtin_ia32_loaddqusi128_mask", + "llvm.x86.avx512.mask.loadu.q.128" => "__builtin_ia32_loaddqudi128_mask", + "llvm.x86.avx512.mask.loadu.ps.128" => "__builtin_ia32_loadups128_mask", + "llvm.x86.avx512.mask.loadu.pd.128" => "__builtin_ia32_loadupd128_mask", + "llvm.x86.avx512.mask.load.d.512" => "__builtin_ia32_movdqa32load512_mask", + "llvm.x86.avx512.mask.load.q.512" => "__builtin_ia32_movdqa64load512_mask", + "llvm.x86.avx512.mask.load.ps.512" => "__builtin_ia32_loadaps512_mask", + "llvm.x86.avx512.mask.load.pd.512" => "__builtin_ia32_loadapd512_mask", + "llvm.x86.avx512.mask.load.d.256" => "__builtin_ia32_movdqa32load256_mask", + "llvm.x86.avx512.mask.load.q.256" => "__builtin_ia32_movdqa64load256_mask", + "llvm.x86.avx512fp16.mask.cmp.sh" => "__builtin_ia32_cmpsh_mask_round", + "llvm.x86.avx512fp16.vcomi.sh" => "__builtin_ia32_cmpsh_mask_round", + "llvm.x86.avx512fp16.add.ph.512" => "__builtin_ia32_addph512_mask_round", + "llvm.x86.avx512fp16.sub.ph.512" => "__builtin_ia32_subph512_mask_round", + "llvm.x86.avx512fp16.mul.ph.512" => "__builtin_ia32_mulph512_mask_round", + "llvm.x86.avx512fp16.div.ph.512" => "__builtin_ia32_divph512_mask_round", + "llvm.x86.avx512fp16.mask.vfmul.cph.512" => "__builtin_ia32_vfmulcph512_mask_round", + "llvm.x86.avx512fp16.mask.vfmul.csh" => "__builtin_ia32_vfmulcsh_mask_round", + "llvm.x86.avx512fp16.mask.vfcmul.cph.512" => "__builtin_ia32_vfcmulcph512_mask_round", + "llvm.x86.avx512fp16.mask.vfcmul.csh" => "__builtin_ia32_vfcmulcsh_mask_round", + "llvm.x86.avx512fp16.mask.vfmadd.cph.512" => "__builtin_ia32_vfmaddcph512_mask3_round", + "llvm.x86.avx512fp16.maskz.vfmadd.cph.512" => "__builtin_ia32_vfmaddcph512_maskz_round", + "llvm.x86.avx512fp16.mask.vfmadd.csh" => "__builtin_ia32_vfmaddcsh_mask3_round", + "llvm.x86.avx512fp16.maskz.vfmadd.csh" => "__builtin_ia32_vfmaddcsh_maskz_round", + "llvm.x86.avx512fp16.mask.vfcmadd.cph.512" => "__builtin_ia32_vfcmaddcph512_mask3_round", + "llvm.x86.avx512fp16.maskz.vfcmadd.cph.512" => "__builtin_ia32_vfcmaddcph512_maskz_round", + "llvm.x86.avx512fp16.mask.vfcmadd.csh" => "__builtin_ia32_vfcmaddcsh_mask3_round", + "llvm.x86.avx512fp16.maskz.vfcmadd.csh" => "__builtin_ia32_vfcmaddcsh_maskz_round", + "llvm.x86.avx512fp16.vfmadd.ph.512" => "__builtin_ia32_vfmaddph512_mask", + "llvm.x86.avx512fp16.vcvtsi642sh" => "__builtin_ia32_vcvtsi2sh64_round", + "llvm.x86.avx512fp16.vcvtusi642sh" => "__builtin_ia32_vcvtusi2sh64_round", + "llvm.x86.avx512fp16.vcvtsh2si64" => "__builtin_ia32_vcvtsh2si64_round", + "llvm.x86.avx512fp16.vcvtsh2usi64" => "__builtin_ia32_vcvtsh2usi64_round", + "llvm.x86.avx512fp16.vcvttsh2si64" => "__builtin_ia32_vcvttsh2si64_round", + "llvm.x86.avx512fp16.vcvttsh2usi64" => "__builtin_ia32_vcvttsh2usi64_round", + "llvm.x86.avx512.mask.load.ps.256" => "__builtin_ia32_loadaps256_mask", + "llvm.x86.avx512.mask.load.pd.256" => "__builtin_ia32_loadapd256_mask", + "llvm.x86.avx512.mask.load.d.128" => "__builtin_ia32_movdqa32load128_mask", + "llvm.x86.avx512.mask.load.q.128" => "__builtin_ia32_movdqa64load128_mask", + "llvm.x86.avx512.mask.load.ps.128" => "__builtin_ia32_loadaps128_mask", + "llvm.x86.avx512.mask.load.pd.128" => "__builtin_ia32_loadapd128_mask", + "llvm.x86.avx512.mask.storeu.d.256" => "__builtin_ia32_storedqusi256_mask", + "llvm.x86.avx512.mask.storeu.q.256" => "__builtin_ia32_storedqudi256_mask", + "llvm.x86.avx512.mask.storeu.ps.256" => "__builtin_ia32_storeups256_mask", + "llvm.x86.avx512.mask.storeu.pd.256" => "__builtin_ia32_storeupd256_mask", + "llvm.x86.avx512.mask.storeu.d.128" => "__builtin_ia32_storedqusi128_mask", + "llvm.x86.avx512.mask.storeu.q.128" => "__builtin_ia32_storedqudi128_mask", + "llvm.x86.avx512.mask.storeu.ps.128" => "__builtin_ia32_storeups128_mask", + "llvm.x86.avx512.mask.storeu.pd.128" => "__builtin_ia32_storeupd128_mask", + "llvm.x86.avx512.mask.store.d.512" => "__builtin_ia32_movdqa32store512_mask", + "llvm.x86.avx512.mask.store.q.512" => "__builtin_ia32_movdqa64store512_mask", + "llvm.x86.avx512.mask.store.ps.512" => "__builtin_ia32_storeaps512_mask", + "llvm.x86.avx512.mask.store.pd.512" => "__builtin_ia32_storeapd512_mask", + "llvm.x86.avx512.mask.store.d.256" => "__builtin_ia32_movdqa32store256_mask", + "llvm.x86.avx512.mask.store.q.256" => "__builtin_ia32_movdqa64store256_mask", + "llvm.x86.avx512.mask.store.ps.256" => "__builtin_ia32_storeaps256_mask", + "llvm.x86.avx512.mask.store.pd.256" => "__builtin_ia32_storeapd256_mask", + "llvm.x86.avx512.mask.store.d.128" => "__builtin_ia32_movdqa32store128_mask", + "llvm.x86.avx512.mask.store.q.128" => "__builtin_ia32_movdqa64store128_mask", + "llvm.x86.avx512.mask.store.ps.128" => "__builtin_ia32_storeaps128_mask", + "llvm.x86.avx512.mask.store.pd.128" => "__builtin_ia32_storeapd128_mask", + "llvm.x86.avx512fp16.vfmadd.f16" => "__builtin_ia32_vfmaddsh3_mask", + "llvm.x86.avx512fp16.vfmaddsub.ph.128" => "__builtin_ia32_vfmaddsubph128_mask", + "llvm.x86.avx512fp16.vfmaddsub.ph.256" => "__builtin_ia32_vfmaddsubph256_mask", + "llvm.x86.avx512fp16.vfmaddsub.ph.512" => "__builtin_ia32_vfmaddsubph512_mask", + "llvm.x86.avx512fp16.sqrt.ph.512" => "__builtin_ia32_sqrtph512_mask_round", + "llvm.x86.avx512fp16.mask.sqrt.sh" => "__builtin_ia32_sqrtsh_mask_round", + "llvm.x86.avx512fp16.max.ph.128" => "__builtin_ia32_maxph128_mask", + "llvm.x86.avx512fp16.max.ph.256" => "__builtin_ia32_maxph256_mask", + "llvm.x86.avx512fp16.max.ph.512" => "__builtin_ia32_maxph512_mask_round", + "llvm.x86.avx512fp16.min.ph.128" => "__builtin_ia32_minph128_mask", + "llvm.x86.avx512fp16.min.ph.256" => "__builtin_ia32_minph256_mask", + "llvm.x86.avx512fp16.min.ph.512" => "__builtin_ia32_minph512_mask_round", + "llvm.x86.avx512fp16.mask.getexp.sh" => "__builtin_ia32_getexpsh_mask_round", + "llvm.x86.avx512fp16.mask.rndscale.ph.128" => "__builtin_ia32_rndscaleph128_mask", + "llvm.x86.avx512fp16.mask.rndscale.ph.256" => "__builtin_ia32_rndscaleph256_mask", + "llvm.x86.avx512fp16.mask.rndscale.ph.512" => "__builtin_ia32_rndscaleph512_mask_round", + "llvm.x86.avx512fp16.mask.scalef.ph.512" => "__builtin_ia32_scalefph512_mask_round", + "llvm.x86.avx512fp16.mask.reduce.ph.512" => "__builtin_ia32_reduceph512_mask_round", + "llvm.x86.avx512fp16.mask.reduce.sh" => "__builtin_ia32_reducesh_mask_round", + "llvm.x86.avx512.sitofp.round.v8f16.v8i16" => "__builtin_ia32_vcvtw2ph128_mask", + "llvm.x86.avx512.sitofp.round.v16f16.v16i16" => "__builtin_ia32_vcvtw2ph256_mask", + "llvm.x86.avx512.sitofp.round.v32f16.v32i16" => "__builtin_ia32_vcvtw2ph512_mask_round", + "llvm.x86.avx512.uitofp.round.v8f16.v8u16" => "__builtin_ia32_vcvtuw2ph128_mask", + "llvm.x86.avx512.uitofp.round.v16f16.v16u16" => "__builtin_ia32_vcvtuw2ph256_mask", + "llvm.x86.avx512.uitofp.round.v32f16.v32u16" => "__builtin_ia32_vcvtuw2ph512_mask_round", + "llvm.x86.avx512.sitofp.round.v8f16.v8i32" => "__builtin_ia32_vcvtdq2ph256_mask", + "llvm.x86.avx512.sitofp.round.v16f16.v16i32" => "__builtin_ia32_vcvtdq2ph512_mask_round", + "llvm.x86.avx512fp16.vcvtsi2sh" => "__builtin_ia32_vcvtsi2sh32_round", + "llvm.x86.avx512.uitofp.round.v8f16.v8u32" => "__builtin_ia32_vcvtudq2ph256_mask", + "llvm.x86.avx512.uitofp.round.v16f16.v16u32" => "__builtin_ia32_vcvtudq2ph512_mask_round", + "llvm.x86.avx512fp16.vcvtusi2sh" => "__builtin_ia32_vcvtusi2sh32_round", + "llvm.x86.avx512.sitofp.round.v8f16.v8i64" => "__builtin_ia32_vcvtqq2ph512_mask_round", + "llvm.x86.avx512.uitofp.round.v8f16.v8u64" => "__builtin_ia32_vcvtuqq2ph512_mask_round", + "llvm.x86.avx512fp16.mask.vcvtps2phx.512" => "__builtin_ia32_vcvtps2phx512_mask_round", + "llvm.x86.avx512fp16.mask.vcvtpd2ph.512" => "__builtin_ia32_vcvtpd2ph512_mask_round", + "llvm.x86.avx512fp16.mask.vcvtph2uw.512" => "__builtin_ia32_vcvtph2uw512_mask_round", + "llvm.x86.avx512fp16.mask.vcvttph2w.512" => "__builtin_ia32_vcvttph2w512_mask_round", + "llvm.x86.avx512fp16.mask.vcvttph2uw.512" => "__builtin_ia32_vcvttph2uw512_mask_round", + "llvm.x86.avx512fp16.mask.vcvtph2dq.512" => "__builtin_ia32_vcvtph2dq512_mask_round", + "llvm.x86.avx512fp16.vcvtsh2si32" => "__builtin_ia32_vcvtsh2si32_round", + "llvm.x86.avx512fp16.mask.vcvtph2udq.512" => "__builtin_ia32_vcvtph2udq512_mask_round", + "llvm.x86.avx512fp16.vcvtsh2usi32" => "__builtin_ia32_vcvtsh2usi32_round", + "llvm.x86.avx512fp16.mask.vcvttph2dq.512" => "__builtin_ia32_vcvttph2dq512_mask_round", + "llvm.x86.avx512fp16.vcvttsh2si32" => "__builtin_ia32_vcvttsh2si32_round", + "llvm.x86.avx512fp16.mask.vcvttph2udq.512" => "__builtin_ia32_vcvttph2udq512_mask_round", + "llvm.x86.avx512fp16.vcvttsh2usi32" => "__builtin_ia32_vcvttsh2usi32_round", + "llvm.x86.avx512fp16.mask.vcvtph2qq.512" => "__builtin_ia32_vcvtph2qq512_mask_round", + "llvm.x86.avx512fp16.mask.vcvtph2uqq.512" => "__builtin_ia32_vcvtph2uqq512_mask_round", + "llvm.x86.avx512fp16.mask.vcvttph2qq.512" => "__builtin_ia32_vcvttph2qq512_mask_round", + "llvm.x86.avx512fp16.mask.vcvttph2uqq.512" => "__builtin_ia32_vcvttph2uqq512_mask_round", + "llvm.x86.avx512fp16.mask.vcvtph2psx.512" => "__builtin_ia32_vcvtph2psx512_mask_round", + "llvm.x86.avx512fp16.mask.vcvtph2pd.512" => "__builtin_ia32_vcvtph2pd512_mask_round", + "llvm.x86.avx512fp16.mask.vfcmadd.cph.256" => "__builtin_ia32_vfcmaddcph256_mask3", + "llvm.x86.avx512fp16.mask.vfmadd.cph.256" => "__builtin_ia32_vfmaddcph256_mask3", + "llvm.x86.avx512fp16.mask.vfcmadd.cph.128" => "__builtin_ia32_vfcmaddcph128_mask3", + "llvm.x86.avx512fp16.mask.vfmadd.cph.128" => "__builtin_ia32_vfmaddcph128_mask3", + "llvm.x86.encodekey128" => "__builtin_ia32_encodekey128_u32", + "llvm.x86.encodekey256" => "__builtin_ia32_encodekey256_u32", + "llvm.x86.aesenc128kl" => "__builtin_ia32_aesenc128kl_u8", + "llvm.x86.aesdec128kl" => "__builtin_ia32_aesdec128kl_u8", + "llvm.x86.aesenc256kl" => "__builtin_ia32_aesenc256kl_u8", + "llvm.x86.aesdec256kl" => "__builtin_ia32_aesdec256kl_u8", + "llvm.x86.aesencwide128kl" => "__builtin_ia32_aesencwide128kl_u8", + "llvm.x86.aesdecwide128kl" => "__builtin_ia32_aesdecwide128kl_u8", + "llvm.x86.aesencwide256kl" => "__builtin_ia32_aesencwide256kl_u8", + "llvm.x86.aesdecwide256kl" => "__builtin_ia32_aesdecwide256kl_u8", + "llvm.x86.avx512.uitofp.round.v8f16.v8i16" => "__builtin_ia32_vcvtuw2ph128_mask", + "llvm.x86.avx512.uitofp.round.v16f16.v16i16" => "__builtin_ia32_vcvtuw2ph256_mask", + "llvm.x86.avx512.uitofp.round.v32f16.v32i16" => "__builtin_ia32_vcvtuw2ph512_mask_round", + "llvm.x86.avx512.uitofp.round.v8f16.v8i32" => "__builtin_ia32_vcvtudq2ph256_mask", + "llvm.x86.avx512.uitofp.round.v16f16.v16i32" => "__builtin_ia32_vcvtudq2ph512_mask_round", + "llvm.x86.avx512.uitofp.round.v8f16.v8i64" => "__builtin_ia32_vcvtuqq2ph512_mask_round", + "llvm.x86.avx512.uitofp.round.v8f64.v8i64" => "__builtin_ia32_cvtuqq2pd512_mask", + "llvm.x86.avx512.uitofp.round.v2f64.v2i64" => "__builtin_ia32_cvtuqq2pd128_mask", + "llvm.x86.avx512.uitofp.round.v4f64.v4i64" => "__builtin_ia32_cvtuqq2pd256_mask", + "llvm.x86.avx512.uitofp.round.v8f32.v8i64" => "__builtin_ia32_cvtuqq2ps512_mask", + "llvm.x86.avx512.uitofp.round.v4f32.v4i64" => "__builtin_ia32_cvtuqq2ps256_mask", + + // TODO: support the tile builtins: + "llvm.x86.ldtilecfg" => "__builtin_trap", + "llvm.x86.sttilecfg" => "__builtin_trap", + "llvm.x86.tileloadd64" => "__builtin_trap", + "llvm.x86.tilerelease" => "__builtin_trap", + "llvm.x86.tilestored64" => "__builtin_trap", + "llvm.x86.tileloaddt164" => "__builtin_trap", + "llvm.x86.tilezero" => "__builtin_trap", + "llvm.x86.tdpbf16ps" => "__builtin_trap", + "llvm.x86.tdpbssd" => "__builtin_trap", + "llvm.x86.tdpbsud" => "__builtin_trap", + "llvm.x86.tdpbusd" => "__builtin_trap", + "llvm.x86.tdpbuud" => "__builtin_trap", + "llvm.x86.tdpfp16ps" => "__builtin_trap", + "llvm.x86.tcmmimfp16ps" => "__builtin_trap", + "llvm.x86.tcmmrlfp16ps" => "__builtin_trap", + + // NOTE: this file is generated by https://github.com/GuillaumeGomez/llvmint/blob/master/generate_list.py + _ => map_arch_intrinsic(name), + }; + + let func = cx.context.get_target_builtin_function(gcc_name); + cx.functions.borrow_mut().insert(gcc_name.to_string(), func); + func +} + +#[cfg(feature = "master")] +include!("archs.rs"); diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs new file mode 100644 index 00000000000..eb0a5336a1f --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs @@ -0,0 +1,1505 @@ +pub mod llvm; +mod simd; + +#[cfg(feature = "master")] +use std::iter; + +#[cfg(feature = "master")] +use gccjit::Type; +use gccjit::{ComparisonOp, Function, FunctionType, RValue, ToRValue, UnaryOp}; +#[cfg(feature = "master")] +use rustc_abi::ExternAbi; +use rustc_abi::{BackendRepr, HasDataLayout}; +use rustc_codegen_ssa::MemFlags; +use rustc_codegen_ssa::base::wants_msvc_seh; +use rustc_codegen_ssa::common::IntPredicate; +use rustc_codegen_ssa::errors::InvalidMonomorphization; +use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; +use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue}; +#[cfg(feature = "master")] +use rustc_codegen_ssa::traits::MiscCodegenMethods; +use rustc_codegen_ssa::traits::{ + ArgAbiBuilderMethods, BaseTypeCodegenMethods, BuilderMethods, ConstCodegenMethods, + IntrinsicCallBuilderMethods, +}; +use rustc_middle::bug; +#[cfg(feature = "master")] +use rustc_middle::ty::layout::FnAbiOf; +use rustc_middle::ty::layout::LayoutOf; +use rustc_middle::ty::{self, Instance, Ty}; +use rustc_span::{Span, Symbol, sym}; +use rustc_target::callconv::{ArgAbi, PassMode}; +use rustc_target::spec::PanicStrategy; + +#[cfg(feature = "master")] +use crate::abi::FnAbiGccExt; +use crate::abi::GccType; +use crate::builder::Builder; +use crate::common::{SignType, TypeReflection}; +use crate::context::CodegenCx; +use crate::intrinsic::simd::generic_simd_intrinsic; +use crate::type_of::LayoutGccExt; + +fn get_simple_intrinsic<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + name: Symbol, +) -> Option<Function<'gcc>> { + let gcc_name = match name { + sym::sqrtf32 => "sqrtf", + sym::sqrtf64 => "sqrt", + sym::powif32 => "__builtin_powif", + sym::powif64 => "__builtin_powi", + sym::sinf32 => "sinf", + sym::sinf64 => "sin", + sym::cosf32 => "cosf", + sym::cosf64 => "cos", + sym::powf32 => "powf", + sym::powf64 => "pow", + sym::expf32 => "expf", + sym::expf64 => "exp", + sym::exp2f32 => "exp2f", + sym::exp2f64 => "exp2", + sym::logf32 => "logf", + sym::logf64 => "log", + sym::log10f32 => "log10f", + sym::log10f64 => "log10", + sym::log2f32 => "log2f", + sym::log2f64 => "log2", + sym::fmaf32 => "fmaf", + sym::fmaf64 => "fma", + // FIXME: calling `fma` from libc without FMA target feature uses expensive software emulation + sym::fmuladdf32 => "fmaf", // TODO: use gcc intrinsic analogous to llvm.fmuladd.f32 + sym::fmuladdf64 => "fma", // TODO: use gcc intrinsic analogous to llvm.fmuladd.f64 + sym::fabsf32 => "fabsf", + sym::fabsf64 => "fabs", + sym::minnumf32 => "fminf", + sym::minnumf64 => "fmin", + sym::minimumf32 => "fminimumf", + sym::minimumf64 => "fminimum", + sym::minimumf128 => { + // GCC doesn't have the intrinsic we want so we use the compiler-builtins one + // https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fminimumf128.html + let f128_type = cx.type_f128(); + return Some(cx.context.new_function( + None, + FunctionType::Extern, + f128_type, + &[ + cx.context.new_parameter(None, f128_type, "a"), + cx.context.new_parameter(None, f128_type, "b"), + ], + "fminimumf128", + false, + )); + } + sym::maxnumf32 => "fmaxf", + sym::maxnumf64 => "fmax", + sym::maximumf32 => "fmaximumf", + sym::maximumf64 => "fmaximum", + sym::maximumf128 => { + // GCC doesn't have the intrinsic we want so we use the compiler-builtins one + // https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fmaximumf128.html + let f128_type = cx.type_f128(); + return Some(cx.context.new_function( + None, + FunctionType::Extern, + f128_type, + &[ + cx.context.new_parameter(None, f128_type, "a"), + cx.context.new_parameter(None, f128_type, "b"), + ], + "fmaximumf128", + false, + )); + } + sym::copysignf32 => "copysignf", + sym::copysignf64 => "copysign", + sym::floorf32 => "floorf", + sym::floorf64 => "floor", + sym::ceilf32 => "ceilf", + sym::ceilf64 => "ceil", + sym::truncf32 => "truncf", + sym::truncf64 => "trunc", + // We match the LLVM backend and lower this to `rint`. + sym::round_ties_even_f32 => "rintf", + sym::round_ties_even_f64 => "rint", + sym::roundf32 => "roundf", + sym::roundf64 => "round", + sym::abort => "abort", + _ => return None, + }; + Some(cx.context.get_builtin_function(gcc_name)) +} + +// TODO(antoyo): We can probably remove these and use the fallback intrinsic implementation. +fn get_simple_function<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + name: Symbol, +) -> Option<Function<'gcc>> { + let (return_type, parameters, func_name) = match name { + sym::minimumf32 => { + let parameters = [ + cx.context.new_parameter(None, cx.float_type, "a"), + cx.context.new_parameter(None, cx.float_type, "b"), + ]; + (cx.float_type, parameters, "fminimumf") + } + sym::minimumf64 => { + let parameters = [ + cx.context.new_parameter(None, cx.double_type, "a"), + cx.context.new_parameter(None, cx.double_type, "b"), + ]; + (cx.double_type, parameters, "fminimum") + } + sym::minimumf128 => { + let f128_type = cx.type_f128(); + // GCC doesn't have the intrinsic we want so we use the compiler-builtins one + // https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fminimumf128.html + let parameters = [ + cx.context.new_parameter(None, f128_type, "a"), + cx.context.new_parameter(None, f128_type, "b"), + ]; + (f128_type, parameters, "fminimumf128") + } + sym::maximumf32 => { + let parameters = [ + cx.context.new_parameter(None, cx.float_type, "a"), + cx.context.new_parameter(None, cx.float_type, "b"), + ]; + (cx.float_type, parameters, "fmaximumf") + } + sym::maximumf64 => { + let parameters = [ + cx.context.new_parameter(None, cx.double_type, "a"), + cx.context.new_parameter(None, cx.double_type, "b"), + ]; + (cx.double_type, parameters, "fmaximum") + } + sym::maximumf128 => { + let f128_type = cx.type_f128(); + // GCC doesn't have the intrinsic we want so we use the compiler-builtins one + // https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fmaximumf128.html + let parameters = [ + cx.context.new_parameter(None, f128_type, "a"), + cx.context.new_parameter(None, f128_type, "b"), + ]; + (f128_type, parameters, "fmaximumf128") + } + _ => return None, + }; + Some(cx.context.new_function( + None, + FunctionType::Extern, + return_type, + ¶meters, + func_name, + false, + )) +} + +fn get_simple_function_f128<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + name: Symbol, +) -> Option<Function<'gcc>> { + if !cx.supports_f128_type { + return None; + } + + let f128_type = cx.type_f128(); + let func_name = match name { + sym::ceilf128 => "ceilf128", + sym::floorf128 => "floorf128", + sym::truncf128 => "truncf128", + sym::roundf128 => "roundf128", + sym::round_ties_even_f128 => "roundevenf128", + sym::sqrtf128 => "sqrtf128", + _ => return None, + }; + Some(cx.context.new_function( + None, + FunctionType::Extern, + f128_type, + &[cx.context.new_parameter(None, f128_type, "a")], + func_name, + false, + )) +} + +fn get_simple_function_f128_2args<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + name: Symbol, +) -> Option<Function<'gcc>> { + if !cx.supports_f128_type { + return None; + } + + let f128_type = cx.type_f128(); + let func_name = match name { + sym::maxnumf128 => "fmaxf128", + sym::minnumf128 => "fminf128", + sym::copysignf128 => "copysignf128", + _ => return None, + }; + Some(cx.context.new_function( + None, + FunctionType::Extern, + f128_type, + &[ + cx.context.new_parameter(None, f128_type, "a"), + cx.context.new_parameter(None, f128_type, "b"), + ], + func_name, + false, + )) +} + +fn f16_builtin<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + name: Symbol, + args: &[OperandRef<'tcx, RValue<'gcc>>], +) -> RValue<'gcc> { + let f32_type = cx.type_f32(); + let builtin_name = match name { + sym::ceilf16 => "__builtin_ceilf", + sym::copysignf16 => "__builtin_copysignf", + sym::floorf16 => "__builtin_floorf", + sym::fmaf16 => "fmaf", + sym::maxnumf16 => "__builtin_fmaxf", + sym::minnumf16 => "__builtin_fminf", + sym::powf16 => "__builtin_powf", + sym::powif16 => { + let func = cx.context.get_builtin_function("__builtin_powif"); + let arg0 = cx.context.new_cast(None, args[0].immediate(), f32_type); + let args = [arg0, args[1].immediate()]; + let result = cx.context.new_call(None, func, &args); + return cx.context.new_cast(None, result, cx.type_f16()); + } + sym::roundf16 => "__builtin_roundf", + sym::round_ties_even_f16 => "__builtin_rintf", + sym::sqrtf16 => "__builtin_sqrtf", + sym::truncf16 => "__builtin_truncf", + _ => unreachable!(), + }; + + let func = cx.context.get_builtin_function(builtin_name); + let args: Vec<_> = + args.iter().map(|arg| cx.context.new_cast(None, arg.immediate(), f32_type)).collect(); + let result = cx.context.new_call(None, func, &args); + cx.context.new_cast(None, result, cx.type_f16()) +} + +impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { + fn codegen_intrinsic_call( + &mut self, + instance: Instance<'tcx>, + args: &[OperandRef<'tcx, RValue<'gcc>>], + result: PlaceRef<'tcx, RValue<'gcc>>, + span: Span, + ) -> Result<(), Instance<'tcx>> { + let tcx = self.tcx; + + let name = tcx.item_name(instance.def_id()); + let name_str = name.as_str(); + let fn_args = instance.args; + + let simple = get_simple_intrinsic(self, name); + // TODO(antoyo): Only call get_simple_function_f128 and get_simple_function_f128_2args when + // it is the symbols for the supported f128 builtins. + let simple_func = get_simple_function(self, name) + .or_else(|| get_simple_function_f128(self, name)) + .or_else(|| get_simple_function_f128_2args(self, name)); + + // FIXME(tempdragon): Re-enable `clippy::suspicious_else_formatting` if the following issue is solved: + // https://github.com/rust-lang/rust-clippy/issues/12497 + // and leave `else if use_integer_compare` to be placed "as is". + #[allow(clippy::suspicious_else_formatting)] + let value = match name { + _ if simple.is_some() => { + let func = simple.expect("simple intrinsic function"); + self.cx.context.new_call( + self.location, + func, + &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), + ) + } + _ if simple_func.is_some() => { + let func = simple_func.expect("simple function"); + self.cx.context.new_call( + self.location, + func, + &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), + ) + } + sym::ceilf16 + | sym::copysignf16 + | sym::floorf16 + | sym::fmaf16 + | sym::maxnumf16 + | sym::minnumf16 + | sym::powf16 + | sym::powif16 + | sym::roundf16 + | sym::round_ties_even_f16 + | sym::sqrtf16 + | sym::truncf16 => f16_builtin(self, name, args), + sym::fmaf128 => { + let f128_type = self.cx.type_f128(); + let func = self.cx.context.new_function( + None, + FunctionType::Extern, + f128_type, + &[ + self.cx.context.new_parameter(None, f128_type, "a"), + self.cx.context.new_parameter(None, f128_type, "b"), + self.cx.context.new_parameter(None, f128_type, "c"), + ], + "fmaf128", + false, + ); + self.cx.context.new_call( + self.location, + func, + &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), + ) + } + sym::powif128 => { + let f128_type = self.cx.type_f128(); + let func = self.cx.context.new_function( + None, + FunctionType::Extern, + f128_type, + &[ + self.cx.context.new_parameter(None, f128_type, "a"), + self.cx.context.new_parameter(None, self.int_type, "b"), + ], + "__powitf2", + false, + ); + self.cx.context.new_call( + self.location, + func, + &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), + ) + } + sym::is_val_statically_known => { + let a = args[0].immediate(); + let builtin = self.context.get_builtin_function("__builtin_constant_p"); + let res = self.context.new_call(None, builtin, &[a]); + self.icmp(IntPredicate::IntEQ, res, self.const_i32(0)) + } + sym::catch_unwind => { + try_intrinsic( + self, + args[0].immediate(), + args[1].immediate(), + args[2].immediate(), + result, + ); + return Ok(()); + } + sym::breakpoint => { + unimplemented!(); + } + sym::va_copy => { + unimplemented!(); + } + sym::va_arg => { + unimplemented!(); + } + + sym::volatile_load | sym::unaligned_volatile_load => { + let ptr = args[0].immediate(); + let load = self.volatile_load(result.layout.gcc_type(self), ptr); + // TODO(antoyo): set alignment. + if let BackendRepr::Scalar(scalar) = result.layout.backend_repr { + self.to_immediate_scalar(load, scalar) + } else { + load + } + } + sym::volatile_store => { + let dst = args[0].deref(self.cx()); + args[1].val.volatile_store(self, dst); + return Ok(()); + } + sym::unaligned_volatile_store => { + let dst = args[0].deref(self.cx()); + args[1].val.unaligned_volatile_store(self, dst); + return Ok(()); + } + sym::prefetch_read_data + | sym::prefetch_write_data + | sym::prefetch_read_instruction + | sym::prefetch_write_instruction => { + unimplemented!(); + } + sym::ctlz + | sym::ctlz_nonzero + | sym::cttz + | sym::cttz_nonzero + | sym::ctpop + | sym::bswap + | sym::bitreverse + | sym::rotate_left + | sym::rotate_right + | sym::saturating_add + | sym::saturating_sub => { + match int_type_width_signed(args[0].layout.ty, self) { + Some((width, signed)) => match name { + sym::ctlz | sym::cttz => { + let func = self.current_func(); + let then_block = func.new_block("then"); + let else_block = func.new_block("else"); + let after_block = func.new_block("after"); + + let arg = args[0].immediate(); + let result = func.new_local(None, self.u32_type, "zeros"); + let zero = self.cx.gcc_zero(arg.get_type()); + let cond = self.gcc_icmp(IntPredicate::IntEQ, arg, zero); + self.llbb().end_with_conditional(None, cond, then_block, else_block); + + let zero_result = self.cx.gcc_uint(self.u32_type, width); + then_block.add_assignment(None, result, zero_result); + then_block.end_with_jump(None, after_block); + + // NOTE: since jumps were added in a place + // count_leading_zeroes() does not expect, the current block + // in the state need to be updated. + self.switch_to_block(else_block); + + let zeros = match name { + sym::ctlz => self.count_leading_zeroes(width, arg), + sym::cttz => self.count_trailing_zeroes(width, arg), + _ => unreachable!(), + }; + self.llbb().add_assignment(None, result, zeros); + self.llbb().end_with_jump(None, after_block); + + // NOTE: since jumps were added in a place rustc does not + // expect, the current block in the state need to be updated. + self.switch_to_block(after_block); + + result.to_rvalue() + } + sym::ctlz_nonzero => self.count_leading_zeroes(width, args[0].immediate()), + sym::cttz_nonzero => self.count_trailing_zeroes(width, args[0].immediate()), + sym::ctpop => self.pop_count(args[0].immediate()), + sym::bswap => { + if width == 8 { + args[0].immediate() // byte swap a u8/i8 is just a no-op + } else { + self.gcc_bswap(args[0].immediate(), width) + } + } + sym::bitreverse => self.bit_reverse(width, args[0].immediate()), + sym::rotate_left | sym::rotate_right => { + // TODO(antoyo): implement using algorithm from: + // https://blog.regehr.org/archives/1063 + // for other platforms. + let is_left = name == sym::rotate_left; + let val = args[0].immediate(); + let raw_shift = args[1].immediate(); + if is_left { + self.rotate_left(val, raw_shift, width) + } else { + self.rotate_right(val, raw_shift, width) + } + } + sym::saturating_add => self.saturating_add( + args[0].immediate(), + args[1].immediate(), + signed, + width, + ), + sym::saturating_sub => self.saturating_sub( + args[0].immediate(), + args[1].immediate(), + signed, + width, + ), + _ => bug!(), + }, + None => { + tcx.dcx().emit_err(InvalidMonomorphization::BasicIntegerType { + span, + name, + ty: args[0].layout.ty, + }); + return Ok(()); + } + } + } + + sym::raw_eq => { + use rustc_abi::BackendRepr::*; + let tp_ty = fn_args.type_at(0); + let layout = self.layout_of(tp_ty).layout; + let _use_integer_compare = match layout.backend_repr() { + Scalar(_) | ScalarPair(_, _) => true, + SimdVector { .. } => false, + Memory { .. } => { + // For rusty ABIs, small aggregates are actually passed + // as `RegKind::Integer` (see `FnAbi::adjust_for_abi`), + // so we re-use that same threshold here. + layout.size() <= self.data_layout().pointer_size() * 2 + } + }; + + let a = args[0].immediate(); + let b = args[1].immediate(); + if layout.size().bytes() == 0 { + self.const_bool(true) + } + /*else if use_integer_compare { + let integer_ty = self.type_ix(layout.size.bits()); // FIXME(antoyo): LLVM creates an integer of 96 bits for [i32; 3], but gcc doesn't support this, so it creates an integer of 128 bits. + let ptr_ty = self.type_ptr_to(integer_ty); + let a_ptr = self.bitcast(a, ptr_ty); + let a_val = self.load(integer_ty, a_ptr, layout.align.abi); + let b_ptr = self.bitcast(b, ptr_ty); + let b_val = self.load(integer_ty, b_ptr, layout.align.abi); + self.icmp(IntPredicate::IntEQ, a_val, b_val) + }*/ + else { + let void_ptr_type = self.context.new_type::<*const ()>(); + let a_ptr = self.bitcast(a, void_ptr_type); + let b_ptr = self.bitcast(b, void_ptr_type); + let n = self.context.new_cast( + None, + self.const_usize(layout.size().bytes()), + self.sizet_type, + ); + let builtin = self.context.get_builtin_function("memcmp"); + let cmp = self.context.new_call(None, builtin, &[a_ptr, b_ptr, n]); + self.icmp(IntPredicate::IntEQ, cmp, self.const_i32(0)) + } + } + + sym::compare_bytes => { + let a = args[0].immediate(); + let b = args[1].immediate(); + let n = args[2].immediate(); + + let void_ptr_type = self.context.new_type::<*const ()>(); + let a_ptr = self.bitcast(a, void_ptr_type); + let b_ptr = self.bitcast(b, void_ptr_type); + + // Here we assume that the `memcmp` provided by the target is a NOP for size 0. + let builtin = self.context.get_builtin_function("memcmp"); + let cmp = self.context.new_call(None, builtin, &[a_ptr, b_ptr, n]); + self.sext(cmp, self.type_ix(32)) + } + + sym::black_box => { + args[0].val.store(self, result); + + let block = self.llbb(); + let extended_asm = block.add_extended_asm(None, ""); + extended_asm.add_input_operand(None, "r", result.val.llval); + extended_asm.add_clobber("memory"); + extended_asm.set_volatile_flag(true); + + // We have copied the value to `result` already. + return Ok(()); + } + + sym::ptr_mask => { + let usize_type = self.context.new_type::<usize>(); + let void_ptr_type = self.context.new_type::<*const ()>(); + + let ptr = args[0].immediate(); + let mask = args[1].immediate(); + + let addr = self.bitcast(ptr, usize_type); + let masked = self.and(addr, mask); + self.bitcast(masked, void_ptr_type) + } + + _ if name_str.starts_with("simd_") => { + match generic_simd_intrinsic( + self, + name, + args, + result.layout.ty, + result.layout.gcc_type(self), + span, + ) { + Ok(value) => value, + Err(()) => return Ok(()), + } + } + + // Fall back to default body + _ => return Err(Instance::new_raw(instance.def_id(), instance.args)), + }; + + if result.layout.ty.is_bool() { + let val = self.from_immediate(value); + self.store_to_place(val, result.val); + } else if !result.layout.ty.is_unit() { + self.store_to_place(value, result.val); + } + Ok(()) + } + + fn abort(&mut self) { + let func = self.context.get_builtin_function("abort"); + let func: RValue<'gcc> = unsafe { std::mem::transmute(func) }; + self.call(self.type_void(), None, None, func, &[], None, None); + } + + fn assume(&mut self, value: Self::Value) { + // TODO(antoyo): switch to assume when it exists. + // Or use something like this: + // #define __assume(cond) do { if (!(cond)) __builtin_unreachable(); } while (0) + self.expect(value, true); + } + + fn expect(&mut self, cond: Self::Value, _expected: bool) -> Self::Value { + // TODO(antoyo) + cond + } + + fn type_checked_load( + &mut self, + _vtable: Self::Value, + _vtable_byte_offset: u64, + _typeid: Self::Value, + ) -> Self::Value { + // Unsupported. + self.context.new_rvalue_from_int(self.int_type, 0) + } + + fn va_start(&mut self, _va_list: RValue<'gcc>) -> RValue<'gcc> { + unimplemented!(); + } + + fn va_end(&mut self, _va_list: RValue<'gcc>) -> RValue<'gcc> { + unimplemented!(); + } +} + +impl<'a, 'gcc, 'tcx> ArgAbiBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { + fn store_fn_arg( + &mut self, + arg_abi: &ArgAbi<'tcx, Ty<'tcx>>, + idx: &mut usize, + dst: PlaceRef<'tcx, Self::Value>, + ) { + arg_abi.store_fn_arg(self, idx, dst) + } + + fn store_arg( + &mut self, + arg_abi: &ArgAbi<'tcx, Ty<'tcx>>, + val: RValue<'gcc>, + dst: PlaceRef<'tcx, RValue<'gcc>>, + ) { + arg_abi.store(self, val, dst) + } +} + +pub trait ArgAbiExt<'gcc, 'tcx> { + fn store( + &self, + bx: &mut Builder<'_, 'gcc, 'tcx>, + val: RValue<'gcc>, + dst: PlaceRef<'tcx, RValue<'gcc>>, + ); + fn store_fn_arg( + &self, + bx: &mut Builder<'_, 'gcc, 'tcx>, + idx: &mut usize, + dst: PlaceRef<'tcx, RValue<'gcc>>, + ); +} + +impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { + /// Stores a direct/indirect value described by this ArgAbi into a + /// place for the original Rust type of this argument/return. + /// Can be used for both storing formal arguments into Rust variables + /// or results of call/invoke instructions into their destinations. + fn store( + &self, + bx: &mut Builder<'_, 'gcc, 'tcx>, + val: RValue<'gcc>, + dst: PlaceRef<'tcx, RValue<'gcc>>, + ) { + if self.is_ignore() { + return; + } + if self.is_sized_indirect() { + OperandValue::Ref(PlaceValue::new_sized(val, self.layout.align.abi)).store(bx, dst) + } else if self.is_unsized_indirect() { + bug!("unsized `ArgAbi` must be handled through `store_fn_arg`"); + } else if let PassMode::Cast { ref cast, .. } = self.mode { + // FIXME(eddyb): Figure out when the simpler Store is safe, clang + // uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}. + let can_store_through_cast_ptr = false; + if can_store_through_cast_ptr { + let cast_ptr_llty = bx.type_ptr_to(cast.gcc_type(bx)); + let cast_dst = bx.pointercast(dst.val.llval, cast_ptr_llty); + bx.store(val, cast_dst, self.layout.align.abi); + } else { + // The actual return type is a struct, but the ABI + // adaptation code has cast it into some scalar type. The + // code that follows is the only reliable way I have + // found to do a transform like i64 -> {i32,i32}. + // Basically we dump the data onto the stack then memcpy it. + // + // Other approaches I tried: + // - Casting rust ret pointer to the foreign type and using Store + // is (a) unsafe if size of foreign type > size of rust type and + // (b) runs afoul of strict aliasing rules, yielding invalid + // assembly under -O (specifically, the store gets removed). + // - Truncating foreign type to correct integral type and then + // bitcasting to the struct type yields invalid cast errors. + + // We instead thus allocate some scratch space... + let scratch_size = cast.size(bx); + let scratch_align = cast.align(bx); + let scratch = bx.alloca(scratch_size, scratch_align); + bx.lifetime_start(scratch, scratch_size); + + // ... where we first store the value... + rustc_codegen_ssa::mir::store_cast(bx, cast, val, scratch, scratch_align); + + // ... and then memcpy it to the intended destination. + bx.memcpy( + dst.val.llval, + self.layout.align.abi, + scratch, + scratch_align, + bx.const_usize(self.layout.size.bytes()), + MemFlags::empty(), + ); + + bx.lifetime_end(scratch, scratch_size); + } + } else { + OperandValue::Immediate(val).store(bx, dst); + } + } + + fn store_fn_arg<'a>( + &self, + bx: &mut Builder<'a, 'gcc, 'tcx>, + idx: &mut usize, + dst: PlaceRef<'tcx, RValue<'gcc>>, + ) { + let mut next = || { + let val = bx.current_func().get_param(*idx as i32); + *idx += 1; + val.to_rvalue() + }; + match self.mode { + PassMode::Ignore => {} + PassMode::Pair(..) => { + OperandValue::Pair(next(), next()).store(bx, dst); + } + PassMode::Indirect { meta_attrs: Some(_), .. } => { + let place_val = PlaceValue { + llval: next(), + llextra: Some(next()), + align: self.layout.align.abi, + }; + OperandValue::Ref(place_val).store(bx, dst); + } + PassMode::Direct(_) + | PassMode::Indirect { meta_attrs: None, .. } + | PassMode::Cast { .. } => { + let next_arg = next(); + self.store(bx, next_arg, dst); + } + } + } +} + +fn int_type_width_signed<'gcc, 'tcx>( + ty: Ty<'tcx>, + cx: &CodegenCx<'gcc, 'tcx>, +) -> Option<(u64, bool)> { + match *ty.kind() { + ty::Int(t) => Some(( + match t { + rustc_middle::ty::IntTy::Isize => u64::from(cx.tcx.sess.target.pointer_width), + rustc_middle::ty::IntTy::I8 => 8, + rustc_middle::ty::IntTy::I16 => 16, + rustc_middle::ty::IntTy::I32 => 32, + rustc_middle::ty::IntTy::I64 => 64, + rustc_middle::ty::IntTy::I128 => 128, + }, + true, + )), + ty::Uint(t) => Some(( + match t { + rustc_middle::ty::UintTy::Usize => u64::from(cx.tcx.sess.target.pointer_width), + rustc_middle::ty::UintTy::U8 => 8, + rustc_middle::ty::UintTy::U16 => 16, + rustc_middle::ty::UintTy::U32 => 32, + rustc_middle::ty::UintTy::U64 => 64, + rustc_middle::ty::UintTy::U128 => 128, + }, + false, + )), + _ => None, + } +} + +impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { + fn bit_reverse(&mut self, width: u64, value: RValue<'gcc>) -> RValue<'gcc> { + let result_type = value.get_type(); + let typ = result_type.to_unsigned(self.cx); + + let value = + if result_type.is_signed(self.cx) { self.gcc_int_cast(value, typ) } else { value }; + + let context = &self.cx.context; + let result = match width { + 8 | 16 | 32 | 64 => { + let mask = ((1u128 << width) - 1) as u64; + let (m0, m1, m2) = if width > 16 { + ( + context.new_rvalue_from_long(typ, (0x5555555555555555u64 & mask) as i64), + context.new_rvalue_from_long(typ, (0x3333333333333333u64 & mask) as i64), + context.new_rvalue_from_long(typ, (0x0f0f0f0f0f0f0f0fu64 & mask) as i64), + ) + } else { + ( + context.new_rvalue_from_int(typ, (0x5555u64 & mask) as i32), + context.new_rvalue_from_int(typ, (0x3333u64 & mask) as i32), + context.new_rvalue_from_int(typ, (0x0f0fu64 & mask) as i32), + ) + }; + let one = context.new_rvalue_from_int(typ, 1); + let two = context.new_rvalue_from_int(typ, 2); + let four = context.new_rvalue_from_int(typ, 4); + + // First step. + let left = self.lshr(value, one); + let left = self.and(left, m0); + let right = self.and(value, m0); + let right = self.shl(right, one); + let step1 = self.or(left, right); + + // Second step. + let left = self.lshr(step1, two); + let left = self.and(left, m1); + let right = self.and(step1, m1); + let right = self.shl(right, two); + let step2 = self.or(left, right); + + // Third step. + let left = self.lshr(step2, four); + let left = self.and(left, m2); + let right = self.and(step2, m2); + let right = self.shl(right, four); + let step3 = self.or(left, right); + + // Fourth step. + if width == 8 { step3 } else { self.gcc_bswap(step3, width) } + } + 128 => { + // TODO(antoyo): find a more efficient implementation? + let sixty_four = self.gcc_int(typ, 64); + let right_shift = self.gcc_lshr(value, sixty_four); + let high = self.gcc_int_cast(right_shift, self.u64_type); + let low = self.gcc_int_cast(value, self.u64_type); + + let reversed_high = self.bit_reverse(64, high); + let reversed_low = self.bit_reverse(64, low); + + let new_low = self.gcc_int_cast(reversed_high, typ); + let new_high = self.shl(self.gcc_int_cast(reversed_low, typ), sixty_four); + + self.gcc_or(new_low, new_high, self.location) + } + _ => { + panic!("cannot bit reverse with width = {}", width); + } + }; + + self.gcc_int_cast(result, result_type) + } + + fn count_leading_zeroes(&mut self, width: u64, arg: RValue<'gcc>) -> RValue<'gcc> { + // TODO(antoyo): use width? + let arg_type = arg.get_type(); + let result_type = self.u32_type; + let arg = if arg_type.is_signed(self.cx) { + let new_type = arg_type.to_unsigned(self.cx); + self.gcc_int_cast(arg, new_type) + } else { + arg + }; + let arg_type = arg.get_type(); + let count_leading_zeroes = + // TODO(antoyo): write a new function Type::is_compatible_with(&Type) and use it here + // instead of using is_uint(). + if arg_type.is_uchar(self.cx) || arg_type.is_ushort(self.cx) || arg_type.is_uint(self.cx) { + "__builtin_clz" + } + else if arg_type.is_ulong(self.cx) { + "__builtin_clzl" + } + else if arg_type.is_ulonglong(self.cx) { + "__builtin_clzll" + } + else if width == 128 { + // Algorithm from: https://stackoverflow.com/a/28433850/389119 + let array_type = self.context.new_array_type(None, arg_type, 3); + let result = self.current_func() + .new_local(None, array_type, "count_loading_zeroes_results"); + + let sixty_four = self.const_uint(arg_type, 64); + let shift = self.lshr(arg, sixty_four); + let high = self.gcc_int_cast(shift, self.u64_type); + let low = self.gcc_int_cast(arg, self.u64_type); + + let zero = self.context.new_rvalue_zero(self.usize_type); + let one = self.context.new_rvalue_one(self.usize_type); + let two = self.context.new_rvalue_from_long(self.usize_type, 2); + + let clzll = self.context.get_builtin_function("__builtin_clzll"); + + let first_elem = self.context.new_array_access(None, result, zero); + let first_value = self.gcc_int_cast(self.context.new_call(None, clzll, &[high]), arg_type); + self.llbb() + .add_assignment(self.location, first_elem, first_value); + + let second_elem = self.context.new_array_access(self.location, result, one); + let cast = self.gcc_int_cast(self.context.new_call(self.location, clzll, &[low]), arg_type); + let second_value = self.add(cast, sixty_four); + self.llbb() + .add_assignment(self.location, second_elem, second_value); + + let third_elem = self.context.new_array_access(self.location, result, two); + let third_value = self.const_uint(arg_type, 128); + self.llbb() + .add_assignment(self.location, third_elem, third_value); + + let not_high = self.context.new_unary_op(self.location, UnaryOp::LogicalNegate, self.u64_type, high); + let not_low = self.context.new_unary_op(self.location, UnaryOp::LogicalNegate, self.u64_type, low); + let not_low_and_not_high = not_low & not_high; + let index = not_high + not_low_and_not_high; + // NOTE: the following cast is necessary to avoid a GIMPLE verification failure in + // gcc. + // TODO(antoyo): do the correct verification in libgccjit to avoid an error at the + // compilation stage. + let index = self.context.new_cast(self.location, index, self.i32_type); + + let res = self.context.new_array_access(self.location, result, index); + + return self.gcc_int_cast(res.to_rvalue(), result_type); + } + else { + let count_leading_zeroes = self.context.get_builtin_function("__builtin_clzll"); + let arg = self.context.new_cast(self.location, arg, self.ulonglong_type); + let diff = self.ulonglong_type.get_size() as i64 - arg_type.get_size() as i64; + let diff = self.context.new_rvalue_from_long(self.int_type, diff * 8); + let res = self.context.new_call(self.location, count_leading_zeroes, &[arg]) - diff; + return self.context.new_cast(self.location, res, result_type); + }; + let count_leading_zeroes = self.context.get_builtin_function(count_leading_zeroes); + let res = self.context.new_call(self.location, count_leading_zeroes, &[arg]); + self.context.new_cast(self.location, res, result_type) + } + + fn count_trailing_zeroes(&mut self, _width: u64, arg: RValue<'gcc>) -> RValue<'gcc> { + let arg_type = arg.get_type(); + let result_type = self.u32_type; + let arg = if arg_type.is_signed(self.cx) { + let new_type = arg_type.to_unsigned(self.cx); + self.gcc_int_cast(arg, new_type) + } else { + arg + }; + let arg_type = arg.get_type(); + let (count_trailing_zeroes, expected_type) = + // TODO(antoyo): write a new function Type::is_compatible_with(&Type) and use it here + // instead of using is_uint(). + if arg_type.is_uchar(self.cx) || arg_type.is_ushort(self.cx) || arg_type.is_uint(self.cx) { + // NOTE: we don't need to & 0xFF for uchar because the result is undefined on zero. + ("__builtin_ctz", self.cx.uint_type) + } + else if arg_type.is_ulong(self.cx) { + ("__builtin_ctzl", self.cx.ulong_type) + } + else if arg_type.is_ulonglong(self.cx) { + ("__builtin_ctzll", self.cx.ulonglong_type) + } + else if arg_type.is_u128(self.cx) { + // Adapted from the algorithm to count leading zeroes from: https://stackoverflow.com/a/28433850/389119 + let array_type = self.context.new_array_type(None, arg_type, 3); + let result = self.current_func() + .new_local(None, array_type, "count_loading_zeroes_results"); + + let sixty_four = self.gcc_int(arg_type, 64); + let shift = self.gcc_lshr(arg, sixty_four); + let high = self.gcc_int_cast(shift, self.u64_type); + let low = self.gcc_int_cast(arg, self.u64_type); + + let zero = self.context.new_rvalue_zero(self.usize_type); + let one = self.context.new_rvalue_one(self.usize_type); + let two = self.context.new_rvalue_from_long(self.usize_type, 2); + + let ctzll = self.context.get_builtin_function("__builtin_ctzll"); + + let first_elem = self.context.new_array_access(self.location, result, zero); + let first_value = self.gcc_int_cast(self.context.new_call(self.location, ctzll, &[low]), arg_type); + self.llbb() + .add_assignment(self.location, first_elem, first_value); + + let second_elem = self.context.new_array_access(self.location, result, one); + let second_value = self.gcc_add(self.gcc_int_cast(self.context.new_call(self.location, ctzll, &[high]), arg_type), sixty_four); + self.llbb() + .add_assignment(self.location, second_elem, second_value); + + let third_elem = self.context.new_array_access(self.location, result, two); + let third_value = self.gcc_int(arg_type, 128); + self.llbb() + .add_assignment(self.location, third_elem, third_value); + + let not_low = self.context.new_unary_op(self.location, UnaryOp::LogicalNegate, self.u64_type, low); + let not_high = self.context.new_unary_op(self.location, UnaryOp::LogicalNegate, self.u64_type, high); + let not_low_and_not_high = not_low & not_high; + let index = not_low + not_low_and_not_high; + // NOTE: the following cast is necessary to avoid a GIMPLE verification failure in + // gcc. + // TODO(antoyo): do the correct verification in libgccjit to avoid an error at the + // compilation stage. + let index = self.context.new_cast(self.location, index, self.i32_type); + + let res = self.context.new_array_access(self.location, result, index); + + return self.gcc_int_cast(res.to_rvalue(), result_type); + } + else { + let count_trailing_zeroes = self.context.get_builtin_function("__builtin_ctzll"); + let arg_size = arg_type.get_size(); + let casted_arg = self.context.new_cast(self.location, arg, self.ulonglong_type); + let byte_diff = self.ulonglong_type.get_size() as i64 - arg_size as i64; + let diff = self.context.new_rvalue_from_long(self.int_type, byte_diff * 8); + let mask = self.context.new_rvalue_from_long(arg_type, -1); // To get the value with all bits set. + let masked = mask & self.context.new_unary_op(self.location, UnaryOp::BitwiseNegate, arg_type, arg); + let cond = self.context.new_comparison(self.location, ComparisonOp::Equals, masked, mask); + let diff = diff * self.context.new_cast(self.location, cond, self.int_type); + let res = self.context.new_call(self.location, count_trailing_zeroes, &[casted_arg]) - diff; + return self.context.new_cast(self.location, res, result_type); + }; + let count_trailing_zeroes = self.context.get_builtin_function(count_trailing_zeroes); + let arg = if arg_type != expected_type { + self.context.new_cast(self.location, arg, expected_type) + } else { + arg + }; + let res = self.context.new_call(self.location, count_trailing_zeroes, &[arg]); + self.context.new_cast(self.location, res, result_type) + } + + fn pop_count(&mut self, value: RValue<'gcc>) -> RValue<'gcc> { + // TODO(antoyo): use the optimized version with fewer operations. + let result_type = self.u32_type; + let arg_type = value.get_type(); + let value_type = arg_type.to_unsigned(self.cx); + + let value = + if arg_type.is_signed(self.cx) { self.gcc_int_cast(value, value_type) } else { value }; + + // only break apart 128-bit ints if they're not natively supported + // TODO(antoyo): remove this if/when native 128-bit integers land in libgccjit + if value_type.is_u128(self.cx) && !self.cx.supports_128bit_integers { + let sixty_four = self.gcc_int(value_type, 64); + let right_shift = self.gcc_lshr(value, sixty_four); + let high = self.gcc_int_cast(right_shift, self.cx.ulonglong_type); + let high = self.pop_count(high); + let low = self.gcc_int_cast(value, self.cx.ulonglong_type); + let low = self.pop_count(low); + let res = high + low; + return self.gcc_int_cast(res, result_type); + } + + // Use Wenger's algorithm for population count, gcc's seems to play better with it + // for (int counter = 0; value != 0; counter++) { + // value &= value - 1; + // } + let func = self.current_func(); + let loop_head = func.new_block("head"); + let loop_body = func.new_block("body"); + let loop_tail = func.new_block("tail"); + + let counter_type = self.int_type; + let counter = self.current_func().new_local(None, counter_type, "popcount_counter"); + let val = self.current_func().new_local(None, value_type, "popcount_value"); + let zero = self.gcc_zero(counter_type); + self.llbb().add_assignment(self.location, counter, zero); + self.llbb().add_assignment(self.location, val, value); + self.br(loop_head); + + // check if value isn't zero + self.switch_to_block(loop_head); + let zero = self.gcc_zero(value_type); + let cond = self.gcc_icmp(IntPredicate::IntNE, val.to_rvalue(), zero); + self.cond_br(cond, loop_body, loop_tail); + + // val &= val - 1; + self.switch_to_block(loop_body); + let one = self.gcc_int(value_type, 1); + let sub = self.gcc_sub(val.to_rvalue(), one); + let op = self.gcc_and(val.to_rvalue(), sub); + loop_body.add_assignment(self.location, val, op); + + // counter += 1 + let one = self.gcc_int(counter_type, 1); + let op = self.gcc_add(counter.to_rvalue(), one); + loop_body.add_assignment(self.location, counter, op); + self.br(loop_head); + + // end of loop + self.switch_to_block(loop_tail); + self.gcc_int_cast(counter.to_rvalue(), result_type) + } + + // Algorithm from: https://blog.regehr.org/archives/1063 + fn rotate_left( + &mut self, + value: RValue<'gcc>, + shift: RValue<'gcc>, + width: u64, + ) -> RValue<'gcc> { + let max = self.const_uint(shift.get_type(), width); + let shift = self.urem(shift, max); + let lhs = self.shl(value, shift); + let result_neg = self.neg(shift); + let result_and = self.and(result_neg, self.const_uint(shift.get_type(), width - 1)); + let rhs = self.lshr(value, result_and); + self.or(lhs, rhs) + } + + // Algorithm from: https://blog.regehr.org/archives/1063 + fn rotate_right( + &mut self, + value: RValue<'gcc>, + shift: RValue<'gcc>, + width: u64, + ) -> RValue<'gcc> { + let max = self.const_uint(shift.get_type(), width); + let shift = self.urem(shift, max); + let lhs = self.lshr(value, shift); + let result_neg = self.neg(shift); + let result_and = self.and(result_neg, self.const_uint(shift.get_type(), width - 1)); + let rhs = self.shl(value, result_and); + self.or(lhs, rhs) + } + + fn saturating_add( + &mut self, + lhs: RValue<'gcc>, + rhs: RValue<'gcc>, + signed: bool, + width: u64, + ) -> RValue<'gcc> { + let result_type = lhs.get_type(); + if signed { + // Based on algorithm from: https://stackoverflow.com/a/56531252/389119 + let func = self.current_func(); + let res = func.new_local(self.location, result_type, "saturating_sum"); + let supports_native_type = self.is_native_int_type(result_type); + let overflow = if supports_native_type { + let func_name = match width { + 8 => "__builtin_add_overflow", + 16 => "__builtin_add_overflow", + 32 => "__builtin_sadd_overflow", + 64 => "__builtin_saddll_overflow", + 128 => "__builtin_add_overflow", + _ => unreachable!(), + }; + let overflow_func = self.context.get_builtin_function(func_name); + self.overflow_call(overflow_func, &[lhs, rhs, res.get_address(self.location)], None) + } else { + let func_name = match width { + 128 => "__rust_i128_addo", + _ => unreachable!(), + }; + let (int_result, overflow) = + self.operation_with_overflow(func_name, lhs, rhs, width); + self.llbb().add_assignment(self.location, res, int_result); + overflow + }; + + let then_block = func.new_block("then"); + let after_block = func.new_block("after"); + + // Return `result_type`'s maximum or minimum value on overflow + // NOTE: convert the type to unsigned to have an unsigned shift. + let unsigned_type = result_type.to_unsigned(self.cx); + let shifted = self.gcc_lshr( + self.gcc_int_cast(lhs, unsigned_type), + self.gcc_int(unsigned_type, width as i64 - 1), + ); + let uint_max = self.gcc_not(self.gcc_int(unsigned_type, 0)); + let int_max = self.gcc_lshr(uint_max, self.gcc_int(unsigned_type, 1)); + then_block.add_assignment( + self.location, + res, + self.gcc_int_cast(self.gcc_add(shifted, int_max), result_type), + ); + then_block.end_with_jump(self.location, after_block); + + self.llbb().end_with_conditional(self.location, overflow, then_block, after_block); + + // NOTE: since jumps were added in a place rustc does not + // expect, the current block in the state need to be updated. + self.switch_to_block(after_block); + + res.to_rvalue() + } else { + // Algorithm from: http://locklessinc.com/articles/sat_arithmetic/ + let res = self.gcc_add(lhs, rhs); + let cond = self.gcc_icmp(IntPredicate::IntULT, res, lhs); + let value = self.gcc_neg(self.gcc_int_cast(cond, result_type)); + self.gcc_or(res, value, self.location) + } + } + + // Algorithm from: https://locklessinc.com/articles/sat_arithmetic/ + fn saturating_sub( + &mut self, + lhs: RValue<'gcc>, + rhs: RValue<'gcc>, + signed: bool, + width: u64, + ) -> RValue<'gcc> { + let result_type = lhs.get_type(); + if signed { + // Based on algorithm from: https://stackoverflow.com/a/56531252/389119 + let func = self.current_func(); + let res = func.new_local(self.location, result_type, "saturating_diff"); + let supports_native_type = self.is_native_int_type(result_type); + let overflow = if supports_native_type { + let func_name = match width { + 8 => "__builtin_sub_overflow", + 16 => "__builtin_sub_overflow", + 32 => "__builtin_ssub_overflow", + 64 => "__builtin_ssubll_overflow", + 128 => "__builtin_sub_overflow", + _ => unreachable!(), + }; + let overflow_func = self.context.get_builtin_function(func_name); + self.overflow_call(overflow_func, &[lhs, rhs, res.get_address(self.location)], None) + } else { + let func_name = match width { + 128 => "__rust_i128_subo", + _ => unreachable!(), + }; + let (int_result, overflow) = + self.operation_with_overflow(func_name, lhs, rhs, width); + self.llbb().add_assignment(self.location, res, int_result); + overflow + }; + + let then_block = func.new_block("then"); + let after_block = func.new_block("after"); + + // Return `result_type`'s maximum or minimum value on overflow + // NOTE: convert the type to unsigned to have an unsigned shift. + let unsigned_type = result_type.to_unsigned(self.cx); + let shifted = self.gcc_lshr( + self.gcc_int_cast(lhs, unsigned_type), + self.gcc_int(unsigned_type, width as i64 - 1), + ); + let uint_max = self.gcc_not(self.gcc_int(unsigned_type, 0)); + let int_max = self.gcc_lshr(uint_max, self.gcc_int(unsigned_type, 1)); + then_block.add_assignment( + self.location, + res, + self.gcc_int_cast(self.gcc_add(shifted, int_max), result_type), + ); + then_block.end_with_jump(self.location, after_block); + + self.llbb().end_with_conditional(self.location, overflow, then_block, after_block); + + // NOTE: since jumps were added in a place rustc does not + // expect, the current block in the state need to be updated. + self.switch_to_block(after_block); + + res.to_rvalue() + } else { + let res = self.gcc_sub(lhs, rhs); + let comparison = self.gcc_icmp(IntPredicate::IntULE, res, lhs); + let value = self.gcc_neg(self.gcc_int_cast(comparison, result_type)); + self.gcc_and(res, value) + } + } +} + +fn try_intrinsic<'a, 'b, 'gcc, 'tcx>( + bx: &'b mut Builder<'a, 'gcc, 'tcx>, + try_func: RValue<'gcc>, + data: RValue<'gcc>, + _catch_func: RValue<'gcc>, + dest: PlaceRef<'tcx, RValue<'gcc>>, +) { + if bx.sess().panic_strategy() == PanicStrategy::Abort { + bx.call(bx.type_void(), None, None, try_func, &[data], None, None); + // Return 0 unconditionally from the intrinsic call; + // we can never unwind. + OperandValue::Immediate(bx.const_i32(0)).store(bx, dest); + } else { + if wants_msvc_seh(bx.sess()) { + unimplemented!(); + } + #[cfg(feature = "master")] + codegen_gnu_try(bx, try_func, data, _catch_func, dest); + #[cfg(not(feature = "master"))] + unimplemented!(); + } +} + +// Definition of the standard `try` function for Rust using the GNU-like model +// of exceptions (e.g., the normal semantics of LLVM's `landingpad` and `invoke` +// instructions). +// +// This codegen is a little surprising because we always call a shim +// function instead of inlining the call to `invoke` manually here. This is done +// because in LLVM we're only allowed to have one personality per function +// definition. The call to the `try` intrinsic is being inlined into the +// function calling it, and that function may already have other personality +// functions in play. By calling a shim we're guaranteed that our shim will have +// the right personality function. +#[cfg(feature = "master")] +fn codegen_gnu_try<'gcc, 'tcx>( + bx: &mut Builder<'_, 'gcc, 'tcx>, + try_func: RValue<'gcc>, + data: RValue<'gcc>, + catch_func: RValue<'gcc>, + dest: PlaceRef<'tcx, RValue<'gcc>>, +) { + let cx: &CodegenCx<'gcc, '_> = bx.cx; + let (llty, func) = get_rust_try_fn(cx, &mut |mut bx| { + // Codegens the shims described above: + // + // bx: + // invoke %try_func(%data) normal %normal unwind %catch + // + // normal: + // ret 0 + // + // catch: + // (%ptr, _) = landingpad + // call %catch_func(%data, %ptr) + // ret 1 + let then = bx.append_sibling_block("then"); + let catch = bx.append_sibling_block("catch"); + + let func = bx.current_func(); + let try_func = func.get_param(0).to_rvalue(); + let data = func.get_param(1).to_rvalue(); + let catch_func = func.get_param(2).to_rvalue(); + let try_func_ty = bx.type_func(&[bx.type_i8p()], bx.type_void()); + + let current_block = bx.block; + + bx.switch_to_block(then); + bx.ret(bx.const_i32(0)); + + // Type indicator for the exception being thrown. + // + // The value is a pointer to the exception object + // being thrown. + bx.switch_to_block(catch); + bx.set_personality_fn(bx.eh_personality()); + + let eh_pointer_builtin = bx.cx.context.get_target_builtin_function("__builtin_eh_pointer"); + let zero = bx.cx.context.new_rvalue_zero(bx.int_type); + let ptr = bx.cx.context.new_call(None, eh_pointer_builtin, &[zero]); + let catch_ty = bx.type_func(&[bx.type_i8p(), bx.type_i8p()], bx.type_void()); + bx.call(catch_ty, None, None, catch_func, &[data, ptr], None, None); + bx.ret(bx.const_i32(1)); + + // NOTE: the blocks must be filled before adding the try/catch, otherwise gcc will not + // generate a try/catch. + // FIXME(antoyo): add a check in the libgccjit API to prevent this. + bx.switch_to_block(current_block); + bx.invoke(try_func_ty, None, None, try_func, &[data], then, catch, None, None); + }); + + let func = unsafe { std::mem::transmute::<Function<'gcc>, RValue<'gcc>>(func) }; + + // Note that no invoke is used here because by definition this function + // can't panic (that's what it's catching). + let ret = bx.call(llty, None, None, func, &[try_func, data, catch_func], None, None); + OperandValue::Immediate(ret).store(bx, dest); +} + +// Helper function used to get a handle to the `__rust_try` function used to +// catch exceptions. +// +// This function is only generated once and is then cached. +#[cfg(feature = "master")] +fn get_rust_try_fn<'a, 'gcc, 'tcx>( + cx: &'a CodegenCx<'gcc, 'tcx>, + codegen: &mut dyn FnMut(Builder<'a, 'gcc, 'tcx>), +) -> (Type<'gcc>, Function<'gcc>) { + if let Some(llfn) = cx.rust_try_fn.get() { + return llfn; + } + + // Define the type up front for the signature of the rust_try function. + let tcx = cx.tcx; + let i8p = Ty::new_mut_ptr(tcx, tcx.types.i8); + // `unsafe fn(*mut i8) -> ()` + let try_fn_ty = Ty::new_fn_ptr( + tcx, + ty::Binder::dummy(tcx.mk_fn_sig( + iter::once(i8p), + tcx.types.unit, + false, + rustc_hir::Safety::Unsafe, + ExternAbi::Rust, + )), + ); + // `unsafe fn(*mut i8, *mut i8) -> ()` + let catch_fn_ty = Ty::new_fn_ptr( + tcx, + ty::Binder::dummy(tcx.mk_fn_sig( + [i8p, i8p].iter().cloned(), + tcx.types.unit, + false, + rustc_hir::Safety::Unsafe, + ExternAbi::Rust, + )), + ); + // `unsafe fn(unsafe fn(*mut i8) -> (), *mut i8, unsafe fn(*mut i8, *mut i8) -> ()) -> i32` + let rust_fn_sig = ty::Binder::dummy(cx.tcx.mk_fn_sig( + [try_fn_ty, i8p, catch_fn_ty], + tcx.types.i32, + false, + rustc_hir::Safety::Unsafe, + ExternAbi::Rust, + )); + let rust_try = gen_fn(cx, "__rust_try", rust_fn_sig, codegen); + cx.rust_try_fn.set(Some(rust_try)); + rust_try +} + +// Helper function to give a Block to a closure to codegen a shim function. +// This is currently primarily used for the `try` intrinsic functions above. +#[cfg(feature = "master")] +fn gen_fn<'a, 'gcc, 'tcx>( + cx: &'a CodegenCx<'gcc, 'tcx>, + name: &str, + rust_fn_sig: ty::PolyFnSig<'tcx>, + codegen: &mut dyn FnMut(Builder<'a, 'gcc, 'tcx>), +) -> (Type<'gcc>, Function<'gcc>) { + let fn_abi = cx.fn_abi_of_fn_ptr(rust_fn_sig, ty::List::empty()); + let return_type = fn_abi.gcc_type(cx).return_type; + // FIXME(eddyb) find a nicer way to do this. + cx.linkage.set(FunctionType::Internal); + let func = cx.declare_fn(name, fn_abi); + cx.set_frame_pointer_type(func); + cx.apply_target_cpu_attr(func); + let block = Builder::append_block(cx, func, "entry-block"); + let bx = Builder::build(cx, block); + codegen(bx); + (return_type, func) +} diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs b/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs new file mode 100644 index 00000000000..fdc15d580ef --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs @@ -0,0 +1,1517 @@ +use std::iter::FromIterator; + +use gccjit::{BinaryOp, RValue, ToRValue, Type}; +#[cfg(feature = "master")] +use gccjit::{ComparisonOp, UnaryOp}; +use rustc_abi::{Align, Size}; +use rustc_codegen_ssa::base::compare_simd_types; +use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; +#[cfg(feature = "master")] +use rustc_codegen_ssa::errors::ExpectedPointerMutability; +use rustc_codegen_ssa::errors::InvalidMonomorphization; +use rustc_codegen_ssa::mir::operand::OperandRef; +use rustc_codegen_ssa::mir::place::PlaceRef; +use rustc_codegen_ssa::traits::{BaseTypeCodegenMethods, BuilderMethods}; +#[cfg(feature = "master")] +use rustc_hir as hir; +use rustc_middle::mir::BinOp; +use rustc_middle::ty::layout::HasTyCtxt; +use rustc_middle::ty::{self, Ty}; +use rustc_span::{Span, Symbol, sym}; + +use crate::builder::Builder; +#[cfg(not(feature = "master"))] +use crate::common::SignType; +#[cfg(feature = "master")] +use crate::context::CodegenCx; + +pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( + bx: &mut Builder<'a, 'gcc, 'tcx>, + name: Symbol, + args: &[OperandRef<'tcx, RValue<'gcc>>], + ret_ty: Ty<'tcx>, + llret_ty: Type<'gcc>, + span: Span, +) -> Result<RValue<'gcc>, ()> { + // macros for error handling: + macro_rules! return_error { + ($err:expr) => {{ + bx.tcx.dcx().emit_err($err); + return Err(()); + }}; + } + macro_rules! require { + ($cond:expr, $err:expr) => { + if !$cond { + return_error!($err); + } + }; + } + macro_rules! require_simd { + ($ty: expr, $diag: expr) => { + require!($ty.is_simd(), $diag) + }; + } + + if name == sym::simd_select_bitmask { + require_simd!( + args[1].layout.ty, + InvalidMonomorphization::SimdArgument { span, name, ty: args[1].layout.ty } + ); + let (len, _) = args[1].layout.ty.simd_size_and_type(bx.tcx()); + + let expected_int_bits = (len.max(8) - 1).next_power_of_two(); + let expected_bytes = len / 8 + ((!len.is_multiple_of(8)) as u64); + + let mask_ty = args[0].layout.ty; + let mut mask = match *mask_ty.kind() { + ty::Int(i) if i.bit_width() == Some(expected_int_bits) => args[0].immediate(), + ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => args[0].immediate(), + ty::Array(elem, len) + if matches!(*elem.kind(), ty::Uint(ty::UintTy::U8)) + && len + .try_to_target_usize(bx.tcx) + .expect("expected monomorphic const in codegen") + == expected_bytes => + { + let place = PlaceRef::alloca(bx, args[0].layout); + args[0].val.store(bx, place); + let int_ty = bx.type_ix(expected_bytes * 8); + let ptr = bx.pointercast(place.val.llval, bx.cx.type_ptr_to(int_ty)); + bx.load(int_ty, ptr, Align::ONE) + } + _ => return_error!(InvalidMonomorphization::InvalidBitmask { + span, + name, + mask_ty, + expected_int_bits, + expected_bytes + }), + }; + + let arg1 = args[1].immediate(); + let arg1_type = arg1.get_type(); + let arg1_vector_type = arg1_type.unqualified().dyncast_vector().expect("vector type"); + let arg1_element_type = arg1_vector_type.get_element_type(); + + // NOTE: since the arguments can be vectors of floats, make sure the mask is a vector of + // integer. + let mask_element_type = bx.type_ix(arg1_element_type.get_size() as u64 * 8); + let vector_mask_type = + bx.context.new_vector_type(mask_element_type, arg1_vector_type.get_num_units() as u64); + + let mut elements = vec![]; + let one = bx.context.new_rvalue_one(mask.get_type()); + for _ in 0..len { + let element = bx.context.new_cast(None, mask & one, mask_element_type); + elements.push(element); + mask = mask >> one; + } + let vector_mask = bx.context.new_rvalue_from_vector(None, vector_mask_type, &elements); + + return Ok(bx.vector_select(vector_mask, arg1, args[2].immediate())); + } + + // every intrinsic below takes a SIMD vector as its first argument + require_simd!( + args[0].layout.ty, + InvalidMonomorphization::SimdInput { span, name, ty: args[0].layout.ty } + ); + let in_ty = args[0].layout.ty; + + let comparison = match name { + sym::simd_eq => Some(BinOp::Eq), + sym::simd_ne => Some(BinOp::Ne), + sym::simd_lt => Some(BinOp::Lt), + sym::simd_le => Some(BinOp::Le), + sym::simd_gt => Some(BinOp::Gt), + sym::simd_ge => Some(BinOp::Ge), + _ => None, + }; + + let (in_len, in_elem) = args[0].layout.ty.simd_size_and_type(bx.tcx()); + if let Some(cmp_op) = comparison { + require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty }); + + let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx()); + require!( + in_len == out_len, + InvalidMonomorphization::ReturnLengthInputType { + span, + name, + in_len, + in_ty, + ret_ty, + out_len + } + ); + require!( + bx.type_kind(bx.element_type(llret_ty)) == TypeKind::Integer, + InvalidMonomorphization::ReturnIntegerType { span, name, ret_ty, out_ty } + ); + + let arg1 = args[0].immediate(); + // NOTE: we get different vector types for the same vector type and libgccjit doesn't + // compare them as equal, so bitcast. + // FIXME(antoyo): allow comparing vector types as equal in libgccjit. + let arg2 = bx.context.new_bitcast(None, args[1].immediate(), arg1.get_type()); + return Ok(compare_simd_types(bx, arg1, arg2, in_elem, llret_ty, cmp_op)); + } + + let simd_bswap = |bx: &mut Builder<'a, 'gcc, 'tcx>, vector: RValue<'gcc>| -> RValue<'gcc> { + let v_type = vector.get_type(); + let vector_type = v_type.unqualified().dyncast_vector().expect("vector type"); + let elem_type = vector_type.get_element_type(); + let elem_size_bytes = elem_type.get_size(); + if elem_size_bytes == 1 { + return vector; + } + + let type_size_bytes = elem_size_bytes as u64 * in_len; + let shuffle_indices = Vec::from_iter(0..type_size_bytes); + let byte_vector_type = bx.context.new_vector_type(bx.type_u8(), type_size_bytes); + let byte_vector = bx.context.new_bitcast(None, args[0].immediate(), byte_vector_type); + + #[cfg(not(feature = "master"))] + let shuffled = { + let new_elements: Vec<_> = shuffle_indices + .chunks_exact(elem_size_bytes as _) + .flat_map(|x| x.iter().rev()) + .map(|&i| { + let index = bx.context.new_rvalue_from_long(bx.u64_type, i as _); + bx.extract_element(byte_vector, index) + }) + .collect(); + + bx.context.new_rvalue_from_vector(None, byte_vector_type, &new_elements) + }; + #[cfg(feature = "master")] + let shuffled = { + let indices: Vec<_> = shuffle_indices + .chunks_exact(elem_size_bytes as _) + .flat_map(|x| x.iter().rev()) + .map(|&i| bx.context.new_rvalue_from_int(bx.u8_type, i as _)) + .collect(); + + let mask = bx.context.new_rvalue_from_vector(None, byte_vector_type, &indices); + bx.context.new_rvalue_vector_perm(None, byte_vector, byte_vector, mask) + }; + bx.context.new_bitcast(None, shuffled, v_type) + }; + + if matches!(name, sym::simd_bswap | sym::simd_bitreverse | sym::simd_ctpop) { + require!( + bx.type_kind(bx.element_type(llret_ty)) == TypeKind::Integer, + InvalidMonomorphization::UnsupportedOperation { span, name, in_ty, in_elem } + ); + } + + #[cfg(feature = "master")] + if name == sym::simd_funnel_shl { + return Ok(simd_funnel_shift( + bx, + args[0].immediate(), + args[1].immediate(), + args[2].immediate(), + true, + )); + } + + #[cfg(feature = "master")] + if name == sym::simd_funnel_shr { + return Ok(simd_funnel_shift( + bx, + args[0].immediate(), + args[1].immediate(), + args[2].immediate(), + false, + )); + } + + if name == sym::simd_bswap { + return Ok(simd_bswap(bx, args[0].immediate())); + } + + let simd_ctpop = |bx: &mut Builder<'a, 'gcc, 'tcx>, vector: RValue<'gcc>| -> RValue<'gcc> { + let mut vector_elements = vec![]; + let elem_ty = bx.element_type(llret_ty); + for i in 0..in_len { + let index = bx.context.new_rvalue_from_long(bx.ulong_type, i as i64); + let element = bx.extract_element(vector, index).to_rvalue(); + let result = bx.context.new_cast(None, bx.pop_count(element), elem_ty); + vector_elements.push(result); + } + bx.context.new_rvalue_from_vector(None, llret_ty, &vector_elements) + }; + + if name == sym::simd_ctpop { + return Ok(simd_ctpop(bx, args[0].immediate())); + } + + // We use a different algorithm from non-vector bitreverse to take advantage of most + // processors' vector shuffle units. It works like this: + // 1. Generate pre-reversed low and high nibbles as a vector. + // 2. Byte-swap the input. + // 3. Mask off the low and high nibbles of each byte in the byte-swapped input. + // 4. Shuffle the pre-reversed low and high-nibbles using the masked nibbles as a shuffle mask. + // 5. Combine the results of the shuffle back together and cast back to the original type. + #[cfg(feature = "master")] + if name == sym::simd_bitreverse { + let vector = args[0].immediate(); + let v_type = vector.get_type(); + let vector_type = v_type.unqualified().dyncast_vector().expect("vector type"); + let elem_type = vector_type.get_element_type(); + let elem_size_bytes = elem_type.get_size(); + + let type_size_bytes = elem_size_bytes as u64 * in_len; + // We need to ensure at least 16 entries in our vector type, since the pre-reversed vectors + // we generate below have 16 entries in them. `new_rvalue_vector_perm` requires the mask + // vector to be of the same length as the source vectors. + let byte_vector_type_size = type_size_bytes.max(16); + + let byte_vector_type = bx.context.new_vector_type(bx.u8_type, type_size_bytes); + let long_byte_vector_type = bx.context.new_vector_type(bx.u8_type, byte_vector_type_size); + + // Step 1: Generate pre-reversed low and high nibbles as a vector. + let zero_byte = bx.context.new_rvalue_zero(bx.u8_type); + let hi_nibble_elements: Vec<_> = (0u8..16) + .map(|x| bx.context.new_rvalue_from_int(bx.u8_type, x.reverse_bits() as _)) + .chain((16..byte_vector_type_size).map(|_| zero_byte)) + .collect(); + let hi_nibble = + bx.context.new_rvalue_from_vector(None, long_byte_vector_type, &hi_nibble_elements); + + let lo_nibble_elements: Vec<_> = (0u8..16) + .map(|x| bx.context.new_rvalue_from_int(bx.u8_type, (x.reverse_bits() >> 4) as _)) + .chain((16..byte_vector_type_size).map(|_| zero_byte)) + .collect(); + let lo_nibble = + bx.context.new_rvalue_from_vector(None, long_byte_vector_type, &lo_nibble_elements); + + let mask = bx.context.new_rvalue_from_vector( + None, + long_byte_vector_type, + &vec![bx.context.new_rvalue_from_int(bx.u8_type, 0x0f); byte_vector_type_size as _], + ); + + let four_vec = bx.context.new_rvalue_from_vector( + None, + long_byte_vector_type, + &vec![bx.context.new_rvalue_from_int(bx.u8_type, 4); byte_vector_type_size as _], + ); + + // Step 2: Byte-swap the input. + let swapped = simd_bswap(bx, args[0].immediate()); + let byte_vector = bx.context.new_bitcast(None, swapped, byte_vector_type); + + // We're going to need to extend the vector with zeros to make sure that the types are the + // same, since that's what new_rvalue_vector_perm expects. + let byte_vector = if byte_vector_type_size > type_size_bytes { + let mut byte_vector_elements = Vec::with_capacity(byte_vector_type_size as _); + for i in 0..type_size_bytes { + let idx = bx.context.new_rvalue_from_int(bx.u32_type, i as _); + let val = bx.extract_element(byte_vector, idx); + byte_vector_elements.push(val); + } + for _ in type_size_bytes..byte_vector_type_size { + byte_vector_elements.push(zero_byte); + } + bx.context.new_rvalue_from_vector(None, long_byte_vector_type, &byte_vector_elements) + } else { + bx.context.new_bitcast(None, byte_vector, long_byte_vector_type) + }; + + // Step 3: Mask off the low and high nibbles of each byte in the byte-swapped input. + let masked_hi = (byte_vector >> four_vec) & mask; + let masked_lo = byte_vector & mask; + + // Step 4: Shuffle the pre-reversed low and high-nibbles using the masked nibbles as a shuffle mask. + let hi = bx.context.new_rvalue_vector_perm(None, hi_nibble, hi_nibble, masked_lo); + let lo = bx.context.new_rvalue_vector_perm(None, lo_nibble, lo_nibble, masked_hi); + + // Step 5: Combine the results of the shuffle back together and cast back to the original type. + let result = hi | lo; + let cast_ty = + bx.context.new_vector_type(elem_type, byte_vector_type_size / (elem_size_bytes as u64)); + + // we might need to truncate if sizeof(v_type) < sizeof(cast_type) + if type_size_bytes < byte_vector_type_size { + let cast_result = bx.context.new_bitcast(None, result, cast_ty); + let elems: Vec<_> = (0..in_len) + .map(|i| { + let idx = bx.context.new_rvalue_from_int(bx.u32_type, i as _); + bx.extract_element(cast_result, idx) + }) + .collect(); + return Ok(bx.context.new_rvalue_from_vector(None, v_type, &elems)); + } + // avoid the unnecessary truncation as an optimization. + return Ok(bx.context.new_bitcast(None, result, v_type)); + } + // since gcc doesn't have vector shuffle methods available in non-patched builds, fallback to + // component-wise bitreverses if they're not available. + #[cfg(not(feature = "master"))] + if name == sym::simd_bitreverse { + let vector = args[0].immediate(); + let vector_ty = vector.get_type(); + let vector_type = vector_ty.unqualified().dyncast_vector().expect("vector type"); + let num_elements = vector_type.get_num_units(); + + let elem_type = vector_type.get_element_type(); + let elem_size_bytes = elem_type.get_size(); + let num_type = elem_type.to_unsigned(bx.cx); + let new_elements: Vec<_> = (0..num_elements) + .map(|idx| { + let index = bx.context.new_rvalue_from_long(num_type, idx as _); + let extracted_value = bx.extract_element(vector, index).to_rvalue(); + bx.bit_reverse(elem_size_bytes as u64 * 8, extracted_value) + }) + .collect(); + return Ok(bx.context.new_rvalue_from_vector(None, vector_ty, &new_elements)); + } + + if name == sym::simd_ctlz || name == sym::simd_cttz { + let vector = args[0].immediate(); + let elements: Vec<_> = (0..in_len) + .map(|i| { + let index = bx.context.new_rvalue_from_long(bx.i32_type, i as i64); + let value = bx.extract_element(vector, index).to_rvalue(); + let value_type = value.get_type(); + let element = if name == sym::simd_ctlz { + bx.count_leading_zeroes(value_type.get_size() as u64 * 8, value) + } else { + bx.count_trailing_zeroes(value_type.get_size() as u64 * 8, value) + }; + bx.context.new_cast(None, element, value_type) + }) + .collect(); + return Ok(bx.context.new_rvalue_from_vector(None, vector.get_type(), &elements)); + } + + if name == sym::simd_shuffle { + // Make sure this is actually a SIMD vector. + let idx_ty = args[2].layout.ty; + let n: u64 = if idx_ty.is_simd() + && matches!(*idx_ty.simd_size_and_type(bx.cx.tcx).1.kind(), ty::Uint(ty::UintTy::U32)) + { + idx_ty.simd_size_and_type(bx.cx.tcx).0 + } else { + return_error!(InvalidMonomorphization::SimdShuffle { span, name, ty: idx_ty }) + }; + require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty }); + + let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx()); + require!( + out_len == n, + InvalidMonomorphization::ReturnLength { span, name, in_len: n, ret_ty, out_len } + ); + require!( + in_elem == out_ty, + InvalidMonomorphization::ReturnElement { span, name, in_elem, in_ty, ret_ty, out_ty } + ); + + let vector = args[2].immediate(); + + return Ok(bx.shuffle_vector(args[0].immediate(), args[1].immediate(), vector)); + } + + #[cfg(feature = "master")] + if name == sym::simd_insert || name == sym::simd_insert_dyn { + require!( + in_elem == args[2].layout.ty, + InvalidMonomorphization::InsertedType { + span, + name, + in_elem, + in_ty, + out_ty: args[2].layout.ty + } + ); + + // TODO(antoyo): For simd_insert, check if the index is a constant of the correct size. + let vector = args[0].immediate(); + let index = args[1].immediate(); + let value = args[2].immediate(); + let variable = bx.current_func().new_local(None, vector.get_type(), "new_vector"); + bx.llbb().add_assignment(None, variable, vector); + let lvalue = bx.context.new_vector_access(None, variable.to_rvalue(), index); + // TODO(antoyo): if simd_insert is constant, use BIT_REF. + bx.llbb().add_assignment(None, lvalue, value); + return Ok(variable.to_rvalue()); + } + + #[cfg(feature = "master")] + if name == sym::simd_extract || name == sym::simd_extract_dyn { + require!( + ret_ty == in_elem, + InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty } + ); + // TODO(antoyo): For simd_extract, check if the index is a constant of the correct size. + let vector = args[0].immediate(); + let index = args[1].immediate(); + return Ok(bx.context.new_vector_access(None, vector, index).to_rvalue()); + } + + if name == sym::simd_select { + let m_elem_ty = in_elem; + let m_len = in_len; + require_simd!( + args[1].layout.ty, + InvalidMonomorphization::SimdArgument { span, name, ty: args[1].layout.ty } + ); + let (v_len, _) = args[1].layout.ty.simd_size_and_type(bx.tcx()); + require!( + m_len == v_len, + InvalidMonomorphization::MismatchedLengths { span, name, m_len, v_len } + ); + // TODO: also support unsigned integers. + match *m_elem_ty.kind() { + ty::Int(_) => {} + _ => return_error!(InvalidMonomorphization::MaskWrongElementType { + span, + name, + ty: m_elem_ty + }), + } + return Ok(bx.vector_select(args[0].immediate(), args[1].immediate(), args[2].immediate())); + } + + if name == sym::simd_cast_ptr { + require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty }); + let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx()); + + require!( + in_len == out_len, + InvalidMonomorphization::ReturnLengthInputType { + span, + name, + in_len, + in_ty, + ret_ty, + out_len + } + ); + + match *in_elem.kind() { + ty::RawPtr(p_ty, _) => { + let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| { + bx.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), ty) + }); + require!( + metadata.is_unit(), + InvalidMonomorphization::CastWidePointer { span, name, ty: in_elem } + ); + } + _ => { + return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: in_elem }) + } + } + match *out_elem.kind() { + ty::RawPtr(p_ty, _) => { + let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| { + bx.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), ty) + }); + require!( + metadata.is_unit(), + InvalidMonomorphization::CastWidePointer { span, name, ty: out_elem } + ); + } + _ => { + return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: out_elem }) + } + } + + let arg = args[0].immediate(); + let elem_type = llret_ty.dyncast_vector().expect("vector return type").get_element_type(); + let values: Vec<_> = (0..in_len) + .map(|i| { + let idx = bx.gcc_int(bx.usize_type, i as _); + let value = bx.extract_element(arg, idx); + bx.pointercast(value, elem_type) + }) + .collect(); + return Ok(bx.context.new_rvalue_from_vector(bx.location, llret_ty, &values)); + } + + if name == sym::simd_expose_provenance { + require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty }); + let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx()); + + require!( + in_len == out_len, + InvalidMonomorphization::ReturnLengthInputType { + span, + name, + in_len, + in_ty, + ret_ty, + out_len + } + ); + + match *in_elem.kind() { + ty::RawPtr(_, _) => {} + _ => { + return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: in_elem }) + } + } + match *out_elem.kind() { + ty::Uint(ty::UintTy::Usize) => {} + _ => return_error!(InvalidMonomorphization::ExpectedUsize { span, name, ty: out_elem }), + } + + let arg = args[0].immediate(); + let elem_type = llret_ty.dyncast_vector().expect("vector return type").get_element_type(); + let values: Vec<_> = (0..in_len) + .map(|i| { + let idx = bx.gcc_int(bx.usize_type, i as _); + let value = bx.extract_element(arg, idx); + bx.ptrtoint(value, elem_type) + }) + .collect(); + return Ok(bx.context.new_rvalue_from_vector(bx.location, llret_ty, &values)); + } + + if name == sym::simd_with_exposed_provenance { + require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty }); + let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx()); + + require!( + in_len == out_len, + InvalidMonomorphization::ReturnLengthInputType { + span, + name, + in_len, + in_ty, + ret_ty, + out_len + } + ); + + match *in_elem.kind() { + ty::Uint(ty::UintTy::Usize) => {} + _ => return_error!(InvalidMonomorphization::ExpectedUsize { span, name, ty: in_elem }), + } + match *out_elem.kind() { + ty::RawPtr(_, _) => {} + _ => { + return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: out_elem }) + } + } + + let arg = args[0].immediate(); + let elem_type = llret_ty.dyncast_vector().expect("vector return type").get_element_type(); + let values: Vec<_> = (0..in_len) + .map(|i| { + let idx = bx.gcc_int(bx.usize_type, i as _); + let value = bx.extract_element(arg, idx); + bx.inttoptr(value, elem_type) + }) + .collect(); + return Ok(bx.context.new_rvalue_from_vector(bx.location, llret_ty, &values)); + } + + #[cfg(feature = "master")] + if name == sym::simd_cast || name == sym::simd_as { + require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty }); + let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx()); + require!( + in_len == out_len, + InvalidMonomorphization::ReturnLengthInputType { + span, + name, + in_len, + in_ty, + ret_ty, + out_len + } + ); + // casting cares about nominal type, not just structural type + if in_elem == out_elem { + return Ok(args[0].immediate()); + } + + enum Style { + Float, + Int, + Unsupported, + } + + let in_style = match *in_elem.kind() { + ty::Int(_) | ty::Uint(_) => Style::Int, + ty::Float(_) => Style::Float, + _ => Style::Unsupported, + }; + + let out_style = match *out_elem.kind() { + ty::Int(_) | ty::Uint(_) => Style::Int, + ty::Float(_) => Style::Float, + _ => Style::Unsupported, + }; + + match (in_style, out_style) { + (Style::Unsupported, Style::Unsupported) => { + require!( + false, + InvalidMonomorphization::UnsupportedCast { + span, + name, + in_ty, + in_elem, + ret_ty, + out_elem + } + ); + } + _ => return Ok(bx.context.convert_vector(None, args[0].immediate(), llret_ty)), + } + } + + macro_rules! arith_binary { + ($($name: ident: $($($p: ident),* => $call: ident),*;)*) => { + $(if name == sym::$name { + match *in_elem.kind() { + $($(ty::$p(_))|* => { + return Ok(bx.$call(args[0].immediate(), args[1].immediate())) + })* + _ => {}, + } + return_error!(InvalidMonomorphization::UnsupportedOperation { span, name, in_ty, in_elem }) + })* + } + } + + if name == sym::simd_bitmask { + // The `fn simd_bitmask(vector) -> unsigned integer` intrinsic takes a + // vector mask and returns the most significant bit (MSB) of each lane in the form + // of either: + // * an unsigned integer + // * an array of `u8` + // If the vector has less than 8 lanes, a u8 is returned with zeroed trailing bits. + // + // The bit order of the result depends on the byte endianness, LSB-first for little + // endian and MSB-first for big endian. + + let vector = args[0].immediate(); + // TODO(antoyo): dyncast_vector should not require a call to unqualified. + let vector_type = vector.get_type().unqualified().dyncast_vector().expect("vector type"); + let elem_type = vector_type.get_element_type(); + + let expected_int_bits = in_len.max(8); + let expected_bytes = + expected_int_bits / 8 + ((!expected_int_bits.is_multiple_of(8)) as u64); + + // FIXME(antoyo): that's not going to work for masks bigger than 128 bits. + let result_type = bx.type_ix(expected_int_bits); + let mut result = bx.context.new_rvalue_zero(result_type); + + let elem_size = elem_type.get_size() * 8; + let sign_shift = bx.context.new_rvalue_from_int(elem_type, elem_size as i32 - 1); + let one = bx.context.new_rvalue_one(elem_type); + + for i in 0..in_len { + let elem = + bx.extract_element(vector, bx.context.new_rvalue_from_int(bx.int_type, i as i32)); + let shifted = elem >> sign_shift; + let masked = shifted & one; + result = result + | (bx.context.new_cast(None, masked, result_type) + << bx.context.new_rvalue_from_int(result_type, i as i32)); + } + + match *ret_ty.kind() { + ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => { + // Zero-extend iN to the bitmask type: + return Ok(result); + } + ty::Array(elem, len) + if matches!(*elem.kind(), ty::Uint(ty::UintTy::U8)) + && len + .try_to_target_usize(bx.tcx) + .expect("expected monomorphic const in codegen") + == expected_bytes => + { + // Zero-extend iN to the array length: + let ze = bx.zext(result, bx.type_ix(expected_bytes * 8)); + + // Convert the integer to a byte array + let ptr = bx.alloca(Size::from_bytes(expected_bytes), Align::ONE); + bx.store(ze, ptr, Align::ONE); + let array_ty = bx.type_array(bx.type_i8(), expected_bytes); + let ptr = bx.pointercast(ptr, bx.cx.type_ptr_to(array_ty)); + return Ok(bx.load(array_ty, ptr, Align::ONE)); + } + _ => return_error!(InvalidMonomorphization::CannotReturn { + span, + name, + ret_ty, + expected_int_bits, + expected_bytes + }), + } + } + + fn simd_simple_float_intrinsic<'gcc, 'tcx>( + name: Symbol, + in_elem: Ty<'_>, + in_ty: Ty<'_>, + in_len: u64, + bx: &mut Builder<'_, 'gcc, 'tcx>, + span: Span, + args: &[OperandRef<'tcx, RValue<'gcc>>], + ) -> Result<RValue<'gcc>, ()> { + macro_rules! return_error { + ($err:expr) => {{ + bx.tcx.dcx().emit_err($err); + return Err(()); + }}; + } + let (elem_ty_str, elem_ty, cast_type) = if let ty::Float(ref f) = *in_elem.kind() { + let elem_ty = bx.cx.type_float_from_ty(*f); + match f.bit_width() { + 16 => ("", elem_ty, Some(bx.cx.double_type)), + 32 => ("f", elem_ty, None), + 64 => ("", elem_ty, None), + _ => { + return_error!(InvalidMonomorphization::FloatingPointVector { + span, + name, + f_ty: *f, + in_ty + }); + } + } + } else { + return_error!(InvalidMonomorphization::FloatingPointType { span, name, in_ty }); + }; + + let vec_ty = bx.cx.type_vector(elem_ty, in_len); + + let intr_name = match name { + sym::simd_ceil => "ceil", + sym::simd_fabs => "fabs", // TODO(antoyo): pand with 170141183420855150465331762880109871103 + sym::simd_fcos => "cos", + sym::simd_fexp2 => "exp2", + sym::simd_fexp => "exp", + sym::simd_flog10 => "log10", + sym::simd_flog2 => "log2", + sym::simd_flog => "log", + sym::simd_floor => "floor", + sym::simd_fma => "fma", + sym::simd_relaxed_fma => "fma", // FIXME: this should relax to non-fused multiply-add when necessary + sym::simd_fsin => "sin", + sym::simd_fsqrt => "sqrt", + sym::simd_round => "round", + sym::simd_round_ties_even => "rint", + sym::simd_trunc => "trunc", + _ => return_error!(InvalidMonomorphization::UnrecognizedIntrinsic { span, name }), + }; + let builtin_name = format!("{}{}", intr_name, elem_ty_str); + let function = bx.context.get_builtin_function(builtin_name); + + // TODO(antoyo): add platform-specific behavior here for architectures that have these + // intrinsics as instructions (for instance, gpus) + let mut vector_elements = vec![]; + for i in 0..in_len { + let index = bx.context.new_rvalue_from_long(bx.ulong_type, i as i64); + let mut arguments = vec![]; + for arg in args { + let mut element = bx.extract_element(arg.immediate(), index).to_rvalue(); + // FIXME: it would probably be better to not have casts here and use the proper + // instructions. + if let Some(typ) = cast_type { + element = bx.context.new_cast(None, element, typ); + } + arguments.push(element); + } + let mut result = bx.context.new_call(None, function, &arguments); + if cast_type.is_some() { + result = bx.context.new_cast(None, result, elem_ty); + } + vector_elements.push(result); + } + let c = bx.context.new_rvalue_from_vector(None, vec_ty, &vector_elements); + Ok(c) + } + + if std::matches!( + name, + sym::simd_ceil + | sym::simd_fabs + | sym::simd_fcos + | sym::simd_fexp2 + | sym::simd_fexp + | sym::simd_flog10 + | sym::simd_flog2 + | sym::simd_flog + | sym::simd_floor + | sym::simd_fma + | sym::simd_relaxed_fma + | sym::simd_fsin + | sym::simd_fsqrt + | sym::simd_round + | sym::simd_round_ties_even + | sym::simd_trunc + ) { + return simd_simple_float_intrinsic(name, in_elem, in_ty, in_len, bx, span, args); + } + + #[cfg(feature = "master")] + fn vector_ty<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + elem_ty: Ty<'tcx>, + vec_len: u64, + ) -> Type<'gcc> { + // FIXME: use cx.layout_of(ty).llvm_type() ? + let elem_ty = match *elem_ty.kind() { + ty::Int(v) => cx.type_int_from_ty(v), + ty::Uint(v) => cx.type_uint_from_ty(v), + ty::Float(v) => cx.type_float_from_ty(v), + _ => unreachable!(), + }; + cx.type_vector(elem_ty, vec_len) + } + + #[cfg(feature = "master")] + fn gather<'a, 'gcc, 'tcx>( + default: RValue<'gcc>, + pointers: RValue<'gcc>, + mask: RValue<'gcc>, + bx: &mut Builder<'a, 'gcc, 'tcx>, + in_len: u64, + invert: bool, + ) -> RValue<'gcc> { + let vector_type = default.get_type(); + let elem_type = + vector_type.unqualified().dyncast_vector().expect("vector type").get_element_type(); + + let mut values = Vec::with_capacity(in_len as usize); + for i in 0..in_len { + let index = bx.context.new_rvalue_from_long(bx.i32_type, i as i64); + let int = bx.context.new_vector_access(None, pointers, index).to_rvalue(); + + let ptr_type = elem_type.make_pointer(); + let ptr = bx.context.new_bitcast(None, int, ptr_type); + let value = ptr.dereference(None).to_rvalue(); + values.push(value); + } + + let vector = bx.context.new_rvalue_from_vector(None, vector_type, &values); + + let mut mask_types = Vec::with_capacity(in_len as usize); + let mut mask_values = Vec::with_capacity(in_len as usize); + for i in 0..in_len { + let index = bx.context.new_rvalue_from_long(bx.i32_type, i as i64); + mask_types.push(bx.context.new_field(None, bx.i32_type, "m")); + let mask_value = bx.context.new_vector_access(None, mask, index).to_rvalue(); + let mask_value_cast = bx.context.new_cast(None, mask_value, bx.i32_type); + let masked = + bx.context.new_rvalue_from_int(bx.i32_type, in_len as i32) & mask_value_cast; + let value = index + masked; + mask_values.push(value); + } + let mask_type = bx.context.new_struct_type(None, "mask_type", &mask_types); + let mask = bx.context.new_struct_constructor(None, mask_type.as_type(), None, &mask_values); + + if invert { + bx.shuffle_vector(vector, default, mask) + } else { + bx.shuffle_vector(default, vector, mask) + } + } + + #[cfg(feature = "master")] + if name == sym::simd_gather { + // simd_gather(values: <N x T>, pointers: <N x *_ T>, + // mask: <N x i{M}>) -> <N x T> + // * N: number of elements in the input vectors + // * T: type of the element to load + // * M: any integer width is supported, will be truncated to i1 + + // All types must be simd vector types + require_simd!(in_ty, InvalidMonomorphization::SimdFirst { span, name, ty: in_ty }); + require_simd!( + args[1].layout.ty, + InvalidMonomorphization::SimdSecond { span, name, ty: args[1].layout.ty } + ); + require_simd!( + args[2].layout.ty, + InvalidMonomorphization::SimdThird { span, name, ty: args[2].layout.ty } + ); + require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty }); + + // Of the same length: + let (out_len, _) = args[1].layout.ty.simd_size_and_type(bx.tcx()); + let (out_len2, _) = args[2].layout.ty.simd_size_and_type(bx.tcx()); + require!( + in_len == out_len, + InvalidMonomorphization::SecondArgumentLength { + span, + name, + in_len, + in_ty, + arg_ty: args[1].layout.ty, + out_len + } + ); + require!( + in_len == out_len2, + InvalidMonomorphization::ThirdArgumentLength { + span, + name, + in_len, + in_ty, + arg_ty: args[2].layout.ty, + out_len: out_len2 + } + ); + + // The return type must match the first argument type + require!( + ret_ty == in_ty, + InvalidMonomorphization::ExpectedReturnType { span, name, in_ty, ret_ty } + ); + + // This counts how many pointers + fn ptr_count(t: Ty<'_>) -> usize { + match *t.kind() { + ty::RawPtr(p_ty, _) => 1 + ptr_count(p_ty), + _ => 0, + } + } + + // Non-ptr type + fn non_ptr(t: Ty<'_>) -> Ty<'_> { + match *t.kind() { + ty::RawPtr(p_ty, _) => non_ptr(p_ty), + _ => t, + } + } + + // The second argument must be a simd vector with an element type that's a pointer + // to the element type of the first argument + let (_, element_ty0) = args[0].layout.ty.simd_size_and_type(bx.tcx()); + let (_, element_ty1) = args[1].layout.ty.simd_size_and_type(bx.tcx()); + let (pointer_count, underlying_ty) = match *element_ty1.kind() { + ty::RawPtr(p_ty, _) if p_ty == in_elem => { + (ptr_count(element_ty1), non_ptr(element_ty1)) + } + _ => { + require!( + false, + InvalidMonomorphization::ExpectedElementType { + span, + name, + expected_element: element_ty1, + second_arg: args[1].layout.ty, + in_elem, + in_ty, + mutability: ExpectedPointerMutability::Not, + } + ); + unreachable!(); + } + }; + assert!(pointer_count > 0); + assert_eq!(pointer_count - 1, ptr_count(element_ty0)); + assert_eq!(underlying_ty, non_ptr(element_ty0)); + + // The element type of the third argument must be an integer type of any width: + // TODO: also support unsigned integers. + let (_, element_ty2) = args[2].layout.ty.simd_size_and_type(bx.tcx()); + match *element_ty2.kind() { + ty::Int(_) => (), + _ => { + require!( + false, + InvalidMonomorphization::MaskWrongElementType { span, name, ty: element_ty2 } + ); + } + } + + return Ok(gather( + args[0].immediate(), + args[1].immediate(), + args[2].immediate(), + bx, + in_len, + false, + )); + } + + #[cfg(feature = "master")] + if name == sym::simd_scatter { + // simd_scatter(values: <N x T>, pointers: <N x *mut T>, + // mask: <N x i{M}>) -> () + // * N: number of elements in the input vectors + // * T: type of the element to load + // * M: any integer width is supported, will be truncated to i1 + + // All types must be simd vector types + require_simd!(in_ty, InvalidMonomorphization::SimdFirst { span, name, ty: in_ty }); + require_simd!( + args[1].layout.ty, + InvalidMonomorphization::SimdSecond { span, name, ty: args[1].layout.ty } + ); + require_simd!( + args[2].layout.ty, + InvalidMonomorphization::SimdThird { span, name, ty: args[2].layout.ty } + ); + + // Of the same length: + let (element_len1, _) = args[1].layout.ty.simd_size_and_type(bx.tcx()); + let (element_len2, _) = args[2].layout.ty.simd_size_and_type(bx.tcx()); + require!( + in_len == element_len1, + InvalidMonomorphization::SecondArgumentLength { + span, + name, + in_len, + in_ty, + arg_ty: args[1].layout.ty, + out_len: element_len1 + } + ); + require!( + in_len == element_len2, + InvalidMonomorphization::ThirdArgumentLength { + span, + name, + in_len, + in_ty, + arg_ty: args[2].layout.ty, + out_len: element_len2 + } + ); + + // This counts how many pointers + fn ptr_count(t: Ty<'_>) -> usize { + match *t.kind() { + ty::RawPtr(p_ty, _) => 1 + ptr_count(p_ty), + _ => 0, + } + } + + // Non-ptr type + fn non_ptr(t: Ty<'_>) -> Ty<'_> { + match *t.kind() { + ty::RawPtr(p_ty, _) => non_ptr(p_ty), + _ => t, + } + } + + // The second argument must be a simd vector with an element type that's a pointer + // to the element type of the first argument + let (_, element_ty0) = args[0].layout.ty.simd_size_and_type(bx.tcx()); + let (_, element_ty1) = args[1].layout.ty.simd_size_and_type(bx.tcx()); + let (_, element_ty2) = args[2].layout.ty.simd_size_and_type(bx.tcx()); + let (pointer_count, underlying_ty) = match *element_ty1.kind() { + ty::RawPtr(p_ty, mutability) + if p_ty == in_elem && mutability == hir::Mutability::Mut => + { + (ptr_count(element_ty1), non_ptr(element_ty1)) + } + _ => { + require!( + false, + InvalidMonomorphization::ExpectedElementType { + span, + name, + expected_element: element_ty1, + second_arg: args[1].layout.ty, + in_elem, + in_ty, + mutability: ExpectedPointerMutability::Mut, + } + ); + unreachable!(); + } + }; + assert!(pointer_count > 0); + assert_eq!(pointer_count - 1, ptr_count(element_ty0)); + assert_eq!(underlying_ty, non_ptr(element_ty0)); + + // The element type of the third argument must be a signed integer type of any width: + // TODO: also support unsigned integers. + match *element_ty2.kind() { + ty::Int(_) => (), + _ => { + require!( + false, + InvalidMonomorphization::MaskWrongElementType { span, name, ty: element_ty2 } + ); + } + } + + let result = + gather(args[0].immediate(), args[1].immediate(), args[2].immediate(), bx, in_len, true); + + let pointers = args[1].immediate(); + + let vector_type = if pointer_count > 1 { + bx.context.new_vector_type(bx.usize_type, in_len) + } else { + vector_ty(bx, underlying_ty, in_len) + }; + let elem_type = vector_type.dyncast_vector().expect("vector type").get_element_type(); + + for i in 0..in_len { + let index = bx.context.new_rvalue_from_int(bx.int_type, i as i32); + let value = bx.context.new_vector_access(None, result, index); + + let int = bx.context.new_vector_access(None, pointers, index).to_rvalue(); + let ptr_type = elem_type.make_pointer(); + let ptr = bx.context.new_bitcast(None, int, ptr_type); + bx.llbb().add_assignment(None, ptr.dereference(None), value); + } + + return Ok(bx.context.new_rvalue_zero(bx.i32_type)); + } + + arith_binary! { + simd_add: Uint, Int => add, Float => fadd; + simd_sub: Uint, Int => sub, Float => fsub; + simd_mul: Uint, Int => mul, Float => fmul; + simd_div: Uint => udiv, Int => sdiv, Float => fdiv; + simd_rem: Uint => urem, Int => srem, Float => frem; + simd_shl: Uint, Int => shl; + simd_shr: Uint => lshr, Int => ashr; + simd_and: Uint, Int => and; + simd_or: Uint, Int => or; // FIXME(antoyo): calling `or` might not work on vectors. + simd_xor: Uint, Int => xor; + simd_fmin: Float => vector_fmin; + simd_fmax: Float => vector_fmax; + } + + macro_rules! arith_unary { + ($($name: ident: $($($p: ident),* => $call: ident),*;)*) => { + $(if name == sym::$name { + match *in_elem.kind() { + $($(ty::$p(_))|* => { + return Ok(bx.$call(args[0].immediate())) + })* + _ => {}, + } + return_error!(InvalidMonomorphization::UnsupportedOperation { span, name, in_ty, in_elem }) + })* + } + } + + arith_unary! { + simd_neg: Int => neg, Float => fneg; + } + + #[cfg(feature = "master")] + if name == sym::simd_saturating_add || name == sym::simd_saturating_sub { + let lhs = args[0].immediate(); + let rhs = args[1].immediate(); + let is_add = name == sym::simd_saturating_add; + let ptr_bits = bx.tcx().data_layout.pointer_size().bits() as _; + let (signed, elem_width, elem_ty) = match *in_elem.kind() { + ty::Int(i) => (true, i.bit_width().unwrap_or(ptr_bits) / 8, bx.cx.type_int_from_ty(i)), + ty::Uint(i) => { + (false, i.bit_width().unwrap_or(ptr_bits) / 8, bx.cx.type_uint_from_ty(i)) + } + _ => { + return_error!(InvalidMonomorphization::ExpectedVectorElementType { + span, + name, + expected_element: args[0].layout.ty.simd_size_and_type(bx.tcx()).1, + vector_type: args[0].layout.ty, + }); + } + }; + + let result = match (signed, is_add) { + (false, true) => { + let res = lhs + rhs; + let cmp = bx.context.new_comparison(None, ComparisonOp::LessThan, res, lhs); + res | cmp + } + (true, true) => { + // Algorithm from: https://codereview.stackexchange.com/questions/115869/saturated-signed-addition + // TODO(antoyo): improve using conditional operators if possible. + // TODO(antoyo): dyncast_vector should not require a call to unqualified. + let arg_type = lhs.get_type().unqualified(); + // TODO(antoyo): convert lhs and rhs to unsigned. + let sum = lhs + rhs; + let vector_type = arg_type.dyncast_vector().expect("vector type"); + let unit = vector_type.get_num_units(); + let a = bx.context.new_rvalue_from_int(elem_ty, ((elem_width as i32) << 3) - 1); + let width = bx.context.new_rvalue_from_vector(None, lhs.get_type(), &vec![a; unit]); + + let xor1 = lhs ^ rhs; + let xor2 = lhs ^ sum; + let and = + bx.context.new_unary_op(None, UnaryOp::BitwiseNegate, arg_type, xor1) & xor2; + let mask = and >> width; + + let one = bx.context.new_rvalue_one(elem_ty); + let ones = + bx.context.new_rvalue_from_vector(None, lhs.get_type(), &vec![one; unit]); + let shift1 = ones << width; + let shift2 = sum >> width; + let mask_min = shift1 ^ shift2; + + let and1 = + bx.context.new_unary_op(None, UnaryOp::BitwiseNegate, arg_type, mask) & sum; + let and2 = mask & mask_min; + + and1 + and2 + } + (false, false) => { + let res = lhs - rhs; + let cmp = bx.context.new_comparison(None, ComparisonOp::LessThanEquals, res, lhs); + res & cmp + } + (true, false) => { + // TODO(antoyo): dyncast_vector should not require a call to unqualified. + let arg_type = lhs.get_type().unqualified(); + // TODO(antoyo): this uses the same algorithm from saturating add, but add the + // negative of the right operand. Find a proper subtraction algorithm. + let rhs = bx.context.new_unary_op(None, UnaryOp::Minus, arg_type, rhs); + + // TODO(antoyo): convert lhs and rhs to unsigned. + let sum = lhs + rhs; + let vector_type = arg_type.dyncast_vector().expect("vector type"); + let unit = vector_type.get_num_units(); + let a = bx.context.new_rvalue_from_int(elem_ty, ((elem_width as i32) << 3) - 1); + let width = bx.context.new_rvalue_from_vector(None, lhs.get_type(), &vec![a; unit]); + + let xor1 = lhs ^ rhs; + let xor2 = lhs ^ sum; + let and = + bx.context.new_unary_op(None, UnaryOp::BitwiseNegate, arg_type, xor1) & xor2; + let mask = and >> width; + + let one = bx.context.new_rvalue_one(elem_ty); + let ones = + bx.context.new_rvalue_from_vector(None, lhs.get_type(), &vec![one; unit]); + let shift1 = ones << width; + let shift2 = sum >> width; + let mask_min = shift1 ^ shift2; + + let and1 = + bx.context.new_unary_op(None, UnaryOp::BitwiseNegate, arg_type, mask) & sum; + let and2 = mask & mask_min; + + and1 + and2 + } + }; + + return Ok(result); + } + + macro_rules! arith_red { + ($name:ident : $vec_op:expr, $float_reduce:ident, $ordered:expr, $op:ident, + $identity:expr) => { + if name == sym::$name { + require!( + ret_ty == in_elem, + InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty } + ); + return match *in_elem.kind() { + ty::Int(_) | ty::Uint(_) => { + let r = bx.vector_reduce_op(args[0].immediate(), $vec_op); + if $ordered { + // if overflow occurs, the result is the + // mathematical result modulo 2^n: + Ok(bx.$op(args[1].immediate(), r)) + } else { + Ok(bx.vector_reduce_op(args[0].immediate(), $vec_op)) + } + } + ty::Float(_) => { + if $ordered { + // ordered arithmetic reductions take an accumulator + let acc = args[1].immediate(); + Ok(bx.$float_reduce(acc, args[0].immediate())) + } else { + Ok(bx.vector_reduce_op(args[0].immediate(), $vec_op)) + } + } + _ => return_error!(InvalidMonomorphization::UnsupportedSymbol { + span, + name, + symbol: sym::$name, + in_ty, + in_elem, + ret_ty + }), + }; + } + }; + } + + arith_red!( + simd_reduce_add_unordered: BinaryOp::Plus, + vector_reduce_fadd_reassoc, + false, + add, + 0.0 // TODO: Use this argument. + ); + arith_red!( + simd_reduce_mul_unordered: BinaryOp::Mult, + vector_reduce_fmul_reassoc, + false, + mul, + 1.0 + ); + arith_red!( + simd_reduce_add_ordered: BinaryOp::Plus, + vector_reduce_fadd, + true, + add, + 0.0 + ); + arith_red!( + simd_reduce_mul_ordered: BinaryOp::Mult, + vector_reduce_fmul, + true, + mul, + 1.0 + ); + + macro_rules! minmax_red { + ($name:ident: $int_red:ident, $float_red:ident) => { + if name == sym::$name { + require!( + ret_ty == in_elem, + InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty } + ); + return match *in_elem.kind() { + ty::Int(_) | ty::Uint(_) => Ok(bx.$int_red(args[0].immediate())), + ty::Float(_) => Ok(bx.$float_red(args[0].immediate())), + _ => return_error!(InvalidMonomorphization::UnsupportedSymbol { + span, + name, + symbol: sym::$name, + in_ty, + in_elem, + ret_ty + }), + }; + } + }; + } + + minmax_red!(simd_reduce_min: vector_reduce_min, vector_reduce_fmin); + minmax_red!(simd_reduce_max: vector_reduce_max, vector_reduce_fmax); + + macro_rules! bitwise_red { + ($name:ident : $op:expr, $boolean:expr) => { + if name == sym::$name { + let input = if !$boolean { + require!( + ret_ty == in_elem, + InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty } + ); + args[0].immediate() + } else { + match *in_elem.kind() { + ty::Int(_) | ty::Uint(_) => {} + _ => return_error!(InvalidMonomorphization::UnsupportedSymbol { + span, + name, + symbol: sym::$name, + in_ty, + in_elem, + ret_ty + }), + } + + args[0].immediate() + }; + return match *in_elem.kind() { + ty::Int(_) | ty::Uint(_) => { + let r = bx.vector_reduce_op(input, $op); + Ok(if !$boolean { + r + } else { + bx.icmp( + IntPredicate::IntNE, + r, + bx.context.new_rvalue_zero(r.get_type()), + ) + }) + } + _ => return_error!(InvalidMonomorphization::UnsupportedSymbol { + span, + name, + symbol: sym::$name, + in_ty, + in_elem, + ret_ty + }), + }; + } + }; + } + + bitwise_red!(simd_reduce_and: BinaryOp::BitwiseAnd, false); + bitwise_red!(simd_reduce_or: BinaryOp::BitwiseOr, false); + bitwise_red!(simd_reduce_xor: BinaryOp::BitwiseXor, false); + bitwise_red!(simd_reduce_all: BinaryOp::BitwiseAnd, true); + bitwise_red!(simd_reduce_any: BinaryOp::BitwiseOr, true); + + unimplemented!("simd {}", name); +} + +#[cfg(feature = "master")] +fn simd_funnel_shift<'a, 'gcc, 'tcx>( + bx: &mut Builder<'a, 'gcc, 'tcx>, + a: RValue<'gcc>, + b: RValue<'gcc>, + shift: RValue<'gcc>, + shift_left: bool, +) -> RValue<'gcc> { + use crate::common::SignType; + + let a_type = a.get_type(); + let vector_type = a_type.unqualified().dyncast_vector().expect("vector type"); + let num_units = vector_type.get_num_units(); + let elem_type = vector_type.get_element_type(); + + let (new_int_type, int_shift_val, int_mask) = if elem_type.is_compatible_with(bx.u8_type) + || elem_type.is_compatible_with(bx.i8_type) + { + (bx.u16_type, 8, u8::MAX as u64) + } else if elem_type.is_compatible_with(bx.u16_type) || elem_type.is_compatible_with(bx.i16_type) + { + (bx.u32_type, 16, u16::MAX as u64) + } else if elem_type.is_compatible_with(bx.u32_type) || elem_type.is_compatible_with(bx.i32_type) + { + (bx.u64_type, 32, u32::MAX as u64) + } else if elem_type.is_compatible_with(bx.u64_type) || elem_type.is_compatible_with(bx.i64_type) + { + (bx.u128_type, 64, u64::MAX) + } else { + unimplemented!("funnel shift on {:?}", elem_type); + }; + + let int_mask = bx.context.new_rvalue_from_long(new_int_type, int_mask as i64); + let int_shift_val = bx.context.new_rvalue_from_int(new_int_type, int_shift_val); + let mut elements = vec![]; + let unsigned_type = elem_type.to_unsigned(bx); + for i in 0..num_units { + let index = bx.context.new_rvalue_from_int(bx.int_type, i as i32); + let a_val = bx.context.new_vector_access(None, a, index).to_rvalue(); + let a_val = bx.context.new_bitcast(None, a_val, unsigned_type); + // TODO: we probably need to use gcc_int_cast instead. + let a_val = bx.gcc_int_cast(a_val, new_int_type); + let b_val = bx.context.new_vector_access(None, b, index).to_rvalue(); + let b_val = bx.context.new_bitcast(None, b_val, unsigned_type); + let b_val = bx.gcc_int_cast(b_val, new_int_type); + let shift_val = bx.context.new_vector_access(None, shift, index).to_rvalue(); + let shift_val = bx.gcc_int_cast(shift_val, new_int_type); + let mut val = a_val << int_shift_val | b_val; + if shift_left { + val = (val << shift_val) >> int_shift_val; + } else { + val = (val >> shift_val) & int_mask; + } + let val = bx.gcc_int_cast(val, elem_type); + elements.push(val); + } + bx.context.new_rvalue_from_vector(None, a_type, &elements) +} diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs new file mode 100644 index 00000000000..b11f11d38e3 --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -0,0 +1,492 @@ +/* + * TODO(antoyo): implement equality in libgccjit based on https://zpz.github.io/blog/overloading-equality-operator-in-cpp-class-hierarchy/ (for type equality?) + * TODO(antoyo): support #[inline] attributes. + * TODO(antoyo): support LTO (gcc's equivalent to Full LTO is -flto -flto-partition=one — https://documentation.suse.com/sbp/all/html/SBP-GCC-10/index.html). + * For Thin LTO, this might be helpful: +// cspell:disable-next-line + * In gcc 4.6 -fwhopr was removed and became default with -flto. The non-whopr path can still be executed via -flto-partition=none. + * Or the new incremental LTO (https://www.phoronix.com/news/GCC-Incremental-LTO-Patches)? + * + * Maybe some missing optimizations enabled by rustc's LTO is in there: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html +// cspell:disable-next-line + * Like -fipa-icf (should be already enabled) and maybe -fdevirtualize-at-ltrans. + * TODO: disable debug info always being emitted. Perhaps this slows down things? + * + * TODO(antoyo): remove the patches. + */ + +#![allow(internal_features)] +#![doc(rust_logo)] +#![feature(rustdoc_internals)] +#![feature(rustc_private)] +#![recursion_limit = "256"] +#![warn(rust_2018_idioms)] +#![warn(unused_lifetimes)] +#![deny(clippy::pattern_type_mismatch)] +#![allow(clippy::needless_lifetimes, clippy::uninlined_format_args)] + +// These crates are pulled from the sysroot because they are part of +// rustc's public API, so we need to ensure version compatibility. +extern crate smallvec; +#[macro_use] +extern crate tracing; + +// The rustc crates we need +extern crate rustc_abi; +extern crate rustc_apfloat; +extern crate rustc_ast; +extern crate rustc_codegen_ssa; +extern crate rustc_data_structures; +extern crate rustc_errors; +extern crate rustc_fluent_macro; +extern crate rustc_fs_util; +extern crate rustc_hir; +extern crate rustc_index; +#[cfg(feature = "master")] +extern crate rustc_interface; +extern crate rustc_macros; +extern crate rustc_middle; +extern crate rustc_session; +extern crate rustc_span; +extern crate rustc_symbol_mangling; +extern crate rustc_target; +extern crate rustc_type_ir; + +// This prevents duplicating functions and statics that are already part of the host rustc process. +#[allow(unused_extern_crates)] +extern crate rustc_driver; + +mod abi; +mod allocator; +mod asm; +mod attributes; +mod back; +mod base; +mod builder; +mod callee; +mod common; +mod consts; +mod context; +mod coverageinfo; +mod debuginfo; +mod declare; +mod errors; +mod gcc_util; +mod int; +mod intrinsic; +mod mono_item; +mod type_; +mod type_of; + +use std::any::Any; +use std::fmt::Debug; +use std::ops::Deref; +use std::path::PathBuf; +#[cfg(not(feature = "master"))] +use std::sync::atomic::AtomicBool; +#[cfg(not(feature = "master"))] +use std::sync::atomic::Ordering; +use std::sync::{Arc, Mutex}; + +use back::lto::{ThinBuffer, ThinData}; +use gccjit::{CType, Context, OptimizationLevel}; +#[cfg(feature = "master")] +use gccjit::{TargetInfo, Version}; +use rustc_ast::expand::allocator::AllocatorKind; +use rustc_ast::expand::autodiff_attrs::AutoDiffItem; +use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule}; +use rustc_codegen_ssa::back::write::{ + CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryFn, +}; +use rustc_codegen_ssa::base::codegen_crate; +use rustc_codegen_ssa::target_features::cfg_target_feature; +use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, WriteBackendMethods}; +use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, TargetConfig}; +use rustc_data_structures::fx::FxIndexMap; +use rustc_data_structures::sync::IntoDynSyncSend; +use rustc_errors::DiagCtxtHandle; +use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; +use rustc_middle::ty::TyCtxt; +use rustc_middle::util::Providers; +use rustc_session::Session; +use rustc_session::config::{OptLevel, OutputFilenames}; +use rustc_span::Symbol; +use rustc_span::fatal_error::FatalError; +use rustc_target::spec::RelocModel; +use tempfile::TempDir; + +use crate::back::lto::ModuleBuffer; +use crate::gcc_util::target_cpu; + +rustc_fluent_macro::fluent_messages! { "../messages.ftl" } + +pub struct PrintOnPanic<F: Fn() -> String>(pub F); + +impl<F: Fn() -> String> Drop for PrintOnPanic<F> { + fn drop(&mut self) { + if ::std::thread::panicking() { + println!("{}", (self.0)()); + } + } +} + +#[cfg(not(feature = "master"))] +#[derive(Debug)] +pub struct TargetInfo { + supports_128bit_integers: AtomicBool, +} + +#[cfg(not(feature = "master"))] +impl TargetInfo { + fn cpu_supports(&self, _feature: &str) -> bool { + false + } + + fn supports_target_dependent_type(&self, typ: CType) -> bool { + match typ { + CType::UInt128t | CType::Int128t => { + if self.supports_128bit_integers.load(Ordering::SeqCst) { + return true; + } + } + _ => (), + } + false + } +} + +#[derive(Clone)] +pub struct LockedTargetInfo { + info: Arc<Mutex<IntoDynSyncSend<TargetInfo>>>, +} + +impl Debug for LockedTargetInfo { + fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.info.lock().expect("lock").fmt(formatter) + } +} + +impl LockedTargetInfo { + fn cpu_supports(&self, feature: &str) -> bool { + self.info.lock().expect("lock").cpu_supports(feature) + } + + fn supports_target_dependent_type(&self, typ: CType) -> bool { + self.info.lock().expect("lock").supports_target_dependent_type(typ) + } +} + +#[derive(Clone)] +pub struct GccCodegenBackend { + target_info: LockedTargetInfo, +} + +impl CodegenBackend for GccCodegenBackend { + fn locale_resource(&self) -> &'static str { + crate::DEFAULT_LOCALE_RESOURCE + } + + fn init(&self, _sess: &Session) { + #[cfg(feature = "master")] + { + let target_cpu = target_cpu(_sess); + + // Get the second TargetInfo with the correct CPU features by setting the arch. + let context = Context::default(); + if target_cpu != "generic" { + context.add_command_line_option(format!("-march={}", target_cpu)); + } + + **self.target_info.info.lock().expect("lock") = context.get_target_info(); + } + + #[cfg(feature = "master")] + gccjit::set_global_personality_function_name(b"rust_eh_personality\0"); + + #[cfg(not(feature = "master"))] + { + let temp_dir = TempDir::new().expect("cannot create temporary directory"); + let temp_file = temp_dir.keep().join("result.asm"); + let check_context = Context::default(); + check_context.set_print_errors_to_stderr(false); + let _int128_ty = check_context.new_c_type(CType::UInt128t); + // NOTE: we cannot just call compile() as this would require other files than libgccjit.so. + check_context.compile_to_file( + gccjit::OutputKind::Assembler, + temp_file.to_str().expect("path to str"), + ); + self.target_info + .info + .lock() + .expect("lock") + .supports_128bit_integers + .store(check_context.get_last_error() == Ok(None), Ordering::SeqCst); + } + } + + fn provide(&self, providers: &mut Providers) { + providers.global_backend_features = |tcx, ()| gcc_util::global_gcc_features(tcx.sess, true) + } + + fn codegen_crate(&self, tcx: TyCtxt<'_>) -> Box<dyn Any> { + let target_cpu = target_cpu(tcx.sess); + let res = codegen_crate(self.clone(), tcx, target_cpu.to_string()); + + Box::new(res) + } + + fn join_codegen( + &self, + ongoing_codegen: Box<dyn Any>, + sess: &Session, + _outputs: &OutputFilenames, + ) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) { + ongoing_codegen + .downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<GccCodegenBackend>>() + .expect("Expected GccCodegenBackend's OngoingCodegen, found Box<Any>") + .join(sess) + } + + fn target_config(&self, sess: &Session) -> TargetConfig { + target_config(sess, &self.target_info) + } +} + +fn new_context<'gcc, 'tcx>(tcx: TyCtxt<'tcx>) -> Context<'gcc> { + let context = Context::default(); + if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" { + context.add_command_line_option("-masm=intel"); + } + #[cfg(feature = "master")] + { + context.set_special_chars_allowed_in_func_names("$.*"); + let version = Version::get(); + let version = format!("{}.{}.{}", version.major, version.minor, version.patch); + context.set_output_ident(&format!( + "rustc version {} with libgccjit {}", + rustc_interface::util::rustc_version_str().unwrap_or("unknown version"), + version, + )); + } + // TODO(antoyo): check if this should only be added when using -Cforce-unwind-tables=n. + context.add_command_line_option("-fno-asynchronous-unwind-tables"); + context +} + +impl ExtraBackendMethods for GccCodegenBackend { + fn supports_parallel(&self) -> bool { + false + } + + fn codegen_allocator( + &self, + tcx: TyCtxt<'_>, + module_name: &str, + kind: AllocatorKind, + alloc_error_handler_kind: AllocatorKind, + ) -> Self::Module { + let mut mods = GccContext { + context: Arc::new(SyncContext::new(new_context(tcx))), + relocation_model: tcx.sess.relocation_model(), + should_combine_object_files: false, + temp_dir: None, + }; + + unsafe { + allocator::codegen(tcx, &mut mods, module_name, kind, alloc_error_handler_kind); + } + mods + } + + fn compile_codegen_unit( + &self, + tcx: TyCtxt<'_>, + cgu_name: Symbol, + ) -> (ModuleCodegen<Self::Module>, u64) { + base::compile_codegen_unit(tcx, cgu_name, self.target_info.clone()) + } + + fn target_machine_factory( + &self, + _sess: &Session, + _opt_level: OptLevel, + _features: &[String], + ) -> TargetMachineFactoryFn<Self> { + // TODO(antoyo): set opt level. + Arc::new(|_| Ok(())) + } +} + +pub struct GccContext { + context: Arc<SyncContext>, + /// This field is needed in order to be able to set the flag -fPIC when necessary when doing + /// LTO. + relocation_model: RelocModel, + should_combine_object_files: bool, + // Temporary directory used by LTO. We keep it here so that it's not removed before linking. + temp_dir: Option<TempDir>, +} + +struct SyncContext { + context: Context<'static>, +} + +impl SyncContext { + fn new(context: Context<'static>) -> Self { + Self { context } + } +} + +impl Deref for SyncContext { + type Target = Context<'static>; + + fn deref(&self) -> &Self::Target { + &self.context + } +} + +unsafe impl Send for SyncContext {} +// FIXME(antoyo): that shouldn't be Sync. Parallel compilation is currently disabled with "CodegenBackend::supports_parallel()". +unsafe impl Sync for SyncContext {} + +impl WriteBackendMethods for GccCodegenBackend { + type Module = GccContext; + type TargetMachine = (); + type TargetMachineError = (); + type ModuleBuffer = ModuleBuffer; + type ThinData = ThinData; + type ThinBuffer = ThinBuffer; + + fn run_and_optimize_fat_lto( + cgcx: &CodegenContext<Self>, + // FIXME(bjorn3): Limit LTO exports to these symbols + _exported_symbols_for_lto: &[String], + each_linked_rlib_for_lto: &[PathBuf], + modules: Vec<FatLtoInput<Self>>, + diff_functions: Vec<AutoDiffItem>, + ) -> Result<ModuleCodegen<Self::Module>, FatalError> { + if !diff_functions.is_empty() { + unimplemented!(); + } + + back::lto::run_fat(cgcx, each_linked_rlib_for_lto, modules) + } + + fn run_thin_lto( + cgcx: &CodegenContext<Self>, + // FIXME(bjorn3): Limit LTO exports to these symbols + _exported_symbols_for_lto: &[String], + each_linked_rlib_for_lto: &[PathBuf], + modules: Vec<(String, Self::ThinBuffer)>, + cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>, + ) -> Result<(Vec<ThinModule<Self>>, Vec<WorkProduct>), FatalError> { + back::lto::run_thin(cgcx, each_linked_rlib_for_lto, modules, cached_modules) + } + + fn print_pass_timings(&self) { + unimplemented!(); + } + + fn print_statistics(&self) { + unimplemented!() + } + + fn optimize( + _cgcx: &CodegenContext<Self>, + _dcx: DiagCtxtHandle<'_>, + module: &mut ModuleCodegen<Self::Module>, + config: &ModuleConfig, + ) -> Result<(), FatalError> { + module.module_llvm.context.set_optimization_level(to_gcc_opt_level(config.opt_level)); + Ok(()) + } + + fn optimize_thin( + cgcx: &CodegenContext<Self>, + thin: ThinModule<Self>, + ) -> Result<ModuleCodegen<Self::Module>, FatalError> { + back::lto::optimize_thin_module(thin, cgcx) + } + + fn codegen( + cgcx: &CodegenContext<Self>, + module: ModuleCodegen<Self::Module>, + config: &ModuleConfig, + ) -> Result<CompiledModule, FatalError> { + back::write::codegen(cgcx, module, config) + } + + fn prepare_thin( + module: ModuleCodegen<Self::Module>, + emit_summary: bool, + ) -> (String, Self::ThinBuffer) { + back::lto::prepare_thin(module, emit_summary) + } + + fn serialize_module(_module: ModuleCodegen<Self::Module>) -> (String, Self::ModuleBuffer) { + unimplemented!(); + } +} + +/// This is the entrypoint for a hot plugged rustc_codegen_gccjit +#[unsafe(no_mangle)] +pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> { + #[cfg(feature = "master")] + let info = { + // Check whether the target supports 128-bit integers, and sized floating point types (like + // Float16). + let context = Context::default(); + Arc::new(Mutex::new(IntoDynSyncSend(context.get_target_info()))) + }; + #[cfg(not(feature = "master"))] + let info = Arc::new(Mutex::new(IntoDynSyncSend(TargetInfo { + supports_128bit_integers: AtomicBool::new(false), + }))); + + Box::new(GccCodegenBackend { target_info: LockedTargetInfo { info } }) +} + +fn to_gcc_opt_level(optlevel: Option<OptLevel>) -> OptimizationLevel { + match optlevel { + None => OptimizationLevel::None, + Some(level) => match level { + OptLevel::No => OptimizationLevel::None, + OptLevel::Less => OptimizationLevel::Limited, + OptLevel::More => OptimizationLevel::Standard, + OptLevel::Aggressive => OptimizationLevel::Aggressive, + OptLevel::Size | OptLevel::SizeMin => OptimizationLevel::Limited, + }, + } +} + +/// Returns the features that should be set in `cfg(target_feature)`. +fn target_config(sess: &Session, target_info: &LockedTargetInfo) -> TargetConfig { + let (unstable_target_features, target_features) = cfg_target_feature(sess, |feature| { + // TODO: we disable Neon for now since we don't support the LLVM intrinsics for it. + if feature == "neon" { + return false; + } + target_info.cpu_supports(feature) + // cSpell:disable + /* + adx, aes, avx, avx2, avx512bf16, avx512bitalg, avx512bw, avx512cd, avx512dq, avx512er, avx512f, avx512fp16, avx512ifma, + avx512pf, avx512vbmi, avx512vbmi2, avx512vl, avx512vnni, avx512vp2intersect, avx512vpopcntdq, + bmi1, bmi2, cmpxchg16b, ermsb, f16c, fma, fxsr, gfni, lzcnt, movbe, pclmulqdq, popcnt, rdrand, rdseed, rtm, + sha, sse, sse2, sse3, sse4.1, sse4.2, sse4a, ssse3, tbm, vaes, vpclmulqdq, xsave, xsavec, xsaveopt, xsaves + */ + // cSpell:enable + }); + + let has_reliable_f16 = target_info.supports_target_dependent_type(CType::Float16); + let has_reliable_f128 = target_info.supports_target_dependent_type(CType::Float128); + + TargetConfig { + target_features, + unstable_target_features, + // There are no known bugs with GCC support for f16 or f128 + has_reliable_f16, + has_reliable_f16_math: has_reliable_f16, + has_reliable_f128, + has_reliable_f128_math: has_reliable_f128, + } +} diff --git a/compiler/rustc_codegen_gcc/src/mono_item.rs b/compiler/rustc_codegen_gcc/src/mono_item.rs new file mode 100644 index 00000000000..ff188c437da --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/mono_item.rs @@ -0,0 +1,79 @@ +#[cfg(feature = "master")] +use gccjit::{FnAttribute, VarAttribute}; +use rustc_codegen_ssa::traits::PreDefineCodegenMethods; +use rustc_hir::def::DefKind; +use rustc_hir::def_id::{DefId, LOCAL_CRATE}; +use rustc_middle::bug; +use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; +use rustc_middle::mir::mono::{Linkage, Visibility}; +use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv, LayoutOf}; +use rustc_middle::ty::{self, Instance, TypeVisitableExt}; + +use crate::context::CodegenCx; +use crate::type_of::LayoutGccExt; +use crate::{attributes, base}; + +impl<'gcc, 'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> { + #[cfg_attr(not(feature = "master"), allow(unused_variables))] + fn predefine_static( + &mut self, + def_id: DefId, + _linkage: Linkage, + visibility: Visibility, + symbol_name: &str, + ) { + let attrs = self.tcx.codegen_fn_attrs(def_id); + let instance = Instance::mono(self.tcx, def_id); + let DefKind::Static { nested, .. } = self.tcx.def_kind(def_id) else { bug!() }; + // Nested statics do not have a type, so pick a dummy type and let `codegen_static` figure out + // the gcc type from the actual evaluated initializer. + let ty = + if nested { self.tcx.types.unit } else { instance.ty(self.tcx, self.typing_env()) }; + let gcc_type = self.layout_of(ty).gcc_type(self); + + let is_tls = attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL); + let global = self.define_global(symbol_name, gcc_type, is_tls, attrs.link_section); + #[cfg(feature = "master")] + global.add_attribute(VarAttribute::Visibility(base::visibility_to_gcc(visibility))); + + // TODO(antoyo): set linkage. + self.instances.borrow_mut().insert(instance, global); + } + + #[cfg_attr(not(feature = "master"), allow(unused_variables))] + fn predefine_fn( + &mut self, + instance: Instance<'tcx>, + linkage: Linkage, + visibility: Visibility, + symbol_name: &str, + ) { + assert!(!instance.args.has_infer()); + + let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty()); + self.linkage.set(base::linkage_to_gcc(linkage)); + let decl = self.declare_fn(symbol_name, fn_abi); + //let attrs = self.tcx.codegen_instance_attrs(instance.def); + + attributes::from_fn_attrs(self, decl, instance); + + // If we're compiling the compiler-builtins crate, e.g., the equivalent of + // compiler-rt, then we want to implicitly compile everything with hidden + // visibility as we're going to link this object all over the place but + // don't want the symbols to get exported. + if linkage != Linkage::Internal && self.tcx.is_compiler_builtins(LOCAL_CRATE) { + #[cfg(feature = "master")] + decl.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Hidden)); + } else if visibility != Visibility::Default { + #[cfg(feature = "master")] + decl.add_attribute(FnAttribute::Visibility(base::visibility_to_gcc(visibility))); + } + + // TODO(antoyo): call set_link_section() to allow initializing argc/argv. + // TODO(antoyo): set unique comdat. + // TODO(antoyo): use inline attribute from there in linkage.set() above. + + self.functions.borrow_mut().insert(symbol_name.to_string(), decl); + self.function_instances.borrow_mut().insert(instance, decl); + } +} diff --git a/compiler/rustc_codegen_gcc/src/type_.rs b/compiler/rustc_codegen_gcc/src/type_.rs new file mode 100644 index 00000000000..15a0206607e --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/type_.rs @@ -0,0 +1,386 @@ +#[cfg(feature = "master")] +use std::convert::TryInto; + +#[cfg(feature = "master")] +use gccjit::CType; +use gccjit::{RValue, Struct, Type}; +use rustc_abi::{AddressSpace, Align, Integer, Size}; +use rustc_codegen_ssa::common::TypeKind; +use rustc_codegen_ssa::traits::{ + BaseTypeCodegenMethods, DerivedTypeCodegenMethods, TypeMembershipCodegenMethods, +}; +use rustc_middle::ty::layout::TyAndLayout; +use rustc_middle::{bug, ty}; + +use crate::common::TypeReflection; +use crate::context::CodegenCx; +use crate::type_of::LayoutGccExt; + +impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { + pub fn type_ix(&self, num_bits: u64) -> Type<'gcc> { + // gcc only supports 1, 2, 4 or 8-byte integers. + // FIXME(antoyo): this is misleading to use the next power of two as rustc_codegen_ssa + // sometimes use 96-bit numbers and the following code will give an integer of a different + // size. + let bytes = (num_bits / 8).next_power_of_two() as i32; + match bytes { + 1 => self.i8_type, + 2 => self.i16_type, + 4 => self.i32_type, + 8 => self.i64_type, + 16 => self.i128_type, + _ => panic!("unexpected num_bits: {}", num_bits), + } + } + + pub fn type_void(&self) -> Type<'gcc> { + self.context.new_type::<()>() + } + + pub fn type_size_t(&self) -> Type<'gcc> { + self.context.new_type::<usize>() + } + + pub fn type_u8(&self) -> Type<'gcc> { + self.u8_type + } + + pub fn type_u16(&self) -> Type<'gcc> { + self.u16_type + } + + pub fn type_u32(&self) -> Type<'gcc> { + self.u32_type + } + + pub fn type_u64(&self) -> Type<'gcc> { + self.u64_type + } + + pub fn type_u128(&self) -> Type<'gcc> { + self.u128_type + } + + pub fn type_ptr_to(&self, ty: Type<'gcc>) -> Type<'gcc> { + ty.make_pointer() + } + + pub fn type_ptr_to_ext(&self, ty: Type<'gcc>, _address_space: AddressSpace) -> Type<'gcc> { + // TODO(antoyo): use address_space, perhaps with TYPE_ADDR_SPACE? + ty.make_pointer() + } + + pub fn type_i8p(&self) -> Type<'gcc> { + self.type_ptr_to(self.type_i8()) + } + + pub fn type_i8p_ext(&self, address_space: AddressSpace) -> Type<'gcc> { + self.type_ptr_to_ext(self.type_i8(), address_space) + } + + pub fn type_pointee_for_align(&self, align: Align) -> Type<'gcc> { + // FIXME(eddyb) We could find a better approximation if ity.align < align. + let ity = Integer::approximate_align(self, align); + self.type_from_integer(ity) + } + + pub fn type_vector(&self, ty: Type<'gcc>, len: u64) -> Type<'gcc> { + self.context.new_vector_type(ty, len) + } + + pub fn type_float_from_ty(&self, t: ty::FloatTy) -> Type<'gcc> { + match t { + ty::FloatTy::F16 => self.type_f16(), + ty::FloatTy::F32 => self.type_f32(), + ty::FloatTy::F64 => self.type_f64(), + ty::FloatTy::F128 => self.type_f128(), + } + } + + pub fn type_i1(&self) -> Type<'gcc> { + self.bool_type + } + + pub fn type_struct(&self, fields: &[Type<'gcc>], packed: bool) -> Type<'gcc> { + let types = fields.to_vec(); + if let Some(typ) = self.struct_types.borrow().get(fields) { + return *typ; + } + let fields: Vec<_> = fields + .iter() + .enumerate() + .map(|(index, field)| { + self.context.new_field(None, *field, format!("field{}_TODO", index)) + }) + .collect(); + let typ = self.context.new_struct_type(None, "struct", &fields).as_type(); + if packed { + #[cfg(feature = "master")] + typ.set_packed(); + } + self.struct_types.borrow_mut().insert(types, typ); + typ + } +} + +impl<'gcc, 'tcx> BaseTypeCodegenMethods for CodegenCx<'gcc, 'tcx> { + fn type_i8(&self) -> Type<'gcc> { + self.i8_type + } + + fn type_i16(&self) -> Type<'gcc> { + self.i16_type + } + + fn type_i32(&self) -> Type<'gcc> { + self.i32_type + } + + fn type_i64(&self) -> Type<'gcc> { + self.i64_type + } + + fn type_i128(&self) -> Type<'gcc> { + self.i128_type + } + + fn type_isize(&self) -> Type<'gcc> { + self.isize_type + } + + fn type_f16(&self) -> Type<'gcc> { + #[cfg(feature = "master")] + if self.supports_f16_type { + return self.context.new_c_type(CType::Float16); + } + bug!("unsupported float width 16") + } + + fn type_f32(&self) -> Type<'gcc> { + #[cfg(feature = "master")] + if self.supports_f32_type { + return self.context.new_c_type(CType::Float32); + } + self.float_type + } + + fn type_f64(&self) -> Type<'gcc> { + #[cfg(feature = "master")] + if self.supports_f64_type { + return self.context.new_c_type(CType::Float64); + } + self.double_type + } + + fn type_f128(&self) -> Type<'gcc> { + #[cfg(feature = "master")] + if self.supports_f128_type { + return self.context.new_c_type(CType::Float128); + } + bug!("unsupported float width 128") + } + + fn type_func(&self, params: &[Type<'gcc>], return_type: Type<'gcc>) -> Type<'gcc> { + self.context.new_function_pointer_type(None, return_type, params, false) + } + + #[cfg(feature = "master")] + fn type_kind(&self, typ: Type<'gcc>) -> TypeKind { + if self.is_int_type_or_bool(typ) { + TypeKind::Integer + } else if typ.get_pointee().is_some() { + TypeKind::Pointer + } else if typ.is_vector() { + TypeKind::Vector + } else if typ.dyncast_array().is_some() { + TypeKind::Array + } else if typ.is_struct().is_some() { + TypeKind::Struct + } else if typ.dyncast_function_ptr_type().is_some() { + TypeKind::Function + } else if typ.is_compatible_with(self.float_type) { + TypeKind::Float + } else if typ.is_compatible_with(self.double_type) { + TypeKind::Double + } else if typ.is_floating_point() { + match typ.get_size() { + 2 => TypeKind::Half, + 4 => TypeKind::Float, + 8 => TypeKind::Double, + 16 => TypeKind::FP128, + size => unreachable!("Floating-point type of size {}", size), + } + } else if typ == self.type_void() { + TypeKind::Void + } else { + // TODO(antoyo): support other types. + unimplemented!(); + } + } + + #[cfg(not(feature = "master"))] + fn type_kind(&self, typ: Type<'gcc>) -> TypeKind { + if self.is_int_type_or_bool(typ) { + TypeKind::Integer + } else if typ.is_compatible_with(self.float_type) { + TypeKind::Float + } else if typ.is_compatible_with(self.double_type) { + TypeKind::Double + } else if typ.is_vector() { + TypeKind::Vector + } else if typ.get_pointee().is_some() { + TypeKind::Pointer + } else if typ.dyncast_array().is_some() { + TypeKind::Array + } else if typ.is_struct().is_some() { + TypeKind::Struct + } else if typ.dyncast_function_ptr_type().is_some() { + TypeKind::Function + } else if typ == self.type_void() { + TypeKind::Void + } else { + // TODO(antoyo): support other types. + unimplemented!(); + } + } + + fn type_ptr(&self) -> Type<'gcc> { + self.type_ptr_to(self.type_void()) + } + + fn type_ptr_ext(&self, address_space: AddressSpace) -> Type<'gcc> { + self.type_ptr_to_ext(self.type_void(), address_space) + } + + fn element_type(&self, ty: Type<'gcc>) -> Type<'gcc> { + if let Some(typ) = ty.dyncast_array() { + typ + } else if let Some(vector_type) = ty.dyncast_vector() { + vector_type.get_element_type() + } else if let Some(typ) = ty.get_pointee() { + typ + } else { + unreachable!() + } + } + + fn vector_length(&self, _ty: Type<'gcc>) -> usize { + unimplemented!(); + } + + #[cfg(feature = "master")] + fn float_width(&self, typ: Type<'gcc>) -> usize { + if typ.is_floating_point() { + (typ.get_size() * u8::BITS).try_into().unwrap() + } else { + panic!("Cannot get width of float type {:?}", typ); + } + } + + #[cfg(not(feature = "master"))] + fn float_width(&self, typ: Type<'gcc>) -> usize { + let f32 = self.context.new_type::<f32>(); + let f64 = self.context.new_type::<f64>(); + if typ.is_compatible_with(f32) { + 32 + } else if typ.is_compatible_with(f64) { + 64 + } else { + panic!("Cannot get width of float type {:?}", typ); + } + // TODO(antoyo): support other sizes. + } + + fn int_width(&self, typ: Type<'gcc>) -> u64 { + self.gcc_int_width(typ) + } + + fn val_ty(&self, value: RValue<'gcc>) -> Type<'gcc> { + value.get_type() + } + + #[cfg_attr(feature = "master", allow(unused_mut))] + fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> { + #[cfg(not(feature = "master"))] + if let Some(struct_type) = ty.is_struct() + && struct_type.get_field_count() == 0 + { + // NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a + // size of usize::MAX in test_binary_search, we workaround this by setting the size to + // zero for ZSTs. + len = 0; + } + + self.context.new_array_type(None, ty, len) + } +} + +impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { + pub fn type_padding_filler(&self, size: Size, align: Align) -> Type<'gcc> { + let unit = Integer::approximate_align(self, align); + let size = size.bytes(); + let unit_size = unit.size().bytes(); + assert_eq!(size % unit_size, 0); + self.type_array(self.type_from_integer(unit), size / unit_size) + } + + pub fn set_struct_body(&self, typ: Struct<'gcc>, fields: &[Type<'gcc>], packed: bool) { + let fields: Vec<_> = fields + .iter() + .enumerate() + .map(|(index, field)| self.context.new_field(None, *field, format!("field_{}", index))) + .collect(); + typ.set_fields(None, &fields); + if packed { + #[cfg(feature = "master")] + typ.as_type().set_packed(); + } + } + + pub fn type_named_struct(&self, name: &str) -> Struct<'gcc> { + self.context.new_opaque_struct_type(None, name) + } +} + +pub fn struct_fields<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + layout: TyAndLayout<'tcx>, +) -> (Vec<Type<'gcc>>, bool) { + let field_count = layout.fields.count(); + + let mut packed = false; + let mut offset = Size::ZERO; + let mut prev_effective_align = layout.align.abi; + let mut result: Vec<_> = Vec::with_capacity(1 + field_count * 2); + for i in layout.fields.index_by_increasing_offset() { + let target_offset = layout.fields.offset(i); + let field = layout.field(cx, i); + let effective_field_align = + layout.align.abi.min(field.align.abi).restrict_for_offset(target_offset); + packed |= effective_field_align < field.align.abi; + + assert!(target_offset >= offset); + let padding = target_offset - offset; + let padding_align = prev_effective_align.min(effective_field_align); + assert_eq!(offset.align_to(padding_align) + padding, target_offset); + result.push(cx.type_padding_filler(padding, padding_align)); + + result.push(field.gcc_type(cx)); + offset = target_offset + field.size; + prev_effective_align = effective_field_align; + } + if layout.is_sized() && field_count > 0 { + if offset > layout.size { + bug!("layout: {:#?} stride: {:?} offset: {:?}", layout, layout.size, offset); + } + let padding = layout.size - offset; + let padding_align = prev_effective_align; + assert_eq!(offset.align_to(padding_align) + padding, layout.size); + result.push(cx.type_padding_filler(padding, padding_align)); + assert_eq!(result.len(), 1 + field_count * 2); + } + + (result, packed) +} + +impl<'gcc, 'tcx> TypeMembershipCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {} diff --git a/compiler/rustc_codegen_gcc/src/type_of.rs b/compiler/rustc_codegen_gcc/src/type_of.rs new file mode 100644 index 00000000000..093f902bc3d --- /dev/null +++ b/compiler/rustc_codegen_gcc/src/type_of.rs @@ -0,0 +1,381 @@ +use std::fmt::Write; + +use gccjit::{Struct, Type}; +use rustc_abi as abi; +use rustc_abi::Primitive::*; +use rustc_abi::{ + BackendRepr, FieldsShape, Integer, PointeeInfo, Reg, Size, TyAbiInterface, Variants, +}; +use rustc_codegen_ssa::traits::{ + BaseTypeCodegenMethods, DerivedTypeCodegenMethods, LayoutTypeCodegenMethods, +}; +use rustc_middle::bug; +use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; +use rustc_middle::ty::print::with_no_trimmed_paths; +use rustc_middle::ty::{self, CoroutineArgsExt, Ty, TypeVisitableExt}; +use rustc_target::callconv::{CastTarget, FnAbi}; + +use crate::abi::{FnAbiGcc, FnAbiGccExt, GccType}; +use crate::context::CodegenCx; +use crate::type_::struct_fields; + +impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { + fn type_from_unsigned_integer(&self, i: Integer) -> Type<'gcc> { + use Integer::*; + match i { + I8 => self.type_u8(), + I16 => self.type_u16(), + I32 => self.type_u32(), + I64 => self.type_u64(), + I128 => self.type_u128(), + } + } + + #[cfg(feature = "master")] + pub fn type_int_from_ty(&self, t: ty::IntTy) -> Type<'gcc> { + match t { + ty::IntTy::Isize => self.type_isize(), + ty::IntTy::I8 => self.type_i8(), + ty::IntTy::I16 => self.type_i16(), + ty::IntTy::I32 => self.type_i32(), + ty::IntTy::I64 => self.type_i64(), + ty::IntTy::I128 => self.type_i128(), + } + } + + #[cfg(feature = "master")] + pub fn type_uint_from_ty(&self, t: ty::UintTy) -> Type<'gcc> { + match t { + ty::UintTy::Usize => self.type_isize(), + ty::UintTy::U8 => self.type_i8(), + ty::UintTy::U16 => self.type_i16(), + ty::UintTy::U32 => self.type_i32(), + ty::UintTy::U64 => self.type_i64(), + ty::UintTy::U128 => self.type_i128(), + } + } +} + +fn uncached_gcc_type<'gcc, 'tcx>( + cx: &CodegenCx<'gcc, 'tcx>, + layout: TyAndLayout<'tcx>, + defer: &mut Option<(Struct<'gcc>, TyAndLayout<'tcx>)>, +) -> Type<'gcc> { + match layout.backend_repr { + BackendRepr::Scalar(_) => bug!("handled elsewhere"), + BackendRepr::SimdVector { ref element, count } => { + let element = layout.scalar_gcc_type_at(cx, element, Size::ZERO); + let element = + // NOTE: gcc doesn't allow pointer types in vectors. + if element.get_pointee().is_some() { + cx.usize_type + } + else { + element + }; + return cx.context.new_vector_type(element, count); + } + BackendRepr::ScalarPair(..) => { + return cx.type_struct( + &[ + layout.scalar_pair_element_gcc_type(cx, 0), + layout.scalar_pair_element_gcc_type(cx, 1), + ], + false, + ); + } + BackendRepr::Memory { .. } => {} + } + + let name = match *layout.ty.kind() { + // FIXME(eddyb) producing readable type names for trait objects can result + // in problematically distinct types due to HRTB and subtyping (see #47638). + // ty::Dynamic(..) | + ty::Adt(..) + | ty::Closure(..) + | ty::CoroutineClosure(..) + | ty::Foreign(..) + | ty::Coroutine(..) + | ty::Str + if !cx.sess().fewer_names() => + { + let mut name = with_no_trimmed_paths!(layout.ty.to_string()); + if let (&ty::Adt(def, _), &Variants::Single { index }) = + (layout.ty.kind(), &layout.variants) + && def.is_enum() + && !def.variants().is_empty() + { + write!(&mut name, "::{}", def.variant(index).name).unwrap(); + } + if let (&ty::Coroutine(_, _), &Variants::Single { index }) = + (layout.ty.kind(), &layout.variants) + { + write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap(); + } + Some(name) + } + ty::Adt(..) => { + // If `Some` is returned then a named struct is created in LLVM. Name collisions are + // avoided by LLVM (with increasing suffixes). If rustc doesn't generate names then that + // can improve perf. + // FIXME(antoyo): I don't think that's true for libgccjit. + Some(String::new()) + } + _ => None, + }; + + match layout.fields { + FieldsShape::Primitive | FieldsShape::Union(_) => { + let fill = cx.type_padding_filler(layout.size, layout.align.abi); + let packed = false; + match name { + None => cx.type_struct(&[fill], packed), + Some(ref name) => { + let gcc_type = cx.type_named_struct(name); + cx.set_struct_body(gcc_type, &[fill], packed); + gcc_type.as_type() + } + } + } + FieldsShape::Array { count, .. } => cx.type_array(layout.field(cx, 0).gcc_type(cx), count), + FieldsShape::Arbitrary { .. } => match name { + None => { + let (gcc_fields, packed) = struct_fields(cx, layout); + cx.type_struct(&gcc_fields, packed) + } + Some(ref name) => { + let gcc_type = cx.type_named_struct(name); + *defer = Some((gcc_type, layout)); + gcc_type.as_type() + } + }, + } +} + +pub trait LayoutGccExt<'tcx> { + fn is_gcc_immediate(&self) -> bool; + fn is_gcc_scalar_pair(&self) -> bool; + fn gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>; + fn immediate_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>; + fn scalar_gcc_type_at<'gcc>( + &self, + cx: &CodegenCx<'gcc, 'tcx>, + scalar: &abi::Scalar, + offset: Size, + ) -> Type<'gcc>; + fn scalar_pair_element_gcc_type<'gcc>( + &self, + cx: &CodegenCx<'gcc, 'tcx>, + index: usize, + ) -> Type<'gcc>; + fn pointee_info_at<'gcc>( + &self, + cx: &CodegenCx<'gcc, 'tcx>, + offset: Size, + ) -> Option<PointeeInfo>; +} + +impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { + fn is_gcc_immediate(&self) -> bool { + match self.backend_repr { + BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => true, + BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false, + } + } + + fn is_gcc_scalar_pair(&self) -> bool { + match self.backend_repr { + BackendRepr::ScalarPair(..) => true, + BackendRepr::Scalar(_) + | BackendRepr::SimdVector { .. } + | BackendRepr::Memory { .. } => false, + } + } + + /// Gets the GCC type corresponding to a Rust type, i.e., `rustc_middle::ty::Ty`. + /// The pointee type of the pointer in `PlaceRef` is always this type. + /// For sized types, it is also the right LLVM type for an `alloca` + /// containing a value of that type, and most immediates (except `bool`). + /// Unsized types, however, are represented by a "minimal unit", e.g. + /// `[T]` becomes `T`, while `str` and `Trait` turn into `i8` - this + /// is useful for indexing slices, as `&[T]`'s data pointer is `T*`. + /// If the type is an unsized struct, the regular layout is generated, + /// with the innermost trailing unsized field using the "minimal unit" + /// of that field's type - this is useful for taking the address of + /// that field and ensuring the struct has the right alignment. + fn gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> { + use rustc_middle::ty::layout::FnAbiOf; + // This must produce the same result for `repr(transparent)` wrappers as for the inner type! + // In other words, this should generally not look at the type at all, but only at the + // layout. + if let BackendRepr::Scalar(ref scalar) = self.backend_repr { + // Use a different cache for scalars because pointers to DSTs + // can be either wide or thin (data pointers of wide pointers). + if let Some(&ty) = cx.scalar_types.borrow().get(&self.ty) { + return ty; + } + let ty = match *self.ty.kind() { + // NOTE: we cannot remove this match like in the LLVM codegen because the call + // to fn_ptr_backend_type handle the on-stack attribute. + // TODO(antoyo): find a less hackish way to handle the on-stack attribute. + ty::FnPtr(sig_tys, hdr) => cx + .fn_ptr_backend_type(cx.fn_abi_of_fn_ptr(sig_tys.with(hdr), ty::List::empty())), + _ => self.scalar_gcc_type_at(cx, scalar, Size::ZERO), + }; + cx.scalar_types.borrow_mut().insert(self.ty, ty); + return ty; + } + + // Check the cache. + let variant_index = match self.variants { + Variants::Single { index } => Some(index), + _ => None, + }; + let cached_type = cx.types.borrow().get(&(self.ty, variant_index)).cloned(); + if let Some(ty) = cached_type { + return ty; + } + + assert!(!self.ty.has_escaping_bound_vars(), "{:?} has escaping bound vars", self.ty); + + // Make sure lifetimes are erased, to avoid generating distinct LLVM + // types for Rust types that only differ in the choice of lifetimes. + let normal_ty = cx.tcx.erase_regions(self.ty); + + let mut defer = None; + let ty = if self.ty != normal_ty { + let mut layout = cx.layout_of(normal_ty); + if let Some(v) = variant_index { + layout = layout.for_variant(cx, v); + } + layout.gcc_type(cx) + } else { + uncached_gcc_type(cx, *self, &mut defer) + }; + + cx.types.borrow_mut().insert((self.ty, variant_index), ty); + + if let Some((deferred_ty, layout)) = defer { + let (fields, packed) = struct_fields(cx, layout); + cx.set_struct_body(deferred_ty, &fields, packed); + } + + ty + } + + fn immediate_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> { + if let BackendRepr::Scalar(ref scalar) = self.backend_repr + && scalar.is_bool() + { + return cx.type_i1(); + } + self.gcc_type(cx) + } + + fn scalar_gcc_type_at<'gcc>( + &self, + cx: &CodegenCx<'gcc, 'tcx>, + scalar: &abi::Scalar, + offset: Size, + ) -> Type<'gcc> { + match scalar.primitive() { + Int(i, true) => cx.type_from_integer(i), + Int(i, false) => cx.type_from_unsigned_integer(i), + Float(f) => cx.type_from_float(f), + Pointer(address_space) => { + // If we know the alignment, pick something better than i8. + let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) { + cx.type_pointee_for_align(pointee.align) + } else { + cx.type_i8() + }; + cx.type_ptr_to_ext(pointee, address_space) + } + } + } + + fn scalar_pair_element_gcc_type<'gcc>( + &self, + cx: &CodegenCx<'gcc, 'tcx>, + index: usize, + ) -> Type<'gcc> { + // This must produce the same result for `repr(transparent)` wrappers as for the inner type! + // In other words, this should generally not look at the type at all, but only at the + // layout. + let (a, b) = match self.backend_repr { + BackendRepr::ScalarPair(ref a, ref b) => (a, b), + _ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self), + }; + let scalar = [a, b][index]; + + // Make sure to return the same type `immediate_gcc_type` would when + // dealing with an immediate pair. This means that `(bool, bool)` is + // effectively represented as `{i8, i8}` in memory and two `i1`s as an + // immediate, just like `bool` is typically `i8` in memory and only `i1` + // when immediate. We need to load/store `bool` as `i8` to avoid + // crippling LLVM optimizations or triggering other LLVM bugs with `i1`. + // TODO(antoyo): this bugs certainly don't happen in this case since the bool type is used instead of i1. + if scalar.is_bool() { + return cx.type_i1(); + } + + let offset = if index == 0 { Size::ZERO } else { a.size(cx).align_to(b.align(cx).abi) }; + self.scalar_gcc_type_at(cx, scalar, offset) + } + + fn pointee_info_at<'a>(&self, cx: &CodegenCx<'a, 'tcx>, offset: Size) -> Option<PointeeInfo> { + if let Some(&pointee) = cx.pointee_infos.borrow().get(&(self.ty, offset)) { + return pointee; + } + + let result = Ty::ty_and_layout_pointee_info_at(*self, cx, offset); + + cx.pointee_infos.borrow_mut().insert((self.ty, offset), result); + result + } +} + +impl<'gcc, 'tcx> LayoutTypeCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> { + fn backend_type(&self, layout: TyAndLayout<'tcx>) -> Type<'gcc> { + layout.gcc_type(self) + } + + fn immediate_backend_type(&self, layout: TyAndLayout<'tcx>) -> Type<'gcc> { + layout.immediate_gcc_type(self) + } + + fn is_backend_immediate(&self, layout: TyAndLayout<'tcx>) -> bool { + layout.is_gcc_immediate() + } + + fn is_backend_scalar_pair(&self, layout: TyAndLayout<'tcx>) -> bool { + layout.is_gcc_scalar_pair() + } + + fn scalar_pair_element_backend_type( + &self, + layout: TyAndLayout<'tcx>, + index: usize, + _immediate: bool, + ) -> Type<'gcc> { + layout.scalar_pair_element_gcc_type(self, index) + } + + fn cast_backend_type(&self, ty: &CastTarget) -> Type<'gcc> { + ty.gcc_type(self) + } + + fn fn_ptr_backend_type(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> Type<'gcc> { + fn_abi.ptr_to_gcc_type(self) + } + + fn reg_backend_type(&self, _ty: &Reg) -> Type<'gcc> { + unimplemented!(); + } + + fn fn_decl_backend_type(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> Type<'gcc> { + // FIXME(antoyo): Should we do something with `FnAbiGcc::fn_attributes`? + let FnAbiGcc { return_type, arguments_type, is_c_variadic, .. } = fn_abi.gcc_type(self); + self.context.new_function_pointer_type(None, return_type, &arguments_type, is_c_variadic) + } +} diff --git a/compiler/rustc_codegen_gcc/target_specs/m68k-unknown-linux-gnu.json b/compiler/rustc_codegen_gcc/target_specs/m68k-unknown-linux-gnu.json new file mode 100644 index 00000000000..95ea06106fb --- /dev/null +++ b/compiler/rustc_codegen_gcc/target_specs/m68k-unknown-linux-gnu.json @@ -0,0 +1,26 @@ +{ + "arch": "m68k", + "cpu": "M68020", + "crt-static-respected": true, + "data-layout": "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16", + "dynamic-linking": true, + "env": "gnu", + "has-rpath": true, + "has-thread-local": true, + "llvm-target": "m68k-unknown-linux-gnu", + "max-atomic-width": 32, + "os": "linux", + "position-independent-executables": true, + "relro-level": "full", + "supported-split-debuginfo": [ + "packed", + "unpacked", + "off" + ], + "target-endian": "big", + "target-family": [ + "unix" + ], + "target-mcount": "_mcount", + "target-pointer-width": "32" +} diff --git a/compiler/rustc_codegen_gcc/tests/failing-ice-tests.txt b/compiler/rustc_codegen_gcc/tests/failing-ice-tests.txt new file mode 100644 index 00000000000..ff1b6f14894 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/failing-ice-tests.txt @@ -0,0 +1,40 @@ +tests/ui/treat-err-as-bug/span_delayed_bug.rs +tests/ui/treat-err-as-bug/err.rs +tests/ui/simd/not-out-of-bounds.rs +tests/ui/simd/monomorphize-shuffle-index.rs +tests/ui/simd/masked-load-store-build-fail.rs +tests/ui/simd/intrinsic/generic-shuffle.rs +tests/ui/simd/intrinsic/generic-elements.rs +tests/ui/simd/intrinsic/generic-cast.rs +tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs +tests/ui/simd/intrinsic/generic-arithmetic-2.rs +tests/ui/panics/default-backtrace-ice.rs +tests/ui/mir/lint/storage-live.rs +tests/ui/layout/valid_range_oob.rs +tests/ui/higher-ranked/trait-bounds/future.rs +tests/ui/consts/const-eval/const-eval-query-stack.rs +tests/ui/simd/masked-load-store.rs +tests/ui/simd/issue-39720.rs +tests/ui/simd/intrinsic/ptr-cast.rs +tests/ui/sepcomp/sepcomp-statics.rs +tests/ui/sepcomp/sepcomp-fns.rs +tests/ui/sepcomp/sepcomp-fns-backwards.rs +tests/ui/sepcomp/sepcomp-extern.rs +tests/ui/sepcomp/sepcomp-cci.rs +tests/ui/lto/thin-lto-inlines2.rs +tests/ui/lto/weak-works.rs +tests/ui/lto/thin-lto-inlines.rs +tests/ui/lto/thin-lto-global-allocator.rs +tests/ui/lto/msvc-imp-present.rs +tests/ui/lto/dylib-works.rs +tests/ui/lto/all-crates.rs +tests/ui/issues/issue-47364.rs +tests/ui/functions-closures/parallel-codegen-closures.rs +tests/ui/sepcomp/sepcomp-unwind.rs +tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs +tests/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs +tests/ui/unwind-no-uwtable.rs +tests/ui/delegation/fn-header.rs +tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +tests/ui/simd/masked-load-store.rs +tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs diff --git a/compiler/rustc_codegen_gcc/tests/failing-lto-tests.txt b/compiler/rustc_codegen_gcc/tests/failing-lto-tests.txt new file mode 100644 index 00000000000..bf0633f7320 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/failing-lto-tests.txt @@ -0,0 +1,33 @@ +tests/ui/lint/unsafe_code/forge_unsafe_block.rs +tests/ui/lint/unused-qualification-in-derive-expansion.rs +tests/ui/macros/macro-quote-test.rs +tests/ui/macros/proc_macro.rs +tests/ui/panic-runtime/lto-unwind.rs +tests/ui/resolve/derive-macro-1.rs +tests/ui/resolve/derive-macro-2.rs +tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs +tests/ui/rfcs/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs +tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs +tests/ui/rust-2018/suggestions-not-always-applicable.rs +tests/ui/rust-2021/reserved-prefixes-via-macro.rs +tests/ui/underscore-imports/duplicate.rs +tests/ui/async-await/issues/issue-60674.rs +tests/ui/attributes/main-removed-2/main.rs +tests/ui/cfg/assume-incomplete-release/assume-incomplete.rs +tests/ui/crate-loading/cross-compiled-proc-macro.rs +tests/ui/derives/derive-marker-tricky.rs +tests/ui/diagnostic_namespace/existing_proc_macros.rs +tests/ui/fmt/format-args-capture-issue-106408.rs +tests/ui/fmt/indoc-issue-106408.rs +tests/ui/hygiene/issue-77523-def-site-async-await.rs +tests/ui/inherent-impls-overlap-check/no-overlap.rs +tests/ui/enum-discriminant/issue-46519.rs +tests/ui/issues/issue-45731.rs +tests/ui/lint/test-allow-dead-extern-static-no-warning.rs +tests/ui/macros/macro-comma-behavior-rpass.rs +tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs +tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs +tests/ui/macros/stringify.rs +tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs +tests/ui/binding/fn-arg-incomplete-pattern-drop-order.rs +tests/ui/lto/debuginfo-lto-alloc.rs diff --git a/compiler/rustc_codegen_gcc/tests/failing-run-make-tests.txt b/compiler/rustc_codegen_gcc/tests/failing-run-make-tests.txt new file mode 100644 index 00000000000..29032b321fa --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/failing-run-make-tests.txt @@ -0,0 +1,41 @@ +tests/run-make/a-b-a-linker-guard/ +tests/run-make/CURRENT_RUSTC_VERSION/ +tests/run-make/cross-lang-lto/ +tests/run-make/cross-lang-lto-upstream-rlibs/ +tests/run-make/doctests-keep-binaries/ +tests/run-make/doctests-runtool/ +tests/run-make/emit-shared-files/ +tests/run-make/exit-code/ +tests/run-make/issue-64153/ +tests/run-make/llvm-ident/ +tests/run-make/native-link-modifier-bundle/ +tests/run-make/remap-path-prefix-dwarf/ +tests/run-make/repr128-dwarf/ +tests/run-make/rlib-format-packed-bundled-libs/ +tests/run-make/rlib-format-packed-bundled-libs-2/ +tests/run-make/rustdoc-determinism/ +tests/run-make/rustdoc-error-lines/ +tests/run-make/rustdoc-map-file/ +tests/run-make/rustdoc-output-path/ +tests/run-make/rustdoc-scrape-examples-invalid-expr/ +tests/run-make/rustdoc-scrape-examples-multiple/ +tests/run-make/rustdoc-scrape-examples-ordering/ +tests/run-make/rustdoc-scrape-examples-remap/ +tests/run-make/rustdoc-scrape-examples-test/ +tests/run-make/rustdoc-scrape-examples-whitespace/ +tests/run-make/rustdoc-scrape-examples-macros/ +tests/run-make/rustdoc-with-out-dir-option/ +tests/run-make/rustdoc-verify-output-files/ +tests/run-make/rustdoc-themes/ +tests/run-make/rustdoc-with-short-out-dir-option/ +tests/run-make/rustdoc-with-output-option/ +tests/run-make/arguments-non-c-like-enum/ +tests/run-make/c-link-to-rust-staticlib/ +tests/run-make/foreign-double-unwind/ +tests/run-make/foreign-exceptions/ +tests/run-make/glibc-staticlib-args/ +tests/run-make/issue-36710/ +tests/run-make/issue-68794-textrel-on-minimal-lib/ +tests/run-make/lto-smoke-c/ +tests/run-make/return-non-c-like-enum/ + diff --git a/compiler/rustc_codegen_gcc/tests/failing-ui-tests.txt b/compiler/rustc_codegen_gcc/tests/failing-ui-tests.txt new file mode 100644 index 00000000000..41fb4729c07 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/failing-ui-tests.txt @@ -0,0 +1,88 @@ +tests/ui/allocator/no_std-alloc-error-handler-custom.rs +tests/ui/allocator/no_std-alloc-error-handler-default.rs +tests/ui/asm/may_unwind.rs +tests/ui/asm/x86_64/may_unwind.rs +tests/ui/drop/dynamic-drop-async.rs +tests/ui/cfg/cfg-panic-abort.rs +tests/ui/intrinsics/panic-uninitialized-zeroed.rs +tests/ui/iterators/iter-sum-overflow-debug.rs +tests/ui/iterators/iter-sum-overflow-overflow-checks.rs +tests/ui/mir/mir_drop_order.rs +tests/ui/mir/mir_let_chains_drop_order.rs +tests/ui/mir/mir_match_guard_let_chains_drop_order.rs +tests/ui/panics/oom-panic-unwind.rs +tests/ui/panic-runtime/abort-link-to-unwinding-crates.rs +tests/ui/panic-runtime/abort.rs +tests/ui/panic-runtime/link-to-abort.rs +tests/ui/parser/unclosed-delimiter-in-dep.rs +tests/ui/consts/missing_span_in_backtrace.rs +tests/ui/drop/dynamic-drop.rs +tests/ui/rfcs/rfc-2091-track-caller/std-panic-locations.rs +tests/ui/simd/issue-17170.rs +tests/ui/simd/issue-39720.rs +tests/ui/issues/issue-14875.rs +tests/ui/issues/issue-29948.rs +tests/ui/process/println-with-broken-pipe.rs +tests/ui/lto/thin-lto-inlines2.rs +tests/ui/panic-runtime/lto-abort.rs +tests/ui/lto/lto-thin-rustc-loads-linker-plugin.rs +tests/ui/async-await/deep-futures-are-freeze.rs +tests/ui/coroutine/resume-after-return.rs +tests/ui/simd/masked-load-store.rs +tests/ui/simd/repr_packed.rs +tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs +tests/ui/consts/try-operator.rs +tests/ui/coroutine/unwind-abort-mix.rs +tests/ui/consts/issue-miri-1910.rs +tests/ui/consts/const_cmp_type_id.rs +tests/ui/consts/issue-73976-monomorphic.rs +tests/ui/consts/issue-94675.rs +tests/ui/traits/const-traits/const-drop-fail.rs +tests/ui/runtime/on-broken-pipe/child-processes.rs +tests/ui/sanitizer/cfi/assoc-ty-lifetime-issue-123053.rs +tests/ui/sanitizer/cfi/async-closures.rs +tests/ui/sanitizer/cfi/closures.rs +tests/ui/sanitizer/cfi/complex-receiver.rs +tests/ui/sanitizer/cfi/coroutine.rs +tests/ui/sanitizer/cfi/drop-in-place.rs +tests/ui/sanitizer/cfi/drop-no-principal.rs +tests/ui/sanitizer/cfi/fn-ptr.rs +tests/ui/sanitizer/cfi/self-ref.rs +tests/ui/sanitizer/cfi/supertraits.rs +tests/ui/sanitizer/cfi/virtual-auto.rs +tests/ui/sanitizer/cfi/sized-associated-ty.rs +tests/ui/sanitizer/cfi/can-reveal-opaques.rs +tests/ui/sanitizer/kcfi-mangling.rs +tests/ui/statics/const_generics.rs +tests/ui/backtrace/dylib-dep.rs +tests/ui/delegation/fn-header.rs +tests/ui/consts/const-eval/parse_ints.rs +tests/ui/simd/intrinsic/generic-as.rs +tests/ui/runtime/rt-explody-panic-payloads.rs +tests/ui/codegen/equal-pointers-unequal/as-cast/inline1.rs +tests/ui/codegen/equal-pointers-unequal/as-cast/inline2.rs +tests/ui/codegen/equal-pointers-unequal/as-cast/segfault.rs +tests/ui/codegen/equal-pointers-unequal/as-cast/zero.rs +tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline1.rs +tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline2.rs +tests/ui/codegen/equal-pointers-unequal/exposed-provenance/segfault.rs +tests/ui/codegen/equal-pointers-unequal/exposed-provenance/zero.rs +tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline1.rs +tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline2.rs +tests/ui/codegen/equal-pointers-unequal/strict-provenance/segfault.rs +tests/ui/codegen/equal-pointers-unequal/strict-provenance/zero.rs +tests/ui/simd/simd-bitmask-notpow2.rs +tests/ui/codegen/StackColoring-not-blowup-stack-issue-40883.rs +tests/ui/numbers-arithmetic/u128-as-f32.rs +tests/ui/lto/all-crates.rs +tests/ui/uninhabited/uninhabited-transparent-return-abi.rs +tests/ui/coroutine/panic-drops-resume.rs +tests/ui/coroutine/panic-drops.rs +tests/ui/coroutine/panic-safe.rs +tests/ui/process/nofile-limit.rs +tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +tests/ui/linking/no-gc-encapsulation-symbols.rs +tests/ui/panics/unwind-force-no-unwind-tables.rs +tests/ui/attributes/fn-align-dyn.rs +tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs +tests/ui/explicit-tail-calls/recursion-etc.rs diff --git a/compiler/rustc_codegen_gcc/tests/failing-ui-tests12.txt b/compiler/rustc_codegen_gcc/tests/failing-ui-tests12.txt new file mode 100644 index 00000000000..b10d4bc82aa --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/failing-ui-tests12.txt @@ -0,0 +1,47 @@ +tests/ui/asm/x86_64/issue-96797.rs +tests/ui/intrinsics/const-eval-select-x86_64.rs +tests/ui/packed/packed-struct-drop-aligned.rs +tests/ui/packed/packed-struct-generic-layout.rs +tests/ui/packed/packed-struct-layout.rs +tests/ui/packed/packed-struct-optimized-enum.rs +tests/ui/packed/packed-struct-size.rs +tests/ui/packed/packed-struct-vec.rs +tests/ui/packed/packed-tuple-struct-layout.rs +tests/ui/simd/array-type.rs +tests/ui/simd/intrinsic/float-minmax-pass.rs +tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs +tests/ui/simd/intrinsic/generic-cast-pass.rs +tests/ui/simd/intrinsic/generic-cast-pointer-width.rs +tests/ui/simd/intrinsic/generic-comparison-pass.rs +tests/ui/simd/intrinsic/generic-elements-pass.rs +tests/ui/simd/intrinsic/generic-reduction-pass.rs +tests/ui/simd/intrinsic/generic-select-pass.rs +tests/ui/simd/intrinsic/inlining-issue67557-ice.rs +tests/ui/simd/intrinsic/inlining-issue67557.rs +tests/ui/simd/shuffle.rs +tests/ui/simd/simd-bitmask.rs +tests/ui/iterators/iter-step-overflow-debug.rs +tests/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs +tests/ui/privacy/reachable-unnameable-items.rs +tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs +tests/ui/async-await/async-fn-size-moved-locals.rs +tests/ui/async-await/async-fn-size-uninit-locals.rs +tests/ui/cfg/cfg-panic.rs +tests/ui/coroutine/size-moved-locals.rs +tests/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs +tests/ui/simd/intrinsic/generic-gather-pass.rs +tests/ui/simd/issue-85915-simd-ptrs.rs +tests/ui/simd/issue-89193.rs +tests/ui/issues/issue-68010-large-zst-consts.rs +tests/ui/rust-2018/proc-macro-crate-in-paths.rs +tests/ui/target-feature/missing-plusminus.rs +tests/ui/sse2.rs +tests/ui/codegen/issue-79865-llvm-miscompile.rs +tests/ui/std-backtrace.rs +tests/ui/mir/alignment/packed.rs +tests/ui/intrinsics/intrinsics-integer.rs +tests/ui/asm/x86_64/evex512-implicit-feature.rs +tests/ui/packed/dyn-trait.rs +tests/ui/packed/issue-118537-field-offset-ice.rs +tests/ui/stable-mir-print/basic_function.rs diff --git a/compiler/rustc_codegen_gcc/tests/hello-world/Cargo.lock b/compiler/rustc_codegen_gcc/tests/hello-world/Cargo.lock new file mode 100644 index 00000000000..fe252db4425 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/hello-world/Cargo.lock @@ -0,0 +1,14 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "hello_world" +version = "0.0.0" +dependencies = [ + "mylib", +] + +[[package]] +name = "mylib" +version = "0.1.0" diff --git a/compiler/rustc_codegen_gcc/tests/hello-world/Cargo.toml b/compiler/rustc_codegen_gcc/tests/hello-world/Cargo.toml new file mode 100644 index 00000000000..c6e22f642f6 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/hello-world/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "hello_world" +edition = "2024" + +[dependencies] +mylib = { path = "mylib" } + +[profile.dev] +lto = "thin" + +[profile.release] +lto = "fat" diff --git a/compiler/rustc_codegen_gcc/tests/hello-world/mylib/Cargo.lock b/compiler/rustc_codegen_gcc/tests/hello-world/mylib/Cargo.lock new file mode 100644 index 00000000000..c8a0bfc6354 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/hello-world/mylib/Cargo.lock @@ -0,0 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "mylib" +version = "0.1.0" diff --git a/compiler/rustc_codegen_gcc/tests/hello-world/mylib/Cargo.toml b/compiler/rustc_codegen_gcc/tests/hello-world/mylib/Cargo.toml new file mode 100644 index 00000000000..d15f62bfb6d --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/hello-world/mylib/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "mylib" +version = "0.1.0" +authors = ["Antoni Boucher <bouanto@zoho.com>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/compiler/rustc_codegen_gcc/tests/hello-world/mylib/src/lib.rs b/compiler/rustc_codegen_gcc/tests/hello-world/mylib/src/lib.rs new file mode 100644 index 00000000000..8d3d111bd19 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/hello-world/mylib/src/lib.rs @@ -0,0 +1,7 @@ +pub fn my_func(a: i32, b: i32) -> i32 { + let mut res = a; + for i in a..b { + res += i; + } + res +} diff --git a/compiler/rustc_codegen_gcc/tests/hello-world/src/main.rs b/compiler/rustc_codegen_gcc/tests/hello-world/src/main.rs new file mode 100644 index 00000000000..71c78d364ac --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/hello-world/src/main.rs @@ -0,0 +1,5 @@ +use mylib::my_func; + +fn main() { + println!("{}", my_func(5, 10)); +} diff --git a/compiler/rustc_codegen_gcc/tests/lang_tests_common.rs b/compiler/rustc_codegen_gcc/tests/lang_tests_common.rs new file mode 100644 index 00000000000..9abe97b1087 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/lang_tests_common.rs @@ -0,0 +1,149 @@ +//! The common code for `tests/lang_tests_*.rs` + +#![allow(clippy::uninlined_format_args)] + +use std::env::{self, current_dir}; +use std::path::{Path, PathBuf}; +use std::process::Command; + +use boml::Toml; +use lang_tester::LangTester; +use tempfile::TempDir; + +/// Controls the compile options (e.g., optimization level) used to compile +/// test code. +#[allow(dead_code)] // Each test crate picks one variant +pub enum Profile { + Debug, + Release, +} + +pub fn main_inner(profile: Profile) { + let tempdir = TempDir::new().expect("temp dir"); + let current_dir = current_dir().expect("current dir"); + let current_dir = current_dir.to_str().expect("current dir").to_string(); + + let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); + + let gcc_path = std::fs::read_to_string(manifest_dir.join("config.toml")) + .ok() + .and_then(|v| { + let toml = Toml::parse(&v).expect("Failed to parse `config.toml`"); + toml.get_string("gcc-path").map(PathBuf::from).ok() + }) + .unwrap_or_else(|| { + // then we try to retrieve it from the `target` folder. + let commit = include_str!("../libgccjit.version").trim(); + Path::new("build/libgccjit").join(commit) + }); + + let gcc_path = Path::new(&gcc_path) + .canonicalize() + .expect("failed to get absolute path of `gcc-path`") + .display() + .to_string(); + unsafe { + env::set_var("LD_LIBRARY_PATH", gcc_path); + } + + fn rust_filter(path: &Path) -> bool { + path.is_file() && path.extension().expect("extension").to_str().expect("to_str") == "rs" + } + + #[cfg(feature = "master")] + fn filter(filename: &Path) -> bool { + rust_filter(filename) + } + + #[cfg(not(feature = "master"))] + fn filter(filename: &Path) -> bool { + if let Some(filename) = filename.to_str() + && filename.ends_with("gep.rs") + { + return false; + } + rust_filter(filename) + } + + LangTester::new() + .test_dir("tests/run") + .test_path_filter(filter) + .test_extract(|path| { + std::fs::read_to_string(path) + .expect("read file") + .lines() + .skip_while(|l| !l.starts_with("//")) + .take_while(|l| l.starts_with("//")) + .map(|l| &l[2..]) + .collect::<Vec<_>>() + .join("\n") + }) + .test_cmds(move |path| { + // Test command 1: Compile `x.rs` into `tempdir/x`. + let mut exe = PathBuf::new(); + exe.push(&tempdir); + exe.push(path.file_stem().expect("file_stem")); + let mut compiler = Command::new("rustc"); + compiler.args([ + &format!("-Zcodegen-backend={}/target/debug/librustc_codegen_gcc.so", current_dir), + "--sysroot", + &format!("{}/build/build_sysroot/sysroot/", current_dir), + "-C", + "link-arg=-lc", + "--extern", + "mini_core=target/out/libmini_core.rlib", + "-o", + exe.to_str().expect("to_str"), + path.to_str().expect("to_str"), + ]); + + // TODO(antoyo): find a way to send this via a cli argument. + let test_target = std::env::var("CG_GCC_TEST_TARGET"); + if let Ok(ref target) = test_target { + compiler.args(["--target", target]); + let linker = format!("{}-gcc", target); + compiler.args(&[format!("-Clinker={}", linker)]); + let mut env_path = std::env::var("PATH").unwrap_or_default(); + // TODO(antoyo): find a better way to add the PATH necessary locally. + env_path = format!("/opt/m68k-unknown-linux-gnu/bin:{}", env_path); + compiler.env("PATH", env_path); + } + + if let Some(flags) = option_env!("TEST_FLAGS") { + for flag in flags.split_whitespace() { + compiler.arg(flag); + } + } + match profile { + Profile::Debug => {} + Profile::Release => { + compiler.args(["-C", "opt-level=3", "-C", "lto=no"]); + } + } + // Test command 2: run `tempdir/x`. + if test_target.is_ok() { + let vm_parent_dir = std::env::var("CG_GCC_VM_DIR") + .map(PathBuf::from) + .unwrap_or_else(|_| std::env::current_dir().unwrap()); + let vm_dir = "vm"; + let exe_filename = exe.file_name().unwrap(); + let vm_home_dir = vm_parent_dir.join(vm_dir).join("home"); + let vm_exe_path = vm_home_dir.join(exe_filename); + // FIXME(antoyo): panicking here makes the test pass. + let inside_vm_exe_path = PathBuf::from("/home").join(exe_filename); + let mut copy = Command::new("sudo"); + copy.arg("cp"); + copy.args([&exe, &vm_exe_path]); + + let mut runtime = Command::new("sudo"); + runtime.args(["chroot", vm_dir, "qemu-m68k-static"]); + runtime.arg(inside_vm_exe_path); + runtime.current_dir(vm_parent_dir); + vec![("Compiler", compiler), ("Copy", copy), ("Run-time", runtime)] + } else { + let runtime = Command::new(exe); + vec![("Compiler", compiler), ("Run-time", runtime)] + } + }) + .run(); +} diff --git a/compiler/rustc_codegen_gcc/tests/lang_tests_debug.rs b/compiler/rustc_codegen_gcc/tests/lang_tests_debug.rs new file mode 100644 index 00000000000..96bd74883ff --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/lang_tests_debug.rs @@ -0,0 +1,5 @@ +mod lang_tests_common; + +fn main() { + lang_tests_common::main_inner(lang_tests_common::Profile::Debug); +} diff --git a/compiler/rustc_codegen_gcc/tests/lang_tests_release.rs b/compiler/rustc_codegen_gcc/tests/lang_tests_release.rs new file mode 100644 index 00000000000..35d5d60c33e --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/lang_tests_release.rs @@ -0,0 +1,5 @@ +mod lang_tests_common; + +fn main() { + lang_tests_common::main_inner(lang_tests_common::Profile::Release); +} diff --git a/compiler/rustc_codegen_gcc/tests/run/abort1.rs b/compiler/rustc_codegen_gcc/tests/run/abort1.rs new file mode 100644 index 00000000000..ff2bb75ece2 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/abort1.rs @@ -0,0 +1,21 @@ +// Compiler: +// +// Run-time: +// status: signal + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +fn test_fail() -> ! { + unsafe { intrinsics::abort() }; +} + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + test_fail(); +} diff --git a/compiler/rustc_codegen_gcc/tests/run/abort2.rs b/compiler/rustc_codegen_gcc/tests/run/abort2.rs new file mode 100644 index 00000000000..781f518e0b2 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/abort2.rs @@ -0,0 +1,23 @@ +// Compiler: +// +// Run-time: +// status: signal + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +fn fail() -> i32 { + unsafe { intrinsics::abort() }; + 0 +} + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + fail(); + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/always_inline.rs b/compiler/rustc_codegen_gcc/tests/run/always_inline.rs new file mode 100644 index 00000000000..ebd741ee090 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/always_inline.rs @@ -0,0 +1,53 @@ +// Compiler: +// +// Run-time: +// status: 0 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +#[inline(always)] +fn fib(n: u8) -> u8 { + if n == 0 { + return 1; + } + if n == 1 { + return 1; + } + fib(n - 1) + fib(n - 2) +} + +#[inline(always)] +fn fib_b(n: u8) -> u8 { + if n == 0 { + return 1; + } + if n == 1 { + return 1; + } + fib_a(n - 1) + fib_a(n - 2) +} + +#[inline(always)] +fn fib_a(n: u8) -> u8 { + if n == 0 { + return 1; + } + if n == 1 { + return 1; + } + fib_b(n - 1) + fib_b(n - 2) +} + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + if fib(2) != fib_a(2) { + intrinsics::abort(); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/array.rs b/compiler/rustc_codegen_gcc/tests/run/array.rs new file mode 100644 index 00000000000..3ab0c309fde --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/array.rs @@ -0,0 +1,36 @@ +// Compiler: +// +// Run-time: +// status: 0 +// stdout: 42 +// 7 +// 5 +// 10 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +static mut ONE: usize = 1; + +fn make_array() -> [u8; 3] { + [42, 10, 5] +} + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + let array = [42, 7, 5]; + let array2 = make_array(); + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, array[ONE - 1]); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, array[ONE]); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, array[ONE + 1]); + + libc::printf(b"%d\n\0" as *const u8 as *const i8, array2[argc as usize] as u32); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/asm.rs b/compiler/rustc_codegen_gcc/tests/run/asm.rs new file mode 100644 index 00000000000..9b15a28d829 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/asm.rs @@ -0,0 +1,238 @@ +// Compiler: +// +// Run-time: +// status: 0 + +#[cfg(target_arch = "x86_64")] +use std::arch::{asm, global_asm}; + +#[cfg(target_arch = "x86_64")] +global_asm!( + " + .global add_asm +add_asm: + mov rax, rdi + add rax, rsi + ret" +); + +#[cfg(target_arch = "x86_64")] +extern "C" { + fn add_asm(a: i64, b: i64) -> i64; +} + +#[cfg(target_arch = "x86_64")] +pub unsafe fn mem_cpy(dst: *mut u8, src: *const u8, len: usize) { + asm!( + "rep movsb", + inout("rdi") dst => _, + inout("rsi") src => _, + inout("rcx") len => _, + options(preserves_flags, nostack) + ); +} + +#[cfg(target_arch = "x86_64")] +fn asm() { + unsafe { + asm!("nop"); + } + + let x: u64; + unsafe { + asm!("mov $5, {}", + out(reg) x, + options(att_syntax) + ); + } + assert_eq!(x, 5); + + let x: u64; + let input: u64 = 42; + unsafe { + asm!("mov {input}, {output}", + "add $1, {output}", + input = in(reg) input, + output = out(reg) x, + options(att_syntax) + ); + } + assert_eq!(x, 43); + + let x: u64; + unsafe { + asm!("mov {}, 6", + out(reg) x, + ); + } + assert_eq!(x, 6); + + let x: u64; + let input: u64 = 42; + unsafe { + asm!("mov {output}, {input}", + "add {output}, 1", + input = in(reg) input, + output = out(reg) x, + ); + } + assert_eq!(x, 43); + + // check inout(reg_class) x + let mut x: u64 = 42; + unsafe { + asm!("add {0}, {0}", + inout(reg) x + ); + } + assert_eq!(x, 84); + + // check inout("reg") x + let mut x: u64 = 42; + unsafe { + asm!("add r11, r11", + inout("r11") x + ); + } + assert_eq!(x, 84); + + // check a mix of + // in("reg") + // inout(class) x => y + // inout (class) x + let x: u64 = 702; + let y: u64 = 100; + let res: u64; + let mut rem: u64 = 0; + unsafe { + asm!("div r11", + in("r11") y, + inout("eax") x => res, + inout("edx") rem, + ); + } + assert_eq!(res, 7); + assert_eq!(rem, 2); + + // check const + let mut x: u64 = 42; + unsafe { + asm!("add {}, {}", + inout(reg) x, + const 1 + ); + } + assert_eq!(x, 43); + + // check const (ATT syntax) + let mut x: u64 = 42; + unsafe { + asm!("add ${}, {}", + const 1, + inout(reg) x, + options(att_syntax) + ); + } + assert_eq!(x, 43); + + // check sym fn + extern "C" fn foo() -> u64 { + 42 + } + let x: u64; + unsafe { + asm!("call {}", sym foo, lateout("rax") x); + } + assert_eq!(x, 42); + + // check sym fn (ATT syntax) + let x: u64; + unsafe { + asm!("call {}", sym foo, lateout("rax") x, options(att_syntax)); + } + assert_eq!(x, 42); + + // check sym static + static FOO: u64 = 42; + let x: u64; + unsafe { + asm!("mov {1}, qword ptr [rip + {0}]", sym FOO, lateout(reg) x); + } + assert_eq!(x, 42); + + // check sym static (ATT syntax) + let x: u64; + unsafe { + asm!("movq {0}(%rip), {1}", sym FOO, lateout(reg) x, options(att_syntax)); + } + assert_eq!(x, 42); + + assert_eq!(unsafe { add_asm(40, 2) }, 42); + + let array1 = [1u8, 2, 3]; + let mut array2 = [0u8, 0, 0]; + unsafe { + mem_cpy(array2.as_mut_ptr(), array1.as_ptr(), 3); + } + assert_eq!(array1, array2); + + // in and clobber registers cannot overlap. This tests that the lateout register without an + // output place (indicated by the `_`) is not added to the list of clobbered registers + let x = 8; + let y: i32; + unsafe { + asm!( + "mov rax, rdi", + in("rdi") x, + lateout("rdi") _, + out("rax") y, + ); + } + assert_eq!((x, y), (8, 8)); + + // sysv64 is the default calling convention on unix systems. The rdi register is + // used to pass arguments in the sysv64 calling convention, so this register will be clobbered + #[cfg(unix)] + { + let x = 16; + let y: i32; + unsafe { + asm!( + "mov rax, rdi", + in("rdi") x, + out("rax") y, + clobber_abi("sysv64"), + ); + } + assert_eq!((x, y), (16, 16)); + } + + // the `b` suffix for registers in the `reg_byte` register class is not supported in GCC + // and needs to be stripped in order to use these registers. + unsafe { + core::arch::asm!( + "", + out("al") _, + out("bl") _, + out("cl") _, + out("dl") _, + out("sil") _, + out("dil") _, + out("r8b") _, + out("r9b") _, + out("r10b") _, + out("r11b") _, + out("r12b") _, + out("r13b") _, + out("r14b") _, + out("r15b") _, + ); + } +} + +#[cfg(not(target_arch = "x86_64"))] +fn asm() {} + +fn main() { + asm(); +} diff --git a/compiler/rustc_codegen_gcc/tests/run/assign.rs b/compiler/rustc_codegen_gcc/tests/run/assign.rs new file mode 100644 index 00000000000..4535ab5778e --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/assign.rs @@ -0,0 +1,42 @@ +// Compiler: +// +// Run-time: +// stdout: 2 +// 7 8 +// 10 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +fn inc_ref(num: &mut isize) -> isize { + *num = *num + 5; + *num + 1 +} + +fn inc(num: isize) -> isize { + num + 1 +} + +#[no_mangle] +extern "C" fn main(mut argc: isize, _argv: *const *const u8) -> i32 { + argc = inc(argc); + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, argc); + } + + let b = inc_ref(&mut argc); + unsafe { + libc::printf(b"%ld %ld\n\0" as *const u8 as *const i8, argc, b); + } + + argc = 10; + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, argc); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/closure.rs b/compiler/rustc_codegen_gcc/tests/run/closure.rs new file mode 100644 index 00000000000..a8a3fadfed4 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/closure.rs @@ -0,0 +1,48 @@ +// Compiler: +// +// Run-time: +// status: 0 +// stdout: Arg: 1 +// Argument: 1 +// String arg: 1 +// Int argument: 2 +// Both args: 11 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +#[no_mangle] +extern "C" fn main(argc: isize, _argv: *const *const u8) -> i32 { + let string = "Arg: %d\n\0"; + let mut closure = || unsafe { + libc::printf(string as *const str as *const i8, argc); + }; + closure(); + + let mut closure = || unsafe { + libc::printf("Argument: %d\n\0" as *const str as *const i8, argc); + }; + closure(); + + let mut closure = |string| unsafe { + libc::printf(string as *const str as *const i8, argc); + }; + closure("String arg: %d\n\0"); + + let mut closure = |arg: isize| unsafe { + libc::printf("Int argument: %d\n\0" as *const str as *const i8, arg); + }; + closure(argc + 1); + + let mut closure = |string, arg: isize| unsafe { + libc::printf(string as *const str as *const i8, arg); + }; + closure("Both args: %d\n\0", argc + 10); + + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/condition.rs b/compiler/rustc_codegen_gcc/tests/run/condition.rs new file mode 100644 index 00000000000..bd3b6f7497f --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/condition.rs @@ -0,0 +1,34 @@ +// Compiler: +// +// Run-time: +// status: 0 +// stdout: true +// 1 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + unsafe { + if argc == 1 { + libc::printf(b"true\n\0" as *const u8 as *const i8); + } + + let string = match argc { + 1 => b"1\n\0", + 2 => b"2\n\0", + 3 => b"3\n\0", + 4 => b"4\n\0", + 5 => b"5\n\0", + _ => b"_\n\0", + }; + libc::printf(string as *const u8 as *const i8); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/empty_main.rs b/compiler/rustc_codegen_gcc/tests/run/empty_main.rs new file mode 100644 index 00000000000..fe3df5a2389 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/empty_main.rs @@ -0,0 +1,17 @@ +// Compiler: +// +// Run-time: +// status: 0 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/exit.rs b/compiler/rustc_codegen_gcc/tests/run/exit.rs new file mode 100644 index 00000000000..e0a59174bd3 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/exit.rs @@ -0,0 +1,20 @@ +// Compiler: +// +// Run-time: +// status: 2 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + unsafe { + libc::exit(2); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/exit_code.rs b/compiler/rustc_codegen_gcc/tests/run/exit_code.rs new file mode 100644 index 00000000000..376824da845 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/exit_code.rs @@ -0,0 +1,17 @@ +// Compiler: +// +// Run-time: +// status: 1 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + 1 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/float.rs b/compiler/rustc_codegen_gcc/tests/run/float.rs new file mode 100644 index 00000000000..df555f383fe --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/float.rs @@ -0,0 +1,26 @@ +// Compiler: +// +// Run-time: +// status: 0 + +fn main() { + use std::hint::black_box; + + macro_rules! check { + ($ty:ty, $expr:expr) => {{ + const EXPECTED: $ty = $expr; + assert_eq!($expr, EXPECTED); + }}; + } + + check!(i32, black_box(0.0f32) as i32); + + check!(u64, black_box(f32::NAN) as u64); + check!(u128, black_box(f32::NAN) as u128); + + check!(i64, black_box(f64::NAN) as i64); + check!(u64, black_box(f64::NAN) as u64); + + check!(i16, black_box(f32::MIN) as i16); + check!(i16, black_box(f32::MAX) as i16); +} diff --git a/compiler/rustc_codegen_gcc/tests/run/fun_ptr.rs b/compiler/rustc_codegen_gcc/tests/run/fun_ptr.rs new file mode 100644 index 00000000000..93b9baee1b2 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/fun_ptr.rs @@ -0,0 +1,30 @@ +// Compiler: +// +// Run-time: +// status: 0 +// stdout: 1 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +fn i16_as_i8(a: i16) -> i8 { + a as i8 +} + +fn call_func(func: fn(i16) -> i8, param: i16) -> i8 { + func(param) +} + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + unsafe { + let result = call_func(i16_as_i8, argc as i16) as isize; + libc::printf(b"%ld\n\0" as *const u8 as *const i8, result); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/gep.rs b/compiler/rustc_codegen_gcc/tests/run/gep.rs new file mode 100644 index 00000000000..c3d1672cff5 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/gep.rs @@ -0,0 +1,10 @@ +// Compiler: +// +// Run-time: +// status: 0 + +fn main() { + let mut value = (1, 1); + let ptr = &mut value as *mut (i32, i32); + println!("{:?}", ptr.wrapping_offset(10)); +} diff --git a/compiler/rustc_codegen_gcc/tests/run/int.rs b/compiler/rustc_codegen_gcc/tests/run/int.rs new file mode 100644 index 00000000000..e20ecc23679 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/int.rs @@ -0,0 +1,324 @@ +// Compiler: +// +// Run-time: +// status: 0 + +fn main() { + use std::hint::black_box; + + macro_rules! check { + ($ty:ty, $expr:expr) => { + { + const EXPECTED: $ty = $expr; + assert_eq!($expr, EXPECTED); + } + }; + } + + check!(u32, (2220326408_u32 + black_box(1)) >> (32 - 6)); + + /// Generate `check!` tests for integer types at least as wide as 128 bits. + macro_rules! check_ops128 { + () => { + check_ops64!(); + + // Shifts. + check!(T, VAL1 << black_box(64)); + check!(T, VAL1 << black_box(81)); + check!(T, VAL3 << black_box(63)); + check!(T, VAL3 << black_box(64)); + + check!(T, VAL1 >> black_box(64)); + check!(T, VAL2 >> black_box(64)); + check!(T, VAL3 >> black_box(64)); + check!(T, VAL3 >> black_box(81)); + }; + } + + /// Generate `check!` tests for integer types at least as wide as 64 bits. + macro_rules! check_ops64 { + () => { + check_ops32!(); + + // Shifts. + check!(T, VAL2 << black_box(33)); + check!(T, VAL2 << black_box(49)); + check!(T, VAL2 << black_box(61)); + check!(T, VAL2 << black_box(63)); + + check!(T, VAL3 << black_box(33)); + check!(T, VAL3 << black_box(49)); + check!(T, VAL3 << black_box(61)); + + check!(T, VAL1 >> black_box(33)); + check!(T, VAL1 >> black_box(49)); + check!(T, VAL1 >> black_box(61)); + check!(T, VAL1 >> black_box(63)); + + check!(T, VAL2 >> black_box(33)); + check!(T, VAL2 >> black_box(49)); + check!(T, VAL2 >> black_box(61)); + check!(T, VAL2 >> black_box(63)); + + check!(T, VAL3 >> black_box(33)); + check!(T, VAL3 >> black_box(49)); + check!(T, VAL3 >> black_box(61)); + check!(T, VAL3 >> black_box(63)); + }; + } + + /// Generate `check!` tests for integer types at least as wide as 32 bits. + macro_rules! check_ops32 { + () => { + // Shifts. + check!(T, VAL2 << black_box(1)); + check!(T, VAL2 << black_box(0)); + + check!(T, VAL3 << black_box(1)); + check!(T, VAL3 << black_box(0)); + + check!(T, VAL1.wrapping_shl(black_box(0))); + check!(T, VAL1.wrapping_shl(black_box(1))); + check!(T, VAL1.wrapping_shl(black_box(33))); + check!(T, VAL1.wrapping_shl(black_box(49))); + check!(T, VAL1.wrapping_shl(black_box(61))); + check!(T, VAL1.wrapping_shl(black_box(63))); + check!(T, VAL1.wrapping_shl(black_box(64))); + check!(T, VAL1.wrapping_shl(black_box(81))); + + check!(Option<T>, VAL1.checked_shl(black_box(0))); + check!(Option<T>, VAL1.checked_shl(black_box(1))); + check!(Option<T>, VAL1.checked_shl(black_box(33))); + check!(Option<T>, VAL1.checked_shl(black_box(49))); + check!(Option<T>, VAL1.checked_shl(black_box(61))); + check!(Option<T>, VAL1.checked_shl(black_box(63))); + check!(Option<T>, VAL1.checked_shl(black_box(64))); + check!(Option<T>, VAL1.checked_shl(black_box(81))); + + check!(T, VAL1 >> black_box(0)); + check!(T, VAL1 >> black_box(1)); + + check!(T, VAL2 >> black_box(1)); + check!(T, VAL2 >> black_box(0)); + + check!(T, VAL3 >> black_box(0)); + check!(T, VAL3 >> black_box(1)); + + check!(T, VAL1.wrapping_shr(black_box(0))); + check!(T, VAL1.wrapping_shr(black_box(1))); + check!(T, VAL1.wrapping_shr(black_box(33))); + check!(T, VAL1.wrapping_shr(black_box(49))); + check!(T, VAL1.wrapping_shr(black_box(61))); + check!(T, VAL1.wrapping_shr(black_box(63))); + check!(T, VAL1.wrapping_shr(black_box(64))); + check!(T, VAL1.wrapping_shr(black_box(81))); + + check!(Option<T>, VAL1.checked_shr(black_box(0))); + check!(Option<T>, VAL1.checked_shr(black_box(1))); + check!(Option<T>, VAL1.checked_shr(black_box(33))); + check!(Option<T>, VAL1.checked_shr(black_box(49))); + check!(Option<T>, VAL1.checked_shr(black_box(61))); + check!(Option<T>, VAL1.checked_shr(black_box(63))); + check!(Option<T>, VAL1.checked_shr(black_box(64))); + check!(Option<T>, VAL1.checked_shr(black_box(81))); + + // Casts + check!(u64, (VAL1 >> black_box(1)) as u64); + + // Addition. + check!(T, VAL1 + black_box(1)); + check!(T, VAL2 + black_box(1)); + check!(T, VAL2 + (VAL2 + black_box(1))); + check!(T, VAL3 + black_box(1)); + + check!(Option<T>, VAL1.checked_add(black_box(1))); + check!(Option<T>, VAL2.checked_add(black_box(1))); + check!(Option<T>, VAL2.checked_add(VAL2 + black_box(1))); + check!(Option<T>, VAL3.checked_add(T::MAX)); + check!(Option<T>, VAL3.checked_add(T::MIN)); + + check!(T, VAL1.wrapping_add(black_box(1))); + check!(T, VAL2.wrapping_add(black_box(1))); + check!(T, VAL2.wrapping_add(VAL2 + black_box(1))); + check!(T, VAL3.wrapping_add(T::MAX)); + check!(T, VAL3.wrapping_add(T::MIN)); + + check!((T, bool), VAL1.overflowing_add(black_box(1))); + check!((T, bool), VAL2.overflowing_add(black_box(1))); + check!((T, bool), VAL2.overflowing_add(VAL2 + black_box(1))); + check!((T, bool), VAL3.overflowing_add(T::MAX)); + check!((T, bool), VAL3.overflowing_add(T::MIN)); + + check!(T, VAL1.saturating_add(black_box(1))); + check!(T, VAL2.saturating_add(black_box(1))); + check!(T, VAL2.saturating_add(VAL2 + black_box(1))); + check!(T, VAL3.saturating_add(T::MAX)); + check!(T, VAL3.saturating_add(T::MIN)); + + // Subtraction + check!(T, VAL1 - black_box(1)); + check!(T, VAL2 - black_box(1)); + check!(T, VAL3 - black_box(1)); + + check!(Option<T>, VAL1.checked_sub(black_box(1))); + check!(Option<T>, VAL2.checked_sub(black_box(1))); + check!(Option<T>, VAL2.checked_sub(VAL2 + black_box(1))); + check!(Option<T>, VAL3.checked_sub(T::MAX)); + check!(Option<T>, VAL3.checked_sub(T::MIN)); + + check!(T, VAL1.wrapping_sub(black_box(1))); + check!(T, VAL2.wrapping_sub(black_box(1))); + check!(T, VAL2.wrapping_sub(VAL2 + black_box(1))); + check!(T, VAL3.wrapping_sub(T::MAX)); + check!(T, VAL3.wrapping_sub(T::MIN)); + + check!((T, bool), VAL1.overflowing_sub(black_box(1))); + check!((T, bool), VAL2.overflowing_sub(black_box(1))); + check!((T, bool), VAL2.overflowing_sub(VAL2 + black_box(1))); + check!((T, bool), VAL3.overflowing_sub(T::MAX)); + check!((T, bool), VAL3.overflowing_sub(T::MIN)); + + check!(T, VAL1.saturating_sub(black_box(1))); + check!(T, VAL2.saturating_sub(black_box(1))); + check!(T, VAL2.saturating_sub(VAL2 + black_box(1))); + check!(T, VAL3.saturating_sub(T::MAX)); + check!(T, VAL3.saturating_sub(T::MIN)); + + // Multiplication + check!(T, VAL1 * black_box(2)); + check!(T, VAL1 * (black_box(1) + VAL2)); + check!(T, VAL2 * black_box(2)); + check!(T, VAL2 * (black_box(1) + VAL2)); + check!(T, VAL3 * black_box(1)); + check!(T, VAL4 * black_box(2)); + check!(T, VAL5 * black_box(2)); + + check!(Option<T>, VAL1.checked_mul(black_box(2))); + check!(Option<T>, VAL1.checked_mul(black_box(1) + VAL2)); + check!(Option<T>, VAL3.checked_mul(VAL3)); + check!(Option<T>, VAL4.checked_mul(black_box(2))); + check!(Option<T>, VAL5.checked_mul(black_box(2))); + + check!(T, VAL1.wrapping_mul(black_box(2))); + check!(T, VAL1.wrapping_mul((black_box(1) + VAL2))); + check!(T, VAL3.wrapping_mul(VAL3)); + check!(T, VAL4.wrapping_mul(black_box(2))); + check!(T, VAL5.wrapping_mul(black_box(2))); + + check!((T, bool), VAL1.overflowing_mul(black_box(2))); + check!((T, bool), VAL1.overflowing_mul(black_box(1) + VAL2)); + check!((T, bool), VAL3.overflowing_mul(VAL3)); + check!((T, bool), VAL4.overflowing_mul(black_box(2))); + check!((T, bool), VAL5.overflowing_mul(black_box(2))); + + check!(T, VAL1.saturating_mul(black_box(2))); + check!(T, VAL1.saturating_mul(black_box(1) + VAL2)); + check!(T, VAL3.saturating_mul(VAL3)); + check!(T, VAL4.saturating_mul(black_box(2))); + check!(T, VAL5.saturating_mul(black_box(2))); + + // Division. + check!(T, VAL1 / black_box(2)); + check!(T, VAL1 / black_box(3)); + + check!(T, VAL2 / black_box(2)); + check!(T, VAL2 / black_box(3)); + + check!(T, VAL3 / black_box(2)); + check!(T, VAL3 / black_box(3)); + check!(T, VAL3 / (black_box(1) + VAL4)); + check!(T, VAL3 / (black_box(1) + VAL2)); + + check!(T, VAL4 / black_box(2)); + check!(T, VAL4 / black_box(3)); + + check!(Option<T>, VAL1.checked_div(black_box(2))); + check!(Option<T>, VAL1.checked_div(black_box(1) + VAL2)); + check!(Option<T>, VAL3.checked_div(VAL3)); + check!(Option<T>, VAL4.checked_div(black_box(2))); + check!(Option<T>, VAL5.checked_div(black_box(2))); + check!(Option<T>, (T::MIN).checked_div(black_box(0 as T).wrapping_sub(1))); + check!(Option<T>, VAL5.checked_div(black_box(0))); // var5 / 0 + + check!(T, VAL1.wrapping_div(black_box(2))); + check!(T, VAL1.wrapping_div(black_box(1) + VAL2)); + check!(T, VAL3.wrapping_div(VAL3)); + check!(T, VAL4.wrapping_div(black_box(2))); + check!(T, VAL5.wrapping_div(black_box(2))); + check!(T, (T::MIN).wrapping_div(black_box(0 as T).wrapping_sub(1))); + + check!((T, bool), VAL1.overflowing_div(black_box(2))); + check!((T, bool), VAL1.overflowing_div(black_box(1) + VAL2)); + check!((T, bool), VAL3.overflowing_div(VAL3)); + check!((T, bool), VAL4.overflowing_div(black_box(2))); + check!((T, bool), VAL5.overflowing_div(black_box(2))); + check!((T, bool), (T::MIN).overflowing_div(black_box(0 as T).wrapping_sub(1))); + + check!(T, VAL1.saturating_div(black_box(2))); + check!(T, VAL1.saturating_div((black_box(1) + VAL2))); + check!(T, VAL3.saturating_div(VAL3)); + check!(T, VAL4.saturating_div(black_box(2))); + check!(T, VAL5.saturating_div(black_box(2))); + check!(T, (T::MIN).saturating_div((0 as T).wrapping_sub(black_box(1)))); + }; + } + + { + type T = u32; + const VAL1: T = 14162_u32; + const VAL2: T = 14556_u32; + const VAL3: T = 323656954_u32; + const VAL4: T = 2023651954_u32; + const VAL5: T = 1323651954_u32; + check_ops32!(); + } + + { + type T = i32; + const VAL1: T = 13456_i32; + const VAL2: T = 10475_i32; + const VAL3: T = 923653954_i32; + const VAL4: T = 993198738_i32; + const VAL5: T = 1023653954_i32; + check_ops32!(); + } + + { + type T = u64; + const VAL1: T = 134217856_u64; + const VAL2: T = 104753732_u64; + const VAL3: T = 12323651988970863954_u64; + const VAL4: T = 7323651988970863954_u64; + const VAL5: T = 8323651988970863954_u64; + check_ops64!(); + } + + { + type T = i64; + const VAL1: T = 134217856_i64; + const VAL2: T = 104753732_i64; + const VAL3: T = 6323651988970863954_i64; + const VAL4: T = 2323651988970863954_i64; + const VAL5: T = 3323651988970863954_i64; + check_ops64!(); + } + + { + type T = u128; + const VAL1: T = 134217856_u128; + const VAL2: T = 10475372733397991552_u128; + const VAL3: T = 193236519889708027473620326106273939584_u128; + const VAL4: T = 123236519889708027473620326106273939584_u128; + const VAL5: T = 153236519889708027473620326106273939584_u128; + check_ops128!(); + } + { + type T = i128; + const VAL1: T = 134217856_i128; + const VAL2: T = 10475372733397991552_i128; + const VAL3: T = 83236519889708027473620326106273939584_i128; + const VAL4: T = 63236519889708027473620326106273939584_i128; + const VAL5: T = 73236519889708027473620326106273939584_i128; + check_ops128!(); + } +} diff --git a/compiler/rustc_codegen_gcc/tests/run/int_overflow.rs b/compiler/rustc_codegen_gcc/tests/run/int_overflow.rs new file mode 100644 index 00000000000..78872159f62 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/int_overflow.rs @@ -0,0 +1,23 @@ +// Compiler: +// +// Run-time: +// stdout: Success +// status: signal + +fn main() { + std::panic::set_hook(Box::new(|_| { + println!("Success"); + std::process::abort(); + })); + + let arg_count = std::env::args().count(); + let int = isize::MAX; + let _int = int + arg_count as isize; // overflow + + // If overflow checking is disabled, we should reach here. + #[cfg(not(debug_assertions))] + unsafe { + println!("Success"); + std::process::abort(); + } +} diff --git a/compiler/rustc_codegen_gcc/tests/run/mut_ref.rs b/compiler/rustc_codegen_gcc/tests/run/mut_ref.rs new file mode 100644 index 00000000000..fa50d5bc5d3 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/mut_ref.rs @@ -0,0 +1,52 @@ +// Compiler: +// +// Run-time: +// stdout: 2 +// 7 +// 6 +// 11 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +struct Test { + field: isize, +} + +fn test(num: isize) -> Test { + Test { field: num + 1 } +} + +fn update_num(num: &mut isize) { + *num = *num + 5; +} + +#[no_mangle] +extern "C" fn main(mut argc: isize, _argv: *const *const u8) -> i32 { + let mut test = test(argc); + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.field); + } + update_num(&mut test.field); + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.field); + } + + update_num(&mut argc); + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, argc); + } + + let refe = &mut argc; + *refe = *refe + 5; + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, argc); + } + + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/operations.rs b/compiler/rustc_codegen_gcc/tests/run/operations.rs new file mode 100644 index 00000000000..a1b0772f76b --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/operations.rs @@ -0,0 +1,24 @@ +// Compiler: +// +// Run-time: +// stdout: 41 +// 39 +// 10 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, 40 + argc); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, 40 - argc); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, 10 * argc); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/packed_u128.rs b/compiler/rustc_codegen_gcc/tests/run/packed_u128.rs new file mode 100644 index 00000000000..b7cc6e21023 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/packed_u128.rs @@ -0,0 +1,31 @@ +// Compiler: +// +// Run-time: +// status: 0 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use intrinsics::black_box; +use mini_core::*; +#[repr(packed(1))] +pub struct ScalarInt { + data: u128, + size: u8, +} +#[inline(never)] +#[no_mangle] +fn read_data(a: &ScalarInt) { + black_box(a.data); +} + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + let data = + [black_box(ScalarInt { data: 0, size: 1 }), black_box(ScalarInt { data: 0, size: 1 })]; + read_data(&data[1]); + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/ptr_cast.rs b/compiler/rustc_codegen_gcc/tests/run/ptr_cast.rs new file mode 100644 index 00000000000..e627886a9d5 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/ptr_cast.rs @@ -0,0 +1,40 @@ +// Compiler: +// +// Run-time: +// status: 0 +// stdout: 10 +// 10 +// 42 +// 1 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { + ( + a as u8, a as u16, a as u32, a as usize, a as i8, a as i16, a as i32, a as isize, b as u8, + b as u32, + ) +} + +static mut ONE: usize = 1; + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + let (a, b, c, d, e, f, g, h, i, j) = int_cast(10, 42); + unsafe { + libc::printf(b"%d\n\0" as *const u8 as *const i8, c); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, d); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, j); + + let ptr = ONE as *mut usize; + let value = ptr as usize; + libc::printf(b"%ld\n\0" as *const u8 as *const i8, value); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/return-tuple.rs b/compiler/rustc_codegen_gcc/tests/run/return-tuple.rs new file mode 100644 index 00000000000..c1254c51ce9 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/return-tuple.rs @@ -0,0 +1,33 @@ +// Compiler: +// +// Run-time: +// status: 0 +// stdout: 10 +// 10 +// 42 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { + ( + a as u8, a as u16, a as u32, a as usize, a as i8, a as i16, a as i32, a as isize, b as u8, + b as u32, + ) +} + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + let (a, b, c, d, e, f, g, h, i, j) = int_cast(10, 42); + unsafe { + libc::printf(b"%d\n\0" as *const u8 as *const i8, c); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, d); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, j); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/slice.rs b/compiler/rustc_codegen_gcc/tests/run/slice.rs new file mode 100644 index 00000000000..449ccabef7f --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/slice.rs @@ -0,0 +1,28 @@ +// Compiler: +// +// Run-time: +// status: 0 +// stdout: 5 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +static mut TWO: usize = 2; + +fn index_slice(s: &[u32]) -> u32 { + unsafe { s[TWO] } +} + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + let array = [42, 7, 5]; + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, index_slice(&array)); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/static.rs b/compiler/rustc_codegen_gcc/tests/run/static.rs new file mode 100644 index 00000000000..1e36cf4f3d3 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/static.rs @@ -0,0 +1,49 @@ +// Compiler: +// +// Run-time: +// status: 0 +// stdout: 10 +// 14 +// 1 +// 12 +// 12 +// 1 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +struct Test { + field: isize, +} + +struct WithRef { + refe: &'static Test, +} + +static mut CONSTANT: isize = 10; + +static mut TEST: Test = Test { field: 12 }; + +static mut TEST2: Test = Test { field: 14 }; + +static mut WITH_REF: WithRef = WithRef { refe: unsafe { &TEST } }; + +#[no_mangle] +extern "C" fn main(argc: isize, _argv: *const *const u8) -> i32 { + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, CONSTANT); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, TEST2.field); + TEST2.field = argc; + libc::printf(b"%ld\n\0" as *const u8 as *const i8, TEST2.field); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, WITH_REF.refe.field); + WITH_REF.refe = &TEST2; + libc::printf(b"%ld\n\0" as *const u8 as *const i8, TEST.field); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, WITH_REF.refe.field); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/structs.rs b/compiler/rustc_codegen_gcc/tests/run/structs.rs new file mode 100644 index 00000000000..da73cbed9ae --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/structs.rs @@ -0,0 +1,41 @@ +// Compiler: +// +// Run-time: +// status: 0 +// stdout: 1 +// 2 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +struct Test { + field: isize, +} + +struct Two { + two: isize, +} + +fn one() -> isize { + 1 +} + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + let test = Test { + field: one(), + }; + let two = Two { + two: 2, + }; + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.field); + libc::printf(b"%ld\n\0" as *const u8 as *const i8, two.two); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/switchint_128bit.rs b/compiler/rustc_codegen_gcc/tests/run/switchint_128bit.rs new file mode 100644 index 00000000000..decae5bfcd7 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/switchint_128bit.rs @@ -0,0 +1,37 @@ +// Compiler: +// +// Run-time: +// status: 0 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use intrinsics::black_box; +use mini_core::*; + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + // 1st. Check that small 128 bit values work. + let val = black_box(64_u128); + match val { + 0 => return 1, + 1 => return 2, + 64 => (), + _ => return 3, + } + // 2nd check that *large* values work. + const BIG: u128 = 0xDEAD_C0FE_BEEF_DECAF_BADD_DECAF_BEEF_u128; + let val = black_box(BIG); + match val { + 0 => return 4, + 1 => return 5, + // Check that we will not match on the lower u64, if the upper qword is different! + 0xcafbadddecafbeef => return 6, + 0xDEAD_C0FE_BEEF_DECAF_BADD_DECAF_BEEF_u128 => (), + _ => return 7, + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/tuple.rs b/compiler/rustc_codegen_gcc/tests/run/tuple.rs new file mode 100644 index 00000000000..e0f2e95f628 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/tuple.rs @@ -0,0 +1,22 @@ +// Compiler: +// +// Run-time: +// status: 0 +// stdout: 3 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![no_main] + +extern crate mini_core; +use mini_core::*; + +#[no_mangle] +extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { + let test: (isize, isize, isize) = (3, 1, 4); + unsafe { + libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.0); + } + 0 +} diff --git a/compiler/rustc_codegen_gcc/tests/run/volatile.rs b/compiler/rustc_codegen_gcc/tests/run/volatile.rs new file mode 100644 index 00000000000..94a7bdc5c06 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/volatile.rs @@ -0,0 +1,27 @@ +// Compiler: +// +// Run-time: +// status: 0 + +use std::mem::MaybeUninit; + +#[allow(dead_code)] +#[derive(Debug)] +struct Struct { + pointer: *const (), + func: unsafe fn(*const ()), +} + +fn func(_ptr: *const ()) { +} + +fn main() { + let mut x = MaybeUninit::<&Struct>::uninit(); + x.write(&Struct { + pointer: std::ptr::null(), + func, + }); + let x = unsafe { x.assume_init() }; + let value = unsafe { (x as *const Struct).read_volatile() }; + println!("{:?}", value); +} diff --git a/compiler/rustc_codegen_gcc/tests/run/volatile2.rs b/compiler/rustc_codegen_gcc/tests/run/volatile2.rs new file mode 100644 index 00000000000..bdcb8259878 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tests/run/volatile2.rs @@ -0,0 +1,111 @@ +// Compiler: +// +// Run-time: +// status: 0 + +mod libc { + #[link(name = "c")] + extern "C" { + pub fn sigaction(signum: i32, act: *const sigaction, oldact: *mut sigaction) -> i32; + pub fn mmap(addr: *mut (), len: usize, prot: i32, flags: i32, fd: i32, offset: i64) -> *mut (); + pub fn mprotect(addr: *mut (), len: usize, prot: i32) -> i32; + } + + pub const PROT_READ: i32 = 1; + pub const PROT_WRITE: i32 = 2; + pub const MAP_PRIVATE: i32 = 0x0002; + pub const MAP_ANONYMOUS: i32 = 0x0020; + pub const MAP_FAILED: *mut u8 = !0 as *mut u8; + + /// glibc sigaction + #[repr(C)] + pub struct sigaction { + pub sa_sigaction: Option<unsafe extern "C" fn(i32, *mut (), *mut ())>, + pub sa_mask: [u32; 32], + pub sa_flags: i32, + pub sa_restorer: Option<unsafe extern "C" fn()>, + } + + pub const SA_SIGINFO: i32 = 0x00000004; + pub const SIGSEGV: i32 = 11; +} + +static mut COUNT: u32 = 0; +static mut STORAGE: *mut u8 = core::ptr::null_mut(); +const PAGE_SIZE: usize = 1 << 15; + +fn main() { + unsafe { + // Register a segfault handler + libc::sigaction( + libc::SIGSEGV, + &libc::sigaction { + sa_sigaction: Some(segv_handler), + sa_flags: libc::SA_SIGINFO, + ..core::mem::zeroed() + }, + core::ptr::null_mut(), + ); + + STORAGE = libc::mmap( + core::ptr::null_mut(), + PAGE_SIZE * 2, + 0, + libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, + -1, + 0, + ).cast(); + if STORAGE == libc::MAP_FAILED { + panic!("error: mmap failed"); + } + + let p_count = (&raw mut COUNT) as *mut u32; + p_count.write_volatile(0); + + // Trigger segfaults + STORAGE.add(0).write_volatile(1); + STORAGE.add(PAGE_SIZE).write_volatile(1); + STORAGE.add(0).write_volatile(1); + STORAGE.add(PAGE_SIZE).write_volatile(1); + STORAGE.add(0).write_volatile(1); + STORAGE.add(PAGE_SIZE).write_volatile(1); + STORAGE.add(0).read_volatile(); + STORAGE.add(PAGE_SIZE).read_volatile(); + STORAGE.add(0).read_volatile(); + STORAGE.add(PAGE_SIZE).read_volatile(); + STORAGE.add(0).read_volatile(); + STORAGE.add(PAGE_SIZE).read_volatile(); + STORAGE.add(0).write_volatile(1); + STORAGE.add(PAGE_SIZE).write_volatile(1); + + // The segfault handler should have been called for every `write_volatile` and + // `read_volatile` in `STORAGE`. If the compiler ignores volatility, some of these writes + // will be combined, causing a different number of segfaults. + // + // This `p_count` read is done by a volatile read. If the compiler + // ignores volatility, the compiler will speculate that `*p_count` is + // unchanged and remove this check, failing the test. + if p_count.read_volatile() != 14 { + panic!("error: segfault count mismatch: {}", p_count.read_volatile()); + } + } +} + +unsafe extern "C" fn segv_handler(_: i32, _: *mut (), _: *mut ()) { + let p_count = (&raw mut COUNT) as *mut u32; + p_count.write_volatile(p_count.read_volatile() + 1); + let count = p_count.read_volatile(); + + // Toggle the protected page so that the handler will be called for + // each `write_volatile` + libc::mprotect( + STORAGE.cast(), + PAGE_SIZE, + if count % 2 == 1 { libc::PROT_READ | libc::PROT_WRITE } else { 0 }, + ); + libc::mprotect( + STORAGE.add(PAGE_SIZE).cast(), + PAGE_SIZE, + if count % 2 == 0 { libc::PROT_READ | libc::PROT_WRITE } else { 0 }, + ); +} diff --git a/compiler/rustc_codegen_gcc/tools/check_intrinsics_duplicates.py b/compiler/rustc_codegen_gcc/tools/check_intrinsics_duplicates.py new file mode 100644 index 00000000000..c09fb3c759f --- /dev/null +++ b/compiler/rustc_codegen_gcc/tools/check_intrinsics_duplicates.py @@ -0,0 +1,67 @@ +import sys + + +def check_duplicates(): + auto_content = "" + manual_content = "" + + with open("src/intrinsic/llvm.rs", "r", encoding="utf8") as f: + manual_content = f.read() + with open("src/intrinsic/archs.rs", "r", encoding="utf8") as f: + auto_content = f.read() + + intrinsics_map = {} + for line in auto_content.splitlines(): + line = line.strip() + if not line.startswith('"'): + continue + parts = line.split('"') + if len(parts) != 5: + continue + intrinsics_map[parts[1]] = parts[3] + + if len(intrinsics_map) == 0: + print("No intrinsics found in auto code... Aborting.") + return 1 + print("Found {} intrinsics in auto code".format(len(intrinsics_map))) + errors = [] + lines = manual_content.splitlines() + pos = 0 + found = 0 + while pos < len(lines): + line = lines[pos].strip() + # This is our marker. + if line == "let gcc_name = match name {": + while pos < len(lines): + line = lines[pos].strip() + pos += 1 + if line == "};": + # We're done! + if found == 0: + print("No intrinsics found in manual code even though we found the " + "marker... Aborting...") + return 1 + for error in errors: + print("ERROR => {}".format(error)) + return 1 if len(errors) != 0 else 0 + parts = line.split('"') + if len(parts) != 5: + continue + found += 1 + if parts[1] in intrinsics_map: + if parts[3] != intrinsics_map[parts[1]]: + print("Same intrinsics (`{}` at line {}) but different GCC " + "translations: `{}` != `{}`".format( + parts[1], pos, intrinsics_map[parts[1]], parts[3])) + else: + errors.append("Duplicated intrinsics: `{}` at line {}. Please remove it " + " from manual code".format(parts[1], pos)) + # Weird but whatever... + return 1 if len(errors) != 0 else 0 + pos += 1 + print("No intrinsics found in manual code... Aborting") + return 1 + + +if __name__ == "__main__": + sys.exit(check_duplicates()) diff --git a/compiler/rustc_codegen_gcc/tools/cspell_dicts/rust.txt b/compiler/rustc_codegen_gcc/tools/cspell_dicts/rust.txt new file mode 100644 index 00000000000..379cbd77eef --- /dev/null +++ b/compiler/rustc_codegen_gcc/tools/cspell_dicts/rust.txt @@ -0,0 +1,2 @@ +lateout +repr diff --git a/compiler/rustc_codegen_gcc/tools/cspell_dicts/rustc_codegen_gcc.txt b/compiler/rustc_codegen_gcc/tools/cspell_dicts/rustc_codegen_gcc.txt new file mode 100644 index 00000000000..4fb018b3ecd --- /dev/null +++ b/compiler/rustc_codegen_gcc/tools/cspell_dicts/rustc_codegen_gcc.txt @@ -0,0 +1,78 @@ +aapcs +addo +archs +ashl +ashr +cgcx +clzll +cmse +codegened +csky +ctfe +ctlz +ctpop +cttz +ctzll +flto +fmaximumf +fmuladd +fmuladdf +fminimumf +fmul +fptosi +fptosui +fptoui +fwrapv +gimple +hrtb +immediates +interner +liblto +llbb +llcx +llextra +llfn +lgcc +llmod +llresult +llret +ltrans +llty +llval +llvals +loong +lshr +masm +maximumf +maxnumf +mavx +mcmodel +minimumf +minnumf +miri +monomorphization +monomorphizations +monomorphized +monomorphizing +movnt +mulo +nvptx +pointee +powitf +reassoc +riscv +rlib +roundevenf +rustc +sitofp +sizet +spir +subo +sysv +tbaa +uitofp +unord +uninlined +utrunc +xabort +zext diff --git a/compiler/rustc_codegen_gcc/tools/generate_intrinsics.py b/compiler/rustc_codegen_gcc/tools/generate_intrinsics.py new file mode 100644 index 00000000000..88927f39b93 --- /dev/null +++ b/compiler/rustc_codegen_gcc/tools/generate_intrinsics.py @@ -0,0 +1,243 @@ +import json +import os +import re +import sys +import subprocess + + +def run_command(command, cwd=None): + p = subprocess.Popen(command, cwd=cwd) + if p.wait() != 0: + print("command `{}` failed...".format(" ".join(command))) + sys.exit(1) + + +def clone_repository(repo_name, path, repo_url, branch="master", sub_paths=None): + if os.path.exists(path): + while True: + choice = input("There is already a `{}` folder, do you want to update it? [y/N]".format(path)) + if choice == "" or choice.lower() == "n": + print("Skipping repository update.") + return + elif choice.lower() == "y": + print("Updating repository...") + run_command(["git", "pull", "origin", branch], cwd=path) + return + else: + print("Didn't understand answer...") + print("Cloning {} repository...".format(repo_name)) + if sub_paths is None: + run_command(["git", "clone", repo_url, "--depth", "1", path]) + else: + run_command(["git", "clone", repo_url, "--filter=tree:0", "--no-checkout", path]) + run_command(["git", "sparse-checkout", "init"], cwd=path) + run_command(["git", "sparse-checkout", "set", *sub_paths], cwd=path) + run_command(["git", "checkout"], cwd=path) + + +def append_intrinsic(array, intrinsic_name, translation): + array.append((intrinsic_name, translation)) + + +def convert_to_string(content): + if content.__class__.__name__ == 'bytes': + return content.decode('utf-8') + return content + + +def extract_intrinsics_from_llvm(llvm_path, intrinsics): + command = ["llvm-tblgen", "llvm/IR/Intrinsics.td"] + cwd = os.path.join(llvm_path, "llvm/include") + print("=> Running command `{}` from `{}`".format(command, cwd)) + p = subprocess.Popen(command, cwd=cwd, stdout=subprocess.PIPE) + output, err = p.communicate() + lines = convert_to_string(output).splitlines() + pos = 0 + while pos < len(lines): + line = lines[pos] + if not line.startswith("def "): + pos += 1 + continue + intrinsic = line.split(" ")[1].strip() + content = line + while pos < len(lines): + line = lines[pos].split(" // ")[0].strip() + content += line + pos += 1 + if line == "}": + break + entries = re.findall('string ClangBuiltinName = "(\\w+)";', content) + current_arch = re.findall('string TargetPrefix = "(\\w+)";', content) + if len(entries) == 1 and len(current_arch) == 1: + current_arch = current_arch[0] + intrinsic = intrinsic.split("_") + if len(intrinsic) < 2 or intrinsic[0] != "int": + continue + intrinsic[0] = "llvm" + intrinsic = ".".join(intrinsic) + if current_arch not in intrinsics: + intrinsics[current_arch] = [] + append_intrinsic(intrinsics[current_arch], intrinsic, entries[0]) + + +def append_translation(json_data, p, array): + it = json_data["index"][p] + content = it["docs"].split('`') + if len(content) != 5: + return + append_intrinsic(array, content[1], content[3]) + + +def extract_intrinsics_from_llvmint(llvmint, intrinsics): + archs = [ + "AMDGPU", + "aarch64", + "arm", + "cuda", + "hexagon", + "mips", + "nvvm", + "ppc", + "ptx", + "x86", + "xcore", + ] + + json_file = os.path.join(llvmint, "target/doc/llvmint.json") + # We need to regenerate the documentation! + run_command( + ["cargo", "rustdoc", "--", "-Zunstable-options", "--output-format", "json"], + cwd=llvmint, + ) + with open(json_file, "r", encoding="utf8") as f: + json_data = json.loads(f.read()) + for p in json_data["paths"]: + it = json_data["paths"][p] + if it["crate_id"] != 0: + # This is from an external crate. + continue + if it["kind"] != "function": + # We're only looking for functions. + continue + # if len(it["path"]) == 2: + # # This is a "general" intrinsic, not bound to a specific arch. + # append_translation(json_data, p, general) + # continue + if len(it["path"]) != 3 or it["path"][1] not in archs: + continue + arch = it["path"][1] + if arch not in intrinsics: + intrinsics[arch] = [] + append_translation(json_data, p, intrinsics[arch]) + + +def fill_intrinsics(intrinsics, from_intrinsics, all_intrinsics): + for arch in from_intrinsics: + if arch not in intrinsics: + intrinsics[arch] = [] + for entry in from_intrinsics[arch]: + if entry[0] in all_intrinsics: + if all_intrinsics[entry[0]] == entry[1]: + # This is a "full" duplicate, both the LLVM instruction and the GCC + # translation are the same. + continue + intrinsics[arch].append((entry[0], entry[1], True)) + else: + intrinsics[arch].append((entry[0], entry[1], False)) + all_intrinsics[entry[0]] = entry[1] + + +def update_intrinsics(llvm_path, llvmint, llvmint2): + intrinsics_llvm = {} + intrinsics_llvmint = {} + all_intrinsics = {} + + extract_intrinsics_from_llvm(llvm_path, intrinsics_llvm) + extract_intrinsics_from_llvmint(llvmint, intrinsics_llvmint) + extract_intrinsics_from_llvmint(llvmint2, intrinsics_llvmint) + + intrinsics = {} + # We give priority to translations from LLVM over the ones from llvmint. + fill_intrinsics(intrinsics, intrinsics_llvm, all_intrinsics) + fill_intrinsics(intrinsics, intrinsics_llvmint, all_intrinsics) + + archs = [arch for arch in intrinsics] + archs.sort() + + output_file = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "../src/intrinsic/archs.rs", + ) + # A hashmap of all architectures. This allows us to first match on the architecture, and then on the intrinsics. + # This speeds up the comparison, and makes our code considerably smaller. + # Since all intrinsic names start with "llvm.", we skip that prefix. + print("Updating content of `{}`...".format(output_file)) + with open(output_file, "w", encoding="utf8") as out: + out.write("// File generated by `rustc_codegen_gcc/tools/generate_intrinsics.py`\n") + out.write("// DO NOT EDIT IT!\n") + out.write("/// Translate a given LLVM intrinsic name to an equivalent GCC one.\n") + out.write("fn map_arch_intrinsic(full_name:&str)->&'static str{\n") + out.write('let Some(name) = full_name.strip_prefix("llvm.") else { unimplemented!("***** unsupported LLVM intrinsic {}", full_name) };\n') + out.write('let Some((arch, name)) = name.split_once(\'.\') else { unimplemented!("***** unsupported LLVM intrinsic {}", name) };\n') + out.write("match arch {\n") + for arch in archs: + if len(intrinsics[arch]) == 0: + continue + out.write("\"{}\" => {{ #[allow(non_snake_case)] fn {}(name: &str,full_name:&str) -> &'static str {{ match name {{".format(arch,arch)) + intrinsics[arch].sort(key=lambda x: (x[0], x[2])) + out.write(' // {}\n'.format(arch)) + for entry in intrinsics[arch]: + llvm_name = entry[0].removeprefix("llvm."); + llvm_name = llvm_name.removeprefix(arch); + llvm_name = llvm_name.removeprefix("."); + if entry[2] is True: # if it is a duplicate + out.write(' // [DUPLICATE]: "{}" => "{}",\n'.format(llvm_name, entry[1])) + elif "_round_mask" in entry[1]: + out.write(' // [INVALID CONVERSION]: "{}" => "{}",\n'.format(llvm_name, entry[1])) + else: + out.write(' "{}" => "{}",\n'.format(llvm_name, entry[1])) + out.write(' _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"),\n') + out.write("}} }} {}(name,full_name) }}\n,".format(arch)) + out.write(' _ => unimplemented!("***** unsupported LLVM architecture {arch}, intrinsic:{full_name}"),\n') + out.write("}\n}") + subprocess.call(["rustfmt", output_file]) + print("Done!") + + +def main(): + llvm_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "llvm-project", + ) + llvmint_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "llvmint", + ) + llvmint2_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "llvmint-2", + ) + + # First, we clone the LLVM repository if it's not already here. + clone_repository( + "llvm-project", + llvm_path, + "https://github.com/llvm/llvm-project", + branch="main", + sub_paths=["llvm/include/llvm/IR", "llvm/include/llvm/CodeGen/"], + ) + clone_repository( + "llvmint", + llvmint_path, + "https://github.com/GuillaumeGomez/llvmint", + ) + clone_repository( + "llvmint2", + llvmint2_path, + "https://github.com/antoyo/llvmint", + ) + update_intrinsics(llvm_path, llvmint_path, llvmint2_path) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/compiler/rustc_codegen_gcc/triagebot.toml b/compiler/rustc_codegen_gcc/triagebot.toml new file mode 100644 index 00000000000..13da0a87def --- /dev/null +++ b/compiler/rustc_codegen_gcc/triagebot.toml @@ -0,0 +1,7 @@ +# Documentation at https://forge.rust-lang.org/triagebot/index.html + +# Prevents un-canonicalized issue links (to avoid wrong issues being linked in r-l/rust) +[issue-links] + +# Prevents mentions in commits to avoid users being spammed +[no-mentions] diff --git a/compiler/rustc_codegen_gcc/y.sh b/compiler/rustc_codegen_gcc/y.sh new file mode 100755 index 00000000000..69d7917dd77 --- /dev/null +++ b/compiler/rustc_codegen_gcc/y.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e +echo "[BUILD] build system" 1>&2 +pushd $(dirname "$0")/build_system > /dev/null +cargo build --release +popd > /dev/null +$(dirname "$0")/build_system/target/release/y $@ |
