1 /*
   2  * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot.asm.x86;
  26 
  27 import sun.jvm.hotspot.utilities.*;
  28 
  29 /* 8 64-bit registers called MMX registers*/
  30 
  31 public class X86MMXRegisters {
  32 
  33    public static final int NUM_MMX_REGISTERS = 8;
  34 
  35    public static final X86MMXRegister MM0;
  36    public static final X86MMXRegister MM1;
  37    public static final X86MMXRegister MM2;
  38    public static final X86MMXRegister MM3;
  39    public static final X86MMXRegister MM4;
  40    public static final X86MMXRegister MM5;
  41    public static final X86MMXRegister MM6;
  42    public static final X86MMXRegister MM7;
  43 
  44    private static X86MMXRegister mmxRegisters[];
  45 
  46    static {
  47       //MMX registers
  48       MM0 = new X86MMXRegister(0, "%mm0");
  49       MM1 = new X86MMXRegister(1, "%mm1");
  50       MM2 = new X86MMXRegister(2, "%mm2");
  51       MM3 = new X86MMXRegister(3, "%mm3");
  52       MM4 = new X86MMXRegister(4, "%mm4");
  53       MM5 = new X86MMXRegister(5, "%mm5");
  54       MM6 = new X86MMXRegister(6, "%mm6");
  55       MM7 = new X86MMXRegister(7, "%mm7");
  56 
  57       mmxRegisters = (new X86MMXRegister[] {
  58             MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7
  59       });
  60    }
  61 
  62    public static int getNumberOfRegisters() {
  63       return NUM_MMX_REGISTERS;
  64    }
  65 
  66    //Return the register name
  67    public static String getRegisterName(int regNum) {
  68       if (Assert.ASSERTS_ENABLED) {
  69          Assert.that(regNum > -1 && regNum < NUM_MMX_REGISTERS, "invalid MMX register number!");
  70       }
  71       return mmxRegisters[regNum].toString();
  72    }
  73 
  74    public static X86MMXRegister getRegister(int regNum) {
  75       if (Assert.ASSERTS_ENABLED) {
  76          Assert.that(regNum > -1 && regNum < NUM_MMX_REGISTERS, "invalid MMX register number!");
  77       }
  78      return mmxRegisters[regNum];
  79    }
  80 }