Skip to content

Commit

Permalink
Add vbsll.v/vbsrl.v
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 12, 2023
1 parent 6f3a1bf commit 86c704a
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 10 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,6 @@ Vector Multiplication High

### vsubi.bu/hu/wu/du

### vbsll.v

### vbsrl.v

### vmaxi.b/h/w/d

### vmini.b/h/w/d
Expand Down
12 changes: 6 additions & 6 deletions code/vbitseli_b.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ v128 vbitseli_b(v128 a, v128 b, int imm) {
}

void test() {
FUZZ2(vbitseli_b, 0x00);
FUZZ2(vbitseli_b, 0x01);
FUZZ2(vbitseli_b, 0x01);
FUZZ2(vbitseli_b, 0x80);
FUZZ2(vbitseli_b, 0xFF);
}
FUZZ2(vbitseli_b, 0x00);
FUZZ2(vbitseli_b, 0x01);
FUZZ2(vbitseli_b, 0x01);
FUZZ2(vbitseli_b, 0x80);
FUZZ2(vbitseli_b, 0xFF);
}
18 changes: 18 additions & 0 deletions code/vbsll_v.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "common.h"

v128 vbsll_v(v128 a, int imm) {
v128 dst;
#include "vbsll_v.h"
return dst;
}

void test() {
FUZZ1(vbsll_v, 0);
FUZZ1(vbsll_v, 3);
FUZZ1(vbsll_v, 7);
FUZZ1(vbsll_v, 8);
FUZZ1(vbsll_v, 16);
FUZZ1(vbsll_v, 24);
FUZZ1(vbsll_v, 25);
FUZZ1(vbsll_v, 31);
}
2 changes: 2 additions & 0 deletions code/vbsll_v.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int shift = (imm * 8) % 128;
dst.qword[0] = (u128)a.qword[0] << shift;
18 changes: 18 additions & 0 deletions code/vbsrl_v.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "common.h"

v128 vbsrl_v(v128 a, int imm) {
v128 dst;
#include "vbsrl_v.h"
return dst;
}

void test() {
FUZZ1(vbsrl_v, 0);
FUZZ1(vbsrl_v, 3);
FUZZ1(vbsrl_v, 7);
FUZZ1(vbsrl_v, 8);
FUZZ1(vbsrl_v, 16);
FUZZ1(vbsrl_v, 24);
FUZZ1(vbsrl_v, 25);
FUZZ1(vbsrl_v, 31);
}
2 changes: 2 additions & 0 deletions code/vbsrl_v.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int shift = (imm * 8) % 128;
dst.qword[0] = (u128)a.qword[0] >> shift;
43 changes: 43 additions & 0 deletions docs/lsx_integer/vshift.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Shift

## __m128i __lsx_vbsll_v (__m128i a, imm0_31 imm)

### Synopsis

```c++
__m128i __lsx_vbsll_v (__m128i a, imm0_31 imm)
#include <lsxintrin.h>
Instruction: vbsll.v vr, vr, imm
CPU Flags: LSX
```
### Description
Compute 128-bit `a` shifted left by `imm * 8` bits.
### Operation
```c++
{% include 'vbsll_v.h' %}
```

## __m128i __lsx_vbsrl_v (__m128i a, imm0_31 imm)

### Synopsis

```c++
__m128i __lsx_vbsrl_v (__m128i a, imm0_31 imm)
#include <lsxintrin.h>
Instruction: vbsrl.v vr, vr, imm
CPU Flags: LSX
```
### Description
Compute 128-bit `a` shifted right by `imm * 8` bits.
### Operation
```c++
{% include 'vbsrl_v.h' %}
```

0 comments on commit 86c704a

Please sign in to comment.