Commit 06520ec2 authored by sampsong's avatar sampsong Committed by Commit bot

PPC: Enable unaligned access and clean up the use of UNALIGNED_ACCESSES

BUG=

R=joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, mbrandy@us.ibm.com, bjaideep@ca.ibm.com, bmeurer@chromium.org, mstarzinger@chromium.org

Review-Url: https://codereview.chromium.org/2242223002
Cr-Commit-Position: refs/heads/master@{#38728}
parent 990999f3
......@@ -989,10 +989,9 @@ void InterpreterAssembler::TraceBytecodeDispatch(Node* target_bytecode) {
bool InterpreterAssembler::TargetSupportsUnalignedAccess() {
#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
return false;
#elif V8_TARGET_ARCH_PPC
return CpuFeatures::IsSupported(UNALIGNED_ACCESSES);
#elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \
V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64
V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || \
V8_TARGET_ARCH_PPC
return true;
#else
#error "Unknown Architecture"
......
......@@ -1231,6 +1231,21 @@ void Assembler::lwax(Register rt, const MemOperand& src) {
}
void Assembler::ldbrx(Register dst, const MemOperand& src) {
x_form(EXT2 | LDBRX, src.ra(), dst, src.rb(), LeaveRC);
}
void Assembler::lwbrx(Register dst, const MemOperand& src) {
x_form(EXT2 | LWBRX, src.ra(), dst, src.rb(), LeaveRC);
}
void Assembler::lhbrx(Register dst, const MemOperand& src) {
x_form(EXT2 | LHBRX, src.ra(), dst, src.rb(), LeaveRC);
}
void Assembler::stb(Register dst, const MemOperand& src) {
DCHECK(!src.ra_.is(r0));
d_form(STB, dst, src.ra(), src.offset(), true);
......
......@@ -877,6 +877,9 @@ class Assembler : public AssemblerBase {
void lwzux(Register dst, const MemOperand& src);
void lwa(Register dst, const MemOperand& src);
void lwax(Register dst, const MemOperand& src);
void ldbrx(Register dst, const MemOperand& src);
void lwbrx(Register dst, const MemOperand& src);
void lhbrx(Register dst, const MemOperand& src);
void stb(Register dst, const MemOperand& src);
void stbx(Register dst, const MemOperand& src);
void stbux(Register dst, const MemOperand& src);
......
......@@ -241,6 +241,8 @@ enum OpcodeExt2 {
POPCNTD = 506 << 1, // Population Count Doubleword
// Below represent bits 10-1 (any value >= 512)
LDBRX = 532 << 1, // load double word byte reversed w/ x-form
LWBRX = 534 << 1, // load word byte reversed w/ x-form
LFSX = 535 << 1, // load float-single w/ x-form
SRWX = 536 << 1, // Shift Right Word
SRDX = 539 << 1, // Shift Right Double Word
......@@ -252,6 +254,7 @@ enum OpcodeExt2 {
STFSUX = 695 << 1, // store float-single w/ update x-form
STFDX = 727 << 1, // store float-double w/ x-form
STFDUX = 759 << 1, // store float-double w/ update x-form
LHBRX = 790 << 1, // load half word byte reversed w/ x-form
SRAW = 792 << 1, // Shift Right Algebraic Word
SRAD = 794 << 1, // Shift Right Algebraic Double Word
SRAWIX = 824 << 1, // Shift Right Algebraic Word Immediate
......
......@@ -3329,50 +3329,9 @@ void MacroAssembler::CopyBytes(Register src, Register dst, Register length,
LoadP(scratch, MemOperand(src));
addi(src, src, Operand(kPointerSize));
subi(length, length, Operand(kPointerSize));
if (CpuFeatures::IsSupported(UNALIGNED_ACCESSES)) {
// currently false for PPC - but possible future opt
StoreP(scratch, MemOperand(dst));
addi(dst, dst, Operand(kPointerSize));
} else {
#if V8_TARGET_LITTLE_ENDIAN
stb(scratch, MemOperand(dst, 0));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 1));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 2));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 3));
#if V8_TARGET_ARCH_PPC64
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 4));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 5));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 6));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 7));
#endif
#else
#if V8_TARGET_ARCH_PPC64
stb(scratch, MemOperand(dst, 7));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 6));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 5));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 4));
ShiftRightImm(scratch, scratch, Operand(8));
#endif
stb(scratch, MemOperand(dst, 3));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 2));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 1));
ShiftRightImm(scratch, scratch, Operand(8));
stb(scratch, MemOperand(dst, 0));
#endif
addi(dst, dst, Operand(kPointerSize));
}
StoreP(scratch, MemOperand(dst));
addi(dst, dst, Operand(kPointerSize));
bdnz(&word_loop);
// Copy the last bytes if any left.
......
......@@ -1269,11 +1269,6 @@ void RegExpMacroAssemblerPPC::CheckStackLimit() {
}
bool RegExpMacroAssemblerPPC::CanReadUnaligned() {
return CpuFeatures::IsSupported(UNALIGNED_ACCESSES) && !slow_safe();
}
void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset,
int characters) {
Register offset = current_input_offset();
......@@ -1287,14 +1282,47 @@ void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset,
// We assume we don't want to do unaligned loads on PPC, so this function
// must only be used to load a single character at a time.
DCHECK(characters == 1);
__ add(current_character(), end_of_input_address(), offset);
#if V8_TARGET_LITTLE_ENDIAN
if (mode_ == LATIN1) {
__ lbz(current_character(), MemOperand(current_character()));
if (characters == 4) {
__ lwz(current_character(), MemOperand(current_character()));
} else if (characters == 2) {
__ lhz(current_character(), MemOperand(current_character()));
} else {
DCHECK(characters == 1);
__ lbz(current_character(), MemOperand(current_character()));
}
} else {
DCHECK(mode_ == UC16);
__ lhz(current_character(), MemOperand(current_character()));
if (characters == 2) {
__ lwz(current_character(), MemOperand(current_character()));
} else {
DCHECK(characters == 1);
__ lhz(current_character(), MemOperand(current_character()));
}
}
#else
if (mode_ == LATIN1) {
if (characters == 4) {
__ lwbrx(current_character(), MemOperand(r0, current_character()));
} else if (characters == 2) {
__ lhbrx(current_character(), MemOperand(r0, current_character()));
} else {
DCHECK(characters == 1);
__ lbz(current_character(), MemOperand(current_character()));
}
} else {
DCHECK(mode_ == UC16);
if (characters == 2) {
__ lwz(current_character(), MemOperand(current_character()));
__ rlwinm(current_character(), current_character(), 16, 0, 31);
} else {
DCHECK(characters == 1);
__ lhz(current_character(), MemOperand(current_character()));
}
}
#endif
}
......
......@@ -78,7 +78,6 @@ class RegExpMacroAssemblerPPC : public NativeRegExpMacroAssembler {
virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
virtual void ClearRegisters(int reg_from, int reg_to);
virtual void WriteStackPointerToRegister(int reg);
virtual bool CanReadUnaligned();
// Called from RegExp if the stack-guard is triggered.
// If the code object is relocated, the return address is fixed before
......
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