summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Santiago Aboy Solanes <solanes@google.com> 2024-08-16 16:16:56 +0100
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-08-21 10:00:10 +0000
commit77c14d181dcec8cec240cf2a99a401397582c6d8 (patch)
treedb65f2dd18cf0bb15661ab5ab6134e6e49864fe7
parent7effb7fac7a1ea037277b0fef1ac1121c3f56f93 (diff)
Clean up instruction_set's switch cases regarding isas
* Remove dead code * Join together cases which return the same values * TIghten up methods e.g. removing unneeded `{}` Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I8a4f7264f9fb113335738539298cc42dbc6f65cb
-rw-r--r--libartbase/arch/instruction_set.cc4
-rw-r--r--libartbase/arch/instruction_set.h49
2 files changed, 9 insertions, 44 deletions
diff --git a/libartbase/arch/instruction_set.cc b/libartbase/arch/instruction_set.cc
index e28b6ca291..12a2c36784 100644
--- a/libartbase/arch/instruction_set.cc
+++ b/libartbase/arch/instruction_set.cc
@@ -36,8 +36,6 @@ void InstructionSetAbort(InstructionSet isa) {
LOG(FATAL) << "Unsupported instruction set " << isa;
UNREACHABLE();
}
- LOG(FATAL) << "Unknown ISA " << isa;
- UNREACHABLE();
}
const char* GetInstructionSetString(InstructionSet isa) {
@@ -56,8 +54,6 @@ const char* GetInstructionSetString(InstructionSet isa) {
case InstructionSet::kNone:
return "none";
}
- LOG(FATAL) << "Unknown ISA " << isa;
- UNREACHABLE();
}
InstructionSet GetInstructionSetFromString(const char* isa_str) {
diff --git a/libartbase/arch/instruction_set.h b/libartbase/arch/instruction_set.h
index c0d27c324f..69b01dbfee 100644
--- a/libartbase/arch/instruction_set.h
+++ b/libartbase/arch/instruction_set.h
@@ -92,7 +92,6 @@ NO_RETURN void InstructionSetAbort(InstructionSet isa);
constexpr PointerSize GetInstructionSetPointerSize(InstructionSet isa) {
switch (isa) {
case InstructionSet::kArm:
- // Fall-through.
case InstructionSet::kThumb2:
return kArmPointerSize;
case InstructionSet::kArm64:
@@ -103,11 +102,9 @@ constexpr PointerSize GetInstructionSetPointerSize(InstructionSet isa) {
return kX86PointerSize;
case InstructionSet::kX86_64:
return kX86_64PointerSize;
-
case InstructionSet::kNone:
- break;
+ InstructionSetAbort(isa);
}
- InstructionSetAbort(isa);
}
constexpr bool IsValidInstructionSet(InstructionSet isa) {
@@ -119,17 +116,14 @@ constexpr bool IsValidInstructionSet(InstructionSet isa) {
case InstructionSet::kX86:
case InstructionSet::kX86_64:
return true;
-
case InstructionSet::kNone:
return false;
}
- return false;
}
constexpr size_t GetInstructionSetInstructionAlignment(InstructionSet isa) {
switch (isa) {
case InstructionSet::kArm:
- // Fall-through.
case InstructionSet::kThumb2:
return kThumb2InstructionAlignment;
case InstructionSet::kArm64:
@@ -140,17 +134,14 @@ constexpr size_t GetInstructionSetInstructionAlignment(InstructionSet isa) {
return kX86InstructionAlignment;
case InstructionSet::kX86_64:
return kX86_64InstructionAlignment;
-
case InstructionSet::kNone:
- break;
+ InstructionSetAbort(isa);
}
- InstructionSetAbort(isa);
}
constexpr size_t GetInstructionSetCodeAlignment(InstructionSet isa) {
switch (isa) {
case InstructionSet::kArm:
- // Fall-through.
case InstructionSet::kThumb2:
return kArmCodeAlignment;
case InstructionSet::kArm64:
@@ -158,14 +149,11 @@ constexpr size_t GetInstructionSetCodeAlignment(InstructionSet isa) {
case InstructionSet::kRiscv64:
return kRiscv64CodeAlignment;
case InstructionSet::kX86:
- // Fall-through.
case InstructionSet::kX86_64:
return kX86CodeAlignment;
-
case InstructionSet::kNone:
- break;
+ InstructionSetAbort(isa);
}
- InstructionSetAbort(isa);
}
// Returns the difference between the code address and a usable PC.
@@ -178,15 +166,12 @@ constexpr size_t GetInstructionSetEntryPointAdjustment(InstructionSet isa) {
case InstructionSet::kX86:
case InstructionSet::kX86_64:
return 0;
- case InstructionSet::kThumb2: {
+ case InstructionSet::kThumb2:
// +1 to set the low-order bit so a BLX will switch to Thumb mode
return 1;
- }
-
case InstructionSet::kNone:
- break;
+ InstructionSetAbort(isa);
}
- InstructionSetAbort(isa);
}
constexpr bool Is64BitInstructionSet(InstructionSet isa) {
@@ -195,16 +180,13 @@ constexpr bool Is64BitInstructionSet(InstructionSet isa) {
case InstructionSet::kThumb2:
case InstructionSet::kX86:
return false;
-
case InstructionSet::kArm64:
case InstructionSet::kRiscv64:
case InstructionSet::kX86_64:
return true;
-
case InstructionSet::kNone:
- break;
+ InstructionSetAbort(isa);
}
- InstructionSetAbort(isa);
}
constexpr PointerSize InstructionSetPointerSize(InstructionSet isa) {
@@ -214,43 +196,31 @@ constexpr PointerSize InstructionSetPointerSize(InstructionSet isa) {
constexpr size_t GetBytesPerGprSpillLocation(InstructionSet isa) {
switch (isa) {
case InstructionSet::kArm:
- // Fall-through.
case InstructionSet::kThumb2:
+ case InstructionSet::kX86:
return 4;
case InstructionSet::kArm64:
- return 8;
case InstructionSet::kRiscv64:
- return 8;
- case InstructionSet::kX86:
- return 4;
case InstructionSet::kX86_64:
return 8;
-
case InstructionSet::kNone:
- break;
+ InstructionSetAbort(isa);
}
- InstructionSetAbort(isa);
}
constexpr size_t GetBytesPerFprSpillLocation(InstructionSet isa) {
switch (isa) {
case InstructionSet::kArm:
- // Fall-through.
case InstructionSet::kThumb2:
return 4;
case InstructionSet::kArm64:
- return 8;
case InstructionSet::kRiscv64:
- return 8;
case InstructionSet::kX86:
- return 8;
case InstructionSet::kX86_64:
return 8;
-
case InstructionSet::kNone:
- break;
+ InstructionSetAbort(isa);
}
- InstructionSetAbort(isa);
}
// Returns the instruction sets supported by the device, or an empty list on failure.
@@ -297,7 +267,6 @@ constexpr size_t GetStackOverflowReservedBytes(InstructionSet isa) {
instruction_set_details::GetStackOverflowReservedBytesFailure(
"kNone has no stack overflow size");
}
- instruction_set_details::GetStackOverflowReservedBytesFailure("Unknown instruction set");
}
// The following definitions create return types for two word-sized entities that will be passed