OLD | NEW |
---|---|
1 //===- unittest/IceParseInstsTest.cpp - test instruction errors -----------===// | 1 //===- unittest/IceParseInstsTest.cpp - test instruction errors -----------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 EXPECT_FALSE(Munger.runTest(ARRAY(Align30), ParseError)); | 394 EXPECT_FALSE(Munger.runTest(ARRAY(Align30), ParseError)); |
395 EXPECT_EQ("Error(62:4): Invalid function record: <24 2 1 31>\n", | 395 EXPECT_EQ("Error(62:4): Invalid function record: <24 2 1 31>\n", |
396 Munger.getTestResults()); | 396 Munger.getTestResults()); |
397 EXPECT_FALSE(DumpMunger.runTestForAssembly(ARRAY(Align30))); | 397 EXPECT_FALSE(DumpMunger.runTestForAssembly(ARRAY(Align30))); |
398 EXPECT_EQ( | 398 EXPECT_EQ( |
399 " store float %p1, float* %p0, align 0;\n" | 399 " store float %p1, float* %p0, align 0;\n" |
400 "Error(62:4): store: Illegal alignment for float. Expects: 1 or 4\n", | 400 "Error(62:4): store: Illegal alignment for float. Expects: 1 or 4\n", |
401 DumpMunger.getLinesWithSubstring("store")); | 401 DumpMunger.getLinesWithSubstring("store")); |
402 } | 402 } |
403 | 403 |
404 // Test that we handle the optional FLAGs argument to binary instructions. | |
Jim Stichnoth
2016/03/24 17:46:32
Would it be possible to (in addition or instead) h
Karl
2016/03/24 19:28:36
Replacing with tbc test.
| |
405 TEST(IceParseInstsTest, IgnoredBinopFlags) { | |
406 const uint64_t BitcodeRecords[] = { | |
407 naclbitc::ENTER_SUBBLOCK, naclbitc::BLK_CODE_ENTER, | |
408 naclbitc::MODULE_BLOCK_ID, 2, Terminator, | |
409 naclbitc::ENTER_SUBBLOCK, naclbitc::BLK_CODE_ENTER, | |
410 naclbitc::TYPE_BLOCK_ID_NEW, 2, Terminator, | |
411 naclbitc::UNABBREV_RECORD, naclbitc::TYPE_CODE_NUMENTRY, 3, Terminator, | |
412 naclbitc::UNABBREV_RECORD, naclbitc::TYPE_CODE_INTEGER, 32, Terminator, | |
413 naclbitc::UNABBREV_RECORD, naclbitc::TYPE_CODE_FUNCTION, | |
414 0, 0, 0, 0, Terminator, | |
415 naclbitc::UNABBREV_RECORD, naclbitc::TYPE_CODE_VOID, Terminator, | |
416 naclbitc::END_BLOCK, naclbitc::BLK_CODE_EXIT, Terminator, | |
417 naclbitc::UNABBREV_RECORD, naclbitc::MODULE_CODE_FUNCTION, | |
418 1, 0, 0, 3, Terminator, | |
419 naclbitc::ENTER_SUBBLOCK, naclbitc::BLK_CODE_ENTER, | |
420 naclbitc::FUNCTION_BLOCK_ID, 2, Terminator, | |
421 naclbitc::UNABBREV_RECORD, naclbitc::FUNC_CODE_DECLAREBLOCKS, 1, Terminator, | |
422 naclbitc::UNABBREV_RECORD, naclbitc::FUNC_CODE_INST_BINOP, | |
423 2, 1, 0, Terminator, | |
424 naclbitc::UNABBREV_RECORD, naclbitc::FUNC_CODE_INST_RET, 1, Terminator, | |
425 naclbitc::END_BLOCK, naclbitc::BLK_CODE_EXIT, Terminator, | |
426 naclbitc::END_BLOCK, naclbitc::BLK_CODE_EXIT, Terminator | |
427 }; | |
428 | |
429 // Show bitcode objdump for BitcodeRecorsd. | |
Jim Stichnoth
2016/03/24 17:46:32
BitcodeRecords
Karl
2016/03/24 19:28:36
Ignoring, replacing with tbc test
| |
430 NaClObjDumpMunger DumpMunger(ARRAY_TERM(BitcodeRecords)); | |
431 EXPECT_TRUE(DumpMunger.runTestForAssembly()); | |
432 EXPECT_EQ( | |
433 "module { // BlockID = 8\n" | |
434 " types { // BlockID = 17\n" | |
435 " count 3;\n" | |
436 " @t0 = i32;\n" | |
437 " @t1 = i32 (i32, i32);\n" | |
438 " @t2 = void;\n" | |
439 " }\n" | |
440 " define internal i32 @f0(i32, i32);\n" | |
441 " function i32 @f0(i32 %p0, i32 %p1) { // BlockID = 12\n" | |
442 " blocks 1;\n" | |
443 " %b0:\n" | |
444 " %v0 = add i32 %p0, %p1;\n" | |
445 " ret i32 %v0;\n" | |
446 " }\n" | |
447 "}\n", | |
448 DumpMunger.getTestResults()); | |
449 | |
450 // Show that Subzero parses the input. | |
451 IceTest::SubzeroBitcodeMunger Munger(ARRAY_TERM(BitcodeRecords)); | |
452 EXPECT_TRUE(Munger.runTest()); | |
453 | |
454 // Show that adding a 4th "flags" field to the BINOP instruction is | |
455 // accepted. | |
456 const uint64_t ReplaceIndex = 10; | |
Jim Stichnoth
2016/03/24 17:46:32
These could be constexpr instead of const... but t
Karl
2016/03/24 19:28:36
Ignoring, replacing with tbc test.
| |
457 const uint64_t FLAGS = 5981; // Value ignored. | |
458 const uint64_t Edit[] = { | |
459 ReplaceIndex, NaClMungedBitcode::Replace, | |
460 naclbitc::UNABBREV_RECORD, naclbitc::FUNC_CODE_INST_BINOP, | |
461 2, 1, 0, FLAGS, Terminator | |
462 }; | |
463 EXPECT_TRUE(Munger.runTest(ARRAY(Edit))); | |
464 } | |
465 | |
404 } // end of anonymous namespace | 466 } // end of anonymous namespace |
OLD | NEW |