1 /* 2 * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2014, Red Hat Inc. All rights reserved. 4 * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. 5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 * 7 * This code is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License version 2 only, as 9 * published by the Free Software Foundation. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 * 25 */ 26 27 #ifndef CPU_RISCV_C1_LINEARSCAN_RISCV_HPP 28 #define CPU_RISCV_C1_LINEARSCAN_RISCV_HPP 29 30 inline bool LinearScan::is_processed_reg_num(int reg_num) 31 { 32 return reg_num <= FrameMap::last_cpu_reg() || reg_num >= pd_nof_cpu_regs_frame_map; 33 } 34 35 inline int LinearScan::num_physical_regs(BasicType type) { 36 return 1; 37 } 38 39 inline bool LinearScan::requires_adjacent_regs(BasicType type) { 40 return false; 41 } 42 43 inline bool LinearScan::is_caller_save(int assigned_reg) { 44 assert(assigned_reg >= 0 && assigned_reg < nof_regs, "should call this only for registers"); 45 if (assigned_reg < pd_first_callee_saved_reg) { 46 return true; 47 } 48 if (assigned_reg > pd_last_callee_saved_reg && assigned_reg < pd_first_callee_saved_fpu_reg_1) { 49 return true; 50 } 51 if (assigned_reg > pd_last_callee_saved_fpu_reg_1 && assigned_reg < pd_first_callee_saved_fpu_reg_2) { 52 return true; 53 } 54 if (assigned_reg > pd_last_callee_saved_fpu_reg_2 && assigned_reg < pd_last_fpu_reg) { 55 return true; 56 } 57 return false; 58 } 59 60 inline void LinearScan::pd_add_temps(LIR_Op* op) { 61 // No special case behaviours yet 62 } 63 64 65 // Implementation of LinearScanWalker 66 67 inline bool LinearScanWalker::pd_init_regs_for_alloc(Interval* cur) 68 { 69 if (allocator()->gen()->is_vreg_flag_set(cur->reg_num(), LIRGenerator::callee_saved)) { 70 assert(cur->type() != T_FLOAT && cur->type() != T_DOUBLE, "cpu regs only"); 71 _first_reg = pd_first_callee_saved_reg; 72 _last_reg = pd_last_callee_saved_reg; 73 return true; 74 } else if (cur->type() == T_INT || cur->type() == T_LONG || cur->type() == T_OBJECT || 75 cur->type() == T_ADDRESS || cur->type() == T_METADATA) { 76 _first_reg = pd_first_cpu_reg; 77 _last_reg = pd_last_allocatable_cpu_reg; 78 return true; 79 } 80 return false; 81 } 82 83 #endif // CPU_RISCV_C1_LINEARSCAN_RISCV_HPP