Skip to content

Commit 377138c

Browse files
committed
8318959: C2: define MachNode::fill_new_machnode() statically
Reviewed-by: kvn, thartmann
1 parent c146685 commit 377138c

File tree

4 files changed

+28
-52
lines changed

4 files changed

+28
-52
lines changed

src/hotspot/share/adlc/formssel.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class InstructForm : public Form {
257257
void set_cisc_reg_mask_name(const char *rm_name) { _cisc_reg_mask_name = rm_name; }
258258
// Output cisc-method prototypes and method bodies
259259
void declare_cisc_version(ArchDesc &AD, FILE *fp_cpp);
260-
bool define_cisc_version (ArchDesc &AD, FILE *fp_cpp);
260+
void define_cisc_version(ArchDesc& AD, FILE* fp_cpp);
261261

262262
bool check_branch_variant(ArchDesc &AD, InstructForm *short_branch);
263263

@@ -273,7 +273,7 @@ class InstructForm : public Form {
273273
bool has_short_branch_form() { return _short_branch_form != nullptr; }
274274
// Output short branch prototypes and method bodies
275275
void declare_short_branch_methods(FILE *fp_cpp);
276-
bool define_short_branch_methods(ArchDesc &AD, FILE *fp_cpp);
276+
void define_short_branch_methods(ArchDesc& AD, FILE* fp_cpp);
277277

278278
uint alignment() { return _alignment; }
279279
void set_alignment(uint val) { _alignment = val; }

src/hotspot/share/adlc/output_c.cpp

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3099,42 +3099,6 @@ void ArchDesc::define_oper_interface(FILE *fp, OperandForm &oper, FormDict &glob
30993099
}
31003100
}
31013101

3102-
//
3103-
// Construct the method to copy _idx, inputs and operands to new node.
3104-
static void define_fill_new_machnode(bool used, FILE *fp_cpp) {
3105-
fprintf(fp_cpp, "\n");
3106-
fprintf(fp_cpp, "// Copy _idx, inputs and operands to new node\n");
3107-
fprintf(fp_cpp, "void MachNode::fill_new_machnode(MachNode* node) const {\n");
3108-
if( !used ) {
3109-
fprintf(fp_cpp, " // This architecture does not have cisc or short branch instructions\n");
3110-
fprintf(fp_cpp, " ShouldNotCallThis();\n");
3111-
fprintf(fp_cpp, "}\n");
3112-
} else {
3113-
// New node must use same node index for access through allocator's tables
3114-
fprintf(fp_cpp, " // New node must use same node index\n");
3115-
fprintf(fp_cpp, " node->set_idx( _idx );\n");
3116-
// Copy machine-independent inputs
3117-
fprintf(fp_cpp, " // Copy machine-independent inputs\n");
3118-
fprintf(fp_cpp, " for( uint j = 0; j < req(); j++ ) {\n");
3119-
fprintf(fp_cpp, " node->add_req(in(j));\n");
3120-
fprintf(fp_cpp, " }\n");
3121-
// Copy machine operands to new MachNode
3122-
fprintf(fp_cpp, " // Copy my operands, except for cisc position\n");
3123-
fprintf(fp_cpp, " int nopnds = num_opnds();\n");
3124-
fprintf(fp_cpp, " assert( node->num_opnds() == (uint)nopnds, \"Must have same number of operands\");\n");
3125-
fprintf(fp_cpp, " MachOper **to = node->_opnds;\n");
3126-
fprintf(fp_cpp, " for( int i = 0; i < nopnds; i++ ) {\n");
3127-
fprintf(fp_cpp, " if( i != cisc_operand() ) \n");
3128-
fprintf(fp_cpp, " to[i] = _opnds[i]->clone();\n");
3129-
fprintf(fp_cpp, " }\n");
3130-
fprintf(fp_cpp, " // Do not increment node index counter, since node reuses my index\n");
3131-
fprintf(fp_cpp, " Compile* C = Compile::current();\n");
3132-
fprintf(fp_cpp, " C->set_unique(C->unique() - 1);\n");
3133-
fprintf(fp_cpp, "}\n");
3134-
}
3135-
fprintf(fp_cpp, "\n");
3136-
}
3137-
31383102
//------------------------------defineClasses----------------------------------
31393103
// Define members of MachNode and MachOper classes based on
31403104
// operand and instruction lists
@@ -3230,7 +3194,6 @@ void ArchDesc::defineClasses(FILE *fp) {
32303194
defineOut_RegMask(_CPP_MISC_file._fp, instr->_ident, reg_mask(*instr));
32313195
}
32323196

3233-
bool used = false;
32343197
// Output the definitions for expand rules & peephole rules
32353198
_instructions.reset();
32363199
for( ; (instr = (InstructForm*)_instructions.iter()) != nullptr; ) {
@@ -3249,15 +3212,12 @@ void ArchDesc::defineClasses(FILE *fp) {
32493212
definePeephole(_CPP_PEEPHOLE_file._fp, instr);
32503213

32513214
// Output code to convert to the cisc version, if applicable
3252-
used |= instr->define_cisc_version(*this, fp);
3215+
instr->define_cisc_version(*this, fp);
32533216

32543217
// Output code to convert to the short branch version, if applicable
3255-
used |= instr->define_short_branch_methods(*this, fp);
3218+
instr->define_short_branch_methods(*this, fp);
32563219
}
32573220

3258-
// Construct the method called by cisc_version() to copy inputs and operands.
3259-
define_fill_new_machnode(used, fp);
3260-
32613221
// Output the definitions for labels
32623222
_instructions.reset();
32633223
while( (instr = (InstructForm*)_instructions.iter()) != nullptr ) {
@@ -4074,7 +4034,7 @@ void InstructForm::declare_cisc_version(ArchDesc &AD, FILE *fp_hpp) {
40744034

40754035
//---------------------------define_cisc_version-------------------------------
40764036
// Build CISC version of this instruction
4077-
bool InstructForm::define_cisc_version(ArchDesc &AD, FILE *fp_cpp) {
4037+
void InstructForm::define_cisc_version(ArchDesc& AD, FILE* fp_cpp) {
40784038
InstructForm *inst_cisc = this->cisc_spill_alternate();
40794039
if( AD.can_cisc_spill() && (inst_cisc != nullptr) ) {
40804040
const char *name = inst_cisc->_ident;
@@ -4120,9 +4080,7 @@ bool InstructForm::define_cisc_version(ArchDesc &AD, FILE *fp_cpp) {
41204080
fprintf(fp_cpp, " return node;\n");
41214081
fprintf(fp_cpp, "}\n");
41224082
fprintf(fp_cpp, "\n");
4123-
return true;
41244083
}
4125-
return false;
41264084
}
41274085

41284086
//---------------------------declare_short_branch_methods----------------------
@@ -4135,7 +4093,7 @@ void InstructForm::declare_short_branch_methods(FILE *fp_hpp) {
41354093

41364094
//---------------------------define_short_branch_methods-----------------------
41374095
// Build definitions for short branch methods
4138-
bool InstructForm::define_short_branch_methods(ArchDesc &AD, FILE *fp_cpp) {
4096+
void InstructForm::define_short_branch_methods(ArchDesc& AD, FILE* fp_cpp) {
41394097
if (has_short_branch_form()) {
41404098
InstructForm *short_branch = short_branch_form();
41414099
const char *name = short_branch->_ident;
@@ -4164,9 +4122,7 @@ bool InstructForm::define_short_branch_methods(ArchDesc &AD, FILE *fp_cpp) {
41644122
fprintf(fp_cpp, " return node;\n");
41654123
fprintf(fp_cpp, "}\n");
41664124
fprintf(fp_cpp,"\n");
4167-
return true;
41684125
}
4169-
return false;
41704126
}
41714127

41724128

src/hotspot/share/opto/machnode.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,27 @@ bool MachNode::cmp( const Node &node ) const {
183183
return true; // match
184184
}
185185

186+
void MachNode::fill_new_machnode(MachNode* node) const {
187+
// New node must use same node index
188+
node->set_idx(_idx);
189+
// Copy machine-independent inputs
190+
for (uint j = 0; j < req(); j++) {
191+
node->add_req(in(j));
192+
}
193+
// Copy my operands, except for cisc position
194+
int nopnds = num_opnds();
195+
assert(node->num_opnds() == (uint)nopnds, "Must have same number of operands");
196+
MachOper** to = node->_opnds;
197+
for (int i = 0; i < nopnds; i++) {
198+
if (i != cisc_operand()) {
199+
to[i] = _opnds[i]->clone();
200+
}
201+
}
202+
// Do not increment node index counter, since node reuses my index
203+
Compile* C = Compile::current();
204+
C->set_unique(C->unique() - 1);
205+
}
206+
186207
// Return an equivalent instruction using memory for cisc_operand position
187208
MachNode *MachNode::cisc_version(int offset) {
188209
ShouldNotCallThis();

src/hotspot/share/opto/machnode.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,8 @@ class MachNode : public Node {
229229
uint8_t barrier_data() const { return _barrier; }
230230
void set_barrier_data(uint8_t data) { _barrier = data; }
231231

232-
// Copy inputs and operands to new node of instruction.
232+
// Copy index, inputs, and operands to a new version of the instruction.
233233
// Called from cisc_version() and short_branch_version().
234-
// !!!! The method's body is defined in ad_<arch>.cpp file.
235234
void fill_new_machnode(MachNode *n) const;
236235

237236
// Return an equivalent instruction using memory for cisc_operand position

0 commit comments

Comments
 (0)