Merging r259798, r259835:
[oota-llvm.git] / docs / MIRLangRef.rst
index d49bd97136e3ed0555e6fef93149b038c8bc0da3..a5f8c8c743ab2829b79f1b3fcd434dbb4a691190 100644 (file)
@@ -99,6 +99,8 @@ depends on the state of the target specific ``MachineFunctionInfo`` or
 High Level Structure
 ====================
 
+.. _embedded-module:
+
 Embedded Module
 ---------------
 
@@ -378,7 +380,8 @@ Register Operands
 The :ref:`register <registers>` primitive is used to represent the register
 machine operands. The register operands can also have optional
 :ref:`register flags <register-flags>`,
-a subregister index, and a reference to the tied register operand.
+:ref:`a subregister index <subregister-indices>`,
+and a reference to the tied register operand.
 The full syntax of a register operand is shown below:
 
 .. code-block:: llvm
@@ -433,13 +436,48 @@ corresponding internal ``llvm::RegState`` representation:
    * - ``debug-use``
      - ``RegState::Debug``
 
+.. _subregister-indices:
+
+Subregister Indices
+~~~~~~~~~~~~~~~~~~~
+
+The register machine operands can reference a portion of a register by using
+the subregister indices. The example below shows an instance of the ``COPY``
+pseudo instruction that uses the X86 ``sub_8bit`` subregister index to copy 8
+lower bits from the 32-bit virtual register 0 to the 8-bit virtual register 1:
+
+.. code-block:: llvm
+
+    %1 = COPY %0:sub_8bit
+
+The names of the subregister indices are target specific, and are typically
+defined in the target's ``*RegisterInfo.td`` file.
+
+Global Value Operands
+^^^^^^^^^^^^^^^^^^^^^
+
+The global value machine operands reference the global values from the
+:ref:`embedded LLVM IR module <embedded-module>`.
+The example below shows an instance of the X86 ``MOV64rm`` instruction that has
+a global value operand named ``G``:
+
+.. code-block:: llvm
+
+    %rax = MOV64rm %rip, 1, _, @G, _
+
+The named global values are represented using an identifier with the '@' prefix.
+If the identifier doesn't match the regular expression
+`[-a-zA-Z$._][-a-zA-Z$._0-9]*`, then this identifier must be quoted.
+
+The unnamed global values are represented using an unsigned numeric value with
+the '@' prefix, like in the following examples: ``@0``, ``@989``.
+
 .. TODO: Describe the parsers default behaviour when optional YAML attributes
    are missing.
 .. TODO: Describe the syntax for the bundled instructions.
 .. TODO: Describe the syntax for virtual register YAML definitions.
-.. TODO: Describe the syntax of the subregisters.
 .. TODO: Describe the machine function's YAML flag attributes.
-.. TODO: Describe the syntax for the global value, external symbol and register
+.. TODO: Describe the syntax for the external symbol and register
    mask machine operands.
 .. TODO: Describe the frame information YAML mapping.
 .. TODO: Describe the syntax of the stack object machine operands and their