aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaChecking.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-08-20[Sema] Modernize Usage (NFC)Kazu Hirata1-2/+2
2023-08-17[clang][SVE] Rename isVLSTBuiltinType, NFCJianjian GUAN1-3/+3
Since we also have VLST for rvv now, it is not clear to keep using `isVLSTBuiltinType`, so I added prefix SVE to it. Reviewed By: paulwalker-arm Differential Revision: https://reviews.llvm.org/D158045
2023-08-12[RISCV] Rewrite CheckInvalidVLENandLMUL to avoid floating point.Craig Topper1-8/+18
This avoids needing an FP value to represent LMUL. Reviewed By: 4vtomat Differential Revision: https://reviews.llvm.org/D157651
2023-08-11clang: Add __builtin_elementwise_sqrtMatt Arsenault1-0/+1
This will be used in the opencl builtin headers to provide direct intrinsic access with proper !fpmath metadata. https://reviews.llvm.org/D156737
2023-08-11[clang][Sema] Skip access check on arrays of zero-length elementdingfei1-1/+1
Bound check on array of zero-sized element isn't meaningful. Fixes https://github.com/llvm/llvm-project/issues/64564 Reviewed By: jacquesguan Differential Revision: https://reviews.llvm.org/D157584
2023-08-11[C23] Rename C2x->C23 in diagnosticsAaron Ballman1-1/+1
This renames C2x to C23 in diagnostic identifiers and messages. The changes were made mechanically.
2023-08-11[C23] Rename C2x -> C23; NFCAaron Ballman1-5/+5
This does the rename for most internal uses of C2x, but does not rename or reword diagnostics (those will be done in a follow-up). I also updated standards references and citations to the final wording in the standard.
2023-08-09[Clang][AArch64] Add diagnostic for calls from non-ZA to shared-ZA functions.Sander de Smalen1-0/+16
The caller is required to have ZA state if it wants to share it with a callee. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D157270
2023-08-09[Clang][AArch64] Diagnostics for SME attributes when target doesn't have 'sme'Sander de Smalen1-2/+16
This patch adds error diagnostics to Clang when code uses the AArch64 SME attributes without specifying 'sme' as available target attribute. * Function definitions marked as '__arm_streaming', '__arm_locally_streaming', '__arm_shared_za' or '__arm_new_za' will by definition use or require SME instructions. * Calls from non-streaming functions to streaming-functions require the compiler to enable/disable streaming-SVE mode around the call-site. In some cases we can accept the SME attributes without having 'sme' enabled: * Function declaration can have the SME attributes. * Definitions can be __arm_streaming_compatible since the generated code should execute on processing elements without SME. Reviewed By: paulwalker-arm Differential Revision: https://reviews.llvm.org/D157269
2023-08-09[Clang][LoongArch] Use the ClangBuiltin class to automatically generate ↵wanglei1-48/+2
support for CBE and CFE Fixed the type modifier (L->W), removed redundant feature checking code since the feature has already been checked in `EmitBuiltinExpr`. And Cleaned up unused diagnostic information. Reviewed By: SixWeining Differential Revision: https://reviews.llvm.org/D156866
2023-08-08[RISCV] Support vector crypto extension C intrinsics4vtomat1-0/+92
Depends on D141672, D138809 Differential Revision: https://reviews.llvm.org/D138810
2023-08-04[RISCV] Support overloaded version ntlh intrinsic functionPiyou Chen1-2/+6
Here is the proposal https://github.com/riscv-non-isa/riscv-c-api-doc/pull/47. The version that omit the domain argument imply domain=__RISCV_NTLH_ALL. ``` type __riscv_ntl_load (type *ptr); void __riscv_ntl_store (type *ptr, type val); ``` Reviewed By: kito-cheng, craig.topper Differential Revision: https://reviews.llvm.org/D156221
2023-07-31clang: Add elementwise bitreverse builtinJoshua Batista1-0/+20
Add codegen for llvm bitreverse elementwise builtin The bitreverse elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types, or too many inputs. The new builtin is restricted to integer types only. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D156357
2023-07-24 clang: Add elementwise pow builtinJoshua Batista1-0/+16
Add codegen for llvm pow elementwise builtin The pow elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types, or too many inputs. The new builtin is restricted to floating point types only. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D153310
2023-07-20[Clang][AArch64][SME] Add ZA zeroing intrinsicsBryan Chan1-0/+4
This patch adds support for the following SME ACLE intrinsics (as defined in https://arm-software.github.io/acle/main/acle.html): - svzero_mask_za - svzero_za Co-authored-by: Sagar Kulkarni <sagar.kulkarni1@huawei.com> Reviewed By: sdesmalen Differential Revision: https://reviews.llvm.org/D134677
2023-07-20[X86] Add SM3 instructions.Freddy Ye1-0/+1
For more details about these instructions, please refer to the latest ISE document: https://www.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html Reviewed By: pengfei Differential Revision: https://reviews.llvm.org/D155147
2023-07-19[RISCV] Upgrade Zvfh version to 1.0 and move out of experimental state.Craig Topper1-1/+1
This has been ratified according to https://wiki.riscv.org/display/HOME/Recently+Ratified+Extensions Differential Revision: https://reviews.llvm.org/D155668
2023-07-18[Clang][RISCV] Improve diagnostic message for full multiply intrinsicseopXD1-0/+67
The full multiply intrinsics are not included for EEW=64 in Zve64*. They require the V extension to be enabled. This commit improves diagnostic message from ``` <source>:4:10: error: call to undeclared function '__riscv_vsmul_vv_i64m1'; 4 | return __riscv_vsmul_vv_i64m1(op1, op2, __RISCV_VXRM_RNU, vl); ``` to ``` test.c:5:10: error: builtin requires: v 5 | return __riscv_vsmul_vv_i64m1(op1, op2, __RISCV_VXRM_RNU, vl); ``` Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D155416
2023-07-18[Clang][RISCV] Guard RVV intrinsics types that is not available when ELEN < 64eopXD1-1/+4
(ELEN, LMUL) pairs of (8, mf8), (16, mf4), (32, mf2), (64, m1) requires at least `zve64x`. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D155414
2023-07-18[RISCV] Remove unnecessary _32 and _64 suffixes from some scalar crypto ↵Craig Topper1-5/+5
builtins. The names of these builtins aren't ambiguous so they don't need the suffix.
2023-07-14[clang][Sema] Add fixit for scoped enum format errorAlex Brachet1-3/+12
This helps transition code bases to handle the new warning added in 3632e2f5179 Before: ``` clang/test/FixIt/format.cpp:10:16: warning: format specifies type 'int' but the argument has type 'N::E' [-Wformat] 10 | printf("%d", N::E::One); // expected-warning{{format specifies type 'int' but the argument has type 'N::E'}} | ~~ ^~~~~~~~~ | %d ``` After: ``` clang/test/FixIt/format.cpp:10:16: warning: format specifies type 'int' but the argument has type 'N::E' [-Wformat] 10 | printf("%d", N::E::One); // expected-warning{{format specifies type 'int' but the argument has type 'N::E'}} | ~~ ^~~~~~~~~ | static_cast<int>( ) ``` Differential Revision: https://reviews.llvm.org/D153623
2023-07-14[clang][Sema] Suggest static_cast in C++ codeAlex Brachet1-3/+3
This patch changes the -Wformat diagnostic to suggest static_cast over a C-style cast for {,Objective}C++ when recommending the argument be casted rather than changing the format string. Before: ``` clang/test/FixIt/format.mm:11:16: warning: format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'wchar_t' [-Wformat] 11 | NSLog(@"%C", wchar_data); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}} | ~~ ^~~~~~~~~~ | (unsigned short) ``` After: ``` clang/test/FixIt/format.mm:11:16: warning: format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'wchar_t' [-Wformat] 11 | NSLog(@"%C", wchar_data); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}} | ~~ ^~~~~~~~~~ | static_cast<unsigned short>( ) ``` Differential Revision: https://reviews.llvm.org/D153622
2023-07-14[RISCV] Fix required features checking with empty stringJim Lin1-1/+1
In our downstream, we define some intrinsics that don't require any extra extension enabled. Such as TARGET_BUILTIN(__builtin_riscv_xxx, "LiLi", "nc", "") But `split` function's `KeepEmpty` argument is True. Got the error message error: builtin requires at least one of the following extensions support to be enabled : '' when we use our customized intrinsic. Reviewed By: craig.topper, wangpc Differential Revision: https://reviews.llvm.org/D154596
2023-07-13[Clang][RISCV] Align RVV intrinsic builtin names with the C intrinsicseopXD1-79/+79
Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D155102
2023-07-13[8/8][RISCV] Add rounding mode control variant for vfredosum, vfredusum, ↵eopXD1-0/+16
vfwredosum, vfwredusum Depends on D154635 For the cover letter of the patch-set, please checkout D154628. This is the 8th patch of the patch-set. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D154636
2023-07-13[7/8][RISCV] Add rounding mode control variant for conversion intrinsics ↵eopXD1-0/+66
between floating-point and integer Depends on D154634 For the cover letter of the patch-set, please checkout D154628. This is the 7th patch of the patch-set. This patch includes change to vfcvt_x_f, vfcvt_xu_f, vfwcvt_x_f, vfwcvt_xu_f, vfncvt_x_f, vfncvt_xu_f vfcvt_f_x, vfcvt_f_xu, vfncvt_f_x vfncvt_f_xu, vfncvt_f_f Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D154635
2023-07-13[6/8][RISCV] Add rounding mode control variant for vfsqrt, vfrec7eopXD1-0/+13
Depends on D154633 For the cover letter of the patch-set, please checkout D154628. This is the 6th patch of the patch-set. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D154634
2023-07-13[5/8][RISCV] Add rounding mode control variant for vfwmacc, vfwnmacc, ↵eopXD1-0/+48
vfwmsac, vfwnmsac Depends on D154632 For the cover letter of the patch-set, please checkout D154628. This is the 5th patch of the patch-set. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D154633
2023-07-13[4/8][RISCV] Add rounding mode control variant for vfmacc, vfnmacc, vfmsac, ↵eopXD1-0/+96
vfnmsac, vfmadd, vfnmadd, vfmsub, vfnmsub Depends on D154631 For the cover letter of the patch-set, please checkout D154628. This is the 4th patch of the patch-set. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D154632
2023-07-13[3/8][RISCV] Add rounding mode control variant for vfmul, vfdiv, vfrdiv, vfwmuleopXD1-0/+42
Depends on D154629 For the cover letter of the patch-set, please checkout D154628. This is the 3rd patch of the patch-set. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D154631
2023-07-13[2/8][RISCV] Add rounding mode control variant for vfwadd, vfwsubeopXD1-0/+48
Depends on D154628 For the cover letter of the patch-set, please checkout D154628. This is the 2nd patch of the patch-set. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D154629
2023-07-13[1/8][RISCV] Add rounding mode control variant for vfsub, vfrsubeopXD1-0/+18
Depends on D152996. This patch-set aims to add a variant for the RVV floating-point intrinsics that controls the rounding mode (`frm`). The rounding mode variant appends `_rm` before the policy suffix to distinguish from those without them. Specification PR: riscv-non-isa/rvv-intrinsic-doc#226 This is the 1st patch of the patch-set. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D154628
2023-07-13[RISCV][POC] Model frm control for vfaddeopXD1-0/+15
Depends on D152879. Specification PR: riscv-non-isa/rvv-intrinsic-doc#226 This patch adds variant of `vfadd` that models the rounding mode control. The added variant has suffix `_rm` appended to differentiate from the existing ones that does not alternate `frm` and uses whatever is inside. The value `7` is used to indicate no rounding mode change. Reusing the semantic from the rounding mode encoding for scalar floating-point instructions. Additional data member `HasFRMRoundModeOp` is added so we can append `_rm` suffix for the fadd variants that models rounding mode control. Additional data member `IsRVVFixedPoint` is added so we can define pseudo instructions with rounding mode operand and distinguish the instructions between fixed-point and floating-point. Reviewed By: craig.topper, kito-cheng Differential Revision: https://reviews.llvm.org/D152996
2023-07-09[RISCV] Remove redundant _ta suffix in RVV intrinsics builtins. NFCeopXD1-18/+18
Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D154693
2023-07-02[clang][Sema][NFC] Make worklist in CheckForIntOverflow constTimm Bäder1-15/+15
2023-06-30[clang] detect integer overflow through temporary valuesLucile Nihlen1-0/+2
Fixes #63629. Differential Revision: https://reviews.llvm.org/D154253
2023-06-27[Clang][Sema] Do not try to analyze dependent alignment during -Wcast-alignserge-sans-paille1-1/+5
Fix #63007 Differential Revision: https://reviews.llvm.org/D151753
2023-06-26[Clang][RISCV] Check type support for local variable declaration of RVV typeeopXD1-0/+20
Guard local variable declaration for RVV intrinsic types. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D153510
2023-06-25[llvm] Add missing StringExtras.h includesElliot Goodrich1-0/+1
In preparation for removing the `#include "llvm/ADT/StringExtras.h"` from the header to source file of `llvm/Support/Error.h`, first add in all the missing includes that were previously included transitively through this header.
2023-06-23clang: Add __builtin_elementwise_rint and nearbyintMatt Arsenault1-0/+2
These are basically the same thing and only differ for strictfp, so add both for future proofing. Note all the elementwise functions are currently broken for strictfp, and use non-constrained ops. Add a test that demonstrates this, but doesn't attempt to fix it.
2023-06-20[RISCV] Model vxrm control for vsmul, vssra, vssrl, vnclip, and vnclipueopXD1-0/+60
Depends on D151397. This patch follows the patch-set of D151395. This patch seeks to update all the remaining fixed-point intrinsics to model vxrm control, adding rounding mode control for `vsmul`, `vssra`, `vssrl`, `vnclip`, and `vnclipu`. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D152879
2023-06-20[3/3][RISCV][POC] Model vxrm in C intrinsics for RVV fixed-point instruction ↵eopXD1-0/+52
vaadd, vasub Depends on D151396. This is the 3rd patch of the patch-set. For the cover letter of the patch-set, please checkout D151395. This commit consists of change in both clang front-end and RISC- back-end. In the front-end, this commit adds an additional operand to the C intrinsics of `vaadd`, `vaaddu`, `vasub`, and `vasubu`, that models the control of the rounding mode. In the back-end, using `vaadd` as an example, this commit replaces the existing `int.riscv.vaadd.*` with `int.riscv.vaadd.rm.*` that was introduced in the previous patch, with the extra operand that models the control of the rounding mode (`vxrm`) for RVV fixed-point intrinsics. Note: The first 3 commit of the patch-set shows the intent to model the rounding mode for fixed-point intrinsics by applying change to `vaadd`, `vaaddu`, `vasub`, and `vasubu`. The proceeding patch will apply the change to the rest of the other fixed-point instructions. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D151397
2023-06-19clang: Add __builtin_elementwise_roundMatt Arsenault1-0/+1
2023-06-18[clang] Add __builtin_isfpclassSerge Pavlov1-5/+18
A new builtin function __builtin_isfpclass is added. It is called as: __builtin_isfpclass(<floating point value>, <test>) and returns an integer value, which is non-zero if the floating point argument falls into one of the classes specified by the second argument, and zero otherwise. The set of classes is an integer value, where each value class is represented by a bit. There are ten data classes, as defined by the IEEE-754 standard, they are represented by bits: 0x0001 (__FPCLASS_SNAN) - Signaling NaN 0x0002 (__FPCLASS_QNAN) - Quiet NaN 0x0004 (__FPCLASS_NEGINF) - Negative infinity 0x0008 (__FPCLASS_NEGNORMAL) - Negative normal 0x0010 (__FPCLASS_NEGSUBNORMAL) - Negative subnormal 0x0020 (__FPCLASS_NEGZERO) - Negative zero 0x0040 (__FPCLASS_POSZERO) - Positive zero 0x0080 (__FPCLASS_POSSUBNORMAL) - Positive subnormal 0x0100 (__FPCLASS_POSNORMAL) - Positive normal 0x0200 (__FPCLASS_POSINF) - Positive infinity They have corresponding builtin macros to facilitate using the builtin function: if (__builtin_isfpclass(x, __FPCLASS_NEGZERO | __FPCLASS_POSZERO) { // x is any zero. } The data class encoding is identical to that used in llvm.is.fpclass function. Differential Revision: https://reviews.llvm.org/D152351
2023-06-16Diagnose incorrect use of scoped enumerations in format stringsAaron Ballman1-3/+7
Scoped enumerations in C++ do not undergo conversion to their underlying type as part of default argument promotion, and so these uses are UB. GCC correctly diagnoses them, and now Clang matches. Fixes https://github.com/llvm/llvm-project/issues/38717
2023-06-14Update with warning message for comparison to NULL pointerKrishna Narayanan1-1/+1
The tautological comparison warning was not properly looking through parenthesized expressions, which is now fixed. Fixes https://github.com/llvm/llvm-project/issues/42992 Differential Revision: https://reviews.llvm.org/D149000
2023-06-13[-Wtcb-enforcement] Disable on unevaluated code.Artem Dergachev1-0/+4
It doesn't make sense for this warning to warn about things that don't impact runtime behavior.
2023-06-10[clang][WebAssembly] Implement support for table types and builtinsPaulo Matos1-0/+185
This commit implements support for WebAssembly table types and respective builtins. Table tables are WebAssembly objects to store reference types. They have a large amount of semantic restrictions including, but not limited to, only being allowed to be declared at the top-level as static arrays of zero-length. Not being arguments or result of functions, not being stored ot memory, etc. This commit introduces the __attribute__((wasm_table)) to attach to arrays of WebAssembly reference types. And the following builtins to manage tables: * ref __builtin_wasm_table_get(table, idx) * void __builtin_wasm_table_set(table, idx, ref) * uint __builtin_wasm_table_size(table) * uint __builtin_wasm_table_grow(table, ref, uint) * void __builtin_wasm_table_fill(table, idx, ref, uint) * void __builtin_wasm_table_copy(table, table, uint, uint, uint) This commit also enables reference-types feature at bleeding-edge. This is joint work with Alex Bradbury (@asb). Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D139010
2023-06-07[Clang] Check for abstract parameters only when functions are defined.Corentin Jabot1-3/+9
The C++ standard allows abstract parameters in deleted functions and in function declarations > The type of a parameter or the return type for a function definition > shall not be a (possibly cv-qualified) class type that is > incomplete or abstract within the function body > unless the function is deleted. Fixes https://github.com/llvm/llvm-project/issues/63012 Reviewed By: #clang-language-wg, aaron.ballman Differential Revision: https://reviews.llvm.org/D152096
2023-05-31[clang] Allow fp in atomic fetch max/min builtinsYaxun (Sam) Liu1-30/+40
LLVM IR already allows floating point type in atomicrmw. Update clang atomic fetch max/min builtins to accept floating point type like we did for fetch add/sub. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D150985 Fixes: SWDEV-401056