annotate src/cpu/x86/vm/c1_LinearScan_x86.hpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children ac637b7220d1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef CPU_X86_VM_C1_LINEARSCAN_X86_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define CPU_X86_VM_C1_LINEARSCAN_X86_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28 inline bool LinearScan::is_processed_reg_num(int reg_num) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
29 #ifndef _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // rsp and rbp (numbers 6 ancd 7) are ignored
a61af66fc99e Initial load
duke
parents:
diff changeset
31 assert(FrameMap::rsp_opr->cpu_regnr() == 6, "wrong assumption below");
a61af66fc99e Initial load
duke
parents:
diff changeset
32 assert(FrameMap::rbp_opr->cpu_regnr() == 7, "wrong assumption below");
a61af66fc99e Initial load
duke
parents:
diff changeset
33 assert(reg_num >= 0, "invalid reg_num");
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 return reg_num < 6 || reg_num > 7;
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
36 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
37 // rsp and rbp, r10, r15 (numbers 6 ancd 7) are ignored
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
38 assert(FrameMap::r10_opr->cpu_regnr() == 12, "wrong assumption below");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
39 assert(FrameMap::r15_opr->cpu_regnr() == 13, "wrong assumption below");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
40 assert(FrameMap::rsp_opr->cpu_regnrLo() == 14, "wrong assumption below");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
41 assert(FrameMap::rbp_opr->cpu_regnrLo() == 15, "wrong assumption below");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
42 assert(reg_num >= 0, "invalid reg_num");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
43
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
44 return reg_num < 12 || reg_num > 15;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
45 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 inline int LinearScan::num_physical_regs(BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // Intel requires two cpu registers for long,
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // but requires only one fpu register for double
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
51 if (LP64_ONLY(false &&) type == T_LONG) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 return 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 return 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 inline bool LinearScan::requires_adjacent_regs(BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 inline bool LinearScan::is_caller_save(int assigned_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 assert(assigned_reg >= 0 && assigned_reg < nof_regs, "should call this only for registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
64 return true; // no callee-saved registers on Intel
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 inline void LinearScan::pd_add_temps(LIR_Op* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 switch (op->code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 case lir_tan:
a61af66fc99e Initial load
duke
parents:
diff changeset
72 case lir_sin:
a61af66fc99e Initial load
duke
parents:
diff changeset
73 case lir_cos: {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // The slow path for these functions may need to save and
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // restore all live registers but we don't want to save and
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // restore everything all the time, so mark the xmms as being
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // killed. If the slow path were explicit or we could propagate
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // live register masks down to the assembly we could do better
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // but we don't have any easy way to do that right now. We
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // could also consider not killing all xmm registers if we
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // assume that slow paths are uncommon but it's not clear that
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // would be a good idea.
a61af66fc99e Initial load
duke
parents:
diff changeset
83 if (UseSSE > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if (TraceLinearScanLevel >= 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 tty->print_cr("killing XMMs for trig");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
89 int op_id = op->id();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 for (int xmm = 0; xmm < FrameMap::nof_caller_save_xmm_regs; xmm++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 LIR_Opr opr = FrameMap::caller_save_xmm_reg_at(xmm);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 add_temp(reg_num(opr), op_id, noUse, T_ILLEGAL);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // Implementation of LinearScanWalker
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 inline bool LinearScanWalker::pd_init_regs_for_alloc(Interval* cur) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (allocator()->gen()->is_vreg_flag_set(cur->reg_num(), LIRGenerator::byte_reg)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 assert(cur->type() != T_FLOAT && cur->type() != T_DOUBLE, "cpu regs only");
a61af66fc99e Initial load
duke
parents:
diff changeset
106 _first_reg = pd_first_byte_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 _last_reg = pd_last_byte_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 } else if ((UseSSE >= 1 && cur->type() == T_FLOAT) || (UseSSE >= 2 && cur->type() == T_DOUBLE)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 _first_reg = pd_first_xmm_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 _last_reg = pd_last_xmm_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 class FpuStackAllocator VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
121 Compilation* _compilation;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 LinearScan* _allocator;
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 LIR_OpVisitState visitor;
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 LIR_List* _lir;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 int _pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 FpuStackSim _sim;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 FpuStackSim _temp_sim;
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 bool _debug_information_computed;
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 LinearScan* allocator() { return _allocator; }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 Compilation* compilation() const { return _compilation; }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // unified bailout support
a61af66fc99e Initial load
duke
parents:
diff changeset
137 void bailout(const char* msg) const { compilation()->bailout(msg); }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 bool bailed_out() const { return compilation()->bailed_out(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 int pos() { return _pos; }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 void set_pos(int pos) { _pos = pos; }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 LIR_Op* cur_op() { return lir()->instructions_list()->at(pos()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
143 LIR_List* lir() { return _lir; }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 void set_lir(LIR_List* lir) { _lir = lir; }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 FpuStackSim* sim() { return &_sim; }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 FpuStackSim* temp_sim() { return &_temp_sim; }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 int fpu_num(LIR_Opr opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 int tos_offset(LIR_Opr opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 LIR_Opr to_fpu_stack_top(LIR_Opr opr, bool dont_check_offset = false);
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Helper functions for handling operations
a61af66fc99e Initial load
duke
parents:
diff changeset
153 void insert_op(LIR_Op* op);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 void insert_exchange(int offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
155 void insert_exchange(LIR_Opr opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 void insert_free(int offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 void insert_free_if_dead(LIR_Opr opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 void insert_free_if_dead(LIR_Opr opr, LIR_Opr ignore);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 void insert_copy(LIR_Opr from, LIR_Opr to);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 void do_rename(LIR_Opr from, LIR_Opr to);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 void do_push(LIR_Opr opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 void pop_if_last_use(LIR_Op* op, LIR_Opr opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 void pop_always(LIR_Op* op, LIR_Opr opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
164 void clear_fpu_stack(LIR_Opr preserve);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 void handle_op1(LIR_Op1* op1);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 void handle_op2(LIR_Op2* op2);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 void handle_opCall(LIR_OpCall* opCall);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 void compute_debug_information(LIR_Op* op);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 void allocate_exception_handler(XHandler* xhandler);
a61af66fc99e Initial load
duke
parents:
diff changeset
170 void allocate_block(BlockBegin* block);
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
173 void check_invalid_lir_op(LIR_Op* op);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // Helper functions for merging of fpu stacks
a61af66fc99e Initial load
duke
parents:
diff changeset
177 void merge_insert_add(LIR_List* instrs, FpuStackSim* cur_sim, int reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 void merge_insert_xchg(LIR_List* instrs, FpuStackSim* cur_sim, int slot);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 void merge_insert_pop(LIR_List* instrs, FpuStackSim* cur_sim);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 bool merge_rename(FpuStackSim* cur_sim, FpuStackSim* sux_sim, int start_slot, int change_slot);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 void merge_fpu_stack(LIR_List* instrs, FpuStackSim* cur_sim, FpuStackSim* sux_sim);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 void merge_cleanup_fpu_stack(LIR_List* instrs, FpuStackSim* cur_sim, BitMap& live_fpu_regs);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 bool merge_fpu_stack_with_successors(BlockBegin* block);
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
186 LIR_Opr to_fpu_stack(LIR_Opr opr); // used by LinearScan for creation of debug information
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 FpuStackAllocator(Compilation* compilation, LinearScan* allocator);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 void allocate();
a61af66fc99e Initial load
duke
parents:
diff changeset
190 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
191
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
192 #endif // CPU_X86_VM_C1_LINEARSCAN_X86_HPP