register_zero.hpp revision 1010:354d3184f6b2
1/* 2 * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. 3 * Copyright 2007 Red Hat, Inc. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 21 * CA 95054 USA or visit www.sun.com if you need additional information or 22 * have any questions. 23 * 24 */ 25 26class VMRegImpl; 27typedef VMRegImpl* VMReg; 28 29// Use Register as shortcut 30class RegisterImpl; 31typedef RegisterImpl* Register; 32 33inline Register as_Register(int encoding) { 34 return (Register)(intptr_t) encoding; 35} 36 37// The implementation of integer registers for the zero architecture 38class RegisterImpl : public AbstractRegisterImpl { 39 public: 40 enum { 41 number_of_registers = 0 42 }; 43 44 // construction 45 inline friend Register as_Register(int encoding); 46 VMReg as_VMReg(); 47 48 // derived registers, offsets, and addresses 49 Register successor() const { 50 return as_Register(encoding() + 1); 51 } 52 53 // accessors 54 int encoding() const { 55 assert(is_valid(), "invalid register"); 56 return (intptr_t)this; 57 } 58 bool is_valid() const { 59 return 0 <= (intptr_t) this && (intptr_t)this < number_of_registers; 60 } 61 const char* name() const; 62}; 63 64// Use FloatRegister as shortcut 65class FloatRegisterImpl; 66typedef FloatRegisterImpl* FloatRegister; 67 68inline FloatRegister as_FloatRegister(int encoding) { 69 return (FloatRegister)(intptr_t) encoding; 70} 71 72// The implementation of floating point registers for the zero architecture 73class FloatRegisterImpl : public AbstractRegisterImpl { 74 public: 75 enum { 76 number_of_registers = 0 77 }; 78 79 // construction 80 inline friend FloatRegister as_FloatRegister(int encoding); 81 VMReg as_VMReg(); 82 83 // derived registers, offsets, and addresses 84 FloatRegister successor() const { 85 return as_FloatRegister(encoding() + 1); 86 } 87 88 // accessors 89 int encoding() const { 90 assert(is_valid(), "invalid register"); 91 return (intptr_t)this; 92 } 93 bool is_valid() const { 94 return 0 <= (intptr_t) this && (intptr_t)this < number_of_registers; 95 } 96 const char* name() const; 97}; 98 99class ConcreteRegisterImpl : public AbstractRegisterImpl { 100 public: 101 enum { 102 number_of_registers = RegisterImpl::number_of_registers + 103 FloatRegisterImpl::number_of_registers 104 }; 105 106 static const int max_gpr; 107 static const int max_fpr; 108}; 109 110CONSTANT_REGISTER_DECLARATION(Register, noreg, (-1)); 111