Index: test/cctest/test-assembler-s390.cc |
diff --git a/test/cctest/test-assembler-s390.cc b/test/cctest/test-assembler-s390.cc |
index ccda898dfb7210ca53e1c9ea7d5d9ea987424e57..f6b79d499499065e4cc164b739a883ca76d85f0c 100644 |
--- a/test/cctest/test-assembler-s390.cc |
+++ b/test/cctest/test-assembler-s390.cc |
@@ -413,4 +413,89 @@ TEST(9) { |
} |
#endif |
+// Test msrkc and msgrkc |
+TEST(10) { |
+ if (!CpuFeatures::IsSupported(MISC_INSTR_EXT2)) { |
+ return; |
+ } |
+ |
+ ::printf("MISC_INSTR_EXT2 is enabled.\n"); |
+ |
+ CcTest::InitializeVM(); |
+ Isolate* isolate = CcTest::i_isolate(); |
+ HandleScope scope(isolate); |
+ |
+ Assembler assm(isolate, NULL, 0); |
+ |
+ Label ok, failed; |
+ |
+ { // test 1: msrkc |
+ __ lgfi(r2, Operand(3)); |
+ __ lgfi(r3, Operand(4)); |
+ __ msrkc(r1, r2, r3); // 3 * 4 |
+ __ b(static_cast<Condition>(le | overflow), &failed); // test failed. |
+ __ chi(r1, Operand(12)); |
+ __ bne(&failed); // test failed. |
+ |
+ __ lgfi(r2, Operand(-3)); |
+ __ lgfi(r3, Operand(4)); |
+ __ msrkc(r1, r2, r3); // -3 * 4 |
+ __ b(static_cast<Condition>(ge | overflow), &failed); // test failed. |
+ __ chi(r1, Operand(-12)); |
+ __ bne(&failed); // test failed. |
+ |
+ __ iilf(r2, Operand(0x80000000)); |
+ __ lgfi(r3, Operand(-1)); |
+ __ msrkc(r1, r2, r3); // INT_MIN * -1 |
+ __ b(nooverflow, &failed); // test failed. |
+ __ cfi(r1, Operand(0x80000000)); |
+ __ bne(&failed); // test failed. |
+ } |
+ |
+ { // test 1: msgrkc |
+ __ lgfi(r2, Operand(3)); |
+ __ lgfi(r3, Operand(4)); |
+ __ msgrkc(r1, r2, r3); // 3 * 4 |
+ __ b(static_cast<Condition>(le | overflow), &failed); // test failed. |
+ __ chi(r1, Operand(12)); |
+ __ bne(&failed); // test failed. |
+ |
+ __ lgfi(r2, Operand(-3)); |
+ __ lgfi(r3, Operand(4)); |
+ __ msgrkc(r1, r2, r3); // -3 * 4 |
+ __ b(static_cast<Condition>(ge | overflow), &failed); // test failed. |
+ __ chi(r1, Operand(-12)); |
+ __ bne(&failed); // test failed. |
+ |
+ __ lgfi(r2, Operand::Zero()); |
+ __ iihf(r2, Operand(0x80000000)); |
+ __ lgfi(r3, Operand(-1)); |
+ __ msgrkc(r1, r2, r3); // INT_MIN * -1 |
+ __ b(nooverflow, &failed); // test failed. |
+ __ cgr(r1, r2); |
+ __ bne(&failed); // test failed. |
+ } |
+ |
+ __ bind(&ok); |
+ __ lgfi(r2, Operand::Zero()); |
+ __ b(r14); // test done. |
+ |
+ __ bind(&failed); |
+ __ lgfi(r2, Operand(1)); |
+ __ b(r14); |
+ |
+ CodeDesc desc; |
+ assm.GetCode(&desc); |
+ Handle<Code> code = isolate->factory()->NewCode( |
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
+#ifdef DEBUG |
+ code->Print(); |
+#endif |
+ F2 f = FUNCTION_CAST<F2>(code->entry()); |
+ intptr_t res = reinterpret_cast<intptr_t>( |
+ CALL_GENERATED_CODE(isolate, f, 3, 4, 0, 0, 0)); |
+ ::printf("f() = %" V8PRIxPTR "\n", res); |
+ CHECK_EQ(0, static_cast<int>(res)); |
+} |
+ |
#undef __ |