Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2500)

Unified Diff: src/mips/macro-assembler-mips.cc

Issue 2069933003: Implement byte swapping instructions on MIPS32 and MIPS64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/mips/macro-assembler-mips.h ('k') | src/mips/simulator-mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips/macro-assembler-mips.cc
diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc
index a58084cfbef4f76a98e8ce55691b7ba81ba77175..0f77c86ac95e5fa32bf017c175de882b99b664b6 100644
--- a/src/mips/macro-assembler-mips.cc
+++ b/src/mips/macro-assembler-mips.cc
@@ -30,7 +30,6 @@ MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size,
}
}
-
void MacroAssembler::Load(Register dst,
const MemOperand& src,
Representation r) {
@@ -67,7 +66,6 @@ void MacroAssembler::Store(Register src,
}
}
-
void MacroAssembler::LoadRoot(Register destination,
Heap::RootListIndex index) {
lw(destination, MemOperand(s6, index << kPointerSizeLog2));
@@ -1191,6 +1189,79 @@ void MacroAssembler::Lsa(Register rd, Register rt, Register rs, uint8_t sa,
// ------------Pseudo-instructions-------------
+// Word Swap Byte
+void MacroAssembler::ByteSwapSigned(Register reg, int operand_size) {
+ DCHECK(operand_size == 1 || operand_size == 2 || operand_size == 4);
+ if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
+ if (operand_size == 2) {
+ seh(reg, reg);
+ } else if (operand_size == 1) {
+ seb(reg, reg);
+ }
+ // No need to do any preparation if operand_size is 4
+
+ wsbh(reg, reg);
+ rotr(reg, reg, 16);
+ } else if (IsMipsArchVariant(kMips32r1) || IsMipsArchVariant(kLoongson)) {
+ if (operand_size == 1) {
+ sll(reg, reg, 24);
+ sra(reg, reg, 24);
+ } else if (operand_size == 2) {
+ sll(reg, reg, 16);
+ sra(reg, reg, 16);
+ }
+ // No need to do any preparation if operand_size is 4
+
+ Register tmp = t0;
+ Register tmp2 = t1;
+
+ andi(tmp2, reg, 0xFF);
+ sll(tmp2, tmp2, 24);
+ or_(tmp, zero_reg, tmp2);
+
+ andi(tmp2, reg, 0xFF00);
+ sll(tmp2, tmp2, 8);
+ or_(tmp, tmp, tmp2);
+
+ srl(reg, reg, 8);
+ andi(tmp2, reg, 0xFF00);
+ or_(tmp, tmp, tmp2);
+
+ srl(reg, reg, 16);
+ andi(tmp2, reg, 0xFF);
+ or_(tmp, tmp, tmp2);
+
+ or_(reg, tmp, zero_reg);
+ }
+}
+
+void MacroAssembler::ByteSwapUnsigned(Register reg, int operand_size) {
+ DCHECK(operand_size == 1 || operand_size == 2);
+
+ if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
+ if (operand_size == 1) {
+ andi(reg, reg, 0xFF);
+ } else {
+ andi(reg, reg, 0xFFFF);
+ }
+ // No need to do any preparation if operand_size is 4
+
+ wsbh(reg, reg);
+ rotr(reg, reg, 16);
+ } else if (IsMipsArchVariant(kMips32r1) || IsMipsArchVariant(kLoongson)) {
+ if (operand_size == 1) {
+ sll(reg, reg, 24);
+ } else {
+ Register tmp = t0;
+
+ andi(tmp, reg, 0xFF00);
+ sll(reg, reg, 24);
+ sll(tmp, tmp, 8);
+ or_(reg, tmp, reg);
+ }
+ }
+}
+
void MacroAssembler::Ulw(Register rd, const MemOperand& rs) {
DCHECK(!rd.is(at));
DCHECK(!rs.rm().is(at));
« no previous file with comments | « src/mips/macro-assembler-mips.h ('k') | src/mips/simulator-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698