[llvm-branch-commits] [llvm] [RISCV][MC] Warn if SEW/LMUL may not be compatible (PR #94313)
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/94313 >From 6e3d6329300e27a23481df3e6e01b9763a34d9d2 Mon Sep 17 00:00:00 2001 From: Wang Pengcheng Date: Thu, 6 Jun 2024 15:05:20 +0800 Subject: [PATCH] Address comments Created using spr 1.3.6-beta.1 --- .../Target/RISCV/AsmParser/RISCVAsmParser.cpp | 17 +++-- llvm/test/MC/RISCV/rvv/vsetvl.s | 6 +++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 4091f9d5e9f8a..49f21e46f34ea 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -2160,10 +2160,9 @@ bool RISCVAsmParser::parseVTypeToken(const AsmToken &Tok, VTypeState &State, unsigned ELEN = STI->hasFeature(RISCV::FeatureStdExtZve64x) ? 64 : 32; unsigned MinLMUL = ELEN / 8; if (Lmul > MinLMUL) -Warning( -Tok.getLoc(), -Twine("The use of vtype encodings with LMUL < SEWMIN/ELEN == mf") + -Twine(MinLMUL) + Twine(" is reserved")); +Warning(Tok.getLoc(), +"use of vtype encodings with LMUL < SEWMIN/ELEN == mf" + +Twine(MinLMUL) + " is reserved"); } State = VTypeState_TailPolicy; @@ -2228,12 +2227,10 @@ ParseStatus RISCVAsmParser::parseVTypeI(OperandVector &Operands) { unsigned MaxSEW = ELEN / Lmul; // If MaxSEW < 8, we should have printed warning about reserved LMUL. if (MaxSEW >= 8 && Sew > MaxSEW) -Warning( -SEWLoc, -Twine("The use of vtype encodings with SEW > ") + Twine(MaxSEW) + -Twine(" and LMUL == ") + Twine(Fractional ? "mf" : "m") + -Twine(Lmul) + -Twine(" may not be compatible with all RVV implementations")); +Warning(SEWLoc, +"use of vtype encodings with SEW > " + Twine(MaxSEW) + +" and LMUL == " + (Fractional ? "mf" : "m") + Twine(Lmul) + +" may not be compatible with all RVV implementations"); } unsigned VTypeI = diff --git a/llvm/test/MC/RISCV/rvv/vsetvl.s b/llvm/test/MC/RISCV/rvv/vsetvl.s index 207daf392bd50..2741def0eeff2 100644 --- a/llvm/test/MC/RISCV/rvv/vsetvl.s +++ b/llvm/test/MC/RISCV/rvv/vsetvl.s @@ -73,21 +73,21 @@ vsetvli a2, a0, e32, m8, ta, ma vsetvli a2, a0, e32, mf2, ta, ma # CHECK-INST: vsetvli a2, a0, e32, mf2, ta, ma -# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: The use of vtype encodings with SEW > 16 and LMUL == mf2 may not be compatible with all RVV implementations{{$}} +# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: use of vtype encodings with SEW > 16 and LMUL == mf2 may not be compatible with all RVV implementations{{$}} # CHECK-ENCODING: [0x57,0x76,0x75,0x0d] # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' (Vector Extensions for Embedded Processors){{$}} # CHECK-UNKNOWN: 0d757657 vsetvli a2, a0, e32, mf4, ta, ma # CHECK-INST: vsetvli a2, a0, e32, mf4, ta, ma -# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: The use of vtype encodings with SEW > 8 and LMUL == mf4 may not be compatible with all RVV implementations{{$}} +# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: use of vtype encodings with SEW > 8 and LMUL == mf4 may not be compatible with all RVV implementations{{$}} # CHECK-ENCODING: [0x57,0x76,0x65,0x0d] # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' (Vector Extensions for Embedded Processors){{$}} # CHECK-UNKNOWN: 0d657657 vsetvli a2, a0, e32, mf8, ta, ma # CHECK-INST: vsetvli a2, a0, e32, mf8, ta, ma -# CHECK-ZVE32X: :[[#@LINE-2]]:22: warning: The use of vtype encodings with LMUL < SEWMIN/ELEN == mf4 is reserved{{$}} +# CHECK-ZVE32X: :[[#@LINE-2]]:22: warning: use of vtype encodings with LMUL < SEWMIN/ELEN == mf4 is reserved{{$}} # CHECK-ENCODING: [0x57,0x76,0x55,0x0d] # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' (Vector Extensions for Embedded Processors){{$}} # CHECK-UNKNOWN: 0d557657 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [RISCV][MC] Warn if SEW/LMUL may not be compatible (PR #94313)
https://github.com/lukel97 edited https://github.com/llvm/llvm-project/pull/94313 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [RISCV][MC] Warn if SEW/LMUL may not be compatible (PR #94313)
https://github.com/lukel97 approved this pull request. https://github.com/llvm/llvm-project/pull/94313 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [RISCV][MC] Warn if SEW/LMUL may not be compatible (PR #94313)
@@ -2211,6 +,16 @@ ParseStatus RISCVAsmParser::parseVTypeI(OperandVector &Operands) { if (getLexer().is(AsmToken::EndOfStatement) && State == VTypeState_Done) { RISCVII::VLMUL VLMUL = RISCVVType::encodeLMUL(Lmul, Fractional); +if (Fractional) { + unsigned ELEN = STI->hasFeature(RISCV::FeatureStdExtZve64x) ? 64 : 32; + unsigned MaxSEW = ELEN / Lmul; + // If MaxSEW < 8, we should have printed warning about reserved LMUL. + if (MaxSEW >= 8 && Sew > MaxSEW) +Warning(SEWLoc, +"use of vtype encodings with SEW > " + Twine(MaxSEW) + +" and LMUL == " + (Fractional ? "mf" : "m") + Twine(Lmul) + lukel97 wrote: Fractional is always true here right? https://github.com/llvm/llvm-project/pull/94313 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [Support] Integrate SipHash.cpp into libSupport. (PR #94394)
kovdan01 wrote: @ahmedbougacha The "original" PR #93902 (which was "split" into this one and PR94393) contained some tests, while I don't see any tests now. Will they be added in a follow-up patch or you plan to add them as a part of this one? https://github.com/llvm/llvm-project/pull/94394 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [Support] Add SipHash-based 16-bit ptrauth stable hash. (PR #93902)
kovdan01 wrote: > * we're now left with only the thin wrapper (the 16-bit one only here) and > the simple unittests The wrapper and the tests LGTM https://github.com/llvm/llvm-project/pull/93902 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] [ELF] Orphan placement: remove hasInputSections condition (PR #93761)
smithp35 wrote: I think https://github.com/llvm/llvm-project/pull/94519 looks good. Probably worth landing that first and rebasing this one. https://github.com/llvm/llvm-project/pull/93761 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [MLIR][OpenMP] Clause-based OpenMP operation definition (PR #92523)
@@ -315,38 +266,17 @@ def SectionsOp : OpenMP_Op<"sections", [AttrSizedOperandSegments, into the final value, which is available in the accumulator after all the sections complete. -The $allocators_vars and $allocate_vars parameters are a variadic list of values -that specify the memory allocator to be used to obtain storage for private values. - -The `nowait` attribute, when present, signifies that there should be no -implicit barrier at the end of the construct. - }]; - let arguments = (ins Variadic:$reduction_vars, - OptionalAttr:$reductions, - Variadic:$allocate_vars, - Variadic:$allocators_vars, - UnitAttr:$nowait); +The optional `byref` attribute controls whether reduction arguments are +passed by reference or by value. tblah wrote: Shouldn't this use the machinery in `OpenMP_ReductionClause`? https://github.com/llvm/llvm-project/pull/92523 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [MLIR][OpenMP] Clause-based OpenMP operation definition (PR #92523)
@@ -920,6 +663,9 @@ def TaskloopOp : OpenMP_Op<"taskloop", [AttrSizedOperandSegments, specifies how to combine the values from each iteration into the final value, which is available in the accumulator after the loop completes. +The optional `byref` attribute controls whether reduction arguments are +passed by reference or by value. + tblah wrote: Here too. I guess we need separate work to standardize how reductions work over different ops? https://github.com/llvm/llvm-project/pull/92523 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [MLIR][OpenMP] Clause-based OpenMP operation definition (PR #92523)
skatrak wrote: @tblah thanks for giving this a look. Basically the issue here with the reduction clause is that its description is currently different for each operation that accepts it. They are generally quite similar, just not the same. I think the clause is already consistent in terms of how it's represented but what it means is slightly different depending on the operation, hence the variations in their way of describing it. If you look at the `OpenMP_ReductionClause` definition in OpenMPClauses.td, you'll see that I added a comment to it saying basically that no description is defined for it because it's different on each operation (same thing I did for the `if` and `in_reduction` clauses). It would be great to agree on a generic description for that clause that would work for all ops, so that it makes sense while reading the generated documentation while being able to centralize this into the clause definition rather than each operation. I created a gist [here](https://gist.github.com/skatrak/ee6e1829980867f8119f91f84cb284b1) with the whole list of descriptions that currently exist for `reduction`, in case that helps with figuring out a shared description. Another option would be to provide a generic description for that clause used by most operations and then override it for one or two if they need to be more specific about something. https://github.com/llvm/llvm-project/pull/92523 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)
@@ -55,6 +55,17 @@ MDNode *getBranchWeightMDNode(const Instruction &I); /// Nullptr otherwise. MDNode *getValidBranchWeightMDNode(const Instruction &I); +/// Check if Branch Weight Metadata has an "expected" field from an llvm.expect* +/// intrinsic +bool hasBranchWeightProvenance(const Instruction &I); ilovepi wrote: hmm, I see your point, given its current use, but I do think we'll want to track more things in the future. Some other options: `IsBranchWeightFromLlvmIntrinsic`, `hasOptionalMetadataField`, or `hasBranchWeightOrigin`? The last is basically the same as the current, but avoids the use of `Provenance` like @MatzeB brought up earlier. WDYT? https://github.com/llvm/llvm-project/pull/86609 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)
@@ -55,6 +55,17 @@ MDNode *getBranchWeightMDNode(const Instruction &I); /// Nullptr otherwise. MDNode *getValidBranchWeightMDNode(const Instruction &I); +/// Check if Branch Weight Metadata has an "expected" field from an llvm.expect* +/// intrinsic +bool hasBranchWeightProvenance(const Instruction &I); david-xl wrote: hasBranchWeightOrigin sounds good to me -- it is straightforward for the reader to understand. https://github.com/llvm/llvm-project/pull/86609 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/86609 >From 7760282ed8dba340d6873d06ff4c18c6efc25b56 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Thu, 6 Jun 2024 19:04:19 + Subject: [PATCH] Add assert for metadata string value Created using spr 1.3.4 --- llvm/lib/IR/ProfDataUtils.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/lib/IR/ProfDataUtils.cpp b/llvm/lib/IR/ProfDataUtils.cpp index f738d76937c24..af536d2110eac 100644 --- a/llvm/lib/IR/ProfDataUtils.cpp +++ b/llvm/lib/IR/ProfDataUtils.cpp @@ -133,6 +133,7 @@ bool hasBranchWeightProvenance(const MDNode *ProfileData) { // NOTE: if we ever have more types of branch weight provenance, // we need to check the string value is "expected". For now, we // supply a more generic API, and avoid the spurious comparisons. + assert(ProfDataName->getString() == "expected"); return ProfDataName; } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm][misexpect] Update MisExpect to use provenance tracking metadata (PR #86610)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/86610 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm][misexpect] Update MisExpect to use provenance tracking metadata (PR #86610)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/86610 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm][ProfDataUtils] provide getNumBranchWeights API (PR #90146)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/90146 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm][ProfDataUtils] provide getNumBranchWeights API (PR #90146)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/90146 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [llvm][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)
@@ -123,6 +121,25 @@ bool hasValidBranchWeightMD(const Instruction &I) { return getValidBranchWeightMDNode(I); } +bool hasBranchWeightProvenance(const Instruction &I) { + auto *ProfileData = I.getMetadata(LLVMContext::MD_prof); + return hasBranchWeightProvenance(ProfileData); +} + +bool hasBranchWeightProvenance(const MDNode *ProfileData) { + if (!isBranchWeightMD(ProfileData)) +return false; + auto *ProfDataName = dyn_cast(ProfileData->getOperand(1)); + // NOTE: if we ever have more types of branch weight provenance, + // we need to check the string value is "expected". For now, we + // supply a more generic API, and avoid the spurious comparisons. + return ProfDataName; ilovepi wrote: done. https://github.com/llvm/llvm-project/pull/86609 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 5367b2c862a7bfe138ee17994edfdb7938437064 7a203002b19f5a2827607e73a998dcd1ace9d135 -- libcxx/include/__functional/move_only_function.h libcxx/include/__functional/move_only_function_common.h libcxx/include/__functional/move_only_function_impl.h libcxx/include/__utility/pointer_int_pair.h libcxx/test/libcxx/private_headers.verify.cpp libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.move/assert.engaged.cpp libcxx/test/libcxx/utilities/pointer_int_pair.pass.cpp libcxx/test/libcxx/utilities/pointer_int_pair/assert.constructor.pass.cpp libcxx/test/libcxx/utilities/pointer_int_pair/constinit.verify.cpp libcxx/test/libcxx/utilities/pointer_int_pair/pointer_int_pair.pass.cpp libcxx/test/libcxx/utilities/pointer_int_pair/static_asserts.verify.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/functor.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/move.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/move_other.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/nullptr.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_const.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_const_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/normal.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/normal_const.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/normal_const_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/normal_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_const.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_const_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/common.h libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/default.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/functor.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/in_place.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/in_place_init_list.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/move.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/move_other.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/nullptr.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/swap.adl.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/swap.member.pass.cpp libcxx/include/__configuration/abi.h libcxx/include/__std_clang_module libcxx/include/functional libcxx/include/version libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/test/support/type_algorithms.h `` View the diff from clang-format here. ``diff diff --git a/libcxx/test/libcxx/private_headers.verify.cpp b/libcxx/test/libcxx/private_headers.verify.cpp index fc76655325..8debceecd2 100644 --- a/libcxx/test/libcxx/private_headers.verify.cpp +++ b/libcxx/test/libcxx/private_headers.verify.cpp @@ -226,11 +226,11 @@ END-SCRIPT #include <__algorithm/unwrap_iter.h> // expected-error@*:* {{use of private header from outside its module: '__algorithm/unwrap_iter.h'}} #include <__algorithm/unwrap_range.h> // expected-error@*:* {{use of private header from outside its module: '__algorithm/unwrap_range.h'}} #include <__algorithm/upper_bound.h> // expected-error@*:* {{use of private header from outside its module: '__algorithm/upper_bound.h'}} -#include <__availability> // expected-error@*:* {{use of private header from outside its module: '__availability'}} +#include <__availability> // expected-error@*:* {{use of private header from outside its module: '__availability'}} #include <__bit/bit_cast.h> // expected-error@*:* {{use of private header from outside its module: '__bit/bit_cast.h'}} #include
[llvm-branch-commits] [lld] [ELF] Orphan placement: remove hasInputSections condition (PR #93761)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/93761 >From 316e0a1effb50b15fa1df54a43d02704f735309d Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 29 May 2024 20:14:18 -0700 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- lld/ELF/Writer.cpp| 18 ++ .../linkerscript/memory-nonalloc-no-warn.test | 19 +-- lld/test/ELF/linkerscript/nobits-offset.s | 2 +- lld/test/ELF/linkerscript/orphan-live-only.s | 6 +++--- .../ELF/linkerscript/symbol-only-align.test | 11 ++- lld/test/ELF/linkerscript/tls-nobits-offset.s | 2 +- 6 files changed, 26 insertions(+), 32 deletions(-) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index c498153f3348b..4add995c93458 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -890,9 +890,7 @@ template void Writer::setReservedSymbolSections() { // countLeadingZeros. static int getRankProximity(OutputSection *a, SectionCommand *b) { auto *osd = dyn_cast(b); - return (osd && osd->osec.hasInputSections) - ? llvm::countl_zero(a->sortRank ^ osd->osec.sortRank) - : -1; + return osd ? llvm::countl_zero(a->sortRank ^ osd->osec.sortRank) : -1; } // When placing orphan sections, we want to place them after symbol assignments @@ -958,20 +956,16 @@ findOrphanPos(SmallVectorImpl::iterator b, sortRank = std::max(sortRank, foundSec->sortRank); for (; i != e; ++i) { auto *curSecDesc = dyn_cast(*i); -if (!curSecDesc || !curSecDesc->osec.hasInputSections) +if (!curSecDesc) continue; if (getRankProximity(sec, curSecDesc) != proximity || sortRank < curSecDesc->osec.sortRank) break; } - auto isOutputSecWithInputSections = [](SectionCommand *cmd) { -auto *osd = dyn_cast(cmd); -return osd && osd->osec.hasInputSections; - }; - auto j = - std::find_if(std::make_reverse_iterator(i), std::make_reverse_iterator(b), - isOutputSecWithInputSections); + auto isOutputSec = [](SectionCommand *cmd) { return isa(cmd); }; + auto j = std::find_if(std::make_reverse_iterator(i), +std::make_reverse_iterator(b), isOutputSec); i = j.base(); // As a special case, if the orphan section is the last section, put @@ -979,7 +973,7 @@ findOrphanPos(SmallVectorImpl::iterator b, // This matches bfd's behavior and is convenient when the linker script fully // specifies the start of the file, but doesn't care about the end (the non // alloc sections for example). - auto nextSec = std::find_if(i, e, isOutputSecWithInputSections); + auto nextSec = std::find_if(i, e, isOutputSec); if (nextSec == e) return e; diff --git a/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test b/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test index 2dcd0f8d6ce2f..9c6111008c818 100644 --- a/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test +++ b/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test @@ -16,22 +16,21 @@ ## The output file must include all sections. # RUN: llvm-readelf -S %t/a.elf | FileCheck %s -# CHECK: There are 12 section headers, starting at offset 0x2140: +# CHECK: There are 12 section headers, starting at offset 0x2138: # CHECK: [Nr] Name Type Address OffSize ES Flg Lk Inf Al # CHECK-NEXT: [ 0] NULL 00 00 00 0 0 0 # CHECK-NEXT: [ 1] .nonallocPROGBITS 001064 001000 00 W 0 0 1 -# CHECK-NEXT: [ 2] .comment PROGBITS {{.*}} {{.*}} 01 MS 0 0 1 -# CHECK-NEXT: [ 3] .symtab SYMTAB {{.*}} {{.*}} 18 5 1 8 -# CHECK-NEXT: [ 4] .shstrtabSTRTAB {{.*}} {{.*}} 00 0 0 1 -# CHECK-NEXT: [ 5] .strtab STRTAB {{.*}} {{.*}} 00 0 0 1 -# CHECK-NEXT: [ 6] .dat PROGBITS 002137 04 00 W 0 0 1 -# CHECK-NEXT: [ 7] .intvec0_out PROGBITS 00213b 00 00 W 0 0 1 -# CHECK-NEXT: [ 8] .intvec1_out PROGBITS 00213b 00 00 W 0 0 1 -# CHECK-NEXT: [ 9] .intvec2_out PROGBITS 00213b 00 00 W 0 0 1 +# CHECK-NEXT: [ 2] .dat PROGBITS 002064 04 00 W 0 0 1 +# CHECK-NEXT: [ 3] .intvec0_out PROGBITS 002068 00 00 W 0 0 1 +# CHECK-NEXT: [ 4] .intvec1_out PROGBITS 002068 00 00 W 0 0 1 +# CHECK-NEXT: [ 5] .intvec2_out PROGBITS 002068 00 00 W 0 0 1 +# CHECK-NEXT: [ 6] .comment PROGBITS {{.*}} {{.*}} 01 MS 0 0 1 +# CHECK-NEXT: [ 7] .symtab SYMTAB {{.*}} {{.*}} 18
[llvm-branch-commits] [lld] [ELF] Orphan placement: remove hasInputSections condition (PR #93761)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/93761 >From 316e0a1effb50b15fa1df54a43d02704f735309d Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 29 May 2024 20:14:18 -0700 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- lld/ELF/Writer.cpp| 18 ++ .../linkerscript/memory-nonalloc-no-warn.test | 19 +-- lld/test/ELF/linkerscript/nobits-offset.s | 2 +- lld/test/ELF/linkerscript/orphan-live-only.s | 6 +++--- .../ELF/linkerscript/symbol-only-align.test | 11 ++- lld/test/ELF/linkerscript/tls-nobits-offset.s | 2 +- 6 files changed, 26 insertions(+), 32 deletions(-) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index c498153f3348b..4add995c93458 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -890,9 +890,7 @@ template void Writer::setReservedSymbolSections() { // countLeadingZeros. static int getRankProximity(OutputSection *a, SectionCommand *b) { auto *osd = dyn_cast(b); - return (osd && osd->osec.hasInputSections) - ? llvm::countl_zero(a->sortRank ^ osd->osec.sortRank) - : -1; + return osd ? llvm::countl_zero(a->sortRank ^ osd->osec.sortRank) : -1; } // When placing orphan sections, we want to place them after symbol assignments @@ -958,20 +956,16 @@ findOrphanPos(SmallVectorImpl::iterator b, sortRank = std::max(sortRank, foundSec->sortRank); for (; i != e; ++i) { auto *curSecDesc = dyn_cast(*i); -if (!curSecDesc || !curSecDesc->osec.hasInputSections) +if (!curSecDesc) continue; if (getRankProximity(sec, curSecDesc) != proximity || sortRank < curSecDesc->osec.sortRank) break; } - auto isOutputSecWithInputSections = [](SectionCommand *cmd) { -auto *osd = dyn_cast(cmd); -return osd && osd->osec.hasInputSections; - }; - auto j = - std::find_if(std::make_reverse_iterator(i), std::make_reverse_iterator(b), - isOutputSecWithInputSections); + auto isOutputSec = [](SectionCommand *cmd) { return isa(cmd); }; + auto j = std::find_if(std::make_reverse_iterator(i), +std::make_reverse_iterator(b), isOutputSec); i = j.base(); // As a special case, if the orphan section is the last section, put @@ -979,7 +973,7 @@ findOrphanPos(SmallVectorImpl::iterator b, // This matches bfd's behavior and is convenient when the linker script fully // specifies the start of the file, but doesn't care about the end (the non // alloc sections for example). - auto nextSec = std::find_if(i, e, isOutputSecWithInputSections); + auto nextSec = std::find_if(i, e, isOutputSec); if (nextSec == e) return e; diff --git a/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test b/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test index 2dcd0f8d6ce2f..9c6111008c818 100644 --- a/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test +++ b/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test @@ -16,22 +16,21 @@ ## The output file must include all sections. # RUN: llvm-readelf -S %t/a.elf | FileCheck %s -# CHECK: There are 12 section headers, starting at offset 0x2140: +# CHECK: There are 12 section headers, starting at offset 0x2138: # CHECK: [Nr] Name Type Address OffSize ES Flg Lk Inf Al # CHECK-NEXT: [ 0] NULL 00 00 00 0 0 0 # CHECK-NEXT: [ 1] .nonallocPROGBITS 001064 001000 00 W 0 0 1 -# CHECK-NEXT: [ 2] .comment PROGBITS {{.*}} {{.*}} 01 MS 0 0 1 -# CHECK-NEXT: [ 3] .symtab SYMTAB {{.*}} {{.*}} 18 5 1 8 -# CHECK-NEXT: [ 4] .shstrtabSTRTAB {{.*}} {{.*}} 00 0 0 1 -# CHECK-NEXT: [ 5] .strtab STRTAB {{.*}} {{.*}} 00 0 0 1 -# CHECK-NEXT: [ 6] .dat PROGBITS 002137 04 00 W 0 0 1 -# CHECK-NEXT: [ 7] .intvec0_out PROGBITS 00213b 00 00 W 0 0 1 -# CHECK-NEXT: [ 8] .intvec1_out PROGBITS 00213b 00 00 W 0 0 1 -# CHECK-NEXT: [ 9] .intvec2_out PROGBITS 00213b 00 00 W 0 0 1 +# CHECK-NEXT: [ 2] .dat PROGBITS 002064 04 00 W 0 0 1 +# CHECK-NEXT: [ 3] .intvec0_out PROGBITS 002068 00 00 W 0 0 1 +# CHECK-NEXT: [ 4] .intvec1_out PROGBITS 002068 00 00 W 0 0 1 +# CHECK-NEXT: [ 5] .intvec2_out PROGBITS 002068 00 00 W 0 0 1 +# CHECK-NEXT: [ 6] .comment PROGBITS {{.*}} {{.*}} 01 MS 0 0 1 +# CHECK-NEXT: [ 7] .symtab SYMTAB {{.*}} {{.*}} 18
[llvm-branch-commits] [llvm][misexpect] Update MisExpect to use provenance tracking metadata (PR #86610)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/86610 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm][misexpect] Update MisExpect to use provenance tracking metadata (PR #86610)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/86610 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm][ProfDataUtils] provide getNumBranchWeights API (PR #90146)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/90146 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm][ProfDataUtils] provide getNumBranchWeights API (PR #90146)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/90146 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [Frontend] Introduce `getDirectiveCategory` for ACC/OMP directives (PR #94689)
https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/94689 The categories are primarily meant for OpenMP, where the spec assigns a category to each directive. It's one of declarative, executable, informational, meta, subsidiary, and utility. These will be used in clang to avoid listing directives belonging to certain categories by hand. >From 64fcf25e2158de44bccf725a0f91d8228b7cb7a5 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 6 Jun 2024 15:10:13 -0500 Subject: [PATCH] [Frontend] Introduce `getDirectiveCategory` for ACC/OMP directives The categories are primarily meant for OpenMP, where the spec assigns a category to each directive. It's one of declarative, executable, informational, meta, subsidiary, and utility. These will be used in clang to avoid listing directives belonging to certain categories by hand. --- .../llvm/Frontend/Directive/DirectiveBase.td | 15 +++ llvm/include/llvm/Frontend/OpenACC/ACC.td | 21 llvm/include/llvm/Frontend/OpenMP/OMP.td | 109 ++ llvm/include/llvm/TableGen/DirectiveEmitter.h | 6 + llvm/test/TableGen/directive1.td | 23 +++- llvm/test/TableGen/directive2.td | 23 +++- llvm/utils/TableGen/DirectiveEmitter.cpp | 31 - 7 files changed, 225 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td index ce532e0cfae29..6889c7e642ec6 100644 --- a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td +++ b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td @@ -156,6 +156,18 @@ def AS_FromLeaves : Association<"FromLeaves"> {}// See below // The name "AS_FromLeaves" is recognized by TableGen, and there is no enum // generated for it. +// Kinds of directive categories. +class Category { + string name = n; // Name of the enum value in enum class Category. +} + +def CA_Declarative: Category<"Declarative"> {} +def CA_Executable: Category<"Executable"> {} +def CA_Informational: Category<"Informational"> {} +def CA_Meta: Category<"Meta"> {} +def CA_Subsidiary: Category<"Subsidiary"> {} +def CA_Utility: Category<"Utility"> {} + // Information about a specific directive. class Directive { // Name of the directive. Can be composite directive sepearted by whitespace. @@ -190,4 +202,7 @@ class Directive { // What the directive is associated with. Association association = AS_FromLeaves; + + // The category if the directive. + Category category = ?; } diff --git a/llvm/include/llvm/Frontend/OpenACC/ACC.td b/llvm/include/llvm/Frontend/OpenACC/ACC.td index dfa6a222e9f77..30a81efe7f8a6 100644 --- a/llvm/include/llvm/Frontend/OpenACC/ACC.td +++ b/llvm/include/llvm/Frontend/OpenACC/ACC.td @@ -268,6 +268,7 @@ def ACCC_Unknown : Clause<"unknown"> { // 2.12 def ACC_Atomic : Directive<"atomic"> { let association = AS_Block; + let category = CA_Executable; } // 2.6.5 @@ -293,6 +294,7 @@ def ACC_Data : Directive<"data"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.13 @@ -308,6 +310,7 @@ def ACC_Declare : Directive<"declare"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.5.3 @@ -334,6 +337,7 @@ def ACC_Kernels : Directive<"kernels"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.5.1 @@ -363,6 +367,7 @@ def ACC_Parallel : Directive<"parallel"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.5.2 @@ -391,6 +396,7 @@ def ACC_Serial : Directive<"serial"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.9 @@ -411,11 +417,13 @@ def ACC_Loop : Directive<"loop"> { VersionedClause ]; let association = AS_Loop; + let category = CA_Executable; } // 2.10 def ACC_Cache : Directive<"cache"> { let association = AS_None; + let category = CA_Executable; } // 2.14.1 @@ -426,6 +434,7 @@ def ACC_Init : Directive<"init"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.15.1 @@ -442,6 +451,7 @@ def ACC_Routine : Directive<"routine"> { VersionedClause ]; let association = AS_Declaration; + let category = CA_Declarative; } // 2.14.3 @@ -461,6 +471,7 @@ def ACC_Set : Directive<"set"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.2 @@ -471,6 +482,7 @@ def ACC_Shutdown : Directive<"shutdown"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.4 @@ -490,6 +502,7 @@ def ACC_Update : Directive<"update"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.16.3 @@ -499,6 +512,7 @@ def ACC_Wait : Directive<"wait"> { VersionedClause ];
[llvm-branch-commits] [llvm] [Frontend] Introduce `getDirectiveCategory` for ACC/OMP directives (PR #94689)
llvmbot wrote: @llvm/pr-subscribers-flang-openmp Author: Krzysztof Parzyszek (kparzysz) Changes The categories are primarily meant for OpenMP, where the spec assigns a category to each directive. It's one of declarative, executable, informational, meta, subsidiary, and utility. These will be used in clang to avoid listing directives belonging to certain categories by hand. --- Patch is 39.92 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/94689.diff 7 Files Affected: - (modified) llvm/include/llvm/Frontend/Directive/DirectiveBase.td (+15) - (modified) llvm/include/llvm/Frontend/OpenACC/ACC.td (+21) - (modified) llvm/include/llvm/Frontend/OpenMP/OMP.td (+109) - (modified) llvm/include/llvm/TableGen/DirectiveEmitter.h (+6) - (modified) llvm/test/TableGen/directive1.td (+22-1) - (modified) llvm/test/TableGen/directive2.td (+22-1) - (modified) llvm/utils/TableGen/DirectiveEmitter.cpp (+30-1) ``diff diff --git a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td index ce532e0cfae29..6889c7e642ec6 100644 --- a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td +++ b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td @@ -156,6 +156,18 @@ def AS_FromLeaves : Association<"FromLeaves"> {}// See below // The name "AS_FromLeaves" is recognized by TableGen, and there is no enum // generated for it. +// Kinds of directive categories. +class Category { + string name = n; // Name of the enum value in enum class Category. +} + +def CA_Declarative: Category<"Declarative"> {} +def CA_Executable: Category<"Executable"> {} +def CA_Informational: Category<"Informational"> {} +def CA_Meta: Category<"Meta"> {} +def CA_Subsidiary: Category<"Subsidiary"> {} +def CA_Utility: Category<"Utility"> {} + // Information about a specific directive. class Directive { // Name of the directive. Can be composite directive sepearted by whitespace. @@ -190,4 +202,7 @@ class Directive { // What the directive is associated with. Association association = AS_FromLeaves; + + // The category if the directive. + Category category = ?; } diff --git a/llvm/include/llvm/Frontend/OpenACC/ACC.td b/llvm/include/llvm/Frontend/OpenACC/ACC.td index dfa6a222e9f77..30a81efe7f8a6 100644 --- a/llvm/include/llvm/Frontend/OpenACC/ACC.td +++ b/llvm/include/llvm/Frontend/OpenACC/ACC.td @@ -268,6 +268,7 @@ def ACCC_Unknown : Clause<"unknown"> { // 2.12 def ACC_Atomic : Directive<"atomic"> { let association = AS_Block; + let category = CA_Executable; } // 2.6.5 @@ -293,6 +294,7 @@ def ACC_Data : Directive<"data"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.13 @@ -308,6 +310,7 @@ def ACC_Declare : Directive<"declare"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.5.3 @@ -334,6 +337,7 @@ def ACC_Kernels : Directive<"kernels"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.5.1 @@ -363,6 +367,7 @@ def ACC_Parallel : Directive<"parallel"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.5.2 @@ -391,6 +396,7 @@ def ACC_Serial : Directive<"serial"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.9 @@ -411,11 +417,13 @@ def ACC_Loop : Directive<"loop"> { VersionedClause ]; let association = AS_Loop; + let category = CA_Executable; } // 2.10 def ACC_Cache : Directive<"cache"> { let association = AS_None; + let category = CA_Executable; } // 2.14.1 @@ -426,6 +434,7 @@ def ACC_Init : Directive<"init"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.15.1 @@ -442,6 +451,7 @@ def ACC_Routine : Directive<"routine"> { VersionedClause ]; let association = AS_Declaration; + let category = CA_Declarative; } // 2.14.3 @@ -461,6 +471,7 @@ def ACC_Set : Directive<"set"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.2 @@ -471,6 +482,7 @@ def ACC_Shutdown : Directive<"shutdown"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.4 @@ -490,6 +502,7 @@ def ACC_Update : Directive<"update"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.16.3 @@ -499,6 +512,7 @@ def ACC_Wait : Directive<"wait"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.6 @@ -516,6 +530,7 @@ def ACC_EnterData : Directive<"enter data"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.7 @@ -534,6 +549,7 @@ def ACC_ExitData : Directive<"exit data"> { VersionedClause ]; let association
[llvm-branch-commits] [llvm] [Frontend] Introduce `getDirectiveCategory` for ACC/OMP directives (PR #94689)
llvmbot wrote: @llvm/pr-subscribers-openacc Author: Krzysztof Parzyszek (kparzysz) Changes The categories are primarily meant for OpenMP, where the spec assigns a category to each directive. It's one of declarative, executable, informational, meta, subsidiary, and utility. These will be used in clang to avoid listing directives belonging to certain categories by hand. --- Patch is 39.92 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/94689.diff 7 Files Affected: - (modified) llvm/include/llvm/Frontend/Directive/DirectiveBase.td (+15) - (modified) llvm/include/llvm/Frontend/OpenACC/ACC.td (+21) - (modified) llvm/include/llvm/Frontend/OpenMP/OMP.td (+109) - (modified) llvm/include/llvm/TableGen/DirectiveEmitter.h (+6) - (modified) llvm/test/TableGen/directive1.td (+22-1) - (modified) llvm/test/TableGen/directive2.td (+22-1) - (modified) llvm/utils/TableGen/DirectiveEmitter.cpp (+30-1) ``diff diff --git a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td index ce532e0cfae29..6889c7e642ec6 100644 --- a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td +++ b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td @@ -156,6 +156,18 @@ def AS_FromLeaves : Association<"FromLeaves"> {}// See below // The name "AS_FromLeaves" is recognized by TableGen, and there is no enum // generated for it. +// Kinds of directive categories. +class Category { + string name = n; // Name of the enum value in enum class Category. +} + +def CA_Declarative: Category<"Declarative"> {} +def CA_Executable: Category<"Executable"> {} +def CA_Informational: Category<"Informational"> {} +def CA_Meta: Category<"Meta"> {} +def CA_Subsidiary: Category<"Subsidiary"> {} +def CA_Utility: Category<"Utility"> {} + // Information about a specific directive. class Directive { // Name of the directive. Can be composite directive sepearted by whitespace. @@ -190,4 +202,7 @@ class Directive { // What the directive is associated with. Association association = AS_FromLeaves; + + // The category if the directive. + Category category = ?; } diff --git a/llvm/include/llvm/Frontend/OpenACC/ACC.td b/llvm/include/llvm/Frontend/OpenACC/ACC.td index dfa6a222e9f77..30a81efe7f8a6 100644 --- a/llvm/include/llvm/Frontend/OpenACC/ACC.td +++ b/llvm/include/llvm/Frontend/OpenACC/ACC.td @@ -268,6 +268,7 @@ def ACCC_Unknown : Clause<"unknown"> { // 2.12 def ACC_Atomic : Directive<"atomic"> { let association = AS_Block; + let category = CA_Executable; } // 2.6.5 @@ -293,6 +294,7 @@ def ACC_Data : Directive<"data"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.13 @@ -308,6 +310,7 @@ def ACC_Declare : Directive<"declare"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.5.3 @@ -334,6 +337,7 @@ def ACC_Kernels : Directive<"kernels"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.5.1 @@ -363,6 +367,7 @@ def ACC_Parallel : Directive<"parallel"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.5.2 @@ -391,6 +396,7 @@ def ACC_Serial : Directive<"serial"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.9 @@ -411,11 +417,13 @@ def ACC_Loop : Directive<"loop"> { VersionedClause ]; let association = AS_Loop; + let category = CA_Executable; } // 2.10 def ACC_Cache : Directive<"cache"> { let association = AS_None; + let category = CA_Executable; } // 2.14.1 @@ -426,6 +434,7 @@ def ACC_Init : Directive<"init"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.15.1 @@ -442,6 +451,7 @@ def ACC_Routine : Directive<"routine"> { VersionedClause ]; let association = AS_Declaration; + let category = CA_Declarative; } // 2.14.3 @@ -461,6 +471,7 @@ def ACC_Set : Directive<"set"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.2 @@ -471,6 +482,7 @@ def ACC_Shutdown : Directive<"shutdown"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.4 @@ -490,6 +502,7 @@ def ACC_Update : Directive<"update"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.16.3 @@ -499,6 +512,7 @@ def ACC_Wait : Directive<"wait"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.6 @@ -516,6 +530,7 @@ def ACC_EnterData : Directive<"enter data"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.7 @@ -534,6 +549,7 @@ def ACC_ExitData : Directive<"exit data"> { VersionedClause ]; let association = AS_
[llvm-branch-commits] [clang] [clang][OpenMP] Shorten directive classification in ParseOpenMP (PR #94691)
https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/94691 Use directive categories to simplify long lists of `case` statements in the OpenMP parser. This is a step towards avoiding dependence on explicitly specified sets of directives that can be expressed more generically. The upcoming OpenMP 6.0 will introduce many new combined directives, and the more generically we handle directives, the easier the introduction of the new standard will be. >From 950ad6a14687f5eab41bf8cc8ed64d07d8ad0a3d Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 6 Jun 2024 15:52:31 -0500 Subject: [PATCH] [clang][OpenMP] Shorten directive classification in ParseOpenMP Use directive categories to simplify long lists of `case` statements in the OpenMP parser. This is a step towards avoiding dependence on explicitly specified sets of directives that can be expressed more generically. The upcoming OpenMP 6.0 will introduce many new combined directives, and the more generically we handle directives, the easier the introduction of the new standard will be. --- clang/include/clang/Parse/Parser.h | 13 + clang/lib/Parse/ParseOpenMP.cpp| 526 - 2 files changed, 230 insertions(+), 309 deletions(-) diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index d054b8cf0d240..88571a4a46f2c 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -3509,6 +3509,19 @@ class Parser : public CodeCompletionHandler { /// metadirective and therefore ends on the closing paren. StmtResult ParseOpenMPDeclarativeOrExecutableDirective( ParsedStmtContext StmtCtx, bool ReadDirectiveWithinMetadirective = false); + + /// Parses executable directive. + /// + /// \param StmtCtx The context in which we're parsing the directive. + /// \param DKind The kind of the executable directive. + /// \param Loc Source location of the beginning of the directive. + /// \param ReadDirectiveWithinMetadirective true if directive is within a + /// metadirective and therefore ends on the closing paren. + StmtResult + ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx, + OpenMPDirectiveKind DKind, SourceLocation Loc, + bool ReadDirectiveWithinMetadirective); + /// Parses clause of kind \a CKind for directive of a kind \a Kind. /// /// \param DKind Kind of current directive. diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 50a872fedebf7..a10bb009ec835 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2374,86 +2374,209 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl( case OMPD_unknown: Diag(Tok, diag::err_omp_unknown_directive); break; - case OMPD_parallel: - case OMPD_simd: - case OMPD_tile: - case OMPD_unroll: - case OMPD_task: - case OMPD_taskyield: + default: +switch (getDirectiveCategory(DKind)) { +case Category::Executable: +case Category::Meta: +case Category::Subsidiary: +case Category::Utility: + Diag(Tok, diag::err_omp_unexpected_directive) + << 1 << getOpenMPDirectiveName(DKind); + break; +default: + break; +} + } + while (Tok.isNot(tok::annot_pragma_openmp_end)) +ConsumeAnyToken(); + ConsumeAnyToken(); + return nullptr; +} + +StmtResult +Parser::ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx, + OpenMPDirectiveKind DKind, + SourceLocation Loc, + bool ReadDirectiveWithinMetadirective) { + bool HasAssociatedStatement = true; + + switch (DKind) { case OMPD_barrier: - case OMPD_taskwait: - case OMPD_taskgroup: - case OMPD_flush: + case OMPD_cancel: + case OMPD_cancellation_point: case OMPD_depobj: + case OMPD_error: + case OMPD_flush: + case OMPD_interop: case OMPD_scan: - case OMPD_for: - case OMPD_for_simd: - case OMPD_sections: - case OMPD_section: - case OMPD_single: - case OMPD_master: - case OMPD_ordered: - case OMPD_critical: - case OMPD_parallel_for: - case OMPD_parallel_for_simd: - case OMPD_parallel_sections: - case OMPD_parallel_master: - case OMPD_parallel_masked: - case OMPD_atomic: - case OMPD_target: - case OMPD_teams: - case OMPD_cancellation_point: - case OMPD_cancel: - case OMPD_target_data: case OMPD_target_enter_data: case OMPD_target_exit_data: - case OMPD_target_parallel: - case OMPD_target_parallel_for: - case OMPD_taskloop: - case OMPD_taskloop_simd: - case OMPD_master_taskloop: - case OMPD_master_taskloop_simd: - case OMPD_parallel_master_taskloop: - case OMPD_parallel_master_taskloop_simd: - case OMPD_masked_taskloop: - case OMPD_masked_taskloop_simd: - case OMPD_parallel_masked_taskloop: - case OMPD_parallel_masked_taskloop_simd: - case OMPD_distr
[llvm-branch-commits] [clang] [clang][OpenMP] Shorten directive classification in ParseOpenMP (PR #94691)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Krzysztof Parzyszek (kparzysz) Changes Use directive categories to simplify long lists of `case` statements in the OpenMP parser. This is a step towards avoiding dependence on explicitly specified sets of directives that can be expressed more generically. The upcoming OpenMP 6.0 will introduce many new combined directives, and the more generically we handle directives, the easier the introduction of the new standard will be. --- Patch is 21.05 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/94691.diff 2 Files Affected: - (modified) clang/include/clang/Parse/Parser.h (+13) - (modified) clang/lib/Parse/ParseOpenMP.cpp (+217-309) ``diff diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index d054b8cf0d240..88571a4a46f2c 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -3509,6 +3509,19 @@ class Parser : public CodeCompletionHandler { /// metadirective and therefore ends on the closing paren. StmtResult ParseOpenMPDeclarativeOrExecutableDirective( ParsedStmtContext StmtCtx, bool ReadDirectiveWithinMetadirective = false); + + /// Parses executable directive. + /// + /// \param StmtCtx The context in which we're parsing the directive. + /// \param DKind The kind of the executable directive. + /// \param Loc Source location of the beginning of the directive. + /// \param ReadDirectiveWithinMetadirective true if directive is within a + /// metadirective and therefore ends on the closing paren. + StmtResult + ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx, + OpenMPDirectiveKind DKind, SourceLocation Loc, + bool ReadDirectiveWithinMetadirective); + /// Parses clause of kind \a CKind for directive of a kind \a Kind. /// /// \param DKind Kind of current directive. diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 50a872fedebf7..a10bb009ec835 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2374,86 +2374,209 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl( case OMPD_unknown: Diag(Tok, diag::err_omp_unknown_directive); break; - case OMPD_parallel: - case OMPD_simd: - case OMPD_tile: - case OMPD_unroll: - case OMPD_task: - case OMPD_taskyield: + default: +switch (getDirectiveCategory(DKind)) { +case Category::Executable: +case Category::Meta: +case Category::Subsidiary: +case Category::Utility: + Diag(Tok, diag::err_omp_unexpected_directive) + << 1 << getOpenMPDirectiveName(DKind); + break; +default: + break; +} + } + while (Tok.isNot(tok::annot_pragma_openmp_end)) +ConsumeAnyToken(); + ConsumeAnyToken(); + return nullptr; +} + +StmtResult +Parser::ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx, + OpenMPDirectiveKind DKind, + SourceLocation Loc, + bool ReadDirectiveWithinMetadirective) { + bool HasAssociatedStatement = true; + + switch (DKind) { case OMPD_barrier: - case OMPD_taskwait: - case OMPD_taskgroup: - case OMPD_flush: + case OMPD_cancel: + case OMPD_cancellation_point: case OMPD_depobj: + case OMPD_error: + case OMPD_flush: + case OMPD_interop: case OMPD_scan: - case OMPD_for: - case OMPD_for_simd: - case OMPD_sections: - case OMPD_section: - case OMPD_single: - case OMPD_master: - case OMPD_ordered: - case OMPD_critical: - case OMPD_parallel_for: - case OMPD_parallel_for_simd: - case OMPD_parallel_sections: - case OMPD_parallel_master: - case OMPD_parallel_masked: - case OMPD_atomic: - case OMPD_target: - case OMPD_teams: - case OMPD_cancellation_point: - case OMPD_cancel: - case OMPD_target_data: case OMPD_target_enter_data: case OMPD_target_exit_data: - case OMPD_target_parallel: - case OMPD_target_parallel_for: - case OMPD_taskloop: - case OMPD_taskloop_simd: - case OMPD_master_taskloop: - case OMPD_master_taskloop_simd: - case OMPD_parallel_master_taskloop: - case OMPD_parallel_master_taskloop_simd: - case OMPD_masked_taskloop: - case OMPD_masked_taskloop_simd: - case OMPD_parallel_masked_taskloop: - case OMPD_parallel_masked_taskloop_simd: - case OMPD_distribute: case OMPD_target_update: - case OMPD_distribute_parallel_for: - case OMPD_distribute_parallel_for_simd: - case OMPD_distribute_simd: - case OMPD_target_parallel_for_simd: - case OMPD_target_simd: - case OMPD_scope: - case OMPD_teams_distribute: - case OMPD_teams_distribute_simd: - case OMPD_teams_distribute_parallel_for_simd: - case OMPD_teams_distribute_parallel_for: - case OMPD_target_teams: - case OMPD_target_teams_distribute: - case OMPD_target_teams_distribute_paralle
[llvm-branch-commits] [llvm] [Frontend] Introduce `getDirectiveCategory` for ACC/OMP directives (PR #94689)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/94689 >From 64fcf25e2158de44bccf725a0f91d8228b7cb7a5 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 6 Jun 2024 15:10:13 -0500 Subject: [PATCH 1/2] [Frontend] Introduce `getDirectiveCategory` for ACC/OMP directives The categories are primarily meant for OpenMP, where the spec assigns a category to each directive. It's one of declarative, executable, informational, meta, subsidiary, and utility. These will be used in clang to avoid listing directives belonging to certain categories by hand. --- .../llvm/Frontend/Directive/DirectiveBase.td | 15 +++ llvm/include/llvm/Frontend/OpenACC/ACC.td | 21 llvm/include/llvm/Frontend/OpenMP/OMP.td | 109 ++ llvm/include/llvm/TableGen/DirectiveEmitter.h | 6 + llvm/test/TableGen/directive1.td | 23 +++- llvm/test/TableGen/directive2.td | 23 +++- llvm/utils/TableGen/DirectiveEmitter.cpp | 31 - 7 files changed, 225 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td index ce532e0cfae29..6889c7e642ec6 100644 --- a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td +++ b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td @@ -156,6 +156,18 @@ def AS_FromLeaves : Association<"FromLeaves"> {}// See below // The name "AS_FromLeaves" is recognized by TableGen, and there is no enum // generated for it. +// Kinds of directive categories. +class Category { + string name = n; // Name of the enum value in enum class Category. +} + +def CA_Declarative: Category<"Declarative"> {} +def CA_Executable: Category<"Executable"> {} +def CA_Informational: Category<"Informational"> {} +def CA_Meta: Category<"Meta"> {} +def CA_Subsidiary: Category<"Subsidiary"> {} +def CA_Utility: Category<"Utility"> {} + // Information about a specific directive. class Directive { // Name of the directive. Can be composite directive sepearted by whitespace. @@ -190,4 +202,7 @@ class Directive { // What the directive is associated with. Association association = AS_FromLeaves; + + // The category if the directive. + Category category = ?; } diff --git a/llvm/include/llvm/Frontend/OpenACC/ACC.td b/llvm/include/llvm/Frontend/OpenACC/ACC.td index dfa6a222e9f77..30a81efe7f8a6 100644 --- a/llvm/include/llvm/Frontend/OpenACC/ACC.td +++ b/llvm/include/llvm/Frontend/OpenACC/ACC.td @@ -268,6 +268,7 @@ def ACCC_Unknown : Clause<"unknown"> { // 2.12 def ACC_Atomic : Directive<"atomic"> { let association = AS_Block; + let category = CA_Executable; } // 2.6.5 @@ -293,6 +294,7 @@ def ACC_Data : Directive<"data"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.13 @@ -308,6 +310,7 @@ def ACC_Declare : Directive<"declare"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.5.3 @@ -334,6 +337,7 @@ def ACC_Kernels : Directive<"kernels"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.5.1 @@ -363,6 +367,7 @@ def ACC_Parallel : Directive<"parallel"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.5.2 @@ -391,6 +396,7 @@ def ACC_Serial : Directive<"serial"> { VersionedClause ]; let association = AS_Block; + let category = CA_Executable; } // 2.9 @@ -411,11 +417,13 @@ def ACC_Loop : Directive<"loop"> { VersionedClause ]; let association = AS_Loop; + let category = CA_Executable; } // 2.10 def ACC_Cache : Directive<"cache"> { let association = AS_None; + let category = CA_Executable; } // 2.14.1 @@ -426,6 +434,7 @@ def ACC_Init : Directive<"init"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.15.1 @@ -442,6 +451,7 @@ def ACC_Routine : Directive<"routine"> { VersionedClause ]; let association = AS_Declaration; + let category = CA_Declarative; } // 2.14.3 @@ -461,6 +471,7 @@ def ACC_Set : Directive<"set"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.2 @@ -471,6 +482,7 @@ def ACC_Shutdown : Directive<"shutdown"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.4 @@ -490,6 +502,7 @@ def ACC_Update : Directive<"update"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.16.3 @@ -499,6 +512,7 @@ def ACC_Wait : Directive<"wait"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.6 @@ -516,6 +530,7 @@ def ACC_EnterData : Directive<"enter data"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; } // 2.14.7 @@ -534,6 +549,7 @@ def ACC_E
[llvm-branch-commits] [llvm] [Frontend] Introduce `getDirectiveCategory` for ACC/OMP directives (PR #94689)
@@ -308,6 +310,7 @@ def ACC_Declare : Directive<"declare"> { VersionedClause ]; let association = AS_None; + let category = CA_Executable; clementval wrote: ```suggestion let category = CA_Declarative; ``` https://github.com/llvm/llvm-project/pull/94689 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Coverage] Handles macros from system headers and nested macros in scratch space (PR #94438)
https://github.com/whentojump closed https://github.com/llvm/llvm-project/pull/94438 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [RISCV][MC] Warn if SEW/LMUL may not be compatible (PR #94313)
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/94313 >From 6e3d6329300e27a23481df3e6e01b9763a34d9d2 Mon Sep 17 00:00:00 2001 From: Wang Pengcheng Date: Thu, 6 Jun 2024 15:05:20 +0800 Subject: [PATCH 1/2] Address comments Created using spr 1.3.6-beta.1 --- .../Target/RISCV/AsmParser/RISCVAsmParser.cpp | 17 +++-- llvm/test/MC/RISCV/rvv/vsetvl.s | 6 +++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 4091f9d5e9f8a..49f21e46f34ea 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -2160,10 +2160,9 @@ bool RISCVAsmParser::parseVTypeToken(const AsmToken &Tok, VTypeState &State, unsigned ELEN = STI->hasFeature(RISCV::FeatureStdExtZve64x) ? 64 : 32; unsigned MinLMUL = ELEN / 8; if (Lmul > MinLMUL) -Warning( -Tok.getLoc(), -Twine("The use of vtype encodings with LMUL < SEWMIN/ELEN == mf") + -Twine(MinLMUL) + Twine(" is reserved")); +Warning(Tok.getLoc(), +"use of vtype encodings with LMUL < SEWMIN/ELEN == mf" + +Twine(MinLMUL) + " is reserved"); } State = VTypeState_TailPolicy; @@ -2228,12 +2227,10 @@ ParseStatus RISCVAsmParser::parseVTypeI(OperandVector &Operands) { unsigned MaxSEW = ELEN / Lmul; // If MaxSEW < 8, we should have printed warning about reserved LMUL. if (MaxSEW >= 8 && Sew > MaxSEW) -Warning( -SEWLoc, -Twine("The use of vtype encodings with SEW > ") + Twine(MaxSEW) + -Twine(" and LMUL == ") + Twine(Fractional ? "mf" : "m") + -Twine(Lmul) + -Twine(" may not be compatible with all RVV implementations")); +Warning(SEWLoc, +"use of vtype encodings with SEW > " + Twine(MaxSEW) + +" and LMUL == " + (Fractional ? "mf" : "m") + Twine(Lmul) + +" may not be compatible with all RVV implementations"); } unsigned VTypeI = diff --git a/llvm/test/MC/RISCV/rvv/vsetvl.s b/llvm/test/MC/RISCV/rvv/vsetvl.s index 207daf392bd50..2741def0eeff2 100644 --- a/llvm/test/MC/RISCV/rvv/vsetvl.s +++ b/llvm/test/MC/RISCV/rvv/vsetvl.s @@ -73,21 +73,21 @@ vsetvli a2, a0, e32, m8, ta, ma vsetvli a2, a0, e32, mf2, ta, ma # CHECK-INST: vsetvli a2, a0, e32, mf2, ta, ma -# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: The use of vtype encodings with SEW > 16 and LMUL == mf2 may not be compatible with all RVV implementations{{$}} +# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: use of vtype encodings with SEW > 16 and LMUL == mf2 may not be compatible with all RVV implementations{{$}} # CHECK-ENCODING: [0x57,0x76,0x75,0x0d] # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' (Vector Extensions for Embedded Processors){{$}} # CHECK-UNKNOWN: 0d757657 vsetvli a2, a0, e32, mf4, ta, ma # CHECK-INST: vsetvli a2, a0, e32, mf4, ta, ma -# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: The use of vtype encodings with SEW > 8 and LMUL == mf4 may not be compatible with all RVV implementations{{$}} +# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: use of vtype encodings with SEW > 8 and LMUL == mf4 may not be compatible with all RVV implementations{{$}} # CHECK-ENCODING: [0x57,0x76,0x65,0x0d] # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' (Vector Extensions for Embedded Processors){{$}} # CHECK-UNKNOWN: 0d657657 vsetvli a2, a0, e32, mf8, ta, ma # CHECK-INST: vsetvli a2, a0, e32, mf8, ta, ma -# CHECK-ZVE32X: :[[#@LINE-2]]:22: warning: The use of vtype encodings with LMUL < SEWMIN/ELEN == mf4 is reserved{{$}} +# CHECK-ZVE32X: :[[#@LINE-2]]:22: warning: use of vtype encodings with LMUL < SEWMIN/ELEN == mf4 is reserved{{$}} # CHECK-ENCODING: [0x57,0x76,0x55,0x0d] # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' (Vector Extensions for Embedded Processors){{$}} # CHECK-UNKNOWN: 0d557657 >From 6b44742cfcc24a07408bbe20070f57ebaa4e9066 Mon Sep 17 00:00:00 2001 From: Wang Pengcheng Date: Fri, 7 Jun 2024 11:27:13 +0800 Subject: [PATCH 2/2] Remove Fractional Created using spr 1.3.6-beta.1 --- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 49f21e46f34ea..ca11d155ec7c6 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -2229,7 +2229,7 @@ ParseStatus RISCVAsmParser::parseVTypeI(OperandVector &Operands) { if (MaxSEW >= 8 && Sew > MaxSEW)
[llvm-branch-commits] [llvm] [RISCV][MC] Warn if SEW/LMUL may not be compatible (PR #94313)
@@ -2211,6 +,16 @@ ParseStatus RISCVAsmParser::parseVTypeI(OperandVector &Operands) { if (getLexer().is(AsmToken::EndOfStatement) && State == VTypeState_Done) { RISCVII::VLMUL VLMUL = RISCVVType::encodeLMUL(Lmul, Fractional); +if (Fractional) { + unsigned ELEN = STI->hasFeature(RISCV::FeatureStdExtZve64x) ? 64 : 32; + unsigned MaxSEW = ELEN / Lmul; + // If MaxSEW < 8, we should have printed warning about reserved LMUL. + if (MaxSEW >= 8 && Sew > MaxSEW) +Warning(SEWLoc, +"use of vtype encodings with SEW > " + Twine(MaxSEW) + +" and LMUL == " + (Fractional ? "mf" : "m") + Twine(Lmul) + wangpc-pp wrote: Good catch! https://github.com/llvm/llvm-project/pull/94313 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// This header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF EricWF wrote: I really dislike this. It produces terrible diagnostics for users. I feel like we could find another way to represent the function type so we can limit the duplication. If we strip the qualifiers and turn them into an enumeration like `_Const|_RValue|_Noexcept`, we could use a traits class to produce the correct function types as needed. We still have to spell out the top level `move_only_function` class a few times, but we can implement everything in a base that takes this enumeration and the desugared type. https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,80 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef MOVE_ONLY_FUNCTION_COMMON_H +#define MOVE_ONLY_FUNCTION_COMMON_H + +#include +#include + +inline bool called; +inline void call_func() noexcept { called = true; } + +struct MoveCounter { + int* counter_; + MoveCounter(int* counter) : counter_(counter) {} + MoveCounter(MoveCounter&& other) : counter_(other.counter_) { ++*counter_; } +}; + +struct TriviallyDestructible { + TriviallyDestructible() = default; + TriviallyDestructible(MoveCounter) {} + TriviallyDestructible(std::initializer_list, MoveCounter) {} + void operator()() const noexcept { called = true; } + int operator()(int i) const noexcept { return i; } +}; + +struct TriviallyDestructibleTooLarge { + TriviallyDestructibleTooLarge() = default; + TriviallyDestructibleTooLarge(MoveCounter) {} + TriviallyDestructibleTooLarge(std::initializer_list, MoveCounter) {} + void operator()() const noexcept { called = true; } + int operator()(int i) const noexcept { return i; } + char a[5 * sizeof(void*)]; +}; + +struct NonTrivial { + NonTrivial() = default; + NonTrivial(MoveCounter) {} + NonTrivial(std::initializer_list&, MoveCounter) {} + NonTrivial(NonTrivial&&) noexcept(false) {} + ~NonTrivial() {} + + void operator()() const noexcept { called = true; } + int operator()(int i) const noexcept { return i; } +}; + +inline int get_val(int i) noexcept { return i; } + +enum class CallType { + None, + LValue, + RValue, + ConstLValue, + ConstRValue, +}; + +struct CallTypeChecker { + CallType* type; + using enum CallType; EricWF wrote: Nice types. https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// This header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV& +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT +# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT false +#endif + +#define _LIBCPP_MOVE_ONLY_FUNCTION_CVREF _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifdef _LIBCPP_ABI_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI [[_Clang::__trivial_abi__]] +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +#endif + +template +class move_only_function; + +template +class _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI move_only_function<_ReturnT( +_ArgTypes...) _LIBCPP_MOVE_ONLY_FUNCTION_CVREF noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT)> { +private: + static constexpr size_t __buffer_size_ = 3 * sizeof(void*); + static constexpr size_t __buffer_alignment_ = alignof(void*); + using _BufferT = __small_buffer<__buffer_size_, __buffer_alignment_>; + + using _TrivialVTable= _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + using _NonTrivialVTable = _MoveOnlyFunctionNonTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + + template + static constexpr _TrivialVTable __trivial_vtable_ = { + .__call_ = [](_BufferT& __buffer, _ArgTypes... __args) noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) -> _ReturnT { +return std::invoke_r<_ReturnT>( +static_cast<_Functor _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS>(*__buffer.__get<_Functor>()), +std::forward<_ArgTypes>(__args)...); + }}; + + template + static constexpr _NonTrivialVTable __non_trivial_vtable_{ + __trivial_vtable_<_Functor>, + [](_BufferT& __buffer) noexcept -> void { +std::destroy_at(__buffer.__get<_Functor>()); +__buffer.__dealloc<_Functor>(); + }, + }; + + template + _LIBCPP_HIDE_FROM_ABI __pointer_bool_pair __get_vptr() { +if constexpr (_BufferT::__fits_in_buffer<_Functor> && is_trivially_destructible_v<_Functor>) { + return {&__trivial_vtable_<_Functor>, false}; +} else { + return {&__non_trivial_vtable_<_Functor>, true}; +} + } + + template + static constexpr bool __is_callable_from = [] { +using _DVT = decay_t<_VT>; +if (_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) { + return is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} else { + return is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} + }(); + + template + _LIBCPP_HIDE_FROM_ABI void __construct(_Args&&... __args) { +static_assert(is_constructible_v, _Func>); + +using _StoredFunc = decay_t<_Func>; +__vtable_ = __get_vptr<_StoredFunc>(); +__buffer_.__construct<_StoredFunc>(std::forward<_Args>(__args)...); + } + + _LIBCPP_HIDE_FROM_ABI void __reset() { +if (__vtable_.__get_value()) EricWF wrote: ```if (__vtable_->__destroy) { __vtable_->__destroy(__buffer_); } ``` https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mai
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,46 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_COMMON_H +#define _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_COMMON_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +class move_only_function; + +template +struct __is_move_only_function : false_type {}; + +template +struct __is_move_only_function> : true_type {}; + +template +struct _MoveOnlyFunctionTrivialVTable { + using _CallFunc = _ReturnT(_BufferT&, _ArgTypes...); + + _CallFunc* __call_; +}; + +template +struct _MoveOnlyFunctionNonTrivialVTable : _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...> { EricWF wrote: We don't need to instantiate this type with `_ReturnT` or `_ArgTypes...`. That's alot of template bloat. https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// This header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF EricWF wrote: Here's what I'm imagining... ```c++ #ifndef _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_H #define _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_H #include <__assert> #include <__config> #include <__functional/invoke.h> #include <__type_traits/decay.h> #include <__type_traits/invoke.h> #include <__type_traits/is_function.h> #include <__type_traits/is_member_function_pointer.h> #include <__type_traits/is_pointer.h> #include <__type_traits/is_same.h> #include <__type_traits/is_trivially_constructible.h> #include <__type_traits/is_trivially_destructible.h> #include <__type_traits/remove_cvref.h> #include <__type_traits/remove_pointer.h> #include <__utility/forward.h> #include <__utility/in_place.h> #include <__utility/swap.h> #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD enum class _Quals : unsigned { _None = 0, _Const= 1, _RVRef= 2, _LVRef= 4, _NoExcept = 8, }; constexpr _Quals operator|(_Quals __x, _Quals __y) { return static_cast<_Quals>(static_cast(__x) | static_cast(__y)); } constexpr _Quals operator&(_Quals __x, _Quals __y) { return static_cast<_Quals>(static_cast(__x) & static_cast(__y)); } constexpr _Quals operator^(_Quals __x, _Quals __y) { return static_cast<_Quals>(static_cast(__x) ^ static_cast(__y)); } constexpr _Quals operator~(_Quals __x) { return static_cast<_Quals>(~static_cast(__x)); } constexpr bool operator==(const _Quals __x, const _Quals __y) { return static_cast(__x) == static_cast(__y); } constexpr bool operator!=(const _Quals __x, const _Quals __y) { return static_cast(__x) != static_cast(__y); } constexpr _Quals __cvref_quals(_Quals __q) { return __q & (_Quals::_Const | _Quals::_RVRef | _Quals::_LVRef); } constexpr bool __is_noexcept(_Quals __q) { return (__q & _Quals::_NoExcept) == _Quals::_NoExcept; } constexpr _Quals __ref_quals(_Quals __q) { return __q & (_Quals::_RVRef | _Quals::_LVRef); } template struct __unqualify_type; template struct __unqualify_type<_Ret(_Args...)> { using type = _Ret(_Args...); static constexpr _Quals __qual = _Quals::_None; }; template struct __unqualify_type<_Ret(_Args...) const> { using type = _Ret(_Args...); static constexpr _Quals __qual = _Quals::_Const; }; template struct __unqualify_type<_Ret(_Args...)&> { using type = _Ret(_Args...); static constexpr _Quals __qual = _Quals::_None | _Quals::_LVRef; }; template struct __unqualify_type<_Ret(_Args...) const&> { using type = _Ret(_Args...); static constexpr _Quals __qual = _Quals::_Const | _Quals::_LVRef; }; template struct __unqualify_type<_Ret(_Args...) &&> { using type = _Ret(_Args...); static constexpr _Quals __qual = _Quals::_None | _Quals::_RVRef; }; template struct __unqualify_type<_Ret(_Args...) const&&> { using type = _Ret(_Args...); static constexpr _Quals __qual = _Quals::_Const | _Quals::_RVRef; }; template struct __unqualify_type<_Ret(_Args...) noexcept> { using type = _Ret(_Args...); static constexpr _Quals __qual = _Quals::_None | _Quals::_NoExcept; }; template struct __unqualify_type<_Ret(_Args...) const noexcept> { using type = _Ret(_Args...); static constexpr _Quals __qual = _Quals::_Const | _Quals::_NoExcept; }; template struct __unqualify_type<_Ret(_Args...) & noexcept> { using type = _Ret(_Args...); static constexpr _Quals __qual = _Qual
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
https://github.com/EricWF edited https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
https://github.com/EricWF edited https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
https://github.com/EricWF edited https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
https://github.com/EricWF edited https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// This header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV& +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT +# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT false +#endif + +#define _LIBCPP_MOVE_ONLY_FUNCTION_CVREF _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifdef _LIBCPP_ABI_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI [[_Clang::__trivial_abi__]] +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +#endif + +template +class move_only_function; + +template +class _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI move_only_function<_ReturnT( +_ArgTypes...) _LIBCPP_MOVE_ONLY_FUNCTION_CVREF noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT)> { +private: + static constexpr size_t __buffer_size_ = 3 * sizeof(void*); + static constexpr size_t __buffer_alignment_ = alignof(void*); + using _BufferT = __small_buffer<__buffer_size_, __buffer_alignment_>; + + using _TrivialVTable= _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + using _NonTrivialVTable = _MoveOnlyFunctionNonTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + + template + static constexpr _TrivialVTable __trivial_vtable_ = { + .__call_ = [](_BufferT& __buffer, _ArgTypes... __args) noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) -> _ReturnT { +return std::invoke_r<_ReturnT>( +static_cast<_Functor _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS>(*__buffer.__get<_Functor>()), +std::forward<_ArgTypes>(__args)...); + }}; + + template + static constexpr _NonTrivialVTable __non_trivial_vtable_{ + __trivial_vtable_<_Functor>, + [](_BufferT& __buffer) noexcept -> void { +std::destroy_at(__buffer.__get<_Functor>()); +__buffer.__dealloc<_Functor>(); + }, + }; + + template + _LIBCPP_HIDE_FROM_ABI __pointer_bool_pair __get_vptr() { +if constexpr (_BufferT::__fits_in_buffer<_Functor> && is_trivially_destructible_v<_Functor>) { + return {&__trivial_vtable_<_Functor>, false}; +} else { + return {&__non_trivial_vtable_<_Functor>, true}; +} + } + + template + static constexpr bool __is_callable_from = [] { +using _DVT = decay_t<_VT>; +if (_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) { + return is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} else { + return is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} + }(); + + template + _LIBCPP_HIDE_FROM_ABI void __construct(_Args&&... __args) { +static_assert(is_constructible_v, _Func>); + +using _StoredFunc = decay_t<_Func>; +__vtable_ = __get_vptr<_StoredFunc>(); +__buffer_.__construct<_StoredFunc>(std::forward<_Args>(__args)...); + } + + _LIBCPP_HIDE_FROM_ABI void __reset() { +if (__vtable_.__get_value()) philnik777 wrote: Did you mean to write something? https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// This header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF philnik777 wrote: Can you give an example? A few people already claimed that it gives terrible diagnostics, but I've yet to see one. https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,46 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_COMMON_H +#define _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_COMMON_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +class move_only_function; + +template +struct __is_move_only_function : false_type {}; + +template +struct __is_move_only_function> : true_type {}; + +template +struct _MoveOnlyFunctionTrivialVTable { + using _CallFunc = _ReturnT(_BufferT&, _ArgTypes...); + + _CallFunc* __call_; +}; + +template +struct _MoveOnlyFunctionNonTrivialVTable : _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...> { philnik777 wrote: Could you elaborate? I don't see how we can have the vtable function pointer without the template arguments. https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits