OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/opcodes.h" | 5 #include "src/compiler/opcodes.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace compiler { | 10 namespace compiler { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 case IrOpcode::k##Opcode: \ | 44 case IrOpcode::k##Opcode: \ |
45 return true; | 45 return true; |
46 JS_OP_LIST(OPCODE) | 46 JS_OP_LIST(OPCODE) |
47 #undef OPCODE | 47 #undef OPCODE |
48 default: | 48 default: |
49 return false; | 49 return false; |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 bool IsLeafOpcode(IrOpcode::Value opcode) { | 54 bool IsConstantOpcode(IrOpcode::Value opcode) { |
55 switch (opcode) { | 55 switch (opcode) { |
56 #define OPCODE(Opcode) \ | 56 #define OPCODE(Opcode) \ |
57 case IrOpcode::k##Opcode: \ | 57 case IrOpcode::k##Opcode: \ |
58 return true; | 58 return true; |
59 LEAF_OP_LIST(OPCODE) | 59 CONSTANT_OP_LIST(OPCODE) |
60 #undef OPCODE | 60 #undef OPCODE |
61 default: | 61 default: |
62 return false; | 62 return false; |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 | 66 |
67 const IrOpcode::Value kInvalidOpcode = static_cast<IrOpcode::Value>(123456789); | 67 const IrOpcode::Value kInvalidOpcode = static_cast<IrOpcode::Value>(123456789); |
68 | 68 |
69 } // namespace | 69 } // namespace |
(...skipping 22 matching lines...) Expand all Loading... |
92 TEST(IrOpcodeTest, IsJsOpcode) { | 92 TEST(IrOpcodeTest, IsJsOpcode) { |
93 EXPECT_FALSE(IrOpcode::IsJsOpcode(kInvalidOpcode)); | 93 EXPECT_FALSE(IrOpcode::IsJsOpcode(kInvalidOpcode)); |
94 #define OPCODE(Opcode) \ | 94 #define OPCODE(Opcode) \ |
95 EXPECT_EQ(IsJsOpcode(IrOpcode::k##Opcode), \ | 95 EXPECT_EQ(IsJsOpcode(IrOpcode::k##Opcode), \ |
96 IrOpcode::IsJsOpcode(IrOpcode::k##Opcode)); | 96 IrOpcode::IsJsOpcode(IrOpcode::k##Opcode)); |
97 ALL_OP_LIST(OPCODE) | 97 ALL_OP_LIST(OPCODE) |
98 #undef OPCODE | 98 #undef OPCODE |
99 } | 99 } |
100 | 100 |
101 | 101 |
102 TEST(IrOpcodeTest, IsLeafOpcode) { | 102 TEST(IrOpcodeTest, IsConstantOpcode) { |
103 EXPECT_FALSE(IrOpcode::IsLeafOpcode(kInvalidOpcode)); | 103 EXPECT_FALSE(IrOpcode::IsConstantOpcode(kInvalidOpcode)); |
104 #define OPCODE(Opcode) \ | 104 #define OPCODE(Opcode) \ |
105 EXPECT_EQ(IsLeafOpcode(IrOpcode::k##Opcode), \ | 105 EXPECT_EQ(IsConstantOpcode(IrOpcode::k##Opcode), \ |
106 IrOpcode::IsLeafOpcode(IrOpcode::k##Opcode)); | 106 IrOpcode::IsConstantOpcode(IrOpcode::k##Opcode)); |
107 ALL_OP_LIST(OPCODE) | 107 ALL_OP_LIST(OPCODE) |
108 #undef OPCODE | 108 #undef OPCODE |
109 } | 109 } |
110 | 110 |
111 | 111 |
112 TEST(IrOpcodeTest, Mnemonic) { | 112 TEST(IrOpcodeTest, Mnemonic) { |
113 EXPECT_STREQ("UnknownOpcode", IrOpcode::Mnemonic(kInvalidOpcode)); | 113 EXPECT_STREQ("UnknownOpcode", IrOpcode::Mnemonic(kInvalidOpcode)); |
114 #define OPCODE(Opcode) \ | 114 #define OPCODE(Opcode) \ |
115 EXPECT_STREQ(#Opcode, IrOpcode::Mnemonic(IrOpcode::k##Opcode)); | 115 EXPECT_STREQ(#Opcode, IrOpcode::Mnemonic(IrOpcode::k##Opcode)); |
116 ALL_OP_LIST(OPCODE) | 116 ALL_OP_LIST(OPCODE) |
117 #undef OPCODE | 117 #undef OPCODE |
118 } | 118 } |
119 | 119 |
120 } // namespace compiler | 120 } // namespace compiler |
121 } // namespace internal | 121 } // namespace internal |
122 } // namespace v8 | 122 } // namespace v8 |
OLD | NEW |