OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 6039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6050 TEST(maddf_msubf_d) { | 6050 TEST(maddf_msubf_d) { |
6051 if (kArchVariant != kMips64r6) return; | 6051 if (kArchVariant != kMips64r6) return; |
6052 helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) { | 6052 helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) { |
6053 __ maddf_d(f4, f6, f8); | 6053 __ maddf_d(f4, f6, f8); |
6054 __ Sdc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add))); | 6054 __ Sdc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add))); |
6055 __ msubf_d(f16, f6, f8); | 6055 __ msubf_d(f16, f6, f8); |
6056 __ Sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub))); | 6056 __ Sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub))); |
6057 }); | 6057 }); |
6058 } | 6058 } |
6059 | 6059 |
6060 uint64_t run_Dins(uint64_t imm, uint64_t source, uint16_t pos, uint16_t size) { | |
6061 Isolate* isolate = CcTest::i_isolate(); | |
6062 HandleScope scope(isolate); | |
6063 | |
6064 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | |
6065 | |
6066 __ li(v0, imm); | |
6067 __ li(t0, source); | |
6068 __ Dins(v0, t0, pos, size); | |
6069 __ jr(ra); | |
6070 __ nop(); | |
6071 | |
6072 CodeDesc desc; | |
6073 assm.GetCode(&desc); | |
6074 Handle<Code> code = isolate->factory()->NewCode( | |
6075 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
6076 F2 f = FUNCTION_CAST<F2>(code->entry()); | |
6077 | |
6078 uint64_t res = reinterpret_cast<uint64_t>( | |
6079 CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); | |
6080 | |
6081 return res; | |
6082 } | |
6083 | |
6084 TEST(Dins) { | |
6085 CcTest::InitializeVM(); | |
6086 | |
6087 // Test Dins macro-instruction. | |
6088 | |
6089 struct TestCaseDins { | |
6090 uint64_t imm; | |
Ilija.Pavlovic1
2017/05/09 09:17:46
Instead "imm" maybe more suitable name is "res".
miran.karic
2017/05/09 13:52:43
This is initial value of target register, not resu
| |
6091 uint64_t source; | |
6092 uint16_t pos; | |
6093 uint16_t size; | |
6094 uint64_t expected_res; | |
6095 }; | |
6096 | |
6097 // We load imm to v0 and source to t0 and then call | |
6098 // Dins(v0, t0, pos, size) to test cases listed below. | |
6099 struct TestCaseDins tc[] = { | |
6100 // imm, source, pos, size, expected_res | |
6101 {0x0, 0x1FABCDEFF, 31, 1, 0x80000000}, | |
Ilija.Pavlovic1
2017/05/09 09:17:46
Instead 0x0, use another value (for example 0xAAAA
miran.karic
2017/05/09 13:52:43
Yes I think that will be better, I adjusted test c
| |
6102 {0x0, 0x1FABCDEFF, 30, 2, 0xc0000000}, | |
6103 {0x0, 0x1FABCDEFF, 0, 32, 0xFABCDEFF}, | |
6104 {0x0, 0x7FABCDEFF, 31, 2, 0x180000000}, | |
6105 {0x0, 0x7FABCDEFF, 0, 33, 0x1FABCDEFF}, | |
6106 {0x0, 0xABCDABCDABCDABCD, 0, 64, 0xABCDABCDABCDABCD}, | |
6107 {0x0, 0xABCEABCFABCEABCF, 32, 1, 0x100000000}, | |
6108 {0x0, 0xABCEABCFABCEABCF, 63, 1, 0x8000000000000000}, | |
6109 {0x0, 0xABCEABCFABCEABCF, 32, 32, 0xABCEABCF00000000}, | |
6110 }; | |
6111 | |
6112 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseDins); | |
6113 for (size_t i = 0; i < nr_test_cases; ++i) { | |
6114 CHECK_EQ(tc[i].expected_res, | |
6115 run_Dins(tc[i].imm, tc[i].source, tc[i].pos, tc[i].size)); | |
6116 } | |
6117 } | |
6118 | |
6119 uint64_t getExpectedValueDINS(uint64_t rt, uint64_t rs, int pos, int size) { | |
6120 uint64_t res = rt; | |
6121 int i; | |
6122 uint64_t bitVal; | |
6123 for (i = 0; i < size; i++) { | |
6124 bitVal = rs & (1 << i); | |
6125 if (bitVal > 0) bitVal = 1; | |
6126 res = res | bitVal << (i + pos); // Works only for rs equals all ones! | |
6127 } | |
6128 return res; | |
6129 } | |
6130 | |
6131 TEST(Dins_all) { | |
Ilija.Pavlovic1
2017/05/09 09:17:46
Maybe not needed to go through all combinations.
miran.karic
2017/05/09 13:52:43
I agree, I removed this test and only left Dins te
| |
6132 CcTest::InitializeVM(); | |
6133 Isolate* isolate = CcTest::i_isolate(); | |
6134 HandleScope scope(isolate); | |
6135 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | |
6136 | |
6137 // Test Dins macro-instruction. | |
6138 | |
6139 const uint64_t rt = 0; | |
6140 const uint64_t rs = std::numeric_limits<uint64_t>::max(); | |
6141 Label exit, error; | |
6142 uint64_t result; | |
6143 | |
6144 int iPos, iSize; | |
6145 // Run through all possible Dins pos and size inputs. | |
6146 for (iPos = 0; iPos < 64; ++iPos) { | |
6147 for (iSize = 1; iSize <= 64 - iPos; ++iSize) { | |
6148 result = getExpectedValueDINS(rt, rs, iPos, iSize); | |
6149 __ li(a0, rt); | |
6150 __ li(a1, rs); | |
6151 __ Dins(a0, a1, iPos, iSize); | |
6152 __ Branch(&error, ne, a0, Operand(result)); | |
6153 __ nop(); | |
6154 } | |
6155 } | |
6156 | |
6157 // Everything was correctly executed. Load the expected result. | |
6158 __ li(v0, 0x31415926); | |
6159 __ b(&exit); | |
6160 __ nop(); | |
6161 | |
6162 __ bind(&error); | |
6163 // Got an error. Return a wrong result. | |
6164 __ li(v0, 666); | |
6165 | |
6166 __ bind(&exit); | |
6167 __ jr(ra); | |
6168 __ nop(); | |
6169 | |
6170 CodeDesc desc; | |
6171 assm.GetCode(&desc); | |
6172 Handle<Code> code = isolate->factory()->NewCode( | |
6173 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
6174 F2 f = FUNCTION_CAST<F2>(code->entry()); | |
6175 int64_t res = | |
6176 reinterpret_cast<int64_t>(CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); | |
6177 | |
6178 CHECK_EQ(0x31415926L, res); | |
6179 } | |
6180 | |
6060 #undef __ | 6181 #undef __ |
OLD | NEW |