Mon, 12 Aug 2019 18:30:40 +0300
8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens
duke@435 | 1 | // |
mikael@6198 | 2 | // Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | // |
duke@435 | 5 | // This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | // under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | // published by the Free Software Foundation. |
duke@435 | 8 | // |
duke@435 | 9 | // This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | // version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | // accompanied this code). |
duke@435 | 14 | // |
duke@435 | 15 | // You should have received a copy of the GNU General Public License version |
duke@435 | 16 | // 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | // Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | // |
trims@1907 | 19 | // Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | // or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | // questions. |
duke@435 | 22 | // |
duke@435 | 23 | // |
duke@435 | 24 | |
duke@435 | 25 | |
duke@435 | 26 | // archDesc.cpp - Internal format for architecture definition |
duke@435 | 27 | #include "adlc.hpp" |
duke@435 | 28 | |
duke@435 | 29 | static FILE *errfile = stderr; |
duke@435 | 30 | |
duke@435 | 31 | //--------------------------- utility functions ----------------------------- |
twisti@5221 | 32 | inline char toUpper(char lower) { |
twisti@5221 | 33 | return (('a' <= lower && lower <= 'z') ? ((char) (lower + ('A'-'a'))) : lower); |
duke@435 | 34 | } |
duke@435 | 35 | char *toUpper(const char *str) { |
duke@435 | 36 | char *upper = new char[strlen(str)+1]; |
duke@435 | 37 | char *result = upper; |
duke@435 | 38 | const char *end = str + strlen(str); |
duke@435 | 39 | for (; str < end; ++str, ++upper) { |
duke@435 | 40 | *upper = toUpper(*str); |
duke@435 | 41 | } |
duke@435 | 42 | *upper = '\0'; |
duke@435 | 43 | return result; |
duke@435 | 44 | } |
duke@435 | 45 | |
duke@435 | 46 | // Utilities to characterize effect statements |
duke@435 | 47 | static bool is_def(int usedef) { |
duke@435 | 48 | switch(usedef) { |
duke@435 | 49 | case Component::DEF: |
duke@435 | 50 | case Component::USE_DEF: return true; break; |
duke@435 | 51 | } |
duke@435 | 52 | return false; |
duke@435 | 53 | } |
duke@435 | 54 | |
duke@435 | 55 | static bool is_use(int usedef) { |
duke@435 | 56 | switch(usedef) { |
duke@435 | 57 | case Component::USE: |
duke@435 | 58 | case Component::USE_DEF: |
duke@435 | 59 | case Component::USE_KILL: return true; break; |
duke@435 | 60 | } |
duke@435 | 61 | return false; |
duke@435 | 62 | } |
duke@435 | 63 | |
duke@435 | 64 | static bool is_kill(int usedef) { |
duke@435 | 65 | switch(usedef) { |
duke@435 | 66 | case Component::KILL: |
duke@435 | 67 | case Component::USE_KILL: return true; break; |
duke@435 | 68 | } |
duke@435 | 69 | return false; |
duke@435 | 70 | } |
duke@435 | 71 | |
duke@435 | 72 | //---------------------------ChainList Methods------------------------------- |
duke@435 | 73 | ChainList::ChainList() { |
duke@435 | 74 | } |
duke@435 | 75 | |
duke@435 | 76 | void ChainList::insert(const char *name, const char *cost, const char *rule) { |
duke@435 | 77 | _name.addName(name); |
duke@435 | 78 | _cost.addName(cost); |
duke@435 | 79 | _rule.addName(rule); |
duke@435 | 80 | } |
duke@435 | 81 | |
duke@435 | 82 | bool ChainList::search(const char *name) { |
duke@435 | 83 | return _name.search(name); |
duke@435 | 84 | } |
duke@435 | 85 | |
duke@435 | 86 | void ChainList::reset() { |
duke@435 | 87 | _name.reset(); |
duke@435 | 88 | _cost.reset(); |
duke@435 | 89 | _rule.reset(); |
duke@435 | 90 | } |
duke@435 | 91 | |
duke@435 | 92 | bool ChainList::iter(const char * &name, const char * &cost, const char * &rule) { |
duke@435 | 93 | bool notDone = false; |
duke@435 | 94 | const char *n = _name.iter(); |
duke@435 | 95 | const char *c = _cost.iter(); |
duke@435 | 96 | const char *r = _rule.iter(); |
duke@435 | 97 | |
duke@435 | 98 | if (n && c && r) { |
duke@435 | 99 | notDone = true; |
duke@435 | 100 | name = n; |
duke@435 | 101 | cost = c; |
duke@435 | 102 | rule = r; |
duke@435 | 103 | } |
duke@435 | 104 | |
duke@435 | 105 | return notDone; |
duke@435 | 106 | } |
duke@435 | 107 | |
duke@435 | 108 | void ChainList::dump() { |
duke@435 | 109 | output(stderr); |
duke@435 | 110 | } |
duke@435 | 111 | |
duke@435 | 112 | void ChainList::output(FILE *fp) { |
duke@435 | 113 | fprintf(fp, "\nChain Rules: output resets iterator\n"); |
duke@435 | 114 | const char *cost = NULL; |
duke@435 | 115 | const char *name = NULL; |
duke@435 | 116 | const char *rule = NULL; |
duke@435 | 117 | bool chains_exist = false; |
duke@435 | 118 | for(reset(); (iter(name,cost,rule)) == true; ) { |
duke@435 | 119 | fprintf(fp, "Chain to <%s> at cost #%s using %s_rule\n",name, cost ? cost : "0", rule); |
duke@435 | 120 | // // Check for transitive chain rules |
duke@435 | 121 | // Form *form = (Form *)_globalNames[rule]; |
duke@435 | 122 | // if (form->is_instruction()) { |
duke@435 | 123 | // // chain_rule(fp, indent, name, cost, rule); |
duke@435 | 124 | // chain_rule(fp, indent, name, cost, rule); |
duke@435 | 125 | // } |
duke@435 | 126 | } |
duke@435 | 127 | reset(); |
duke@435 | 128 | if( ! chains_exist ) { |
duke@435 | 129 | fprintf(fp, "No entries in this ChainList\n"); |
duke@435 | 130 | } |
duke@435 | 131 | } |
duke@435 | 132 | |
duke@435 | 133 | |
duke@435 | 134 | //---------------------------MatchList Methods------------------------------- |
duke@435 | 135 | bool MatchList::search(const char *opc, const char *res, const char *lch, |
duke@435 | 136 | const char *rch, Predicate *pr) { |
duke@435 | 137 | bool tmp = false; |
duke@435 | 138 | if ((res == _resultStr) || (res && _resultStr && !strcmp(res, _resultStr))) { |
duke@435 | 139 | if ((lch == _lchild) || (lch && _lchild && !strcmp(lch, _lchild))) { |
duke@435 | 140 | if ((rch == _rchild) || (rch && _rchild && !strcmp(rch, _rchild))) { |
duke@435 | 141 | char * predStr = get_pred(); |
duke@435 | 142 | char * prStr = pr?pr->_pred:NULL; |
jrose@910 | 143 | if (ADLParser::equivalent_expressions(prStr, predStr)) { |
duke@435 | 144 | return true; |
duke@435 | 145 | } |
duke@435 | 146 | } |
duke@435 | 147 | } |
duke@435 | 148 | } |
duke@435 | 149 | if (_next) { |
duke@435 | 150 | tmp = _next->search(opc, res, lch, rch, pr); |
duke@435 | 151 | } |
duke@435 | 152 | return tmp; |
duke@435 | 153 | } |
duke@435 | 154 | |
duke@435 | 155 | |
duke@435 | 156 | void MatchList::dump() { |
duke@435 | 157 | output(stderr); |
duke@435 | 158 | } |
duke@435 | 159 | |
duke@435 | 160 | void MatchList::output(FILE *fp) { |
duke@435 | 161 | fprintf(fp, "\nMatchList output is Unimplemented();\n"); |
duke@435 | 162 | } |
duke@435 | 163 | |
duke@435 | 164 | |
duke@435 | 165 | //---------------------------ArchDesc Constructor and Destructor------------- |
duke@435 | 166 | |
duke@435 | 167 | ArchDesc::ArchDesc() |
duke@435 | 168 | : _globalNames(cmpstr,hashstr, Form::arena), |
duke@435 | 169 | _globalDefs(cmpstr,hashstr, Form::arena), |
duke@435 | 170 | _preproc_table(cmpstr,hashstr, Form::arena), |
duke@435 | 171 | _idealIndex(cmpstr,hashstr, Form::arena), |
duke@435 | 172 | _internalOps(cmpstr,hashstr, Form::arena), |
duke@435 | 173 | _internalMatch(cmpstr,hashstr, Form::arena), |
duke@435 | 174 | _chainRules(cmpstr,hashstr, Form::arena), |
goetz@6499 | 175 | _cisc_spill_operand(NULL), |
goetz@6499 | 176 | _needs_clone_jvms(false) { |
duke@435 | 177 | |
duke@435 | 178 | // Initialize the opcode to MatchList table with NULLs |
duke@435 | 179 | for( int i=0; i<_last_opcode; ++i ) { |
duke@435 | 180 | _mlistab[i] = NULL; |
duke@435 | 181 | } |
duke@435 | 182 | |
duke@435 | 183 | // Set-up the global tables |
duke@435 | 184 | initKeywords(_globalNames); // Initialize the Name Table with keywords |
duke@435 | 185 | |
duke@435 | 186 | // Prime user-defined types with predefined types: Set, RegI, RegF, ... |
duke@435 | 187 | initBaseOpTypes(); |
duke@435 | 188 | |
duke@435 | 189 | // Initialize flags & counters |
duke@435 | 190 | _TotalLines = 0; |
duke@435 | 191 | _no_output = 0; |
duke@435 | 192 | _quiet_mode = 0; |
duke@435 | 193 | _disable_warnings = 0; |
duke@435 | 194 | _dfa_debug = 0; |
duke@435 | 195 | _dfa_small = 0; |
duke@435 | 196 | _adl_debug = 0; |
duke@435 | 197 | _adlocation_debug = 0; |
duke@435 | 198 | _internalOpCounter = 0; |
duke@435 | 199 | _cisc_spill_debug = false; |
duke@435 | 200 | _short_branch_debug = false; |
duke@435 | 201 | |
duke@435 | 202 | // Initialize match rule flags |
duke@435 | 203 | for (int i = 0; i < _last_opcode; i++) { |
duke@435 | 204 | _has_match_rule[i] = false; |
duke@435 | 205 | } |
duke@435 | 206 | |
duke@435 | 207 | // Error/Warning Counts |
duke@435 | 208 | _syntax_errs = 0; |
duke@435 | 209 | _semantic_errs = 0; |
duke@435 | 210 | _warnings = 0; |
duke@435 | 211 | _internal_errs = 0; |
duke@435 | 212 | |
duke@435 | 213 | // Initialize I/O Files |
duke@435 | 214 | _ADL_file._name = NULL; _ADL_file._fp = NULL; |
duke@435 | 215 | // Machine dependent output files |
kvn@868 | 216 | _DFA_file._name = NULL; _DFA_file._fp = NULL; |
kvn@868 | 217 | _HPP_file._name = NULL; _HPP_file._fp = NULL; |
kvn@868 | 218 | _CPP_file._name = NULL; _CPP_file._fp = NULL; |
duke@435 | 219 | _bug_file._name = "bugs.out"; _bug_file._fp = NULL; |
duke@435 | 220 | |
duke@435 | 221 | // Initialize Register & Pipeline Form Pointers |
duke@435 | 222 | _register = NULL; |
duke@435 | 223 | _encode = NULL; |
duke@435 | 224 | _pipeline = NULL; |
kvn@4161 | 225 | _frame = NULL; |
duke@435 | 226 | } |
duke@435 | 227 | |
duke@435 | 228 | ArchDesc::~ArchDesc() { |
duke@435 | 229 | // Clean-up and quit |
duke@435 | 230 | |
duke@435 | 231 | } |
duke@435 | 232 | |
duke@435 | 233 | //---------------------------ArchDesc methods: Public ---------------------- |
duke@435 | 234 | // Store forms according to type |
duke@435 | 235 | void ArchDesc::addForm(PreHeaderForm *ptr) { _pre_header.addForm(ptr); }; |
duke@435 | 236 | void ArchDesc::addForm(HeaderForm *ptr) { _header.addForm(ptr); }; |
duke@435 | 237 | void ArchDesc::addForm(SourceForm *ptr) { _source.addForm(ptr); }; |
duke@435 | 238 | void ArchDesc::addForm(EncodeForm *ptr) { _encode = ptr; }; |
duke@435 | 239 | void ArchDesc::addForm(InstructForm *ptr) { _instructions.addForm(ptr); }; |
duke@435 | 240 | void ArchDesc::addForm(MachNodeForm *ptr) { _machnodes.addForm(ptr); }; |
duke@435 | 241 | void ArchDesc::addForm(OperandForm *ptr) { _operands.addForm(ptr); }; |
duke@435 | 242 | void ArchDesc::addForm(OpClassForm *ptr) { _opclass.addForm(ptr); }; |
duke@435 | 243 | void ArchDesc::addForm(AttributeForm *ptr) { _attributes.addForm(ptr); }; |
duke@435 | 244 | void ArchDesc::addForm(RegisterForm *ptr) { _register = ptr; }; |
duke@435 | 245 | void ArchDesc::addForm(FrameForm *ptr) { _frame = ptr; }; |
duke@435 | 246 | void ArchDesc::addForm(PipelineForm *ptr) { _pipeline = ptr; }; |
duke@435 | 247 | |
duke@435 | 248 | // Build MatchList array and construct MatchLists |
duke@435 | 249 | void ArchDesc::generateMatchLists() { |
duke@435 | 250 | // Call inspection routines to populate array |
duke@435 | 251 | inspectOperands(); |
duke@435 | 252 | inspectInstructions(); |
duke@435 | 253 | } |
duke@435 | 254 | |
duke@435 | 255 | // Build MatchList structures for operands |
duke@435 | 256 | void ArchDesc::inspectOperands() { |
duke@435 | 257 | |
duke@435 | 258 | // Iterate through all operands |
duke@435 | 259 | _operands.reset(); |
duke@435 | 260 | OperandForm *op; |
duke@435 | 261 | for( ; (op = (OperandForm*)_operands.iter()) != NULL;) { |
duke@435 | 262 | // Construct list of top-level operands (components) |
duke@435 | 263 | op->build_components(); |
duke@435 | 264 | |
duke@435 | 265 | // Ensure that match field is defined. |
duke@435 | 266 | if ( op->_matrule == NULL ) continue; |
duke@435 | 267 | |
duke@435 | 268 | // Type check match rules |
duke@435 | 269 | check_optype(op->_matrule); |
duke@435 | 270 | |
duke@435 | 271 | // Construct chain rules |
duke@435 | 272 | build_chain_rule(op); |
duke@435 | 273 | |
duke@435 | 274 | MatchRule &mrule = *op->_matrule; |
duke@435 | 275 | Predicate *pred = op->_predicate; |
duke@435 | 276 | |
duke@435 | 277 | // Grab the machine type of the operand |
duke@435 | 278 | const char *rootOp = op->_ident; |
duke@435 | 279 | mrule._machType = rootOp; |
duke@435 | 280 | |
duke@435 | 281 | // Check for special cases |
duke@435 | 282 | if (strcmp(rootOp,"Universe")==0) continue; |
duke@435 | 283 | if (strcmp(rootOp,"label")==0) continue; |
duke@435 | 284 | // !!!!! !!!!! |
duke@435 | 285 | assert( strcmp(rootOp,"sReg") != 0, "Disable untyped 'sReg'"); |
duke@435 | 286 | if (strcmp(rootOp,"sRegI")==0) continue; |
duke@435 | 287 | if (strcmp(rootOp,"sRegP")==0) continue; |
duke@435 | 288 | if (strcmp(rootOp,"sRegF")==0) continue; |
duke@435 | 289 | if (strcmp(rootOp,"sRegD")==0) continue; |
duke@435 | 290 | if (strcmp(rootOp,"sRegL")==0) continue; |
duke@435 | 291 | |
duke@435 | 292 | // Cost for this match |
duke@435 | 293 | const char *costStr = op->cost(); |
duke@435 | 294 | const char *defaultCost = |
duke@435 | 295 | ((AttributeForm*)_globalNames[AttributeForm::_op_cost])->_attrdef; |
duke@435 | 296 | const char *cost = costStr? costStr : defaultCost; |
duke@435 | 297 | |
duke@435 | 298 | // Find result type for match. |
duke@435 | 299 | const char *result = op->reduce_result(); |
duke@435 | 300 | bool has_root = false; |
duke@435 | 301 | |
duke@435 | 302 | // Construct a MatchList for this entry |
duke@435 | 303 | buildMatchList(op->_matrule, result, rootOp, pred, cost); |
duke@435 | 304 | } |
duke@435 | 305 | } |
duke@435 | 306 | |
duke@435 | 307 | // Build MatchList structures for instructions |
duke@435 | 308 | void ArchDesc::inspectInstructions() { |
duke@435 | 309 | |
duke@435 | 310 | // Iterate through all instructions |
duke@435 | 311 | _instructions.reset(); |
duke@435 | 312 | InstructForm *instr; |
duke@435 | 313 | for( ; (instr = (InstructForm*)_instructions.iter()) != NULL; ) { |
duke@435 | 314 | // Construct list of top-level operands (components) |
duke@435 | 315 | instr->build_components(); |
duke@435 | 316 | |
duke@435 | 317 | // Ensure that match field is defined. |
duke@435 | 318 | if ( instr->_matrule == NULL ) continue; |
duke@435 | 319 | |
duke@435 | 320 | MatchRule &mrule = *instr->_matrule; |
duke@435 | 321 | Predicate *pred = instr->build_predicate(); |
duke@435 | 322 | |
duke@435 | 323 | // Grab the machine type of the operand |
duke@435 | 324 | const char *rootOp = instr->_ident; |
duke@435 | 325 | mrule._machType = rootOp; |
duke@435 | 326 | |
duke@435 | 327 | // Cost for this match |
duke@435 | 328 | const char *costStr = instr->cost(); |
duke@435 | 329 | const char *defaultCost = |
duke@435 | 330 | ((AttributeForm*)_globalNames[AttributeForm::_ins_cost])->_attrdef; |
duke@435 | 331 | const char *cost = costStr? costStr : defaultCost; |
duke@435 | 332 | |
duke@435 | 333 | // Find result type for match |
duke@435 | 334 | const char *result = instr->reduce_result(); |
duke@435 | 335 | |
kvn@3051 | 336 | if ( instr->is_ideal_branch() && instr->label_position() == -1 || |
kvn@3051 | 337 | !instr->is_ideal_branch() && instr->label_position() != -1) { |
kvn@3051 | 338 | syntax_err(instr->_linenum, "%s: Only branches to a label are supported\n", rootOp); |
kvn@3051 | 339 | } |
kvn@3051 | 340 | |
duke@435 | 341 | Attribute *attr = instr->_attribs; |
duke@435 | 342 | while (attr != NULL) { |
duke@435 | 343 | if (strcmp(attr->_ident,"ins_short_branch") == 0 && |
duke@435 | 344 | attr->int_val(*this) != 0) { |
kvn@3040 | 345 | if (!instr->is_ideal_branch() || instr->label_position() == -1) { |
kvn@3040 | 346 | syntax_err(instr->_linenum, "%s: Only short branch to a label is supported\n", rootOp); |
kvn@3040 | 347 | } |
duke@435 | 348 | instr->set_short_branch(true); |
duke@435 | 349 | } else if (strcmp(attr->_ident,"ins_alignment") == 0 && |
duke@435 | 350 | attr->int_val(*this) != 0) { |
duke@435 | 351 | instr->set_alignment(attr->int_val(*this)); |
duke@435 | 352 | } |
duke@435 | 353 | attr = (Attribute *)attr->_next; |
duke@435 | 354 | } |
duke@435 | 355 | |
duke@435 | 356 | if (!instr->is_short_branch()) { |
duke@435 | 357 | buildMatchList(instr->_matrule, result, mrule._machType, pred, cost); |
duke@435 | 358 | } |
duke@435 | 359 | } |
duke@435 | 360 | } |
duke@435 | 361 | |
duke@435 | 362 | static int setsResult(MatchRule &mrule) { |
duke@435 | 363 | if (strcmp(mrule._name,"Set") == 0) return 1; |
duke@435 | 364 | return 0; |
duke@435 | 365 | } |
duke@435 | 366 | |
duke@435 | 367 | const char *ArchDesc::getMatchListIndex(MatchRule &mrule) { |
duke@435 | 368 | if (setsResult(mrule)) { |
duke@435 | 369 | // right child |
duke@435 | 370 | return mrule._rChild->_opType; |
duke@435 | 371 | } else { |
duke@435 | 372 | // first entry |
duke@435 | 373 | return mrule._opType; |
duke@435 | 374 | } |
duke@435 | 375 | } |
duke@435 | 376 | |
duke@435 | 377 | |
duke@435 | 378 | //------------------------------result of reduction---------------------------- |
duke@435 | 379 | |
duke@435 | 380 | |
duke@435 | 381 | //------------------------------left reduction--------------------------------- |
duke@435 | 382 | // Return the left reduction associated with an internal name |
duke@435 | 383 | const char *ArchDesc::reduceLeft(char *internalName) { |
duke@435 | 384 | const char *left = NULL; |
duke@435 | 385 | MatchNode *mnode = (MatchNode*)_internalMatch[internalName]; |
duke@435 | 386 | if (mnode->_lChild) { |
duke@435 | 387 | mnode = mnode->_lChild; |
duke@435 | 388 | left = mnode->_internalop ? mnode->_internalop : mnode->_opType; |
duke@435 | 389 | } |
duke@435 | 390 | return left; |
duke@435 | 391 | } |
duke@435 | 392 | |
duke@435 | 393 | |
duke@435 | 394 | //------------------------------right reduction-------------------------------- |
duke@435 | 395 | const char *ArchDesc::reduceRight(char *internalName) { |
duke@435 | 396 | const char *right = NULL; |
duke@435 | 397 | MatchNode *mnode = (MatchNode*)_internalMatch[internalName]; |
duke@435 | 398 | if (mnode->_rChild) { |
duke@435 | 399 | mnode = mnode->_rChild; |
duke@435 | 400 | right = mnode->_internalop ? mnode->_internalop : mnode->_opType; |
duke@435 | 401 | } |
duke@435 | 402 | return right; |
duke@435 | 403 | } |
duke@435 | 404 | |
duke@435 | 405 | |
duke@435 | 406 | //------------------------------check_optype----------------------------------- |
duke@435 | 407 | void ArchDesc::check_optype(MatchRule *mrule) { |
duke@435 | 408 | MatchRule *rule = mrule; |
duke@435 | 409 | |
duke@435 | 410 | // !!!!! |
duke@435 | 411 | // // Cycle through the list of match rules |
duke@435 | 412 | // while(mrule) { |
duke@435 | 413 | // // Check for a filled in type field |
duke@435 | 414 | // if (mrule->_opType == NULL) { |
duke@435 | 415 | // const Form *form = operands[_result]; |
duke@435 | 416 | // OpClassForm *opcForm = form ? form->is_opclass() : NULL; |
duke@435 | 417 | // assert(opcForm != NULL, "Match Rule contains invalid operand name."); |
duke@435 | 418 | // } |
duke@435 | 419 | // char *opType = opcForm->_ident; |
duke@435 | 420 | // } |
duke@435 | 421 | } |
duke@435 | 422 | |
duke@435 | 423 | //------------------------------add_chain_rule_entry-------------------------- |
duke@435 | 424 | void ArchDesc::add_chain_rule_entry(const char *src, const char *cost, |
duke@435 | 425 | const char *result) { |
duke@435 | 426 | // Look-up the operation in chain rule table |
duke@435 | 427 | ChainList *lst = (ChainList *)_chainRules[src]; |
duke@435 | 428 | if (lst == NULL) { |
duke@435 | 429 | lst = new ChainList(); |
duke@435 | 430 | _chainRules.Insert(src, lst); |
duke@435 | 431 | } |
duke@435 | 432 | if (!lst->search(result)) { |
duke@435 | 433 | if (cost == NULL) { |
duke@435 | 434 | cost = ((AttributeForm*)_globalNames[AttributeForm::_op_cost])->_attrdef; |
duke@435 | 435 | } |
duke@435 | 436 | lst->insert(result, cost, result); |
duke@435 | 437 | } |
duke@435 | 438 | } |
duke@435 | 439 | |
duke@435 | 440 | //------------------------------build_chain_rule------------------------------- |
duke@435 | 441 | void ArchDesc::build_chain_rule(OperandForm *oper) { |
duke@435 | 442 | MatchRule *rule; |
duke@435 | 443 | |
duke@435 | 444 | // Check for chain rules here |
duke@435 | 445 | // If this is only a chain rule |
duke@435 | 446 | if ((oper->_matrule) && (oper->_matrule->_lChild == NULL) && |
duke@435 | 447 | (oper->_matrule->_rChild == NULL)) { |
duke@435 | 448 | |
twisti@1038 | 449 | { |
twisti@1038 | 450 | const Form *form = _globalNames[oper->_matrule->_opType]; |
twisti@1038 | 451 | if ((form) && form->is_operand() && |
twisti@1038 | 452 | (form->ideal_only() == false)) { |
twisti@1038 | 453 | add_chain_rule_entry(oper->_matrule->_opType, oper->cost(), oper->_ident); |
twisti@1038 | 454 | } |
duke@435 | 455 | } |
duke@435 | 456 | // Check for additional chain rules |
duke@435 | 457 | if (oper->_matrule->_next) { |
duke@435 | 458 | rule = oper->_matrule; |
duke@435 | 459 | do { |
duke@435 | 460 | rule = rule->_next; |
duke@435 | 461 | // Any extra match rules after the first must be chain rules |
duke@435 | 462 | const Form *form = _globalNames[rule->_opType]; |
duke@435 | 463 | if ((form) && form->is_operand() && |
duke@435 | 464 | (form->ideal_only() == false)) { |
duke@435 | 465 | add_chain_rule_entry(rule->_opType, oper->cost(), oper->_ident); |
duke@435 | 466 | } |
duke@435 | 467 | } while(rule->_next != NULL); |
duke@435 | 468 | } |
duke@435 | 469 | } |
duke@435 | 470 | else if ((oper->_matrule) && (oper->_matrule->_next)) { |
duke@435 | 471 | // Regardles of whether the first matchrule is a chain rule, check the list |
duke@435 | 472 | rule = oper->_matrule; |
duke@435 | 473 | do { |
duke@435 | 474 | rule = rule->_next; |
duke@435 | 475 | // Any extra match rules after the first must be chain rules |
duke@435 | 476 | const Form *form = _globalNames[rule->_opType]; |
duke@435 | 477 | if ((form) && form->is_operand() && |
duke@435 | 478 | (form->ideal_only() == false)) { |
duke@435 | 479 | assert( oper->cost(), "This case expects NULL cost, not default cost"); |
duke@435 | 480 | add_chain_rule_entry(rule->_opType, oper->cost(), oper->_ident); |
duke@435 | 481 | } |
duke@435 | 482 | } while(rule->_next != NULL); |
duke@435 | 483 | } |
duke@435 | 484 | |
duke@435 | 485 | } |
duke@435 | 486 | |
duke@435 | 487 | //------------------------------buildMatchList--------------------------------- |
duke@435 | 488 | // operands and instructions provide the result |
duke@435 | 489 | void ArchDesc::buildMatchList(MatchRule *mrule, const char *resultStr, |
duke@435 | 490 | const char *rootOp, Predicate *pred, |
duke@435 | 491 | const char *cost) { |
duke@435 | 492 | const char *leftstr, *rightstr; |
duke@435 | 493 | MatchNode *mnode; |
duke@435 | 494 | |
duke@435 | 495 | leftstr = rightstr = NULL; |
duke@435 | 496 | // Check for chain rule, and do not generate a match list for it |
duke@435 | 497 | if ( mrule->is_chain_rule(_globalNames) ) { |
duke@435 | 498 | return; |
duke@435 | 499 | } |
duke@435 | 500 | |
duke@435 | 501 | // Identify index position among ideal operands |
duke@435 | 502 | intptr_t index = _last_opcode; |
duke@435 | 503 | const char *indexStr = getMatchListIndex(*mrule); |
duke@435 | 504 | index = (intptr_t)_idealIndex[indexStr]; |
duke@435 | 505 | if (index == 0) { |
duke@435 | 506 | fprintf(stderr, "Ideal node missing: %s\n", indexStr); |
duke@435 | 507 | assert(index != 0, "Failed lookup of ideal node\n"); |
duke@435 | 508 | } |
duke@435 | 509 | |
duke@435 | 510 | // Check that this will be placed appropriately in the DFA |
duke@435 | 511 | if (index >= _last_opcode) { |
duke@435 | 512 | fprintf(stderr, "Invalid match rule %s <-- ( %s )\n", |
duke@435 | 513 | resultStr ? resultStr : " ", |
duke@435 | 514 | rootOp ? rootOp : " "); |
duke@435 | 515 | assert(index < _last_opcode, "Matching item not in ideal graph\n"); |
duke@435 | 516 | return; |
duke@435 | 517 | } |
duke@435 | 518 | |
duke@435 | 519 | |
duke@435 | 520 | // Walk the MatchRule, generating MatchList entries for each level |
duke@435 | 521 | // of the rule (each nesting of parentheses) |
duke@435 | 522 | // Check for "Set" |
duke@435 | 523 | if (!strcmp(mrule->_opType, "Set")) { |
duke@435 | 524 | mnode = mrule->_rChild; |
duke@435 | 525 | buildMList(mnode, rootOp, resultStr, pred, cost); |
duke@435 | 526 | return; |
duke@435 | 527 | } |
duke@435 | 528 | // Build MatchLists for children |
duke@435 | 529 | // Check each child for an internal operand name, and use that name |
duke@435 | 530 | // for the parent's matchlist entry if it exists |
duke@435 | 531 | mnode = mrule->_lChild; |
duke@435 | 532 | if (mnode) { |
duke@435 | 533 | buildMList(mnode, NULL, NULL, NULL, NULL); |
duke@435 | 534 | leftstr = mnode->_internalop ? mnode->_internalop : mnode->_opType; |
duke@435 | 535 | } |
duke@435 | 536 | mnode = mrule->_rChild; |
duke@435 | 537 | if (mnode) { |
duke@435 | 538 | buildMList(mnode, NULL, NULL, NULL, NULL); |
duke@435 | 539 | rightstr = mnode->_internalop ? mnode->_internalop : mnode->_opType; |
duke@435 | 540 | } |
duke@435 | 541 | // Search for an identical matchlist entry already on the list |
duke@435 | 542 | if ((_mlistab[index] == NULL) || |
duke@435 | 543 | (_mlistab[index] && |
duke@435 | 544 | !_mlistab[index]->search(rootOp, resultStr, leftstr, rightstr, pred))) { |
duke@435 | 545 | // Place this match rule at front of list |
duke@435 | 546 | MatchList *mList = |
duke@435 | 547 | new MatchList(_mlistab[index], pred, cost, |
duke@435 | 548 | rootOp, resultStr, leftstr, rightstr); |
duke@435 | 549 | _mlistab[index] = mList; |
duke@435 | 550 | } |
duke@435 | 551 | } |
duke@435 | 552 | |
duke@435 | 553 | // Recursive call for construction of match lists |
duke@435 | 554 | void ArchDesc::buildMList(MatchNode *node, const char *rootOp, |
duke@435 | 555 | const char *resultOp, Predicate *pred, |
duke@435 | 556 | const char *cost) { |
duke@435 | 557 | const char *leftstr, *rightstr; |
duke@435 | 558 | const char *resultop; |
duke@435 | 559 | const char *opcode; |
duke@435 | 560 | MatchNode *mnode; |
duke@435 | 561 | Form *form; |
duke@435 | 562 | |
duke@435 | 563 | leftstr = rightstr = NULL; |
duke@435 | 564 | // Do not process leaves of the Match Tree if they are not ideal |
duke@435 | 565 | if ((node) && (node->_lChild == NULL) && (node->_rChild == NULL) && |
duke@435 | 566 | ((form = (Form *)_globalNames[node->_opType]) != NULL) && |
duke@435 | 567 | (!form->ideal_only())) { |
duke@435 | 568 | return; |
duke@435 | 569 | } |
duke@435 | 570 | |
duke@435 | 571 | // Identify index position among ideal operands |
duke@435 | 572 | intptr_t index = _last_opcode; |
duke@435 | 573 | const char *indexStr = node ? node->_opType : (char *) " "; |
duke@435 | 574 | index = (intptr_t)_idealIndex[indexStr]; |
duke@435 | 575 | if (index == 0) { |
duke@435 | 576 | fprintf(stderr, "error: operand \"%s\" not found\n", indexStr); |
duke@435 | 577 | assert(0, "fatal error"); |
duke@435 | 578 | } |
duke@435 | 579 | |
duke@435 | 580 | // Build MatchLists for children |
duke@435 | 581 | // Check each child for an internal operand name, and use that name |
duke@435 | 582 | // for the parent's matchlist entry if it exists |
duke@435 | 583 | mnode = node->_lChild; |
duke@435 | 584 | if (mnode) { |
duke@435 | 585 | buildMList(mnode, NULL, NULL, NULL, NULL); |
duke@435 | 586 | leftstr = mnode->_internalop ? mnode->_internalop : mnode->_opType; |
duke@435 | 587 | } |
duke@435 | 588 | mnode = node->_rChild; |
duke@435 | 589 | if (mnode) { |
duke@435 | 590 | buildMList(mnode, NULL, NULL, NULL, NULL); |
duke@435 | 591 | rightstr = mnode->_internalop ? mnode->_internalop : mnode->_opType; |
duke@435 | 592 | } |
duke@435 | 593 | // Grab the string for the opcode of this list entry |
duke@435 | 594 | if (rootOp == NULL) { |
duke@435 | 595 | opcode = (node->_internalop) ? node->_internalop : node->_opType; |
duke@435 | 596 | } else { |
duke@435 | 597 | opcode = rootOp; |
duke@435 | 598 | } |
duke@435 | 599 | // Grab the string for the result of this list entry |
duke@435 | 600 | if (resultOp == NULL) { |
duke@435 | 601 | resultop = (node->_internalop) ? node->_internalop : node->_opType; |
duke@435 | 602 | } |
duke@435 | 603 | else resultop = resultOp; |
duke@435 | 604 | // Search for an identical matchlist entry already on the list |
duke@435 | 605 | if ((_mlistab[index] == NULL) || (_mlistab[index] && |
duke@435 | 606 | !_mlistab[index]->search(opcode, resultop, leftstr, rightstr, pred))) { |
duke@435 | 607 | // Place this match rule at front of list |
duke@435 | 608 | MatchList *mList = |
duke@435 | 609 | new MatchList(_mlistab[index],pred,cost, |
duke@435 | 610 | opcode, resultop, leftstr, rightstr); |
duke@435 | 611 | _mlistab[index] = mList; |
duke@435 | 612 | } |
duke@435 | 613 | } |
duke@435 | 614 | |
duke@435 | 615 | // Count number of OperandForms defined |
duke@435 | 616 | int ArchDesc::operandFormCount() { |
duke@435 | 617 | // Only interested in ones with non-NULL match rule |
duke@435 | 618 | int count = 0; _operands.reset(); |
duke@435 | 619 | OperandForm *cur; |
duke@435 | 620 | for( ; (cur = (OperandForm*)_operands.iter()) != NULL; ) { |
duke@435 | 621 | if (cur->_matrule != NULL) ++count; |
duke@435 | 622 | }; |
duke@435 | 623 | return count; |
duke@435 | 624 | } |
duke@435 | 625 | |
duke@435 | 626 | // Count number of OpClassForms defined |
duke@435 | 627 | int ArchDesc::opclassFormCount() { |
duke@435 | 628 | // Only interested in ones with non-NULL match rule |
duke@435 | 629 | int count = 0; _operands.reset(); |
duke@435 | 630 | OpClassForm *cur; |
duke@435 | 631 | for( ; (cur = (OpClassForm*)_opclass.iter()) != NULL; ) { |
duke@435 | 632 | ++count; |
duke@435 | 633 | }; |
duke@435 | 634 | return count; |
duke@435 | 635 | } |
duke@435 | 636 | |
duke@435 | 637 | // Count number of InstructForms defined |
duke@435 | 638 | int ArchDesc::instructFormCount() { |
duke@435 | 639 | // Only interested in ones with non-NULL match rule |
duke@435 | 640 | int count = 0; _instructions.reset(); |
duke@435 | 641 | InstructForm *cur; |
duke@435 | 642 | for( ; (cur = (InstructForm*)_instructions.iter()) != NULL; ) { |
duke@435 | 643 | if (cur->_matrule != NULL) ++count; |
duke@435 | 644 | }; |
duke@435 | 645 | return count; |
duke@435 | 646 | } |
duke@435 | 647 | |
duke@435 | 648 | |
duke@435 | 649 | //------------------------------get_preproc_def-------------------------------- |
duke@435 | 650 | // Return the textual binding for a given CPP flag name. |
duke@435 | 651 | // Return NULL if there is no binding, or it has been #undef-ed. |
duke@435 | 652 | char* ArchDesc::get_preproc_def(const char* flag) { |
kvn@4161 | 653 | // In case of syntax errors, flag may take the value NULL. |
kvn@4161 | 654 | SourceForm* deff = NULL; |
kvn@4161 | 655 | if (flag != NULL) |
kvn@4161 | 656 | deff = (SourceForm*) _preproc_table[flag]; |
duke@435 | 657 | return (deff == NULL) ? NULL : deff->_code; |
duke@435 | 658 | } |
duke@435 | 659 | |
duke@435 | 660 | |
duke@435 | 661 | //------------------------------set_preproc_def-------------------------------- |
duke@435 | 662 | // Change or create a textual binding for a given CPP flag name. |
duke@435 | 663 | // Giving NULL means the flag name is to be #undef-ed. |
duke@435 | 664 | // In any case, _preproc_list collects all names either #defined or #undef-ed. |
duke@435 | 665 | void ArchDesc::set_preproc_def(const char* flag, const char* def) { |
duke@435 | 666 | SourceForm* deff = (SourceForm*) _preproc_table[flag]; |
duke@435 | 667 | if (deff == NULL) { |
duke@435 | 668 | deff = new SourceForm(NULL); |
duke@435 | 669 | _preproc_table.Insert(flag, deff); |
duke@435 | 670 | _preproc_list.addName(flag); // this supports iteration |
duke@435 | 671 | } |
duke@435 | 672 | deff->_code = (char*) def; |
duke@435 | 673 | } |
duke@435 | 674 | |
duke@435 | 675 | |
duke@435 | 676 | bool ArchDesc::verify() { |
duke@435 | 677 | |
duke@435 | 678 | if (_register) |
duke@435 | 679 | assert( _register->verify(), "Register declarations failed verification"); |
duke@435 | 680 | if (!_quiet_mode) |
duke@435 | 681 | fprintf(stderr,"\n"); |
duke@435 | 682 | // fprintf(stderr,"---------------------------- Verify Operands ---------------\n"); |
duke@435 | 683 | // _operands.verify(); |
duke@435 | 684 | // fprintf(stderr,"\n"); |
duke@435 | 685 | // fprintf(stderr,"---------------------------- Verify Operand Classes --------\n"); |
duke@435 | 686 | // _opclass.verify(); |
duke@435 | 687 | // fprintf(stderr,"\n"); |
duke@435 | 688 | // fprintf(stderr,"---------------------------- Verify Attributes ------------\n"); |
duke@435 | 689 | // _attributes.verify(); |
duke@435 | 690 | // fprintf(stderr,"\n"); |
duke@435 | 691 | if (!_quiet_mode) |
duke@435 | 692 | fprintf(stderr,"---------------------------- Verify Instructions ----------------------------\n"); |
duke@435 | 693 | _instructions.verify(); |
duke@435 | 694 | if (!_quiet_mode) |
duke@435 | 695 | fprintf(stderr,"\n"); |
duke@435 | 696 | // if ( _encode ) { |
duke@435 | 697 | // fprintf(stderr,"---------------------------- Verify Encodings --------------\n"); |
duke@435 | 698 | // _encode->verify(); |
duke@435 | 699 | // } |
duke@435 | 700 | |
duke@435 | 701 | //if (_pipeline) _pipeline->verify(); |
duke@435 | 702 | |
duke@435 | 703 | return true; |
duke@435 | 704 | } |
duke@435 | 705 | |
duke@435 | 706 | |
duke@435 | 707 | void ArchDesc::dump() { |
duke@435 | 708 | _pre_header.dump(); |
duke@435 | 709 | _header.dump(); |
duke@435 | 710 | _source.dump(); |
duke@435 | 711 | if (_register) _register->dump(); |
duke@435 | 712 | fprintf(stderr,"\n"); |
duke@435 | 713 | fprintf(stderr,"------------------ Dump Operands ---------------------\n"); |
duke@435 | 714 | _operands.dump(); |
duke@435 | 715 | fprintf(stderr,"\n"); |
duke@435 | 716 | fprintf(stderr,"------------------ Dump Operand Classes --------------\n"); |
duke@435 | 717 | _opclass.dump(); |
duke@435 | 718 | fprintf(stderr,"\n"); |
duke@435 | 719 | fprintf(stderr,"------------------ Dump Attributes ------------------\n"); |
duke@435 | 720 | _attributes.dump(); |
duke@435 | 721 | fprintf(stderr,"\n"); |
duke@435 | 722 | fprintf(stderr,"------------------ Dump Instructions -----------------\n"); |
duke@435 | 723 | _instructions.dump(); |
duke@435 | 724 | if ( _encode ) { |
duke@435 | 725 | fprintf(stderr,"------------------ Dump Encodings --------------------\n"); |
duke@435 | 726 | _encode->dump(); |
duke@435 | 727 | } |
duke@435 | 728 | if (_pipeline) _pipeline->dump(); |
duke@435 | 729 | } |
duke@435 | 730 | |
duke@435 | 731 | |
duke@435 | 732 | //------------------------------init_keywords---------------------------------- |
duke@435 | 733 | // Load the kewords into the global name table |
duke@435 | 734 | void ArchDesc::initKeywords(FormDict& names) { |
duke@435 | 735 | // Insert keyword strings into Global Name Table. Keywords have a NULL value |
duke@435 | 736 | // field for quick easy identification when checking identifiers. |
duke@435 | 737 | names.Insert("instruct", NULL); |
duke@435 | 738 | names.Insert("operand", NULL); |
duke@435 | 739 | names.Insert("attribute", NULL); |
duke@435 | 740 | names.Insert("source", NULL); |
duke@435 | 741 | names.Insert("register", NULL); |
duke@435 | 742 | names.Insert("pipeline", NULL); |
duke@435 | 743 | names.Insert("constraint", NULL); |
duke@435 | 744 | names.Insert("predicate", NULL); |
duke@435 | 745 | names.Insert("encode", NULL); |
duke@435 | 746 | names.Insert("enc_class", NULL); |
duke@435 | 747 | names.Insert("interface", NULL); |
duke@435 | 748 | names.Insert("opcode", NULL); |
duke@435 | 749 | names.Insert("ins_encode", NULL); |
duke@435 | 750 | names.Insert("match", NULL); |
duke@435 | 751 | names.Insert("effect", NULL); |
duke@435 | 752 | names.Insert("expand", NULL); |
duke@435 | 753 | names.Insert("rewrite", NULL); |
duke@435 | 754 | names.Insert("reg_def", NULL); |
duke@435 | 755 | names.Insert("reg_class", NULL); |
duke@435 | 756 | names.Insert("alloc_class", NULL); |
duke@435 | 757 | names.Insert("resource", NULL); |
duke@435 | 758 | names.Insert("pipe_class", NULL); |
duke@435 | 759 | names.Insert("pipe_desc", NULL); |
duke@435 | 760 | } |
duke@435 | 761 | |
duke@435 | 762 | |
duke@435 | 763 | //------------------------------internal_err---------------------------------- |
duke@435 | 764 | // Issue a parser error message, and skip to the end of the current line |
duke@435 | 765 | void ArchDesc::internal_err(const char *fmt, ...) { |
duke@435 | 766 | va_list args; |
duke@435 | 767 | |
duke@435 | 768 | va_start(args, fmt); |
duke@435 | 769 | _internal_errs += emit_msg(0, INTERNAL_ERR, 0, fmt, args); |
duke@435 | 770 | va_end(args); |
duke@435 | 771 | |
duke@435 | 772 | _no_output = 1; |
duke@435 | 773 | } |
duke@435 | 774 | |
duke@435 | 775 | //------------------------------syntax_err---------------------------------- |
duke@435 | 776 | // Issue a parser error message, and skip to the end of the current line |
duke@435 | 777 | void ArchDesc::syntax_err(int lineno, const char *fmt, ...) { |
duke@435 | 778 | va_list args; |
duke@435 | 779 | |
duke@435 | 780 | va_start(args, fmt); |
duke@435 | 781 | _internal_errs += emit_msg(0, SYNERR, lineno, fmt, args); |
duke@435 | 782 | va_end(args); |
duke@435 | 783 | |
duke@435 | 784 | _no_output = 1; |
duke@435 | 785 | } |
duke@435 | 786 | |
duke@435 | 787 | //------------------------------emit_msg--------------------------------------- |
duke@435 | 788 | // Emit a user message, typically a warning or error |
duke@435 | 789 | int ArchDesc::emit_msg(int quiet, int flag, int line, const char *fmt, |
duke@435 | 790 | va_list args) { |
duke@435 | 791 | static int last_lineno = -1; |
duke@435 | 792 | int i; |
duke@435 | 793 | const char *pref; |
duke@435 | 794 | |
duke@435 | 795 | switch(flag) { |
duke@435 | 796 | case 0: pref = "Warning: "; break; |
duke@435 | 797 | case 1: pref = "Syntax Error: "; break; |
duke@435 | 798 | case 2: pref = "Semantic Error: "; break; |
duke@435 | 799 | case 3: pref = "Internal Error: "; break; |
duke@435 | 800 | default: assert(0, ""); break; |
duke@435 | 801 | } |
duke@435 | 802 | |
duke@435 | 803 | if (line == last_lineno) return 0; |
duke@435 | 804 | last_lineno = line; |
duke@435 | 805 | |
duke@435 | 806 | if (!quiet) { /* no output if in quiet mode */ |
duke@435 | 807 | i = fprintf(errfile, "%s(%d) ", _ADL_file._name, line); |
duke@435 | 808 | while (i++ <= 15) fputc(' ', errfile); |
duke@435 | 809 | fprintf(errfile, "%-8s:", pref); |
duke@435 | 810 | vfprintf(errfile, fmt, args); |
kvn@4161 | 811 | fprintf(errfile, "\n"); |
kvn@4161 | 812 | fflush(errfile); |
kvn@4161 | 813 | } |
duke@435 | 814 | return 1; |
duke@435 | 815 | } |
duke@435 | 816 | |
duke@435 | 817 | |
duke@435 | 818 | // --------------------------------------------------------------------------- |
duke@435 | 819 | //--------Utilities to build mappings for machine registers ------------------ |
duke@435 | 820 | // --------------------------------------------------------------------------- |
duke@435 | 821 | |
duke@435 | 822 | // Construct the name of the register mask. |
duke@435 | 823 | static const char *getRegMask(const char *reg_class_name) { |
duke@435 | 824 | if( reg_class_name == NULL ) return "RegMask::Empty"; |
duke@435 | 825 | |
duke@435 | 826 | if (strcmp(reg_class_name,"Universe")==0) { |
duke@435 | 827 | return "RegMask::Empty"; |
duke@435 | 828 | } else if (strcmp(reg_class_name,"stack_slots")==0) { |
duke@435 | 829 | return "(Compile::current()->FIRST_STACK_mask())"; |
duke@435 | 830 | } else { |
duke@435 | 831 | char *rc_name = toUpper(reg_class_name); |
duke@435 | 832 | const char *mask = "_mask"; |
roland@3317 | 833 | int length = (int)strlen(rc_name) + (int)strlen(mask) + 5; |
duke@435 | 834 | char *regMask = new char[length]; |
roland@3317 | 835 | sprintf(regMask,"%s%s()", rc_name, mask); |
neliasso@4875 | 836 | delete[] rc_name; |
duke@435 | 837 | return regMask; |
duke@435 | 838 | } |
duke@435 | 839 | } |
duke@435 | 840 | |
duke@435 | 841 | // Convert a register class name to its register mask. |
duke@435 | 842 | const char *ArchDesc::reg_class_to_reg_mask(const char *rc_name) { |
duke@435 | 843 | const char *reg_mask = "RegMask::Empty"; |
duke@435 | 844 | |
duke@435 | 845 | if( _register ) { |
duke@435 | 846 | RegClass *reg_class = _register->getRegClass(rc_name); |
duke@435 | 847 | if (reg_class == NULL) { |
duke@435 | 848 | syntax_err(0, "Use of an undefined register class %s", rc_name); |
duke@435 | 849 | return reg_mask; |
duke@435 | 850 | } |
duke@435 | 851 | |
duke@435 | 852 | // Construct the name of the register mask. |
duke@435 | 853 | reg_mask = getRegMask(rc_name); |
duke@435 | 854 | } |
duke@435 | 855 | |
duke@435 | 856 | return reg_mask; |
duke@435 | 857 | } |
duke@435 | 858 | |
duke@435 | 859 | |
duke@435 | 860 | // Obtain the name of the RegMask for an OperandForm |
duke@435 | 861 | const char *ArchDesc::reg_mask(OperandForm &opForm) { |
duke@435 | 862 | const char *regMask = "RegMask::Empty"; |
duke@435 | 863 | |
duke@435 | 864 | // Check constraints on result's register class |
duke@435 | 865 | const char *result_class = opForm.constrained_reg_class(); |
kvn@4161 | 866 | if (result_class == NULL) { |
kvn@4161 | 867 | opForm.dump(); |
kvn@4161 | 868 | syntax_err(opForm._linenum, |
kvn@4161 | 869 | "Use of an undefined result class for operand: %s", |
kvn@4161 | 870 | opForm._ident); |
kvn@4161 | 871 | abort(); |
kvn@4161 | 872 | } |
kvn@4161 | 873 | |
duke@435 | 874 | regMask = reg_class_to_reg_mask( result_class ); |
duke@435 | 875 | |
duke@435 | 876 | return regMask; |
duke@435 | 877 | } |
duke@435 | 878 | |
duke@435 | 879 | // Obtain the name of the RegMask for an InstructForm |
duke@435 | 880 | const char *ArchDesc::reg_mask(InstructForm &inForm) { |
duke@435 | 881 | const char *result = inForm.reduce_result(); |
kvn@4161 | 882 | |
kvn@4161 | 883 | if (result == NULL) { |
kvn@4161 | 884 | syntax_err(inForm._linenum, |
kvn@4161 | 885 | "Did not find result operand or RegMask" |
kvn@4161 | 886 | " for this instruction: %s", |
kvn@4161 | 887 | inForm._ident); |
kvn@4161 | 888 | abort(); |
kvn@4161 | 889 | } |
duke@435 | 890 | |
duke@435 | 891 | // Instructions producing 'Universe' use RegMask::Empty |
duke@435 | 892 | if( strcmp(result,"Universe")==0 ) { |
duke@435 | 893 | return "RegMask::Empty"; |
duke@435 | 894 | } |
duke@435 | 895 | |
duke@435 | 896 | // Lookup this result operand and get its register class |
duke@435 | 897 | Form *form = (Form*)_globalNames[result]; |
kvn@4161 | 898 | if (form == NULL) { |
kvn@4161 | 899 | syntax_err(inForm._linenum, |
kvn@4161 | 900 | "Did not find result operand for result: %s", result); |
kvn@4161 | 901 | abort(); |
kvn@4161 | 902 | } |
duke@435 | 903 | OperandForm *oper = form->is_operand(); |
kvn@4161 | 904 | if (oper == NULL) { |
kvn@4161 | 905 | syntax_err(inForm._linenum, "Form is not an OperandForm:"); |
kvn@4161 | 906 | form->dump(); |
kvn@4161 | 907 | abort(); |
kvn@4161 | 908 | } |
duke@435 | 909 | return reg_mask( *oper ); |
duke@435 | 910 | } |
duke@435 | 911 | |
duke@435 | 912 | |
duke@435 | 913 | // Obtain the STACK_OR_reg_mask name for an OperandForm |
duke@435 | 914 | char *ArchDesc::stack_or_reg_mask(OperandForm &opForm) { |
duke@435 | 915 | // name of cisc_spillable version |
duke@435 | 916 | const char *reg_mask_name = reg_mask(opForm); |
kvn@4161 | 917 | |
kvn@4161 | 918 | if (reg_mask_name == NULL) { |
kvn@4161 | 919 | syntax_err(opForm._linenum, |
kvn@4161 | 920 | "Did not find reg_mask for opForm: %s", |
kvn@4161 | 921 | opForm._ident); |
kvn@4161 | 922 | abort(); |
kvn@4161 | 923 | } |
duke@435 | 924 | |
duke@435 | 925 | const char *stack_or = "STACK_OR_"; |
duke@435 | 926 | int length = (int)strlen(stack_or) + (int)strlen(reg_mask_name) + 1; |
duke@435 | 927 | char *result = new char[length]; |
duke@435 | 928 | sprintf(result,"%s%s", stack_or, reg_mask_name); |
duke@435 | 929 | |
duke@435 | 930 | return result; |
duke@435 | 931 | } |
duke@435 | 932 | |
duke@435 | 933 | // Record that the register class must generate a stack_or_reg_mask |
duke@435 | 934 | void ArchDesc::set_stack_or_reg(const char *reg_class_name) { |
duke@435 | 935 | if( _register ) { |
duke@435 | 936 | RegClass *reg_class = _register->getRegClass(reg_class_name); |
zmajo@7853 | 937 | reg_class->set_stack_version(true); |
duke@435 | 938 | } |
duke@435 | 939 | } |
duke@435 | 940 | |
duke@435 | 941 | |
duke@435 | 942 | // Return the type signature for the ideal operation |
duke@435 | 943 | const char *ArchDesc::getIdealType(const char *idealOp) { |
duke@435 | 944 | // Find last character in idealOp, it specifies the type |
duke@435 | 945 | char last_char = 0; |
duke@435 | 946 | const char *ptr = idealOp; |
kvn@3882 | 947 | for (; *ptr != '\0'; ++ptr) { |
duke@435 | 948 | last_char = *ptr; |
duke@435 | 949 | } |
duke@435 | 950 | |
kvn@3882 | 951 | // Match Vector types. |
kvn@3882 | 952 | if (strncmp(idealOp, "Vec",3)==0) { |
kvn@3882 | 953 | switch(last_char) { |
kvn@3882 | 954 | case 'S': return "TypeVect::VECTS"; |
kvn@3882 | 955 | case 'D': return "TypeVect::VECTD"; |
kvn@3882 | 956 | case 'X': return "TypeVect::VECTX"; |
kvn@3882 | 957 | case 'Y': return "TypeVect::VECTY"; |
kvn@3882 | 958 | default: |
kvn@3882 | 959 | internal_err("Vector type %s with unrecognized type\n",idealOp); |
kvn@3882 | 960 | } |
kvn@3882 | 961 | } |
kvn@3882 | 962 | |
duke@435 | 963 | // !!!!! |
kvn@3882 | 964 | switch(last_char) { |
duke@435 | 965 | case 'I': return "TypeInt::INT"; |
duke@435 | 966 | case 'P': return "TypePtr::BOTTOM"; |
coleenp@548 | 967 | case 'N': return "TypeNarrowOop::BOTTOM"; |
duke@435 | 968 | case 'F': return "Type::FLOAT"; |
duke@435 | 969 | case 'D': return "Type::DOUBLE"; |
duke@435 | 970 | case 'L': return "TypeLong::LONG"; |
duke@435 | 971 | case 's': return "TypeInt::CC /*flags*/"; |
duke@435 | 972 | default: |
duke@435 | 973 | return NULL; |
duke@435 | 974 | // !!!!! |
duke@435 | 975 | // internal_err("Ideal type %s with unrecognized type\n",idealOp); |
duke@435 | 976 | break; |
duke@435 | 977 | } |
duke@435 | 978 | |
duke@435 | 979 | return NULL; |
duke@435 | 980 | } |
duke@435 | 981 | |
duke@435 | 982 | |
duke@435 | 983 | |
duke@435 | 984 | OperandForm *ArchDesc::constructOperand(const char *ident, |
duke@435 | 985 | bool ideal_only) { |
duke@435 | 986 | OperandForm *opForm = new OperandForm(ident, ideal_only); |
duke@435 | 987 | _globalNames.Insert(ident, opForm); |
duke@435 | 988 | addForm(opForm); |
duke@435 | 989 | |
duke@435 | 990 | return opForm; |
duke@435 | 991 | } |
duke@435 | 992 | |
duke@435 | 993 | |
duke@435 | 994 | // Import predefined base types: Set = 1, RegI, RegP, ... |
duke@435 | 995 | void ArchDesc::initBaseOpTypes() { |
duke@435 | 996 | // Create OperandForm and assign type for each opcode. |
duke@435 | 997 | for (int i = 1; i < _last_machine_leaf; ++i) { |
duke@435 | 998 | char *ident = (char *)NodeClassNames[i]; |
duke@435 | 999 | constructOperand(ident, true); |
duke@435 | 1000 | } |
duke@435 | 1001 | // Create InstructForm and assign type for each ideal instruction. |
duke@435 | 1002 | for ( int j = _last_machine_leaf+1; j < _last_opcode; ++j) { |
duke@435 | 1003 | char *ident = (char *)NodeClassNames[j]; |
roland@4159 | 1004 | if(!strcmp(ident, "ConI") || !strcmp(ident, "ConP") || |
roland@4159 | 1005 | !strcmp(ident, "ConN") || !strcmp(ident, "ConNKlass") || |
duke@435 | 1006 | !strcmp(ident, "ConF") || !strcmp(ident, "ConD") || |
duke@435 | 1007 | !strcmp(ident, "ConL") || !strcmp(ident, "Con" ) || |
duke@435 | 1008 | !strcmp(ident, "Bool") ) { |
duke@435 | 1009 | constructOperand(ident, true); |
duke@435 | 1010 | } |
duke@435 | 1011 | else { |
duke@435 | 1012 | InstructForm *insForm = new InstructForm(ident, true); |
duke@435 | 1013 | // insForm->_opcode = nextUserOpType(ident); |
duke@435 | 1014 | _globalNames.Insert(ident,insForm); |
duke@435 | 1015 | addForm(insForm); |
duke@435 | 1016 | } |
duke@435 | 1017 | } |
duke@435 | 1018 | |
duke@435 | 1019 | { OperandForm *opForm; |
duke@435 | 1020 | // Create operand type "Universe" for return instructions. |
duke@435 | 1021 | const char *ident = "Universe"; |
duke@435 | 1022 | opForm = constructOperand(ident, false); |
duke@435 | 1023 | |
duke@435 | 1024 | // Create operand type "label" for branch targets |
duke@435 | 1025 | ident = "label"; |
duke@435 | 1026 | opForm = constructOperand(ident, false); |
duke@435 | 1027 | |
duke@435 | 1028 | // !!!!! Update - when adding a new sReg/stackSlot type |
duke@435 | 1029 | // Create operand types "sReg[IPFDL]" for stack slot registers |
duke@435 | 1030 | opForm = constructOperand("sRegI", false); |
duke@435 | 1031 | opForm->_constraint = new Constraint("ALLOC_IN_RC", "stack_slots"); |
duke@435 | 1032 | opForm = constructOperand("sRegP", false); |
duke@435 | 1033 | opForm->_constraint = new Constraint("ALLOC_IN_RC", "stack_slots"); |
duke@435 | 1034 | opForm = constructOperand("sRegF", false); |
duke@435 | 1035 | opForm->_constraint = new Constraint("ALLOC_IN_RC", "stack_slots"); |
duke@435 | 1036 | opForm = constructOperand("sRegD", false); |
duke@435 | 1037 | opForm->_constraint = new Constraint("ALLOC_IN_RC", "stack_slots"); |
duke@435 | 1038 | opForm = constructOperand("sRegL", false); |
duke@435 | 1039 | opForm->_constraint = new Constraint("ALLOC_IN_RC", "stack_slots"); |
duke@435 | 1040 | |
duke@435 | 1041 | // Create operand type "method" for call targets |
duke@435 | 1042 | ident = "method"; |
duke@435 | 1043 | opForm = constructOperand(ident, false); |
duke@435 | 1044 | } |
duke@435 | 1045 | |
duke@435 | 1046 | // Create Effect Forms for each of the legal effects |
duke@435 | 1047 | // USE, DEF, USE_DEF, KILL, USE_KILL |
duke@435 | 1048 | { |
duke@435 | 1049 | const char *ident = "USE"; |
duke@435 | 1050 | Effect *eForm = new Effect(ident); |
duke@435 | 1051 | _globalNames.Insert(ident, eForm); |
duke@435 | 1052 | ident = "DEF"; |
duke@435 | 1053 | eForm = new Effect(ident); |
duke@435 | 1054 | _globalNames.Insert(ident, eForm); |
duke@435 | 1055 | ident = "USE_DEF"; |
duke@435 | 1056 | eForm = new Effect(ident); |
duke@435 | 1057 | _globalNames.Insert(ident, eForm); |
duke@435 | 1058 | ident = "KILL"; |
duke@435 | 1059 | eForm = new Effect(ident); |
duke@435 | 1060 | _globalNames.Insert(ident, eForm); |
duke@435 | 1061 | ident = "USE_KILL"; |
duke@435 | 1062 | eForm = new Effect(ident); |
duke@435 | 1063 | _globalNames.Insert(ident, eForm); |
duke@435 | 1064 | ident = "TEMP"; |
duke@435 | 1065 | eForm = new Effect(ident); |
duke@435 | 1066 | _globalNames.Insert(ident, eForm); |
roland@3316 | 1067 | ident = "CALL"; |
roland@3316 | 1068 | eForm = new Effect(ident); |
roland@3316 | 1069 | _globalNames.Insert(ident, eForm); |
duke@435 | 1070 | } |
duke@435 | 1071 | |
duke@435 | 1072 | // |
duke@435 | 1073 | // Build mapping from ideal names to ideal indices |
duke@435 | 1074 | int idealIndex = 0; |
duke@435 | 1075 | for (idealIndex = 1; idealIndex < _last_machine_leaf; ++idealIndex) { |
duke@435 | 1076 | const char *idealName = NodeClassNames[idealIndex]; |
twisti@1038 | 1077 | _idealIndex.Insert((void*) idealName, (void*) (intptr_t) idealIndex); |
duke@435 | 1078 | } |
duke@435 | 1079 | for ( idealIndex = _last_machine_leaf+1; |
duke@435 | 1080 | idealIndex < _last_opcode; ++idealIndex) { |
duke@435 | 1081 | const char *idealName = NodeClassNames[idealIndex]; |
twisti@1038 | 1082 | _idealIndex.Insert((void*) idealName, (void*) (intptr_t) idealIndex); |
duke@435 | 1083 | } |
duke@435 | 1084 | |
duke@435 | 1085 | } |
duke@435 | 1086 | |
duke@435 | 1087 | |
duke@435 | 1088 | //---------------------------addSUNcopyright------------------------------- |
duke@435 | 1089 | // output SUN copyright info |
duke@435 | 1090 | void ArchDesc::addSunCopyright(char* legal, int size, FILE *fp) { |
andrew@1403 | 1091 | size_t count = fwrite(legal, 1, size, fp); |
andrew@1403 | 1092 | assert(count == (size_t) size, "copyright info truncated"); |
duke@435 | 1093 | fprintf(fp,"\n"); |
duke@435 | 1094 | fprintf(fp,"// Machine Generated File. Do Not Edit!\n"); |
duke@435 | 1095 | fprintf(fp,"\n"); |
duke@435 | 1096 | } |
duke@435 | 1097 | |
duke@435 | 1098 | |
stefank@2314 | 1099 | //---------------------------addIncludeGuardStart-------------------------- |
stefank@2314 | 1100 | // output the start of an include guard. |
stefank@2314 | 1101 | void ArchDesc::addIncludeGuardStart(ADLFILE &adlfile, const char* guardString) { |
duke@435 | 1102 | // Build #include lines |
duke@435 | 1103 | fprintf(adlfile._fp, "\n"); |
stefank@2314 | 1104 | fprintf(adlfile._fp, "#ifndef %s\n", guardString); |
stefank@2314 | 1105 | fprintf(adlfile._fp, "#define %s\n", guardString); |
duke@435 | 1106 | fprintf(adlfile._fp, "\n"); |
duke@435 | 1107 | |
duke@435 | 1108 | } |
duke@435 | 1109 | |
stefank@2314 | 1110 | //---------------------------addIncludeGuardEnd-------------------------- |
stefank@2314 | 1111 | // output the end of an include guard. |
stefank@2314 | 1112 | void ArchDesc::addIncludeGuardEnd(ADLFILE &adlfile, const char* guardString) { |
stefank@2314 | 1113 | // Build #include lines |
stefank@2314 | 1114 | fprintf(adlfile._fp, "\n"); |
stefank@2314 | 1115 | fprintf(adlfile._fp, "#endif // %s\n", guardString); |
stefank@2314 | 1116 | |
stefank@2314 | 1117 | } |
stefank@2314 | 1118 | |
stefank@2314 | 1119 | //---------------------------addInclude-------------------------- |
stefank@2314 | 1120 | // output the #include line for this file. |
stefank@2314 | 1121 | void ArchDesc::addInclude(ADLFILE &adlfile, const char* fileName) { |
stefank@2314 | 1122 | fprintf(adlfile._fp, "#include \"%s\"\n", fileName); |
stefank@2314 | 1123 | |
stefank@2314 | 1124 | } |
stefank@2314 | 1125 | |
stefank@2314 | 1126 | void ArchDesc::addInclude(ADLFILE &adlfile, const char* includeDir, const char* fileName) { |
stefank@2314 | 1127 | fprintf(adlfile._fp, "#include \"%s/%s\"\n", includeDir, fileName); |
stefank@2314 | 1128 | |
stefank@2314 | 1129 | } |
duke@435 | 1130 | |
duke@435 | 1131 | //---------------------------addPreprocessorChecks----------------------------- |
duke@435 | 1132 | // Output C preprocessor code to verify the backend compilation environment. |
duke@435 | 1133 | // The idea is to force code produced by "adlc -DHS64" to be compiled by a |
duke@435 | 1134 | // command of the form "CC ... -DHS64 ...", so that any #ifdefs in the source |
duke@435 | 1135 | // blocks select C code that is consistent with adlc's selections of AD code. |
duke@435 | 1136 | void ArchDesc::addPreprocessorChecks(FILE *fp) { |
duke@435 | 1137 | const char* flag; |
duke@435 | 1138 | _preproc_list.reset(); |
duke@435 | 1139 | if (_preproc_list.count() > 0 && !_preproc_list.current_is_signal()) { |
duke@435 | 1140 | fprintf(fp, "// Check consistency of C++ compilation with ADLC options:\n"); |
duke@435 | 1141 | } |
duke@435 | 1142 | for (_preproc_list.reset(); (flag = _preproc_list.iter()) != NULL; ) { |
duke@435 | 1143 | if (_preproc_list.current_is_signal()) break; |
duke@435 | 1144 | char* def = get_preproc_def(flag); |
duke@435 | 1145 | fprintf(fp, "// Check adlc "); |
duke@435 | 1146 | if (def) |
duke@435 | 1147 | fprintf(fp, "-D%s=%s\n", flag, def); |
duke@435 | 1148 | else fprintf(fp, "-U%s\n", flag); |
duke@435 | 1149 | fprintf(fp, "#%s %s\n", |
duke@435 | 1150 | def ? "ifndef" : "ifdef", flag); |
duke@435 | 1151 | fprintf(fp, "# error \"%s %s be defined\"\n", |
duke@435 | 1152 | flag, def ? "must" : "must not"); |
duke@435 | 1153 | fprintf(fp, "#endif // %s\n", flag); |
duke@435 | 1154 | } |
duke@435 | 1155 | } |
duke@435 | 1156 | |
duke@435 | 1157 | |
duke@435 | 1158 | // Convert operand name into enum name |
duke@435 | 1159 | const char *ArchDesc::machOperEnum(const char *opName) { |
duke@435 | 1160 | return ArchDesc::getMachOperEnum(opName); |
duke@435 | 1161 | } |
duke@435 | 1162 | |
duke@435 | 1163 | // Convert operand name into enum name |
duke@435 | 1164 | const char *ArchDesc::getMachOperEnum(const char *opName) { |
duke@435 | 1165 | return (opName ? toUpper(opName) : opName); |
duke@435 | 1166 | } |
duke@435 | 1167 | |
duke@435 | 1168 | //---------------------------buildMustCloneMap----------------------------- |
duke@435 | 1169 | // Flag cases when machine needs cloned values or instructions |
duke@435 | 1170 | void ArchDesc::buildMustCloneMap(FILE *fp_hpp, FILE *fp_cpp) { |
duke@435 | 1171 | // Build external declarations for mappings |
duke@435 | 1172 | fprintf(fp_hpp, "// Mapping from machine-independent opcode to boolean\n"); |
duke@435 | 1173 | fprintf(fp_hpp, "// Flag cases where machine needs cloned values or instructions\n"); |
duke@435 | 1174 | fprintf(fp_hpp, "extern const char must_clone[];\n"); |
duke@435 | 1175 | fprintf(fp_hpp, "\n"); |
duke@435 | 1176 | |
duke@435 | 1177 | // Build mapping from ideal names to ideal indices |
duke@435 | 1178 | fprintf(fp_cpp, "\n"); |
duke@435 | 1179 | fprintf(fp_cpp, "// Mapping from machine-independent opcode to boolean\n"); |
duke@435 | 1180 | fprintf(fp_cpp, "const char must_clone[] = {\n"); |
duke@435 | 1181 | for (int idealIndex = 0; idealIndex < _last_opcode; ++idealIndex) { |
duke@435 | 1182 | int must_clone = 0; |
duke@435 | 1183 | const char *idealName = NodeClassNames[idealIndex]; |
duke@435 | 1184 | // Previously selected constants for cloning |
duke@435 | 1185 | // !!!!! |
duke@435 | 1186 | // These are the current machine-dependent clones |
duke@435 | 1187 | if ( strcmp(idealName,"CmpI") == 0 |
duke@435 | 1188 | || strcmp(idealName,"CmpU") == 0 |
duke@435 | 1189 | || strcmp(idealName,"CmpP") == 0 |
coleenp@548 | 1190 | || strcmp(idealName,"CmpN") == 0 |
duke@435 | 1191 | || strcmp(idealName,"CmpL") == 0 |
thartmann@8797 | 1192 | || strcmp(idealName,"CmpUL") == 0 |
duke@435 | 1193 | || strcmp(idealName,"CmpD") == 0 |
duke@435 | 1194 | || strcmp(idealName,"CmpF") == 0 |
duke@435 | 1195 | || strcmp(idealName,"FastLock") == 0 |
duke@435 | 1196 | || strcmp(idealName,"FastUnlock") == 0 |
rbackman@6375 | 1197 | || strcmp(idealName,"OverflowAddI") == 0 |
rbackman@6375 | 1198 | || strcmp(idealName,"OverflowAddL") == 0 |
rbackman@6375 | 1199 | || strcmp(idealName,"OverflowSubI") == 0 |
rbackman@6375 | 1200 | || strcmp(idealName,"OverflowSubL") == 0 |
rbackman@6375 | 1201 | || strcmp(idealName,"OverflowMulI") == 0 |
rbackman@6375 | 1202 | || strcmp(idealName,"OverflowMulL") == 0 |
duke@435 | 1203 | || strcmp(idealName,"Bool") == 0 |
duke@435 | 1204 | || strcmp(idealName,"Binary") == 0 ) { |
duke@435 | 1205 | // Removed ConI from the must_clone list. CPUs that cannot use |
duke@435 | 1206 | // large constants as immediates manifest the constant as an |
duke@435 | 1207 | // instruction. The must_clone flag prevents the constant from |
duke@435 | 1208 | // floating up out of loops. |
duke@435 | 1209 | must_clone = 1; |
duke@435 | 1210 | } |
duke@435 | 1211 | fprintf(fp_cpp, " %d%s // %s: %d\n", must_clone, |
duke@435 | 1212 | (idealIndex != (_last_opcode - 1)) ? "," : " // no trailing comma", |
duke@435 | 1213 | idealName, idealIndex); |
duke@435 | 1214 | } |
duke@435 | 1215 | // Finish defining table |
duke@435 | 1216 | fprintf(fp_cpp, "};\n"); |
duke@435 | 1217 | } |