From d7f0844f5a181a8ce8fea00c09872b4620281bc1 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 4 Oct 2022 00:36:29 +0000 Subject: [PATCH] Add risc-v support to versioner. Also fill out some of the data we've fallen behind on, like "which API levels actually exist". Signed-off-by: Mao Han Signed-off-by: Xia Lifang Signed-off-by: Chen Guoyin Signed-off-by: Wang Chen Signed-off-by: Lu Xufan Test: treehugger Change-Id: I1939426c4a22fea14232a7a93c768691ebb242ec --- tools/versioner/src/Arch.cpp | 4 ++++ tools/versioner/src/Arch.h | 9 ++++++++- tools/versioner/src/DeclarationDatabase.cpp | 1 + tools/versioner/src/Preprocessor.cpp | 3 ++- tools/versioner/src/versioner.h | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/versioner/src/Arch.cpp b/tools/versioner/src/Arch.cpp index 3a27a6e34..d4d0208d5 100644 --- a/tools/versioner/src/Arch.cpp +++ b/tools/versioner/src/Arch.cpp @@ -28,6 +28,9 @@ std::string to_string(const Arch& arch) { case Arch::arm64: return "arm64"; + case Arch::riscv64: + return "riscv64"; + case Arch::x86: return "x86"; @@ -41,6 +44,7 @@ std::string to_string(const Arch& arch) { static const std::unordered_map arch_name_map{ {"arm", Arch::arm}, {"arm64", Arch::arm64}, + {"riscv64", Arch::riscv64}, {"x86", Arch::x86}, {"x86_64", Arch::x86_64}, }; diff --git a/tools/versioner/src/Arch.h b/tools/versioner/src/Arch.h index 74d0f8f42..fd98abc00 100644 --- a/tools/versioner/src/Arch.h +++ b/tools/versioner/src/Arch.h @@ -28,6 +28,7 @@ enum class Arch : size_t { arm = 0, arm64, + riscv64, x86, x86_64, }; @@ -121,6 +122,7 @@ class ArchMapIterator { static const std::set supported_archs = { Arch::arm, Arch::arm64, + Arch::riscv64, Arch::x86, Arch::x86_64, }; @@ -128,17 +130,19 @@ static const std::set supported_archs = { static ArchMap arch_targets = { { Arch::arm, "arm-linux-androideabi" }, { Arch::arm64, "aarch64-linux-android" }, + { Arch::riscv64, "riscv64-linux-android" }, { Arch::x86, "i686-linux-android" }, { Arch::x86_64, "x86_64-linux-android" }, }; static const std::set default_levels = { - 14, 15, 16, 17, 18, 19, 21, 23, 24, 25, 26, 27, 28, 29, 30, + 14, 15, 16, 17, 18, 19, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 33, 34, }; static const ArchMap arch_min_api = { { Arch::arm, 9 }, { Arch::arm64, 21 }, + { Arch::riscv64, 10000 }, { Arch::x86, 9 }, { Arch::x86_64, 21 }, }; @@ -160,4 +164,7 @@ static const std::unordered_map api_codename_map{ {"P", 28}, {"Q", 29}, {"R", 30}, + {"S", 31}, + {"T", 33}, + {"U", 34}, }; diff --git a/tools/versioner/src/DeclarationDatabase.cpp b/tools/versioner/src/DeclarationDatabase.cpp index ec2e38dbe..a029c3bdf 100644 --- a/tools/versioner/src/DeclarationDatabase.cpp +++ b/tools/versioner/src/DeclarationDatabase.cpp @@ -170,6 +170,7 @@ class Visitor : public RecursiveASTVisitor { &arch_availability[Arch::x86].introduced } }, { "introduced_in_64", { &arch_availability[Arch::arm64].introduced, + &arch_availability[Arch::riscv64].introduced, &arch_availability[Arch::x86_64].introduced } }, }; diff --git a/tools/versioner/src/Preprocessor.cpp b/tools/versioner/src/Preprocessor.cpp index eb88c4669..14f80d8aa 100644 --- a/tools/versioner/src/Preprocessor.cpp +++ b/tools/versioner/src/Preprocessor.cpp @@ -141,11 +141,12 @@ static std::string generateGuardCondition(const DeclarationAvailability& avail) static const std::vector>> arch_sets = { { "", supported_archs }, { "!defined(__LP64__)", { Arch::arm, Arch::x86 } }, - { "defined(__LP64__)", { Arch::arm64, Arch::x86_64 } }, + { "defined(__LP64__)", { Arch::arm64, Arch::riscv64, Arch::x86_64 } }, }; std::map individual_archs = { { Arch::arm, "defined(__arm__)" }, { Arch::arm64, "defined(__aarch64__)" }, + { Arch::riscv64, "defined(__riscv)" }, { Arch::x86, "defined(__i386__)" }, { Arch::x86_64, "defined(__x86_64__)" }, }; diff --git a/tools/versioner/src/versioner.h b/tools/versioner/src/versioner.h index e9c4989e3..225e14bde 100644 --- a/tools/versioner/src/versioner.h +++ b/tools/versioner/src/versioner.h @@ -39,5 +39,5 @@ static const std::unordered_map> ignored_headers = { { "sys/_system_properties.h", supported_archs }, // time64.h #errors when included on LP64 archs. - { "time64.h", { Arch::arm64, Arch::x86_64 } }, + { "time64.h", { Arch::arm64, Arch::riscv64, Arch::x86_64 } }, };