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

Unified Diff: src/mips64/macro-assembler-mips64.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/mips64/macro-assembler-mips64.h ('k') | src/mips64/simulator-mips64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips64/macro-assembler-mips64.cc
diff --git a/src/mips64/macro-assembler-mips64.cc b/src/mips64/macro-assembler-mips64.cc
index f409c0fb49a564d862437213a8fd3ad62cf92947..c93b847daab61ce40d46e39d627c0180e3e6a968 100644
--- a/src/mips64/macro-assembler-mips64.cc
+++ b/src/mips64/macro-assembler-mips64.cc
@@ -29,7 +29,6 @@ MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size,
}
}
-
void MacroAssembler::Load(Register dst,
const MemOperand& src,
Representation r) {
@@ -1324,6 +1323,49 @@ void MacroAssembler::Dlsa(Register rd, Register rt, Register rs, uint8_t sa,
// ------------Pseudo-instructions-------------
+// Change endianness
+void MacroAssembler::ByteSwapSigned(Register reg, int operand_size) {
+ DCHECK(operand_size == 1 || operand_size == 2 || operand_size == 4 ||
+ operand_size == 8);
+ DCHECK(kArchVariant == kMips64r6 || kArchVariant == kMips64r2);
+ if (operand_size == 1) {
+ seb(reg, reg);
+ sll(reg, reg, 0);
+ dsbh(reg, reg);
+ dshd(reg, reg);
+ } else if (operand_size == 2) {
+ seh(reg, reg);
+ sll(reg, reg, 0);
+ dsbh(reg, reg);
+ dshd(reg, reg);
+ } else if (operand_size == 4) {
+ sll(reg, reg, 0);
+ dsbh(reg, reg);
+ dshd(reg, reg);
+ } else {
+ dsbh(reg, reg);
+ dshd(reg, reg);
+ }
+}
+
+void MacroAssembler::ByteSwapUnsigned(Register reg, int operand_size) {
+ DCHECK(operand_size == 1 || operand_size == 2 || operand_size == 4);
+ if (operand_size == 1) {
+ andi(reg, reg, 0xFF);
+ dsbh(reg, reg);
+ dshd(reg, reg);
+ } else if (operand_size == 2) {
+ andi(reg, reg, 0xFFFF);
+ dsbh(reg, reg);
+ dshd(reg, reg);
+ } else {
+ dsll32(reg, reg, 0);
+ dsrl32(reg, reg, 0);
+ dsbh(reg, reg);
+ dshd(reg, reg);
+ }
+}
+
void MacroAssembler::Ulw(Register rd, const MemOperand& rs) {
DCHECK(!rd.is(at));
DCHECK(!rs.rm().is(at));
« no previous file with comments | « src/mips64/macro-assembler-mips64.h ('k') | src/mips64/simulator-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698