Tue, 09 Oct 2012 16:09:31 -0700
8000592: Improve adlc usability
Summary: several changes to adlc to improve its usability
Reviewed-by: kvn
Contributed-by: goetz.lindenmaier@sap.com
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1998, 2010, 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 | |
stefank@2314 | 25 | #ifndef SHARE_VM_ADLC_FORMSOPT_HPP |
stefank@2314 | 26 | #define SHARE_VM_ADLC_FORMSOPT_HPP |
stefank@2314 | 27 | |
duke@435 | 28 | // FORMSOPT.HPP - ADL Parser Target Specific Optimization Forms Classes |
duke@435 | 29 | |
duke@435 | 30 | // Class List |
duke@435 | 31 | class Form; |
duke@435 | 32 | class InstructForm; |
duke@435 | 33 | class OperandForm; |
duke@435 | 34 | class OpClassForm; |
duke@435 | 35 | class AttributeForm; |
duke@435 | 36 | class RegisterForm; |
duke@435 | 37 | class PipelineForm; |
duke@435 | 38 | class SourceForm; |
duke@435 | 39 | class EncodeForm; |
duke@435 | 40 | class Component; |
duke@435 | 41 | class Constraint; |
duke@435 | 42 | class Predicate; |
duke@435 | 43 | class MatchRule; |
duke@435 | 44 | class Attribute; |
duke@435 | 45 | class Effect; |
duke@435 | 46 | class ExpandRule; |
duke@435 | 47 | class RewriteRule; |
duke@435 | 48 | class ConstructRule; |
duke@435 | 49 | class FormatRule; |
duke@435 | 50 | class Peephole; |
duke@435 | 51 | class PeepMatch; |
duke@435 | 52 | class PeepConstraint; |
duke@435 | 53 | class EncClass; |
duke@435 | 54 | class Interface; |
duke@435 | 55 | class RegInterface; |
duke@435 | 56 | class ConstInterface; |
duke@435 | 57 | class MemInterface; |
duke@435 | 58 | class CondInterface; |
duke@435 | 59 | class Opcode; |
duke@435 | 60 | class InsEncode; |
duke@435 | 61 | class RegDef; |
duke@435 | 62 | class RegClass; |
duke@435 | 63 | class AllocClass; |
duke@435 | 64 | class ResourceForm; |
duke@435 | 65 | class PipeClassForm; |
duke@435 | 66 | class PipeClassOperandForm; |
duke@435 | 67 | class PipeClassResourceForm; |
duke@435 | 68 | class PeepMatch; |
duke@435 | 69 | class PeepConstraint; |
duke@435 | 70 | class PeepReplace; |
duke@435 | 71 | class MatchList; |
duke@435 | 72 | |
duke@435 | 73 | class ArchDesc; |
duke@435 | 74 | |
duke@435 | 75 | //==============================Register Allocation============================ |
duke@435 | 76 | //------------------------------RegisterForm----------------------------------- |
duke@435 | 77 | class RegisterForm : public Form { |
duke@435 | 78 | private: |
duke@435 | 79 | AllocClass *_current_ac; // State used by iter_RegDefs() |
duke@435 | 80 | |
duke@435 | 81 | public: |
duke@435 | 82 | // Public Data |
duke@435 | 83 | NameList _rdefs; // List of register definition names |
duke@435 | 84 | Dict _regDef; // map register name to RegDef* |
duke@435 | 85 | |
duke@435 | 86 | NameList _rclasses; // List of register class names |
duke@435 | 87 | Dict _regClass; // map register class name to RegClass* |
duke@435 | 88 | |
duke@435 | 89 | NameList _aclasses; // List of allocation class names |
duke@435 | 90 | Dict _allocClass; // Dictionary of allocation classes |
duke@435 | 91 | |
duke@435 | 92 | static int _reg_ctr; // Register counter |
duke@435 | 93 | static int RegMask_Size(); // Compute RegMask size |
duke@435 | 94 | |
duke@435 | 95 | // Public Methods |
duke@435 | 96 | RegisterForm(); |
duke@435 | 97 | ~RegisterForm(); |
duke@435 | 98 | |
duke@435 | 99 | void addRegDef(char *regName, char *callingConv, char *c_conv, |
duke@435 | 100 | char * idealtype, char *encoding, char* concreteName); |
duke@435 | 101 | RegClass *addRegClass(const char *className); |
duke@435 | 102 | AllocClass *addAllocClass(char *allocName); |
duke@435 | 103 | void addSpillRegClass(); |
duke@435 | 104 | |
duke@435 | 105 | // Provide iteration over all register definitions |
duke@435 | 106 | // in the order used by the register allocator |
duke@435 | 107 | void reset_RegDefs(); |
duke@435 | 108 | RegDef *iter_RegDefs(); |
duke@435 | 109 | RegDef *getRegDef (const char *regName); |
duke@435 | 110 | |
duke@435 | 111 | RegClass *getRegClass(const char *className); |
duke@435 | 112 | |
duke@435 | 113 | // Return register mask, compressed chunk and register # |
duke@435 | 114 | uint reg_mask(char *register_class); |
duke@435 | 115 | |
duke@435 | 116 | // Check that register classes are compatible with chunks |
duke@435 | 117 | bool verify(); |
duke@435 | 118 | |
duke@435 | 119 | void dump(); // Debug printer |
duke@435 | 120 | void output(FILE *fp); // Write info to output files |
duke@435 | 121 | }; |
duke@435 | 122 | |
duke@435 | 123 | //------------------------------RegDef----------------------------------------- |
duke@435 | 124 | class RegDef : public Form { |
duke@435 | 125 | public: |
duke@435 | 126 | // Public Data |
duke@435 | 127 | const char *_regname; // ADLC (Opto) Register name |
duke@435 | 128 | const char *_callconv; // Calling convention |
duke@435 | 129 | const char *_c_conv; // Native calling convention, 'C' |
duke@435 | 130 | const char *_idealtype; // Ideal Type for register save/restore |
duke@435 | 131 | const char *_concrete; // concrete register name |
duke@435 | 132 | |
duke@435 | 133 | private: |
duke@435 | 134 | const char *_register_encode; // The register encoding |
duke@435 | 135 | // The chunk and register mask bits define info for register allocation |
duke@435 | 136 | uint32 _register_num; // Which register am I |
duke@435 | 137 | |
duke@435 | 138 | public: |
duke@435 | 139 | // Public Methods |
duke@435 | 140 | RegDef(char *regname, char *callconv, char *c_conv, |
duke@435 | 141 | char *idealtype, char *encoding, char *concrete); |
duke@435 | 142 | ~RegDef(); // Destructor |
duke@435 | 143 | |
duke@435 | 144 | // Interface to define/redefine the register number |
duke@435 | 145 | void set_register_num(uint32 new_register_num); |
duke@435 | 146 | |
duke@435 | 147 | // Bit pattern used for generating machine code |
duke@435 | 148 | const char *register_encode() const; |
duke@435 | 149 | // Register number used in machine-independent code |
duke@435 | 150 | uint32 register_num() const; |
duke@435 | 151 | |
duke@435 | 152 | void dump(); // Debug printer |
duke@435 | 153 | void output(FILE *fp); // Write info to output files |
duke@435 | 154 | }; |
duke@435 | 155 | |
duke@435 | 156 | //------------------------------RegClass--------------------------------------- |
duke@435 | 157 | class RegClass : public Form { |
duke@435 | 158 | public: |
duke@435 | 159 | // Public Data |
duke@435 | 160 | const char *_classid; // Name of class |
duke@435 | 161 | NameList _regDefs; // List of registers in class |
duke@435 | 162 | Dict _regDef; // Dictionary of registers in class |
duke@435 | 163 | bool _stack_or_reg; // Allowed on any stack slot |
roland@3317 | 164 | char* _user_defined; |
duke@435 | 165 | |
duke@435 | 166 | // Public Methods |
duke@435 | 167 | RegClass(const char *classid);// Constructor |
duke@435 | 168 | |
duke@435 | 169 | void addReg(RegDef *regDef); // Add a register to this class |
duke@435 | 170 | |
duke@435 | 171 | uint size() const; // Number of registers in class |
duke@435 | 172 | int regs_in_word( int wordnum, bool stack_also ); |
duke@435 | 173 | |
duke@435 | 174 | const RegDef *get_RegDef(const char *regDef_name) const; |
duke@435 | 175 | |
duke@435 | 176 | // Returns the lowest numbered register in the mask. |
duke@435 | 177 | const RegDef* find_first_elem(); |
duke@435 | 178 | |
duke@435 | 179 | // Iteration support |
duke@435 | 180 | void reset(); // Reset the following two iterators |
duke@435 | 181 | RegDef *RegDef_iter(); // which move jointly, |
duke@435 | 182 | const char *rd_name_iter(); // invoking either advances both. |
duke@435 | 183 | |
duke@435 | 184 | void dump(); // Debug printer |
duke@435 | 185 | void output(FILE *fp); // Write info to output files |
duke@435 | 186 | }; |
duke@435 | 187 | |
duke@435 | 188 | //------------------------------AllocClass------------------------------------- |
duke@435 | 189 | class AllocClass : public Form { |
duke@435 | 190 | private: |
duke@435 | 191 | |
duke@435 | 192 | public: |
duke@435 | 193 | // Public Data |
duke@435 | 194 | char *_classid; // Name of class |
duke@435 | 195 | NameList _regDefs; // List of registers in class |
duke@435 | 196 | Dict _regDef; // Dictionary of registers in class |
duke@435 | 197 | |
duke@435 | 198 | // Public Methods |
duke@435 | 199 | AllocClass(char *classid); // Constructor |
duke@435 | 200 | |
duke@435 | 201 | void addReg(RegDef *regDef); // Add a register to this class |
duke@435 | 202 | uint size() {return _regDef.Size();} // Number of registers in class |
duke@435 | 203 | |
duke@435 | 204 | void dump(); // Debug printer |
duke@435 | 205 | void output(FILE *fp); // Write info to output files |
duke@435 | 206 | }; |
duke@435 | 207 | |
duke@435 | 208 | |
duke@435 | 209 | //==============================Frame Handling================================ |
duke@435 | 210 | //------------------------------FrameForm------------------------------------- |
duke@435 | 211 | class FrameForm : public Form { |
duke@435 | 212 | private: |
duke@435 | 213 | |
duke@435 | 214 | public: |
duke@435 | 215 | // Public Data |
duke@435 | 216 | bool _direction; // Direction of stack growth |
duke@435 | 217 | char *_sync_stack_slots; |
duke@435 | 218 | char *_inline_cache_reg; |
duke@435 | 219 | char *_interpreter_method_oop_reg; |
duke@435 | 220 | char *_interpreter_frame_pointer_reg; |
duke@435 | 221 | char *_cisc_spilling_operand_name; |
duke@435 | 222 | char *_frame_pointer; |
duke@435 | 223 | char *_c_frame_pointer; |
duke@435 | 224 | char *_alignment; |
duke@435 | 225 | bool _return_addr_loc; |
duke@435 | 226 | bool _c_return_addr_loc; |
duke@435 | 227 | char *_return_addr; |
duke@435 | 228 | char *_c_return_addr; |
duke@435 | 229 | char *_in_preserve_slots; |
duke@435 | 230 | char *_varargs_C_out_slots_killed; |
duke@435 | 231 | char *_calling_convention; |
duke@435 | 232 | char *_c_calling_convention; |
duke@435 | 233 | char *_return_value; |
duke@435 | 234 | char *_c_return_value; |
duke@435 | 235 | |
duke@435 | 236 | // Public Methods |
duke@435 | 237 | FrameForm(); |
duke@435 | 238 | ~FrameForm(); |
duke@435 | 239 | |
duke@435 | 240 | void dump(); // Debug printer |
duke@435 | 241 | void output(FILE *fp); // Write info to output files |
duke@435 | 242 | }; |
duke@435 | 243 | |
duke@435 | 244 | |
duke@435 | 245 | //==============================Scheduling===================================== |
duke@435 | 246 | //------------------------------PipelineForm----------------------------------- |
duke@435 | 247 | class PipelineForm : public Form { |
duke@435 | 248 | private: |
duke@435 | 249 | |
duke@435 | 250 | public: |
duke@435 | 251 | // Public Data |
duke@435 | 252 | NameList _reslist; // List of pipeline resources |
duke@435 | 253 | FormDict _resdict; // Resource Name -> ResourceForm mapping |
duke@435 | 254 | int _rescount; // Number of resources (ignores OR cases) |
duke@435 | 255 | int _maxcycleused; // Largest cycle used relative to beginning of instruction |
duke@435 | 256 | |
duke@435 | 257 | NameList _stages; // List of pipeline stages on architecture |
duke@435 | 258 | int _stagecnt; // Number of stages listed |
duke@435 | 259 | |
duke@435 | 260 | NameList _classlist; // List of pipeline classes |
duke@435 | 261 | FormDict _classdict; // Class Name -> PipeClassForm mapping |
duke@435 | 262 | int _classcnt; // Number of classes |
duke@435 | 263 | |
duke@435 | 264 | NameList _noplist; // List of NOP instructions |
duke@435 | 265 | int _nopcnt; // Number of nop instructions |
duke@435 | 266 | |
duke@435 | 267 | bool _variableSizeInstrs; // Indicates if this architecture has variable sized instructions |
duke@435 | 268 | bool _branchHasDelaySlot; // Indicates that branches have delay slot instructions |
duke@435 | 269 | int _maxInstrsPerBundle; // Indicates the maximum number of instructions for ILP |
duke@435 | 270 | int _maxBundlesPerCycle; // Indicates the maximum number of bundles for ILP |
duke@435 | 271 | int _instrUnitSize; // The minimum instruction unit size, in bytes |
duke@435 | 272 | int _bundleUnitSize; // The bundle unit size, in bytes |
duke@435 | 273 | int _instrFetchUnitSize; // The size of the I-fetch unit, in bytes [must be power of 2] |
duke@435 | 274 | int _instrFetchUnits; // The number of I-fetch units processed per cycle |
duke@435 | 275 | |
duke@435 | 276 | // Public Methods |
duke@435 | 277 | PipelineForm(); |
duke@435 | 278 | ~PipelineForm(); |
duke@435 | 279 | |
duke@435 | 280 | void dump(); // Debug printer |
duke@435 | 281 | void output(FILE *fp); // Write info to output files |
duke@435 | 282 | }; |
duke@435 | 283 | |
duke@435 | 284 | //------------------------------ResourceForm----------------------------------- |
duke@435 | 285 | class ResourceForm : public Form { |
duke@435 | 286 | public: |
duke@435 | 287 | unsigned mask() const { return _resmask; }; |
duke@435 | 288 | |
duke@435 | 289 | private: |
duke@435 | 290 | // Public Data |
duke@435 | 291 | unsigned _resmask; // Resource Mask (OR of resource specifier bits) |
duke@435 | 292 | |
duke@435 | 293 | public: |
duke@435 | 294 | |
duke@435 | 295 | // Virtual Methods |
duke@435 | 296 | virtual ResourceForm *is_resource() const; |
duke@435 | 297 | |
duke@435 | 298 | // Public Methods |
duke@435 | 299 | ResourceForm(unsigned resmask); // Constructor |
duke@435 | 300 | ~ResourceForm(); // Destructor |
duke@435 | 301 | |
duke@435 | 302 | void dump(); // Debug printer |
duke@435 | 303 | void output(FILE *fp); // Write info to output files |
duke@435 | 304 | }; |
duke@435 | 305 | |
duke@435 | 306 | //------------------------------PipeClassOperandForm----------------------------- |
duke@435 | 307 | class PipeClassOperandForm : public Form { |
duke@435 | 308 | private: |
duke@435 | 309 | |
duke@435 | 310 | public: |
duke@435 | 311 | // Public Data |
duke@435 | 312 | const char *_stage; // Name of Stage |
duke@435 | 313 | unsigned _iswrite; // Read or Write |
duke@435 | 314 | unsigned _more_instrs; // Additional Instructions |
duke@435 | 315 | |
duke@435 | 316 | // Public Methods |
duke@435 | 317 | PipeClassOperandForm(const char *stage, unsigned iswrite, unsigned more_instrs) |
duke@435 | 318 | : _stage(stage) |
duke@435 | 319 | , _iswrite(iswrite) |
duke@435 | 320 | , _more_instrs(more_instrs) |
duke@435 | 321 | {}; |
duke@435 | 322 | |
duke@435 | 323 | ~PipeClassOperandForm() {}; // Destructor |
duke@435 | 324 | |
duke@435 | 325 | bool isWrite() const { return _iswrite != 0; } |
duke@435 | 326 | |
duke@435 | 327 | void dump(); // Debug printer |
duke@435 | 328 | void output(FILE *fp); // Write info to output files |
duke@435 | 329 | }; |
duke@435 | 330 | |
duke@435 | 331 | //------------------------------PipeClassResourceForm-------------------------- |
duke@435 | 332 | class PipeClassResourceForm : public Form { |
duke@435 | 333 | private: |
duke@435 | 334 | |
duke@435 | 335 | public: |
duke@435 | 336 | // Public Data |
duke@435 | 337 | const char *_resource; // Resource |
duke@435 | 338 | const char *_stage; // Stage the resource is used in |
duke@435 | 339 | int _cycles; // Number of cycles the resource is used |
duke@435 | 340 | |
duke@435 | 341 | // Public Methods |
duke@435 | 342 | PipeClassResourceForm(const char *resource, const char *stage, int cycles) |
duke@435 | 343 | // Constructor |
duke@435 | 344 | : _resource(resource) |
duke@435 | 345 | , _stage(stage) |
duke@435 | 346 | , _cycles(cycles) |
duke@435 | 347 | {}; |
duke@435 | 348 | |
duke@435 | 349 | ~PipeClassResourceForm() {}; // Destructor |
duke@435 | 350 | |
duke@435 | 351 | void dump(); // Debug printer |
duke@435 | 352 | void output(FILE *fp); // Write info to output files |
duke@435 | 353 | }; |
duke@435 | 354 | |
duke@435 | 355 | //------------------------------PipeClassForm---------------------------------- |
duke@435 | 356 | class PipeClassForm : public Form { |
duke@435 | 357 | private: |
duke@435 | 358 | |
duke@435 | 359 | public: |
duke@435 | 360 | |
duke@435 | 361 | // Public Data |
duke@435 | 362 | const char *_ident; // Name of class |
duke@435 | 363 | int _num; // Used in name of MachNode subclass |
duke@435 | 364 | NameList _parameters; // Locally defined names |
duke@435 | 365 | FormDict _localNames; // Table of operands & their types |
duke@435 | 366 | FormDict _localUsage; // Table of operand usage |
duke@435 | 367 | FormList _resUsage; // List of resource usage |
duke@435 | 368 | NameList _instructs; // List of instructions and machine nodes that use this pipeline class |
duke@435 | 369 | bool _has_fixed_latency; // Always takes this number of cycles |
duke@435 | 370 | int _fixed_latency; // Always takes this number of cycles |
duke@435 | 371 | int _instruction_count; // Number of instructions in first bundle |
duke@435 | 372 | bool _has_multiple_bundles; // Indicates if 1 or multiple bundles |
duke@435 | 373 | bool _has_branch_delay_slot; // Has branch delay slot as last instruction |
duke@435 | 374 | bool _force_serialization; // This node serializes relative to surrounding nodes |
duke@435 | 375 | bool _may_have_no_code; // This node may generate no code based on register allocation |
duke@435 | 376 | |
duke@435 | 377 | // Virtual Methods |
duke@435 | 378 | virtual PipeClassForm *is_pipeclass() const; |
duke@435 | 379 | |
duke@435 | 380 | // Public Methods |
duke@435 | 381 | PipeClassForm(const char *id, int num); |
duke@435 | 382 | // Constructor |
duke@435 | 383 | ~PipeClassForm(); // Destructor |
duke@435 | 384 | |
duke@435 | 385 | bool hasFixedLatency() { return _has_fixed_latency; } |
duke@435 | 386 | int fixedLatency() { return _fixed_latency; } |
duke@435 | 387 | |
duke@435 | 388 | void setFixedLatency(int fixed_latency) { _has_fixed_latency = 1; _fixed_latency = fixed_latency; } |
duke@435 | 389 | |
duke@435 | 390 | void setInstructionCount(int i) { _instruction_count = i; } |
duke@435 | 391 | void setMultipleBundles(bool b) { _has_multiple_bundles = b; } |
duke@435 | 392 | void setBranchDelay(bool s) { _has_branch_delay_slot = s; } |
duke@435 | 393 | void setForceSerialization(bool s) { _force_serialization = s; } |
duke@435 | 394 | void setMayHaveNoCode(bool s) { _may_have_no_code = s; } |
duke@435 | 395 | |
duke@435 | 396 | int InstructionCount() const { return _instruction_count; } |
duke@435 | 397 | bool hasMultipleBundles() const { return _has_multiple_bundles; } |
duke@435 | 398 | bool hasBranchDelay() const { return _has_branch_delay_slot; } |
duke@435 | 399 | bool forceSerialization() const { return _force_serialization; } |
duke@435 | 400 | bool mayHaveNoCode() const { return _may_have_no_code; } |
duke@435 | 401 | |
duke@435 | 402 | void dump(); // Debug printer |
duke@435 | 403 | void output(FILE *fp); // Write info to output files |
duke@435 | 404 | }; |
duke@435 | 405 | |
duke@435 | 406 | |
duke@435 | 407 | //==============================Peephole Optimization========================== |
duke@435 | 408 | //------------------------------Peephole--------------------------------------- |
duke@435 | 409 | class Peephole : public Form { |
duke@435 | 410 | private: |
duke@435 | 411 | static int _peephole_counter;// Incremented by each peephole rule parsed |
duke@435 | 412 | int _peephole_number;// Remember my order in architecture description |
duke@435 | 413 | PeepMatch *_match; // Instruction pattern to match |
duke@435 | 414 | PeepConstraint *_constraint; // List of additional constraints |
duke@435 | 415 | PeepReplace *_replace; // Instruction pattern to substitute in |
duke@435 | 416 | |
duke@435 | 417 | Peephole *_next; |
duke@435 | 418 | |
duke@435 | 419 | public: |
duke@435 | 420 | // Public Methods |
duke@435 | 421 | Peephole(); |
duke@435 | 422 | ~Peephole(); |
duke@435 | 423 | |
duke@435 | 424 | // Append a peephole rule with the same root instruction |
duke@435 | 425 | void append_peephole(Peephole *next_peephole); |
duke@435 | 426 | |
duke@435 | 427 | // Store the components of this peephole rule |
duke@435 | 428 | void add_match(PeepMatch *only_one_match); |
duke@435 | 429 | void append_constraint(PeepConstraint *next_constraint); |
duke@435 | 430 | void add_replace(PeepReplace *only_one_replacement); |
duke@435 | 431 | |
duke@435 | 432 | // Access the components of this peephole rule |
duke@435 | 433 | int peephole_number() { return _peephole_number; } |
duke@435 | 434 | PeepMatch *match() { return _match; } |
duke@435 | 435 | PeepConstraint *constraints() { return _constraint; } |
duke@435 | 436 | PeepReplace *replacement() { return _replace; } |
duke@435 | 437 | Peephole *next() { return _next; } |
duke@435 | 438 | |
duke@435 | 439 | void dump(); // Debug printer |
duke@435 | 440 | void output(FILE *fp); // Write info to output files |
duke@435 | 441 | }; |
duke@435 | 442 | |
duke@435 | 443 | |
duke@435 | 444 | class PeepMatch : public Form { |
duke@435 | 445 | private: |
duke@435 | 446 | char *_rule; |
duke@435 | 447 | // NameList _depth; // Depth of this instruction |
duke@435 | 448 | NameList _parent; |
duke@435 | 449 | NameList _position; |
duke@435 | 450 | NameList _instrs; // List of instructions in match rule |
duke@435 | 451 | NameList _input; // input position in parent's instruction |
duke@435 | 452 | int _max_position; |
duke@435 | 453 | |
duke@435 | 454 | public: |
duke@435 | 455 | // Public Methods |
duke@435 | 456 | PeepMatch(char *rule); |
duke@435 | 457 | ~PeepMatch(); |
duke@435 | 458 | |
duke@435 | 459 | // Insert info into the match-rule |
duke@435 | 460 | void add_instruction(int parent, int position, const char *name, int input); |
duke@435 | 461 | |
duke@435 | 462 | // Access info about instructions in the peep-match rule |
duke@435 | 463 | int max_position(); |
twisti@1038 | 464 | const char *instruction_name(int position); |
duke@435 | 465 | // Iterate through all info on matched instructions |
duke@435 | 466 | void reset(); |
twisti@1038 | 467 | void next_instruction(int &parent, int &position, const char* &name, int &input); |
duke@435 | 468 | // 'true' if current position in iteration is a placeholder, not matched. |
duke@435 | 469 | bool is_placeholder(); |
duke@435 | 470 | |
duke@435 | 471 | void dump(); |
duke@435 | 472 | void output(FILE *fp); |
duke@435 | 473 | }; |
duke@435 | 474 | |
duke@435 | 475 | |
duke@435 | 476 | class PeepConstraint : public Form { |
duke@435 | 477 | private: |
duke@435 | 478 | PeepConstraint *_next; // Additional constraints ANDed together |
duke@435 | 479 | |
duke@435 | 480 | public: |
twisti@1038 | 481 | const int _left_inst; |
twisti@1038 | 482 | const char* _left_op; |
twisti@1038 | 483 | const char* _relation; |
twisti@1038 | 484 | const int _right_inst; |
twisti@1038 | 485 | const char* _right_op; |
duke@435 | 486 | |
duke@435 | 487 | public: |
duke@435 | 488 | // Public Methods |
twisti@1038 | 489 | PeepConstraint(int left_inst, char* left_op, char* relation, |
twisti@1038 | 490 | int right_inst, char* right_op); |
duke@435 | 491 | ~PeepConstraint(); |
duke@435 | 492 | |
duke@435 | 493 | // Check if constraints use instruction at position |
twisti@1038 | 494 | bool constrains_instruction(int position); |
duke@435 | 495 | |
duke@435 | 496 | // Add another constraint |
duke@435 | 497 | void append(PeepConstraint *next_peep_constraint); |
duke@435 | 498 | // Access the next constraint in the list |
duke@435 | 499 | PeepConstraint *next(); |
duke@435 | 500 | |
duke@435 | 501 | void dump(); |
duke@435 | 502 | void output(FILE *fp); |
duke@435 | 503 | }; |
duke@435 | 504 | |
duke@435 | 505 | |
duke@435 | 506 | class PeepReplace : public Form { |
duke@435 | 507 | private: |
duke@435 | 508 | char *_rule; |
duke@435 | 509 | NameList _instruction; |
duke@435 | 510 | NameList _operand_inst_num; |
duke@435 | 511 | NameList _operand_op_name; |
duke@435 | 512 | |
duke@435 | 513 | public: |
duke@435 | 514 | |
duke@435 | 515 | // Public Methods |
duke@435 | 516 | PeepReplace(char *rule); |
duke@435 | 517 | ~PeepReplace(); |
duke@435 | 518 | |
duke@435 | 519 | // Add contents of peepreplace |
duke@435 | 520 | void add_instruction(char *root); |
duke@435 | 521 | void add_operand( int inst_num, char *inst_operand ); |
duke@435 | 522 | |
duke@435 | 523 | // Access contents of peepreplace |
duke@435 | 524 | void reset(); |
duke@435 | 525 | void next_instruction(const char * &root); |
twisti@1038 | 526 | void next_operand(int &inst_num, const char * &inst_operand ); |
duke@435 | 527 | |
duke@435 | 528 | // Utilities |
duke@435 | 529 | void dump(); |
duke@435 | 530 | void output(FILE *fp); |
duke@435 | 531 | }; |
duke@435 | 532 | |
duke@435 | 533 | |
duke@435 | 534 | class PeepChild : public Form { |
duke@435 | 535 | public: |
duke@435 | 536 | const int _inst_num; // Number of instruction (-1 if only named) |
duke@435 | 537 | const char *_inst_op; // Instruction's operand, NULL if number == -1 |
duke@435 | 538 | const char *_inst_name; // Name of the instruction |
duke@435 | 539 | |
duke@435 | 540 | public: |
duke@435 | 541 | PeepChild(char *inst_name) |
duke@435 | 542 | : _inst_num(-1), _inst_op(NULL), _inst_name(inst_name) {}; |
duke@435 | 543 | PeepChild(int inst_num, char *inst_op, char *inst_name) |
duke@435 | 544 | : _inst_num(inst_num), _inst_op(inst_op), _inst_name(inst_name) {}; |
duke@435 | 545 | ~PeepChild(); |
duke@435 | 546 | |
duke@435 | 547 | bool use_leaf_operand() { return _inst_num != -1; }; |
duke@435 | 548 | bool generate_an_instruction() { return _inst_num == -1; } |
duke@435 | 549 | |
duke@435 | 550 | void dump(); |
duke@435 | 551 | void output(FILE *fp); |
duke@435 | 552 | }; |
stefank@2314 | 553 | |
stefank@2314 | 554 | #endif // SHARE_VM_ADLC_FORMSOPT_HPP |