Skip to content

Commit 7e2e22c

Browse files
committed
[LLVM][RVV 0.7.1] Use T-Head suggested naming schema (ruyisdk#30)
* [LLVM][RVV 0.7.1] `xtheadv` -> `xtheadvector` * [LLVM][RVV 0.7.1] MC names (1/N) * [LLVM][RVV 0.7.1] MC names (2/N) * [LLVM][RVV 0.7.1] MC names (3/N) * [LLVM][RVV 0.7.1] MC names (4/N) * [LLVM][RVV 0.7.1] LLVM intrinsic names (5/N) * [LLVM][RVV 0.7.1] LLVM intrinsic names (6/N) * [LLVM][RVV 0.7.1] Pass all MC tests * [LLVM][RVV 0.7.1] Pass all LLVM CodeGen tests * [LLVM][RVV 0.7.1] `llvm.riscv.xv*` -> `llvm.riscv.th.v*` * [Clang][RVV 0.7.1] `xv*` -> `th_v*` * [Clang][RVV 0.7.1] Update tests * [Clang][RVV 0.7.1] Update macros and headers with T-Head upstream Ref: riscv-non-isa/rvv-intrinsic-doc#298 * [LLVM][RVV 0.7.1] Rename * [Clang][RVV 0.7.1] Fix pragma * [LLVM][RVV 0.7.1] Fix vleff tests
1 parent 4ee4c49 commit 7e2e22c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+13458
-13465
lines changed

clang/include/clang/Basic/riscv_vector_xtheadv.td

+39-39
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void __riscv_vwrite_csr(enum RVV_CSR __csr, unsigned long __value) {
5959
}
6060
}
6161
}] in
62-
def xvread_xvwrite_csr: RVVHeader;
62+
def th_vread_th_vwrite_csr: RVVHeader;
6363

6464
// vsetvl/vsetvlmax are a macro because they require constant integers in SEW
6565
// and LMUL.
@@ -68,55 +68,55 @@ let HeaderCode =
6868

6969
/* These two builtins comes from the 1.0 implementation, */
7070
/* for compatibility, we forward these calls to the corresponding 0.7 builtins. */
71-
#define __builtin_rvv_vsetvli(avl, sew, lmul) __builtin_rvv_xvsetvl((size_t)(avl), sew, lmul)
72-
#define __builtin_rvv_vsetvlimax(sew, lmul) __builtin_rvv_xvsetvlmax(sew, lmul)
71+
#define __builtin_rvv_vsetvli(avl, sew, lmul) __builtin_rvv_th_vsetvl((size_t)(avl), sew, lmul)
72+
#define __builtin_rvv_vsetvlimax(sew, lmul) __builtin_rvv_th_vsetvlmax(sew, lmul)
7373

74-
#define __riscv_vsetvl_e8m1(avl) __builtin_rvv_xvsetvl((size_t)(avl), 0, 0)
75-
#define __riscv_vsetvl_e8m2(avl) __builtin_rvv_xvsetvl((size_t)(avl), 0, 1)
76-
#define __riscv_vsetvl_e8m4(avl) __builtin_rvv_xvsetvl((size_t)(avl), 0, 2)
77-
#define __riscv_vsetvl_e8m8(avl) __builtin_rvv_xvsetvl((size_t)(avl), 0, 3)
74+
#define __riscv_vsetvl_e8m1(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 0, 0)
75+
#define __riscv_vsetvl_e8m2(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 0, 1)
76+
#define __riscv_vsetvl_e8m4(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 0, 2)
77+
#define __riscv_vsetvl_e8m8(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 0, 3)
7878

79-
#define __riscv_vsetvl_e16m1(avl) __builtin_rvv_xvsetvl((size_t)(avl), 1, 0)
80-
#define __riscv_vsetvl_e16m2(avl) __builtin_rvv_xvsetvl((size_t)(avl), 1, 1)
81-
#define __riscv_vsetvl_e16m4(avl) __builtin_rvv_xvsetvl((size_t)(avl), 1, 2)
82-
#define __riscv_vsetvl_e16m8(avl) __builtin_rvv_xvsetvl((size_t)(avl), 1, 3)
79+
#define __riscv_vsetvl_e16m1(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 1, 0)
80+
#define __riscv_vsetvl_e16m2(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 1, 1)
81+
#define __riscv_vsetvl_e16m4(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 1, 2)
82+
#define __riscv_vsetvl_e16m8(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 1, 3)
8383

84-
#define __riscv_vsetvl_e32m1(avl) __builtin_rvv_xvsetvl((size_t)(avl), 2, 0)
85-
#define __riscv_vsetvl_e32m2(avl) __builtin_rvv_xvsetvl((size_t)(avl), 2, 1)
86-
#define __riscv_vsetvl_e32m4(avl) __builtin_rvv_xvsetvl((size_t)(avl), 2, 2)
87-
#define __riscv_vsetvl_e32m8(avl) __builtin_rvv_xvsetvl((size_t)(avl), 2, 3)
84+
#define __riscv_vsetvl_e32m1(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 2, 0)
85+
#define __riscv_vsetvl_e32m2(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 2, 1)
86+
#define __riscv_vsetvl_e32m4(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 2, 2)
87+
#define __riscv_vsetvl_e32m8(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 2, 3)
8888

8989
#if __riscv_v_elen >= 64
90-
#define __riscv_vsetvl_e64m1(avl) __builtin_rvv_xvsetvl((size_t)(avl), 3, 0)
91-
#define __riscv_vsetvl_e64m2(avl) __builtin_rvv_xvsetvl((size_t)(avl), 3, 1)
92-
#define __riscv_vsetvl_e64m4(avl) __builtin_rvv_xvsetvl((size_t)(avl), 3, 2)
93-
#define __riscv_vsetvl_e64m8(avl) __builtin_rvv_xvsetvl((size_t)(avl), 3, 3)
90+
#define __riscv_vsetvl_e64m1(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 3, 0)
91+
#define __riscv_vsetvl_e64m2(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 3, 1)
92+
#define __riscv_vsetvl_e64m4(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 3, 2)
93+
#define __riscv_vsetvl_e64m8(avl) __builtin_rvv_th_vsetvl((size_t)(avl), 3, 3)
9494
#endif
9595

96-
#define __riscv_vsetvlmax_e8m1() __builtin_rvv_xvsetvlmax(0, 0)
97-
#define __riscv_vsetvlmax_e8m2() __builtin_rvv_xvsetvlmax(0, 1)
98-
#define __riscv_vsetvlmax_e8m4() __builtin_rvv_xvsetvlmax(0, 2)
99-
#define __riscv_vsetvlmax_e8m8() __builtin_rvv_xvsetvlmax(0, 3)
96+
#define __riscv_vsetvlmax_e8m1() __builtin_rvv_th_vsetvlmax(0, 0)
97+
#define __riscv_vsetvlmax_e8m2() __builtin_rvv_th_vsetvlmax(0, 1)
98+
#define __riscv_vsetvlmax_e8m4() __builtin_rvv_th_vsetvlmax(0, 2)
99+
#define __riscv_vsetvlmax_e8m8() __builtin_rvv_th_vsetvlmax(0, 3)
100100

101-
#define __riscv_vsetvlmax_e16m1() __builtin_rvv_xvsetvlmax(1, 0)
102-
#define __riscv_vsetvlmax_e16m2() __builtin_rvv_xvsetvlmax(1, 1)
103-
#define __riscv_vsetvlmax_e16m4() __builtin_rvv_xvsetvlmax(1, 2)
104-
#define __riscv_vsetvlmax_e16m8() __builtin_rvv_xvsetvlmax(1, 3)
101+
#define __riscv_vsetvlmax_e16m1() __builtin_rvv_th_vsetvlmax(1, 0)
102+
#define __riscv_vsetvlmax_e16m2() __builtin_rvv_th_vsetvlmax(1, 1)
103+
#define __riscv_vsetvlmax_e16m4() __builtin_rvv_th_vsetvlmax(1, 2)
104+
#define __riscv_vsetvlmax_e16m8() __builtin_rvv_th_vsetvlmax(1, 3)
105105

106-
#define __riscv_vsetvlmax_e32m1() __builtin_rvv_xvsetvlmax(2, 0)
107-
#define __riscv_vsetvlmax_e32m2() __builtin_rvv_xvsetvlmax(2, 1)
108-
#define __riscv_vsetvlmax_e32m4() __builtin_rvv_xvsetvlmax(2, 2)
109-
#define __riscv_vsetvlmax_e32m8() __builtin_rvv_xvsetvlmax(2, 3)
106+
#define __riscv_vsetvlmax_e32m1() __builtin_rvv_th_vsetvlmax(2, 0)
107+
#define __riscv_vsetvlmax_e32m2() __builtin_rvv_th_vsetvlmax(2, 1)
108+
#define __riscv_vsetvlmax_e32m4() __builtin_rvv_th_vsetvlmax(2, 2)
109+
#define __riscv_vsetvlmax_e32m8() __builtin_rvv_th_vsetvlmax(2, 3)
110110

111111
#if __riscv_v_elen >= 64
112-
#define __riscv_vsetvlmax_e64m1() __builtin_rvv_xvsetvlmax(3, 0)
113-
#define __riscv_vsetvlmax_e64m2() __builtin_rvv_xvsetvlmax(3, 1)
114-
#define __riscv_vsetvlmax_e64m4() __builtin_rvv_xvsetvlmax(3, 2)
115-
#define __riscv_vsetvlmax_e64m8() __builtin_rvv_xvsetvlmax(3, 3)
112+
#define __riscv_vsetvlmax_e64m1() __builtin_rvv_th_vsetvlmax(3, 0)
113+
#define __riscv_vsetvlmax_e64m2() __builtin_rvv_th_vsetvlmax(3, 1)
114+
#define __riscv_vsetvlmax_e64m4() __builtin_rvv_th_vsetvlmax(3, 2)
115+
#define __riscv_vsetvlmax_e64m8() __builtin_rvv_th_vsetvlmax(3, 3)
116116
#endif
117117

118118
}] in
119-
def xvsetvl_macro: RVVHeader;
119+
def th_vsetvl_macro: RVVHeader;
120120

121121
let HasBuiltinAlias = false,
122122
HasVL = false,
@@ -125,14 +125,14 @@ let HasBuiltinAlias = false,
125125
Log2LMUL = [0],
126126
ManualCodegen = [{IntrinsicTypes = {ResultType};}] in // Set XLEN type
127127
{
128-
def xvsetvl : RVVBuiltin<"", "zzKzKz", "i">;
129-
def xvsetvlmax : RVVBuiltin<"", "zKzKz", "i">;
128+
def th_vsetvl : RVVBuiltin<"", "zzKzKz", "i">;
129+
def th_vsetvlmax : RVVBuiltin<"", "zKzKz", "i">;
130130
}
131131

132132
//===----------------------------------------------------------------------===//
133133
// 12. Vector Integer Arithmetic Instructions
134134
//===----------------------------------------------------------------------===//
135135

136136
let UnMaskedPolicyScheme = HasPassthruOperand in {
137-
defm xvadd : RVVIntBinBuiltinSet;
137+
defm th_vadd : RVVIntBinBuiltinSet;
138138
}

clang/lib/Basic/Targets/RISCV.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,9 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
206206
Builder.defineMacro("__riscv_v_intrinsic", Twine(getVersionValue(0, 12)));
207207
}
208208

209-
if (ISAInfo->hasExtension("xtheadv")) {
210-
// TODO: should we define __riscv_vector here?
211-
Builder.defineMacro("__riscv_vector");
212-
Builder.defineMacro("__riscv_vector_xtheadv");
213-
// TODO: which intrinsic version? reuse the v0.11 for now.
214-
Builder.defineMacro("__riscv_v_intrinsic", Twine(getVersionValue(0, 11)));
209+
if (ISAInfo->hasExtension("xtheadvector")) {
210+
// https://github.com/riscv-non-isa/rvv-intrinsic-doc/pull/298/files
211+
Builder.defineMacro("__riscv_th_v_intrinsic", Twine(getVersionValue(0, 11)));
215212
}
216213

217214
auto VScale = getVScaleRange(Opts);

clang/lib/Headers/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,12 @@ if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST LLVM_TARGETS_TO_BUILD)
419419
)
420420
endif()
421421
if(RISCV IN_LIST LLVM_TARGETS_TO_BUILD)
422-
# Generate riscv_vector.h and riscv_vector_xtheadv.h
422+
# Generate riscv_vector.h and riscv_th_vector.h
423423
clang_generate_header(-gen-riscv-vector-header riscv_vector.td riscv_vector.h)
424-
clang_generate_header(-gen-riscv-xtheadv-header riscv_vector_xtheadv.td riscv_vector_xtheadv.h)
424+
clang_generate_header(-gen-riscv-xtheadv-header riscv_vector_xtheadv.td riscv_th_vector.h)
425425
list(APPEND riscv_generated_files
426426
"${CMAKE_CURRENT_BINARY_DIR}/riscv_vector.h"
427-
"${CMAKE_CURRENT_BINARY_DIR}/riscv_vector_xtheadv.h"
427+
"${CMAKE_CURRENT_BINARY_DIR}/riscv_th_vector.h"
428428
)
429429
endif()
430430

clang/lib/Parse/ParsePragma.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -4125,7 +4125,7 @@ void PragmaMaxTokensTotalHandler::HandlePragma(Preprocessor &PP,
41254125

41264126
// Handle '#pragma clang riscv intrinsic vector'.
41274127
// '#pragma clang riscv intrinsic sifive_vector'
4128-
// '#pragma clang riscv intrinsic xtheadv_vector'.
4128+
// '#pragma clang riscv intrinsic thead_vector'.
41294129
void PragmaRISCVHandler::HandlePragma(Preprocessor &PP,
41304130
PragmaIntroducer Introducer,
41314131
Token &FirstToken) {
@@ -4142,10 +4142,10 @@ void PragmaRISCVHandler::HandlePragma(Preprocessor &PP,
41424142
PP.Lex(Tok);
41434143
II = Tok.getIdentifierInfo();
41444144
if (!II || !(II->isStr("vector") || II->isStr("sifive_vector") ||
4145-
II->isStr("xtheadv_vector"))) {
4145+
II->isStr("thead_vector"))) {
41464146
PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)
41474147
<< PP.getSpelling(Tok) << "riscv" << /*Expected=*/true
4148-
<< "'vector', 'sifive_vector' or 'xtheadv_vector'";
4148+
<< "'vector', 'sifive_vector' or 'thead_vector'";
41494149
return;
41504150
}
41514151

@@ -4160,6 +4160,6 @@ void PragmaRISCVHandler::HandlePragma(Preprocessor &PP,
41604160
Actions.RISCV().DeclareRVVBuiltins = true;
41614161
else if (II->isStr("sifive_vector"))
41624162
Actions.RISCV().DeclareSiFiveVectorBuiltins = true;
4163-
else if (II->isStr("xtheadv_vector"))
4163+
else if (II->isStr("thead_vector"))
41644164
Actions.RISCV().DeclareRISCVXTHeadVBuiltins = true;
41654165
}

clang/lib/Sema/SemaRISCV.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -656,10 +656,10 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
656656
case RISCVVector::BI__builtin_rvv_vsetvlimax:
657657
return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 3) ||
658658
CheckLMUL(TheCall, 1, true);
659-
case RISCVVector::BI__builtin_rvv_xvsetvl:
659+
case RISCVVector::BI__builtin_rvv_th_vsetvl:
660660
return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 3) ||
661661
CheckLMUL(TheCall, 2, false);
662-
case RISCVVector::BI__builtin_rvv_xvsetvlmax:
662+
case RISCVVector::BI__builtin_rvv_th_vsetvlmax:
663663
return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 3) ||
664664
CheckLMUL(TheCall, 1, false);
665665
case RISCVVector::BI__builtin_rvv_vget_v: {

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/rvv-error.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// RUN: %clang_cc1 -triple riscv64 -target-feature +xtheadv -disable-O0-optnone -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck --check-prefix=CHECK-RV64V %s
1+
// RUN: %clang_cc1 -triple riscv64 -target-feature +xtheadvector -disable-O0-optnone -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck --check-prefix=CHECK-RV64V %s
22
// RUN: not %clang_cc1 -triple riscv64 -emit-llvm-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-RV64-ERR
33

44
// CHECK-RV64V-LABEL: @test(
55
// CHECK-RV64V-NEXT: entry:
6-
// CHECK-RV64V-NEXT: [[TMP0:%.*]] = call i64 @llvm.riscv.xvsetvl.i64(i64 1, i64 0, i64 0)
6+
// CHECK-RV64V-NEXT: [[TMP0:%.*]] = call i64 @llvm.riscv.th.vsetvl.i64(i64 1, i64 0, i64 0)
77
// CHECK-RV64V-NEXT: [[CONV:%.*]] = trunc i64 [[TMP0]] to i32
88
// CHECK-RV64V-NEXT: ret i32 [[CONV]]
99
//
1010

11-
// CHECK-RV64-ERR: error: builtin requires at least one of the following extensions to be enabled: 'Xtheadv'
11+
// CHECK-RV64-ERR: error: builtin requires at least one of the following extensions to be enabled: 'Xtheadvector'
1212

13-
#include <riscv_vector_xtheadv.h>
13+
#include <riscv_th_vector.h>
1414

1515
int test() {
1616
return __builtin_rvv_vsetvli(1, 0, 0); // e8m1

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/rvv-errors.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 %s -triple=riscv64 -target-feature +xtheadv -fsyntax-only -verify
1+
// RUN: %clang_cc1 %s -triple=riscv64 -target-feature +xtheadvector -fsyntax-only -verify
22

33
#include <riscv_vector.h>
44

clang/test/CodeGen/RISCV/rvv0p71-intrinsics-handcrafted/rvv-intrinsic-datatypes.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// RUN: %clang_cc1 -triple riscv64 -target-feature +xtheadv \
1+
// RUN: %clang_cc1 -triple riscv64 -target-feature +xtheadvector \
22
// RUN: -O0 -emit-llvm %s -o - | FileCheck %s
33

44
#include <riscv_vector.h>
55

6-
// This test case tests the typedef generated under riscv_vector_xtheadv.h
6+
// This test case tests the typedef generated under riscv_th_vector.h
77

88
// CHECK-LABEL: define dso_local void @_Z3foov
99
// CHECK-SAME: () #[[ATTR0:[0-9]+]] {

clang/test/Driver/riscv-arch.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@
415415
// RUN: FileCheck -check-prefix=RV32-V-GOODVERS %s
416416
// RV32-V-GOODVERS: "-target-feature" "+v"
417417

418-
// RUN: %clang --target=riscv32-unknown-elf -march=rv32i_xtheadv -### %s -c 2>&1 | \
418+
// RUN: %clang --target=riscv32-unknown-elf -march=rv32i_xtheadvector -### %s -c 2>&1 | \
419419
// RUN: FileCheck -check-prefix=RV32-V0P7-GOODVERS %s
420-
// RV32-V0P7-GOODVERS: "-target-feature" "+xtheadv"
420+
// RV32-V0P7-GOODVERS: "-target-feature" "+xtheadvector"
421421

422422
// RUN: not %clang --target=riscv32-unknown-elf -march=rv32iv1p0_zvl32b0p1 -### %s -c 2>&1 | \
423423
// RUN: FileCheck -check-prefix=RV32-ZVL-BADVERS %s

clang/test/Preprocessor/riscv-target-features.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -883,12 +883,13 @@
883883
// CHECK-ZCE-EXT: __riscv_zce 1000000{{$}}
884884

885885
// RUN: %clang -target riscv32-unknown-linux-gnu \
886-
// RUN: -march=rv32i_xtheadv -x c -E -dM %s \
886+
// RUN: -march=rv32i_xtheadvector -x c -E -dM %s \
887887
// RUN: -o - | FileCheck --check-prefix=CHECK-V0P7-EXT %s
888888
// RUN: %clang -target riscv64-unknown-linux-gnu \
889-
// RUN: -march=rv64i_xtheadv -x c -E -dM %s \
889+
// RUN: -march=rv64i_xtheadvector -x c -E -dM %s \
890890
// RUN: -o - | FileCheck --check-prefix=CHECK-V0P7-EXT %s
891-
// CHECK-V0P7-EXT: __riscv_xtheadv 7000{{$}}
891+
// CHECK-V0P7-EXT: __riscv_th_v_intrinsic 11000{{$}}
892+
// CHECK-V0P7-EXT: __riscv_xtheadvector 7000{{$}}
892893

893894
// RUN: %clang --target=riscv32-unknown-linux-gnu \
894895
// RUN: -march=rv32izcf1p0 -E -dM %s \

clang/test/Sema/riscv-bad-intrinsic-pragma.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: 2>&1 | FileCheck %s
33

44
#pragma clang riscv intrinsic vvvv
5-
// CHECK: warning: unexpected argument 'vvvv' to '#pragma riscv'; expected 'vector', 'sifive_vector' or 'xtheadv_vector' [-Wignored-pragmas]
5+
// CHECK: warning: unexpected argument 'vvvv' to '#pragma riscv'; expected 'vector', 'sifive_vector' or 'thead_vector' [-Wignored-pragmas]
66

77
#pragma clang riscv what + 3241
88
// CHECK: warning: unexpected argument 'what' to '#pragma riscv'; expected 'intrinsic' [-Wignored-pragmas]

clang/utils/TableGen/RISCVVEmitter.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class RVVEmitter {
102102
public:
103103
RVVEmitter(RecordKeeper &R) : Records(R) {}
104104

105-
/// Emit riscv_vector.h or riscv_vector_xtheadv.h
105+
/// Emit riscv_vector.h or riscv_th_vector.h
106106
void createHeader(raw_ostream &o, clang::RVVHeaderType Type);
107107

108108
/// Emit all the __builtin prototypes and code needed by Sema.
@@ -330,11 +330,12 @@ void RVVEmitter::createHeader(raw_ostream &OS, clang::RVVHeaderType Type) {
330330
" */\n\n";
331331

332332
if (Type == clang::RVVHeaderType::RVV) {
333-
// `__riscv_vector_xtheadv` is defined in `RISCVTargetInfo::getTargetDefines`
334-
// If in `riscv_vector.h` we found that the xtheadv extension is required and enabled,
335-
// we forward the include directive to the real header containing intrinsics for xtheadv.
336-
OS << "#ifdef __riscv_vector_xtheadv\n";
337-
OS << "#include <riscv_vector_xtheadv.h>\n";
333+
// `__riscv_th_v_intrinsic` is defined in `RISCVTargetInfo::getTargetDefines`
334+
// If in `riscv_vector.h` we found that the xtheadvector extension is required and enabled,
335+
// we forward the include directive to the desired one.
336+
// https://github.com/riscv-non-isa/rvv-intrinsic-doc/pull/298/files
337+
OS << "#if defined (__riscv_xtheadvector) && defined (__riscv_th_v_intrinsic)\n";
338+
OS << "#include <riscv_th_vector.h>\n";
338339
OS << "#else\n\n";
339340
// Otherwise, we include the real header containing intrinsics for RVV 1.0
340341
}
@@ -346,8 +347,8 @@ void RVVEmitter::createHeader(raw_ostream &OS, clang::RVVHeaderType Type) {
346347
OS << "#include <stddef.h>\n\n";
347348

348349
if (Type == clang::RVVHeaderType::XTHEADV_VECTOR) {
349-
OS << "#ifndef __riscv_vector_xtheadv\n";
350-
OS << "#error \"Vector intrinsics require the vector extension.\"\n";
350+
OS << "#ifndef __riscv_xtheadvector\n";
351+
OS << "#error \"Vector intrinsics require either Vector extension or XTheadVector extension.\"\n";
351352
OS << "#endif\n\n";
352353
}
353354

@@ -360,7 +361,7 @@ void RVVEmitter::createHeader(raw_ostream &OS, clang::RVVHeaderType Type) {
360361
OS << "#pragma clang riscv intrinsic vector\n\n";
361362
break;
362363
case clang::RVVHeaderType::XTHEADV_VECTOR:
363-
OS << "#pragma clang riscv intrinsic xtheadv_vector\n\n";
364+
OS << "#pragma clang riscv intrinsic thead_vector\n\n";
364365
break;
365366
}
366367

@@ -437,7 +438,7 @@ void RVVEmitter::createHeader(raw_ostream &OS, clang::RVVHeaderType Type) {
437438
OS << "#endif // __RISCV_VECTOR_H\n";
438439

439440
if (Type == clang::RVVHeaderType::RVV) {
440-
OS << "#endif // __riscv_vector_xtheadv\n\n";
441+
OS << "#endif // __riscv_xtheadvector\n\n";
441442
}
442443
}
443444

@@ -451,7 +452,7 @@ void RVVEmitter::createBuiltins(raw_ostream &OS, clang::RVVHeaderType Type) {
451452
OS << "#if defined(TARGET_BUILTIN) && !defined(RISCVV_BUILTIN)\n";
452453
OS << "#define RISCVV_BUILTIN(ID, TYPE, ATTRS) TARGET_BUILTIN(ID, TYPE, "
453454
"ATTRS, \""
454-
<< (Type == clang::RVVHeaderType::RVV ? "zve32x" : "xtheadv") << "\")\n";
455+
<< (Type == clang::RVVHeaderType::RVV ? "zve32x" : "xtheadvector") << "\")\n";
455456
OS << "#endif\n";
456457
for (auto &Def : Defs) {
457458
auto P =

clang/utils/TableGen/TableGenBackends.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace clang {
2727
// Decide whether to emit header code
2828
// `#pragma clang riscv intrinsic vector` for RVV 1.0 (the `RVV`),
2929
// or
30-
// `#pragma clang riscv intrinsic xtheadv_vector` for RVV 0.7.1 (the
30+
// `#pragma clang riscv intrinsic thead_vector` for RVV 0.7.1 (the
3131
// `XTHEADV_VECTOR`).
3232
enum RVVHeaderType : uint8_t { RVV, XTHEADV_VECTOR };
3333

0 commit comments

Comments
 (0)