1 /*
   2  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
   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_AARCH32_VM_C1_LINEARSCAN_AARCH32_HPP
  27 #define CPU_AARCH32_VM_C1_LINEARSCAN_AARCH32_HPP
  28 
  29 inline bool LinearScan::is_processed_reg_num(int reg_num) {
  30   return reg_num <= pd_last_cpu_reg || reg_num >= pd_nof_cpu_regs_frame_map;
  31 }
  32 
  33 inline int LinearScan::num_physical_regs(BasicType type) {
  34   if (type == T_LONG || type == T_DOUBLE) {
  35     return 2;
  36   }
  37   return 1;
  38 }
  39 
  40 inline bool LinearScan::requires_adjacent_regs(BasicType type) {
  41   return type == T_DOUBLE;
  42 }
  43 
  44 inline bool LinearScan::is_caller_save(int assigned_reg) {
  45   assert(assigned_reg >= 0 && assigned_reg < nof_regs,
  46          "should call this only for registers");
  47   // TODO: Remove the following line when support for callee-saved registers
  48   // is added
  49   return true;
  50   if (assigned_reg < pd_first_callee_saved_cpu_reg) {
  51     return true;
  52   }
  53   if (assigned_reg > pd_last_callee_saved_cpu_reg &&
  54       assigned_reg < pd_first_callee_saved_fpu_reg) {
  55     return true;
  56   }
  57   if (assigned_reg > pd_last_callee_saved_fpu_reg &&
  58       assigned_reg <= pd_last_fpu_reg) {
  59     return true;
  60   }
  61   return false;
  62 }
  63 
  64 // If there are special cases when some particular LIR operations kill some
  65 // specific registers, this behavior should be described here. An example
  66 // can be found in x86 port.
  67 inline void LinearScan::pd_add_temps(LIR_Op* op) {
  68   if (op->code() == lir_move) {
  69     LIR_Op1* move_op = op->as_Op1();
  70     if (move_op->move_kind() == lir_move_volatile) {
  71       bool is_long = move_op->type() == T_LONG;
  72       bool is_double = move_op->type() == T_DOUBLE;
  73       bool is_store = move_op->in_opr()->is_register();
  74       if (is_double) {
  75         add_temp(reg_num(FrameMap::long0_opr), op->id(), noUse, T_ILLEGAL);
  76         add_temp(reg_numHi(FrameMap::long0_opr), op->id(), noUse, T_ILLEGAL);
  77       }
  78       if (is_store && (is_long || is_double)) {
  79         add_temp(reg_num(FrameMap::long1_opr), op->id(), noUse, T_ILLEGAL);
  80         add_temp(reg_numHi(FrameMap::long1_opr), op->id(), noUse, T_ILLEGAL);
  81       }
  82     }
  83   }
  84 }
  85 
  86 inline bool LinearScanWalker::pd_init_regs_for_alloc(Interval* cur) {
  87 #ifndef HARD_FLOAT_CC
  88     BasicType type = cur->type();
  89     if(!hasFPU()) {
  90         if (type == T_FLOAT || type == T_DOUBLE) {
  91             _first_reg = pd_first_cpu_reg;
  92             _last_reg = FrameMap::last_cpu_reg();;
  93             return true;
  94         }
  95     }
  96 #endif
  97   return false;
  98 }
  99 
 100 #endif // CPU_AARCH32_VM_C1_LINEARSCAN_AARCH32_HPP