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 */
013package org.jikesrvm.compilers.opt.ir.ia32;
014
015import org.jikesrvm.VM;
016import org.jikesrvm.classloader.RVMMethod;
017import org.jikesrvm.compilers.opt.ir.GenericRegisterPool;
018import org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand;
019import org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand;
020import org.jikesrvm.compilers.opt.ir.operand.Operand;
021import org.jikesrvm.runtime.Magic;
022import org.vmmagic.unboxed.Address;
023
024/**
025 * Pool of symbolic registers.<p>
026 *
027 * Intel specific implementation where JTOC is stored in the processor object
028 * and accessed through the processor register.
029 *
030 * @see org.jikesrvm.compilers.opt.ir.Register
031 */
032public final class RegisterPool extends GenericRegisterPool {
033
034  /**
035   * Initializes a new register pool for the method meth.
036   *
037   * @param meth the RVMMethod of the outermost method
038   */
039  public RegisterPool(RVMMethod meth) {
040    super(meth);
041  }
042
043  /**
044   * Return a constant operand that is the base address of the JTOC.
045   * <p>
046   * TODO: This really should be returning an AddressConstantOperand,
047   *       but that causes rippling changes in BURS that are larger
048   *       than we want to deal with right now.
049   *
050   * @return an operand that holds the JTOC
051   */
052  @Override
053  public Operand makeJTOCOp() {
054    Address jtoc = Magic.getTocPointer();
055    return VM.BuildFor32Addr ? new IntConstantOperand(jtoc.toInt()) :
056      new LongConstantOperand(jtoc.toLong());
057  }
058
059  @Override
060  public Operand makeTocOp() {
061    return makeJTOCOp();
062  }
063}