Skip to content

Commit 54b40a1

Browse files
committed
[1/3][Clang][RISCV] Add __riscv_ prefix for vread, vwrite, vlenb, vsetvl, and vsetvlmax
This commit adds prefix for intrinsics that are defined through `HeaderCode` under `riscv_vector.td`. This is the 1st commit of a patch-set to add `__riscv_` for all RVV intrinsics. This follows the naming guideline under riscv-c-api-doc to add the `__riscv_` suffix for all RVV intrinsics. Pull Request: riscv-non-isa/riscv-c-api-doc#31 riscv-non-isa/rvv-intrinsic-doc#189 Depends on D142016. Reviewed By: kito-cheng Differential Revision: https://reviews.llvm.org/D142085
1 parent b2bf995 commit 54b40a1

File tree

7 files changed

+147
-147
lines changed

7 files changed

+147
-147
lines changed

clang/include/clang/Basic/riscv_vector.td

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ enum RVV_CSR {
15391539
};
15401540

15411541
static __inline__ __attribute__((__always_inline__, __nodebug__))
1542-
unsigned long vread_csr(enum RVV_CSR __csr) {
1542+
unsigned long __riscv_vread_csr(enum RVV_CSR __csr) {
15431543
unsigned long __rv = 0;
15441544
switch (__csr) {
15451545
case RVV_VSTART:
@@ -1559,7 +1559,7 @@ unsigned long vread_csr(enum RVV_CSR __csr) {
15591559
}
15601560

15611561
static __inline__ __attribute__((__always_inline__, __nodebug__))
1562-
void vwrite_csr(enum RVV_CSR __csr, unsigned long __value) {
1562+
void __riscv_vwrite_csr(enum RVV_CSR __csr, unsigned long __value) {
15631563
switch (__csr) {
15641564
case RVV_VSTART:
15651565
__asm__ __volatile__ ("csrw\tvstart, %z0" : : "rJ"(__value) : "memory");
@@ -1580,7 +1580,7 @@ def vread_vwrite_csr: RVVHeader;
15801580

15811581
let HeaderCode =
15821582
[{
1583-
#define vlenb() __builtin_rvv_vlenb()
1583+
#define __riscv_vlenb() __builtin_rvv_vlenb()
15841584
}] in
15851585
def vlenb_macro: RVVHeader;
15861586

@@ -1611,62 +1611,62 @@ let HasBuiltinAlias = false, HasVL = false, HasMasked = false,
16111611
// and LMUL.
16121612
let HeaderCode =
16131613
[{
1614-
#define vsetvl_e8mf4(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 6)
1615-
#define vsetvl_e8mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 7)
1616-
#define vsetvl_e8m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 0)
1617-
#define vsetvl_e8m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 1)
1618-
#define vsetvl_e8m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 2)
1619-
#define vsetvl_e8m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 3)
1620-
1621-
#define vsetvl_e16mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 7)
1622-
#define vsetvl_e16m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 0)
1623-
#define vsetvl_e16m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 1)
1624-
#define vsetvl_e16m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 2)
1625-
#define vsetvl_e16m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 3)
1626-
1627-
#define vsetvl_e32m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 0)
1628-
#define vsetvl_e32m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 1)
1629-
#define vsetvl_e32m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 2)
1630-
#define vsetvl_e32m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 3)
1614+
#define __riscv_vsetvl_e8mf4(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 6)
1615+
#define __riscv_vsetvl_e8mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 7)
1616+
#define __riscv_vsetvl_e8m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 0)
1617+
#define __riscv_vsetvl_e8m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 1)
1618+
#define __riscv_vsetvl_e8m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 2)
1619+
#define __riscv_vsetvl_e8m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 3)
1620+
1621+
#define __riscv_vsetvl_e16mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 7)
1622+
#define __riscv_vsetvl_e16m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 0)
1623+
#define __riscv_vsetvl_e16m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 1)
1624+
#define __riscv_vsetvl_e16m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 2)
1625+
#define __riscv_vsetvl_e16m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 3)
1626+
1627+
#define __riscv_vsetvl_e32m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 0)
1628+
#define __riscv_vsetvl_e32m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 1)
1629+
#define __riscv_vsetvl_e32m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 2)
1630+
#define __riscv_vsetvl_e32m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 3)
16311631

16321632
#if __riscv_v_elen >= 64
1633-
#define vsetvl_e8mf8(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 5)
1634-
#define vsetvl_e16mf4(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 6)
1635-
#define vsetvl_e32mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 7)
1636-
1637-
#define vsetvl_e64m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 0)
1638-
#define vsetvl_e64m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 1)
1639-
#define vsetvl_e64m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 2)
1640-
#define vsetvl_e64m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 3)
1633+
#define __riscv_vsetvl_e8mf8(avl) __builtin_rvv_vsetvli((size_t)(avl), 0, 5)
1634+
#define __riscv_vsetvl_e16mf4(avl) __builtin_rvv_vsetvli((size_t)(avl), 1, 6)
1635+
#define __riscv_vsetvl_e32mf2(avl) __builtin_rvv_vsetvli((size_t)(avl), 2, 7)
1636+
1637+
#define __riscv_vsetvl_e64m1(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 0)
1638+
#define __riscv_vsetvl_e64m2(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 1)
1639+
#define __riscv_vsetvl_e64m4(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 2)
1640+
#define __riscv_vsetvl_e64m8(avl) __builtin_rvv_vsetvli((size_t)(avl), 3, 3)
16411641
#endif
16421642

1643-
#define vsetvlmax_e8mf4() __builtin_rvv_vsetvlimax(0, 6)
1644-
#define vsetvlmax_e8mf2() __builtin_rvv_vsetvlimax(0, 7)
1645-
#define vsetvlmax_e8m1() __builtin_rvv_vsetvlimax(0, 0)
1646-
#define vsetvlmax_e8m2() __builtin_rvv_vsetvlimax(0, 1)
1647-
#define vsetvlmax_e8m4() __builtin_rvv_vsetvlimax(0, 2)
1648-
#define vsetvlmax_e8m8() __builtin_rvv_vsetvlimax(0, 3)
1643+
#define __riscv_vsetvlmax_e8mf4() __builtin_rvv_vsetvlimax(0, 6)
1644+
#define __riscv_vsetvlmax_e8mf2() __builtin_rvv_vsetvlimax(0, 7)
1645+
#define __riscv_vsetvlmax_e8m1() __builtin_rvv_vsetvlimax(0, 0)
1646+
#define __riscv_vsetvlmax_e8m2() __builtin_rvv_vsetvlimax(0, 1)
1647+
#define __riscv_vsetvlmax_e8m4() __builtin_rvv_vsetvlimax(0, 2)
1648+
#define __riscv_vsetvlmax_e8m8() __builtin_rvv_vsetvlimax(0, 3)
16491649

1650-
#define vsetvlmax_e16mf2() __builtin_rvv_vsetvlimax(1, 7)
1651-
#define vsetvlmax_e16m1() __builtin_rvv_vsetvlimax(1, 0)
1652-
#define vsetvlmax_e16m2() __builtin_rvv_vsetvlimax(1, 1)
1653-
#define vsetvlmax_e16m4() __builtin_rvv_vsetvlimax(1, 2)
1654-
#define vsetvlmax_e16m8() __builtin_rvv_vsetvlimax(1, 3)
1650+
#define __riscv_vsetvlmax_e16mf2() __builtin_rvv_vsetvlimax(1, 7)
1651+
#define __riscv_vsetvlmax_e16m1() __builtin_rvv_vsetvlimax(1, 0)
1652+
#define __riscv_vsetvlmax_e16m2() __builtin_rvv_vsetvlimax(1, 1)
1653+
#define __riscv_vsetvlmax_e16m4() __builtin_rvv_vsetvlimax(1, 2)
1654+
#define __riscv_vsetvlmax_e16m8() __builtin_rvv_vsetvlimax(1, 3)
16551655

1656-
#define vsetvlmax_e32m1() __builtin_rvv_vsetvlimax(2, 0)
1657-
#define vsetvlmax_e32m2() __builtin_rvv_vsetvlimax(2, 1)
1658-
#define vsetvlmax_e32m4() __builtin_rvv_vsetvlimax(2, 2)
1659-
#define vsetvlmax_e32m8() __builtin_rvv_vsetvlimax(2, 3)
1656+
#define __riscv_vsetvlmax_e32m1() __builtin_rvv_vsetvlimax(2, 0)
1657+
#define __riscv_vsetvlmax_e32m2() __builtin_rvv_vsetvlimax(2, 1)
1658+
#define __riscv_vsetvlmax_e32m4() __builtin_rvv_vsetvlimax(2, 2)
1659+
#define __riscv_vsetvlmax_e32m8() __builtin_rvv_vsetvlimax(2, 3)
16601660

16611661
#if __riscv_v_elen >= 64
1662-
#define vsetvlmax_e8mf8() __builtin_rvv_vsetvlimax(0, 5)
1663-
#define vsetvlmax_e16mf4() __builtin_rvv_vsetvlimax(1, 6)
1664-
#define vsetvlmax_e32mf2() __builtin_rvv_vsetvlimax(2, 7)
1665-
1666-
#define vsetvlmax_e64m1() __builtin_rvv_vsetvlimax(3, 0)
1667-
#define vsetvlmax_e64m2() __builtin_rvv_vsetvlimax(3, 1)
1668-
#define vsetvlmax_e64m4() __builtin_rvv_vsetvlimax(3, 2)
1669-
#define vsetvlmax_e64m8() __builtin_rvv_vsetvlimax(3, 3)
1662+
#define __riscv_vsetvlmax_e8mf8() __builtin_rvv_vsetvlimax(0, 5)
1663+
#define __riscv_vsetvlmax_e16mf4() __builtin_rvv_vsetvlimax(1, 6)
1664+
#define __riscv_vsetvlmax_e32mf2() __builtin_rvv_vsetvlimax(2, 7)
1665+
1666+
#define __riscv_vsetvlmax_e64m1() __builtin_rvv_vsetvlimax(3, 0)
1667+
#define __riscv_vsetvlmax_e64m2() __builtin_rvv_vsetvlimax(3, 1)
1668+
#define __riscv_vsetvlmax_e64m4() __builtin_rvv_vsetvlimax(3, 2)
1669+
#define __riscv_vsetvlmax_e64m8() __builtin_rvv_vsetvlimax(3, 3)
16701670
#endif
16711671

16721672
}] in

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsetvl.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
1313
//
1414
size_t test_vsetvl_e8mf8(size_t avl) {
15-
return vsetvl_e8mf8(avl);
15+
return __riscv_vsetvl_e8mf8(avl);
1616
}
1717

1818
// CHECK-RV64-LABEL: @test_vsetvl_e8mf4(
@@ -21,7 +21,7 @@ size_t test_vsetvl_e8mf8(size_t avl) {
2121
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
2222
//
2323
size_t test_vsetvl_e8mf4(size_t avl) {
24-
return vsetvl_e8mf4(avl);
24+
return __riscv_vsetvl_e8mf4(avl);
2525
}
2626

2727
// CHECK-RV64-LABEL: @test_vsetvl_e8mf2(
@@ -30,7 +30,7 @@ size_t test_vsetvl_e8mf4(size_t avl) {
3030
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
3131
//
3232
size_t test_vsetvl_e8mf2(size_t avl) {
33-
return vsetvl_e8mf2(avl);
33+
return __riscv_vsetvl_e8mf2(avl);
3434
}
3535

3636
// CHECK-RV64-LABEL: @test_vsetvl_e8m1(
@@ -39,7 +39,7 @@ size_t test_vsetvl_e8mf2(size_t avl) {
3939
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
4040
//
4141
size_t test_vsetvl_e8m1(size_t avl) {
42-
return vsetvl_e8m1(avl);
42+
return __riscv_vsetvl_e8m1(avl);
4343
}
4444

4545
// CHECK-RV64-LABEL: @test_vsetvl_e8m2(
@@ -48,7 +48,7 @@ size_t test_vsetvl_e8m1(size_t avl) {
4848
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
4949
//
5050
size_t test_vsetvl_e8m2(size_t avl) {
51-
return vsetvl_e8m2(avl);
51+
return __riscv_vsetvl_e8m2(avl);
5252
}
5353

5454
// CHECK-RV64-LABEL: @test_vsetvl_e8m4(
@@ -57,7 +57,7 @@ size_t test_vsetvl_e8m2(size_t avl) {
5757
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
5858
//
5959
size_t test_vsetvl_e8m4(size_t avl) {
60-
return vsetvl_e8m4(avl);
60+
return __riscv_vsetvl_e8m4(avl);
6161
}
6262

6363
// CHECK-RV64-LABEL: @test_vsetvl_e8m8(
@@ -66,7 +66,7 @@ size_t test_vsetvl_e8m4(size_t avl) {
6666
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
6767
//
6868
size_t test_vsetvl_e8m8(size_t avl) {
69-
return vsetvl_e8m8(avl);
69+
return __riscv_vsetvl_e8m8(avl);
7070
}
7171

7272
// CHECK-RV64-LABEL: @test_vsetvl_e16mf4(
@@ -75,7 +75,7 @@ size_t test_vsetvl_e8m8(size_t avl) {
7575
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
7676
//
7777
size_t test_vsetvl_e16mf4(size_t avl) {
78-
return vsetvl_e16mf4(avl);
78+
return __riscv_vsetvl_e16mf4(avl);
7979
}
8080

8181
// CHECK-RV64-LABEL: @test_vsetvl_e16mf2(
@@ -84,7 +84,7 @@ size_t test_vsetvl_e16mf4(size_t avl) {
8484
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
8585
//
8686
size_t test_vsetvl_e16mf2(size_t avl) {
87-
return vsetvl_e16mf2(avl);
87+
return __riscv_vsetvl_e16mf2(avl);
8888
}
8989

9090
// CHECK-RV64-LABEL: @test_vsetvl_e16m1(
@@ -93,7 +93,7 @@ size_t test_vsetvl_e16mf2(size_t avl) {
9393
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
9494
//
9595
size_t test_vsetvl_e16m1(size_t avl) {
96-
return vsetvl_e16m1(avl);
96+
return __riscv_vsetvl_e16m1(avl);
9797
}
9898

9999
// CHECK-RV64-LABEL: @test_vsetvl_e16m2(
@@ -102,7 +102,7 @@ size_t test_vsetvl_e16m1(size_t avl) {
102102
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
103103
//
104104
size_t test_vsetvl_e16m2(size_t avl) {
105-
return vsetvl_e16m2(avl);
105+
return __riscv_vsetvl_e16m2(avl);
106106
}
107107

108108
// CHECK-RV64-LABEL: @test_vsetvl_e16m4(
@@ -111,7 +111,7 @@ size_t test_vsetvl_e16m2(size_t avl) {
111111
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
112112
//
113113
size_t test_vsetvl_e16m4(size_t avl) {
114-
return vsetvl_e16m4(avl);
114+
return __riscv_vsetvl_e16m4(avl);
115115
}
116116

117117
// CHECK-RV64-LABEL: @test_vsetvl_e16m8(
@@ -120,7 +120,7 @@ size_t test_vsetvl_e16m4(size_t avl) {
120120
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
121121
//
122122
size_t test_vsetvl_e16m8(size_t avl) {
123-
return vsetvl_e16m8(avl);
123+
return __riscv_vsetvl_e16m8(avl);
124124
}
125125

126126
// CHECK-RV64-LABEL: @test_vsetvl_e32mf2(
@@ -129,7 +129,7 @@ size_t test_vsetvl_e16m8(size_t avl) {
129129
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
130130
//
131131
size_t test_vsetvl_e32mf2(size_t avl) {
132-
return vsetvl_e32mf2(avl);
132+
return __riscv_vsetvl_e32mf2(avl);
133133
}
134134

135135
// CHECK-RV64-LABEL: @test_vsetvl_e32m1(
@@ -138,7 +138,7 @@ size_t test_vsetvl_e32mf2(size_t avl) {
138138
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
139139
//
140140
size_t test_vsetvl_e32m1(size_t avl) {
141-
return vsetvl_e32m1(avl);
141+
return __riscv_vsetvl_e32m1(avl);
142142
}
143143

144144
// CHECK-RV64-LABEL: @test_vsetvl_e32m2(
@@ -147,7 +147,7 @@ size_t test_vsetvl_e32m1(size_t avl) {
147147
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
148148
//
149149
size_t test_vsetvl_e32m2(size_t avl) {
150-
return vsetvl_e32m2(avl);
150+
return __riscv_vsetvl_e32m2(avl);
151151
}
152152

153153
// CHECK-RV64-LABEL: @test_vsetvl_e32m4(
@@ -156,7 +156,7 @@ size_t test_vsetvl_e32m2(size_t avl) {
156156
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
157157
//
158158
size_t test_vsetvl_e32m4(size_t avl) {
159-
return vsetvl_e32m4(avl);
159+
return __riscv_vsetvl_e32m4(avl);
160160
}
161161

162162
// CHECK-RV64-LABEL: @test_vsetvl_e32m8(
@@ -165,7 +165,7 @@ size_t test_vsetvl_e32m4(size_t avl) {
165165
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
166166
//
167167
size_t test_vsetvl_e32m8(size_t avl) {
168-
return vsetvl_e32m8(avl);
168+
return __riscv_vsetvl_e32m8(avl);
169169
}
170170

171171
// CHECK-RV64-LABEL: @test_vsetvl_e64m1(
@@ -174,7 +174,7 @@ size_t test_vsetvl_e32m8(size_t avl) {
174174
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
175175
//
176176
size_t test_vsetvl_e64m1(size_t avl) {
177-
return vsetvl_e64m1(avl);
177+
return __riscv_vsetvl_e64m1(avl);
178178
}
179179

180180
// CHECK-RV64-LABEL: @test_vsetvl_e64m2(
@@ -183,7 +183,7 @@ size_t test_vsetvl_e64m1(size_t avl) {
183183
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
184184
//
185185
size_t test_vsetvl_e64m2(size_t avl) {
186-
return vsetvl_e64m2(avl);
186+
return __riscv_vsetvl_e64m2(avl);
187187
}
188188

189189
// CHECK-RV64-LABEL: @test_vsetvl_e64m4(
@@ -192,7 +192,7 @@ size_t test_vsetvl_e64m2(size_t avl) {
192192
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
193193
//
194194
size_t test_vsetvl_e64m4(size_t avl) {
195-
return vsetvl_e64m4(avl);
195+
return __riscv_vsetvl_e64m4(avl);
196196
}
197197

198198
// CHECK-RV64-LABEL: @test_vsetvl_e64m8(
@@ -201,6 +201,6 @@ size_t test_vsetvl_e64m4(size_t avl) {
201201
// CHECK-RV64-NEXT: ret i64 [[TMP0]]
202202
//
203203
size_t test_vsetvl_e64m8(size_t avl) {
204-
return vsetvl_e64m8(avl);
204+
return __riscv_vsetvl_e64m8(avl);
205205
}
206206

0 commit comments

Comments
 (0)