001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Eclipse Public License (EPL);
005 * You may not use this file except in compliance with the License. You
006 * may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.jikesrvm.compilers.opt.regalloc;
014
015 import org.jikesrvm.compilers.opt.ir.IR;
016 import org.jikesrvm.compilers.opt.ir.Register;
017
018 /**
019 * This class helps manage register preferences for coalescing and
020 * register allocation.
021 */
022 public abstract class GenericRegisterPreferences {
023 /**
024 * The main backing data structure;
025 */
026 private final CoalesceGraph graph = new CoalesceGraph();
027
028 /**
029 * Add a affinity of weight w between two registers.
030 */
031 protected void addAffinity(int w, Register r1, Register r2) {
032 graph.addAffinity(w, r1, r2);
033 }
034
035 /**
036 * Set up register preferences for an IR. This is machine-dependent.
037 */
038 public abstract void initialize(IR ir);
039
040 /**
041 * Return the backing graph holding the preferences.
042 */
043 public CoalesceGraph getGraph() {
044 return graph;
045 }
046 }