aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Belliard <vincent.belliard@arm.com>2017-08-16 08:25:47 -0700
committerVincent Belliard <vincent.belliard@arm.com>2017-08-21 08:38:59 -0700
commit8be27ed0d22c239a0608ab5c7fad5c61a9fec17f (patch)
tree9be39028d58e7673ef66d9facbd2a69b810174bc
parentb106626553485e688388d1acd08347a8252704aa (diff)
Use DtPrinter to print some of the data types.
Change-Id: Id198393e31c05bffed4537554aac2be1a2919382
-rw-r--r--src/aarch32/disasm-aarch32.cc70
-rw-r--r--src/aarch32/disasm-aarch32.h17
-rw-r--r--src/aarch32/instructions-aarch32.h1
3 files changed, 56 insertions, 32 deletions
diff --git a/src/aarch32/disasm-aarch32.cc b/src/aarch32/disasm-aarch32.cc
index 6d0fedf5..92ff0395 100644
--- a/src/aarch32/disasm-aarch32.cc
+++ b/src/aarch32/disasm-aarch32.cc
@@ -5007,10 +5007,11 @@ void Disassembler::vldr(Condition cond,
DRegister rd,
Location* location) {
os().SetCurrentInstruction(kVldr, kFpNeon);
- os() << ToCString(kVldr) << ConditionPrinter(it_block_, cond) << dt << " "
- << rd << ", " << PrintLabel(kLoadDoublePrecisionLocation,
- location,
- GetCodeAddress() & ~3);
+ os() << ToCString(kVldr) << ConditionPrinter(it_block_, cond)
+ << DtPrinter(dt, Untyped64) << " " << rd << ", "
+ << PrintLabel(kLoadDoublePrecisionLocation,
+ location,
+ GetCodeAddress() & ~3);
}
void Disassembler::vldr(Condition cond,
@@ -5018,8 +5019,9 @@ void Disassembler::vldr(Condition cond,
DRegister rd,
const MemOperand& operand) {
os().SetCurrentInstruction(kVldr, kFpNeon);
- os() << ToCString(kVldr) << ConditionPrinter(it_block_, cond) << dt << " "
- << rd << ", " << PrintMemOperand(kLoadDoublePrecisionLocation, operand);
+ os() << ToCString(kVldr) << ConditionPrinter(it_block_, cond)
+ << DtPrinter(dt, Untyped64) << " " << rd << ", "
+ << PrintMemOperand(kLoadDoublePrecisionLocation, operand);
}
void Disassembler::vldr(Condition cond,
@@ -5027,10 +5029,11 @@ void Disassembler::vldr(Condition cond,
SRegister rd,
Location* location) {
os().SetCurrentInstruction(kVldr, kFpNeon);
- os() << ToCString(kVldr) << ConditionPrinter(it_block_, cond) << dt << " "
- << rd << ", " << PrintLabel(kLoadSinglePrecisionLocation,
- location,
- GetCodeAddress() & ~3);
+ os() << ToCString(kVldr) << ConditionPrinter(it_block_, cond)
+ << DtPrinter(dt, Untyped32) << " " << rd << ", "
+ << PrintLabel(kLoadSinglePrecisionLocation,
+ location,
+ GetCodeAddress() & ~3);
}
void Disassembler::vldr(Condition cond,
@@ -5038,8 +5041,9 @@ void Disassembler::vldr(Condition cond,
SRegister rd,
const MemOperand& operand) {
os().SetCurrentInstruction(kVldr, kFpNeon);
- os() << ToCString(kVldr) << ConditionPrinter(it_block_, cond) << dt << " "
- << rd << ", " << PrintMemOperand(kLoadSinglePrecisionLocation, operand);
+ os() << ToCString(kVldr) << ConditionPrinter(it_block_, cond)
+ << DtPrinter(dt, Untyped32) << " " << rd << ", "
+ << PrintMemOperand(kLoadSinglePrecisionLocation, operand);
}
void Disassembler::vmax(
@@ -6802,8 +6806,9 @@ void Disassembler::vstr(Condition cond,
DRegister rd,
const MemOperand& operand) {
os().SetCurrentInstruction(kVstr, kFpNeon);
- os() << ToCString(kVstr) << ConditionPrinter(it_block_, cond) << dt << " "
- << rd << ", " << PrintMemOperand(kStoreDoublePrecisionLocation, operand);
+ os() << ToCString(kVstr) << ConditionPrinter(it_block_, cond)
+ << DtPrinter(dt, Untyped64) << " " << rd << ", "
+ << PrintMemOperand(kStoreDoublePrecisionLocation, operand);
}
void Disassembler::vstr(Condition cond,
@@ -6811,8 +6816,9 @@ void Disassembler::vstr(Condition cond,
SRegister rd,
const MemOperand& operand) {
os().SetCurrentInstruction(kVstr, kFpNeon);
- os() << ToCString(kVstr) << ConditionPrinter(it_block_, cond) << dt << " "
- << rd << ", " << PrintMemOperand(kStoreSinglePrecisionLocation, operand);
+ os() << ToCString(kVstr) << ConditionPrinter(it_block_, cond)
+ << DtPrinter(dt, Untyped32) << " " << rd << ", "
+ << PrintMemOperand(kStoreSinglePrecisionLocation, operand);
}
void Disassembler::vsub(
@@ -22904,7 +22910,7 @@ void Disassembler::DecodeT32(uint32_t instr) {
int32_t offset = (instr & 0xff) << 2;
// VSTR{<c>}{<q>}{.32} <Sd>, [<Rn>{, #{+/-}<imm>}] ; T2 NOLINT(whitespace/line_length)
vstr(CurrentCond(),
- kDataTypeValueNone,
+ Untyped32,
SRegister(rd),
MemOperand(Register(rn),
sign,
@@ -22921,7 +22927,7 @@ void Disassembler::DecodeT32(uint32_t instr) {
int32_t offset = (instr & 0xff) << 2;
// VSTR{<c>}{<q>}{.64} <Dd>, [<Rn>{, #{+/-}<imm>}] ; T1 NOLINT(whitespace/line_length)
vstr(CurrentCond(),
- kDataTypeValueNone,
+ Untyped64,
DRegister(rd),
MemOperand(Register(rn),
sign,
@@ -23086,12 +23092,12 @@ void Disassembler::DecodeT32(uint32_t instr) {
// VLDR{<c>}{<q>}{.32} <Sd>, <label> ; T2
if (minus_zero) {
vldr(CurrentCond(),
- kDataTypeValueNone,
+ Untyped32,
SRegister(rd),
MemOperand(pc, minus, 0));
} else {
vldr(CurrentCond(),
- kDataTypeValueNone,
+ Untyped32,
SRegister(rd),
&location);
}
@@ -23109,12 +23115,12 @@ void Disassembler::DecodeT32(uint32_t instr) {
// VLDR{<c>}{<q>}{.64} <Dd>, <label> ; T1
if (minus_zero) {
vldr(CurrentCond(),
- kDataTypeValueNone,
+ Untyped64,
DRegister(rd),
MemOperand(pc, minus, 0));
} else {
vldr(CurrentCond(),
- kDataTypeValueNone,
+ Untyped64,
DRegister(rd),
&location);
}
@@ -23153,7 +23159,7 @@ void Disassembler::DecodeT32(uint32_t instr) {
int32_t offset = (instr & 0xff) << 2;
// VLDR{<c>}{<q>}{.32} <Sd>, [<Rn>{, #{+/-}<imm>}] ; T2 NOLINT(whitespace/line_length)
vldr(CurrentCond(),
- kDataTypeValueNone,
+ Untyped32,
SRegister(rd),
MemOperand(Register(rn),
sign,
@@ -23175,7 +23181,7 @@ void Disassembler::DecodeT32(uint32_t instr) {
int32_t offset = (instr & 0xff) << 2;
// VLDR{<c>}{<q>}{.64} <Dd>, [<Rn>{, #{+/-}<imm>}] ; T1 NOLINT(whitespace/line_length)
vldr(CurrentCond(),
- kDataTypeValueNone,
+ Untyped64,
DRegister(rd),
MemOperand(Register(rn),
sign,
@@ -65767,7 +65773,7 @@ void Disassembler::DecodeA32(uint32_t instr) {
int32_t offset = (instr & 0xff) << 2;
// VSTR{<c>}{<q>}{.32} <Sd>, [<Rn>{, #{+/-}<imm>}] ; A2
vstr(condition,
- kDataTypeValueNone,
+ Untyped32,
SRegister(rd),
MemOperand(Register(rn), sign, offset, Offset));
break;
@@ -65785,7 +65791,7 @@ void Disassembler::DecodeA32(uint32_t instr) {
int32_t offset = (instr & 0xff) << 2;
// VSTR{<c>}{<q>}{.64} <Dd>, [<Rn>{, #{+/-}<imm>}] ; A1
vstr(condition,
- kDataTypeValueNone,
+ Untyped64,
DRegister(rd),
MemOperand(Register(rn), sign, offset, Offset));
break;
@@ -65969,12 +65975,12 @@ void Disassembler::DecodeA32(uint32_t instr) {
// VLDR{<c>}{<q>}{.32} <Sd>, <label> ; A2
if (minus_zero) {
vldr(condition,
- kDataTypeValueNone,
+ Untyped32,
SRegister(rd),
MemOperand(pc, minus, 0));
} else {
vldr(condition,
- kDataTypeValueNone,
+ Untyped32,
SRegister(rd),
&location);
}
@@ -65997,12 +66003,12 @@ void Disassembler::DecodeA32(uint32_t instr) {
// VLDR{<c>}{<q>}{.64} <Dd>, <label> ; A1
if (minus_zero) {
vldr(condition,
- kDataTypeValueNone,
+ Untyped64,
DRegister(rd),
MemOperand(pc, minus, 0));
} else {
vldr(condition,
- kDataTypeValueNone,
+ Untyped64,
DRegister(rd),
&location);
}
@@ -66043,7 +66049,7 @@ void Disassembler::DecodeA32(uint32_t instr) {
int32_t offset = (instr & 0xff) << 2;
// VLDR{<c>}{<q>}{.32} <Sd>, [<Rn>{, #{+/-}<imm>}] ; A2 NOLINT(whitespace/line_length)
vldr(condition,
- kDataTypeValueNone,
+ Untyped32,
SRegister(rd),
MemOperand(Register(rn),
sign,
@@ -66066,7 +66072,7 @@ void Disassembler::DecodeA32(uint32_t instr) {
int32_t offset = (instr & 0xff) << 2;
// VLDR{<c>}{<q>}{.64} <Dd>, [<Rn>{, #{+/-}<imm>}] ; A1 NOLINT(whitespace/line_length)
vldr(condition,
- kDataTypeValueNone,
+ Untyped64,
DRegister(rd),
MemOperand(Register(rn),
sign,
diff --git a/src/aarch32/disasm-aarch32.h b/src/aarch32/disasm-aarch32.h
index 657136a8..922e8c7f 100644
--- a/src/aarch32/disasm-aarch32.h
+++ b/src/aarch32/disasm-aarch32.h
@@ -111,6 +111,19 @@ class Disassembler {
}
};
+ class DtPrinter {
+ DataType dt_;
+ DataType default_dt_;
+
+ public:
+ DtPrinter(DataType dt, DataType default_dt)
+ : dt_(dt), default_dt_(default_dt) {}
+ friend std::ostream& operator<<(std::ostream& os, DtPrinter dt) {
+ if (dt.dt_.Is(dt.default_dt_)) return os;
+ return os << dt.dt_;
+ }
+ };
+
// TODO: Merge this class with PrintLabel below. This Location class
// represents a PC-relative offset, not an address.
class Location {
@@ -221,6 +234,10 @@ class Disassembler {
os_ << size;
return *this;
}
+ virtual DisassemblerStream& operator<<(const DtPrinter& dt) {
+ os_ << dt;
+ return *this;
+ }
virtual DisassemblerStream& operator<<(const DataType& type) {
os_ << type;
return *this;
diff --git a/src/aarch32/instructions-aarch32.h b/src/aarch32/instructions-aarch32.h
index 2ff5c8bb..79ca0e78 100644
--- a/src/aarch32/instructions-aarch32.h
+++ b/src/aarch32/instructions-aarch32.h
@@ -300,6 +300,7 @@ class DataType {
return (value_ & kDataTypeSizeMask) == size;
}
const char* GetName() const;
+ bool Is(DataType type) const { return value_ == type.value_; }
bool Is(DataTypeValue value) const { return value_ == value; }
bool Is(DataTypeType type) const { return GetType() == type; }
bool IsNoneOr(DataTypeValue value) const {