From 9af09806fd91ca9ca52807704bf30bbf80a733b0 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 16 Aug 2017 08:25:47 -0700 Subject: Use DtPrinter to print some data types. Change-Id: Id198393e31c05bffed4537554aac2be1a2919382 --- src/aarch32/disasm-aarch32.cc | 70 +++++++++++++++++++++----------------- src/aarch32/disasm-aarch32.h | 17 +++++++++ src/aarch32/instructions-aarch32.h | 1 + 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{}{}{.32} , [{, #{+/-}}] ; 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{}{}{.64}
, [{, #{+/-}}] ; 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{}{}{.32} ,
,
, [{, #{+/-}}] ; 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{}{}{.32} , [{, #{+/-}}] ; 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{}{}{.64}
, [{, #{+/-}}] ; 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{}{}{.32} ,
,
, [{, #{+/-}}] ; 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..b5ac4976 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& cond) { + os_ << cond; + 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 { -- cgit v1.2.3