<commit_before>//! Handling of everything related to the calling convention. Also fills `fx.local_map`.

#[cfg(debug_assertions)]
mod comments;
mod pass_mode;
mod returning;

use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::ty::layout::FnAbiExt;
use rustc_target::abi::call::{Conv, FnAbi};
use rustc_target::spec::abi::Abi;

use cranelift_codegen::ir::AbiParam;
use smallvec::smallvec;

use self::pass_mode::*;
use crate::prelude::*;

pub(crate) use self::returning::{can_return_to_ssa_var, codegen_return};

fn clif_sig_from_fn_abi<'tcx>(
    tcx: TyCtxt<'tcx>,
    triple: &target_lexicon::Triple,
    fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
) -> Signature {
    let call_conv = match fn_abi.conv {
        Conv::Rust | Conv::C => CallConv::triple_default(triple),
        Conv::X86_64SysV => CallConv::SystemV,
        Conv::X86_64Win64 => CallConv::WindowsFastcall,
        Conv::ArmAapcs
        | Conv::Msp430Intr
        | Conv::PtxKernel
        | Conv::X86Fastcall
        | Conv::X86Intr
        | Conv::X86Stdcall
        | Conv::X86ThisCall
        | Conv::X86VectorCall
        | Conv::AmdGpuKernel
        | Conv::AvrInterrupt
        | Conv::AvrNonBlockingInterrupt => {
            todo!("{:?}", fn_abi.conv)
        }
    };
    let inputs = fn_abi
        .args
        .iter()
        .map(|arg_abi| arg_abi.get_abi_param(tcx).into_iter())
        .flatten();

    let (return_ptr, returns) = fn_abi.ret.get_abi_return(tcx);
    // Sometimes the first param is an pointer to the place where the return value needs to be stored.
    let params: Vec<_> = return_ptr.into_iter().chain(inputs).collect();

    Signature {
        params,
        returns,
        call_conv,
    }
}
<commit_msg>Sync from rust f4008fe94935d05ffb3a48fc5b7149070bb45550<commit_after>//! Handling of everything related to the calling convention. Also fills `fx.local_map`.

#[cfg(debug_assertions)]
mod comments;
mod pass_mode;
mod returning;

use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::ty::layout::FnAbiExt;
use rustc_target::abi::call::{Conv, FnAbi};
use rustc_target::spec::abi::Abi;

use cranelift_codegen::ir::AbiParam;
use smallvec::smallvec;

use self::pass_mode::*;
use crate::prelude::*;

pub(crate) use self::returning::{can_return_to_ssa_var, codegen_return};

fn clif_sig_from_fn_abi<'tcx>(
    tcx: TyCtxt<'tcx>,
    triple: &target_lexicon::Triple,
    fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
) -> Signature {
    let call_conv = match fn_abi.conv {
        Conv::Rust | Conv::C => CallConv::triple_default(triple),
        Conv::X86_64SysV => CallConv::SystemV,
        Conv::X86_64Win64 => CallConv::WindowsFastcall,
        Conv::ArmAapcs
        | Conv::CCmseNonSecureCall
        | Conv::Msp430Intr
        | Conv::PtxKernel
        | Conv::X86Fastcall
        | Conv::X86Intr
        | Conv::X86Stdcall
        | Conv::X86ThisCall
        | Conv::X86VectorCall
        | Conv::AmdGpuKernel
        | Conv::AvrInterrupt
        | Conv::AvrNonBlockingInterrupt => {
            todo!("{:?}", fn_abi.conv)
        }
    };
    let inputs = fn_abi
        .args
        .iter()
        .map(|arg_abi| arg_abi.get_abi_param(tcx).into_iter())
        .flatten();

    let (return_ptr, returns) = fn_abi.ret.get_abi_return(tcx);
    // Sometimes the first param is an pointer to the place where the return value needs to be stored.
    let params: Vec<_> = return_ptr.into_iter().chain(inputs).collect();

    Signature {
        params,
        returns,
        call_conv,
    }
}

{'fraction_non_alphanumeric': 0.13511988716502116, 'fraction_numerical': 0.02059238363892807, 'mean_word_length': 3.3138686131386863, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4689071', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1255, 'n_words': 228}