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

Side by Side Diff: runtime/vm/assembler_mips_test.cc

Issue 14206002: Adds some floating point instructions to MIPS simulator, assembler, disassembler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 __ Bind(&done); 1100 __ Bind(&done);
1101 __ Ret(); 1101 __ Ret();
1102 } 1102 }
1103 1103
1104 1104
1105 ASSEMBLER_TEST_RUN(AddOverflow_detect, test) { 1105 ASSEMBLER_TEST_RUN(AddOverflow_detect, test) {
1106 typedef int (*SimpleCode)(); 1106 typedef int (*SimpleCode)();
1107 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); 1107 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
1108 } 1108 }
1109 1109
1110
1111 ASSEMBLER_TEST_GENERATE(Mtc1Mfc1, assembler) {
1112 __ mtc1(ZR, F0);
1113 __ mfc1(V0, F0);
1114 __ Ret();
1115 }
1116
1117
1118 ASSEMBLER_TEST_RUN(Mtc1Mfc1, test) {
1119 typedef double (*SimpleCode)();
1120 EXPECT(test != NULL);
1121 double res = EXECUTE_TEST_CODE_FLOAT(SimpleCode, test->entry());
1122 EXPECT_FLOAT_EQ(0.0, res, 0.001);
1123 }
1124
1125
1126 ASSEMBLER_TEST_GENERATE(Addd, assembler) {
1127 __ LoadImmediate(F0, 1.0);
1128 __ LoadImmediate(F2, 2.0);
1129 __ addd(F4, F0, F2);
1130 __ mfc1(V0, F4);
1131 __ mfc1(V1, F5);
1132 __ Ret();
1133 }
1134
1135
1136 ASSEMBLER_TEST_RUN(Addd, test) {
1137 typedef double (*SimpleCode)();
1138 EXPECT(test != NULL);
1139 double res = EXECUTE_TEST_CODE_DOUBLE(SimpleCode, test->entry());
1140 EXPECT_FLOAT_EQ(3.0, res, 0.001);
1141 }
1142
1143
1144 ASSEMBLER_TEST_GENERATE(Adds, assembler) {
1145 __ LoadImmediate(F0, 1.0f);
1146 __ LoadImmediate(F2, 2.0f);
1147 __ adds(F4, F0, F2);
1148 __ mfc1(V0, F4);
1149 __ Ret();
1150 }
1151
1152
1153 ASSEMBLER_TEST_RUN(Adds, test) {
1154 typedef double (*SimpleCode)();
1155 EXPECT(test != NULL);
1156 double res = EXECUTE_TEST_CODE_FLOAT(SimpleCode, test->entry());
1157 EXPECT_FLOAT_EQ(3.0, res, 0.001);
1158 }
1159
1160
1161 ASSEMBLER_TEST_GENERATE(Movd, assembler) {
1162 __ LoadImmediate(F0, 1.0);
1163 __ movd(F2, F0);
1164 __ mfc1(V0, F2);
1165 __ mfc1(V1, F3);
1166 __ Ret();
1167 }
1168
1169
1170 ASSEMBLER_TEST_RUN(Movd, test) {
1171 typedef double (*SimpleCode)();
1172 EXPECT(test != NULL);
1173 double res = EXECUTE_TEST_CODE_DOUBLE(SimpleCode, test->entry());
1174 EXPECT_FLOAT_EQ(1.0, res, 0.001);
1175 }
1176
1177
1178 ASSEMBLER_TEST_GENERATE(Movs, assembler) {
1179 __ LoadImmediate(F0, 1.0f);
1180 __ movd(F2, F0);
1181 __ mfc1(V0, F2);
1182 __ Ret();
1183 }
1184
1185
1186 ASSEMBLER_TEST_RUN(Movs, test) {
1187 typedef double (*SimpleCode)();
1188 EXPECT(test != NULL);
1189 double res = EXECUTE_TEST_CODE_FLOAT(SimpleCode, test->entry());
1190 EXPECT_FLOAT_EQ(1.0, res, 0.001);
1191 }
1192
1193
1194 ASSEMBLER_TEST_GENERATE(Sdc1Ldc1, assembler) {
1195 __ AddImmediate(SP, -8 * kWordSize);
1196 __ LoadImmediate(T1, ~(8 - 1));
1197 __ and_(T0, SP, T1); // Need 8 byte alignment.
1198 __ LoadImmediate(F0, 1.0);
1199 __ sdc1(F0, Address(T0));
1200 __ ldc1(F2, Address(T0));
1201 __ mfc1(V0, F2);
1202 __ mfc1(V1, F3);
1203 __ Ret();
1204 }
1205
1206
1207 ASSEMBLER_TEST_RUN(Sdc1Ldc1, test) {
1208 typedef double (*SimpleCode)();
1209 EXPECT(test != NULL);
1210 double res = EXECUTE_TEST_CODE_DOUBLE(SimpleCode, test->entry());
1211 EXPECT_FLOAT_EQ(1.0, res, 0.001);
1212 }
1213
1214
1215 ASSEMBLER_TEST_GENERATE(Swc1Lwc1, assembler) {
1216 __ AddImmediate(SP, -1 * kWordSize);
1217 __ LoadImmediate(F0, 1.0f);
1218 __ swc1(F0, Address(SP));
1219 __ lwc1(F1, Address(SP));
1220 __ mfc1(V0, F1);
1221 __ AddImmediate(SP, 1 * kWordSize);
1222 __ Ret();
1223 }
1224
1225 ASSEMBLER_TEST_RUN(Swc1Lwc1, test) {
1226 typedef double (*SimpleCode)();
1227 EXPECT(test != NULL);
1228 double res = EXECUTE_TEST_CODE_FLOAT(SimpleCode, test->entry());
1229 EXPECT_FLOAT_EQ(1.0, res, 0.001);
1230 }
1231
1232
1233 ASSEMBLER_TEST_GENERATE(Adds_NaN, assembler) {
1234 __ LoadImmediate(F0, 1.0f);
1235 __ LoadImmediate(T0, 0x7f800001); // NaN
1236 __ mtc1(T0, F2);
1237 __ adds(F4, F0, F2);
1238 __ mfc1(V0, F4);
1239 __ Ret();
1240 }
1241
1242
1243 ASSEMBLER_TEST_RUN(Adds_NaN, test) {
1244 typedef double (*SimpleCode)();
1245 EXPECT(test != NULL);
1246 float res = EXECUTE_TEST_CODE_FLOAT(SimpleCode, test->entry());
1247 EXPECT_EQ(isnan(res), true);
1248 }
1249
1250
1251 ASSEMBLER_TEST_GENERATE(Adds_Inf, assembler) {
1252 __ LoadImmediate(F0, 1.0f);
1253 __ LoadImmediate(T0, 0x7f800000); // +inf
1254 __ mtc1(T0, F2);
1255 __ adds(F4, F0, F2);
1256 __ mfc1(V0, F4);
1257 __ Ret();
1258 }
1259
1260
1261 ASSEMBLER_TEST_RUN(Adds_Inf, test) {
1262 typedef double (*SimpleCode)();
1263 EXPECT(test != NULL);
1264 float res = EXECUTE_TEST_CODE_FLOAT(SimpleCode, test->entry());
1265 EXPECT_EQ(isfinite(res), false);
1266 }
1267
1110 } // namespace dart 1268 } // namespace dart
1111 1269
1112 #endif // defined TARGET_ARCH_MIPS 1270 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698