-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support signed integers for
bswap
intrinsic (#174)
Fixes #169
- Loading branch information
Showing
2 changed files
with
77 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Test bswap intrinsic | ||
// build-pass | ||
|
||
#![allow(internal_features)] | ||
#![feature(core_intrinsics)] | ||
#![no_std] | ||
|
||
use core::intrinsics::bswap; | ||
use spirv_std::spirv; | ||
|
||
#[spirv(compute(threads(1)))] | ||
pub fn main() { | ||
let original_i16: i16 = 0x1234; | ||
let swapped_i16 = bswap(original_i16); | ||
|
||
let original_neg_i16: i16 = -0x1234; | ||
let swapped_neg_i16 = bswap(original_neg_i16); | ||
|
||
let original_i32: i32 = 0x12345678; | ||
let swapped_i32 = bswap(original_i32); | ||
|
||
let original_neg_i32: i32 = -0x12345678; | ||
let swapped_neg_i32 = bswap(original_neg_i32); | ||
|
||
let original_zero_i16: i16 = 0; | ||
let swapped_zero_i16 = bswap(original_zero_i16); | ||
|
||
let original_zero_i32: i32 = 0; | ||
let swapped_zero_i32 = bswap(original_zero_i32); | ||
|
||
let original_u8: u8 = 0x12; | ||
let swapped_u8 = bswap(original_u8); | ||
|
||
let original_u16: u16 = 0x1234; | ||
let swapped_u16 = bswap(original_u16); | ||
|
||
let original_u32: u32 = 0x12345678; | ||
let swapped_u32 = bswap(original_u32); | ||
|
||
let original_u64: u64 = 0x123456789ABCDEF0; | ||
let swapped_u64 = bswap(original_u64); | ||
} |