aboutsummaryrefslogtreecommitdiff
path: root/llvm/docs/LangRef.rst
diff options
context:
space:
mode:
authorIan Hickson <ian@hixie.ch>2024-02-22 05:35:23 -0800
committerGitHub <noreply@github.com>2024-02-22 14:35:23 +0100
commit770fd3856660fea6cbaa78d9cb1f03cc92611783 (patch)
tree6b459caddd30e3ae29dccf44239a3f0e6d0b2f4a /llvm/docs/LangRef.rst
parentafa8a2eed0c4ca61ac19abd88022e63e58408af1 (diff)
downloadllvm-770fd3856660fea6cbaa78d9cb1f03cc92611783.zip
llvm-770fd3856660fea6cbaa78d9cb1f03cc92611783.tar.gz
llvm-770fd3856660fea6cbaa78d9cb1f03cc92611783.tar.bz2
[LangRef] Document string literals in LLVM's format (#82529)
Diffstat (limited to 'llvm/docs/LangRef.rst')
-rw-r--r--llvm/docs/LangRef.rst33
1 files changed, 32 insertions, 1 deletions
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index fd2e3aa..8f4495e 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -61,10 +61,13 @@ run by the parser after parsing input assembly and by the optimizer
before it outputs bitcode. The violations pointed out by the verifier
pass indicate bugs in transformation passes or input to the parser.
+Syntax
+======
+
.. _identifiers:
Identifiers
-===========
+-----------
LLVM identifiers come in two basic types: global and local. Global
identifiers (functions, global variables) begin with the ``'@'``
@@ -140,6 +143,34 @@ It also shows a convention that we follow in this document. When
demonstrating instructions, we will follow an instruction with a comment
that defines the type and name of value produced.
+.. _strings:
+
+String constants
+----------------
+
+Strings in LLVM programs are delimited by ``"`` characters. Within a
+string, all bytes are treated literally with the exception of ``\``
+characters, which start escapes, and the first ``"`` character, which
+ends the string.
+
+There are two kinds of escapes.
+
+* ``\\`` represents a single ``\`` character.
+
+* ``\`` followed by two hexadecimal characters (0-9, a-f, or A-F)
+ represents the byte with the given value (e.g. \x00 represents a
+ null byte).
+
+To represent a ``"`` character, use ``\22``. (``\"`` will end the string
+with a trailing ``\``.)
+
+Newlines do not terminate string constants; strings can span multiple
+lines.
+
+The interpretation of string constants (e.g. their character encoding)
+depends on context.
+
+
High Level Structure
====================