diff options
author | Steve Kondik <steve@cyngn.com> | 2015-07-12 17:13:50 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2015-07-15 15:36:12 -0700 |
commit | d36d235d0ce67113a8e2f1b1657c62a99103a9ab (patch) | |
tree | 13133415a2144dbf7797062f95eaf7b5eae8a54a | |
parent | 0ad677f050b36eed5ca270e52a395a9c47e365d5 (diff) | |
download | android_art-stable/cm-12.1-YOG4P.tar.gz android_art-stable/cm-12.1-YOG4P.tar.bz2 android_art-stable/cm-12.1-YOG4P.zip |
Revert "Revert "AArch64: Fix incorrect use of preceding LIR.""stable/cm-12.1-YOG4P
* Restore A53 workarounds. We were missing the rest of the series.
This reverts commit be627376eb8dd5a07414e966cf24ba94030cff96.
Change-Id: I6bef49b5381047fa381c77031d883bba3dae6d9f
(cherry picked from commit 913010c500e9c3ac9d348a19d5a03694ae08a408)
Ticket: CYNGNOS-442
-rw-r--r-- | compiler/dex/compiler_enums.h | 1 | ||||
-rw-r--r-- | compiler/dex/quick/arm64/arm64_lir.h | 3 | ||||
-rw-r--r-- | compiler/dex/quick/arm64/assemble_arm64.cc | 60 | ||||
-rw-r--r-- | compiler/dex/quick/arm64/int_arm64.cc | 5 | ||||
-rw-r--r-- | dex2oat/dex2oat.cc | 6 | ||||
-rw-r--r-- | runtime/base/macros.h | 2 | ||||
-rw-r--r-- | runtime/instruction_set.h | 9 |
7 files changed, 74 insertions, 12 deletions
diff --git a/compiler/dex/compiler_enums.h b/compiler/dex/compiler_enums.h index 62be1f3fc7..daff79d838 100644 --- a/compiler/dex/compiler_enums.h +++ b/compiler/dex/compiler_enums.h @@ -539,6 +539,7 @@ enum FixupKind { kFixupMovImmLST, // kThumb2MovImm16LST. kFixupMovImmHST, // kThumb2MovImm16HST. kFixupAlign4, // Align to 4-byte boundary. + kFixupA53Erratum835769, // Cortex A53 Erratum 835769. }; std::ostream& operator<<(std::ostream& os, const FixupKind& kind); diff --git a/compiler/dex/quick/arm64/arm64_lir.h b/compiler/dex/quick/arm64/arm64_lir.h index 83d0590e32..ff4543de97 100644 --- a/compiler/dex/quick/arm64/arm64_lir.h +++ b/compiler/dex/quick/arm64/arm64_lir.h @@ -320,6 +320,7 @@ enum ArmOpcode { kA64Madd4rrrr, // madd[s0011011000] rm[20-16] [0] ra[14-10] rn[9-5] rd[4-0]. kA64Msub4rrrr, // msub[s0011011000] rm[20-16] [1] ra[14-10] rn[9-5] rd[4-0]. kA64Neg3rro, // neg alias of "sub arg0, rzr, arg1, arg2". + kA64Nop0, // nop alias of "hint #0" [11010101000000110010000000011111]. kA64Orr3Rrl, // orr [s01100100] N[22] imm_r[21-16] imm_s[15-10] rn[9-5] rd[4-0]. kA64Orr4rrro, // orr [s0101010] shift[23-22] [0] rm[20-16] imm_6[15-10] rn[9-5] rd[4-0]. kA64Ret, // ret [11010110010111110000001111000000]. @@ -332,7 +333,7 @@ enum ArmOpcode { kA64Scvtf2fw, // scvtf [000111100s100010000000] rn[9-5] rd[4-0]. kA64Scvtf2fx, // scvtf [100111100s100010000000] rn[9-5] rd[4-0]. kA64Sdiv3rrr, // sdiv[s0011010110] rm[20-16] [000011] rn[9-5] rd[4-0]. - kA64Smaddl4xwwx, // smaddl [10011011001] rm[20-16] [0] ra[14-10] rn[9-5] rd[4-0]. + kA64Smull3xww, // smull [10011011001] rm[20-16] [011111] rn[9-5] rd[4-0]. kA64Smulh3xxx, // smulh [10011011010] rm[20-16] [011111] rn[9-5] rd[4-0]. kA64Stp4ffXD, // stp [0s10110100] imm_7[21-15] rt2[14-10] rn[9-5] rt[4-0]. kA64Stp4rrXD, // stp [s010100100] imm_7[21-15] rt2[14-10] rn[9-5] rt[4-0]. diff --git a/compiler/dex/quick/arm64/assemble_arm64.cc b/compiler/dex/quick/arm64/assemble_arm64.cc index 0898f7fa41..72236de08f 100644 --- a/compiler/dex/quick/arm64/assemble_arm64.cc +++ b/compiler/dex/quick/arm64/assemble_arm64.cc @@ -14,8 +14,9 @@ * limitations under the License. */ -#include "arm64_lir.h" #include "codegen_arm64.h" + +#include "arm64_lir.h" #include "dex/quick/mir_to_lir-inl.h" namespace art { @@ -467,13 +468,17 @@ const ArmEncodingMap Arm64Mir2Lir::EncodingMap[kA64Last] = { kFmtRegR, 20, 16, IS_QUAD_OP | REG_DEF0_USE123, "madd", "!0r, !1r, !3r, !2r", kFixupNone), ENCODING_MAP(WIDE(kA64Msub4rrrr), SF_VARIANTS(0x1b008000), - kFmtRegR, 4, 0, kFmtRegR, 9, 5, kFmtRegR, 14, 10, - kFmtRegR, 20, 16, IS_QUAD_OP | REG_DEF0_USE123, - "msub", "!0r, !1r, !3r, !2r", kFixupNone), + kFmtRegR, 4, 0, kFmtRegR, 9, 5, kFmtRegR, 20, 16, + kFmtRegR, 14, 10, IS_QUAD_OP | REG_DEF0_USE123 | NEEDS_FIXUP, + "msub", "!0r, !1r, !2r, !3r", kFixupA53Erratum835769), ENCODING_MAP(WIDE(kA64Neg3rro), SF_VARIANTS(0x4b0003e0), kFmtRegR, 4, 0, kFmtRegR, 20, 16, kFmtShift, -1, -1, kFmtUnused, -1, -1, IS_TERTIARY_OP | REG_DEF0_USE1, "neg", "!0r, !1r!2o", kFixupNone), + ENCODING_MAP(kA64Nop0, NO_VARIANTS(0xd503201f), + kFmtUnused, -1, -1, kFmtUnused, -1, -1, kFmtUnused, -1, -1, + kFmtUnused, -1, -1, NO_OPERAND, + "nop", "", kFixupNone), ENCODING_MAP(WIDE(kA64Orr3Rrl), SF_VARIANTS(0x32000000), kFmtRegROrSp, 4, 0, kFmtRegR, 9, 5, kFmtBitBlt, 22, 10, kFmtUnused, -1, -1, IS_TERTIARY_OP | REG_DEF0_USE1, @@ -522,10 +527,10 @@ const ArmEncodingMap Arm64Mir2Lir::EncodingMap[kA64Last] = { kFmtRegR, 4, 0, kFmtRegR, 9, 5, kFmtRegR, 20, 16, kFmtUnused, -1, -1, IS_TERTIARY_OP | REG_DEF0_USE12, "sdiv", "!0r, !1r, !2r", kFixupNone), - ENCODING_MAP(WIDE(kA64Smaddl4xwwx), NO_VARIANTS(0x9b200000), + ENCODING_MAP(kA64Smull3xww, NO_VARIANTS(0x9b207c00), kFmtRegX, 4, 0, kFmtRegW, 9, 5, kFmtRegW, 20, 16, - kFmtRegX, 14, 10, IS_QUAD_OP | REG_DEF0_USE123, - "smaddl", "!0x, !1w, !2w, !3x", kFixupNone), + kFmtUnused, -1, -1, IS_TERTIARY_OP | REG_DEF0_USE12, + "smull", "!0x, !1w, !2w", kFixupNone), ENCODING_MAP(kA64Smulh3xxx, NO_VARIANTS(0x9b407c00), kFmtRegX, 4, 0, kFmtRegX, 9, 5, kFmtRegX, 20, 16, kFmtUnused, -1, -1, IS_TERTIARY_OP | REG_DEF0_USE12, @@ -828,6 +833,20 @@ uint8_t* Arm64Mir2Lir::EncodeLIRs(uint8_t* write_pos, LIR* lir) { // are better set directly from the code (they will require no more than 2 instructions). #define ALIGNED_DATA_OFFSET(offset) (((offset) + 0x7) & ~0x7) +/* + * Get the LIR which emits the instruction preceding the given LIR. + * Returns nullptr, if no previous emitting insn found. + */ +static LIR* GetPrevEmittingLIR(LIR* lir) { + DCHECK(lir != nullptr); + LIR* prev_lir = lir->prev; + while ((prev_lir != nullptr) && + (prev_lir->flags.is_nop || Mir2Lir::IsPseudoLirOp(prev_lir->opcode))) { + prev_lir = prev_lir->prev; + } + return prev_lir; +} + // Assemble the LIR into binary instruction format. void Arm64Mir2Lir::AssembleLIR() { LIR* lir; @@ -920,6 +939,33 @@ void Arm64Mir2Lir::AssembleLIR() { lir->operands[1] = delta; break; } + case kFixupA53Erratum835769: + // Avoid emitting code that could trigger Cortex A53's erratum 835769. + // This fixup should be carried out for all multiply-accumulate instructions: madd, msub, + // smaddl, smsubl, umaddl and umsubl. + if (cu_->GetInstructionSetFeatures().NeedFix835769()) { + // Check that this is a 64-bit multiply-accumulate. + if (IS_WIDE(lir->opcode)) { + LIR* prev_insn = GetPrevEmittingLIR(lir); + if (prev_insn == nullptr) { + break; + } + uint64_t prev_insn_flags = EncodingMap[UNWIDE(prev_insn->opcode)].flags; + // Check that the instruction preceding the multiply-accumulate is a load or store. + if ((prev_insn_flags & IS_LOAD) != 0 || (prev_insn_flags & IS_STORE) != 0) { + // insert a NOP between the load/store and the multiply-accumulate. + LIR* new_lir = RawLIR(lir->dalvik_offset, kA64Nop0, 0, 0, 0, 0, 0, NULL); + new_lir->offset = lir->offset; + new_lir->flags.fixup = kFixupNone; + new_lir->flags.size = EncodingMap[kA64Nop0].size; + InsertLIRBefore(lir, new_lir); + lir->offset += new_lir->flags.size; + offset_adjustment += new_lir->flags.size; + res = kRetryAll; + } + } + } + break; default: LOG(FATAL) << "Unexpected case: opcode: " << lir->opcode << ", fixup: " << lir->flags.fixup; } diff --git a/compiler/dex/quick/arm64/int_arm64.cc b/compiler/dex/quick/arm64/int_arm64.cc index 1e97a3246c..a9b4658edf 100644 --- a/compiler/dex/quick/arm64/int_arm64.cc +++ b/compiler/dex/quick/arm64/int_arm64.cc @@ -419,8 +419,7 @@ bool Arm64Mir2Lir::SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_d rl_src = LoadValue(rl_src, kCoreReg); RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); RegStorage r_long_mul = AllocTemp(); - NewLIR4(kA64Smaddl4xwwx, As64BitReg(r_long_mul).GetReg(), - r_magic.GetReg(), rl_src.reg.GetReg(), rxzr); + NewLIR3(kA64Smull3xww, As64BitReg(r_long_mul).GetReg(), r_magic.GetReg(), rl_src.reg.GetReg()); switch (pattern) { case Divide3: OpRegRegImm(kOpLsr, As64BitReg(r_long_mul), As64BitReg(r_long_mul), 32); @@ -635,7 +634,7 @@ RegLocation Arm64Mir2Lir::GenDivRem(RegLocation rl_dest, RegStorage r_src1, RegS } OpRegRegReg(kOpDiv, temp, r_src1, r_src2); NewLIR4(kA64Msub4rrrr | wide, rl_result.reg.GetReg(), temp.GetReg(), - r_src1.GetReg(), r_src2.GetReg()); + r_src2.GetReg(), r_src1.GetReg()); FreeTemp(temp); } return rl_result; diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index c41147265f..2294c93a46 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -751,6 +751,12 @@ static InstructionSetFeatures ParseFeatureList(std::string str) { } else if (feature == "nolpae") { // Turn off support for Large Physical Address Extension. result.SetHasLpae(false); + } else if (feature == "needfix_835769") { + // need fix CortexA53 errata 835769 + result.SetFix835769(true); + } else if (feature == "noneedfix_835769") { + // no need fix CortexA53 errata 835769 + result.SetFix835769(false); } else { Usage("Unknown instruction set feature: '%s'", feature.c_str()); } diff --git a/runtime/base/macros.h b/runtime/base/macros.h index fae9271d9e..b1eab92f0c 100644 --- a/runtime/base/macros.h +++ b/runtime/base/macros.h @@ -151,7 +151,7 @@ char (&ArraySizeHelper(T (&array)[N]))[N]; #define UNLIKELY(x) __builtin_expect((x), false) // Stringify the argument. -#define QUOTE(x) #x +#define QUOTE(x...) #x #define STRINGIFY(x) QUOTE(x) #ifndef NDEBUG diff --git a/runtime/instruction_set.h b/runtime/instruction_set.h index da7d153c08..257c3d38e1 100644 --- a/runtime/instruction_set.h +++ b/runtime/instruction_set.h @@ -180,6 +180,7 @@ size_t GetStackOverflowReservedBytes(InstructionSet isa); enum InstructionFeatures { kHwDiv = 0x1, // Supports hardware divide. kHwLpae = 0x2, // Supports Large Physical Address Extension. + kFix835769 = 0x4, // need fix CortexA53 errata 835769 }; // This is a bitmask of supported features per architecture. @@ -206,6 +207,14 @@ class PACKED(4) InstructionSetFeatures { mask_ = (mask_ & ~kHwLpae) | (v ? kHwLpae : 0); } + bool NeedFix835769() const { + return (mask_ & kFix835769) != 0; + } + + void SetFix835769(bool v) { + mask_ = (mask_ & ~kFix835769) | (v ? kFix835769 : 0); + } + std::string GetFeatureString() const; // Other features in here. |