@@ -5556,14 +5556,16 @@ ASSEMBLER_TEST_GENERATE(TestRepMovsBytes, assembler) {
55565556}
55575557
55585558ASSEMBLER_TEST_RUN (TestRepMovsBytes, test) {
5559- const char * from = " 0123456789" ;
5560- const char * to = new char [10 ];
5561- typedef void (*TestRepMovsBytes)(const char * from, const char * to, int count);
5559+ const char * from = " 0123456789x" ;
5560+ char * to = new char [11 ];
5561+ to[10 ] = ' y' ;
5562+ typedef void (*TestRepMovsBytes)(const char * from, char * to, int count);
55625563 reinterpret_cast <TestRepMovsBytes>(test->entry ())(from, to, 10 );
55635564 EXPECT_EQ (to[0 ], ' 0' );
55645565 for (int i = 0 ; i < 10 ; i++) {
55655566 EXPECT_EQ (from[i], to[i]);
55665567 }
5568+ EXPECT_EQ (to[10 ], ' y' );
55675569 delete[] to;
55685570 EXPECT_DISASSEMBLY_NOT_WINDOWS (
55695571 " push rsi\n "
@@ -5583,6 +5585,163 @@ ASSEMBLER_TEST_RUN(TestRepMovsBytes, test) {
55835585 " ret\n " );
55845586}
55855587
5588+ ASSEMBLER_TEST_GENERATE (TestRepMovsWords, assembler) {
5589+ __ pushq (RSI);
5590+ __ pushq (RDI);
5591+ __ pushq (CallingConventions::kArg1Reg ); // from.
5592+ __ pushq (CallingConventions::kArg2Reg ); // to.
5593+ __ pushq (CallingConventions::kArg3Reg ); // count.
5594+ __ movq (RSI, Address (RSP, 2 * target::kWordSize )); // from.
5595+ __ movq (RDI, Address (RSP, 1 * target::kWordSize )); // to.
5596+ __ movq (RCX, Address (RSP, 0 * target::kWordSize )); // count.
5597+ __ rep_movsw ();
5598+ // Remove saved arguments.
5599+ __ popq (RAX);
5600+ __ popq (RAX);
5601+ __ popq (RAX);
5602+ __ popq (RDI);
5603+ __ popq (RSI);
5604+ __ ret ();
5605+ }
5606+
5607+ ASSEMBLER_TEST_RUN (TestRepMovsWords, test) {
5608+ const uint16_t from[11 ] = {0x0123 , 0x1234 , 0x2345 , 0x3456 , 0x4567 , 0x5678 ,
5609+ 0x6789 , 0x789A , 0x89AB , 0x9ABC , 0xABCD };
5610+ uint16_t * to = new uint16_t [11 ];
5611+ to[10 ] = 0xFEFE ;
5612+ typedef void (*TestRepMovsWords)(const uint16_t * from, uint16_t * to,
5613+ int count);
5614+ reinterpret_cast <TestRepMovsWords>(test->entry ())(from, to, 10 );
5615+ EXPECT_EQ (to[0 ], 0x0123u );
5616+ for (int i = 0 ; i < 10 ; i++) {
5617+ EXPECT_EQ (from[i], to[i]);
5618+ }
5619+ EXPECT_EQ (to[10 ], 0xFEFEu );
5620+ delete[] to;
5621+ EXPECT_DISASSEMBLY_NOT_WINDOWS (
5622+ " push rsi\n "
5623+ " push rdi\n "
5624+ " push rdi\n "
5625+ " push rsi\n "
5626+ " push rdx\n "
5627+ " movq rsi,[rsp+0x10]\n "
5628+ " movq rdi,[rsp+0x8]\n "
5629+ " movq rcx,[rsp]\n "
5630+ " rep movsw\n "
5631+ " pop rax\n "
5632+ " pop rax\n "
5633+ " pop rax\n "
5634+ " pop rdi\n "
5635+ " pop rsi\n "
5636+ " ret\n " );
5637+ }
5638+
5639+ ASSEMBLER_TEST_GENERATE (TestRepMovsDwords, assembler) {
5640+ __ pushq (RSI);
5641+ __ pushq (RDI);
5642+ __ pushq (CallingConventions::kArg1Reg ); // from.
5643+ __ pushq (CallingConventions::kArg2Reg ); // to.
5644+ __ pushq (CallingConventions::kArg3Reg ); // count.
5645+ __ movq (RSI, Address (RSP, 2 * target::kWordSize )); // from.
5646+ __ movq (RDI, Address (RSP, 1 * target::kWordSize )); // to.
5647+ __ movq (RCX, Address (RSP, 0 * target::kWordSize )); // count.
5648+ __ rep_movsl ();
5649+ // Remove saved arguments.
5650+ __ popq (RAX);
5651+ __ popq (RAX);
5652+ __ popq (RAX);
5653+ __ popq (RDI);
5654+ __ popq (RSI);
5655+ __ ret ();
5656+ }
5657+
5658+ ASSEMBLER_TEST_RUN (TestRepMovsDwords, test) {
5659+ const uint32_t from[11 ] = {0x01234567 , 0x12345678 , 0x23456789 , 0x3456789A ,
5660+ 0x456789AB , 0x56789ABC , 0x6789ABCD , 0x789ABCDE ,
5661+ 0x89ABCDEF , 0x9ABCDEF0 , 0xABCDEF01 };
5662+ uint32_t * to = new uint32_t [11 ];
5663+ to[10 ] = 0xFEFEFEFE ;
5664+ typedef void (*TestRepMovsDwords)(const uint32_t * from, uint32_t * to,
5665+ int count);
5666+ reinterpret_cast <TestRepMovsDwords>(test->entry ())(from, to, 10 );
5667+ EXPECT_EQ (to[0 ], 0x01234567u );
5668+ for (int i = 0 ; i < 10 ; i++) {
5669+ EXPECT_EQ (from[i], to[i]);
5670+ }
5671+ EXPECT_EQ (to[10 ], 0xFEFEFEFEu );
5672+ delete[] to;
5673+ EXPECT_DISASSEMBLY_NOT_WINDOWS (
5674+ " push rsi\n "
5675+ " push rdi\n "
5676+ " push rdi\n "
5677+ " push rsi\n "
5678+ " push rdx\n "
5679+ " movq rsi,[rsp+0x10]\n "
5680+ " movq rdi,[rsp+0x8]\n "
5681+ " movq rcx,[rsp]\n "
5682+ " rep movsl\n "
5683+ " pop rax\n "
5684+ " pop rax\n "
5685+ " pop rax\n "
5686+ " pop rdi\n "
5687+ " pop rsi\n "
5688+ " ret\n " );
5689+ }
5690+
5691+ ASSEMBLER_TEST_GENERATE (TestRepMovsQwords, assembler) {
5692+ __ pushq (RSI);
5693+ __ pushq (RDI);
5694+ __ pushq (CallingConventions::kArg1Reg ); // from.
5695+ __ pushq (CallingConventions::kArg2Reg ); // to.
5696+ __ pushq (CallingConventions::kArg3Reg ); // count.
5697+ __ movq (RSI, Address (RSP, 2 * target::kWordSize )); // from.
5698+ __ movq (RDI, Address (RSP, 1 * target::kWordSize )); // to.
5699+ __ movq (RCX, Address (RSP, 0 * target::kWordSize )); // count.
5700+ __ rep_movsq ();
5701+ // Remove saved arguments.
5702+ __ popq (RAX);
5703+ __ popq (RAX);
5704+ __ popq (RAX);
5705+ __ popq (RDI);
5706+ __ popq (RSI);
5707+ __ ret ();
5708+ }
5709+
5710+ ASSEMBLER_TEST_RUN (TestRepMovsQwords, test) {
5711+ const uint64_t from[11 ] = {
5712+ 0x0123456789ABCDEF , 0x123456789ABCDEF0 , 0x23456789ABCDEF01 ,
5713+ 0x3456789ABCDEF012 , 0x456789ABCDEF0123 , 0x56789ABCDEF01234 ,
5714+ 0x6789ABCDEF012345 , 0x789ABCDEF0123456 , 0x89ABCDEF01234567 ,
5715+ 0x9ABCDEF012345678 , 0xABCDEF0123456789 };
5716+ uint64_t * to = new uint64_t [11 ];
5717+ to[10 ] = 0xFEFEFEFEFEFEFEFE ;
5718+ typedef void (*TestRepMovsQwords)(const uint64_t * from, uint64_t * to,
5719+ int count);
5720+ reinterpret_cast <TestRepMovsQwords>(test->entry ())(from, to, 10 );
5721+ EXPECT_EQ (to[0 ], 0x0123456789ABCDEFu );
5722+ for (int i = 0 ; i < 10 ; i++) {
5723+ EXPECT_EQ (from[i], to[i]);
5724+ }
5725+ EXPECT_EQ (to[10 ], 0xFEFEFEFEFEFEFEFEu );
5726+ delete[] to;
5727+ EXPECT_DISASSEMBLY_NOT_WINDOWS (
5728+ " push rsi\n "
5729+ " push rdi\n "
5730+ " push rdi\n "
5731+ " push rsi\n "
5732+ " push rdx\n "
5733+ " movq rsi,[rsp+0x10]\n "
5734+ " movq rdi,[rsp+0x8]\n "
5735+ " movq rcx,[rsp]\n "
5736+ " rep movsq\n "
5737+ " pop rax\n "
5738+ " pop rax\n "
5739+ " pop rax\n "
5740+ " pop rdi\n "
5741+ " pop rsi\n "
5742+ " ret\n " );
5743+ }
5744+
55865745ASSEMBLER_TEST_GENERATE (ConditionalMovesCompare, assembler) {
55875746 __ cmpq (CallingConventions::kArg1Reg , CallingConventions::kArg2Reg );
55885747 __ movq (RDX, Immediate (1 )); // Greater equal.
0 commit comments