NullRegisterAllocator.java revision 2ad60cfc28e14ee8f0bb038720836a4696c478ad
1/*
2 * Copyright (C) 2007 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
17package com.android.dx.ssa.back;
18
19import com.android.dx.ssa.BasicRegisterMapper;
20import com.android.dx.ssa.RegisterMapper;
21import com.android.dx.ssa.SsaMethod;
22
23import java.util.BitSet;
24import java.util.ArrayList;
25
26/**
27 * A register allocator that maps SSA register n to Rop register 2*n,
28 * essentially preserving the original mapping and remaining agnostic
29 * about normal or wide categories. Used for debugging.
30 */
31public class NullRegisterAllocator extends RegisterAllocator {
32
33    /** {@inheritDoc} */
34    public NullRegisterAllocator(
35            final SsaMethod ssaMeth, final InterferenceGraph interference) {
36
37        super(ssaMeth, interference);
38    }
39
40    /** {@inheritDoc} */
41    @Override
42    public boolean wantsParamsMovedHigh() {
43        // We're not smart enough for this.
44        return false;
45    }
46
47    /** {@inheritDoc} */
48    @Override
49    public RegisterMapper allocateRegisters() {
50        int oldRegCount = ssaMeth.getRegCount();
51
52        BasicRegisterMapper mapper
53                = new BasicRegisterMapper(oldRegCount);
54
55        for (int i = 0; i < oldRegCount; i++) {
56            mapper.addMapping(i, i*2, 2);
57        }
58
59        return mapper;
60    }
61}
62