Mercurial > hg > truffle
comparison src/share/vm/adlc/formssel.cpp @ 603:dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
Summary: Some fixes which are required to build on recent GCCs.
Reviewed-by: never, kvn
Contributed-by: langel@redhat.com
author | twisti |
---|---|
date | Fri, 27 Feb 2009 03:35:40 -0800 |
parents | ed6404fac86b |
children | 98cb887364d3 |
comparison
equal
deleted
inserted
replaced
602:ed6404fac86b | 603:dbbe28fc66b5 |
---|---|
1 /* | 1 /* |
2 * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 1998-2009 Sun Microsystems, Inc. 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. |
842 const char *name; | 842 const char *name; |
843 const char *kill_name = NULL; | 843 const char *kill_name = NULL; |
844 for (_parameters.reset(); (name = _parameters.iter()) != NULL;) { | 844 for (_parameters.reset(); (name = _parameters.iter()) != NULL;) { |
845 OperandForm *opForm = (OperandForm*)_localNames[name]; | 845 OperandForm *opForm = (OperandForm*)_localNames[name]; |
846 | 846 |
847 const Form *form = _effects[name]; | 847 Effect* e = NULL; |
848 Effect *e = form ? form->is_effect() : NULL; | 848 { |
849 const Form* form = _effects[name]; | |
850 e = form ? form->is_effect() : NULL; | |
851 } | |
852 | |
849 if (e != NULL) { | 853 if (e != NULL) { |
850 has_temp |= e->is(Component::TEMP); | 854 has_temp |= e->is(Component::TEMP); |
851 | 855 |
852 // KILLs must be declared after any TEMPs because TEMPs are real | 856 // KILLs must be declared after any TEMPs because TEMPs are real |
853 // uses so their operand numbering must directly follow the real | 857 // uses so their operand numbering must directly follow the real |
1108 char *result = NULL; | 1112 char *result = NULL; |
1109 char *result2 = NULL; | 1113 char *result2 = NULL; |
1110 const char *op_name = NULL; | 1114 const char *op_name = NULL; |
1111 const char *reg_type = NULL; | 1115 const char *reg_type = NULL; |
1112 FormDict &globals = AD.globalNames(); | 1116 FormDict &globals = AD.globalNames(); |
1113 cisc_spill_operand = _matrule->cisc_spill_match(globals, AD.get_registers(), instr->_matrule, op_name, reg_type); | 1117 cisc_spill_operand = _matrule->matchrule_cisc_spill_match(globals, AD.get_registers(), instr->_matrule, op_name, reg_type); |
1114 if( (cisc_spill_operand != Not_cisc_spillable) && (op_name != NULL) && equivalent_predicates(this, instr) ) { | 1118 if( (cisc_spill_operand != Not_cisc_spillable) && (op_name != NULL) && equivalent_predicates(this, instr) ) { |
1115 cisc_spill_operand = operand_position(op_name, Component::USE); | 1119 cisc_spill_operand = operand_position(op_name, Component::USE); |
1116 int def_oper = operand_position(op_name, Component::DEF); | 1120 int def_oper = operand_position(op_name, Component::DEF); |
1117 if( def_oper == NameList::Not_in_list && instr->num_opnds() == num_opnds()) { | 1121 if( def_oper == NameList::Not_in_list && instr->num_opnds() == num_opnds()) { |
1118 // Do not support cisc-spilling for destination operands and | 1122 // Do not support cisc-spilling for destination operands and |
2192 | 2196 |
2193 // Return zero-based position in component list, only counting constants; | 2197 // Return zero-based position in component list, only counting constants; |
2194 // Return -1 if not in list. | 2198 // Return -1 if not in list. |
2195 int OperandForm::constant_position(FormDict &globals, const Component *last) { | 2199 int OperandForm::constant_position(FormDict &globals, const Component *last) { |
2196 // Iterate through components and count constants preceeding 'constant' | 2200 // Iterate through components and count constants preceeding 'constant' |
2197 uint position = 0; | 2201 int position = 0; |
2198 Component *comp; | 2202 Component *comp; |
2199 _components.reset(); | 2203 _components.reset(); |
2200 while( (comp = _components.iter()) != NULL && (comp != last) ) { | 2204 while( (comp = _components.iter()) != NULL && (comp != last) ) { |
2201 // Special case for operands that take a single user-defined operand | 2205 // Special case for operands that take a single user-defined operand |
2202 // Skip the initial definition in the component list. | 2206 // Skip the initial definition in the component list. |
2295 assert( op, "Memory Interface 'disp' can only emit an operand form"); | 2299 assert( op, "Memory Interface 'disp' can only emit an operand form"); |
2296 // Check if this is a ConP, which may require relocation | 2300 // Check if this is a ConP, which may require relocation |
2297 if ( op->is_base_constant(globals) == Form::idealP ) { | 2301 if ( op->is_base_constant(globals) == Form::idealP ) { |
2298 // Find the constant's index: _c0, _c1, _c2, ... , _cN | 2302 // Find the constant's index: _c0, _c1, _c2, ... , _cN |
2299 uint idx = op->constant_position( globals, rep_var); | 2303 uint idx = op->constant_position( globals, rep_var); |
2300 fprintf(fp," virtual bool disp_is_oop() const {", _ident); | 2304 fprintf(fp," virtual bool disp_is_oop() const {"); |
2301 fprintf(fp, " return _c%d->isa_oop_ptr();", idx); | 2305 fprintf(fp, " return _c%d->isa_oop_ptr();", idx); |
2302 fprintf(fp, " }\n"); | 2306 fprintf(fp, " }\n"); |
2303 } | 2307 } |
2304 } | 2308 } |
2305 | 2309 |
3033 return false; | 3037 return false; |
3034 } | 3038 } |
3035 | 3039 |
3036 // Recursive call collecting info on top-level operands, not transitive. | 3040 // Recursive call collecting info on top-level operands, not transitive. |
3037 // Implementation does not modify state of internal structures. | 3041 // Implementation does not modify state of internal structures. |
3038 void MatchNode::append_components(FormDict &locals, ComponentList &components, | 3042 void MatchNode::append_components(FormDict& locals, ComponentList& components, |
3039 bool deflag) const { | 3043 bool def_flag) const { |
3040 int usedef = deflag ? Component::DEF : Component::USE; | 3044 int usedef = def_flag ? Component::DEF : Component::USE; |
3041 FormDict &globals = _AD.globalNames(); | 3045 FormDict &globals = _AD.globalNames(); |
3042 | 3046 |
3043 assert (_name != NULL, "MatchNode::build_components encountered empty node\n"); | 3047 assert (_name != NULL, "MatchNode::build_components encountered empty node\n"); |
3044 // Base case | 3048 // Base case |
3045 if (_lChild==NULL && _rChild==NULL) { | 3049 if (_lChild==NULL && _rChild==NULL) { |
3053 } | 3057 } |
3054 } | 3058 } |
3055 return; | 3059 return; |
3056 } | 3060 } |
3057 // Promote results of "Set" to DEF | 3061 // Promote results of "Set" to DEF |
3058 bool def_flag = (!strcmp(_opType, "Set")) ? true : false; | 3062 bool tmpdef_flag = (!strcmp(_opType, "Set")) ? true : false; |
3059 if (_lChild) _lChild->append_components(locals, components, def_flag); | 3063 if (_lChild) _lChild->append_components(locals, components, tmpdef_flag); |
3060 def_flag = false; // only applies to component immediately following 'Set' | 3064 tmpdef_flag = false; // only applies to component immediately following 'Set' |
3061 if (_rChild) _rChild->append_components(locals, components, def_flag); | 3065 if (_rChild) _rChild->append_components(locals, components, tmpdef_flag); |
3062 } | 3066 } |
3063 | 3067 |
3064 // Find the n'th base-operand in the match node, | 3068 // Find the n'th base-operand in the match node, |
3065 // recursively investigates match rules of user-defined operands. | 3069 // recursively investigates match rules of user-defined operands. |
3066 // | 3070 // |
3402 const Form *form2 = globals[op2]; | 3406 const Form *form2 = globals[op2]; |
3403 | 3407 |
3404 return (form1 == form2); | 3408 return (form1 == form2); |
3405 } | 3409 } |
3406 | 3410 |
3407 //-------------------------cisc_spill_match------------------------------------ | 3411 //-------------------------cisc_spill_match_node------------------------------- |
3408 // Recursively check two MatchRules for legal conversion via cisc-spilling | 3412 // Recursively check two MatchRules for legal conversion via cisc-spilling |
3409 int MatchNode::cisc_spill_match(FormDict &globals, RegisterForm *registers, MatchNode *mRule2, const char * &operand, const char * ®_type) { | 3413 int MatchNode::cisc_spill_match(FormDict& globals, RegisterForm* registers, MatchNode* mRule2, const char* &operand, const char* ®_type) { |
3410 int cisc_spillable = Maybe_cisc_spillable; | 3414 int cisc_spillable = Maybe_cisc_spillable; |
3411 int left_spillable = Maybe_cisc_spillable; | 3415 int left_spillable = Maybe_cisc_spillable; |
3412 int right_spillable = Maybe_cisc_spillable; | 3416 int right_spillable = Maybe_cisc_spillable; |
3413 | 3417 |
3414 // Check that each has same number of operands at this level | 3418 // Check that each has same number of operands at this level |
3478 } | 3482 } |
3479 | 3483 |
3480 return cisc_spillable; | 3484 return cisc_spillable; |
3481 } | 3485 } |
3482 | 3486 |
3483 //---------------------------cisc_spill_match---------------------------------- | 3487 //---------------------------cisc_spill_match_rule------------------------------ |
3484 // Recursively check two MatchRules for legal conversion via cisc-spilling | 3488 // Recursively check two MatchRules for legal conversion via cisc-spilling |
3485 // This method handles the root of Match tree, | 3489 // This method handles the root of Match tree, |
3486 // general recursive checks done in MatchNode | 3490 // general recursive checks done in MatchNode |
3487 int MatchRule::cisc_spill_match(FormDict &globals, RegisterForm *registers, | 3491 int MatchRule::matchrule_cisc_spill_match(FormDict& globals, RegisterForm* registers, |
3488 MatchRule *mRule2, const char * &operand, | 3492 MatchRule* mRule2, const char* &operand, |
3489 const char * ®_type) { | 3493 const char* ®_type) { |
3490 int cisc_spillable = Maybe_cisc_spillable; | 3494 int cisc_spillable = Maybe_cisc_spillable; |
3491 int left_spillable = Maybe_cisc_spillable; | 3495 int left_spillable = Maybe_cisc_spillable; |
3492 int right_spillable = Maybe_cisc_spillable; | 3496 int right_spillable = Maybe_cisc_spillable; |
3493 | 3497 |
3494 // Check that each sets a result | 3498 // Check that each sets a result |
3522 } | 3526 } |
3523 | 3527 |
3524 //----------------------------- equivalent ------------------------------------ | 3528 //----------------------------- equivalent ------------------------------------ |
3525 // Recursively check to see if two match rules are equivalent. | 3529 // Recursively check to see if two match rules are equivalent. |
3526 // This rule handles the root. | 3530 // This rule handles the root. |
3527 bool MatchRule::equivalent(FormDict &globals, MatchRule *mRule2) { | 3531 bool MatchRule::equivalent(FormDict &globals, MatchNode *mRule2) { |
3528 // Check that each sets a result | 3532 // Check that each sets a result |
3529 if (sets_result() != mRule2->sets_result()) { | 3533 if (sets_result() != mRule2->sets_result()) { |
3530 return false; | 3534 return false; |
3531 } | 3535 } |
3532 | 3536 |
3638 } | 3642 } |
3639 } | 3643 } |
3640 | 3644 |
3641 //-------------------------- swap_commutative_op ------------------------------ | 3645 //-------------------------- swap_commutative_op ------------------------------ |
3642 // Recursively swap specified commutative operation with subtree operands. | 3646 // Recursively swap specified commutative operation with subtree operands. |
3643 void MatchRule::swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt) { | 3647 void MatchRule::matchrule_swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt) { |
3644 assert(match_rules_cnt < 100," too many match rule clones"); | 3648 assert(match_rules_cnt < 100," too many match rule clones"); |
3645 // Clone | 3649 // Clone |
3646 MatchRule* clone = new MatchRule(_AD, this); | 3650 MatchRule* clone = new MatchRule(_AD, this); |
3647 // Swap operands of commutative operation | 3651 // Swap operands of commutative operation |
3648 ((MatchNode*)clone)->swap_commutative_op(true, count); | 3652 ((MatchNode*)clone)->swap_commutative_op(true, count); |
3651 clone->_result = buf; | 3655 clone->_result = buf; |
3652 | 3656 |
3653 clone->_next = this->_next; | 3657 clone->_next = this->_next; |
3654 this-> _next = clone; | 3658 this-> _next = clone; |
3655 if( (--count) > 0 ) { | 3659 if( (--count) > 0 ) { |
3656 this-> swap_commutative_op(instr_ident, count, match_rules_cnt); | 3660 this-> matchrule_swap_commutative_op(instr_ident, count, match_rules_cnt); |
3657 clone->swap_commutative_op(instr_ident, count, match_rules_cnt); | 3661 clone->matchrule_swap_commutative_op(instr_ident, count, match_rules_cnt); |
3658 } | 3662 } |
3659 } | 3663 } |
3660 | 3664 |
3661 //------------------------------MatchRule-------------------------------------- | 3665 //------------------------------MatchRule-------------------------------------- |
3662 MatchRule::MatchRule(ArchDesc &ad) | 3666 MatchRule::MatchRule(ArchDesc &ad) |
3684 MatchRule::~MatchRule() { | 3688 MatchRule::~MatchRule() { |
3685 } | 3689 } |
3686 | 3690 |
3687 // Recursive call collecting info on top-level operands, not transitive. | 3691 // Recursive call collecting info on top-level operands, not transitive. |
3688 // Implementation does not modify state of internal structures. | 3692 // Implementation does not modify state of internal structures. |
3689 void MatchRule::append_components(FormDict &locals, ComponentList &components) const { | 3693 void MatchRule::append_components(FormDict& locals, ComponentList& components, bool def_flag) const { |
3690 assert (_name != NULL, "MatchNode::build_components encountered empty node\n"); | 3694 assert (_name != NULL, "MatchNode::build_components encountered empty node\n"); |
3691 | 3695 |
3692 MatchNode::append_components(locals, components, | 3696 MatchNode::append_components(locals, components, |
3693 false /* not necessarily a def */); | 3697 false /* not necessarily a def */); |
3694 } | 3698 } |