src/hotspot/share/adlc/Doc/Syntax.doc
author coleenp
Wed, 08 Aug 2018 15:24:21 -0400
changeset 51338 aa3bfacc912c
parent 47216 71c04702a3d5
permissions -rw-r--r--
8208677: Move inner metaspace cleaning out of class unloading Summary: move to safepoint cleanup actions to do if needed. Reviewed-by: eosterlund, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
#
32575
059965be379b 8134898: Small fixes found during JVMCI work
kvn
parents: 5547
diff changeset
     2
# Copyright (c) 1997, 2015, 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: 2131
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2131
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: 2131
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
JavaSoft HotSpot Architecture Description Language Syntax Specification
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
Version 0.4 - September 19, 1997
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
A. Introduction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
This document specifies the syntax and associated semantics for the JavaSoft
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
HotSpot Architecture Description Language.  This language is used to describe
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
the architecture of a processor, and is the input to the ADL Compiler.  The
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
ADL Compiler compiles an ADL file into code which is incorporated into the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
Optimizing Just In Time Compiler (OJIT) to generate efficient and correct code
32575
059965be379b 8134898: Small fixes found during JVMCI work
kvn
parents: 5547
diff changeset
    36
for the target architecture.  The ADL describes three basic different types
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
of architectural features.  It describes the instruction set (and associated
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
operands) of the target architecture.  It describes the register set of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
target architecture along with relevant information for the register allocator.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
Finally, it describes the architecture's pipeline for scheduling purposes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
The ADL is used to create an architecture description file for a target
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
architecture.  The architecture description file along with some additional
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
target specific oracles, written in C++, represent the principal effort in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
porting the OJIT to a new target architecture.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
B. Example Syntax
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
	1. Instruction/Operand Syntax for Matching and Encoding
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// Create a cost attribute for all operands, and specify the default value
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
op_attrib  op_cost(10);	
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// Create a cost attribute for all instruction, and specify a default value
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
ins_attrib ins_cost(100);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
// example operand form
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
operand x_reg(REG_NUM rnum)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
%{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
	constraint(IS_RCLASS(rnum, RC_X_REG));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
	match(VREG) %{ rnum = new_VR(); %} // block after rule is constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
	encode %{ return rnum; %}          // encode rules are required
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
	// this operand has no op_cost entry because it uses the default value
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
%}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// example instruction form
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
instruct add_accum_reg(x_reg dst, reg src)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
%{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
	match(SET dst (PLUS dst src)); // no block = use default constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
	encode			       // rule is body of a C++ function
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
	%{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
	    return pentium_encode_add_accum_reg(rnum);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
	%}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
	ins_cost(200);	// this instruction is more costly than the default
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
%}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
	2. Register Set Description Syntax for Allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
reg_def AX(SOE, 1); // declare register AX, mark it save on entry with index 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
reg_def BX(SOC);    // declare register BX, and mark it save on call
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
reg_class X_REG(AX, BX); // form a matcher register class of X_REG
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
                         // these are used for constraints, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
alloc_class class1(AX, BX); // form an allocation class of registers
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1
diff changeset
    91
                            // used by the register allocator for separate
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
                            // allocation of target register classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
	3. Pipeline Syntax for Scheduling
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
C. Keywords
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
1. Matching/Encoding 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
	a. instruct    - indicates a machine instruction entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
	b. operand     - indicates a machine operand entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
	c. opclass     - indicates a class of machine operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
	d. source      - indicates a block of C++ source code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
	e. op_attrib   - indicates an optional attribute for all operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
	f. ins_attrib  - indicates an optional attribute for all instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
	g. match       - indicates a matching rule for an operand/instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
	h. encode      - indicates an encoding rule for an operand/instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
	i. predicate   - indicates a predicate for matching operand/instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
       *j. constraint  - indicates a constraint on the value of an operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
       *k. effect      - describes the dataflow effect of an operand which 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
			 is not part of a match rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
       *l. expand      - indicates a single instruction for matching which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
			 expands to multiple instructions for output
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
       *m. rewrite     - indicates a single instruction for matching which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
			 gets rewritten to one or more instructions after
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
			 allocation depending upon the registers allocated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
       *n. format      - indicates a format rule for an operand/instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
	o. construct   - indicates a default constructor for an operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
	[NOTE: * indicates a feature which will not be in first release ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
2. Register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
       *a. register    - indicates an architecture register definition section
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
       *b. reg_def     - indicates a register declaration
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
       *b. reg_class   - indicates a class (list) of registers for matching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
       *c. alloc_class - indicates a class (list) of registers for allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
3. Pipeline
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
       *a. pipeline    - indicates an architecture pipeline definition section
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
       *b. resource    - indicates a pipeline resource used by instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
       *c. pipe_desc   - indicates the relevant stages of the pipeline
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
       *d. pipe_class  - indicates a description of the pipeline behavior
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
	   		 for a group of instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
       *e. ins_pipe    - indicates what pipeline class an instruction is in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
D. Delimiters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
	1. Comments
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
		a. /* ... */  (like C code)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
		b. // ... EOL (like C++ code)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
		c. Comments must be preceeded by whitespace
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
	2. Blocks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
		a. %{ ... %} (% just distinguishes from C++ syntax)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
		b. Must be whitespace before and after block delimiters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
	3. Terminators
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
		a. ;   (standard statement terminator)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
		b. %}  (block terminator)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
		c. EOF (file terminator)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1
diff changeset
   153
	4. Each statement must start on a separate line
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
	5. Identifiers cannot contain: (){}%;,"/\
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
E. Instruction Form: instruct instr1(oper1 dst, oper2 src) %{ ... %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
	1.  Identifier (scope of all instruction names is global in ADL file)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
	2.  Operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
		a. Specified in argument style: (<type> <name>, ...)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
		b. Type must be the name of an Operand Form
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
		c. Name is a locally scoped name, used for substitution, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
	3.  Match Rule: match(SET dst (PLUS dst src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
		a. Parenthesized Inorder Binary Tree: [lft = left; rgh = right]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
		   (root root->lft (root->rgh (root->rgh->lft root->rgh->rgh)))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
		b. Interior nodes in tree are operators (nodes) in abstract IR
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
		c. Leaves are operands from instruction operand list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
		d. Assignment operation and destination, which are implicit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
		   in the abstract IR, must be specified in the match rule.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
	4.  Encode Rule: encode %{ return CONST; %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
		a. Block form must contain C++ code which constitutes the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
		   body of a C++ function which takes no arguments, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
		   returns an integer.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
		b. Local names (operand names) are can be used as substitution
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
		   symbols in the code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
	5.  Attribute (ins_attrib): ins_cost(37);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
		a. Identifier (must be name defined as instruction attribute)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
		b. Argument must be a constant value or a C++ expression which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
		   evaluates to a constant at compile time.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
       *6.  Effect: effect(src, OP_KILL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
		a. Arguments must be the name of an operand and one of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
		   pre-defined effect type symbols:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
		   OP_DEF, OP_USE, OP_KILL, OP_USE_DEF, OP_DEF_USE, OP_USE_KILL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
       *7.  Expand: 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
		a. Parameters for the new instructions must be the name of 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
		   an expand rule temporary operand or must match the local
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
		   operand name in both the instruction being expanded and 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
		   the new instruction being generated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
		instruct convI2B( xRegI dst, eRegI src ) %{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  		   match(Set dst (Conv2B src));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
		   expand %{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
	 	     eFlagsReg cr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
			 loadZero(dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
			 testI_zero(cr,src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
			 set_nz(dst,cr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
		   %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
		%}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
		// Move zero into a register without setting flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
		instruct loadZero(eRegI dst) %{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
		  effect( DEF dst );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
		  format %{ "MOV    $dst,0" %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
		  opcode(0xB8); // +rd
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
		  ins_encode( LdI0(dst) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
		%}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
       *8.  Rewrite
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
	9.  Format: format(add_X $src, $dst); | format %{ ... %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
		a. Argument form takes a text string, possibly containing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
		   some substitution symbols, which will be printed out
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
		   to the assembly language file.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
		b. The block form takes valid C++ code which forms the body
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
		   of a function which takes no arguments, and returns a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
		   pointer to a string to print out to the assembly file.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
		Mentions of a literal register r in a or b must be of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
		the form r_enc or r_num. The form r_enc refers to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
		encoding of the register in an instruction. The form
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
		r_num refers to the number of the register. While
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
		r_num is unique, two different registers may have the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
		same r_enc, as, for example, an integer and a floating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
		point register.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
F. Operand Form: operand x_reg(REG_T rall) %{ ... %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
	1.  Identifier (scope of all operand names is global in ADL file)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
	2.  Components
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
		a. Specified in argument style: (<type> <name>, ...)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
		b. Type must be a predefined Component Type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
		c. Name is a locally scoped name, used for substitution, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
	3.  Match: (VREG)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
		a. Parenthesized Inorder Binary Tree: [lft = left; rgh = right]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
		   (root root->lft (root->rgh (root->rgh->lft root->rgh->rgh)))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
		b. Interior nodes in tree are operators (nodes) in abstract IR
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
		c. Leaves are components from operand component list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
		d. Block following tree is the body of a C++ function taking
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
		   no arguments and returning no value, which assigns values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
		   to the components of the operand at match time.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
	4.  Encode: encode %{ return CONST; %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
		a. Block form must contain C++ code which constitutes the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
		   body of a C++ function which takes no arguments, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
		   returns an integer.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
		b. Local names (operand names) are can be used as substitution
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
		   symbols in the code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
	5.  Attribute (op_attrib): op_cost(5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
		a. Identifier (must be name defined as operand attribute)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
		b. Argument must be a constant value or a C++ expression which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
		   evaluates to a constant at compile time.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
	6.  Predicate: predicate(0 <= src < 256);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
		a. Argument must be a valid C++ expression which evaluates
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
		   to either TRUE of FALSE at run time.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
       *7.  Constraint: constraint(IS_RCLASS(dst, RC_X_CLASS));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
                a. Arguments must contain only predefined constraint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
                   functions on values defined in the AD file.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
                b. Multiple arguments can be chained together logically
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
                   with "&&".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
 	8.  Construct: construct %{ ... %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
		a. Block must be a valid C++ function body which takes no
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
		   arguments, and returns no values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
		b. Purpose of block is to assign values to the elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
		   of an operand which is constructed outside the matching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
		   process.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
		c. This block is logically identical to the constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
		   block in a match rule.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
	9.  Format: format(add_X $src, $dst); | format %{ ... %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
		a. Argument form takes a text string, possibly containing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
		   some substitution symbols, which will be printed out
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
		   to the assembly language file.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
		b. The block form takes valid C++ code which forms the body
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
		   of a function which takes no arguments, and returns a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
		   pointer to a string to print out to the assembly file.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
		Mentions of a literal register r in a or b must be of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
		the form r_enc or r_num. The form r_enc refers to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
		encoding of the register in an instruction. The form
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
		r_num refers to the number of the register. While
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
		r_num is unique, two different registers may have the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
		same r_enc, as, for example, an integer and a floating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
		point register.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
G. Operand Class Form: opclass memory( direct, indirect, ind_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
H. Attribute Form (keywords ins_atrib & op_attrib): ins_attrib ins_cost(10);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
	1. Identifier (scope of all attribute names is global in ADL file)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
	2. Argument must be a valid C++ expression which evaluates to a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
	   constant at compile time, and specifies the default value of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
	   this attribute if attribute definition is not included in an
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
	   operand/instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
I. Source Form: source %{ ... %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
	1. Source Block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
		a. All source blocks are delimited by "%{" and "%}".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
		b. All source blocks are copied verbatim into the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
		   C++ output file, and must be valid C++ code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
		   Mentions of a literal register r in this code must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
		   be of the form r_enc or r_num. The form r_enc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
		   refers to the encoding of the register in an
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
		   instruction. The form r_num refers to the number of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
		   the register. While r_num is unique, two different
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
		   registers may have the same r_enc, as, for example,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
		   an integer and a floating point register.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
J. *Register Form: register %{ ... %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
	1. Block contains architecture specific information for allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
	2. Reg_def: reg_def reg_AX(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
		a. Identifier is name by which register will be referenced
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
		   throughout the rest of the AD, and the allocator and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
		   back-end.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
		b. Argument is the Save on Entry index (where 0 means that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
		   the register is Save on Call).  This is used by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
		   frame management routines for generating register saves
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
		   and restores.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
	3. Reg_class: reg_class x_regs(reg_AX, reg_BX, reg_CX, reg_DX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
		a. Identifier is the name of the class used throughout the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
		   instruction selector.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
		b. Arguments are a list of register names in the class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
	4. Alloc_class: alloc_class x_alloc(reg_AX, reg_BX, reg_CX, reg_DX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
		a. Identifier is the name of the class used throughout the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
		   register allocator.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
		b. Arguments are a list of register names in the class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
K. *Pipeline Form: pipeline %{ ... %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
	1. Block contains architecture specific information for scheduling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
	2. Resource: resource(ialu1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
		a. Argument is the name of the resource.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
	3. Pipe_desc: pipe_desc(Address, Access, Read, Execute);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
		a. Arguments are names of relevant phases of the pipeline.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
		b. If ALL instructions behave identically in a pipeline
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
		   phase, it does not need to be specified. (This is typically
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
		   true for pre-fetch, fetch, and decode pipeline stages.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
		c. There must be one name per cycle consumed in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
		   pipeline, even if there is no instruction which has
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
		   significant behavior in that stage (for instance, extra
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
		   stages inserted for load and store instructions which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
		   are just cycles which pass waiting for the completion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
		   of the memory operation).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
	4. Pipe_class: pipe_class pipe_normal(dagen; ; membus; ialu1, ialu2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
		a. Identifier names the class for use in ins_pipe statements
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
		b. Arguments are a list of stages, separated by ;'s which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
		   contain comma separated lists of resource names.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
		c. There must be an entry for each stage defined in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
		   pipe_desc statement, (even if it is empty as in the example)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
		   and entries are associated with stages by the order of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
		   stage declarations in the pipe_desc statement.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350