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

Side by Side Diff: test/cctest/test-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, 5 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 unified diff | Download patch
« no previous file with comments | « test/cctest/test-macro-assembler-mips.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 static bool all_zeroes(const byte* beg, const byte* end) { 54 static bool all_zeroes(const byte* beg, const byte* end) {
55 CHECK(beg); 55 CHECK(beg);
56 CHECK(beg <= end); 56 CHECK(beg <= end);
57 while (beg < end) { 57 while (beg < end) {
58 if (*beg++ != 0) 58 if (*beg++ != 0)
59 return false; 59 return false;
60 } 60 }
61 return true; 61 return true;
62 } 62 }
63 63
64 TEST(BYTESWAP) {
65 DCHECK(kArchVariant == kMips64r6 || kArchVariant == kMips64r2);
66 CcTest::InitializeVM();
67 Isolate* isolate = CcTest::i_isolate();
68 HandleScope scope(isolate);
69
70 struct T {
71 int64_t r1;
72 int64_t r2;
73 int64_t r3;
74 int64_t r4;
75 int64_t r5;
76 int64_t r6;
77 int64_t r7;
78 };
79 T t;
80
81 MacroAssembler assembler(isolate, NULL, 0,
82 v8::internal::CodeObjectRequired::kYes);
83
84 MacroAssembler* masm = &assembler;
85
86 __ ld(a4, MemOperand(a0, offsetof(T, r1)));
87 __ nop();
88 __ ByteSwapSigned(a4, 8);
89 __ sd(a4, MemOperand(a0, offsetof(T, r1)));
90
91 __ ld(a4, MemOperand(a0, offsetof(T, r2)));
92 __ nop();
93 __ ByteSwapSigned(a4, 4);
94 __ sd(a4, MemOperand(a0, offsetof(T, r2)));
95
96 __ ld(a4, MemOperand(a0, offsetof(T, r3)));
97 __ nop();
98 __ ByteSwapSigned(a4, 2);
99 __ sd(a4, MemOperand(a0, offsetof(T, r3)));
100
101 __ ld(a4, MemOperand(a0, offsetof(T, r4)));
102 __ nop();
103 __ ByteSwapSigned(a4, 1);
104 __ sd(a4, MemOperand(a0, offsetof(T, r4)));
105
106 __ ld(a4, MemOperand(a0, offsetof(T, r5)));
107 __ nop();
108 __ ByteSwapUnsigned(a4, 1);
109 __ sd(a4, MemOperand(a0, offsetof(T, r5)));
110
111 __ ld(a4, MemOperand(a0, offsetof(T, r6)));
112 __ nop();
113 __ ByteSwapUnsigned(a4, 2);
114 __ sd(a4, MemOperand(a0, offsetof(T, r6)));
115
116 __ ld(a4, MemOperand(a0, offsetof(T, r7)));
117 __ nop();
118 __ ByteSwapUnsigned(a4, 4);
119 __ sd(a4, MemOperand(a0, offsetof(T, r7)));
120
121 __ jr(ra);
122 __ nop();
123
124 CodeDesc desc;
125 masm->GetCode(&desc);
126 Handle<Code> code = isolate->factory()->NewCode(
127 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
128 ::F3 f = FUNCTION_CAST<::F3>(code->entry());
129 t.r1 = 0x5612FFCD9D327ACC;
130 t.r2 = 0x781A15C3;
131 t.r3 = 0xFCDE;
132 t.r4 = 0x9F;
133 t.r5 = 0x9F;
134 t.r6 = 0xFCDE;
135 t.r7 = 0xC81A15C3;
136 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
137 USE(dummy);
138
139 CHECK_EQ(static_cast<int64_t>(0xCC7A329DCDFF1256), t.r1);
140 CHECK_EQ(static_cast<int64_t>(0xC3151A7800000000), t.r2);
141 CHECK_EQ(static_cast<int64_t>(0xDEFCFFFFFFFFFFFF), t.r3);
142 CHECK_EQ(static_cast<int64_t>(0x9FFFFFFFFFFFFFFF), t.r4);
143 CHECK_EQ(static_cast<int64_t>(0x9F00000000000000), t.r5);
144 CHECK_EQ(static_cast<int64_t>(0xDEFC000000000000), t.r6);
145 CHECK_EQ(static_cast<int64_t>(0xC3151AC800000000), t.r7);
146 }
64 147
65 TEST(CopyBytes) { 148 TEST(CopyBytes) {
66 CcTest::InitializeVM(); 149 CcTest::InitializeVM();
67 Isolate* isolate = CcTest::i_isolate(); 150 Isolate* isolate = CcTest::i_isolate();
68 HandleScope handles(isolate); 151 HandleScope handles(isolate);
69 152
70 const int data_size = 1 * KB; 153 const int data_size = 1 * KB;
71 size_t act_size; 154 size_t act_size;
72 155
73 // Allocate two blocks to copy data between. 156 // Allocate two blocks to copy data between.
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 int32_t out_offset) { 1822 int32_t out_offset) {
1740 __ Uldc1(f0, MemOperand(a0, in_offset), t0); 1823 __ Uldc1(f0, MemOperand(a0, in_offset), t0);
1741 __ Usdc1(f0, MemOperand(a0, out_offset), t0); 1824 __ Usdc1(f0, MemOperand(a0, out_offset), t0);
1742 })); 1825 }));
1743 } 1826 }
1744 } 1827 }
1745 } 1828 }
1746 } 1829 }
1747 1830
1748 #undef __ 1831 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-macro-assembler-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698