[llvm-commits] CVS: llvm/docs/LangRef.html

Chris Lattner lattner at cs.uiuc.edu
Thu Feb 12 11:02:02 PST 2004


Changes in directory llvm/docs:

LangRef.html updated: 1.43 -> 1.44

---
Log message:

Document the llvm.memcpy intrinsic.  Clean up some of the formatting of other
sections


---
Diffs of the changes:  (+109 -23)

Index: llvm/docs/LangRef.html
diff -u llvm/docs/LangRef.html:1.43 llvm/docs/LangRef.html:1.44
--- llvm/docs/LangRef.html:1.43	Mon Jan  5 23:31:32 2004
+++ llvm/docs/LangRef.html	Thu Feb 12 11:01:32 2004
@@ -95,6 +95,11 @@
           <li><a href="#i_va_copy">'<tt>llvm.va_copy</tt>'  Intrinsic</a></li>
         </ol>
       </li>
+      <li><a href="#int_libc">Standard C Library Intrinsics</a>
+        <ol>
+          <li><a href="#i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a></li>
+        </ol>
+      </li>
       <li><a href="#int_debugger">Debugger intrinsics</a>
     </ol>
   </li>
@@ -1594,23 +1599,31 @@
 <!-- *********************************************************************** -->
 
 <div class="doc_text">
-<p>LLVM supports the notion of an "intrinsic function".  These
-functions have well known names and semantics, and are required to
-follow certain restrictions. Overall, these instructions represent an
-extension mechanism for the LLVM language that does not require
-changing all of the transformations in LLVM to add to the language (or
-the bytecode reader/writer, the parser, etc...).</p>
-<p>Intrinsic function names must all start with an "<tt>llvm.</tt>"
-prefix, this prefix is reserved in LLVM for intrinsic names, thus
-functions may not be named this.  Intrinsic functions must always be
-external functions: you cannot define the body of intrinsic functions. 
-Intrinsic functions may only be used in call or invoke instructions: it
-is illegal to take the address of an intrinsic function.  Additionally,
-because intrinsic functions are part of the LLVM language, it is
-required that they all be documented here if any are added.</p>
-<p>Unless an intrinsic function is target-specific, there must be a
-lowering pass to eliminate the intrinsic or all backends must support
-the intrinsic function.</p>
+
+<p>LLVM supports the notion of an "intrinsic function".  These functions have
+well known names and semantics, and are required to follow certain
+restrictions. Overall, these instructions represent an extension mechanism for
+the LLVM language that does not require changing all of the transformations in
+LLVM to add to the language (or the bytecode reader/writer, the parser,
+etc...).</p>
+
+<p>Intrinsic function names must all start with an "<tt>llvm.</tt>" prefix, this
+prefix is reserved in LLVM for intrinsic names, thus functions may not be named
+this.  Intrinsic functions must always be external functions: you cannot define
+the body of intrinsic functions.  Intrinsic functions may only be used in call
+or invoke instructions: it is illegal to take the address of an intrinsic
+function.  Additionally, because intrinsic functions are part of the LLVM
+language, it is required that they all be documented here if any are added.</p>
+
+
+<p>
+Adding an intrinsic to LLVM is straight-forward if it is possible to express the
+concept in LLVM directly (ie, code generator support is not _required_).  To do
+this, extend the default implementation of the IntrinsicLowering class to handle
+the intrinsic.  Code generators use this class to lower intrinsics they do not
+understand to raw LLVM instructions that they do.
+</p>
+
 </div>
 
 <!-- ======================================================================= -->
@@ -1631,11 +1644,26 @@
 <p>This example shows how the <a href="#i_vanext"><tt>vanext</tt></a>
 instruction and the variable argument handling intrinsic functions are
 used.</p>
-<pre>int %test(int %X, ...) {<br>  ; Initialize variable argument processing<br>  %ap = call sbyte*()* %<a
- href="#i_va_start">llvm.va_start</a>()<br><br>  ; Read a single integer argument<br>  %tmp = vaarg sbyte* %ap, int<br><br>  ; Advance to the next argument<br>  %ap2 = vanext sbyte* %ap, int<br><br>  ; Demonstrate usage of llvm.va_copy and llvm.va_end<br>  %aq = call sbyte* (sbyte*)* %<a
- href="#i_va_copy">llvm.va_copy</a>(sbyte* %ap2)<br>  call void %<a
- href="#i_va_end">llvm.va_end</a>(sbyte* %aq)<br><br>  ; Stop processing of arguments.<br>  call void %<a
- href="#i_va_end">llvm.va_end</a>(sbyte* %ap2)<br>  ret int %tmp<br>}<br></pre>
+<pre>
+int %test(int %X, ...) {
+  ; Initialize variable argument processing
+  %ap = call sbyte* %<a href="#i_va_start">llvm.va_start</a>()
+
+  ; Read a single integer argument
+  %tmp = vaarg sbyte* %ap, int
+
+  ; Advance to the next argument
+  %ap2 = vanext sbyte* %ap, int
+
+  ; Demonstrate usage of llvm.va_copy and llvm.va_end
+  %aq = call sbyte* %<a href="#i_va_copy">llvm.va_copy</a>(sbyte* %ap2)
+  call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %aq)
+
+  ; Stop processing of arguments.
+  call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %ap2)
+  ret int %tmp
+}
+</pre>
 </div>
 
 <!-- _______________________________________________________________________ -->
@@ -1704,6 +1732,64 @@
 complex and require memory allocation, for example.</p>
 </div>
 
+<!-- ======================================================================= -->
+<div class="doc_subsection">
+  <a name="int_libc">Standard C Library Intrinsics</a>
+</div>
+
+<div class="doc_text">
+<p>
+
+</p>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
+  <a name="i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a>
+</div>
+
+<div class="doc_text">
+
+<h5>Syntax:</h5>
+<pre>
+  call void (sbyte*, sbyte*, uint, uint)* %llvm.memcpy(sbyte* <dest>, sbyte* <src>,
+                                                       uint <len>, uint <align>)
+</pre>
+
+<h5>Overview:</h5>
+
+<p>
+The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source
+location to the destination location.
+</p>
+
+<p>
+Note that, unlike the standard libc function, the <tt>llvm.memcpy</tt> intrinsic
+does not return a value, and takes an extra alignment argument.
+</p>
+
+<h5>Arguments:</h5>
+
+<p>
+The first argument is a pointer to the destination, the second is a pointer to
+the source.  The third argument is an (arbitrarily sized) integer argument
+specifying the number of bytes to copy, and the fourth argument is the alignment
+of the source and destination locations.
+</p>
+
+<h5>Semantics:</h5>
+
+<p>
+The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source
+location to the destination location, which are not allowed to overlap.  It
+copies "len" bytes of memory over.  If the argument is known to be aligned to
+some boundary, this can be specified as the fourth argument, otherwise it should
+be set to 0 or 1.
+</p>
+</div>
+
+
 
 <!-- ======================================================================= -->
 <div class="doc_subsection">
@@ -1725,6 +1811,6 @@
 <div class="doc_footer">
 <address><a href="mailto:sabre at nondot.org">Chris Lattner</a></address>
 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a> <br>
-Last modified: $Date: 2004/01/06 05:31:32 $ </div>
+Last modified: $Date: 2004/02/12 17:01:32 $ </div>
 </body>
 </html>





More information about the llvm-commits mailing list