Nicolas Geoffray | 818f210 | 2014-02-18 16:43:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 17 | #include "pretty_printer.h" |
| 18 | |
Mathieu Chartier | b666f48 | 2015-02-18 14:33:14 -0800 | [diff] [blame] | 19 | #include "base/arena_allocator.h" |
Nicolas Geoffray | 818f210 | 2014-02-18 16:43:35 +0000 | [diff] [blame] | 20 | #include "builder.h" |
David Sehr | 9e734c7 | 2018-01-04 17:56:19 -0800 | [diff] [blame] | 21 | #include "dex/dex_file.h" |
| 22 | #include "dex/dex_instruction.h" |
Nicolas Geoffray | 818f210 | 2014-02-18 16:43:35 +0000 | [diff] [blame] | 23 | #include "nodes.h" |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 24 | #include "optimizing_unit_test.h" |
Nicolas Geoffray | 818f210 | 2014-02-18 16:43:35 +0000 | [diff] [blame] | 25 | |
| 26 | #include "gtest/gtest.h" |
| 27 | |
Vladimir Marko | 0a51605 | 2019-10-14 13:00:44 +0000 | [diff] [blame] | 28 | namespace art { |
Nicolas Geoffray | 818f210 | 2014-02-18 16:43:35 +0000 | [diff] [blame] | 29 | |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 30 | class PrettyPrinterTest : public OptimizingUnitTest { |
| 31 | protected: |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 32 | void TestCode(const std::vector<uint16_t>& data, const char* expected); |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 33 | }; |
| 34 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 35 | void PrettyPrinterTest::TestCode(const std::vector<uint16_t>& data, const char* expected) { |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 36 | HGraph* graph = CreateCFG(data); |
Nicolas Geoffray | 818f210 | 2014-02-18 16:43:35 +0000 | [diff] [blame] | 37 | StringPrettyPrinter printer(graph); |
| 38 | printer.VisitInsertionOrder(); |
| 39 | ASSERT_STREQ(expected, printer.str().c_str()); |
Nicolas Geoffray | 818f210 | 2014-02-18 16:43:35 +0000 | [diff] [blame] | 40 | } |
| 41 | |
David Brazdil | badd826 | 2016-02-02 16:28:56 +0000 | [diff] [blame] | 42 | TEST_F(PrettyPrinterTest, ReturnVoid) { |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 43 | const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM( |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 44 | Instruction::RETURN_VOID); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 45 | |
| 46 | const char* expected = |
| 47 | "BasicBlock 0, succ: 1\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 48 | " 0: SuspendCheck\n" |
| 49 | " 1: Goto 1\n" |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 50 | "BasicBlock 1, pred: 0, succ: 2\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 51 | " 2: ReturnVoid\n" |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 52 | "BasicBlock 2, pred: 1\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 53 | " 3: Exit\n"; |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 54 | |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 55 | TestCode(data, expected); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 56 | } |
| 57 | |
David Brazdil | badd826 | 2016-02-02 16:28:56 +0000 | [diff] [blame] | 58 | TEST_F(PrettyPrinterTest, CFG1) { |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 59 | const char* expected = |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 60 | "BasicBlock 0, succ: 1\n" |
| 61 | " 0: SuspendCheck\n" |
| 62 | " 1: Goto 1\n" |
| 63 | "BasicBlock 1, pred: 0, succ: 2\n" |
| 64 | " 2: Goto 2\n" |
| 65 | "BasicBlock 2, pred: 1, succ: 3\n" |
| 66 | " 3: ReturnVoid\n" |
| 67 | "BasicBlock 3, pred: 2\n" |
| 68 | " 4: Exit\n"; |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 69 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 70 | const std::vector<uint16_t> data = |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 71 | ZERO_REGISTER_CODE_ITEM( |
| 72 | Instruction::GOTO | 0x100, |
| 73 | Instruction::RETURN_VOID); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 74 | |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 75 | TestCode(data, expected); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 76 | } |
| 77 | |
David Brazdil | badd826 | 2016-02-02 16:28:56 +0000 | [diff] [blame] | 78 | TEST_F(PrettyPrinterTest, CFG2) { |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 79 | const char* expected = |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 80 | "BasicBlock 0, succ: 1\n" |
| 81 | " 0: SuspendCheck\n" |
| 82 | " 1: Goto 1\n" |
| 83 | "BasicBlock 1, pred: 0, succ: 2\n" |
| 84 | " 2: Goto 2\n" |
| 85 | "BasicBlock 2, pred: 1, succ: 3\n" |
| 86 | " 3: Goto 3\n" |
| 87 | "BasicBlock 3, pred: 2, succ: 4\n" |
| 88 | " 4: ReturnVoid\n" |
| 89 | "BasicBlock 4, pred: 3\n" |
| 90 | " 5: Exit\n"; |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 91 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 92 | const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM( |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 93 | Instruction::GOTO | 0x100, |
| 94 | Instruction::GOTO | 0x100, |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 95 | Instruction::RETURN_VOID); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 96 | |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 97 | TestCode(data, expected); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 98 | } |
| 99 | |
David Brazdil | badd826 | 2016-02-02 16:28:56 +0000 | [diff] [blame] | 100 | TEST_F(PrettyPrinterTest, CFG3) { |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 101 | const char* expected = |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 102 | "BasicBlock 0, succ: 1\n" |
| 103 | " 0: SuspendCheck\n" |
| 104 | " 1: Goto 1\n" |
| 105 | "BasicBlock 1, pred: 0, succ: 3\n" |
| 106 | " 2: Goto 3\n" |
| 107 | "BasicBlock 2, pred: 3, succ: 4\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 108 | " 4: ReturnVoid\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 109 | "BasicBlock 3, pred: 1, succ: 2\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 110 | " 3: Goto 2\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 111 | "BasicBlock 4, pred: 2\n" |
| 112 | " 5: Exit\n"; |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 113 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 114 | const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM( |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 115 | Instruction::GOTO | 0x200, |
| 116 | Instruction::RETURN_VOID, |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 117 | Instruction::GOTO | 0xFF00); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 118 | |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 119 | TestCode(data1, expected); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 120 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 121 | const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM( |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 122 | Instruction::GOTO_16, 3, |
| 123 | Instruction::RETURN_VOID, |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 124 | Instruction::GOTO_16, 0xFFFF); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 125 | |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 126 | TestCode(data2, expected); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 127 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 128 | const std::vector<uint16_t> data3 = ZERO_REGISTER_CODE_ITEM( |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 129 | Instruction::GOTO_32, 4, 0, |
| 130 | Instruction::RETURN_VOID, |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 131 | Instruction::GOTO_32, 0xFFFF, 0xFFFF); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 132 | |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 133 | TestCode(data3, expected); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 134 | } |
| 135 | |
David Brazdil | badd826 | 2016-02-02 16:28:56 +0000 | [diff] [blame] | 136 | TEST_F(PrettyPrinterTest, CFG4) { |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 137 | const char* expected = |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 138 | "BasicBlock 0, succ: 3\n" |
David Brazdil | 6032891 | 2016-04-04 17:47:42 +0000 | [diff] [blame] | 139 | " 1: SuspendCheck\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 140 | " 2: Goto 3\n" |
| 141 | "BasicBlock 1, pred: 3, 1, succ: 1\n" |
| 142 | " 3: SuspendCheck\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 143 | " 4: Goto 1\n" |
| 144 | "BasicBlock 3, pred: 0, succ: 1\n" |
| 145 | " 0: Goto 1\n"; |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 146 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 147 | const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM( |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 148 | Instruction::NOP, |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 149 | Instruction::GOTO | 0xFF00); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 150 | |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 151 | TestCode(data1, expected); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 152 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 153 | const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM( |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 154 | Instruction::GOTO_32, 0, 0); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 155 | |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 156 | TestCode(data2, expected); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 157 | } |
| 158 | |
David Brazdil | badd826 | 2016-02-02 16:28:56 +0000 | [diff] [blame] | 159 | TEST_F(PrettyPrinterTest, CFG5) { |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 160 | const char* expected = |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 161 | "BasicBlock 0, succ: 1\n" |
| 162 | " 0: SuspendCheck\n" |
| 163 | " 1: Goto 1\n" |
| 164 | "BasicBlock 1, pred: 0, succ: 3\n" |
| 165 | " 2: ReturnVoid\n" |
| 166 | "BasicBlock 3, pred: 1\n" |
| 167 | " 3: Exit\n"; |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 168 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 169 | const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM( |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 170 | Instruction::RETURN_VOID, |
| 171 | Instruction::GOTO | 0x100, |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 172 | Instruction::GOTO | 0xFE00); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 173 | |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 174 | TestCode(data, expected); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 175 | } |
| 176 | |
David Brazdil | badd826 | 2016-02-02 16:28:56 +0000 | [diff] [blame] | 177 | TEST_F(PrettyPrinterTest, CFG6) { |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 178 | const char* expected = |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 179 | "BasicBlock 0, succ: 1\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 180 | " 3: IntConstant [4, 4]\n" |
| 181 | " 1: SuspendCheck\n" |
| 182 | " 2: Goto 1\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 183 | "BasicBlock 1, pred: 0, succ: 5, 2\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 184 | " 4: Equal(3, 3) [5]\n" |
| 185 | " 5: If(4)\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 186 | "BasicBlock 2, pred: 1, succ: 3\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 187 | " 6: Goto 3\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 188 | "BasicBlock 3, pred: 5, 2, succ: 4\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 189 | " 7: ReturnVoid\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 190 | "BasicBlock 4, pred: 3\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 191 | " 8: Exit\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 192 | "BasicBlock 5, pred: 1, succ: 3\n" |
| 193 | " 0: Goto 3\n"; |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 194 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 195 | const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM( |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 196 | Instruction::CONST_4 | 0 | 0, |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 197 | Instruction::IF_EQ, 3, |
| 198 | Instruction::GOTO | 0x100, |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 199 | Instruction::RETURN_VOID); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 200 | |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 201 | TestCode(data, expected); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 202 | } |
| 203 | |
David Brazdil | badd826 | 2016-02-02 16:28:56 +0000 | [diff] [blame] | 204 | TEST_F(PrettyPrinterTest, CFG7) { |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 205 | const char* expected = |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 206 | "BasicBlock 0, succ: 1\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 207 | " 4: IntConstant [5, 5]\n" |
David Brazdil | 6032891 | 2016-04-04 17:47:42 +0000 | [diff] [blame] | 208 | " 2: SuspendCheck\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 209 | " 3: Goto 1\n" |
| 210 | "BasicBlock 1, pred: 0, succ: 5, 6\n" |
| 211 | " 5: Equal(4, 4) [6]\n" |
| 212 | " 6: If(5)\n" |
| 213 | "BasicBlock 2, pred: 6, 3, succ: 3\n" |
| 214 | " 11: Goto 3\n" |
| 215 | "BasicBlock 3, pred: 5, 2, succ: 2\n" |
| 216 | " 8: SuspendCheck\n" |
| 217 | " 9: Goto 2\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 218 | "BasicBlock 5, pred: 1, succ: 3\n" |
| 219 | " 0: Goto 3\n" |
| 220 | "BasicBlock 6, pred: 1, succ: 2\n" |
| 221 | " 1: Goto 2\n"; |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 222 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 223 | const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM( |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 224 | Instruction::CONST_4 | 0 | 0, |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 225 | Instruction::IF_EQ, 3, |
| 226 | Instruction::GOTO | 0x100, |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 227 | Instruction::GOTO | 0xFF00); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 228 | |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 229 | TestCode(data, expected); |
| 230 | } |
| 231 | |
David Brazdil | badd826 | 2016-02-02 16:28:56 +0000 | [diff] [blame] | 232 | TEST_F(PrettyPrinterTest, IntConstant) { |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 233 | const char* expected = |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 234 | "BasicBlock 0, succ: 1\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 235 | " 2: IntConstant\n" |
| 236 | " 0: SuspendCheck\n" |
| 237 | " 1: Goto 1\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 238 | "BasicBlock 1, pred: 0, succ: 2\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 239 | " 3: ReturnVoid\n" |
David Brazdil | 86ea7ee | 2016-02-16 09:26:07 +0000 | [diff] [blame] | 240 | "BasicBlock 2, pred: 1\n" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 241 | " 4: Exit\n"; |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 242 | |
Mathieu Chartier | fa3db3d | 2018-01-12 14:42:18 -0800 | [diff] [blame] | 243 | const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM( |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 244 | Instruction::CONST_4 | 0 | 0, |
| 245 | Instruction::RETURN_VOID); |
| 246 | |
| 247 | TestCode(data, expected); |
Nicolas Geoffray | be9a92a | 2014-02-25 14:22:56 +0000 | [diff] [blame] | 248 | } |
Nicolas Geoffray | 818f210 | 2014-02-18 16:43:35 +0000 | [diff] [blame] | 249 | } // namespace art |