@@ -15,7 +15,7 @@ A legal instruction is defined as:
1515* operating on **vregs that can be loaded and stored ** -- if necessary, the
1616 target can select a ``G_LOAD ``/``G_STORE `` of each gvreg operand.
1717
18- As opposed to SelectionDAG, there are no legalization phases. In particular,
18+ Unlike SelectionDAG, there are no legalization phases. In particular,
1919'type' and 'operation' legalization are not separate.
2020
2121Legalization is iterative, and all state is contained in GMIR. To maintain the
@@ -44,7 +44,7 @@ have a ``G_FOO`` instruction of the form::
4444 %1:_(s32) = G_CONSTANT i32 1
4545 %2:_(s32) = G_FOO %0:_(s32), %1:_(s32)
4646
47- it's impossible to say that G_FOO is legal iff %1 is a ``G_CONSTANT `` with
47+ it's impossible to say that `` G_FOO `` is legal iff %1 is a ``G_CONSTANT `` with
4848value ``1 ``. However, the following::
4949
5050 %2:_(s32) = G_FOO %0:_(s32), i32 1
@@ -93,8 +93,8 @@ legality contains:
9393
9494.. rubric :: Footnotes
9595
96- .. [#legalizer-legacy-footnote ] An API is broadly similar to
97- SelectionDAG/TargetLowering is available but is not recommended as a more
96+ .. [#legalizer-legacy-footnote ] An API that is broadly similar to
97+ SelectionDAG/TargetLowering is available, but is not recommended as a more
9898 powerful API is available.
9999
100100 Rule Processing and Declaring Rules
@@ -108,10 +108,10 @@ legalized as a result of the rules. If the ruleset is exhausted without
108108satisfying any rule, then it is considered unsupported.
109109
110110When it doesn't declare the instruction legal, each pass over the rules may
111- request that one type changes to another type. Sometimes this can cause multiple
111+ request that one type be changed to another type. Sometimes this can cause multiple
112112types to change but we avoid this as much as possible as making multiple changes
113113can make it difficult to avoid infinite loops where, for example, narrowing one
114- type causes another to be too small and widening that type causes the first one
114+ type causes another to be too small, and widening that type causes the first one
115115to be too big.
116116
117117In general, it's advisable to declare instructions legal as close to the top of
@@ -130,7 +130,7 @@ and the instruction::
130130
131131 %2:_(s7) = G_ADD %0:_(s7), %1:_(s7)
132132
133- this doesn't meet the predicate for the :ref: `.legalFor() <legalfor >` as ``s7 ``
133+ This doesn't meet the predicate for the :ref: `.legalFor() <legalfor >` as ``s7 ``
134134is not one of the listed types so it falls through to the
135135:ref: `.clampScalar() <clampscalar >`. It does meet the predicate for this rule
136136as the type is smaller than the ``s32 `` and this rule instructs the legalizer
@@ -148,7 +148,7 @@ processing by the legalizer.
148148Rule Actions
149149""""""""""""
150150
151- There are various rule factories that append rules to a ruleset but they have a
151+ There are various rule factories that append rules to a ruleset, but they have a
152152few actions in common:
153153
154154.. _legalfor :
@@ -202,7 +202,7 @@ few actions in common:
202202Rule Predicates
203203"""""""""""""""
204204
205- The rule factories also have predicates in common:
205+ The rule factories also have the following predicates in common:
206206
207207* ``legal() ``, ``lower() ``, etc. are always satisfied.
208208
@@ -269,81 +269,81 @@ Consumer Type Set
269269 The set of types which is the union of all possible types consumed by at
270270 least one legal instruction.
271271
272- Both sets are often identical but there's no guarantee of that. For example,
272+ Both sets are often identical, but there's no guarantee of that. For example,
273273it's not uncommon to be unable to consume s64 but still be able to produce it
274274for a few specific instructions.
275275
276276Minimum Rules For Scalars
277277"""""""""""""""""""""""""
278278
279- * G_ANYEXT must be legal for all inputs from the producer type set and all larger
279+ * `` G_ANYEXT `` must be legal for all inputs from the producer type set and all larger
280280 outputs from the consumer type set.
281- * G_TRUNC must be legal for all inputs from the producer type set and all
281+ * `` G_TRUNC `` must be legal for all inputs from the producer type set and all
282282 smaller outputs from the consumer type set.
283283
284- G_ANYEXT, and G_TRUNC have mandatory legality since the GMIR requires a means to
284+ `` G_ANYEXT `` and `` G_TRUNC `` have mandatory legality since the GMIR requires a means to
285285connect operations with different type sizes. They are usually trivial to support
286- since G_ANYEXT doesn't define the value of the additional bits and G_TRUNC is
287- discarding bits. The other conversions can be lowered into G_ANYEXT/ G_TRUNC
286+ since `` G_ANYEXT `` doesn't define the value of the additional bits and `` G_TRUNC `` is
287+ discarding bits. The other conversions can be lowered into `` G_ANYEXT ``/`` G_TRUNC ``
288288with some additional operations that are subject to further legalization. For
289- example, G_SEXT can lower to::
289+ example, `` G_SEXT `` can lower to::
290290
291291 %1 = G_ANYEXT %0
292292 %2 = G_CONSTANT ...
293293 %3 = G_SHL %1, %2
294294 %4 = G_ASHR %3, %2
295295
296- and the G_CONSTANT/ G_SHL/ G_ASHR can further lower to other operations or target
297- instructions. Similarly, G_FPEXT has no legality requirement since it can lower
298- to a G_ANYEXT followed by a target instruction.
296+ and the `` G_CONSTANT ``/`` G_SHL ``/`` G_ASHR `` can further lower to other operations or target
297+ instructions. Similarly, `` G_FPEXT `` has no legality requirement since it can lower
298+ to a `` G_ANYEXT `` followed by a target instruction.
299299
300- G_MERGE_VALUES and G_UNMERGE_VALUES do not have legality requirements since the
301- former can lower to G_ANYEXT and some other legalizable instructions, while the
302- latter can lower to some legalizable instructions followed by G_TRUNC.
300+ `` G_MERGE_VALUES `` and `` G_UNMERGE_VALUES `` do not have legality requirements since the
301+ former can lower to `` G_ANYEXT `` and some other legalizable instructions, while the
302+ latter can lower to some legalizable instructions followed by `` G_TRUNC `` .
303303
304304Minimum Legality For Vectors
305305""""""""""""""""""""""""""""
306306
307307Within the vector types, there aren't any defined conversions in LLVM IR as
308308vectors are often converted by reinterpreting the bits or by decomposing the
309- vector and reconstituting it as a different type. As such, G_BITCAST is the
309+ vector and reconstituting it as a different type. As such, `` G_BITCAST `` is the
310310only operation to account for. We generally don't require that it's legal
311- because it can usually be lowered to COPY (or to nothing using
312- replaceAllUses()). However, there are situations where G_BITCAST is non-trivial
311+ because it can usually be lowered to `` COPY `` (or to nothing using
312+ `` replaceAllUses() `` ). However, there are situations where `` G_BITCAST `` is non-trivial
313313(e.g. little-endian vectors of big-endian data such as on big-endian MIPS MSA and
314- big-endian ARM NEON, see `_i_bitcast `). To account for this G_BITCAST must be
314+ big-endian ARM NEON, see `_i_bitcast `). To account for this, `` G_BITCAST `` must be
315315legal for all type combinations that change the bit pattern in the value.
316316
317- There are no legality requirements for G_BUILD_VECTOR, or G_BUILD_VECTOR_TRUNC
317+ There are no legality requirements for `` G_BUILD_VECTOR `` , or `` G_BUILD_VECTOR_TRUNC ``
318318since these can be handled by:
319319* Declaring them legal.
320320* Scalarizing them.
321- * Lowering them to G_TRUNC+ G_ANYEXT and some legalizable instructions.
321+ * Lowering them to `` G_TRUNC``+`` G_ANYEXT `` and some legalizable instructions.
322322* Lowering them to target instructions which are legal by definition.
323323
324- The same reasoning also allows G_UNMERGE_VALUES to lack legality requirements
324+ The same reasoning also allows `` G_UNMERGE_VALUES `` to lack legality requirements
325325for vector inputs.
326326
327327Minimum Legality for Pointers
328328"""""""""""""""""""""""""""""
329329
330- There are no minimum rules for pointers since G_INTTOPTR and G_PTRTOINT can
331- be selected to a COPY from register class to another by the legalizer.
330+ There are no minimum rules for pointers since `` G_INTTOPTR `` and `` G_PTRTOINT `` can
331+ be selected to a `` COPY `` from register class to another by the legalizer.
332332
333333Minimum Legality For Operations
334334"""""""""""""""""""""""""""""""
335335
336- The rules for G_ANYEXT, G_MERGE_VALUES, G_BITCAST, G_BUILD_VECTOR,
337- G_BUILD_VECTOR_TRUNC, G_CONCAT_VECTORS, G_UNMERGE_VALUES, G_PTRTOINT, and
338- G_INTTOPTR have already been noted above. In addition to those, the following
336+ The rules for `` G_ANYEXT ``, `` G_MERGE_VALUES ``, `` G_BITCAST ``, `` G_BUILD_VECTOR `` ,
337+ `` G_BUILD_VECTOR_TRUNC ``, `` G_CONCAT_VECTORS ``, `` G_UNMERGE_VALUES ``, `` G_PTRTOINT `` , and
338+ `` G_INTTOPTR `` have already been noted above. In addition to those, the following
339339operations have requirements:
340340
341- * For every type that can be produced by any instruction, G_IMPLICIT_DEF must be
342- legal .
343- * G_PHI must be legal for all types in the producer and consumer typesets. This
341+ * `` G_IMPLICIT_DEF `` must be legal for every type that can be produced
342+ by any instruction .
343+ * `` G_PHI `` must be legal for all types in the producer and consumer typesets. This
344344 is usually trivial as it requires no code to be selected.
345- * At least one G_FRAME_INDEX must be legal
346- * At least one G_BLOCK_ADDR must be legal
345+ * At least one `` G_FRAME_INDEX `` must be legal
346+ * At least one `` G_BLOCK_ADDR `` must be legal
347347
348- There are many other operations you'd expect to have legality requirements but
348+ There are many other operations you'd expect to have legality requirements, but
349349they can be lowered to target instructions which are legal by definition.
0 commit comments