diff options
Diffstat (limited to 'libartbase/arch/instruction_set.h')
-rw-r--r-- | libartbase/arch/instruction_set.h | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/libartbase/arch/instruction_set.h b/libartbase/arch/instruction_set.h index 69983d2fe8..e68ff08c17 100644 --- a/libartbase/arch/instruction_set.h +++ b/libartbase/arch/instruction_set.h @@ -99,6 +99,21 @@ constexpr PointerSize GetInstructionSetPointerSize(InstructionSet isa) { InstructionSetAbort(isa); } +constexpr bool IsValidInstructionSet(InstructionSet isa) { + switch (isa) { + case InstructionSet::kArm: + case InstructionSet::kThumb2: + case InstructionSet::kArm64: + 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: @@ -118,33 +133,38 @@ constexpr size_t GetInstructionSetInstructionAlignment(InstructionSet isa) { InstructionSetAbort(isa); } -constexpr bool IsValidInstructionSet(InstructionSet isa) { +constexpr size_t GetInstructionSetCodeAlignment(InstructionSet isa) { switch (isa) { case InstructionSet::kArm: + // Fall-through. case InstructionSet::kThumb2: + return kArmCodeAlignment; case InstructionSet::kArm64: + return kArm64CodeAlignment; case InstructionSet::kX86: + // Fall-through. case InstructionSet::kX86_64: - return true; + return kX86CodeAlignment; case InstructionSet::kNone: - return false; + break; } - return false; + InstructionSetAbort(isa); } -constexpr size_t GetInstructionSetCodeAlignment(InstructionSet isa) { +// Returns the difference between the code address and a usable PC. +// Mainly to cope with `kThumb2` where the lower bit must be set. +constexpr size_t GetInstructionSetEntryPointAdjustment(InstructionSet isa) { switch (isa) { case InstructionSet::kArm: - // Fall-through. - case InstructionSet::kThumb2: - return kArmCodeAlignment; case InstructionSet::kArm64: - return kArm64CodeAlignment; case InstructionSet::kX86: - // Fall-through. case InstructionSet::kX86_64: - return kX86CodeAlignment; + return 0; + case InstructionSet::kThumb2: { + // +1 to set the low-order bit so a BLX will switch to Thumb mode + return 1; + } case InstructionSet::kNone: break; |