13ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray/* 23ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * Copyright (C) 2014 The Android Open Source Project 33ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * 43ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * Licensed under the Apache License, Version 2.0 (the "License"); 53ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * you may not use this file except in compliance with the License. 63ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * You may obtain a copy of the License at 73ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * 83ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * http://www.apache.org/licenses/LICENSE-2.0 93ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * 103ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * Unless required by applicable law or agreed to in writing, software 113ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * distributed under the License is distributed on an "AS IS" BASIS, 123ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * See the License for the specific language governing permissions and 143ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray * limitations under the License. 153ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray */ 163ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray 173ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray#ifndef ART_COMPILER_OPTIMIZING_OPTIMIZING_UNIT_TEST_H_ 183ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray#define ART_COMPILER_OPTIMIZING_OPTIMIZING_UNIT_TEST_H_ 193ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray 20a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray#include "ssa_liveness_analysis.h" 21a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray 22a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffraynamespace art { 23a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray 243ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray#define NUM_INSTRUCTIONS(...) \ 253ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray (sizeof((uint16_t[]) {__VA_ARGS__}) /sizeof(uint16_t)) 263ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray 273ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray#define ZERO_REGISTER_CODE_ITEM(...) \ 283ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray { 0, 0, 0, 0, 0, 0, NUM_INSTRUCTIONS(__VA_ARGS__), 0, __VA_ARGS__ } 293ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray 303ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray#define ONE_REGISTER_CODE_ITEM(...) \ 313ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray { 1, 0, 0, 0, 0, 0, NUM_INSTRUCTIONS(__VA_ARGS__), 0, __VA_ARGS__ } 323ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray 33bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray#define TWO_REGISTERS_CODE_ITEM(...) \ 34bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray { 2, 0, 0, 0, 0, 0, NUM_INSTRUCTIONS(__VA_ARGS__), 0, __VA_ARGS__ } 35bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray 36a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray#define THREE_REGISTERS_CODE_ITEM(...) \ 37a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray { 3, 0, 0, 0, 0, 0, NUM_INSTRUCTIONS(__VA_ARGS__), 0, __VA_ARGS__ } 38a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray 39a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas GeoffrayLiveInterval* BuildInterval(const size_t ranges[][2], 40a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray size_t number_of_ranges, 41a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray ArenaAllocator* allocator, 42a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray int reg = -1) { 43a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray LiveInterval* interval = new (allocator) LiveInterval(allocator, Primitive::kPrimInt); 44a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray for (size_t i = number_of_ranges; i > 0; --i) { 45a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray interval->AddRange(ranges[i - 1][0], ranges[i - 1][1]); 46a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray } 47a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray interval->SetRegister(reg); 48a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray return interval; 49a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray} 50a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray 51a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray} // namespace art 52a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray 533ff386aafefd5282bb76c8a50506a70a4321e698Nicolas Geoffray#endif // ART_COMPILER_OPTIMIZING_OPTIMIZING_UNIT_TEST_H_ 54