[llvm-branch-commits] [flang] [flang] Implement tanpi (PR #149527)
https://github.com/c8ef created https://github.com/llvm/llvm-project/pull/149527
None
>From b1c844ef619540c36898b2194f7599f056c80805 Mon Sep 17 00:00:00 2001
From: c8ef
Date: Fri, 18 Jul 2025 15:04:52 +
Subject: [PATCH] [flang] Implement tanpi
---
.../flang/Optimizer/Builder/IntrinsicCall.h | 1 +
flang/lib/Evaluate/intrinsics.cpp | 1 +
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 16 ++
flang/test/Lower/Intrinsics/tanpi.f90 | 22 +++
4 files changed, 40 insertions(+)
create mode 100644 flang/test/Lower/Intrinsics/tanpi.f90
diff --git a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
index d84d3593ebca6..ab08415fe32c8 100644
--- a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
@@ -439,6 +439,7 @@ struct IntrinsicLibrary {
mlir::ArrayRef args);
void genSystemClock(llvm::ArrayRef);
mlir::Value genTand(mlir::Type, llvm::ArrayRef);
+ mlir::Value genTanpi(mlir::Type, llvm::ArrayRef);
mlir::Value genTime(mlir::Type, llvm::ArrayRef);
mlir::Value genTrailz(mlir::Type, llvm::ArrayRef);
fir::ExtendedValue genTransfer(mlir::Type,
diff --git a/flang/lib/Evaluate/intrinsics.cpp
b/flang/lib/Evaluate/intrinsics.cpp
index d44239b41fa20..9c6d49dfda3e8 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -989,6 +989,7 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
{"tan", {{"x", SameFloating}}, SameFloating},
{"tand", {{"x", SameFloating}}, SameFloating},
{"tanh", {{"x", SameFloating}}, SameFloating},
+{"tanpi", {{"x", SameFloating}}, SameFloating},
{"team_number", {OptionalTEAM}, DefaultInt, Rank::scalar,
IntrinsicClass::transformationalFunction},
{"this_image",
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 823b1eb887992..c7758df695db2 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -942,6 +942,7 @@ static constexpr IntrinsicHandler handlers[]{
{{{"count", asAddr}, {"count_rate", asAddr}, {"count_max", asAddr}}},
/*isElemental=*/false},
{"tand", &I::genTand},
+{"tanpi", &I::genTanpi},
{"this_grid", &I::genThisGrid, {}, /*isElemental=*/false},
{"this_thread_block", &I::genThisThreadBlock, {}, /*isElemental=*/false},
{"this_warp", &I::genThisWarp, {}, /*isElemental=*/false},
@@ -8157,6 +8158,21 @@ mlir::Value IntrinsicLibrary::genTand(mlir::Type
resultType,
return getRuntimeCallGenerator("tan", ftype)(builder, loc, {arg});
}
+// TANPI
+mlir::Value IntrinsicLibrary::genTanpi(mlir::Type resultType,
+ llvm::ArrayRef args) {
+ assert(args.size() == 1);
+ mlir::MLIRContext *context = builder.getContext();
+ mlir::FunctionType ftype =
+ mlir::FunctionType::get(context, {resultType}, {args[0].getType()});
+ llvm::APFloat pi = llvm::APFloat(llvm::numbers::pi);
+ mlir::Value dfactor =
+ builder.createRealConstant(loc, mlir::Float64Type::get(context), pi);
+ mlir::Value factor = builder.createConvert(loc, args[0].getType(), dfactor);
+ mlir::Value arg = builder.create(loc, args[0], factor);
+ return getRuntimeCallGenerator("tan", ftype)(builder, loc, {arg});
+}
+
// THIS_GRID
mlir::Value IntrinsicLibrary::genThisGrid(mlir::Type resultType,
llvm::ArrayRef args) {
diff --git a/flang/test/Lower/Intrinsics/tanpi.f90
b/flang/test/Lower/Intrinsics/tanpi.f90
new file mode 100644
index 0..9cc3ae6ef1563
--- /dev/null
+++ b/flang/test/Lower/Intrinsics/tanpi.f90
@@ -0,0 +1,22 @@
+! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s --check-prefixes="CHECK"
+
+function test_real4(x)
+ real :: x, test_real4
+ test_real4 = tanpi(x)
+end function
+
+! CHECK-LABEL: @_QPtest_real4
+! CHECK: %[[dfactor:.*]] = arith.constant 3.1415926535897931 : f64
+! CHECK: %[[factor:.*]] = fir.convert %[[dfactor]] : (f64) -> f32
+! CHECK: %[[mul:.*]] = arith.mulf %{{.*}}, %[[factor]] fastmath : f32
+! CHECK: %[[tan:.*]] = math.tan %[[mul]] fastmath : f32
+
+function test_real8(x)
+ real(8) :: x, test_real8
+ test_real8 = tanpi(x)
+end function
+
+! CHECK-LABEL: @_QPtest_real8
+! CHECK: %[[dfactor:.*]] = arith.constant 3.1415926535897931 : f64
+! CHECK: %[[mul:.*]] = arith.mulf %{{.*}}, %[[dfactor]] fastmath :
f64
+! CHECK: %[[tan:.*]] = math.tan %[[mul]] fastmath : f64
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [flang] Implement `tanpi` (PR #149527)
https://github.com/c8ef ready_for_review https://github.com/llvm/llvm-project/pull/149527 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [flang] Implement `tanpi` (PR #149527)
https://github.com/c8ef edited https://github.com/llvm/llvm-project/pull/149527 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [flang] Implement `tanpi` (PR #149527)
c8ef wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/149527?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#149527** https://app.graphite.dev/github/pr/llvm/llvm-project/149527?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/149527?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#149525** https://app.graphite.dev/github/pr/llvm/llvm-project/149525?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/149527 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [flang] Implement `asinpi` (PR #150238)
https://github.com/c8ef created https://github.com/llvm/llvm-project/pull/150238
None
>From 5f1e70f3486f5e66ff3db5bf3a56095632118d1d Mon Sep 17 00:00:00 2001
From: c8ef
Date: Wed, 23 Jul 2025 15:20:37 +
Subject: [PATCH] [flang] Implement `asinpi`
---
.../flang/Optimizer/Builder/IntrinsicCall.h | 1 +
flang/lib/Evaluate/intrinsics.cpp | 1 +
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 16
flang/test/Lower/Intrinsics/asinpi.f90| 26 +++
4 files changed, 44 insertions(+)
create mode 100644 flang/test/Lower/Intrinsics/asinpi.f90
diff --git a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
index a93b397240576..2afd50410ae82 100644
--- a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
@@ -204,6 +204,7 @@ struct IntrinsicLibrary {
fir::ExtendedValue
genCommandArgumentCount(mlir::Type, llvm::ArrayRef);
mlir::Value genAsind(mlir::Type, llvm::ArrayRef);
+ mlir::Value genAsinpi(mlir::Type, llvm::ArrayRef);
fir::ExtendedValue genAssociated(mlir::Type,
llvm::ArrayRef);
mlir::Value genAtand(mlir::Type, llvm::ArrayRef);
diff --git a/flang/lib/Evaluate/intrinsics.cpp
b/flang/lib/Evaluate/intrinsics.cpp
index 97e87935c02b0..768e4bafa90ee 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -359,6 +359,7 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
{"asin", {{"x", SameFloating}}, SameFloating},
{"asind", {{"x", SameFloating}}, SameFloating},
{"asinh", {{"x", SameFloating}}, SameFloating},
+{"asinpi", {{"x", SameFloating}}, SameFloating},
{"associated",
{{"pointer", AnyPointer, Rank::anyOrAssumedRank, Optionality::required,
common::Intent::In, {ArgFlag::canBeNullPointer}},
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index f3af423b24685..4753d0add6787 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -279,6 +279,7 @@ static constexpr IntrinsicHandler handlers[]{
{{{"mask", asValue}, {"pred", asValue}}},
/*isElemental=*/false},
{"asind", &I::genAsind},
+{"asinpi", &I::genAsinpi},
{"associated",
&I::genAssociated,
{{{"pointer", asInquired}, {"target", asInquired}}},
@@ -2845,6 +2846,21 @@ mlir::Value IntrinsicLibrary::genAsind(mlir::Type
resultType,
return mlir::arith::MulFOp::create(builder, loc, result, factor);
}
+// ASINPI
+mlir::Value IntrinsicLibrary::genAsinpi(mlir::Type resultType,
+llvm::ArrayRef args) {
+ assert(args.size() == 1);
+ mlir::MLIRContext *context = builder.getContext();
+ mlir::FunctionType ftype =
+ mlir::FunctionType::get(context, {resultType}, {args[0].getType()});
+ mlir::Value asin = getRuntimeCallGenerator("asin", ftype)(builder, loc,
args);
+ llvm::APFloat inv_pi = llvm::APFloat(llvm::numbers::inv_pi);
+ mlir::Value dfactor =
+ builder.createRealConstant(loc, mlir::Float64Type::get(context), inv_pi);
+ mlir::Value factor = builder.createConvert(loc, resultType, dfactor);
+ return mlir::arith::MulFOp::create(builder, loc, asin, factor);
+}
+
// ATAND, ATAN2D
mlir::Value IntrinsicLibrary::genAtand(mlir::Type resultType,
llvm::ArrayRef args) {
diff --git a/flang/test/Lower/Intrinsics/asinpi.f90
b/flang/test/Lower/Intrinsics/asinpi.f90
new file mode 100644
index 0..1c1838c56ca27
--- /dev/null
+++ b/flang/test/Lower/Intrinsics/asinpi.f90
@@ -0,0 +1,26 @@
+! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
--check-prefixes="CHECK,CHECK-FAST"
+! RUN: bbc --math-runtime=precise -emit-fir -hlfir=false %s -o - | FileCheck
%s --check-prefixes="CHECK,CHECK-PRECISE"
+! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
--check-prefixes="CHECK,CHECK-FAST"
+
+function test_real4(x)
+ real :: x, test_real4
+ test_real4 = asinpi(x)
+end function
+
+! CHECK-LABEL: @_QPtest_real4
+! CHECK-PRECISE: %[[asin:.*]] = fir.call @asinf({{%[A-Za-z0-9._]+}})
fastmath : (f32) -> f32
+! CHECK-FAST: %[[asin:.*]] = math.asin %{{.*}} : f32
+! CHECK: %[[dpi:.*]] = arith.constant 0.31830988618379069 : f64
+! CHECK: %[[inv_pi:.*]] = fir.convert %[[dpi]] : (f64) -> f32
+! CHECK: %{{.*}} = arith.mulf %[[asin]], %[[inv_pi]] fastmath : f32
+
+function test_real8(x)
+ real(8) :: x, test_real8
+ test_real8 = asinpi(x)
+end function
+
+! CHECK-LABEL: @_QPtest_real8
+! CHECK-PRECISE: %[[asin:.*]] = fir.call @asin({{%[A-Za-z0-9._]+}})
fastmath : (f64) -> f64
+! CHECK-FAST: %[[asin:.*]] = math.asin %{{.*}} : f64
+! CHECK: %[[inv_pi:.*]] = arith.constant 0.31830988618379069 : f64
+! CHECK: %{{.*}} = arith.mulf %[[asin]], %[[inv_pi]] fastmath : f64
__
[llvm-branch-commits] [flang] [flang] Implement `asinpi` (PR #150238)
https://github.com/c8ef ready_for_review https://github.com/llvm/llvm-project/pull/150238 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [flang] Implement `asinpi` (PR #150238)
c8ef wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/150238?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#150238** https://app.graphite.dev/github/pr/llvm/llvm-project/150238?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/150238?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#150234** https://app.graphite.dev/github/pr/llvm/llvm-project/150234?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/150238 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [flang] Implement `asinpi` (PR #150238)
c8ef wrote: ### Merge activity * **Jul 23, 3:52 PM UTC**: A user started a stack merge that includes this pull request via [Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/150238). https://github.com/llvm/llvm-project/pull/150238 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [flang] Implement `tanpi` (PR #149527)
@@ -8157,6 +8158,21 @@ mlir::Value IntrinsicLibrary::genTand(mlir::Type
resultType,
return getRuntimeCallGenerator("tan", ftype)(builder, loc, {arg});
}
+// TANPI
+mlir::Value IntrinsicLibrary::genTanpi(mlir::Type resultType,
+ llvm::ArrayRef args) {
+ assert(args.size() == 1);
+ mlir::MLIRContext *context = builder.getContext();
+ mlir::FunctionType ftype =
+ mlir::FunctionType::get(context, {resultType}, {args[0].getType()});
+ llvm::APFloat pi = llvm::APFloat(llvm::numbers::pi);
+ mlir::Value dfactor =
+ builder.createRealConstant(loc, mlir::Float64Type::get(context), pi);
+ mlir::Value factor = builder.createConvert(loc, args[0].getType(), dfactor);
c8ef wrote:
Based on our discussion in #149525, I believe this patch is ready to go, too?
My current plan is to first implement the missing trigonometric pi functions,
and then address the constant pi problem. I'll open an issue to track this.
https://github.com/llvm/llvm-project/pull/149527
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_LOOPBACK` (PR #172312)
https://github.com/c8ef ready_for_review https://github.com/llvm/llvm-project/pull/172312 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_LOOPBACK` (PR #172312)
https://github.com/c8ef created https://github.com/llvm/llvm-project/pull/172312
None
>From 77c407bc401353723cc0a5d684c9e17102d0559b Mon Sep 17 00:00:00 2001
From: c8ef
Date: Mon, 15 Dec 2025 23:01:04 +0800
Subject: [PATCH] [libc] Add `IN6_IS_ADDR_LOOPBACK`
---
libc/include/llvm-libc-macros/netinet-in-macros.h | 9 +
libc/test/include/netinet_in_test.cpp | 5 +
2 files changed, 14 insertions(+)
diff --git a/libc/include/llvm-libc-macros/netinet-in-macros.h
b/libc/include/llvm-libc-macros/netinet-in-macros.h
index f97a2dd0c3fda..3148aed6bb112 100644
--- a/libc/include/llvm-libc-macros/netinet-in-macros.h
+++ b/libc/include/llvm-libc-macros/netinet-in-macros.h
@@ -44,6 +44,15 @@
(__LLVM_LIBC_CAST(reinterpret_cast, uint32_t *, a)[2]) == 0 &&
\
(__LLVM_LIBC_CAST(reinterpret_cast, uint32_t *, a)[3]) == 0)
+#define IN6_IS_ADDR_LOOPBACK(a)
\
+ ((__LLVM_LIBC_CAST(reinterpret_cast, uint32_t *, a)[0]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint32_t *, a)[1]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint32_t *, a)[2]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[12]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[13]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[14]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[15]) == 1)
+
#define IN6_IS_ADDR_LINKLOCAL(a)
\
((__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[0]) == 0xfe &&
\
(__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xc0) == 0x80)
diff --git a/libc/test/include/netinet_in_test.cpp
b/libc/test/include/netinet_in_test.cpp
index d70c780800858..15e57ccef7ac5 100644
--- a/libc/test/include/netinet_in_test.cpp
+++ b/libc/test/include/netinet_in_test.cpp
@@ -19,6 +19,11 @@ TEST(LlvmLibcNetinetInTest, IN6Macro) {
buff[i] = 0;
}
+ EXPECT_FALSE(IN6_IS_ADDR_LOOPBACK(buff));
+ buff[15] = 1;
+ EXPECT_TRUE(IN6_IS_ADDR_LOOPBACK(buff));
+ buff[15] = 0;
+
buff[0] = 0xfe;
buff[1] = 0x80;
EXPECT_TRUE(IN6_IS_ADDR_LINKLOCAL(buff));
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_LOOPBACK` (PR #172312)
c8ef wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.com/github/pr/llvm/llvm-project/172312?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#172312** https://app.graphite.com/github/pr/llvm/llvm-project/172312?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.com/github/pr/llvm/llvm-project/172312?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#172311** https://app.graphite.com/github/pr/llvm/llvm-project/172311?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/172312 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_MULTICAST` (PR #172498)
c8ef wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.com/github/pr/llvm/llvm-project/172498?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#172498** https://app.graphite.com/github/pr/llvm/llvm-project/172498?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.com/github/pr/llvm/llvm-project/172498?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#172312** https://app.graphite.com/github/pr/llvm/llvm-project/172312?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#172311** https://app.graphite.com/github/pr/llvm/llvm-project/172311?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/172498 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_MULTICAST` (PR #172498)
https://github.com/c8ef created https://github.com/llvm/llvm-project/pull/172498
None
>From 8e34a2da81601b39d5ae78d51e0e45be7067d00c Mon Sep 17 00:00:00 2001
From: c8ef
Date: Tue, 16 Dec 2025 23:11:31 +0800
Subject: [PATCH] [libc] Add `IN6_IS_ADDR_MULTICAST`
---
libc/include/llvm-libc-macros/netinet-in-macros.h | 3 +++
libc/test/include/netinet_in_test.cpp | 5 +
2 files changed, 8 insertions(+)
diff --git a/libc/include/llvm-libc-macros/netinet-in-macros.h
b/libc/include/llvm-libc-macros/netinet-in-macros.h
index 3148aed6bb112..863ff8759e446 100644
--- a/libc/include/llvm-libc-macros/netinet-in-macros.h
+++ b/libc/include/llvm-libc-macros/netinet-in-macros.h
@@ -53,6 +53,9 @@
(__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[14]) == 0 &&
\
(__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[15]) == 1)
+#define IN6_IS_ADDR_MULTICAST(a)
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[0]) == 0xff
+
#define IN6_IS_ADDR_LINKLOCAL(a)
\
((__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[0]) == 0xfe &&
\
(__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xc0) == 0x80)
diff --git a/libc/test/include/netinet_in_test.cpp
b/libc/test/include/netinet_in_test.cpp
index 15e57ccef7ac5..e8cb8e48ff4b4 100644
--- a/libc/test/include/netinet_in_test.cpp
+++ b/libc/test/include/netinet_in_test.cpp
@@ -24,6 +24,11 @@ TEST(LlvmLibcNetinetInTest, IN6Macro) {
EXPECT_TRUE(IN6_IS_ADDR_LOOPBACK(buff));
buff[15] = 0;
+ EXPECT_FALSE(IN6_IS_ADDR_MULTICAST(buff));
+ buff[0] = 0xff;
+ EXPECT_TRUE(IN6_IS_ADDR_MULTICAST(buff));
+ buff[0] = 0;
+
buff[0] = 0xfe;
buff[1] = 0x80;
EXPECT_TRUE(IN6_IS_ADDR_LINKLOCAL(buff));
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_MULTICAST` (PR #172498)
https://github.com/c8ef ready_for_review https://github.com/llvm/llvm-project/pull/172498 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_MC*` (PR #172643)
https://github.com/c8ef created https://github.com/llvm/llvm-project/pull/172643
None
>From 27557d0d8ab2d9e3bb6c6e2a97160f6e60eb513a Mon Sep 17 00:00:00 2001
From: c8ef
Date: Wed, 17 Dec 2025 20:32:55 +0800
Subject: [PATCH] [libc] Add `IN6_IS_ADDR_MC*`
---
.../llvm-libc-macros/netinet-in-macros.h | 20 +++
libc/test/include/netinet_in_test.cpp | 14 +
2 files changed, 34 insertions(+)
diff --git a/libc/include/llvm-libc-macros/netinet-in-macros.h
b/libc/include/llvm-libc-macros/netinet-in-macros.h
index 863ff8759e446..88ffe92756b16 100644
--- a/libc/include/llvm-libc-macros/netinet-in-macros.h
+++ b/libc/include/llvm-libc-macros/netinet-in-macros.h
@@ -64,4 +64,24 @@
((__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[0]) == 0xfe &&
\
(__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xc0) == 0xc0)
+#define IN6_IS_ADDR_MC_NODELOCAL(a)
\
+ (IN6_IS_ADDR_MULTICAST(a) &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xf) == 0x1)
+
+#define IN6_IS_ADDR_MC_LINKLOCAL(a)
\
+ (IN6_IS_ADDR_MULTICAST(a) &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xf) == 0x2)
+
+#define IN6_IS_ADDR_MC_SITELOCAL(a)
\
+ (IN6_IS_ADDR_MULTICAST(a) &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xf) == 0x5)
+
+#define IN6_IS_ADDR_MC_ORGLOCAL(a)
\
+ (IN6_IS_ADDR_MULTICAST(a) &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xf) == 0x8)
+
+#define IN6_IS_ADDR_MC_GLOBAL(a)
\
+ (IN6_IS_ADDR_MULTICAST(a) &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xf) == 0xe)
+
#endif // LLVM_LIBC_MACROS_NETINET_IN_MACROS_H
diff --git a/libc/test/include/netinet_in_test.cpp
b/libc/test/include/netinet_in_test.cpp
index e8cb8e48ff4b4..72500c4d51438 100644
--- a/libc/test/include/netinet_in_test.cpp
+++ b/libc/test/include/netinet_in_test.cpp
@@ -42,4 +42,18 @@ TEST(LlvmLibcNetinetInTest, IN6Macro) {
buff[0] = 0xff;
buff[1] = 0x80;
EXPECT_FALSE(IN6_IS_ADDR_SITELOCAL(buff));
+
+ buff[0] = 0xff;
+ buff[1] = 0x1;
+ EXPECT_TRUE(IN6_IS_ADDR_MC_NODELOCAL(buff));
+ buff[1] = 0x2;
+ EXPECT_TRUE(IN6_IS_ADDR_MC_LINKLOCAL(buff));
+ buff[1] = 0x5;
+ EXPECT_TRUE(IN6_IS_ADDR_MC_SITELOCAL(buff));
+ buff[1] = 0x8;
+ EXPECT_TRUE(IN6_IS_ADDR_MC_ORGLOCAL(buff));
+ buff[1] = 0xe;
+ EXPECT_TRUE(IN6_IS_ADDR_MC_GLOBAL(buff));
+ buff[1] = 0;
+ buff[0] = 0;
}
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_MC*` (PR #172643)
c8ef wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.com/github/pr/llvm/llvm-project/172643?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#172643** https://app.graphite.com/github/pr/llvm/llvm-project/172643?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.com/github/pr/llvm/llvm-project/172643?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#172498** https://app.graphite.com/github/pr/llvm/llvm-project/172498?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#172312** https://app.graphite.com/github/pr/llvm/llvm-project/172312?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#172311** https://app.graphite.com/github/pr/llvm/llvm-project/172311?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/172643 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_MC*` (PR #172643)
https://github.com/c8ef ready_for_review https://github.com/llvm/llvm-project/pull/172643 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_V4MAPPED` (PR #172645)
https://github.com/c8ef created https://github.com/llvm/llvm-project/pull/172645
None
>From 0a03867534b22394304030c6f933781b8bb60ea8 Mon Sep 17 00:00:00 2001
From: c8ef
Date: Wed, 17 Dec 2025 20:47:11 +0800
Subject: [PATCH] [libc] Add `IN6_IS_ADDR_V4MAPPED`
---
libc/include/llvm-libc-macros/netinet-in-macros.h | 8
libc/test/include/netinet_in_test.cpp | 7 +++
2 files changed, 15 insertions(+)
diff --git a/libc/include/llvm-libc-macros/netinet-in-macros.h
b/libc/include/llvm-libc-macros/netinet-in-macros.h
index 88ffe92756b16..1d7bef833f2b8 100644
--- a/libc/include/llvm-libc-macros/netinet-in-macros.h
+++ b/libc/include/llvm-libc-macros/netinet-in-macros.h
@@ -64,6 +64,14 @@
((__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[0]) == 0xfe &&
\
(__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xc0) == 0xc0)
+#define IN6_IS_ADDR_V4MAPPED(a)
\
+ ((__LLVM_LIBC_CAST(reinterpret_cast, uint32_t *, a)[0]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint32_t *, a)[1]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[8]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[9]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[10]) == 0xff &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[11]) == 0xff)
+
#define IN6_IS_ADDR_MC_NODELOCAL(a)
\
(IN6_IS_ADDR_MULTICAST(a) &&
\
(__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xf) == 0x1)
diff --git a/libc/test/include/netinet_in_test.cpp
b/libc/test/include/netinet_in_test.cpp
index 72500c4d51438..2f57080ef8b77 100644
--- a/libc/test/include/netinet_in_test.cpp
+++ b/libc/test/include/netinet_in_test.cpp
@@ -56,4 +56,11 @@ TEST(LlvmLibcNetinetInTest, IN6Macro) {
EXPECT_TRUE(IN6_IS_ADDR_MC_GLOBAL(buff));
buff[1] = 0;
buff[0] = 0;
+
+ EXPECT_FALSE(IN6_IS_ADDR_V4MAPPED(buff));
+ buff[10] = 0xff;
+ buff[11] = 0xff;
+ EXPECT_TRUE(IN6_IS_ADDR_V4MAPPED(buff));
+ buff[10] = 0;
+ buff[11] = 0;
}
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_V4MAPPED` (PR #172645)
https://github.com/c8ef ready_for_review https://github.com/llvm/llvm-project/pull/172645 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_V4MAPPED` (PR #172645)
c8ef wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.com/github/pr/llvm/llvm-project/172645?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#172645** https://app.graphite.com/github/pr/llvm/llvm-project/172645?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.com/github/pr/llvm/llvm-project/172645?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#172643** https://app.graphite.com/github/pr/llvm/llvm-project/172643?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#172498** https://app.graphite.com/github/pr/llvm/llvm-project/172498?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#172312** https://app.graphite.com/github/pr/llvm/llvm-project/172312?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#172311** https://app.graphite.com/github/pr/llvm/llvm-project/172311?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/172645 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_V4COMPAT` (PR #172646)
https://github.com/c8ef created https://github.com/llvm/llvm-project/pull/172646
None
>From 886d2a0d7bbc21173a6731de0d6bea04d612b050 Mon Sep 17 00:00:00 2001
From: c8ef
Date: Wed, 17 Dec 2025 20:57:20 +0800
Subject: [PATCH] [libc] Add `IN6_IS_ADDR_V4COMPAT`
---
libc/include/llvm-libc-macros/netinet-in-macros.h | 6 ++
libc/test/include/netinet_in_test.cpp | 11 +++
2 files changed, 17 insertions(+)
diff --git a/libc/include/llvm-libc-macros/netinet-in-macros.h
b/libc/include/llvm-libc-macros/netinet-in-macros.h
index 1d7bef833f2b8..f22f0bab33772 100644
--- a/libc/include/llvm-libc-macros/netinet-in-macros.h
+++ b/libc/include/llvm-libc-macros/netinet-in-macros.h
@@ -72,6 +72,12 @@
(__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[10]) == 0xff &&
\
(__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[11]) == 0xff)
+#define IN6_IS_ADDR_V4COMPAT(a)
\
+ ((__LLVM_LIBC_CAST(reinterpret_cast, uint32_t *, a)[0]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint32_t *, a)[1]) == 0 &&
\
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint32_t *, a)[2]) == 0 &&
\
+ !IN6_IS_ADDR_UNSPECIFIED(a) && !IN6_IS_ADDR_LOOPBACK(a))
+
#define IN6_IS_ADDR_MC_NODELOCAL(a)
\
(IN6_IS_ADDR_MULTICAST(a) &&
\
(__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xf) == 0x1)
diff --git a/libc/test/include/netinet_in_test.cpp
b/libc/test/include/netinet_in_test.cpp
index 2f57080ef8b77..2fb46a9227c07 100644
--- a/libc/test/include/netinet_in_test.cpp
+++ b/libc/test/include/netinet_in_test.cpp
@@ -63,4 +63,15 @@ TEST(LlvmLibcNetinetInTest, IN6Macro) {
EXPECT_TRUE(IN6_IS_ADDR_V4MAPPED(buff));
buff[10] = 0;
buff[11] = 0;
+
+ for (int i = 12; i < 16; ++i) {
+buff[i] ^= 42;
+EXPECT_TRUE(IN6_IS_ADDR_V4COMPAT(buff));
+buff[i] ^= 42;
+ }
+ for (int i = 0; i < 12; ++i) {
+buff[i] ^= 42;
+EXPECT_FALSE(IN6_IS_ADDR_V4COMPAT(buff));
+buff[i] ^= 42;
+ }
}
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_V4COMPAT` (PR #172646)
c8ef wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.com/github/pr/llvm/llvm-project/172646?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#172646** https://app.graphite.com/github/pr/llvm/llvm-project/172646?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.com/github/pr/llvm/llvm-project/172646?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#172645** https://app.graphite.com/github/pr/llvm/llvm-project/172645?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#172643** https://app.graphite.com/github/pr/llvm/llvm-project/172643?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#172498** https://app.graphite.com/github/pr/llvm/llvm-project/172498?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#172312** https://app.graphite.com/github/pr/llvm/llvm-project/172312?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#172311** https://app.graphite.com/github/pr/llvm/llvm-project/172311?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/172646 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Add `IN6_IS_ADDR_V4COMPAT` (PR #172646)
https://github.com/c8ef ready_for_review https://github.com/llvm/llvm-project/pull/172646 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
