1 /*
 2  * Copyright (c) 2000, 2021, 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_AARCH64_C1_LIRASSEMBLER_AARCH64_HPP
27 #define CPU_AARCH64_C1_LIRASSEMBLER_AARCH64_HPP
28 
29 // ArrayCopyStub needs access to bailout
30 friend class ArrayCopyStub;
31 
32  private:
33 
34   int array_element_size(BasicType type) const;
35 
36   void arith_fpu_implementation(LIR_Code code, int left_index, int right_index, int dest_index, bool pop_fpu_stack);
37 
38   // helper functions which checks for overflow and sets bailout if it
39   // occurs.  Always returns a valid embeddable pointer but in the
40   // bailout case the pointer won't be to unique storage.
41   address float_constant(float f);
42   address double_constant(double d);
43 
44   address int_constant(jlong n);
45 
46   bool is_literal_address(LIR_Address* addr);
47 
48   // When we need to use something other than rscratch1 use this method.
49   Address as_Address(LIR_Address* addr, Register tmp);
50 
51   // Ensure we have a valid Address (base+offset) to a stack-slot.
52   Address stack_slot_address(int index, uint shift, Register tmp, int adjust = 0);
53 
54   // Record the type of the receiver in ReceiverTypeData
55   void type_profile_helper(Register mdo,
56                            ciMethodData *md, ciProfileData *data,
57                            Register recv, Label* update_done);
58   void add_debug_info_for_branch(address adr, CodeEmitInfo* info);
59 
60   void casw(Register addr, Register newval, Register cmpval);
61   void casl(Register addr, Register newval, Register cmpval);
62 
63   void poll_for_safepoint(relocInfo::relocType rtype, CodeEmitInfo* info = NULL);
64 
65   static const int max_tableswitches = 20;
66   struct tableswitch switches[max_tableswitches];
67   int tableswitch_count;
68 
69   void init() { tableswitch_count = 0; }
70 
71   void deoptimize_trap(CodeEmitInfo *info);
72 
73   enum {
74     // call stub: CompiledStaticCall::to_interp_stub_size() +
75     //            CompiledStaticCall::to_trampoline_stub_size()
76     _call_stub_size = 13 * NativeInstruction::instruction_size,
77     _exception_handler_size = DEBUG_ONLY(1*K) NOT_DEBUG(175),
78     _deopt_handler_size = 7 * NativeInstruction::instruction_size
79   };
80 
81   void arraycopy_inlinetype_check(Register obj, Register tmp, CodeStub* slow_path, bool is_dest, bool null_check);
82   void move(LIR_Opr src, LIR_Opr dst);
83 
84 public:
85 
86   void store_parameter(Register r, int offset_from_esp_in_words);
87   void store_parameter(jint c,     int offset_from_esp_in_words);
88   void store_parameter(jobject c,  int offset_from_esp_in_words);
89 
90 #endif // CPU_AARCH64_C1_LIRASSEMBLER_AARCH64_HPP