blob: 6a610ab201b69ee6efa70791832b5c61206572b4 [file] [log] [blame]
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -08001/*
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
17#include "bb_optimizations.h"
18#include "dataflow_iterator.h"
19#include "dataflow_iterator-inl.h"
20
21namespace art {
22
23/*
24 * Code Layout pass implementation start.
25 */
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070026bool CodeLayout::Worker(PassDataHolder* data) const {
James C Scott4f596682014-05-01 05:52:04 -070027 DCHECK(data != nullptr);
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070028 PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data);
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070029 CompilationUnit* c_unit = pass_me_data_holder->c_unit;
30 DCHECK(c_unit != nullptr);
James C Scott4f596682014-05-01 05:52:04 -070031 BasicBlock* bb = pass_me_data_holder->bb;
32 DCHECK(bb != nullptr);
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070033 c_unit->mir_graph->LayoutBlocks(bb);
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080034 // No need of repeating, so just return false.
35 return false;
36}
37
38/*
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080039 * BasicBlock Combine pass implementation start.
40 */
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070041bool BBCombine::Worker(PassDataHolder* data) const {
James C Scott4f596682014-05-01 05:52:04 -070042 DCHECK(data != nullptr);
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070043 PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data);
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070044 CompilationUnit* c_unit = pass_me_data_holder->c_unit;
45 DCHECK(c_unit != nullptr);
James C Scott4f596682014-05-01 05:52:04 -070046 BasicBlock* bb = pass_me_data_holder->bb;
47 DCHECK(bb != nullptr);
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070048 c_unit->mir_graph->CombineBlocks(bb);
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080049
50 // No need of repeating, so just return false.
51 return false;
52}
53
54/*
55 * BasicBlock Optimization pass implementation start.
56 */
Jean Christophe Beylere1f65bc2014-06-09 10:18:26 -070057void BBOptimizations::Start(PassDataHolder* data) const {
James C Scott4f596682014-05-01 05:52:04 -070058 DCHECK(data != nullptr);
Jean Christophe Beylere1f65bc2014-06-09 10:18:26 -070059 CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit;
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070060 DCHECK(c_unit != nullptr);
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080061 /*
62 * This pass has a different ordering depEnding on the suppress exception,
63 * so do the pass here for now:
64 * - Later, the Start should just change the ordering and we can move the extended
65 * creation into the pass driver's main job with a new iterator
66 */
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070067 c_unit->mir_graph->BasicBlockOptimization();
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080068}
69
70} // namespace art