src/hotspot/share/adlc/main.cpp
author stefank
Mon, 19 Aug 2019 11:30:03 +0200
changeset 57811 947252a54b98
parent 54825 1b03400e5a8f
child 58061 fafba5cf3546
permissions -rw-r--r--
8229838: Rename markOop files to markWord Reviewed-by: dholmes, rehn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
51078
fc6cfe40e32a 8207049: Minor improvements of compiler code.
goetz
parents: 49449
diff changeset
     2
 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2129
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2129
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2129
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// MAIN.CPP - Entry point for the Architecture Description Language Compiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "adlc.hpp"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
//------------------------------Prototypes-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
static void  usage(ArchDesc& AD);          // Print usage message and exit
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
static char *strip_ext(char *fname);       // Strip off name extension
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
static char *base_plus_suffix(const char* base, const char *suffix);// New concatenated string
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
static int get_legal_text(FileBuff &fbuf, char **legal_text); // Get pointer to legal text
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
ArchDesc* globalAD = NULL;      // global reference to Architecture Description object
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
const char* get_basename(const char* filename) {
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
  const char *basename = filename;
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
  const char *cp;
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
  for (cp = basename; *cp; cp++) {
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    40
    if (*cp == '/') {
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    41
      basename = cp+1;
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    42
    }
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    43
  }
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    44
  return basename;
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    45
}
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    46
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
//------------------------------main-------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
int main(int argc, char *argv[])
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  ArchDesc      AD;             // Architecture Description object
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  globalAD = &AD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // ResourceMark  mark;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  ADLParser    *ADL_Parse;      // ADL Parser object to parse AD file
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // Check for proper arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  if( argc == 1 ) usage(AD);    // No arguments?  Then print usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Read command line arguments and file names
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  for( int i = 1; i < argc; i++ ) { // For all arguments
51050
96ea37459ca7 8207011: Remove uses of the register storage class specifier
mikael
parents: 49449
diff changeset
    61
    char *s = argv[i];          // Get option/filename
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    if( *s++ == '-' ) {         // It's a flag? (not a filename)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
      if( !*s ) {               // Stand-alone `-' means stdin
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
        //********** INSERT CODE HERE **********
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
      } else while (*s != '\0') { // While have flags on option
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
        switch (*s++) {         // Handle flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
        case 'd':               // Debug flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
          AD._dfa_debug += 1;   // Set Debug Flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
        case 'g':               // Debug ad location flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
          AD._adlocation_debug += 1;       // Set Debug ad location Flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
        case 'o':               // No Output Flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
          AD._no_output ^= 1;   // Toggle no_output flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
        case 'q':               // Quiet Mode Flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
          AD._quiet_mode ^= 1;  // Toggle quiet_mode flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
        case 'w':               // Disable Warnings Flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
          AD._disable_warnings ^= 1; // Toggle disable_warnings flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
        case 'T':               // Option to make DFA as many subroutine calls.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
          AD._dfa_small += 1;   // Set Mode Flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
        case 'c': {             // Set C++ Output file name
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
          AD._CPP_file._name = s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
          const char *base = strip_ext(strdup(s));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
          AD._CPP_CLONE_file._name    = base_plus_suffix(base,"_clone.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
          AD._CPP_EXPAND_file._name   = base_plus_suffix(base,"_expand.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
          AD._CPP_FORMAT_file._name   = base_plus_suffix(base,"_format.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
          AD._CPP_GEN_file._name      = base_plus_suffix(base,"_gen.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
          AD._CPP_MISC_file._name     = base_plus_suffix(base,"_misc.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
          AD._CPP_PEEPHOLE_file._name = base_plus_suffix(base,"_peephole.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
          AD._CPP_PIPELINE_file._name = base_plus_suffix(base,"_pipeline.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
          s += strlen(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
        case 'h':               // Set C++ Output file name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
          AD._HPP_file._name = s; s += strlen(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
        case 'v':               // Set C++ Output file name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
          AD._VM_file._name = s; s += strlen(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
        case 'a':               // Set C++ Output file name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
          AD._DFA_file._name = s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
          AD._bug_file._name = s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
          s += strlen(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
        case '#':               // Special internal debug flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
          AD._adl_debug++;      // Increment internal debug level
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
        case 's':               // Output which instructions are cisc-spillable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
          AD._cisc_spill_debug = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
        case 'D':               // Flag Definition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
          {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
            char* flag = s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
            s += strlen(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
            char* def = strchr(flag, '=');
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
            if (def == NULL)  def = (char*)"1";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
            else              *def++ = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
            AD.set_preproc_def(flag, def);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
        case 'U':               // Flag Un-Definition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
          {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
            char* flag = s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
            s += strlen(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
            AD.set_preproc_def(flag, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
        default:                // Unknown option
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
          usage(AD);            // So print usage and exit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
        }                       // End of switch on options...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
      }                         // End of while have options...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    } else {                    // Not an option; must be a filename
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
      AD._ADL_file._name = argv[i]; // Set the input filename
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
      // // Files for storage, based on input file name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
      const char *base = strip_ext(strdup(argv[i]));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      char       *temp = base_plus_suffix("dfa_",base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
      AD._DFA_file._name = base_plus_suffix(temp,".cpp");
51078
fc6cfe40e32a 8207049: Minor improvements of compiler code.
goetz
parents: 49449
diff changeset
   145
      delete[] temp;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
      temp = base_plus_suffix("ad_",base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
      AD._CPP_file._name          = base_plus_suffix(temp,".cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
      AD._CPP_CLONE_file._name    = base_plus_suffix(temp,"_clone.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      AD._CPP_EXPAND_file._name   = base_plus_suffix(temp,"_expand.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
      AD._CPP_FORMAT_file._name   = base_plus_suffix(temp,"_format.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
      AD._CPP_GEN_file._name      = base_plus_suffix(temp,"_gen.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
      AD._CPP_MISC_file._name     = base_plus_suffix(temp,"_misc.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
      AD._CPP_PEEPHOLE_file._name = base_plus_suffix(temp,"_peephole.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
      AD._CPP_PIPELINE_file._name = base_plus_suffix(temp,"_pipeline.cpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
      AD._HPP_file._name = base_plus_suffix(temp,".hpp");
51078
fc6cfe40e32a 8207049: Minor improvements of compiler code.
goetz
parents: 49449
diff changeset
   156
      delete[] temp;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
      temp = base_plus_suffix("adGlobals_",base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
      AD._VM_file._name = base_plus_suffix(temp,".hpp");
51078
fc6cfe40e32a 8207049: Minor improvements of compiler code.
goetz
parents: 49449
diff changeset
   159
      delete[] temp;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
      temp = base_plus_suffix("bugs_",base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
      AD._bug_file._name = base_plus_suffix(temp,".out");
51078
fc6cfe40e32a 8207049: Minor improvements of compiler code.
goetz
parents: 49449
diff changeset
   162
      delete[] temp;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    }                           // End of files vs options...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  }                             // End of while have command line arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  // Open files used to store the matcher and its components
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  if (AD.open_files() == 0) return 1; // Open all input/output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  // Build the File Buffer, Parse the input, & Generate Code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  FileBuff  ADL_Buf(&AD._ADL_file, AD); // Create a file buffer for input file
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  // Get pointer to legal text at the beginning of AD file.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  // It will be used in generated ad files.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  char* legal_text;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  int legal_sz = get_legal_text(ADL_Buf, &legal_text);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  ADL_Parse = new ADLParser(ADL_Buf, AD); // Create a parser to parse the buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  ADL_Parse->parse();           // Parse buffer & build description lists
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  if( AD._dfa_debug >= 1 ) {    // For higher debug settings, print dump
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    AD.dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  delete ADL_Parse;             // Delete parser
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // Verify that the results of the parse are consistent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  AD.verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  // Prepare to generate the result files:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  AD.generateMatchLists();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  AD.identify_unique_operands();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  AD.identify_cisc_spill_instructions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  AD.identify_short_branches();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  // Make sure every file starts with a copyright:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  AD.addSunCopyright(legal_text, legal_sz, AD._HPP_file._fp);           // .hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  AD.addSunCopyright(legal_text, legal_sz, AD._CPP_file._fp);           // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  AD.addSunCopyright(legal_text, legal_sz, AD._CPP_CLONE_file._fp);     // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  AD.addSunCopyright(legal_text, legal_sz, AD._CPP_EXPAND_file._fp);    // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  AD.addSunCopyright(legal_text, legal_sz, AD._CPP_FORMAT_file._fp);    // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  AD.addSunCopyright(legal_text, legal_sz, AD._CPP_GEN_file._fp);       // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  AD.addSunCopyright(legal_text, legal_sz, AD._CPP_MISC_file._fp);      // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  AD.addSunCopyright(legal_text, legal_sz, AD._CPP_PEEPHOLE_file._fp);  // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  AD.addSunCopyright(legal_text, legal_sz, AD._CPP_PIPELINE_file._fp);  // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  AD.addSunCopyright(legal_text, legal_sz, AD._VM_file._fp);            // .hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  AD.addSunCopyright(legal_text, legal_sz, AD._DFA_file._fp);           // .cpp
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   206
  // Add include guards for all .hpp files
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   207
  AD.addIncludeGuardStart(AD._HPP_file, "GENERATED_ADFILES_AD_HPP");        // .hpp
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   208
  AD.addIncludeGuardStart(AD._VM_file, "GENERATED_ADFILES_ADGLOBALS_HPP");  // .hpp
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   209
  // Add includes
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   210
  AD.addInclude(AD._CPP_file, "precompiled.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   211
  AD.addInclude(AD._CPP_file, "adfiles", get_basename(AD._VM_file._name));
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   212
  AD.addInclude(AD._CPP_file, "adfiles", get_basename(AD._HPP_file._name));
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   213
  AD.addInclude(AD._CPP_file, "memory/allocation.inline.hpp");
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents: 13971
diff changeset
   214
  AD.addInclude(AD._CPP_file, "asm/macroAssembler.inline.hpp");
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents: 14631
diff changeset
   215
  AD.addInclude(AD._CPP_file, "code/compiledIC.hpp");
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 23529
diff changeset
   216
  AD.addInclude(AD._CPP_file, "code/nativeInst.hpp");
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 23529
diff changeset
   217
  AD.addInclude(AD._CPP_file, "code/vmreg.inline.hpp");
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29081
diff changeset
   218
  AD.addInclude(AD._CPP_file, "gc/shared/collectedHeap.inline.hpp");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13104
diff changeset
   219
  AD.addInclude(AD._CPP_file, "oops/compiledICHolder.hpp");
54825
1b03400e5a8f 8223637: Fix build breakage after 8223136
stefank
parents: 51092
diff changeset
   220
  AD.addInclude(AD._CPP_file, "oops/compressedOops.hpp");
57811
947252a54b98 8229838: Rename markOop files to markWord
stefank
parents: 54825
diff changeset
   221
  AD.addInclude(AD._CPP_file, "oops/markWord.hpp");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13104
diff changeset
   222
  AD.addInclude(AD._CPP_file, "oops/method.hpp");
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   223
  AD.addInclude(AD._CPP_file, "oops/oop.inline.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   224
  AD.addInclude(AD._CPP_file, "opto/cfgnode.hpp");
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
   225
  AD.addInclude(AD._CPP_file, "opto/intrinsicnode.hpp");
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   226
  AD.addInclude(AD._CPP_file, "opto/locknode.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   227
  AD.addInclude(AD._CPP_file, "opto/opcodes.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   228
  AD.addInclude(AD._CPP_file, "opto/regalloc.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   229
  AD.addInclude(AD._CPP_file, "opto/regmask.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   230
  AD.addInclude(AD._CPP_file, "opto/runtime.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   231
  AD.addInclude(AD._CPP_file, "runtime/biasedLocking.hpp");
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
   232
  AD.addInclude(AD._CPP_file, "runtime/safepointMechanism.hpp");
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   233
  AD.addInclude(AD._CPP_file, "runtime/sharedRuntime.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   234
  AD.addInclude(AD._CPP_file, "runtime/stubRoutines.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   235
  AD.addInclude(AD._CPP_file, "utilities/growableArray.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   236
  AD.addInclude(AD._HPP_file, "memory/allocation.hpp");
54825
1b03400e5a8f 8223637: Fix build breakage after 8223136
stefank
parents: 51092
diff changeset
   237
  AD.addInclude(AD._HPP_file, "oops/compressedOops.hpp");
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 23529
diff changeset
   238
  AD.addInclude(AD._HPP_file, "code/nativeInst.hpp");
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   239
  AD.addInclude(AD._HPP_file, "opto/machnode.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   240
  AD.addInclude(AD._HPP_file, "opto/node.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   241
  AD.addInclude(AD._HPP_file, "opto/regalloc.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   242
  AD.addInclude(AD._HPP_file, "opto/subnode.hpp");
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   243
  AD.addInclude(AD._HPP_file, "opto/vectornode.hpp");
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   244
  AD.addInclude(AD._CPP_CLONE_file, "precompiled.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   245
  AD.addInclude(AD._CPP_CLONE_file, "adfiles", get_basename(AD._HPP_file._name));
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   246
  AD.addInclude(AD._CPP_EXPAND_file, "precompiled.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   247
  AD.addInclude(AD._CPP_EXPAND_file, "adfiles", get_basename(AD._HPP_file._name));
54825
1b03400e5a8f 8223637: Fix build breakage after 8223136
stefank
parents: 51092
diff changeset
   248
  AD.addInclude(AD._CPP_EXPAND_file, "oops/compressedOops.hpp");
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   249
  AD.addInclude(AD._CPP_FORMAT_file, "precompiled.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   250
  AD.addInclude(AD._CPP_FORMAT_file, "adfiles", get_basename(AD._HPP_file._name));
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   251
  AD.addInclude(AD._CPP_GEN_file, "precompiled.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   252
  AD.addInclude(AD._CPP_GEN_file, "adfiles", get_basename(AD._HPP_file._name));
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   253
  AD.addInclude(AD._CPP_GEN_file, "opto/cfgnode.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   254
  AD.addInclude(AD._CPP_GEN_file, "opto/locknode.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   255
  AD.addInclude(AD._CPP_MISC_file, "precompiled.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   256
  AD.addInclude(AD._CPP_MISC_file, "adfiles", get_basename(AD._HPP_file._name));
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   257
  AD.addInclude(AD._CPP_PEEPHOLE_file, "precompiled.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   258
  AD.addInclude(AD._CPP_PEEPHOLE_file, "adfiles", get_basename(AD._HPP_file._name));
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   259
  AD.addInclude(AD._CPP_PIPELINE_file, "precompiled.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   260
  AD.addInclude(AD._CPP_PIPELINE_file, "adfiles", get_basename(AD._HPP_file._name));
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   261
  AD.addInclude(AD._DFA_file, "precompiled.hpp");
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   262
  AD.addInclude(AD._DFA_file, "adfiles", get_basename(AD._HPP_file._name));
54825
1b03400e5a8f 8223637: Fix build breakage after 8223136
stefank
parents: 51092
diff changeset
   263
  AD.addInclude(AD._DFA_file, "oops/compressedOops.hpp");
22856
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22838
diff changeset
   264
  AD.addInclude(AD._DFA_file, "opto/cfgnode.hpp");  // Use PROB_MAX in predicate.
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 30764
diff changeset
   265
  AD.addInclude(AD._DFA_file, "opto/intrinsicnode.hpp");
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   266
  AD.addInclude(AD._DFA_file, "opto/matcher.hpp");
42063
dca9294d9f59 8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents: 33628
diff changeset
   267
  AD.addInclude(AD._DFA_file, "opto/narrowptrnode.hpp");
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   268
  AD.addInclude(AD._DFA_file, "opto/opcodes.hpp");
23529
a77755391144 8039045: PPC64: need include in adl generated files after 8001532
goetz
parents: 22872
diff changeset
   269
  AD.addInclude(AD._DFA_file, "opto/convertnode.hpp");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  // Make sure each .cpp file starts with include lines:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  // files declaring and defining generators for Mach* Objects (hpp,cpp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  // Generate the result files:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  // enumerations, class definitions, object generators, and the DFA
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  // file containing enumeration of machine operands & instructions (hpp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  AD.addPreHeaderBlocks(AD._HPP_file._fp);        // .hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  AD.buildMachOperEnum(AD._HPP_file._fp);         // .hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  AD.buildMachOpcodesEnum(AD._HPP_file._fp);      // .hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  AD.buildMachRegisterNumbers(AD._VM_file._fp);   // VM file
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  AD.buildMachRegisterEncodes(AD._HPP_file._fp);  // .hpp file
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  AD.declareRegSizes(AD._HPP_file._fp);           // .hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  AD.build_pipeline_enums(AD._HPP_file._fp);      // .hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  // output definition of class "State"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  AD.defineStateClass(AD._HPP_file._fp);          // .hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  // file declaring the Mach* classes derived from MachOper and MachNode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  AD.declareClasses(AD._HPP_file._fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  // declare and define maps: in the .hpp and .cpp files respectively
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  AD.addSourceBlocks(AD._CPP_file._fp);           // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  AD.addHeaderBlocks(AD._HPP_file._fp);           // .hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  AD.buildReduceMaps(AD._HPP_file._fp, AD._CPP_file._fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  AD.buildMustCloneMap(AD._HPP_file._fp, AD._CPP_file._fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  // build CISC_spilling oracle and MachNode::cisc_spill() methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  AD.build_cisc_spill_instructions(AD._HPP_file._fp, AD._CPP_file._fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  // define methods for machine dependent State, MachOper, and MachNode classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  AD.defineClasses(AD._CPP_file._fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  AD.buildMachOperGenerator(AD._CPP_GEN_file._fp);// .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  AD.buildMachNodeGenerator(AD._CPP_GEN_file._fp);// .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  // define methods for machine dependent instruction matching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  AD.buildInstructMatchCheck(AD._CPP_file._fp);  // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  // define methods for machine dependent frame management
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  AD.buildFrameMethods(AD._CPP_file._fp);         // .cpp
22865
3b8857d7b3cc 8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents: 22856
diff changeset
   301
  AD.generate_needs_clone_jvms(AD._CPP_file._fp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  // do this last:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  AD.addPreprocessorChecks(AD._CPP_file._fp);     // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  AD.addPreprocessorChecks(AD._CPP_CLONE_file._fp);     // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  AD.addPreprocessorChecks(AD._CPP_EXPAND_file._fp);    // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  AD.addPreprocessorChecks(AD._CPP_FORMAT_file._fp);    // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  AD.addPreprocessorChecks(AD._CPP_GEN_file._fp);       // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  AD.addPreprocessorChecks(AD._CPP_MISC_file._fp);      // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  AD.addPreprocessorChecks(AD._CPP_PEEPHOLE_file._fp);  // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  AD.addPreprocessorChecks(AD._CPP_PIPELINE_file._fp);  // .cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  // define the finite automata that selects lowest cost production
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  AD.buildDFA(AD._DFA_file._fp);
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   315
  // Add include guards for all .hpp files
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   316
  AD.addIncludeGuardEnd(AD._HPP_file, "GENERATED_ADFILES_AD_HPP");        // .hpp
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   317
  AD.addIncludeGuardEnd(AD._VM_file, "GENERATED_ADFILES_ADGLOBALS_HPP");  // .hpp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  AD.close_files(0);               // Close all input/output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  // Final printout and statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  // cout << program;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  if( AD._dfa_debug & 2 ) {    // For higher debug settings, print timing info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    //    Timer t_stop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    //    Timer t_total = t_stop - t_start; // Total running time
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    //    cerr << "\n---Architecture Description Totals---\n";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    //    cerr << ", Total lines: " << TotalLines;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    //    float l = TotalLines;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    //    cerr << "\nTotal Compilation Time: " << t_total << "\n";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    //    float ft = (float)t_total;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    //    if( ft > 0.0 ) fprintf(stderr,"Lines/sec: %#5.2f\n", l/ft);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  return (AD._syntax_errs + AD._semantic_errs + AD._internal_errs); // Bye Bye!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
//------------------------------usage------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
static void usage(ArchDesc& AD)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  printf("Architecture Description Language Compiler\n\n");
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13728
diff changeset
   341
  printf("Usage: adlc [-doqwTs] [-#]* [-D<FLAG>[=<DEF>]] [-U<FLAG>] [-c<CPP_FILE_NAME>] [-h<HPP_FILE_NAME>] [-a<DFA_FILE_NAME>] [-v<GLOBALS_FILE_NAME>] <ADL_FILE_NAME>\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  printf(" d  produce DFA debugging info\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  printf(" o  no output produced, syntax and semantic checking only\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  printf(" q  quiet mode, supresses all non-essential messages\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  printf(" w  suppress warning messages\n");
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13728
diff changeset
   346
  printf(" T  make DFA as many subroutine calls\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13728
diff changeset
   347
  printf(" s  output which instructions are cisc-spillable\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13728
diff changeset
   348
  printf(" D  define preprocessor symbol\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13728
diff changeset
   349
  printf(" U  undefine preprocessor symbol\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  printf(" c  specify CPP file name (default: %s)\n", AD._CPP_file._name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  printf(" h  specify HPP file name (default: %s)\n", AD._HPP_file._name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  printf(" a  specify DFA output file name\n");
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13728
diff changeset
   353
  printf(" v  specify adGlobals output file name\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13728
diff changeset
   354
  printf(" #  increment ADL debug level\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  printf("\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
//------------------------------open_file------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
int ArchDesc::open_file(bool required, ADLFILE & ADF, const char *action)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  if (required &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
      (ADF._fp = fopen(ADF._name, action)) == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    printf("ERROR: Cannot open file for %s: %s\n", action, ADF._name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    close_files(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
    return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  return 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
//------------------------------open_files-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
int ArchDesc::open_files(void)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  if (_ADL_file._name == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  { printf("ERROR: No ADL input file specified\n"); return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  if (!open_file(true       , _ADL_file, "r"))          { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  if (!open_file(!_no_output, _DFA_file, "w"))          { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  if (!open_file(!_no_output, _HPP_file, "w"))          { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  if (!open_file(!_no_output, _CPP_file, "w"))          { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  if (!open_file(!_no_output, _CPP_CLONE_file, "w"))    { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  if (!open_file(!_no_output, _CPP_EXPAND_file, "w"))   { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  if (!open_file(!_no_output, _CPP_FORMAT_file, "w"))   { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  if (!open_file(!_no_output, _CPP_GEN_file, "w"))      { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  if (!open_file(!_no_output, _CPP_MISC_file, "w"))     { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  if (!open_file(!_no_output, _CPP_PEEPHOLE_file, "w")) { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  if (!open_file(!_no_output, _CPP_PIPELINE_file, "w")) { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  if (!open_file(!_no_output, _VM_file , "w"))          { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  if (!open_file(_dfa_debug != 0, _bug_file, "w"))    { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  return 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
//------------------------------close_file------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
void ArchDesc::close_file(int delete_out, ADLFILE& ADF)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  if (ADF._fp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
    fclose(ADF._fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
    if (delete_out) remove(ADF._name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
//------------------------------close_files------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
void ArchDesc::close_files(int delete_out)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  if (_ADL_file._fp) fclose(_ADL_file._fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  close_file(delete_out, _CPP_file);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  close_file(delete_out, _CPP_CLONE_file);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  close_file(delete_out, _CPP_EXPAND_file);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  close_file(delete_out, _CPP_FORMAT_file);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  close_file(delete_out, _CPP_GEN_file);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  close_file(delete_out, _CPP_MISC_file);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  close_file(delete_out, _CPP_PEEPHOLE_file);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  close_file(delete_out, _CPP_PIPELINE_file);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  close_file(delete_out, _HPP_file);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  close_file(delete_out, _DFA_file);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  close_file(delete_out, _bug_file);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  if (!_quiet_mode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    printf("\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    if (_no_output || delete_out) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
      if (_ADL_file._name) printf("%s: ", _ADL_file._name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      printf("No output produced");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
      if (_ADL_file._name) printf("%s --> ", _ADL_file._name);
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   427
      printf("%s, %s, %s, %s, %s, %s, %s, %s, %s, %s",
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
             _CPP_file._name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
             _CPP_CLONE_file._name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
             _CPP_EXPAND_file._name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
             _CPP_FORMAT_file._name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
             _CPP_GEN_file._name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
             _CPP_MISC_file._name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
             _CPP_PEEPHOLE_file._name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
             _CPP_PIPELINE_file._name,
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   436
             _HPP_file._name,
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   437
             _DFA_file._name);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    printf("\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
//------------------------------strip_ext--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
static char *strip_ext(char *fname)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  char *ep;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  if (fname) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    ep = fname + strlen(fname) - 1; // start at last character and look for '.'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    while (ep >= fname && *ep != '.') --ep;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    if (*ep == '.')     *ep = '\0'; // truncate string at '.'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  return fname;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
//------------------------------base_plus_suffix-------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
// New concatenated string
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
static char *base_plus_suffix(const char* base, const char *suffix)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  int len = (int)strlen(base) + (int)strlen(suffix) + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  char* fname = new char[len];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  sprintf(fname,"%s%s",base,suffix);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  return fname;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
//------------------------------get_legal_text---------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
// Get pointer to legal text at the beginning of AD file.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
// This code assumes that a legal text starts at the beginning of .ad files,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
// is commented by "//" at each line and ends with empty line.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
int get_legal_text(FileBuff &fbuf, char **legal_text)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  char* legal_start = fbuf.get_line();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  assert(legal_start[0] == '/' && legal_start[1] == '/', "Incorrect header of AD file");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  char* legal_end = fbuf.get_line();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  assert(strncmp(legal_end, "// Copyright", 12) == 0, "Incorrect header of AD file");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  while(legal_end[0] == '/' && legal_end[1] == '/') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
    legal_end = fbuf.get_line();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  *legal_text = legal_start;
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   482
  return (int) (legal_end - legal_start);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
// VS2005 has its own definition, identical to this one.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
#if !defined(_WIN32) || defined(_WIN64) || _MSC_VER < 1400
19696
bd5a0131bde1 8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents: 17094
diff changeset
   487
void *operator new( size_t size, int, const char *, int ) throw() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  return ::operator new( size );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
#endif