Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -13139,6 +13139,7 @@ def err_riscv_attribute_interrupt_requires_extension : Error<
"RISC-V 'interrupt' attribute '%0' requires extension '%1'">;
def err_riscv_attribute_interrupt_invalid_combination : Error<
"RISC-V 'interrupt' attribute contains invalid combination of interrupt types">;
def err_riscv_builtin_invalid_twiden : Error<"RISC-V XSfmm twiden must be 1, 2 or 4">;

def err_std_source_location_impl_not_found : Error<
"'std::source_location::__impl' was not found; it must be defined before '__builtin_source_location' is called">;
Expand Down
33 changes: 31 additions & 2 deletions clang/lib/Sema/SemaRISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,37 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 15) ||
SemaRef.BuiltinConstantArgMultiple(TheCall, 0, 4);
}
case RISCVVector::BI__builtin_rvv_sf_vtzero_t:
return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 15);
case RISCVVector::BI__builtin_rvv_sf_vtzero_t: {
llvm::APSInt Log2SEWResult;
llvm::APSInt TWidenResult;
if (SemaRef.BuiltinConstantArg(TheCall, 3, Log2SEWResult) ||
SemaRef.BuiltinConstantArg(TheCall, 4, TWidenResult))
return true;

int Log2SEW = Log2SEWResult.getSExtValue();
int TWiden = TWidenResult.getSExtValue();
int TEW = (1 << Log2SEW) * TWiden;

// 3 <= LogSEW <= 6
if (SemaRef.BuiltinConstantArgRange(TheCall, 3, 3, 6))
return true;

// TWiden
if (TWiden != 1 && TWiden != 2 && TWiden != 4)
return Diag(TheCall->getBeginLoc(),
diag::err_riscv_builtin_invalid_twiden);

// For TEW = 8, mtd can be 0~15.
// For TEW = 16 or 64, mtd can only be 0, 2, 4, 6, 8, 10, 12, 14.
// For TEW = 32, mtd can only be 0, 4, 8, 12.
if (TEW == 8)
return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 15);
if (TEW == 16 || TEW == 64)
return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 15) ||
SemaRef.BuiltinConstantArgMultiple(TheCall, 0, 2);
return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 15) ||
SemaRef.BuiltinConstantArgMultiple(TheCall, 0, 4);
}
case RISCVVector::BI__builtin_rvv_vget_v: {
ASTContext::BuiltinVectorTypeInfo ResVecInfo =
Context.getBuiltinVectorTypeInfo(cast<BuiltinType>(
Expand Down
4 changes: 4 additions & 0 deletions clang/test/Sema/sifive-xsfmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ void test(vfloat32m8_t arg0, vuint8m8_t arg1) {
__riscv_sf_mm_e5m2_e4m3(20, arg1, arg1, 1, 2, 3); /* expected-error {{argument value 20 is outside the valid range [0, 15]}} */
__riscv_sf_mm_u_u(24, arg1, arg1, 1, 2, 3); /* expected-error {{argument value 24 is outside the valid range [0, 15]}} */
__riscv_sf_vtzero_t_e8w1(18, 0, 0); /* expected-error {{argument value 18 is outside the valid range [0, 15]}} */
__riscv_sf_vtzero_t_e16w1(3, 0, 0); /* expected-error {{argument should be a multiple of 2}} */
__riscv_sf_vtzero_t_e16w2(3, 0, 0); /* expected-error {{argument should be a multiple of 4}} */
__riscv_sf_vtzero_t_e32w1(5, 0, 0); /* expected-error {{argument should be a multiple of 4}} */
__riscv_sf_vtzero_t_e32w2(5, 0, 0); /* expected-error {{argument should be a multiple of 2}} */
}
Loading