Mercurial > hg > graal-compiler
comparison src/share/vm/adlc/output_c.cpp @ 1203:844a9d73ec22
6916644: C2 compiler crash on x86
Reviewed-by: kvn, twisti
author | never |
---|---|
date | Fri, 29 Jan 2010 22:51:41 -0800 |
parents | 2056494941db |
children | cff162798819 |
comparison
equal
deleted
inserted
replaced
1202:5f24d0319e54 | 1203:844a9d73ec22 |
---|---|
1 /* | 1 /* |
2 * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 1998-2010 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. |
1494 void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { | 1494 void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { |
1495 unsigned cnt = 0; // Count nodes we have expand into | 1495 unsigned cnt = 0; // Count nodes we have expand into |
1496 unsigned i; | 1496 unsigned i; |
1497 | 1497 |
1498 // Generate Expand function header | 1498 // Generate Expand function header |
1499 fprintf(fp,"MachNode *%sNode::Expand(State *state, Node_List &proj_list) {\n", node->_ident); | 1499 fprintf(fp,"MachNode *%sNode::Expand(State *state, Node_List &proj_list, Node* mem) {\n", node->_ident); |
1500 fprintf(fp,"Compile* C = Compile::current();\n"); | 1500 fprintf(fp,"Compile* C = Compile::current();\n"); |
1501 // Generate expand code | 1501 // Generate expand code |
1502 if( node->expands() ) { | 1502 if( node->expands() ) { |
1503 const char *opid; | 1503 const char *opid; |
1504 int new_pos, exp_pos; | 1504 int new_pos, exp_pos; |
1544 } | 1544 } |
1545 | 1545 |
1546 // Build a mapping from operand index to input edges | 1546 // Build a mapping from operand index to input edges |
1547 fprintf(fp," unsigned idx0 = oper_input_base();\n"); | 1547 fprintf(fp," unsigned idx0 = oper_input_base();\n"); |
1548 | 1548 |
1549 // The order in which inputs are added to a node is very | 1549 // The order in which the memory input is added to a node is very |
1550 // strange. Store nodes get a memory input before Expand is | 1550 // strange. Store nodes get a memory input before Expand is |
1551 // called and all other nodes get it afterwards so | 1551 // called and other nodes get it afterwards or before depending on |
1552 // oper_input_base is wrong during expansion. This code adjusts | 1552 // match order so oper_input_base is wrong during expansion. This |
1553 // is so that expansion will work correctly. | 1553 // code adjusts it so that expansion will work correctly. |
1554 bool missing_memory_edge = node->_matrule->needs_ideal_memory_edge(_globalNames) && | 1554 int has_memory_edge = node->_matrule->needs_ideal_memory_edge(_globalNames); |
1555 node->is_ideal_store() == Form::none; | 1555 if (has_memory_edge) { |
1556 if (missing_memory_edge) { | 1556 fprintf(fp," if (mem == (Node*)1) {\n"); |
1557 fprintf(fp," idx0--; // Adjust base because memory edge hasn't been inserted yet\n"); | 1557 fprintf(fp," idx0--; // Adjust base because memory edge hasn't been inserted yet\n"); |
1558 fprintf(fp," }\n"); | |
1558 } | 1559 } |
1559 | 1560 |
1560 for( i = 0; i < node->num_opnds(); i++ ) { | 1561 for( i = 0; i < node->num_opnds(); i++ ) { |
1561 fprintf(fp," unsigned idx%d = idx%d + num%d;\n", | 1562 fprintf(fp," unsigned idx%d = idx%d + num%d;\n", |
1562 i+1,i,i); | 1563 i+1,i,i); |
1609 int memory_operand = new_inst->memory_operand(_globalNames); | 1610 int memory_operand = new_inst->memory_operand(_globalNames); |
1610 if( memory_operand != InstructForm::NO_MEMORY_OPERAND ) { | 1611 if( memory_operand != InstructForm::NO_MEMORY_OPERAND ) { |
1611 int node_mem_op = node->memory_operand(_globalNames); | 1612 int node_mem_op = node->memory_operand(_globalNames); |
1612 assert( node_mem_op != InstructForm::NO_MEMORY_OPERAND, | 1613 assert( node_mem_op != InstructForm::NO_MEMORY_OPERAND, |
1613 "expand rule member needs memory but top-level inst doesn't have any" ); | 1614 "expand rule member needs memory but top-level inst doesn't have any" ); |
1614 if (!missing_memory_edge) { | 1615 if (has_memory_edge) { |
1615 // Copy memory edge | 1616 // Copy memory edge |
1616 fprintf(fp," n%d->add_req(_in[1]);\t// Add memory edge\n", cnt); | 1617 fprintf(fp," if (mem != (Node*)1) {\n"); |
1618 fprintf(fp," n%d->add_req(_in[1]);\t// Add memory edge\n", cnt); | |
1619 fprintf(fp," }\n"); | |
1617 } | 1620 } |
1618 } | 1621 } |
1619 | 1622 |
1620 // Iterate over the new instruction's operands | 1623 // Iterate over the new instruction's operands |
1621 int prev_pos = -1; | 1624 int prev_pos = -1; |
1687 fprintf(fp," tmp%d = n%d;\n", exp_pos, cnt); | 1690 fprintf(fp," tmp%d = n%d;\n", exp_pos, cnt); |
1688 } | 1691 } |
1689 } // done iterating over a new instruction's operands | 1692 } // done iterating over a new instruction's operands |
1690 | 1693 |
1691 // Invoke Expand() for the newly created instruction. | 1694 // Invoke Expand() for the newly created instruction. |
1692 fprintf(fp," result = n%d->Expand( state, proj_list );\n", cnt); | 1695 fprintf(fp," result = n%d->Expand( state, proj_list, mem );\n", cnt); |
1693 assert( !new_inst->expands(), "Do not have complete support for recursive expansion"); | 1696 assert( !new_inst->expands(), "Do not have complete support for recursive expansion"); |
1694 } // done iterating over new instructions | 1697 } // done iterating over new instructions |
1695 fprintf(fp,"\n"); | 1698 fprintf(fp,"\n"); |
1696 } // done generating expand rule | 1699 } // done generating expand rule |
1697 | 1700 |