31
32 // Static initialization
33
34 // This declares the position where vars are kept in the cvstate
35 // For some degree of consistency we use the TypeFunc enum to
36 // soak up spots in the inputs even though we only use early Control
37 // and Memory slots. (So far.)
38 const uint IdealKit::first_var = TypeFunc::Parms + 1;
39
40 //----------------------------IdealKit-----------------------------------------
41 IdealKit::IdealKit(GraphKit* gkit, bool delay_all_transforms, bool has_declarations) :
42 _gvn(gkit->gvn()), C(gkit->C) {
43 _initial_ctrl = gkit->control();
44 _initial_memory = gkit->merged_memory();
45 _initial_i_o = gkit->i_o();
46 _delay_all_transforms = delay_all_transforms;
47 _var_ct = 0;
48 _cvstate = NULL;
49 // We can go memory state free or else we need the entire memory state
50 assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split");
51 assert(!_gvn.is_IterGVN(), "IdealKit can't be used during Optimize phase");
52 int init_size = 5;
53 _pending_cvstates = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0);
54 DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray<int>(C->node_arena(), init_size, 0, 0));
55 if (!has_declarations) {
56 declarations_done();
57 }
58 }
59
60 //----------------------------sync_kit-----------------------------------------
61 void IdealKit::sync_kit(GraphKit* gkit) {
62 set_all_memory(gkit->merged_memory());
63 set_i_o(gkit->i_o());
64 set_ctrl(gkit->control());
65 }
66
67 //-------------------------------if_then-------------------------------------
68 // Create: if(left relop right)
69 // / \
70 // iffalse iftrue
71 // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate.
279 const BasicType bt = n->bottom_type()->basic_type();
280 const Type* ct = Type::get_const_basic_type(bt);
281 return delay_transform(PhiNode::make(reg, n, ct));
282 }
283
284 //-----------------------------declarations_done-------------------------------
285 void IdealKit::declarations_done() {
286 _cvstate = new_cvstate(); // initialize current cvstate
287 set_ctrl(_initial_ctrl); // initialize control in current cvstate
288 set_all_memory(_initial_memory);// initialize memory in current cvstate
289 set_i_o(_initial_i_o); // initialize i_o in current cvstate
290 DEBUG_ONLY(_state->push(BlockS));
291 }
292
293 //-----------------------------transform-----------------------------------
294 Node* IdealKit::transform(Node* n) {
295 if (_delay_all_transforms) {
296 return delay_transform(n);
297 } else {
298 n = gvn().transform(n);
299 C->record_for_igvn(n);
300 return n;
301 }
302 }
303
304 //-----------------------------delay_transform-----------------------------------
305 Node* IdealKit::delay_transform(Node* n) {
306 // Delay transform until IterativeGVN
307 gvn().set_type(n, n->bottom_type());
308 C->record_for_igvn(n);
309 return n;
310 }
311
312 //-----------------------------new_cvstate-----------------------------------
313 Node* IdealKit::new_cvstate() {
314 uint sz = _var_ct + first_var;
315 return new Node(sz);
316 }
317
318 //-----------------------------copy_cvstate-----------------------------------
319 Node* IdealKit::copy_cvstate() {
320 Node* ns = new_cvstate();
321 for (uint i = 0; i < ns->req(); i++) ns->init_req(i, _cvstate->in(i));
322 // We must clone memory since it will be updated as we do stores.
323 ns->set_req(TypeFunc::Memory, MergeMemNode::make(ns->in(TypeFunc::Memory)));
324 return ns;
325 }
326
327 //-----------------------------clear-----------------------------------
328 void IdealKit::clear(Node* m) {
|
31
32 // Static initialization
33
34 // This declares the position where vars are kept in the cvstate
35 // For some degree of consistency we use the TypeFunc enum to
36 // soak up spots in the inputs even though we only use early Control
37 // and Memory slots. (So far.)
38 const uint IdealKit::first_var = TypeFunc::Parms + 1;
39
40 //----------------------------IdealKit-----------------------------------------
41 IdealKit::IdealKit(GraphKit* gkit, bool delay_all_transforms, bool has_declarations) :
42 _gvn(gkit->gvn()), C(gkit->C) {
43 _initial_ctrl = gkit->control();
44 _initial_memory = gkit->merged_memory();
45 _initial_i_o = gkit->i_o();
46 _delay_all_transforms = delay_all_transforms;
47 _var_ct = 0;
48 _cvstate = NULL;
49 // We can go memory state free or else we need the entire memory state
50 assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split");
51 int init_size = 5;
52 _pending_cvstates = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0);
53 DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray<int>(C->node_arena(), init_size, 0, 0));
54 if (!has_declarations) {
55 declarations_done();
56 }
57 }
58
59 //----------------------------sync_kit-----------------------------------------
60 void IdealKit::sync_kit(GraphKit* gkit) {
61 set_all_memory(gkit->merged_memory());
62 set_i_o(gkit->i_o());
63 set_ctrl(gkit->control());
64 }
65
66 //-------------------------------if_then-------------------------------------
67 // Create: if(left relop right)
68 // / \
69 // iffalse iftrue
70 // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate.
278 const BasicType bt = n->bottom_type()->basic_type();
279 const Type* ct = Type::get_const_basic_type(bt);
280 return delay_transform(PhiNode::make(reg, n, ct));
281 }
282
283 //-----------------------------declarations_done-------------------------------
284 void IdealKit::declarations_done() {
285 _cvstate = new_cvstate(); // initialize current cvstate
286 set_ctrl(_initial_ctrl); // initialize control in current cvstate
287 set_all_memory(_initial_memory);// initialize memory in current cvstate
288 set_i_o(_initial_i_o); // initialize i_o in current cvstate
289 DEBUG_ONLY(_state->push(BlockS));
290 }
291
292 //-----------------------------transform-----------------------------------
293 Node* IdealKit::transform(Node* n) {
294 if (_delay_all_transforms) {
295 return delay_transform(n);
296 } else {
297 n = gvn().transform(n);
298 gvn().record_for_igvn(n);
299 return n;
300 }
301 }
302
303 //-----------------------------delay_transform-----------------------------------
304 Node* IdealKit::delay_transform(Node* n) {
305 // Delay transform until IterativeGVN
306 gvn().set_type(n, n->bottom_type());
307 gvn().record_for_igvn(n);
308 return n;
309 }
310
311 //-----------------------------new_cvstate-----------------------------------
312 Node* IdealKit::new_cvstate() {
313 uint sz = _var_ct + first_var;
314 return new Node(sz);
315 }
316
317 //-----------------------------copy_cvstate-----------------------------------
318 Node* IdealKit::copy_cvstate() {
319 Node* ns = new_cvstate();
320 for (uint i = 0; i < ns->req(); i++) ns->init_req(i, _cvstate->in(i));
321 // We must clone memory since it will be updated as we do stores.
322 ns->set_req(TypeFunc::Memory, MergeMemNode::make(ns->in(TypeFunc::Memory)));
323 return ns;
324 }
325
326 //-----------------------------clear-----------------------------------
327 void IdealKit::clear(Node* m) {
|