Panther Search Documentation Tutorials Devlog Downloads Source Code

Bitwise Intrinsics

Panther
Documentation


@and

func @and = <{T: Type}> (lhs: T, rhs: T) -> T;

Bitwise and. T must be integral or a vector of integral.

@or

func @or = <{T: Type}> (lhs: T, rhs: T) -> T;

Bitwise or. T must be integral or a vector of integral.

@xor

func @xor = <{T: Type}> (lhs: T, rhs: T) -> T;

Bitwise exclusive or. T must be integral or a vector of integral.

@shl

func @shl = <{T: Type, SHIFT_T: Type, MAY_WRAP: Bool}> (lhs: T, rhs: SHIFT_T) -> T;

Bitwise shift left. T must be integral or a vector of integral. SHIFT_T must be unsigned with a width of ceil(log2(@bitWidth<{T}>()))

If T is unsigned and MAY_WRAP is false, it is undefined behavior if any 1 bits are shifted out.

If T is signed and MAY_WRAP is false, it is undefined behavior if the result is a different sign than lhs.

@shlSat

func @shlSat = <{T: Type, SHIFT_T: Type}> (lhs: T, rhs: T) -> T;

Bitwise saturating shift left. T must be integral or a vector of integral. SHIFT_T must be unsigned integral with a width of ceil(log2(@bitWidth<{T}>())).

@shr

func @shr = <{T: Type, SHIFT_T: Type, MAY_WRAP: Bool}> (lhs: T, rhs: SHIFT_T) -> T;

Bitwise shift right. T must be integral or a vector of integral. SHIFT_T must be unsigned integral with a width of ceil(log2(@bitWidth<{T}>())).

If MAY_WRAP is false, it is undefined behavior if any 1 bits are shifted out.

@bitReverse

func @bitReverse = <{T: Type}> (arg: T) -> T;

Reverse the bits. T must be integral or a vector of integral, and must have an even bitwidth

@bSwap

func @bSwap = <{T: Type}> (arg: T) -> T;

Swap the bytes . T must be integral or a vector of integral.

@ctPop

func @ctPop = <{T: Type}> (arg: T) -> T;

Count the number of one bits. T must be integral or a vector of integral.

@ctlz

func @ctlz = <{T: Type}> (arg: T) -> T;

Count number of leading zero bits. T must be integral or a vector of integral.

@cttz

func @cttz = <{T: Type}> (arg: T) -> T;

Count number of trailing zero bits. T must be integral or a vector of integral.