Commit a338dad4 authored by jacob.bramley's avatar jacob.bramley Committed by Commit bot

[arm] Fix an accessor return type.

Existing uses are correct but the return type was misleading.

Also clarify some related comments to make the difference between Bits
and BitField more obvious.

BUG=

Review-Url: https://codereview.chromium.org/2275973002
Cr-Commit-Position: refs/heads/master@{#38894}
parent a55fdb1e
...@@ -477,40 +477,42 @@ class Instruction { ...@@ -477,40 +477,42 @@ class Instruction {
*reinterpret_cast<Instr*>(this) = value; *reinterpret_cast<Instr*>(this) = value;
} }
// Read one particular bit out of the instruction bits. // Extract a single bit from the instruction bits and return it as bit 0 in
// the result.
inline int Bit(int nr) const { inline int Bit(int nr) const {
return (InstructionBits() >> nr) & 1; return (InstructionBits() >> nr) & 1;
} }
// Read a bit field's value out of the instruction bits. // Extract a bit field <hi:lo> from the instruction bits and return it in the
// least-significant bits of the result.
inline int Bits(int hi, int lo) const { inline int Bits(int hi, int lo) const {
return (InstructionBits() >> lo) & ((2 << (hi - lo)) - 1); return (InstructionBits() >> lo) & ((2 << (hi - lo)) - 1);
} }
// Read a bit field out of the instruction bits. // Read a bit field <hi:lo>, leaving its position unchanged in the result.
inline int BitField(int hi, int lo) const { inline int BitField(int hi, int lo) const {
return InstructionBits() & (((2 << (hi - lo)) - 1) << lo); return InstructionBits() & (((2 << (hi - lo)) - 1) << lo);
} }
// Static support. // Static support.
// Read one particular bit out of the instruction bits. // Extract a single bit from the instruction bits and return it as bit 0 in
// the result.
static inline int Bit(Instr instr, int nr) { static inline int Bit(Instr instr, int nr) {
return (instr >> nr) & 1; return (instr >> nr) & 1;
} }
// Read the value of a bit field out of the instruction bits. // Extract a bit field <hi:lo> from the instruction bits and return it in the
// least-significant bits of the result.
static inline int Bits(Instr instr, int hi, int lo) { static inline int Bits(Instr instr, int hi, int lo) {
return (instr >> lo) & ((2 << (hi - lo)) - 1); return (instr >> lo) & ((2 << (hi - lo)) - 1);
} }
// Read a bit field <hi:lo>, leaving its position unchanged in the result.
// Read a bit field out of the instruction bits.
static inline int BitField(Instr instr, int hi, int lo) { static inline int BitField(Instr instr, int hi, int lo) {
return instr & (((2 << (hi - lo)) - 1) << lo); return instr & (((2 << (hi - lo)) - 1) << lo);
} }
// Accessors for the different named fields used in the ARM encoding. // Accessors for the different named fields used in the ARM encoding.
// The naming of these accessor corresponds to figure A3-1. // The naming of these accessor corresponds to figure A3-1.
// //
...@@ -525,13 +527,11 @@ class Instruction { ...@@ -525,13 +527,11 @@ class Instruction {
// Generally applicable fields // Generally applicable fields
inline Condition ConditionValue() const { inline int ConditionValue() const { return Bits(31, 28); }
return static_cast<Condition>(Bits(31, 28));
}
inline Condition ConditionField() const { inline Condition ConditionField() const {
return static_cast<Condition>(BitField(31, 28)); return static_cast<Condition>(BitField(31, 28));
} }
DECLARE_STATIC_TYPED_ACCESSOR(Condition, ConditionValue); DECLARE_STATIC_TYPED_ACCESSOR(int, ConditionValue);
DECLARE_STATIC_TYPED_ACCESSOR(Condition, ConditionField); DECLARE_STATIC_TYPED_ACCESSOR(Condition, ConditionField);
inline int TypeValue() const { return Bits(27, 25); } inline int TypeValue() const { return Bits(27, 25); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment