1 /*
   2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef CPU_ZERO_REGISTER_ZERO_HPP
  27 #define CPU_ZERO_REGISTER_ZERO_HPP
  28 
  29 #include "asm/register.hpp"
  30 #include "runtime/vm_version.hpp"
  31 
  32 class VMRegImpl;
  33 typedef VMRegImpl* VMReg;
  34 
  35 // Use Register as shortcut
  36 class RegisterImpl;
  37 typedef RegisterImpl* Register;
  38 
  39 inline Register as_Register(int encoding) {
  40   return (Register)(intptr_t) encoding;
  41 }
  42 
  43 // The implementation of integer registers for the zero architecture
  44 class RegisterImpl : public AbstractRegisterImpl {
  45  public:
  46   enum {
  47     number_of_registers = 0
  48   };
  49 
  50   // construction
  51   inline friend Register as_Register(int encoding);
  52   VMReg as_VMReg();
  53 
  54   // derived registers, offsets, and addresses
  55   Register successor() const {
  56     return as_Register(encoding() + 1);
  57   }
  58 
  59   // accessors
  60   int encoding() const {
  61     assert(is_valid(), "invalid register");
  62     return (intptr_t)this;
  63   }
  64   bool is_valid() const {
  65     return 0 <= (intptr_t) this && (intptr_t)this < number_of_registers;
  66   }
  67   const char* name() const;
  68 };
  69 
  70 // Use FloatRegister as shortcut
  71 class FloatRegisterImpl;
  72 typedef FloatRegisterImpl* FloatRegister;
  73 
  74 inline FloatRegister as_FloatRegister(int encoding) {
  75   return (FloatRegister)(intptr_t) encoding;
  76 }
  77 
  78 // The implementation of floating point registers for the zero architecture
  79 class FloatRegisterImpl : public AbstractRegisterImpl {
  80  public:
  81   enum {
  82     number_of_registers = 0
  83   };
  84 
  85   // construction
  86   inline friend FloatRegister as_FloatRegister(int encoding);
  87   VMReg as_VMReg();
  88 
  89   // derived registers, offsets, and addresses
  90   FloatRegister successor() const {
  91     return as_FloatRegister(encoding() + 1);
  92   }
  93 
  94   // accessors
  95   int encoding() const {
  96     assert(is_valid(), "invalid register");
  97     return (intptr_t)this;
  98   }
  99   bool is_valid() const {
 100     return 0 <= (intptr_t) this && (intptr_t)this < number_of_registers;
 101   }
 102   const char* name() const;
 103 };
 104 
 105 class ConcreteRegisterImpl : public AbstractRegisterImpl {
 106  public:
 107   enum {
 108     number_of_registers = RegisterImpl::number_of_registers +
 109                           FloatRegisterImpl::number_of_registers
 110   };
 111 
 112   static const int max_gpr;
 113   static const int max_fpr;
 114 };
 115 
 116 CONSTANT_REGISTER_DECLARATION(Register, noreg, (-1));
 117 #ifndef DONT_USE_REGISTER_DEFINES
 118 #define noreg ((Register)(noreg_RegisterEnumValue))
 119 #endif
 120 
 121 #endif // CPU_ZERO_REGISTER_ZERO_HPP