[clang] [clang] Introduce `SemaRISCV` (PR #92682)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
https://github.com/topperc approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
@@ -0,0 +1,52 @@ +//===- SemaRISCV.h --- RISC-V target-specific routines ===// Endilll wrote: Fixed https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
@@ -0,0 +1,52 @@ +//===- SemaRISCV.h --- RISC-V target-specific routines ===// topperc wrote: I think header files are supposed to have `-*- C++ -*-` on this line https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
https://github.com/wangpc-pp approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
@@ -1,12 +1,12 @@ -//==- SemaRISCVVectorLookup.cpp - Name Lookup for RISC-V Vector Intrinsic -==// +//==--- SemaRISCV.cpp --- RISC-V target-specific routines --==// Endilll wrote: I never noticed this. Thanks! https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
@@ -1,12 +1,12 @@ -//==- SemaRISCVVectorLookup.cpp - Name Lookup for RISC-V Vector Intrinsic -==// +//==--- SemaRISCV.cpp --- RISC-V target-specific routines --==// MaskRay wrote: The prevailing style starts with `//===-` or `//===--` https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
Endilll wrote: > Pushing a prerequisite commit first with git mv SemaRISCVVectorLookup.cpp > SemaRISCV.cpp should make git recognize this as a file rename. This PR can be > changed to rebase on that precommit. Thank you for suggestion! Done. https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
MaskRay wrote: Nice refactoring! Pushing a prerequisite commit first with `git mv SemaRISCVVectorLookup.cpp SemaRISCV.cpp` should make git recognize this as a file rename. This PR can be changed to rebase on that precommit. https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
https://github.com/kito-cheng approved this pull request. LGTM as the original author of `SemaRISCVVectorLookup.cpp` :) It's great to see we can put all RISC-V related stuff within same place rather than many different files. https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
https://github.com/cor3ntin approved this pull request. https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
wangpc-pp wrote: I think it's a good rewrite. Added more RISCV guys. https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
Endilll wrote: It is, but I guess significant enough to not be disguised by labeling as NFC. https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
wangpc-pp wrote: Is it a NFC? https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) Changes This patch moves `Sema` functions that are specific for RISC-V into the new `SemaRISCV` class. This continues previous efforts to split `Sema` up. Additional context can be found in https://github.com/llvm/llvm-project/pull/84184. This PR is somewhat different from previous PRs on this topic: 1. Splitting out target-specific functions wasn't previously discussed. It felt quite natural to do, though. 2. I had to make some static function in `SemaChecking.cpp` member functions of `Sema` in order to use them in `SemaRISCV`. 3. I dropped "RISCV" from identifiers, but decided to leave "RVV" (RISC-V "V" vector extensions) intact. I think it's an idiomatic abbreviation at this point, but I'm open to input from contributors in that area. 4. I repurposed `SemaRISCVVectorLookup.cpp` for `SemaRISCV`. I think this was a successful experiment, which both helps the goal of splitting `Sema` up, and shows a way to approach `SemaChecking.cpp`, which I wasn't sure how to approach before. As we move more target-specific function out of there, we'll gradually make the checking "framework" inside `SemaChecking.cpp` public, which is currently a whole bunch of static functions. This would enable us to move more functions outside of `SemaChecking.cpp`. --- Patch is 167.97 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/92682.diff 12 Files Affected: - (modified) clang/include/clang/Sema/Sema.h (+25-40) - (added) clang/include/clang/Sema/SemaRISCV.h (+52) - (modified) clang/lib/Parse/ParsePragma.cpp (+3-2) - (modified) clang/lib/Sema/CMakeLists.txt (+1-1) - (modified) clang/lib/Sema/Sema.cpp (+3-1) - (modified) clang/lib/Sema/SemaCast.cpp (+3-2) - (modified) clang/lib/Sema/SemaChecking.cpp (+78-969) - (modified) clang/lib/Sema/SemaDecl.cpp (+3-2) - (modified) clang/lib/Sema/SemaExpr.cpp (-21) - (modified) clang/lib/Sema/SemaLookup.cpp (+6-5) - (added) clang/lib/Sema/SemaRISCV.cpp (+1427) - (removed) clang/lib/Sema/SemaRISCVVectorLookup.cpp (-504) ``diff diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index d4d4a82525a02..e01cca9f380a6 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -173,6 +173,7 @@ class SemaHLSL; class SemaObjC; class SemaOpenACC; class SemaOpenMP; +class SemaRISCV; class SemaSYCL; class StandardConversionSequence; class Stmt; @@ -1014,6 +1015,11 @@ class Sema final : public SemaBase { return *OpenMPPtr; } + SemaRISCV &RISCV() { +assert(RISCVPtr); +return *RISCVPtr; + } + SemaSYCL &SYCL() { assert(SYCLPtr); return *SYCLPtr; @@ -1055,6 +1061,7 @@ class Sema final : public SemaBase { std::unique_ptr ObjCPtr; std::unique_ptr OpenACCPtr; std::unique_ptr OpenMPPtr; + std::unique_ptr RISCVPtr; std::unique_ptr SYCLPtr; ///@} @@ -2030,6 +2037,23 @@ class Sema final : public SemaBase { void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc); + bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result); + bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High, + bool RangeIsError = true); + bool BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum, + unsigned Multiple); + bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum); + bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum, + unsigned ArgBits); + bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum, + unsigned ArgBits); + + bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount); + bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount); + bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount, + unsigned MaxArgCount); + bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount); + private: void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, const ArraySubscriptExpr *ASE = nullptr, @@ -2098,11 +2122,7 @@ class Sema final : public SemaBase { bool CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); bool CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); - bool CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum); - bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, - CallExpr *TheCall); - void checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D, - const llvm::StringMap &FeatureMap); + bool CheckLoongArchBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); b
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
llvmbot wrote: @llvm/pr-subscribers-backend-risc-v Author: Vlad Serebrennikov (Endilll) Changes This patch moves `Sema` functions that are specific for RISC-V into the new `SemaRISCV` class. This continues previous efforts to split `Sema` up. Additional context can be found in https://github.com/llvm/llvm-project/pull/84184. This PR is somewhat different from previous PRs on this topic: 1. Splitting out target-specific functions wasn't previously discussed. It felt quite natural to do, though. 2. I had to make some static function in `SemaChecking.cpp` member functions of `Sema` in order to use them in `SemaRISCV`. 3. I dropped "RISCV" from identifiers, but decided to leave "RVV" (RISC-V "V" vector extensions) intact. I think it's an idiomatic abbreviation at this point, but I'm open to input from contributors in that area. 4. I repurposed `SemaRISCVVectorLookup.cpp` for `SemaRISCV`. I think this was a successful experiment, which both helps the goal of splitting `Sema` up, and shows a way to approach `SemaChecking.cpp`, which I wasn't sure how to approach before. As we move more target-specific function out of there, we'll gradually make the checking "framework" inside `SemaChecking.cpp` public, which is currently a whole bunch of static functions. This would enable us to move more functions outside of `SemaChecking.cpp`. --- Patch is 167.97 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/92682.diff 12 Files Affected: - (modified) clang/include/clang/Sema/Sema.h (+25-40) - (added) clang/include/clang/Sema/SemaRISCV.h (+52) - (modified) clang/lib/Parse/ParsePragma.cpp (+3-2) - (modified) clang/lib/Sema/CMakeLists.txt (+1-1) - (modified) clang/lib/Sema/Sema.cpp (+3-1) - (modified) clang/lib/Sema/SemaCast.cpp (+3-2) - (modified) clang/lib/Sema/SemaChecking.cpp (+78-969) - (modified) clang/lib/Sema/SemaDecl.cpp (+3-2) - (modified) clang/lib/Sema/SemaExpr.cpp (-21) - (modified) clang/lib/Sema/SemaLookup.cpp (+6-5) - (added) clang/lib/Sema/SemaRISCV.cpp (+1427) - (removed) clang/lib/Sema/SemaRISCVVectorLookup.cpp (-504) ``diff diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index d4d4a82525a02..e01cca9f380a6 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -173,6 +173,7 @@ class SemaHLSL; class SemaObjC; class SemaOpenACC; class SemaOpenMP; +class SemaRISCV; class SemaSYCL; class StandardConversionSequence; class Stmt; @@ -1014,6 +1015,11 @@ class Sema final : public SemaBase { return *OpenMPPtr; } + SemaRISCV &RISCV() { +assert(RISCVPtr); +return *RISCVPtr; + } + SemaSYCL &SYCL() { assert(SYCLPtr); return *SYCLPtr; @@ -1055,6 +1061,7 @@ class Sema final : public SemaBase { std::unique_ptr ObjCPtr; std::unique_ptr OpenACCPtr; std::unique_ptr OpenMPPtr; + std::unique_ptr RISCVPtr; std::unique_ptr SYCLPtr; ///@} @@ -2030,6 +2037,23 @@ class Sema final : public SemaBase { void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc); + bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result); + bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High, + bool RangeIsError = true); + bool BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum, + unsigned Multiple); + bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum); + bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum, + unsigned ArgBits); + bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum, + unsigned ArgBits); + + bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount); + bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount); + bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount, + unsigned MaxArgCount); + bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount); + private: void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, const ArraySubscriptExpr *ASE = nullptr, @@ -2098,11 +2122,7 @@ class Sema final : public SemaBase { bool CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); bool CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); - bool CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum); - bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, - CallExpr *TheCall); - void checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D, - const llvm::StringMap &FeatureMap); + bool CheckLoongArchBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCa