mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-10-28 18:07:12 +08:00
[libyuv] Simplify RVV configuration in BUILD.bazel and libyuv.bzl
Restructure RISC-V Vector (RVV) configuration to follow the pattern used by NEON and SVE: - Move RVV_COPTS immediately after SVE_COPTS. - Define ENABLE_RVV_COPTS (-march=rv32gcv) and ENABLE_RVV64_COPTS (-march=rv64gcv) with SUPPORTS_RVV_COPTS (-DLIBYUV_RVV). - Revert ALL_COPTS to PLATFORM_COPTS so RVV vector flags are not applied to generic sources. - Add ALL_RVV_COPTS, RVV_DEPS, and libyuv_rvv_impl target. - Update libyuv.bzl to add libyuv_rvv_srcs and exclude source/*rvv*.cc from libyuv_srcs. R=wtc@google.com Test: cmake -B out/Release -DUNIT_TEST=ON && cmake --build out/Release Bug: none Change-Id: Ia60a8bc1da9db46f0c5295064d7b9d3d5609a38f TAG=agy CONV=06856819-10a7-4815-93d3-cdcd32da7495 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8357976 Reviewed-by: richard winterton <rrwinterton@gmail.com>
This commit is contained in:
parent
24b6126b0e
commit
137e29972e
55
BUILD.bazel
55
BUILD.bazel
@ -5,7 +5,7 @@
|
|||||||
# and scaling.
|
# and scaling.
|
||||||
|
|
||||||
load("@bazel_skylib//lib:selects.bzl", "selects")
|
load("@bazel_skylib//lib:selects.bzl", "selects")
|
||||||
load(":libyuv.bzl", "libyuv_hdrs", "libyuv_neon_srcs", "libyuv_srcs", "libyuv_sve_srcs", "libyuv_test_srcs")
|
load(":libyuv.bzl", "libyuv_hdrs", "libyuv_neon_srcs", "libyuv_rvv_srcs", "libyuv_srcs", "libyuv_sve_srcs", "libyuv_test_srcs")
|
||||||
|
|
||||||
# Detect if we are in Google's internal repository (where source files are
|
# Detect if we are in Google's internal repository (where source files are
|
||||||
# under files/) or open source (where source files are at the root).
|
# under files/) or open source (where source files are at the root).
|
||||||
@ -44,6 +44,24 @@ SVE_COPTS = select({
|
|||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
SUPPORTS_RVV_COPTS = [
|
||||||
|
"-DLIBYUV_RVV",
|
||||||
|
]
|
||||||
|
|
||||||
|
ENABLE_RVV_COPTS = [
|
||||||
|
"-march=rv32gcv",
|
||||||
|
]
|
||||||
|
|
||||||
|
ENABLE_RVV64_COPTS = [
|
||||||
|
"-march=rv64gcv",
|
||||||
|
]
|
||||||
|
|
||||||
|
RVV_COPTS = select({
|
||||||
|
"@platforms//cpu:riscv32": ENABLE_RVV_COPTS + SUPPORTS_RVV_COPTS,
|
||||||
|
"@platforms//cpu:riscv64": ENABLE_RVV64_COPTS + SUPPORTS_RVV_COPTS,
|
||||||
|
"//conditions:default": [],
|
||||||
|
})
|
||||||
|
|
||||||
PLATFORM_COPTS = select({
|
PLATFORM_COPTS = select({
|
||||||
"@platforms//os:android": ["-DHAVE_JPEG"],
|
"@platforms//os:android": ["-DHAVE_JPEG"],
|
||||||
"@platforms//os:linux": ["-DHAVE_JPEG"],
|
"@platforms//os:linux": ["-DHAVE_JPEG"],
|
||||||
@ -56,26 +74,14 @@ PLATFORM_COPTS = select({
|
|||||||
"-DGOOGLE_COMMANDLINEFLAGS_FULL_API",
|
"-DGOOGLE_COMMANDLINEFLAGS_FULL_API",
|
||||||
]
|
]
|
||||||
|
|
||||||
RVV_COPTS = select({
|
ALL_COPTS = PLATFORM_COPTS
|
||||||
"@platforms//cpu:riscv64": [
|
|
||||||
"-march=rv64gcv",
|
|
||||||
"-fno-vectorize",
|
|
||||||
"-fno-slp-vectorize",
|
|
||||||
],
|
|
||||||
"@platforms//cpu:riscv32": [
|
|
||||||
"-march=rv32gcv",
|
|
||||||
"-fno-vectorize",
|
|
||||||
"-fno-slp-vectorize",
|
|
||||||
],
|
|
||||||
"//conditions:default": [],
|
|
||||||
})
|
|
||||||
|
|
||||||
ALL_COPTS = PLATFORM_COPTS + RVV_COPTS
|
|
||||||
|
|
||||||
ALL_NEON_COPTS = NEON_COPTS + PLATFORM_COPTS
|
ALL_NEON_COPTS = NEON_COPTS + PLATFORM_COPTS
|
||||||
|
|
||||||
ALL_SVE_COPTS = SVE_COPTS + PLATFORM_COPTS
|
ALL_SVE_COPTS = SVE_COPTS + PLATFORM_COPTS
|
||||||
|
|
||||||
|
ALL_RVV_COPTS = RVV_COPTS + PLATFORM_COPTS
|
||||||
|
|
||||||
NEON_DEPS = select({
|
NEON_DEPS = select({
|
||||||
"@platforms//cpu:armv7": [":libyuv_neon_impl"],
|
"@platforms//cpu:armv7": [":libyuv_neon_impl"],
|
||||||
"@platforms//cpu:aarch64": [":libyuv_neon_impl"],
|
"@platforms//cpu:aarch64": [":libyuv_neon_impl"],
|
||||||
@ -87,6 +93,12 @@ SVE_DEPS = select({
|
|||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
RVV_DEPS = select({
|
||||||
|
"@platforms//cpu:riscv32": [":libyuv_rvv_impl"],
|
||||||
|
"@platforms//cpu:riscv64": [":libyuv_rvv_impl"],
|
||||||
|
"//conditions:default": [],
|
||||||
|
})
|
||||||
|
|
||||||
PLATFORM_DEPS = select({
|
PLATFORM_DEPS = select({
|
||||||
"@platforms//os:android": ["@libjpeg_turbo//:jpeg"],
|
"@platforms//os:android": ["@libjpeg_turbo//:jpeg"],
|
||||||
"@platforms//os:linux": ["@libjpeg_turbo//:jpeg"],
|
"@platforms//os:linux": ["@libjpeg_turbo//:jpeg"],
|
||||||
@ -95,7 +107,7 @@ PLATFORM_DEPS = select({
|
|||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
})
|
})
|
||||||
|
|
||||||
ALL_DEPS = NEON_DEPS + SVE_DEPS + PLATFORM_DEPS
|
ALL_DEPS = NEON_DEPS + SVE_DEPS + RVV_DEPS + PLATFORM_DEPS
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "libyuv",
|
name = "libyuv",
|
||||||
@ -174,6 +186,15 @@ cc_library(
|
|||||||
alwayslink = 1,
|
alwayslink = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "libyuv_rvv_impl",
|
||||||
|
srcs = libyuv_rvv_srcs(PREFIX),
|
||||||
|
copts = ALL_RVV_COPTS,
|
||||||
|
includes = [PREFIX + "include"],
|
||||||
|
visibility = ["//visibility:private"],
|
||||||
|
alwayslink = 1,
|
||||||
|
)
|
||||||
|
|
||||||
cc_test(
|
cc_test(
|
||||||
name = "libyuv_test",
|
name = "libyuv_test",
|
||||||
srcs = libyuv_test_srcs(PREFIX),
|
srcs = libyuv_test_srcs(PREFIX),
|
||||||
|
|||||||
@ -10,6 +10,7 @@ def libyuv_srcs(prefix = ""):
|
|||||||
],
|
],
|
||||||
exclude = [
|
exclude = [
|
||||||
prefix + "source/*neon*.cc",
|
prefix + "source/*neon*.cc",
|
||||||
|
prefix + "source/*rvv*.cc",
|
||||||
prefix + "source/*sve*.cc",
|
prefix + "source/*sve*.cc",
|
||||||
prefix + "source/*sme*.cc",
|
prefix + "source/*sme*.cc",
|
||||||
],
|
],
|
||||||
@ -30,6 +31,12 @@ def libyuv_neon_srcs(prefix = ""):
|
|||||||
prefix + "include/libyuv/*.h",
|
prefix + "include/libyuv/*.h",
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def libyuv_rvv_srcs(prefix = ""):
|
||||||
|
return native.glob([
|
||||||
|
prefix + "source/*rvv*.cc",
|
||||||
|
prefix + "include/libyuv/*.h",
|
||||||
|
])
|
||||||
|
|
||||||
def libyuv_sve_srcs(prefix = ""):
|
def libyuv_sve_srcs(prefix = ""):
|
||||||
return native.glob([
|
return native.glob([
|
||||||
prefix + "source/*sve*.cc",
|
prefix + "source/*sve*.cc",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user