comparison src/share/vm/adlc/formssel.cpp @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents 89152779163c 78bbf4d43a14
children
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
1 /* 1 /*
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
30 InstructForm::InstructForm(const char *id, bool ideal_only) 30 InstructForm::InstructForm(const char *id, bool ideal_only)
31 : _ident(id), _ideal_only(ideal_only), 31 : _ident(id), _ideal_only(ideal_only),
32 _localNames(cmpstr, hashstr, Form::arena), 32 _localNames(cmpstr, hashstr, Form::arena),
33 _effects(cmpstr, hashstr, Form::arena), 33 _effects(cmpstr, hashstr, Form::arena),
34 _is_mach_constant(false), 34 _is_mach_constant(false),
35 _needs_constant_base(false),
35 _has_call(false) 36 _has_call(false)
36 { 37 {
37 _ftype = Form::INS; 38 _ftype = Form::INS;
38 39
39 _matrule = NULL; 40 _matrule = NULL;
40 _insencode = NULL; 41 _insencode = NULL;
41 _constant = NULL; 42 _constant = NULL;
42 _opcode = NULL; 43 _is_postalloc_expand = false;
43 _size = NULL; 44 _opcode = NULL;
44 _attribs = NULL; 45 _size = NULL;
45 _predicate = NULL; 46 _attribs = NULL;
46 _exprule = NULL; 47 _predicate = NULL;
47 _rewrule = NULL; 48 _exprule = NULL;
48 _format = NULL; 49 _rewrule = NULL;
49 _peephole = NULL; 50 _format = NULL;
50 _ins_pipe = NULL; 51 _peephole = NULL;
51 _uniq_idx = NULL; 52 _ins_pipe = NULL;
52 _num_uniq = 0; 53 _uniq_idx = NULL;
53 _cisc_spill_operand = Not_cisc_spillable;// Which operand may cisc-spill 54 _num_uniq = 0;
55 _cisc_spill_operand = Not_cisc_spillable;// Which operand may cisc-spill
54 _cisc_spill_alternate = NULL; // possible cisc replacement 56 _cisc_spill_alternate = NULL; // possible cisc replacement
55 _cisc_reg_mask_name = NULL; 57 _cisc_reg_mask_name = NULL;
56 _is_cisc_alternate = false; 58 _is_cisc_alternate = false;
57 _is_short_branch = false; 59 _is_short_branch = false;
58 _short_branch_form = NULL; 60 _short_branch_form = NULL;
59 _alignment = 1; 61 _alignment = 1;
60 } 62 }
61 63
62 InstructForm::InstructForm(const char *id, InstructForm *instr, MatchRule *rule) 64 InstructForm::InstructForm(const char *id, InstructForm *instr, MatchRule *rule)
63 : _ident(id), _ideal_only(false), 65 : _ident(id), _ideal_only(false),
64 _localNames(instr->_localNames), 66 _localNames(instr->_localNames),
65 _effects(instr->_effects), 67 _effects(instr->_effects),
66 _is_mach_constant(false), 68 _is_mach_constant(false),
69 _needs_constant_base(false),
67 _has_call(false) 70 _has_call(false)
68 { 71 {
69 _ftype = Form::INS; 72 _ftype = Form::INS;
70 73
71 _matrule = rule; 74 _matrule = rule;
72 _insencode = instr->_insencode; 75 _insencode = instr->_insencode;
73 _constant = instr->_constant; 76 _constant = instr->_constant;
74 _opcode = instr->_opcode; 77 _is_postalloc_expand = instr->_is_postalloc_expand;
75 _size = instr->_size; 78 _opcode = instr->_opcode;
76 _attribs = instr->_attribs; 79 _size = instr->_size;
77 _predicate = instr->_predicate; 80 _attribs = instr->_attribs;
78 _exprule = instr->_exprule; 81 _predicate = instr->_predicate;
79 _rewrule = instr->_rewrule; 82 _exprule = instr->_exprule;
80 _format = instr->_format; 83 _rewrule = instr->_rewrule;
81 _peephole = instr->_peephole; 84 _format = instr->_format;
82 _ins_pipe = instr->_ins_pipe; 85 _peephole = instr->_peephole;
83 _uniq_idx = instr->_uniq_idx; 86 _ins_pipe = instr->_ins_pipe;
84 _num_uniq = instr->_num_uniq; 87 _uniq_idx = instr->_uniq_idx;
85 _cisc_spill_operand = Not_cisc_spillable;// Which operand may cisc-spill 88 _num_uniq = instr->_num_uniq;
86 _cisc_spill_alternate = NULL; // possible cisc replacement 89 _cisc_spill_operand = Not_cisc_spillable; // Which operand may cisc-spill
87 _cisc_reg_mask_name = NULL; 90 _cisc_spill_alternate = NULL; // possible cisc replacement
88 _is_cisc_alternate = false; 91 _cisc_reg_mask_name = NULL;
89 _is_short_branch = false; 92 _is_cisc_alternate = false;
90 _short_branch_form = NULL; 93 _is_short_branch = false;
91 _alignment = 1; 94 _short_branch_form = NULL;
95 _alignment = 1;
92 // Copy parameters 96 // Copy parameters
93 const char *name; 97 const char *name;
94 instr->_parameters.reset(); 98 instr->_parameters.reset();
95 for (; (name = instr->_parameters.iter()) != NULL;) 99 for (; (name = instr->_parameters.iter()) != NULL;)
96 _parameters.addName(name); 100 _parameters.addName(name);
153 } 157 }
154 158
155 // This instruction has an expand rule? 159 // This instruction has an expand rule?
156 bool InstructForm::expands() const { 160 bool InstructForm::expands() const {
157 return ( _exprule != NULL ); 161 return ( _exprule != NULL );
162 }
163
164 // This instruction has a late expand rule?
165 bool InstructForm::postalloc_expands() const {
166 return _is_postalloc_expand;
158 } 167 }
159 168
160 // This instruction has a peephole rule? 169 // This instruction has a peephole rule?
161 Peephole *InstructForm::peepholes() const { 170 Peephole *InstructForm::peepholes() const {
162 return _peephole; 171 return _peephole;
637 if( strcmp(_matrule->_opType,"MemBarRelease") == 0 ) return true; 646 if( strcmp(_matrule->_opType,"MemBarRelease") == 0 ) return true;
638 if( strcmp(_matrule->_opType,"MemBarAcquire") == 0 ) return true; 647 if( strcmp(_matrule->_opType,"MemBarAcquire") == 0 ) return true;
639 if( strcmp(_matrule->_opType,"MemBarReleaseLock") == 0 ) return true; 648 if( strcmp(_matrule->_opType,"MemBarReleaseLock") == 0 ) return true;
640 if( strcmp(_matrule->_opType,"MemBarAcquireLock") == 0 ) return true; 649 if( strcmp(_matrule->_opType,"MemBarAcquireLock") == 0 ) return true;
641 if( strcmp(_matrule->_opType,"MemBarStoreStore") == 0 ) return true; 650 if( strcmp(_matrule->_opType,"MemBarStoreStore") == 0 ) return true;
651 if( strcmp(_matrule->_opType,"StoreFence") == 0 ) return true;
652 if( strcmp(_matrule->_opType,"LoadFence") == 0 ) return true;
642 653
643 return false; 654 return false;
644 } 655 }
645 656
646 int InstructForm::memory_operand(FormDict &globals) const { 657 int InstructForm::memory_operand(FormDict &globals) const {
647 // Machine independent loads must be checked for anti-dependences 658 // Machine independent loads must be checked for anti-dependences
648 // Check if instruction has a USE of a memory operand class, or a def. 659 // Check if instruction has a USE of a memory operand class, or a def.
649 int USE_of_memory = 0; 660 int USE_of_memory = 0;
650 int DEF_of_memory = 0; 661 int DEF_of_memory = 0;
651 const char* last_memory_DEF = NULL; // to test DEF/USE pairing in asserts 662 const char* last_memory_DEF = NULL; // to test DEF/USE pairing in asserts
663 const char* last_memory_USE = NULL;
652 Component *unique = NULL; 664 Component *unique = NULL;
653 Component *comp = NULL; 665 Component *comp = NULL;
654 ComponentList &components = (ComponentList &)_components; 666 ComponentList &components = (ComponentList &)_components;
655 667
656 components.reset(); 668 components.reset();
668 } else if( comp->isa(Component::USE) ) { 680 } else if( comp->isa(Component::USE) ) {
669 if( last_memory_DEF != NULL ) { 681 if( last_memory_DEF != NULL ) {
670 assert(0 == strcmp(last_memory_DEF, comp->_name), "every memory DEF is followed by a USE of the same name"); 682 assert(0 == strcmp(last_memory_DEF, comp->_name), "every memory DEF is followed by a USE of the same name");
671 last_memory_DEF = NULL; 683 last_memory_DEF = NULL;
672 } 684 }
673 USE_of_memory++; 685 // Handles same memory being used multiple times in the case of BMI1 instructions.
686 if (last_memory_USE != NULL) {
687 if (strcmp(comp->_name, last_memory_USE) != 0) {
688 USE_of_memory++;
689 }
690 } else {
691 USE_of_memory++;
692 }
693 last_memory_USE = comp->_name;
694
674 if (DEF_of_memory == 0) // defs take precedence 695 if (DEF_of_memory == 0) // defs take precedence
675 unique = comp; 696 unique = comp;
676 } else { 697 } else {
677 assert(last_memory_DEF == NULL, "unpaired memory DEF"); 698 assert(last_memory_DEF == NULL, "unpaired memory DEF");
678 } 699 }
1267 fprintf(fp, "char reg[128]; ra->dump_register(in(mach_constant_base_node_input()), reg);\n"); 1288 fprintf(fp, "char reg[128]; ra->dump_register(in(mach_constant_base_node_input()), reg);\n");
1268 fprintf(fp, " st->print(\"%%s\", reg);\n"); 1289 fprintf(fp, " st->print(\"%%s\", reg);\n");
1269 return; 1290 return;
1270 } 1291 }
1271 if (strcmp(rep_var, "constantoffset") == 0) { 1292 if (strcmp(rep_var, "constantoffset") == 0) {
1272 fprintf(fp, "st->print(\"#%%d\", constant_offset());\n"); 1293 fprintf(fp, "st->print(\"#%%d\", constant_offset_unchecked());\n");
1273 return; 1294 return;
1274 } 1295 }
1275 if (strcmp(rep_var, "constantaddress") == 0) { 1296 if (strcmp(rep_var, "constantaddress") == 0) {
1276 fprintf(fp, "st->print(\"constant table base + #%%d\", constant_offset());\n"); 1297 fprintf(fp, "st->print(\"constant table base + #%%d\", constant_offset_unchecked());\n");
1277 return; 1298 return;
1278 } 1299 }
1279 1300
1280 // Find replacement variable's type 1301 // Find replacement variable's type
1281 const Form *form = _localNames[rep_var]; 1302 const Form *form = _localNames[rep_var];
1299 // This component isn't in the input array. Print out the static 1320 // This component isn't in the input array. Print out the static
1300 // name of the register. 1321 // name of the register.
1301 OperandForm* oper = form->is_operand(); 1322 OperandForm* oper = form->is_operand();
1302 if (oper != NULL && oper->is_bound_register()) { 1323 if (oper != NULL && oper->is_bound_register()) {
1303 const RegDef* first = oper->get_RegClass()->find_first_elem(); 1324 const RegDef* first = oper->get_RegClass()->find_first_elem();
1304 fprintf(fp, " st->print(\"%s\");\n", first->_regname); 1325 fprintf(fp, " st->print_raw(\"%s\");\n", first->_regname);
1305 } else { 1326 } else {
1306 globalAD->syntax_err(_linenum, "In %s can't find format for %s %s", _ident, opc->_ident, rep_var); 1327 globalAD->syntax_err(_linenum, "In %s can't find format for %s %s", _ident, opc->_ident, rep_var);
1307 } 1328 }
1308 } else { 1329 } else {
1309 // Output the format call for this operand 1330 // Output the format call for this operand
2507 switch(const_type) { 2528 switch(const_type) {
2508 case Form::idealI: fprintf(fp," st->print(\"#%%d\", _c%d);\n", const_index); break; 2529 case Form::idealI: fprintf(fp," st->print(\"#%%d\", _c%d);\n", const_index); break;
2509 case Form::idealP: fprintf(fp," if (_c%d) _c%d->dump_on(st);\n", const_index, const_index); break; 2530 case Form::idealP: fprintf(fp," if (_c%d) _c%d->dump_on(st);\n", const_index, const_index); break;
2510 case Form::idealNKlass: 2531 case Form::idealNKlass:
2511 case Form::idealN: fprintf(fp," if (_c%d) _c%d->dump_on(st);\n", const_index, const_index); break; 2532 case Form::idealN: fprintf(fp," if (_c%d) _c%d->dump_on(st);\n", const_index, const_index); break;
2512 case Form::idealL: fprintf(fp," st->print(\"#%%lld\", _c%d);\n", const_index); break; 2533 case Form::idealL: fprintf(fp," st->print(\"#\" INT64_FORMAT, (int64_t)_c%d);\n", const_index); break;
2513 case Form::idealF: fprintf(fp," st->print(\"#%%f\", _c%d);\n", const_index); break; 2534 case Form::idealF: fprintf(fp," st->print(\"#%%f\", _c%d);\n", const_index); break;
2514 case Form::idealD: fprintf(fp," st->print(\"#%%f\", _c%d);\n", const_index); break; 2535 case Form::idealD: fprintf(fp," st->print(\"#%%f\", _c%d);\n", const_index); break;
2515 default: 2536 default:
2516 assert( false, "ShouldNotReachHere()"); 2537 assert( false, "ShouldNotReachHere()");
2517 } 2538 }
4043 } 4064 }
4044 4065
4045 bool MatchRule::is_ideal_membar() const { 4066 bool MatchRule::is_ideal_membar() const {
4046 if( !_opType ) return false; 4067 if( !_opType ) return false;
4047 return 4068 return
4048 !strcmp(_opType,"MemBarAcquire" ) || 4069 !strcmp(_opType,"MemBarAcquire") ||
4049 !strcmp(_opType,"MemBarRelease" ) || 4070 !strcmp(_opType,"MemBarRelease") ||
4050 !strcmp(_opType,"MemBarAcquireLock") || 4071 !strcmp(_opType,"MemBarAcquireLock") ||
4051 !strcmp(_opType,"MemBarReleaseLock") || 4072 !strcmp(_opType,"MemBarReleaseLock") ||
4052 !strcmp(_opType,"MemBarVolatile" ) || 4073 !strcmp(_opType,"LoadFence" ) ||
4053 !strcmp(_opType,"MemBarCPUOrder" ) || 4074 !strcmp(_opType,"StoreFence") ||
4054 !strcmp(_opType,"MemBarStoreStore" ); 4075 !strcmp(_opType,"MemBarVolatile") ||
4076 !strcmp(_opType,"MemBarCPUOrder") ||
4077 !strcmp(_opType,"MemBarStoreStore");
4055 } 4078 }
4056 4079
4057 bool MatchRule::is_ideal_loadPC() const { 4080 bool MatchRule::is_ideal_loadPC() const {
4058 if ( _opType && (strcmp(_opType,"Set") == 0) && _rChild ) { 4081 if ( _opType && (strcmp(_opType,"Set") == 0) && _rChild ) {
4059 return (strcmp(_rChild->_opType,"LoadPC") == 0); 4082 return (strcmp(_rChild->_opType,"LoadPC") == 0);