Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions crates/core_arch/src/loongarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,20 @@ pub fn rdtime_d() -> (i64, isize) {

#[allow(improper_ctypes)]
unsafe extern "unadjusted" {
#[link_name = "llvm.loongarch.crc.w.b.w"]
fn __crc_w_b_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.crc.w.h.w"]
fn __crc_w_h_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.crc.w.w.w"]
fn __crc_w_w_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.crc.w.d.w"]
fn __crc_w_d_w(a: i64, b: i32) -> i32;
#[link_name = "llvm.loongarch.crcc.w.b.w"]
fn __crcc_w_b_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.crcc.w.h.w"]
fn __crcc_w_h_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.crcc.w.w.w"]
fn __crcc_w_w_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.crcc.w.d.w"]
fn __crcc_w_d_w(a: i64, b: i32) -> i32;
#[link_name = "llvm.loongarch.cacop.d"]
Expand All @@ -48,13 +60,55 @@ unsafe extern "unadjusted" {
fn __ldpte(a: i64, b: i64);
}

/// Calculate the CRC value using the IEEE 802.3 polynomial (0xEDB88320)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crc_w_b_w(a: i8, b: i32) -> i32 {
unsafe { __crc_w_b_w(a as i32, b) }
}

/// Calculate the CRC value using the IEEE 802.3 polynomial (0xEDB88320)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crc_w_h_w(a: i16, b: i32) -> i32 {
unsafe { __crc_w_h_w(a as i32, b) }
}

/// Calculate the CRC value using the IEEE 802.3 polynomial (0xEDB88320)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crc_w_w_w(a: i32, b: i32) -> i32 {
unsafe { __crc_w_w_w(a, b) }
}

/// Calculate the CRC value using the IEEE 802.3 polynomial (0xEDB88320)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crc_w_d_w(a: i64, b: i32) -> i32 {
unsafe { __crc_w_d_w(a, b) }
}

/// Calculate the CRC value using the Castagnoli polynomial (0x82F63B78)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crcc_w_b_w(a: i8, b: i32) -> i32 {
unsafe { __crcc_w_b_w(a as i32, b) }
}

/// Calculate the CRC value using the Castagnoli polynomial (0x82F63B78)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crcc_w_h_w(a: i16, b: i32) -> i32 {
unsafe { __crcc_w_h_w(a as i32, b) }
}

/// Calculate the CRC value using the Castagnoli polynomial (0x82F63B78)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crcc_w_w_w(a: i32, b: i32) -> i32 {
unsafe { __crcc_w_w_w(a, b) }
}

/// Calculate the CRC value using the Castagnoli polynomial (0x82F63B78)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
Expand Down
54 changes: 0 additions & 54 deletions crates/core_arch/src/loongarch_shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ pub fn rdtimeh_w() -> (i32, isize) {

#[allow(improper_ctypes)]
unsafe extern "unadjusted" {
#[link_name = "llvm.loongarch.crc.w.b.w"]
fn __crc_w_b_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.crc.w.h.w"]
fn __crc_w_h_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.crc.w.w.w"]
fn __crc_w_w_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.crcc.w.b.w"]
fn __crcc_w_b_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.crcc.w.h.w"]
fn __crcc_w_h_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.crcc.w.w.w"]
fn __crcc_w_w_w(a: i32, b: i32) -> i32;
#[link_name = "llvm.loongarch.dbar"]
fn __dbar(a: i32);
#[link_name = "llvm.loongarch.ibar"]
Expand Down Expand Up @@ -70,48 +58,6 @@ unsafe extern "unadjusted" {
fn __frsqrte_d(a: f64) -> f64;
}

/// Calculate the CRC value using the IEEE 802.3 polynomial (0xEDB88320)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crc_w_b_w(a: i32, b: i32) -> i32 {
unsafe { __crc_w_b_w(a, b) }
}

/// Calculate the CRC value using the IEEE 802.3 polynomial (0xEDB88320)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crc_w_h_w(a: i32, b: i32) -> i32 {
unsafe { __crc_w_h_w(a, b) }
}

/// Calculate the CRC value using the IEEE 802.3 polynomial (0xEDB88320)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crc_w_w_w(a: i32, b: i32) -> i32 {
unsafe { __crc_w_w_w(a, b) }
}

/// Calculate the CRC value using the Castagnoli polynomial (0x82F63B78)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crcc_w_b_w(a: i32, b: i32) -> i32 {
unsafe { __crcc_w_b_w(a, b) }
}

/// Calculate the CRC value using the Castagnoli polynomial (0x82F63B78)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crcc_w_h_w(a: i32, b: i32) -> i32 {
unsafe { __crcc_w_h_w(a, b) }
}

/// Calculate the CRC value using the Castagnoli polynomial (0x82F63B78)
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub fn crcc_w_w_w(a: i32, b: i32) -> i32 {
unsafe { __crcc_w_w_w(a, b) }
}

/// Generates the memory barrier instruction
#[inline(always)]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
Expand Down
Loading