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.ir.ia32;
014    
015    import org.jikesrvm.classloader.RVMMethod;
016    import org.jikesrvm.compilers.opt.ir.GenericRegisterPool;
017    import org.jikesrvm.compilers.opt.ir.IR;
018    import org.jikesrvm.compilers.opt.ir.Instruction;
019    import org.jikesrvm.compilers.opt.ir.Operators;
020    import org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand;
021    import org.jikesrvm.compilers.opt.ir.operand.Operand;
022    import org.jikesrvm.runtime.Magic;
023    import org.vmmagic.unboxed.Address;
024    
025    /**
026     * Pool of symbolic registers.
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     */
032    public abstract class RegisterPool extends GenericRegisterPool implements Operators {
033    
034      /**
035       * Initializes a new register pool for the method meth.
036       *
037       * @param meth the RVMMethod of the outermost method
038       */
039      protected RegisterPool(RVMMethod meth) {
040        super(meth);
041      }
042    
043      /**
044       * Return a constant operand that is the base address of the JTOC.
045       * TODO: This really should be returning an AddressConstantOperand,
046       *       but that causes rippling changes in BURS that are larger
047       *       than I want to deal with right now. --dave 12/20/2005.
048       *
049       * @param  ir  the containing IR
050       * @param s    the instruction to insert the load operand before
051       * @return a register operand that holds the JTOC
052       */
053      public Operand makeJTOCOp(IR ir, Instruction s) {
054        Address jtoc = Magic.getTocPointer();
055        return new IntConstantOperand(jtoc.toInt());
056      }
057    }