| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | 
|  | 2 | "http://www.w3.org/TR/html4/strict.dtd"> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3 | <html> | 
|  | 4 | <head> | 
|  | 5 | <title>LLVM Assembly Language Reference Manual</title> | 
| Reid Spencer | 3921c74 | 2004-08-26 20:44:00 +0000 | [diff] [blame] | 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | 
|  | 7 | <meta name="author" content="Chris Lattner"> | 
|  | 8 | <meta name="description" | 
|  | 9 | content="LLVM Assembly Language Reference Manual."> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 10 | <link rel="stylesheet" href="llvm.css" type="text/css"> | 
|  | 11 | </head> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 12 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 13 | <body> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 14 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 15 | <div class="doc_title"> LLVM Language Reference Manual </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 16 | <ol> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 17 | <li><a href="#abstract">Abstract</a></li> | 
|  | 18 | <li><a href="#introduction">Introduction</a></li> | 
|  | 19 | <li><a href="#identifiers">Identifiers</a></li> | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 20 | <li><a href="#highlevel">High Level Structure</a> | 
|  | 21 | <ol> | 
|  | 22 | <li><a href="#modulestructure">Module Structure</a></li> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 23 | <li><a href="#linkage">Linkage Types</a></li> | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 24 | <li><a href="#globalvars">Global Variables</a></li> | 
|  | 25 | <li><a href="#functionstructure">Function Structure</a></li> | 
|  | 26 | </ol> | 
|  | 27 | </li> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 28 | <li><a href="#typesystem">Type System</a> | 
|  | 29 | <ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 30 | <li><a href="#t_primitive">Primitive Types</a> | 
|  | 31 | <ol> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 32 | <li><a href="#t_classifications">Type Classifications</a></li> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 33 | </ol> | 
|  | 34 | </li> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 35 | <li><a href="#t_derived">Derived Types</a> | 
|  | 36 | <ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 37 | <li><a href="#t_array">Array Type</a></li> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 38 | <li><a href="#t_function">Function Type</a></li> | 
|  | 39 | <li><a href="#t_pointer">Pointer Type</a></li> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 40 | <li><a href="#t_struct">Structure Type</a></li> | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 41 | <li><a href="#t_packed">Packed Type</a></li> | 
| Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 42 | <li><a href="#t_opaque">Opaque Type</a></li> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 43 | </ol> | 
|  | 44 | </li> | 
|  | 45 | </ol> | 
|  | 46 | </li> | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 47 | <li><a href="#constants">Constants</a> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 48 | <ol> | 
|  | 49 | <li><a href="#simpleconstants">Simple Constants</a> | 
|  | 50 | <li><a href="#aggregateconstants">Aggregate Constants</a> | 
|  | 51 | <li><a href="#globalconstants">Global Variable and Function Addresses</a> | 
|  | 52 | <li><a href="#undefvalues">Undefined Values</a> | 
|  | 53 | <li><a href="#constantexprs">Constant Expressions</a> | 
|  | 54 | </ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 55 | </li> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 56 | <li><a href="#instref">Instruction Reference</a> | 
|  | 57 | <ol> | 
|  | 58 | <li><a href="#terminators">Terminator Instructions</a> | 
|  | 59 | <ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 60 | <li><a href="#i_ret">'<tt>ret</tt>' Instruction</a></li> | 
|  | 61 | <li><a href="#i_br">'<tt>br</tt>' Instruction</a></li> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 62 | <li><a href="#i_switch">'<tt>switch</tt>' Instruction</a></li> | 
|  | 63 | <li><a href="#i_invoke">'<tt>invoke</tt>' Instruction</a></li> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 64 | <li><a href="#i_unwind">'<tt>unwind</tt>'  Instruction</a></li> | 
| Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 65 | <li><a href="#i_unreachable">'<tt>unreachable</tt>' Instruction</a></li> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 66 | </ol> | 
|  | 67 | </li> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 68 | <li><a href="#binaryops">Binary Operations</a> | 
|  | 69 | <ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 70 | <li><a href="#i_add">'<tt>add</tt>' Instruction</a></li> | 
|  | 71 | <li><a href="#i_sub">'<tt>sub</tt>' Instruction</a></li> | 
|  | 72 | <li><a href="#i_mul">'<tt>mul</tt>' Instruction</a></li> | 
|  | 73 | <li><a href="#i_div">'<tt>div</tt>' Instruction</a></li> | 
|  | 74 | <li><a href="#i_rem">'<tt>rem</tt>' Instruction</a></li> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 75 | <li><a href="#i_setcc">'<tt>set<i>cc</i></tt>' Instructions</a></li> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 76 | </ol> | 
|  | 77 | </li> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 78 | <li><a href="#bitwiseops">Bitwise Binary Operations</a> | 
|  | 79 | <ol> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 80 | <li><a href="#i_and">'<tt>and</tt>' Instruction</a></li> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 81 | <li><a href="#i_or">'<tt>or</tt>'  Instruction</a></li> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 82 | <li><a href="#i_xor">'<tt>xor</tt>' Instruction</a></li> | 
|  | 83 | <li><a href="#i_shl">'<tt>shl</tt>' Instruction</a></li> | 
|  | 84 | <li><a href="#i_shr">'<tt>shr</tt>' Instruction</a></li> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 85 | </ol> | 
|  | 86 | </li> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 87 | <li><a href="#memoryops">Memory Access Operations</a> | 
|  | 88 | <ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 89 | <li><a href="#i_malloc">'<tt>malloc</tt>'   Instruction</a></li> | 
|  | 90 | <li><a href="#i_free">'<tt>free</tt>'     Instruction</a></li> | 
|  | 91 | <li><a href="#i_alloca">'<tt>alloca</tt>'   Instruction</a></li> | 
|  | 92 | <li><a href="#i_load">'<tt>load</tt>'     Instruction</a></li> | 
|  | 93 | <li><a href="#i_store">'<tt>store</tt>'    Instruction</a></li> | 
|  | 94 | <li><a href="#i_getelementptr">'<tt>getelementptr</tt>' Instruction</a></li> | 
|  | 95 | </ol> | 
|  | 96 | </li> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 97 | <li><a href="#otherops">Other Operations</a> | 
|  | 98 | <ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 99 | <li><a href="#i_phi">'<tt>phi</tt>'   Instruction</a></li> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 100 | <li><a href="#i_cast">'<tt>cast .. to</tt>' Instruction</a></li> | 
| Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 101 | <li><a href="#i_select">'<tt>select</tt>' Instruction</a></li> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 102 | <li><a href="#i_call">'<tt>call</tt>'  Instruction</a></li> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 103 | <li><a href="#i_vanext">'<tt>vanext</tt>' Instruction</a></li> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 104 | <li><a href="#i_vaarg">'<tt>vaarg</tt>'  Instruction</a></li> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 105 | </ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 106 | </li> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 107 | </ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 108 | </li> | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 109 | <li><a href="#intrinsics">Intrinsic Functions</a> | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 110 | <ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 111 | <li><a href="#int_varargs">Variable Argument Handling Intrinsics</a> | 
|  | 112 | <ol> | 
|  | 113 | <li><a href="#i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a></li> | 
|  | 114 | <li><a href="#i_va_end">'<tt>llvm.va_end</tt>'   Intrinsic</a></li> | 
|  | 115 | <li><a href="#i_va_copy">'<tt>llvm.va_copy</tt>'  Intrinsic</a></li> | 
|  | 116 | </ol> | 
|  | 117 | </li> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 118 | <li><a href="#int_gc">Accurate Garbage Collection Intrinsics</a> | 
|  | 119 | <ol> | 
|  | 120 | <li><a href="#i_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a></li> | 
|  | 121 | <li><a href="#i_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a></li> | 
|  | 122 | <li><a href="#i_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a></li> | 
|  | 123 | </ol> | 
|  | 124 | </li> | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 125 | <li><a href="#int_codegen">Code Generator Intrinsics</a> | 
|  | 126 | <ol> | 
|  | 127 | <li><a href="#i_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a></li> | 
|  | 128 | <li><a href="#i_frameaddress">'<tt>llvm.frameaddress</tt>'   Intrinsic</a></li> | 
| Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 129 | <li><a href="#i_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a></li> | 
| Andrew Lenharth | 7f4ec3b | 2005-03-28 20:05:49 +0000 | [diff] [blame] | 130 | <li><a href="#i_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a></li> | 
| John Criswell | 7123e27 | 2004-04-09 16:43:20 +0000 | [diff] [blame] | 131 | </ol> | 
|  | 132 | </li> | 
|  | 133 | <li><a href="#int_os">Operating System Intrinsics</a> | 
|  | 134 | <ol> | 
| Chris Lattner | 3200628 | 2004-06-11 02:28:03 +0000 | [diff] [blame] | 135 | <li><a href="#i_readport">'<tt>llvm.readport</tt>' Intrinsic</a></li> | 
|  | 136 | <li><a href="#i_writeport">'<tt>llvm.writeport</tt>' Intrinsic</a></li> | 
| John Criswell | 183402a | 2004-04-12 15:02:16 +0000 | [diff] [blame] | 137 | <li><a href="#i_readio">'<tt>llvm.readio</tt>'   Intrinsic</a></li> | 
|  | 138 | <li><a href="#i_writeio">'<tt>llvm.writeio</tt>'   Intrinsic</a></li> | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 139 | </ol> | 
| Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 140 | <li><a href="#int_libc">Standard C Library Intrinsics</a> | 
|  | 141 | <ol> | 
|  | 142 | <li><a href="#i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a></li> | 
| Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 143 | <li><a href="#i_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a></li> | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 144 | <li><a href="#i_memset">'<tt>llvm.memset</tt>' Intrinsic</a></li> | 
| Alkis Evlogimenos | 9685372 | 2004-06-12 19:19:14 +0000 | [diff] [blame] | 145 | <li><a href="#i_isunordered">'<tt>llvm.isunordered</tt>' Intrinsic</a></li> | 
| Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 146 | </ol> | 
|  | 147 | </li> | 
| Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 148 | <li><a href="#int_count">Bit counting Intrinsics</a> | 
|  | 149 | <ol> | 
|  | 150 | <li><a href="#int_ctpop">'<tt>llvm.ctpop</tt>' Intrinsic </a></li> | 
|  | 151 | <li><a href="#int_cttz">'<tt>llvm.cttz</tt>' Intrinsic </a></li> | 
|  | 152 | <li><a href="#int_ctlz">'<tt>llvm.ctlz</tt>' Intrinsic </a></li> | 
|  | 153 | </ol> | 
|  | 154 | </li> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 155 | <li><a href="#int_debugger">Debugger intrinsics</a></li> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 156 | </ol> | 
|  | 157 | </li> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 158 | </ol> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 159 |  | 
|  | 160 | <div class="doc_author"> | 
|  | 161 | <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a> | 
|  | 162 | and <a href="mailto:vadve@cs.uiuc.edu">Vikram Adve</a></p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 163 | </div> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 164 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 165 | <!-- *********************************************************************** --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 166 | <div class="doc_section"> <a name="abstract">Abstract </a></div> | 
|  | 167 | <!-- *********************************************************************** --> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 168 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 169 | <div class="doc_text"> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 170 | <p>This document is a reference manual for the LLVM assembly language. | 
|  | 171 | LLVM is an SSA based representation that provides type safety, | 
|  | 172 | low-level operations, flexibility, and the capability of representing | 
|  | 173 | 'all' high-level languages cleanly.  It is the common code | 
|  | 174 | representation used throughout all phases of the LLVM compilation | 
|  | 175 | strategy.</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 176 | </div> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 177 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 178 | <!-- *********************************************************************** --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 179 | <div class="doc_section"> <a name="introduction">Introduction</a> </div> | 
|  | 180 | <!-- *********************************************************************** --> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 181 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 182 | <div class="doc_text"> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 183 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 184 | <p>The LLVM code representation is designed to be used in three | 
|  | 185 | different forms: as an in-memory compiler IR, as an on-disk bytecode | 
|  | 186 | representation (suitable for fast loading by a Just-In-Time compiler), | 
|  | 187 | and as a human readable assembly language representation.  This allows | 
|  | 188 | LLVM to provide a powerful intermediate representation for efficient | 
|  | 189 | compiler transformations and analysis, while providing a natural means | 
|  | 190 | to debug and visualize the transformations.  The three different forms | 
|  | 191 | of LLVM are all equivalent.  This document describes the human readable | 
|  | 192 | representation and notation.</p> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 193 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 194 | <p>The LLVM representation aims to be a light-weight and low-level | 
|  | 195 | while being expressive, typed, and extensible at the same time.  It | 
|  | 196 | aims to be a "universal IR" of sorts, by being at a low enough level | 
|  | 197 | that high-level ideas may be cleanly mapped to it (similar to how | 
|  | 198 | microprocessors are "universal IR's", allowing many source languages to | 
|  | 199 | be mapped to them).  By providing type information, LLVM can be used as | 
|  | 200 | the target of optimizations: for example, through pointer analysis, it | 
|  | 201 | can be proven that a C automatic variable is never accessed outside of | 
|  | 202 | the current function... allowing it to be promoted to a simple SSA | 
|  | 203 | value instead of a memory location.</p> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 204 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 205 | </div> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 206 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 207 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 208 | <div class="doc_subsubsection"> <a name="wellformed">Well-Formedness</a> </div> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 209 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 210 | <div class="doc_text"> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 211 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 212 | <p>It is important to note that this document describes 'well formed' | 
|  | 213 | LLVM assembly language.  There is a difference between what the parser | 
|  | 214 | accepts and what is considered 'well formed'.  For example, the | 
|  | 215 | following instruction is syntactically okay, but not well formed:</p> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 216 |  | 
|  | 217 | <pre> | 
|  | 218 | %x = <a href="#i_add">add</a> int 1, %x | 
|  | 219 | </pre> | 
|  | 220 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 221 | <p>...because the definition of <tt>%x</tt> does not dominate all of | 
|  | 222 | its uses. The LLVM infrastructure provides a verification pass that may | 
|  | 223 | be used to verify that an LLVM module is well formed.  This pass is | 
|  | 224 | automatically run by the parser after parsing input assembly, and by | 
|  | 225 | the optimizer before it outputs bytecode.  The violations pointed out | 
|  | 226 | by the verifier pass indicate bugs in transformation passes or input to | 
|  | 227 | the parser.</p> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 228 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 229 | <!-- Describe the typesetting conventions here. --> </div> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 230 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 231 | <!-- *********************************************************************** --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 232 | <div class="doc_section"> <a name="identifiers">Identifiers</a> </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 233 | <!-- *********************************************************************** --> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 234 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 235 | <div class="doc_text"> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 236 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 237 | <p>LLVM uses three different forms of identifiers, for different | 
|  | 238 | purposes:</p> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 239 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 240 | <ol> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 241 | <li>Named values are represented as a string of characters with a '%' prefix. | 
|  | 242 | For example, %foo, %DivisionByZero, %a.really.long.identifier.  The actual | 
|  | 243 | regular expression used is '<tt>%[a-zA-Z$._][a-zA-Z$._0-9]*</tt>'. | 
|  | 244 | Identifiers which require other characters in their names can be surrounded | 
|  | 245 | with quotes.  In this way, anything except a <tt>"</tt> character can be used | 
|  | 246 | in a name.</li> | 
|  | 247 |  | 
|  | 248 | <li>Unnamed values are represented as an unsigned numeric value with a '%' | 
|  | 249 | prefix.  For example, %12, %2, %44.</li> | 
|  | 250 |  | 
| Reid Spencer | cc16dc3 | 2004-12-09 18:02:53 +0000 | [diff] [blame] | 251 | <li>Constants, which are described in a <a href="#constants">section about | 
|  | 252 | constants</a>, below.</li> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 253 | </ol> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 254 |  | 
|  | 255 | <p>LLVM requires that values start with a '%' sign for two reasons: Compilers | 
|  | 256 | don't need to worry about name clashes with reserved words, and the set of | 
|  | 257 | reserved words may be expanded in the future without penalty.  Additionally, | 
|  | 258 | unnamed identifiers allow a compiler to quickly come up with a temporary | 
|  | 259 | variable without having to avoid symbol table conflicts.</p> | 
|  | 260 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 261 | <p>Reserved words in LLVM are very similar to reserved words in other | 
|  | 262 | languages. There are keywords for different opcodes ('<tt><a | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 263 | href="#i_add">add</a></tt>', '<tt><a href="#i_cast">cast</a></tt>', '<tt><a | 
|  | 264 | href="#i_ret">ret</a></tt>', etc...), for primitive type names ('<tt><a | 
|  | 265 | href="#t_void">void</a></tt>', '<tt><a href="#t_uint">uint</a></tt>', etc...), | 
|  | 266 | and others.  These reserved words cannot conflict with variable names, because | 
|  | 267 | none of them start with a '%' character.</p> | 
|  | 268 |  | 
|  | 269 | <p>Here is an example of LLVM code to multiply the integer variable | 
|  | 270 | '<tt>%X</tt>' by 8:</p> | 
|  | 271 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 272 | <p>The easy way:</p> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 273 |  | 
|  | 274 | <pre> | 
|  | 275 | %result = <a href="#i_mul">mul</a> uint %X, 8 | 
|  | 276 | </pre> | 
|  | 277 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 278 | <p>After strength reduction:</p> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 279 |  | 
|  | 280 | <pre> | 
|  | 281 | %result = <a href="#i_shl">shl</a> uint %X, ubyte 3 | 
|  | 282 | </pre> | 
|  | 283 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 284 | <p>And the hard way:</p> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 285 |  | 
|  | 286 | <pre> | 
|  | 287 | <a href="#i_add">add</a> uint %X, %X           <i>; yields {uint}:%0</i> | 
|  | 288 | <a href="#i_add">add</a> uint %0, %0           <i>; yields {uint}:%1</i> | 
|  | 289 | %result = <a href="#i_add">add</a> uint %1, %1 | 
|  | 290 | </pre> | 
|  | 291 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 292 | <p>This last way of multiplying <tt>%X</tt> by 8 illustrates several | 
|  | 293 | important lexical features of LLVM:</p> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 294 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 295 | <ol> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 296 |  | 
|  | 297 | <li>Comments are delimited with a '<tt>;</tt>' and go until the end of | 
|  | 298 | line.</li> | 
|  | 299 |  | 
|  | 300 | <li>Unnamed temporaries are created when the result of a computation is not | 
|  | 301 | assigned to a named value.</li> | 
|  | 302 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 303 | <li>Unnamed temporaries are numbered sequentially</li> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 304 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 305 | </ol> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 306 |  | 
|  | 307 | <p>...and it also show a convention that we follow in this document.  When | 
|  | 308 | demonstrating instructions, we will follow an instruction with a comment that | 
|  | 309 | defines the type and name of value produced.  Comments are shown in italic | 
|  | 310 | text.</p> | 
|  | 311 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 312 | </div> | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 313 |  | 
|  | 314 | <!-- *********************************************************************** --> | 
|  | 315 | <div class="doc_section"> <a name="highlevel">High Level Structure</a> </div> | 
|  | 316 | <!-- *********************************************************************** --> | 
|  | 317 |  | 
|  | 318 | <!-- ======================================================================= --> | 
|  | 319 | <div class="doc_subsection"> <a name="modulestructure">Module Structure</a> | 
|  | 320 | </div> | 
|  | 321 |  | 
|  | 322 | <div class="doc_text"> | 
|  | 323 |  | 
|  | 324 | <p>LLVM programs are composed of "Module"s, each of which is a | 
|  | 325 | translation unit of the input programs.  Each module consists of | 
|  | 326 | functions, global variables, and symbol table entries.  Modules may be | 
|  | 327 | combined together with the LLVM linker, which merges function (and | 
|  | 328 | global variable) definitions, resolves forward declarations, and merges | 
|  | 329 | symbol table entries. Here is an example of the "hello world" module:</p> | 
|  | 330 |  | 
|  | 331 | <pre><i>; Declare the string constant as a global constant...</i> | 
|  | 332 | <a href="#identifiers">%.LC0</a> = <a href="#linkage_internal">internal</a> <a | 
|  | 333 | href="#globalvars">constant</a> <a href="#t_array">[13 x sbyte]</a> c"hello world\0A\00"          <i>; [13 x sbyte]*</i> | 
|  | 334 |  | 
|  | 335 | <i>; External declaration of the puts function</i> | 
|  | 336 | <a href="#functionstructure">declare</a> int %puts(sbyte*)                                            <i>; int(sbyte*)* </i> | 
|  | 337 |  | 
|  | 338 | <i>; Definition of main function</i> | 
|  | 339 | int %main() {                                                        <i>; int()* </i> | 
|  | 340 | <i>; Convert [13x sbyte]* to sbyte *...</i> | 
|  | 341 | %cast210 = <a | 
|  | 342 | href="#i_getelementptr">getelementptr</a> [13 x sbyte]* %.LC0, long 0, long 0 <i>; sbyte*</i> | 
|  | 343 |  | 
|  | 344 | <i>; Call puts function to write out the string to stdout...</i> | 
|  | 345 | <a | 
|  | 346 | href="#i_call">call</a> int %puts(sbyte* %cast210)                              <i>; int</i> | 
|  | 347 | <a | 
|  | 348 | href="#i_ret">ret</a> int 0<br>}<br></pre> | 
|  | 349 |  | 
|  | 350 | <p>This example is made up of a <a href="#globalvars">global variable</a> | 
|  | 351 | named "<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>" | 
|  | 352 | function, and a <a href="#functionstructure">function definition</a> | 
|  | 353 | for "<tt>main</tt>".</p> | 
|  | 354 |  | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 355 | <p>In general, a module is made up of a list of global values, | 
|  | 356 | where both functions and global variables are global values.  Global values are | 
|  | 357 | represented by a pointer to a memory location (in this case, a pointer to an | 
|  | 358 | array of char, and a pointer to a function), and have one of the following <a | 
|  | 359 | href="#linkage">linkage types</a>.</p> | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 360 |  | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 361 | </div> | 
|  | 362 |  | 
|  | 363 | <!-- ======================================================================= --> | 
|  | 364 | <div class="doc_subsection"> | 
|  | 365 | <a name="linkage">Linkage Types</a> | 
|  | 366 | </div> | 
|  | 367 |  | 
|  | 368 | <div class="doc_text"> | 
|  | 369 |  | 
|  | 370 | <p> | 
|  | 371 | All Global Variables and Functions have one of the following types of linkage: | 
|  | 372 | </p> | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 373 |  | 
|  | 374 | <dl> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 375 |  | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 376 | <dt><tt><b><a name="linkage_internal">internal</a></b></tt> </dt> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 377 |  | 
|  | 378 | <dd>Global values with internal linkage are only directly accessible by | 
|  | 379 | objects in the current module.  In particular, linking code into a module with | 
|  | 380 | an internal global value may cause the internal to be renamed as necessary to | 
|  | 381 | avoid collisions.  Because the symbol is internal to the module, all | 
|  | 382 | references can be updated.  This corresponds to the notion of the | 
|  | 383 | '<tt>static</tt>' keyword in C, or the idea of "anonymous namespaces" in C++. | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 384 | </dd> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 385 |  | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 386 | <dt><tt><b><a name="linkage_linkonce">linkonce</a></b></tt>: </dt> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 387 |  | 
|  | 388 | <dd>"<tt>linkonce</tt>" linkage is similar to <tt>internal</tt> linkage, with | 
|  | 389 | the twist that linking together two modules defining the same | 
|  | 390 | <tt>linkonce</tt> globals will cause one of the globals to be discarded.  This | 
|  | 391 | is typically used to implement inline functions.  Unreferenced | 
|  | 392 | <tt>linkonce</tt> globals are allowed to be discarded. | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 393 | </dd> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 394 |  | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 395 | <dt><tt><b><a name="linkage_weak">weak</a></b></tt>: </dt> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 396 |  | 
|  | 397 | <dd>"<tt>weak</tt>" linkage is exactly the same as <tt>linkonce</tt> linkage, | 
|  | 398 | except that unreferenced <tt>weak</tt> globals may not be discarded.  This is | 
|  | 399 | used to implement constructs in C such as "<tt>int X;</tt>" at global scope. | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 400 | </dd> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 401 |  | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 402 | <dt><tt><b><a name="linkage_appending">appending</a></b></tt>: </dt> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 403 |  | 
|  | 404 | <dd>"<tt>appending</tt>" linkage may only be applied to global variables of | 
|  | 405 | pointer to array type.  When two global variables with appending linkage are | 
|  | 406 | linked together, the two global arrays are appended together.  This is the | 
|  | 407 | LLVM, typesafe, equivalent of having the system linker append together | 
|  | 408 | "sections" with identical names when .o files are linked. | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 409 | </dd> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 410 |  | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 411 | <dt><tt><b><a name="linkage_external">externally visible</a></b></tt>:</dt> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 412 |  | 
|  | 413 | <dd>If none of the above identifiers are used, the global is externally | 
|  | 414 | visible, meaning that it participates in linkage and can be used to resolve | 
|  | 415 | external symbol references. | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 416 | </dd> | 
|  | 417 | </dl> | 
|  | 418 |  | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 419 | <p><a name="linkage_external">For example, since the "<tt>.LC0</tt>" | 
|  | 420 | variable is defined to be internal, if another module defined a "<tt>.LC0</tt>" | 
|  | 421 | variable and was linked with this one, one of the two would be renamed, | 
|  | 422 | preventing a collision.  Since "<tt>main</tt>" and "<tt>puts</tt>" are | 
|  | 423 | external (i.e., lacking any linkage declarations), they are accessible | 
|  | 424 | outside of the current module.  It is illegal for a function <i>declaration</i> | 
|  | 425 | to have any linkage type other than "externally visible".</a></p> | 
| Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 426 |  | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 427 | </div> | 
|  | 428 |  | 
|  | 429 | <!-- ======================================================================= --> | 
|  | 430 | <div class="doc_subsection"> | 
|  | 431 | <a name="globalvars">Global Variables</a> | 
|  | 432 | </div> | 
|  | 433 |  | 
|  | 434 | <div class="doc_text"> | 
|  | 435 |  | 
| Chris Lattner | 3689a34 | 2005-02-12 19:30:21 +0000 | [diff] [blame] | 436 | <p>Global variables define regions of memory allocated at compilation time | 
|  | 437 | instead of run-time.  Global variables may optionally be initialized.  A | 
|  | 438 | variable may be defined as a global "constant", which indicates that the | 
|  | 439 | contents of the variable will <b>never</b> be modified (enabling better | 
|  | 440 | optimization, allowing the global data to be placed in the read-only section of | 
|  | 441 | an executable, etc).  Note that variables that need runtime initialization | 
|  | 442 | cannot be marked "constant", as there is a store to the variable.</p> | 
|  | 443 |  | 
|  | 444 | <p> | 
|  | 445 | LLVM explicitly allows <em>declarations</em> of global variables to be marked | 
|  | 446 | constant, even if the final definition of the global is not.  This capability | 
|  | 447 | can be used to enable slightly better optimization of the program, but requires | 
|  | 448 | the language definition to guarantee that optimizations based on the | 
|  | 449 | 'constantness' are valid for the translation units that do not include the | 
|  | 450 | definition. | 
|  | 451 | </p> | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 452 |  | 
|  | 453 | <p>As SSA values, global variables define pointer values that are in | 
|  | 454 | scope (i.e. they dominate) all basic blocks in the program.  Global | 
|  | 455 | variables always define a pointer to their "content" type because they | 
|  | 456 | describe a region of memory, and all memory objects in LLVM are | 
|  | 457 | accessed through pointers.</p> | 
|  | 458 |  | 
|  | 459 | </div> | 
|  | 460 |  | 
|  | 461 |  | 
|  | 462 | <!-- ======================================================================= --> | 
|  | 463 | <div class="doc_subsection"> | 
|  | 464 | <a name="functionstructure">Functions</a> | 
|  | 465 | </div> | 
|  | 466 |  | 
|  | 467 | <div class="doc_text"> | 
|  | 468 |  | 
|  | 469 | <p>LLVM function definitions are composed of a (possibly empty) argument list, | 
|  | 470 | an opening curly brace, a list of basic blocks, and a closing curly brace.  LLVM | 
|  | 471 | function declarations are defined with the "<tt>declare</tt>" keyword, a | 
|  | 472 | function name, and a function signature.</p> | 
|  | 473 |  | 
|  | 474 | <p>A function definition contains a list of basic blocks, forming the CFG for | 
|  | 475 | the function.  Each basic block may optionally start with a label (giving the | 
|  | 476 | basic block a symbol table entry), contains a list of instructions, and ends | 
|  | 477 | with a <a href="#terminators">terminator</a> instruction (such as a branch or | 
|  | 478 | function return).</p> | 
|  | 479 |  | 
|  | 480 | <p>The first basic block in program is special in two ways: it is immediately | 
|  | 481 | executed on entrance to the function, and it is not allowed to have predecessor | 
|  | 482 | basic blocks (i.e. there can not be any branches to the entry block of a | 
|  | 483 | function).  Because the block can have no predecessors, it also cannot have any | 
|  | 484 | <a href="#i_phi">PHI nodes</a>.</p> | 
|  | 485 |  | 
|  | 486 | <p>LLVM functions are identified by their name and type signature.  Hence, two | 
|  | 487 | functions with the same name but different parameter lists or return values are | 
| Chris Lattner | d4f6b17 | 2005-03-07 22:13:59 +0000 | [diff] [blame] | 488 | considered different functions, and LLVM will resolve references to each | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 489 | appropriately.</p> | 
|  | 490 |  | 
|  | 491 | </div> | 
|  | 492 |  | 
|  | 493 |  | 
|  | 494 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 495 | <!-- *********************************************************************** --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 496 | <div class="doc_section"> <a name="typesystem">Type System</a> </div> | 
|  | 497 | <!-- *********************************************************************** --> | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 498 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 499 | <div class="doc_text"> | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 500 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 501 | <p>The LLVM type system is one of the most important features of the | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 502 | intermediate representation.  Being typed enables a number of | 
|  | 503 | optimizations to be performed on the IR directly, without having to do | 
|  | 504 | extra analyses on the side before the transformation.  A strong type | 
|  | 505 | system makes it easier to read the generated code and enables novel | 
|  | 506 | analyses and transformations that are not feasible to perform on normal | 
|  | 507 | three address code representations.</p> | 
| Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 508 |  | 
|  | 509 | </div> | 
|  | 510 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 511 | <!-- ======================================================================= --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 512 | <div class="doc_subsection"> <a name="t_primitive">Primitive Types</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 513 | <div class="doc_text"> | 
| John Criswell | 4457dc9 | 2004-04-09 16:48:45 +0000 | [diff] [blame] | 514 | <p>The primitive types are the fundamental building blocks of the LLVM | 
| Chris Lattner | d4f6b17 | 2005-03-07 22:13:59 +0000 | [diff] [blame] | 515 | system. The current set of primitive types is as follows:</p> | 
| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 516 |  | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 517 | <table class="layout"> | 
|  | 518 | <tr class="layout"> | 
|  | 519 | <td class="left"> | 
|  | 520 | <table> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 521 | <tbody> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 522 | <tr><th>Type</th><th>Description</th></tr> | 
|  | 523 | <tr><td><tt>void</tt></td><td>No value</td></tr> | 
| Misha Brukman | cfa87bc | 2005-04-22 18:02:52 +0000 | [diff] [blame] | 524 | <tr><td><tt>ubyte</tt></td><td>Unsigned 8-bit value</td></tr> | 
|  | 525 | <tr><td><tt>ushort</tt></td><td>Unsigned 16-bit value</td></tr> | 
|  | 526 | <tr><td><tt>uint</tt></td><td>Unsigned 32-bit value</td></tr> | 
|  | 527 | <tr><td><tt>ulong</tt></td><td>Unsigned 64-bit value</td></tr> | 
|  | 528 | <tr><td><tt>float</tt></td><td>32-bit floating point value</td></tr> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 529 | <tr><td><tt>label</tt></td><td>Branch destination</td></tr> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 530 | </tbody> | 
|  | 531 | </table> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 532 | </td> | 
|  | 533 | <td class="right"> | 
|  | 534 | <table> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 535 | <tbody> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 536 | <tr><th>Type</th><th>Description</th></tr> | 
|  | 537 | <tr><td><tt>bool</tt></td><td>True or False value</td></tr> | 
| Misha Brukman | cfa87bc | 2005-04-22 18:02:52 +0000 | [diff] [blame] | 538 | <tr><td><tt>sbyte</tt></td><td>Signed 8-bit value</td></tr> | 
|  | 539 | <tr><td><tt>short</tt></td><td>Signed 16-bit value</td></tr> | 
|  | 540 | <tr><td><tt>int</tt></td><td>Signed 32-bit value</td></tr> | 
|  | 541 | <tr><td><tt>long</tt></td><td>Signed 64-bit value</td></tr> | 
|  | 542 | <tr><td><tt>double</tt></td><td>64-bit floating point value</td></tr> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 543 | </tbody> | 
|  | 544 | </table> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 545 | </td> | 
|  | 546 | </tr> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 547 | </table> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 548 | </div> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 549 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 550 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 551 | <div class="doc_subsubsection"> <a name="t_classifications">Type | 
|  | 552 | Classifications</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 553 | <div class="doc_text"> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 554 | <p>These different primitive types fall into a few useful | 
|  | 555 | classifications:</p> | 
| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 556 |  | 
|  | 557 | <table border="1" cellspacing="0" cellpadding="4"> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 558 | <tbody> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 559 | <tr><th>Classification</th><th>Types</th></tr> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 560 | <tr> | 
|  | 561 | <td><a name="t_signed">signed</a></td> | 
|  | 562 | <td><tt>sbyte, short, int, long, float, double</tt></td> | 
|  | 563 | </tr> | 
|  | 564 | <tr> | 
|  | 565 | <td><a name="t_unsigned">unsigned</a></td> | 
|  | 566 | <td><tt>ubyte, ushort, uint, ulong</tt></td> | 
|  | 567 | </tr> | 
|  | 568 | <tr> | 
|  | 569 | <td><a name="t_integer">integer</a></td> | 
|  | 570 | <td><tt>ubyte, sbyte, ushort, short, uint, int, ulong, long</tt></td> | 
|  | 571 | </tr> | 
|  | 572 | <tr> | 
|  | 573 | <td><a name="t_integral">integral</a></td> | 
| Misha Brukman | c24b758 | 2004-08-12 20:16:08 +0000 | [diff] [blame] | 574 | <td><tt>bool, ubyte, sbyte, ushort, short, uint, int, ulong, long</tt> | 
|  | 575 | </td> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 576 | </tr> | 
|  | 577 | <tr> | 
|  | 578 | <td><a name="t_floating">floating point</a></td> | 
|  | 579 | <td><tt>float, double</tt></td> | 
|  | 580 | </tr> | 
|  | 581 | <tr> | 
|  | 582 | <td><a name="t_firstclass">first class</a></td> | 
| Misha Brukman | c24b758 | 2004-08-12 20:16:08 +0000 | [diff] [blame] | 583 | <td><tt>bool, ubyte, sbyte, ushort, short, uint, int, ulong, long,<br> | 
|  | 584 | float, double, <a href="#t_pointer">pointer</a>, | 
|  | 585 | <a href="#t_packed">packed</a></tt></td> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 586 | </tr> | 
|  | 587 | </tbody> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 588 | </table> | 
| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 589 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 590 | <p>The <a href="#t_firstclass">first class</a> types are perhaps the | 
|  | 591 | most important.  Values of these types are the only ones which can be | 
|  | 592 | produced by instructions, passed as arguments, or used as operands to | 
|  | 593 | instructions.  This means that all structures and arrays must be | 
|  | 594 | manipulated either by pointer or by component.</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 595 | </div> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 596 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 597 | <!-- ======================================================================= --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 598 | <div class="doc_subsection"> <a name="t_derived">Derived Types</a> </div> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 599 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 600 | <div class="doc_text"> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 601 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 602 | <p>The real power in LLVM comes from the derived types in the system. | 
|  | 603 | This is what allows a programmer to represent arrays, functions, | 
|  | 604 | pointers, and other useful types.  Note that these derived types may be | 
|  | 605 | recursive: For example, it is possible to have a two dimensional array.</p> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 606 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 607 | </div> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 608 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 609 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 610 | <div class="doc_subsubsection"> <a name="t_array">Array Type</a> </div> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 611 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 612 | <div class="doc_text"> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 613 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 614 | <h5>Overview:</h5> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 615 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 616 | <p>The array type is a very simple derived type that arranges elements | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 617 | sequentially in memory.  The array type requires a size (number of | 
|  | 618 | elements) and an underlying data type.</p> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 619 |  | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 620 | <h5>Syntax:</h5> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 621 |  | 
|  | 622 | <pre> | 
|  | 623 | [<# elements> x <elementtype>] | 
|  | 624 | </pre> | 
|  | 625 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 626 | <p>The number of elements is a constant integer value, elementtype may | 
|  | 627 | be any type with a size.</p> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 628 |  | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 629 | <h5>Examples:</h5> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 630 | <table class="layout"> | 
|  | 631 | <tr class="layout"> | 
|  | 632 | <td class="left"> | 
|  | 633 | <tt>[40 x int ]</tt><br/> | 
|  | 634 | <tt>[41 x int ]</tt><br/> | 
|  | 635 | <tt>[40 x uint]</tt><br/> | 
|  | 636 | </td> | 
|  | 637 | <td class="left"> | 
|  | 638 | Array of 40 integer values.<br/> | 
|  | 639 | Array of 41 integer values.<br/> | 
|  | 640 | Array of 40 unsigned integer values.<br/> | 
|  | 641 | </td> | 
|  | 642 | </tr> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 643 | </table> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 644 | <p>Here are some examples of multidimensional arrays:</p> | 
|  | 645 | <table class="layout"> | 
|  | 646 | <tr class="layout"> | 
|  | 647 | <td class="left"> | 
|  | 648 | <tt>[3 x [4 x int]]</tt><br/> | 
|  | 649 | <tt>[12 x [10 x float]]</tt><br/> | 
|  | 650 | <tt>[2 x [3 x [4 x uint]]]</tt><br/> | 
|  | 651 | </td> | 
|  | 652 | <td class="left"> | 
|  | 653 | 3x4 array integer values.<br/> | 
|  | 654 | 12x10 array of single precision floating point values.<br/> | 
|  | 655 | 2x3x4 array of unsigned integer values.<br/> | 
|  | 656 | </td> | 
|  | 657 | </tr> | 
|  | 658 | </table> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 659 | </div> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 660 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 661 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 662 | <div class="doc_subsubsection"> <a name="t_function">Function Type</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 663 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 664 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 665 | <p>The function type can be thought of as a function signature.  It | 
|  | 666 | consists of a return type and a list of formal parameter types. | 
| John Criswell | 009900b | 2003-11-25 21:45:46 +0000 | [diff] [blame] | 667 | Function types are usually used to build virtual function tables | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 668 | (which are structures of pointers to functions), for indirect function | 
|  | 669 | calls, and when defining a function.</p> | 
| John Criswell | 009900b | 2003-11-25 21:45:46 +0000 | [diff] [blame] | 670 | <p> | 
|  | 671 | The return type of a function type cannot be an aggregate type. | 
|  | 672 | </p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 673 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 674 | <pre>  <returntype> (<parameter list>)<br></pre> | 
| Misha Brukman | c24b758 | 2004-08-12 20:16:08 +0000 | [diff] [blame] | 675 | <p>Where '<tt><parameter list></tt>' is a comma-separated list of type | 
|  | 676 | specifiers.  Optionally, the parameter list may include a type <tt>...</tt>, | 
| Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 677 | which indicates that the function takes a variable number of arguments. | 
|  | 678 | Variable argument functions can access their arguments with the <a | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 679 | href="#int_varargs">variable argument handling intrinsic</a> functions.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 680 | <h5>Examples:</h5> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 681 | <table class="layout"> | 
|  | 682 | <tr class="layout"> | 
|  | 683 | <td class="left"> | 
|  | 684 | <tt>int (int)</tt> <br/> | 
|  | 685 | <tt>float (int, int *) *</tt><br/> | 
|  | 686 | <tt>int (sbyte *, ...)</tt><br/> | 
|  | 687 | </td> | 
|  | 688 | <td class="left"> | 
|  | 689 | function taking an <tt>int</tt>, returning an <tt>int</tt><br/> | 
|  | 690 | <a href="#t_pointer">Pointer</a> to a function that takes an | 
| Misha Brukman | c24b758 | 2004-08-12 20:16:08 +0000 | [diff] [blame] | 691 | <tt>int</tt> and a <a href="#t_pointer">pointer</a> to <tt>int</tt>, | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 692 | returning <tt>float</tt>.<br/> | 
|  | 693 | A vararg function that takes at least one <a href="#t_pointer">pointer</a> | 
|  | 694 | to <tt>sbyte</tt> (signed char in C), which returns an integer.  This is | 
|  | 695 | the signature for <tt>printf</tt> in LLVM.<br/> | 
|  | 696 | </td> | 
|  | 697 | </tr> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 698 | </table> | 
| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 699 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 700 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 701 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 702 | <div class="doc_subsubsection"> <a name="t_struct">Structure Type</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 703 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 704 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 705 | <p>The structure type is used to represent a collection of data members | 
|  | 706 | together in memory.  The packing of the field types is defined to match | 
|  | 707 | the ABI of the underlying processor.  The elements of a structure may | 
|  | 708 | be any type that has a size.</p> | 
|  | 709 | <p>Structures are accessed using '<tt><a href="#i_load">load</a></tt> | 
|  | 710 | and '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a | 
|  | 711 | field with the '<tt><a href="#i_getelementptr">getelementptr</a></tt>' | 
|  | 712 | instruction.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 713 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 714 | <pre>  { <type list> }<br></pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 715 | <h5>Examples:</h5> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 716 | <table class="layout"> | 
|  | 717 | <tr class="layout"> | 
|  | 718 | <td class="left"> | 
|  | 719 | <tt>{ int, int, int }</tt><br/> | 
|  | 720 | <tt>{ float, int (int) * }</tt><br/> | 
|  | 721 | </td> | 
|  | 722 | <td class="left"> | 
|  | 723 | a triple of three <tt>int</tt> values<br/> | 
|  | 724 | A pair, where the first element is a <tt>float</tt> and the second element | 
|  | 725 | is a <a href="#t_pointer">pointer</a> to a <a href="#t_function">function</a> | 
|  | 726 | that takes an <tt>int</tt>, returning an <tt>int</tt>.<br/> | 
|  | 727 | </td> | 
|  | 728 | </tr> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 729 | </table> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 730 | </div> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 731 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 732 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 733 | <div class="doc_subsubsection"> <a name="t_pointer">Pointer Type</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 734 | <div class="doc_text"> | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 735 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 736 | <p>As in many languages, the pointer type represents a pointer or | 
|  | 737 | reference to another object, which must live in memory.</p> | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 738 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 739 | <pre>  <type> *<br></pre> | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 740 | <h5>Examples:</h5> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 741 | <table class="layout"> | 
|  | 742 | <tr class="layout"> | 
|  | 743 | <td class="left"> | 
|  | 744 | <tt>[4x int]*</tt><br/> | 
|  | 745 | <tt>int (int *) *</tt><br/> | 
|  | 746 | </td> | 
|  | 747 | <td class="left"> | 
|  | 748 | A <a href="#t_pointer">pointer</a> to <a href="#t_array">array</a> of | 
|  | 749 | four <tt>int</tt> values<br/> | 
|  | 750 | A <a href="#t_pointer">pointer</a> to a <a | 
| Chris Lattner | a977c48 | 2005-02-19 02:22:14 +0000 | [diff] [blame] | 751 | href="#t_function">function</a> that takes an <tt>int*</tt>, returning an | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 752 | <tt>int</tt>.<br/> | 
|  | 753 | </td> | 
|  | 754 | </tr> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 755 | </table> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 756 | </div> | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 757 |  | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 758 | <!-- _______________________________________________________________________ --> | 
|  | 759 | <div class="doc_subsubsection"> <a name="t_packed">Packed Type</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 760 | <div class="doc_text"> | 
| Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 761 |  | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 762 | <h5>Overview:</h5> | 
| Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 763 |  | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 764 | <p>A packed type is a simple derived type that represents a vector | 
|  | 765 | of elements.  Packed types are used when multiple primitive data | 
|  | 766 | are operated in parallel using a single instruction (SIMD). | 
|  | 767 | A packed type requires a size (number of | 
|  | 768 | elements) and an underlying primitive data type.  Packed types are | 
|  | 769 | considered <a href="#t_firstclass">first class</a>.</p> | 
| Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 770 |  | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 771 | <h5>Syntax:</h5> | 
| Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 772 |  | 
|  | 773 | <pre> | 
|  | 774 | < <# elements> x <elementtype> > | 
|  | 775 | </pre> | 
|  | 776 |  | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 777 | <p>The number of elements is a constant integer value, elementtype may | 
|  | 778 | be any integral or floating point type.</p> | 
| Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 779 |  | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 780 | <h5>Examples:</h5> | 
| Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 781 |  | 
| Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 782 | <table class="layout"> | 
|  | 783 | <tr class="layout"> | 
|  | 784 | <td class="left"> | 
|  | 785 | <tt><4 x int></tt><br/> | 
|  | 786 | <tt><8 x float></tt><br/> | 
|  | 787 | <tt><2 x uint></tt><br/> | 
|  | 788 | </td> | 
|  | 789 | <td class="left"> | 
|  | 790 | Packed vector of 4 integer values.<br/> | 
|  | 791 | Packed vector of 8 floating-point values.<br/> | 
|  | 792 | Packed vector of 2 unsigned integer values.<br/> | 
|  | 793 | </td> | 
|  | 794 | </tr> | 
|  | 795 | </table> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 796 | </div> | 
|  | 797 |  | 
| Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 798 | <!-- _______________________________________________________________________ --> | 
|  | 799 | <div class="doc_subsubsection"> <a name="t_opaque">Opaque Type</a> </div> | 
|  | 800 | <div class="doc_text"> | 
|  | 801 |  | 
|  | 802 | <h5>Overview:</h5> | 
|  | 803 |  | 
|  | 804 | <p>Opaque types are used to represent unknown types in the system.  This | 
|  | 805 | corresponds (for example) to the C notion of a foward declared structure type. | 
|  | 806 | In LLVM, opaque types can eventually be resolved to any type (not just a | 
|  | 807 | structure type).</p> | 
|  | 808 |  | 
|  | 809 | <h5>Syntax:</h5> | 
|  | 810 |  | 
|  | 811 | <pre> | 
|  | 812 | opaque | 
|  | 813 | </pre> | 
|  | 814 |  | 
|  | 815 | <h5>Examples:</h5> | 
|  | 816 |  | 
|  | 817 | <table class="layout"> | 
|  | 818 | <tr class="layout"> | 
|  | 819 | <td class="left"> | 
|  | 820 | <tt>opaque</tt> | 
|  | 821 | </td> | 
|  | 822 | <td class="left"> | 
|  | 823 | An opaque type.<br/> | 
|  | 824 | </td> | 
|  | 825 | </tr> | 
|  | 826 | </table> | 
|  | 827 | </div> | 
|  | 828 |  | 
|  | 829 |  | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 830 | <!-- *********************************************************************** --> | 
|  | 831 | <div class="doc_section"> <a name="constants">Constants</a> </div> | 
|  | 832 | <!-- *********************************************************************** --> | 
|  | 833 |  | 
|  | 834 | <div class="doc_text"> | 
|  | 835 |  | 
|  | 836 | <p>LLVM has several different basic types of constants.  This section describes | 
|  | 837 | them all and their syntax.</p> | 
|  | 838 |  | 
|  | 839 | </div> | 
|  | 840 |  | 
|  | 841 | <!-- ======================================================================= --> | 
| Reid Spencer | cc16dc3 | 2004-12-09 18:02:53 +0000 | [diff] [blame] | 842 | <div class="doc_subsection"><a name="simpleconstants">Simple Constants</a></div> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 843 |  | 
|  | 844 | <div class="doc_text"> | 
|  | 845 |  | 
|  | 846 | <dl> | 
|  | 847 | <dt><b>Boolean constants</b></dt> | 
|  | 848 |  | 
|  | 849 | <dd>The two strings '<tt>true</tt>' and '<tt>false</tt>' are both valid | 
|  | 850 | constants of the <tt><a href="#t_primitive">bool</a></tt> type. | 
|  | 851 | </dd> | 
|  | 852 |  | 
|  | 853 | <dt><b>Integer constants</b></dt> | 
|  | 854 |  | 
| Reid Spencer | cc16dc3 | 2004-12-09 18:02:53 +0000 | [diff] [blame] | 855 | <dd>Standard integers (such as '4') are constants of the <a | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 856 | href="#t_integer">integer</a> type.  Negative numbers may be used with signed | 
|  | 857 | integer types. | 
|  | 858 | </dd> | 
|  | 859 |  | 
|  | 860 | <dt><b>Floating point constants</b></dt> | 
|  | 861 |  | 
|  | 862 | <dd>Floating point constants use standard decimal notation (e.g. 123.421), | 
|  | 863 | exponential notation (e.g. 1.23421e+2), or a more precise hexadecimal | 
| Reid Spencer | cc16dc3 | 2004-12-09 18:02:53 +0000 | [diff] [blame] | 864 | notation.  Floating point constants have an optional hexadecimal | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 865 | notation (see below).  Floating point constants must have a <a | 
|  | 866 | href="#t_floating">floating point</a> type. </dd> | 
|  | 867 |  | 
|  | 868 | <dt><b>Null pointer constants</b></dt> | 
|  | 869 |  | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 870 | <dd>The identifier '<tt>null</tt>' is recognized as a null pointer constant | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 871 | and must be of <a href="#t_pointer">pointer type</a>.</dd> | 
|  | 872 |  | 
|  | 873 | </dl> | 
|  | 874 |  | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 875 | <p>The one non-intuitive notation for constants is the optional hexadecimal form | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 876 | of floating point constants.  For example, the form '<tt>double | 
|  | 877 | 0x432ff973cafa8000</tt>' is equivalent to (but harder to read than) '<tt>double | 
|  | 878 | 4.5e+15</tt>'.  The only time hexadecimal floating point constants are required | 
| Reid Spencer | cc16dc3 | 2004-12-09 18:02:53 +0000 | [diff] [blame] | 879 | (and the only time that they are generated by the disassembler) is when a | 
|  | 880 | floating point constant must be emitted but it cannot be represented as a | 
|  | 881 | decimal floating point number.  For example, NaN's, infinities, and other | 
|  | 882 | special values are represented in their IEEE hexadecimal format so that | 
|  | 883 | assembly and disassembly do not cause any bits to change in the constants.</p> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 884 |  | 
|  | 885 | </div> | 
|  | 886 |  | 
|  | 887 | <!-- ======================================================================= --> | 
|  | 888 | <div class="doc_subsection"><a name="aggregateconstants">Aggregate Constants</a> | 
|  | 889 | </div> | 
|  | 890 |  | 
|  | 891 | <div class="doc_text"> | 
| Chris Lattner | d4f6b17 | 2005-03-07 22:13:59 +0000 | [diff] [blame] | 892 | <p>Aggregate constants arise from aggregation of simple constants | 
|  | 893 | and smaller aggregate constants.</p> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 894 |  | 
|  | 895 | <dl> | 
|  | 896 | <dt><b>Structure constants</b></dt> | 
|  | 897 |  | 
|  | 898 | <dd>Structure constants are represented with notation similar to structure | 
|  | 899 | type definitions (a comma separated list of elements, surrounded by braces | 
| Chris Lattner | d4f6b17 | 2005-03-07 22:13:59 +0000 | [diff] [blame] | 900 | (<tt>{}</tt>)).  For example: "<tt>{ int 4, float 17.0, int* %G }</tt>", | 
|  | 901 | where "<tt>%G</tt>" is declared as "<tt>%G = external global int</tt>".  Structure constants | 
|  | 902 | must have <a href="#t_struct">structure type</a>, and the number and | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 903 | types of elements must match those specified by the type. | 
|  | 904 | </dd> | 
|  | 905 |  | 
|  | 906 | <dt><b>Array constants</b></dt> | 
|  | 907 |  | 
|  | 908 | <dd>Array constants are represented with notation similar to array type | 
|  | 909 | definitions (a comma separated list of elements, surrounded by square brackets | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 910 | (<tt>[]</tt>)).  For example: "<tt>[ int 42, int 11, int 74 ]</tt>".  Array | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 911 | constants must have <a href="#t_array">array type</a>, and the number and | 
|  | 912 | types of elements must match those specified by the type. | 
|  | 913 | </dd> | 
|  | 914 |  | 
|  | 915 | <dt><b>Packed constants</b></dt> | 
|  | 916 |  | 
|  | 917 | <dd>Packed constants are represented with notation similar to packed type | 
|  | 918 | definitions (a comma separated list of elements, surrounded by | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 919 | less-than/greater-than's (<tt><></tt>)).  For example: "<tt>< int 42, | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 920 | int 11, int 74, int 100 ></tt>".  Packed constants must have <a | 
|  | 921 | href="#t_packed">packed type</a>, and the number and types of elements must | 
|  | 922 | match those specified by the type. | 
|  | 923 | </dd> | 
|  | 924 |  | 
|  | 925 | <dt><b>Zero initialization</b></dt> | 
|  | 926 |  | 
|  | 927 | <dd>The string '<tt>zeroinitializer</tt>' can be used to zero initialize a | 
|  | 928 | value to zero of <em>any</em> type, including scalar and aggregate types. | 
|  | 929 | This is often used to avoid having to print large zero initializers (e.g. for | 
|  | 930 | large arrays), and is always exactly equivalent to using explicit zero | 
|  | 931 | initializers. | 
|  | 932 | </dd> | 
|  | 933 | </dl> | 
|  | 934 |  | 
|  | 935 | </div> | 
|  | 936 |  | 
|  | 937 | <!-- ======================================================================= --> | 
|  | 938 | <div class="doc_subsection"> | 
|  | 939 | <a name="globalconstants">Global Variable and Function Addresses</a> | 
|  | 940 | </div> | 
|  | 941 |  | 
|  | 942 | <div class="doc_text"> | 
|  | 943 |  | 
|  | 944 | <p>The addresses of <a href="#globalvars">global variables</a> and <a | 
|  | 945 | href="#functionstructure">functions</a> are always implicitly valid (link-time) | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 946 | constants.  These constants are explicitly referenced when the <a | 
|  | 947 | href="#identifiers">identifier for the global</a> is used and always have <a | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 948 | href="#t_pointer">pointer</a> type. For example, the following is a legal LLVM | 
|  | 949 | file:</p> | 
|  | 950 |  | 
|  | 951 | <pre> | 
|  | 952 | %X = global int 17 | 
|  | 953 | %Y = global int 42 | 
|  | 954 | %Z = global [2 x int*] [ int* %X, int* %Y ] | 
|  | 955 | </pre> | 
|  | 956 |  | 
|  | 957 | </div> | 
|  | 958 |  | 
|  | 959 | <!-- ======================================================================= --> | 
| Reid Spencer | 2dc45b8 | 2004-12-09 18:13:12 +0000 | [diff] [blame] | 960 | <div class="doc_subsection"><a name="undefvalues">Undefined Values</a></div> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 961 | <div class="doc_text"> | 
| Reid Spencer | 2dc45b8 | 2004-12-09 18:13:12 +0000 | [diff] [blame] | 962 | <p>The string '<tt>undef</tt>' is recognized as a type-less constant that has | 
|  | 963 | no specific value.  Undefined values may be of any type, and be used anywhere | 
|  | 964 | a constant is permitted.</p> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 965 |  | 
| Reid Spencer | 2dc45b8 | 2004-12-09 18:13:12 +0000 | [diff] [blame] | 966 | <p>Undefined values indicate to the compiler that the program is well defined | 
|  | 967 | no matter what value is used, giving the compiler more freedom to optimize. | 
|  | 968 | </p> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 969 | </div> | 
|  | 970 |  | 
|  | 971 | <!-- ======================================================================= --> | 
|  | 972 | <div class="doc_subsection"><a name="constantexprs">Constant Expressions</a> | 
|  | 973 | </div> | 
|  | 974 |  | 
|  | 975 | <div class="doc_text"> | 
|  | 976 |  | 
|  | 977 | <p>Constant expressions are used to allow expressions involving other constants | 
|  | 978 | to be used as constants.  Constant expressions may be of any <a | 
|  | 979 | href="#t_firstclass">first class</a> type, and may involve any LLVM operation | 
|  | 980 | that does not have side effects (e.g. load and call are not supported).  The | 
|  | 981 | following is the syntax for constant expressions:</p> | 
|  | 982 |  | 
|  | 983 | <dl> | 
|  | 984 | <dt><b><tt>cast ( CST to TYPE )</tt></b></dt> | 
|  | 985 |  | 
|  | 986 | <dd>Cast a constant to another type.</dd> | 
|  | 987 |  | 
|  | 988 | <dt><b><tt>getelementptr ( CSTPTR, IDX0, IDX1, ... )</tt></b></dt> | 
|  | 989 |  | 
|  | 990 | <dd>Perform the <a href="#i_getelementptr">getelementptr operation</a> on | 
|  | 991 | constants.  As with the <a href="#i_getelementptr">getelementptr</a> | 
|  | 992 | instruction, the index list may have zero or more indexes, which are required | 
|  | 993 | to make sense for the type of "CSTPTR".</dd> | 
|  | 994 |  | 
|  | 995 | <dt><b><tt>OPCODE ( LHS, RHS )</tt></b></dt> | 
|  | 996 |  | 
| Reid Spencer | 2dc45b8 | 2004-12-09 18:13:12 +0000 | [diff] [blame] | 997 | <dd>Perform the specified operation of the LHS and RHS constants. OPCODE may | 
|  | 998 | be any of the <a href="#binaryops">binary</a> or <a href="#bitwiseops">bitwise | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 999 | binary</a> operations.  The constraints on operands are the same as those for | 
|  | 1000 | the corresponding instruction (e.g. no bitwise operations on floating point | 
|  | 1001 | are allowed).</dd> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1002 | </dl> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1003 | </div> | 
| Chris Lattner | 9ee5d22 | 2004-03-08 16:49:10 +0000 | [diff] [blame] | 1004 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1005 | <!-- *********************************************************************** --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1006 | <div class="doc_section"> <a name="instref">Instruction Reference</a> </div> | 
|  | 1007 | <!-- *********************************************************************** --> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1008 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1009 | <div class="doc_text"> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1010 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1011 | <p>The LLVM instruction set consists of several different | 
|  | 1012 | classifications of instructions: <a href="#terminators">terminator | 
|  | 1013 | instructions</a>, <a href="#binaryops">binary instructions</a>, <a | 
|  | 1014 | href="#memoryops">memory instructions</a>, and <a href="#otherops">other | 
|  | 1015 | instructions</a>.</p> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1016 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1017 | </div> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1018 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1019 | <!-- ======================================================================= --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1020 | <div class="doc_subsection"> <a name="terminators">Terminator | 
|  | 1021 | Instructions</a> </div> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1022 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1023 | <div class="doc_text"> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1024 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1025 | <p>As mentioned <a href="#functionstructure">previously</a>, every | 
|  | 1026 | basic block in a program ends with a "Terminator" instruction, which | 
|  | 1027 | indicates which block should be executed after the current block is | 
|  | 1028 | finished. These terminator instructions typically yield a '<tt>void</tt>' | 
|  | 1029 | value: they produce control flow, not values (the one exception being | 
|  | 1030 | the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction).</p> | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 1031 | <p>There are six different terminator instructions: the '<a | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1032 | href="#i_ret"><tt>ret</tt></a>' instruction, the '<a href="#i_br"><tt>br</tt></a>' | 
|  | 1033 | instruction, the '<a href="#i_switch"><tt>switch</tt></a>' instruction, | 
| Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 1034 | the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction, the '<a | 
|  | 1035 | href="#i_unwind"><tt>unwind</tt></a>' instruction, and the '<a | 
|  | 1036 | href="#i_unreachable"><tt>unreachable</tt></a>' instruction.</p> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1037 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1038 | </div> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1039 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1040 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1041 | <div class="doc_subsubsection"> <a name="i_ret">'<tt>ret</tt>' | 
|  | 1042 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1043 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1044 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1045 | <pre>  ret <type> <value>       <i>; Return a value from a non-void function</i> | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1046 | ret void                 <i>; Return from void function</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1047 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1048 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1049 | <p>The '<tt>ret</tt>' instruction is used to return control flow (and a | 
|  | 1050 | value) from a function, back to the caller.</p> | 
| John Criswell | 4457dc9 | 2004-04-09 16:48:45 +0000 | [diff] [blame] | 1051 | <p>There are two forms of the '<tt>ret</tt>' instruction: one that | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1052 | returns a value and then causes control flow, and one that just causes | 
|  | 1053 | control flow to occur.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1054 | <h5>Arguments:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1055 | <p>The '<tt>ret</tt>' instruction may return any '<a | 
|  | 1056 | href="#t_firstclass">first class</a>' type.  Notice that a function is | 
|  | 1057 | not <a href="#wellformed">well formed</a> if there exists a '<tt>ret</tt>' | 
|  | 1058 | instruction inside of the function that returns a value that does not | 
|  | 1059 | match the return type of the function.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1060 | <h5>Semantics:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1061 | <p>When the '<tt>ret</tt>' instruction is executed, control flow | 
|  | 1062 | returns back to the calling function's context.  If the caller is a "<a | 
| John Criswell | fa08187 | 2004-06-25 15:16:57 +0000 | [diff] [blame] | 1063 | href="#i_call"><tt>call</tt></a>" instruction, execution continues at | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1064 | the instruction after the call.  If the caller was an "<a | 
|  | 1065 | href="#i_invoke"><tt>invoke</tt></a>" instruction, execution continues | 
|  | 1066 | at the beginning "normal" of the destination block.  If the instruction | 
|  | 1067 | returns a value, that value shall set the call or invoke instruction's | 
|  | 1068 | return value.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1069 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1070 | <pre>  ret int 5                       <i>; Return an integer value of 5</i> | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1071 | ret void                        <i>; Return from a void function</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1072 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1073 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1074 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1075 | <div class="doc_subsubsection"> <a name="i_br">'<tt>br</tt>' Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1076 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1077 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1078 | <pre>  br bool <cond>, label <iftrue>, label <iffalse><br>  br label <dest>          <i>; Unconditional branch</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1079 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1080 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1081 | <p>The '<tt>br</tt>' instruction is used to cause control flow to | 
|  | 1082 | transfer to a different basic block in the current function.  There are | 
|  | 1083 | two forms of this instruction, corresponding to a conditional branch | 
|  | 1084 | and an unconditional branch.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1085 | <h5>Arguments:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1086 | <p>The conditional branch form of the '<tt>br</tt>' instruction takes a | 
|  | 1087 | single '<tt>bool</tt>' value and two '<tt>label</tt>' values.  The | 
|  | 1088 | unconditional form of the '<tt>br</tt>' instruction takes a single '<tt>label</tt>' | 
|  | 1089 | value as a target.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1090 | <h5>Semantics:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1091 | <p>Upon execution of a conditional '<tt>br</tt>' instruction, the '<tt>bool</tt>' | 
|  | 1092 | argument is evaluated.  If the value is <tt>true</tt>, control flows | 
|  | 1093 | to the '<tt>iftrue</tt>' <tt>label</tt> argument.  If "cond" is <tt>false</tt>, | 
|  | 1094 | control flows to the '<tt>iffalse</tt>' <tt>label</tt> argument.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1095 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1096 | <pre>Test:<br>  %cond = <a href="#i_setcc">seteq</a> int %a, %b<br>  br bool %cond, label %IfEqual, label %IfUnequal<br>IfEqual:<br>  <a | 
|  | 1097 | href="#i_ret">ret</a> int 1<br>IfUnequal:<br>  <a href="#i_ret">ret</a> int 0<br></pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1098 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1099 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 1100 | <div class="doc_subsubsection"> | 
|  | 1101 | <a name="i_switch">'<tt>switch</tt>' Instruction</a> | 
|  | 1102 | </div> | 
|  | 1103 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1104 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1105 | <h5>Syntax:</h5> | 
| Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 1106 |  | 
|  | 1107 | <pre> | 
|  | 1108 | switch <intty> <value>, label <defaultdest> [ <intty> <val>, label <dest> ... ] | 
|  | 1109 | </pre> | 
|  | 1110 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1111 | <h5>Overview:</h5> | 
| Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 1112 |  | 
|  | 1113 | <p>The '<tt>switch</tt>' instruction is used to transfer control flow to one of | 
|  | 1114 | several different places.  It is a generalization of the '<tt>br</tt>' | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1115 | instruction, allowing a branch to occur to one of many possible | 
|  | 1116 | destinations.</p> | 
| Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 1117 |  | 
|  | 1118 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1119 | <h5>Arguments:</h5> | 
| Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 1120 |  | 
|  | 1121 | <p>The '<tt>switch</tt>' instruction uses three parameters: an integer | 
|  | 1122 | comparison value '<tt>value</tt>', a default '<tt>label</tt>' destination, and | 
|  | 1123 | an array of pairs of comparison value constants and '<tt>label</tt>'s.  The | 
|  | 1124 | table is not allowed to contain duplicate constant entries.</p> | 
|  | 1125 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1126 | <h5>Semantics:</h5> | 
| Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 1127 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1128 | <p>The <tt>switch</tt> instruction specifies a table of values and | 
|  | 1129 | destinations. When the '<tt>switch</tt>' instruction is executed, this | 
| John Criswell | 8411475 | 2004-06-25 16:05:06 +0000 | [diff] [blame] | 1130 | table is searched for the given value.  If the value is found, control flow is | 
|  | 1131 | transfered to the corresponding destination; otherwise, control flow is | 
|  | 1132 | transfered to the default destination.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1133 |  | 
| Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 1134 | <h5>Implementation:</h5> | 
|  | 1135 |  | 
|  | 1136 | <p>Depending on properties of the target machine and the particular | 
|  | 1137 | <tt>switch</tt> instruction, this instruction may be code generated in different | 
| John Criswell | 8411475 | 2004-06-25 16:05:06 +0000 | [diff] [blame] | 1138 | ways.  For example, it could be generated as a series of chained conditional | 
|  | 1139 | branches or with a lookup table.</p> | 
| Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 1140 |  | 
|  | 1141 | <h5>Example:</h5> | 
|  | 1142 |  | 
|  | 1143 | <pre> | 
|  | 1144 | <i>; Emulate a conditional br instruction</i> | 
|  | 1145 | %Val = <a href="#i_cast">cast</a> bool %value to int | 
|  | 1146 | switch int %Val, label %truedest [int 0, label %falsedest ] | 
|  | 1147 |  | 
|  | 1148 | <i>; Emulate an unconditional br instruction</i> | 
|  | 1149 | switch uint 0, label %dest [ ] | 
|  | 1150 |  | 
|  | 1151 | <i>; Implement a jump table:</i> | 
|  | 1152 | switch uint %val, label %otherwise [ uint 0, label %onzero | 
|  | 1153 | uint 1, label %onone | 
|  | 1154 | uint 2, label %ontwo ] | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1155 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1156 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1157 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1158 | <div class="doc_subsubsection"> <a name="i_invoke">'<tt>invoke</tt>' | 
|  | 1159 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1160 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1161 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1162 | <pre>  <result> = invoke <ptr to function ty> %<function ptr val>(<function args>)<br>                 to label <normal label> except label <exception label><br></pre> | 
| Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 1163 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1164 | <p>The '<tt>invoke</tt>' instruction causes control to transfer to a | 
|  | 1165 | specified function, with the possibility of control flow transfer to | 
|  | 1166 | either the '<tt>normal</tt>' <tt>label</tt> label or the '<tt>exception</tt>'<tt>label</tt>. | 
|  | 1167 | If the callee function returns with the "<tt><a href="#i_ret">ret</a></tt>" | 
|  | 1168 | instruction, control flow will return to the "normal" label.  If the | 
|  | 1169 | callee (or any indirect callees) returns with the "<a href="#i_unwind"><tt>unwind</tt></a>" | 
|  | 1170 | instruction, control is interrupted, and continued at the dynamically | 
|  | 1171 | nearest "except" label.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1172 | <h5>Arguments:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1173 | <p>This instruction requires several arguments:</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1174 | <ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1175 | <li>'<tt>ptr to function ty</tt>': shall be the signature of the | 
|  | 1176 | pointer to function value being invoked.  In most cases, this is a | 
|  | 1177 | direct function invocation, but indirect <tt>invoke</tt>s are just as | 
|  | 1178 | possible, branching off an arbitrary pointer to function value. </li> | 
|  | 1179 | <li>'<tt>function ptr val</tt>': An LLVM value containing a pointer | 
|  | 1180 | to a function to be invoked. </li> | 
|  | 1181 | <li>'<tt>function args</tt>': argument list whose types match the | 
|  | 1182 | function signature argument types.  If the function signature indicates | 
|  | 1183 | the function accepts a variable number of arguments, the extra | 
|  | 1184 | arguments can be specified. </li> | 
|  | 1185 | <li>'<tt>normal label</tt>': the label reached when the called | 
|  | 1186 | function executes a '<tt><a href="#i_ret">ret</a></tt>' instruction. </li> | 
|  | 1187 | <li>'<tt>exception label</tt>': the label reached when a callee | 
|  | 1188 | returns with the <a href="#i_unwind"><tt>unwind</tt></a> instruction. </li> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1189 | </ol> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1190 | <h5>Semantics:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1191 | <p>This instruction is designed to operate as a standard '<tt><a | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1192 | href="#i_call">call</a></tt>' instruction in most regards.  The | 
|  | 1193 | primary difference is that it establishes an association with a label, | 
|  | 1194 | which is used by the runtime library to unwind the stack.</p> | 
|  | 1195 | <p>This instruction is used in languages with destructors to ensure | 
|  | 1196 | that proper cleanup is performed in the case of either a <tt>longjmp</tt> | 
|  | 1197 | or a thrown exception.  Additionally, this is important for | 
|  | 1198 | implementation of '<tt>catch</tt>' clauses in high-level languages that | 
|  | 1199 | support them.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1200 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1201 | <pre>  %retval = invoke int %Test(int 15)<br>              to label %Continue<br>              except label %TestCleanup     <i>; {int}:retval set</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1202 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1203 | </div> | 
| Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 1204 |  | 
|  | 1205 |  | 
| Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 1206 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 1207 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1208 | <div class="doc_subsubsection"> <a name="i_unwind">'<tt>unwind</tt>' | 
|  | 1209 | Instruction</a> </div> | 
| Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 1210 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1211 | <div class="doc_text"> | 
| Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 1212 |  | 
| Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 1213 | <h5>Syntax:</h5> | 
| Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 1214 | <pre> | 
|  | 1215 | unwind | 
|  | 1216 | </pre> | 
|  | 1217 |  | 
| Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 1218 | <h5>Overview:</h5> | 
| Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 1219 |  | 
|  | 1220 | <p>The '<tt>unwind</tt>' instruction unwinds the stack, continuing control flow | 
|  | 1221 | at the first callee in the dynamic call stack which used an <a | 
|  | 1222 | href="#i_invoke"><tt>invoke</tt></a> instruction to perform the call.  This is | 
|  | 1223 | primarily used to implement exception handling.</p> | 
|  | 1224 |  | 
| Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 1225 | <h5>Semantics:</h5> | 
| Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 1226 |  | 
|  | 1227 | <p>The '<tt>unwind</tt>' intrinsic causes execution of the current function to | 
|  | 1228 | immediately halt.  The dynamic call stack is then searched for the first <a | 
|  | 1229 | href="#i_invoke"><tt>invoke</tt></a> instruction on the call stack.  Once found, | 
|  | 1230 | execution continues at the "exceptional" destination block specified by the | 
|  | 1231 | <tt>invoke</tt> instruction.  If there is no <tt>invoke</tt> instruction in the | 
|  | 1232 | dynamic call chain, undefined behavior results.</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1233 | </div> | 
| Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 1234 |  | 
|  | 1235 | <!-- _______________________________________________________________________ --> | 
|  | 1236 |  | 
|  | 1237 | <div class="doc_subsubsection"> <a name="i_unreachable">'<tt>unreachable</tt>' | 
|  | 1238 | Instruction</a> </div> | 
|  | 1239 |  | 
|  | 1240 | <div class="doc_text"> | 
|  | 1241 |  | 
|  | 1242 | <h5>Syntax:</h5> | 
|  | 1243 | <pre> | 
|  | 1244 | unreachable | 
|  | 1245 | </pre> | 
|  | 1246 |  | 
|  | 1247 | <h5>Overview:</h5> | 
|  | 1248 |  | 
|  | 1249 | <p>The '<tt>unreachable</tt>' instruction has no defined semantics.  This | 
|  | 1250 | instruction is used to inform the optimizer that a particular portion of the | 
|  | 1251 | code is not reachable.  This can be used to indicate that the code after a | 
|  | 1252 | no-return function cannot be reached, and other facts.</p> | 
|  | 1253 |  | 
|  | 1254 | <h5>Semantics:</h5> | 
|  | 1255 |  | 
|  | 1256 | <p>The '<tt>unreachable</tt>' instruction has no defined semantics.</p> | 
|  | 1257 | </div> | 
|  | 1258 |  | 
|  | 1259 |  | 
|  | 1260 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1261 | <!-- ======================================================================= --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1262 | <div class="doc_subsection"> <a name="binaryops">Binary Operations</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1263 | <div class="doc_text"> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1264 | <p>Binary operators are used to do most of the computation in a | 
|  | 1265 | program.  They require two operands, execute an operation on them, and | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 1266 | produce a single value.  The operands might represent | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1267 | multiple data, as is the case with the <a href="#t_packed">packed</a> data type. | 
|  | 1268 | The result value of a binary operator is not | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1269 | necessarily the same type as its operands.</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1270 | <p>There are several different binary operators:</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1271 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1272 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1273 | <div class="doc_subsubsection"> <a name="i_add">'<tt>add</tt>' | 
|  | 1274 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1275 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1276 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1277 | <pre>  <result> = add <ty> <var1>, <var2>   <i>; yields {ty}:result</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1278 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1279 | <h5>Overview:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1280 | <p>The '<tt>add</tt>' instruction returns the sum of its two operands.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1281 | <h5>Arguments:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1282 | <p>The two arguments to the '<tt>add</tt>' instruction must be either <a | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1283 | href="#t_integer">integer</a> or <a href="#t_floating">floating point</a> values. | 
|  | 1284 | This instruction can also take <a href="#t_packed">packed</a> versions of the values. | 
|  | 1285 | Both arguments must have identical types.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1286 | <h5>Semantics:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1287 | <p>The value produced is the integer or floating point sum of the two | 
|  | 1288 | operands.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1289 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1290 | <pre>  <result> = add int 4, %var          <i>; yields {int}:result = 4 + %var</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1291 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1292 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1293 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1294 | <div class="doc_subsubsection"> <a name="i_sub">'<tt>sub</tt>' | 
|  | 1295 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1296 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1297 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1298 | <pre>  <result> = sub <ty> <var1>, <var2>   <i>; yields {ty}:result</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1299 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1300 | <h5>Overview:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1301 | <p>The '<tt>sub</tt>' instruction returns the difference of its two | 
|  | 1302 | operands.</p> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1303 | <p>Note that the '<tt>sub</tt>' instruction is used to represent the '<tt>neg</tt>' | 
|  | 1304 | instruction present in most other intermediate representations.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1305 | <h5>Arguments:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1306 | <p>The two arguments to the '<tt>sub</tt>' instruction must be either <a | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1307 | href="#t_integer">integer</a> or <a href="#t_floating">floating point</a> | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1308 | values. | 
|  | 1309 | This instruction can also take <a href="#t_packed">packed</a> versions of the values. | 
|  | 1310 | Both arguments must have identical types.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1311 | <h5>Semantics:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1312 | <p>The value produced is the integer or floating point difference of | 
|  | 1313 | the two operands.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1314 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1315 | <pre>  <result> = sub int 4, %var          <i>; yields {int}:result = 4 - %var</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1316 | <result> = sub int 0, %val          <i>; yields {int}:result = -%var</i> | 
|  | 1317 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1318 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1319 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1320 | <div class="doc_subsubsection"> <a name="i_mul">'<tt>mul</tt>' | 
|  | 1321 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1322 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1323 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1324 | <pre>  <result> = mul <ty> <var1>, <var2>   <i>; yields {ty}:result</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1325 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1326 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1327 | <p>The  '<tt>mul</tt>' instruction returns the product of its two | 
|  | 1328 | operands.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1329 | <h5>Arguments:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1330 | <p>The two arguments to the '<tt>mul</tt>' instruction must be either <a | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1331 | href="#t_integer">integer</a> or <a href="#t_floating">floating point</a> | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1332 | values. | 
|  | 1333 | This instruction can also take <a href="#t_packed">packed</a> versions of the values. | 
|  | 1334 | Both arguments must have identical types.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1335 | <h5>Semantics:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1336 | <p>The value produced is the integer or floating point product of the | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1337 | two operands.</p> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1338 | <p>There is no signed vs unsigned multiplication.  The appropriate | 
|  | 1339 | action is taken based on the type of the operand.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1340 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1341 | <pre>  <result> = mul int 4, %var          <i>; yields {int}:result = 4 * %var</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1342 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1343 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1344 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1345 | <div class="doc_subsubsection"> <a name="i_div">'<tt>div</tt>' | 
|  | 1346 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1347 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1348 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1349 | <pre>  <result> = div <ty> <var1>, <var2>   <i>; yields {ty}:result</i> | 
|  | 1350 | </pre> | 
|  | 1351 | <h5>Overview:</h5> | 
|  | 1352 | <p>The '<tt>div</tt>' instruction returns the quotient of its two | 
|  | 1353 | operands.</p> | 
|  | 1354 | <h5>Arguments:</h5> | 
|  | 1355 | <p>The two arguments to the '<tt>div</tt>' instruction must be either <a | 
|  | 1356 | href="#t_integer">integer</a> or <a href="#t_floating">floating point</a> | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1357 | values. | 
|  | 1358 | This instruction can also take <a href="#t_packed">packed</a> versions of the values. | 
|  | 1359 | Both arguments must have identical types.</p> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1360 | <h5>Semantics:</h5> | 
|  | 1361 | <p>The value produced is the integer or floating point quotient of the | 
|  | 1362 | two operands.</p> | 
|  | 1363 | <h5>Example:</h5> | 
|  | 1364 | <pre>  <result> = div int 4, %var          <i>; yields {int}:result = 4 / %var</i> | 
|  | 1365 | </pre> | 
|  | 1366 | </div> | 
|  | 1367 | <!-- _______________________________________________________________________ --> | 
|  | 1368 | <div class="doc_subsubsection"> <a name="i_rem">'<tt>rem</tt>' | 
|  | 1369 | Instruction</a> </div> | 
|  | 1370 | <div class="doc_text"> | 
|  | 1371 | <h5>Syntax:</h5> | 
|  | 1372 | <pre>  <result> = rem <ty> <var1>, <var2>   <i>; yields {ty}:result</i> | 
|  | 1373 | </pre> | 
|  | 1374 | <h5>Overview:</h5> | 
|  | 1375 | <p>The '<tt>rem</tt>' instruction returns the remainder from the | 
|  | 1376 | division of its two operands.</p> | 
|  | 1377 | <h5>Arguments:</h5> | 
|  | 1378 | <p>The two arguments to the '<tt>rem</tt>' instruction must be either <a | 
|  | 1379 | href="#t_integer">integer</a> or <a href="#t_floating">floating point</a> | 
| Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1380 | values. | 
|  | 1381 | This instruction can also take <a href="#t_packed">packed</a> versions of the values. | 
|  | 1382 | Both arguments must have identical types.</p> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1383 | <h5>Semantics:</h5> | 
|  | 1384 | <p>This returns the <i>remainder</i> of a division (where the result | 
|  | 1385 | has the same sign as the divisor), not the <i>modulus</i> (where the | 
|  | 1386 | result has the same sign as the dividend) of a value.  For more | 
|  | 1387 | information about the difference, see: <a | 
|  | 1388 | href="http://mathforum.org/dr.math/problems/anne.4.28.99.html">The | 
|  | 1389 | Math Forum</a>.</p> | 
|  | 1390 | <h5>Example:</h5> | 
|  | 1391 | <pre>  <result> = rem int 4, %var          <i>; yields {int}:result = 4 % %var</i> | 
|  | 1392 | </pre> | 
|  | 1393 | </div> | 
|  | 1394 | <!-- _______________________________________________________________________ --> | 
|  | 1395 | <div class="doc_subsubsection"> <a name="i_setcc">'<tt>set<i>cc</i></tt>' | 
|  | 1396 | Instructions</a> </div> | 
|  | 1397 | <div class="doc_text"> | 
|  | 1398 | <h5>Syntax:</h5> | 
|  | 1399 | <pre>  <result> = seteq <ty> <var1>, <var2>   <i>; yields {bool}:result</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1400 | <result> = setne <ty> <var1>, <var2>   <i>; yields {bool}:result</i> | 
|  | 1401 | <result> = setlt <ty> <var1>, <var2>   <i>; yields {bool}:result</i> | 
|  | 1402 | <result> = setgt <ty> <var1>, <var2>   <i>; yields {bool}:result</i> | 
|  | 1403 | <result> = setle <ty> <var1>, <var2>   <i>; yields {bool}:result</i> | 
|  | 1404 | <result> = setge <ty> <var1>, <var2>   <i>; yields {bool}:result</i> | 
|  | 1405 | </pre> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1406 | <h5>Overview:</h5> | 
|  | 1407 | <p>The '<tt>set<i>cc</i></tt>' family of instructions returns a boolean | 
|  | 1408 | value based on a comparison of their two operands.</p> | 
|  | 1409 | <h5>Arguments:</h5> | 
|  | 1410 | <p>The two arguments to the '<tt>set<i>cc</i></tt>' instructions must | 
|  | 1411 | be of <a href="#t_firstclass">first class</a> type (it is not possible | 
|  | 1412 | to compare '<tt>label</tt>'s, '<tt>array</tt>'s, '<tt>structure</tt>' | 
|  | 1413 | or '<tt>void</tt>' values, etc...).  Both arguments must have identical | 
|  | 1414 | types.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1415 | <h5>Semantics:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1416 | <p>The '<tt>seteq</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' | 
|  | 1417 | value if both operands are equal.<br> | 
|  | 1418 | The '<tt>setne</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' | 
|  | 1419 | value if both operands are unequal.<br> | 
|  | 1420 | The '<tt>setlt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' | 
|  | 1421 | value if the first operand is less than the second operand.<br> | 
|  | 1422 | The '<tt>setgt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' | 
|  | 1423 | value if the first operand is greater than the second operand.<br> | 
|  | 1424 | The '<tt>setle</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' | 
|  | 1425 | value if the first operand is less than or equal to the second operand.<br> | 
|  | 1426 | The '<tt>setge</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' | 
|  | 1427 | value if the first operand is greater than or equal to the second | 
|  | 1428 | operand.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1429 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1430 | <pre>  <result> = seteq int   4, 5        <i>; yields {bool}:result = false</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1431 | <result> = setne float 4, 5        <i>; yields {bool}:result = true</i> | 
|  | 1432 | <result> = setlt uint  4, 5        <i>; yields {bool}:result = true</i> | 
|  | 1433 | <result> = setgt sbyte 4, 5        <i>; yields {bool}:result = false</i> | 
|  | 1434 | <result> = setle sbyte 4, 5        <i>; yields {bool}:result = true</i> | 
|  | 1435 | <result> = setge sbyte 4, 5        <i>; yields {bool}:result = false</i> | 
|  | 1436 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1437 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1438 | <!-- ======================================================================= --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1439 | <div class="doc_subsection"> <a name="bitwiseops">Bitwise Binary | 
|  | 1440 | Operations</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1441 | <div class="doc_text"> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1442 | <p>Bitwise binary operators are used to do various forms of | 
|  | 1443 | bit-twiddling in a program.  They are generally very efficient | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 1444 | instructions and can commonly be strength reduced from other | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1445 | instructions.  They require two operands, execute an operation on them, | 
|  | 1446 | and produce a single value.  The resulting value of the bitwise binary | 
|  | 1447 | operators is always the same type as its first operand.</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1448 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1449 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1450 | <div class="doc_subsubsection"> <a name="i_and">'<tt>and</tt>' | 
|  | 1451 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1452 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1453 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1454 | <pre>  <result> = and <ty> <var1>, <var2>   <i>; yields {ty}:result</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1455 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1456 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1457 | <p>The '<tt>and</tt>' instruction returns the bitwise logical and of | 
|  | 1458 | its two operands.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1459 | <h5>Arguments:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1460 | <p>The two arguments to the '<tt>and</tt>' instruction must be <a | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1461 | href="#t_integral">integral</a> values.  Both arguments must have | 
|  | 1462 | identical types.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1463 | <h5>Semantics:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1464 | <p>The truth table used for the '<tt>and</tt>' instruction is:</p> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1465 | <p> </p> | 
| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1466 | <div style="align: center"> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1467 | <table border="1" cellspacing="0" cellpadding="4"> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1468 | <tbody> | 
|  | 1469 | <tr> | 
|  | 1470 | <td>In0</td> | 
|  | 1471 | <td>In1</td> | 
|  | 1472 | <td>Out</td> | 
|  | 1473 | </tr> | 
|  | 1474 | <tr> | 
|  | 1475 | <td>0</td> | 
|  | 1476 | <td>0</td> | 
|  | 1477 | <td>0</td> | 
|  | 1478 | </tr> | 
|  | 1479 | <tr> | 
|  | 1480 | <td>0</td> | 
|  | 1481 | <td>1</td> | 
|  | 1482 | <td>0</td> | 
|  | 1483 | </tr> | 
|  | 1484 | <tr> | 
|  | 1485 | <td>1</td> | 
|  | 1486 | <td>0</td> | 
|  | 1487 | <td>0</td> | 
|  | 1488 | </tr> | 
|  | 1489 | <tr> | 
|  | 1490 | <td>1</td> | 
|  | 1491 | <td>1</td> | 
|  | 1492 | <td>1</td> | 
|  | 1493 | </tr> | 
|  | 1494 | </tbody> | 
|  | 1495 | </table> | 
| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1496 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1497 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1498 | <pre>  <result> = and int 4, %var         <i>; yields {int}:result = 4 & %var</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1499 | <result> = and int 15, 40          <i>; yields {int}:result = 8</i> | 
|  | 1500 | <result> = and int 4, 8            <i>; yields {int}:result = 0</i> | 
|  | 1501 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1502 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1503 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1504 | <div class="doc_subsubsection"> <a name="i_or">'<tt>or</tt>' Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1505 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1506 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1507 | <pre>  <result> = or <ty> <var1>, <var2>   <i>; yields {ty}:result</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1508 | </pre> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1509 | <h5>Overview:</h5> | 
|  | 1510 | <p>The '<tt>or</tt>' instruction returns the bitwise logical inclusive | 
|  | 1511 | or of its two operands.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1512 | <h5>Arguments:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1513 | <p>The two arguments to the '<tt>or</tt>' instruction must be <a | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1514 | href="#t_integral">integral</a> values.  Both arguments must have | 
|  | 1515 | identical types.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1516 | <h5>Semantics:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1517 | <p>The truth table used for the '<tt>or</tt>' instruction is:</p> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1518 | <p> </p> | 
| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1519 | <div style="align: center"> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1520 | <table border="1" cellspacing="0" cellpadding="4"> | 
|  | 1521 | <tbody> | 
|  | 1522 | <tr> | 
|  | 1523 | <td>In0</td> | 
|  | 1524 | <td>In1</td> | 
|  | 1525 | <td>Out</td> | 
|  | 1526 | </tr> | 
|  | 1527 | <tr> | 
|  | 1528 | <td>0</td> | 
|  | 1529 | <td>0</td> | 
|  | 1530 | <td>0</td> | 
|  | 1531 | </tr> | 
|  | 1532 | <tr> | 
|  | 1533 | <td>0</td> | 
|  | 1534 | <td>1</td> | 
|  | 1535 | <td>1</td> | 
|  | 1536 | </tr> | 
|  | 1537 | <tr> | 
|  | 1538 | <td>1</td> | 
|  | 1539 | <td>0</td> | 
|  | 1540 | <td>1</td> | 
|  | 1541 | </tr> | 
|  | 1542 | <tr> | 
|  | 1543 | <td>1</td> | 
|  | 1544 | <td>1</td> | 
|  | 1545 | <td>1</td> | 
|  | 1546 | </tr> | 
|  | 1547 | </tbody> | 
|  | 1548 | </table> | 
| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1549 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1550 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1551 | <pre>  <result> = or int 4, %var         <i>; yields {int}:result = 4 | %var</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1552 | <result> = or int 15, 40          <i>; yields {int}:result = 47</i> | 
|  | 1553 | <result> = or int 4, 8            <i>; yields {int}:result = 12</i> | 
|  | 1554 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1555 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1556 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1557 | <div class="doc_subsubsection"> <a name="i_xor">'<tt>xor</tt>' | 
|  | 1558 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1559 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1560 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1561 | <pre>  <result> = xor <ty> <var1>, <var2>   <i>; yields {ty}:result</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1562 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1563 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1564 | <p>The '<tt>xor</tt>' instruction returns the bitwise logical exclusive | 
|  | 1565 | or of its two operands.  The <tt>xor</tt> is used to implement the | 
|  | 1566 | "one's complement" operation, which is the "~" operator in C.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1567 | <h5>Arguments:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1568 | <p>The two arguments to the '<tt>xor</tt>' instruction must be <a | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1569 | href="#t_integral">integral</a> values.  Both arguments must have | 
|  | 1570 | identical types.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1571 | <h5>Semantics:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1572 | <p>The truth table used for the '<tt>xor</tt>' instruction is:</p> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1573 | <p> </p> | 
| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1574 | <div style="align: center"> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1575 | <table border="1" cellspacing="0" cellpadding="4"> | 
|  | 1576 | <tbody> | 
|  | 1577 | <tr> | 
|  | 1578 | <td>In0</td> | 
|  | 1579 | <td>In1</td> | 
|  | 1580 | <td>Out</td> | 
|  | 1581 | </tr> | 
|  | 1582 | <tr> | 
|  | 1583 | <td>0</td> | 
|  | 1584 | <td>0</td> | 
|  | 1585 | <td>0</td> | 
|  | 1586 | </tr> | 
|  | 1587 | <tr> | 
|  | 1588 | <td>0</td> | 
|  | 1589 | <td>1</td> | 
|  | 1590 | <td>1</td> | 
|  | 1591 | </tr> | 
|  | 1592 | <tr> | 
|  | 1593 | <td>1</td> | 
|  | 1594 | <td>0</td> | 
|  | 1595 | <td>1</td> | 
|  | 1596 | </tr> | 
|  | 1597 | <tr> | 
|  | 1598 | <td>1</td> | 
|  | 1599 | <td>1</td> | 
|  | 1600 | <td>0</td> | 
|  | 1601 | </tr> | 
|  | 1602 | </tbody> | 
|  | 1603 | </table> | 
| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1604 | </div> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1605 | <p> </p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1606 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1607 | <pre>  <result> = xor int 4, %var         <i>; yields {int}:result = 4 ^ %var</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1608 | <result> = xor int 15, 40          <i>; yields {int}:result = 39</i> | 
|  | 1609 | <result> = xor int 4, 8            <i>; yields {int}:result = 12</i> | 
| Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 1610 | <result> = xor int %V, -1          <i>; yields {int}:result = ~%V</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1611 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1612 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1613 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1614 | <div class="doc_subsubsection"> <a name="i_shl">'<tt>shl</tt>' | 
|  | 1615 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1616 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1617 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1618 | <pre>  <result> = shl <ty> <var1>, ubyte <var2>   <i>; yields {ty}:result</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1619 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1620 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1621 | <p>The '<tt>shl</tt>' instruction returns the first operand shifted to | 
|  | 1622 | the left a specified number of bits.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1623 | <h5>Arguments:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1624 | <p>The first argument to the '<tt>shl</tt>' instruction must be an <a | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1625 | href="#t_integer">integer</a> type.  The second argument must be an '<tt>ubyte</tt>' | 
|  | 1626 | type.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1627 | <h5>Semantics:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1628 | <p>The value produced is <tt>var1</tt> * 2<sup><tt>var2</tt></sup>.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1629 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1630 | <pre>  <result> = shl int 4, ubyte %var   <i>; yields {int}:result = 4 << %var</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1631 | <result> = shl int 4, ubyte 2      <i>; yields {int}:result = 16</i> | 
|  | 1632 | <result> = shl int 1, ubyte 10     <i>; yields {int}:result = 1024</i> | 
|  | 1633 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1634 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1635 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1636 | <div class="doc_subsubsection"> <a name="i_shr">'<tt>shr</tt>' | 
|  | 1637 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1638 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1639 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1640 | <pre>  <result> = shr <ty> <var1>, ubyte <var2>   <i>; yields {ty}:result</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1641 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1642 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1643 | <p>The '<tt>shr</tt>' instruction returns the first operand shifted to | 
|  | 1644 | the right a specified number of bits.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1645 | <h5>Arguments:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1646 | <p>The first argument to the '<tt>shr</tt>' instruction must be an <a | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1647 | href="#t_integer">integer</a> type.  The second argument must be an '<tt>ubyte</tt>' | 
|  | 1648 | type.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1649 | <h5>Semantics:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1650 | <p>If the first argument is a <a href="#t_signed">signed</a> type, the | 
|  | 1651 | most significant bit is duplicated in the newly free'd bit positions. | 
|  | 1652 | If the first argument is unsigned, zero bits shall fill the empty | 
|  | 1653 | positions.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1654 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1655 | <pre>  <result> = shr int 4, ubyte %var   <i>; yields {int}:result = 4 >> %var</i> | 
| Chris Lattner | 8c6bb90 | 2003-06-18 21:30:51 +0000 | [diff] [blame] | 1656 | <result> = shr uint 4, ubyte 1     <i>; yields {uint}:result = 2</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1657 | <result> = shr int 4, ubyte 2      <i>; yields {int}:result = 1</i> | 
| Chris Lattner | 8c6bb90 | 2003-06-18 21:30:51 +0000 | [diff] [blame] | 1658 | <result> = shr sbyte 4, ubyte 3    <i>; yields {sbyte}:result = 0</i> | 
|  | 1659 | <result> = shr sbyte -2, ubyte 1   <i>; yields {sbyte}:result = -1</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1660 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1661 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1662 | <!-- ======================================================================= --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1663 | <div class="doc_subsection"> <a name="memoryops">Memory Access | 
|  | 1664 | Operations</a></div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1665 | <div class="doc_text"> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1666 | <p>A key design point of an SSA-based representation is how it | 
|  | 1667 | represents memory.  In LLVM, no memory locations are in SSA form, which | 
|  | 1668 | makes things very simple.  This section describes how to read, write, | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 1669 | allocate, and free memory in LLVM.</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1670 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1671 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1672 | <div class="doc_subsubsection"> <a name="i_malloc">'<tt>malloc</tt>' | 
|  | 1673 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1674 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1675 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1676 | <pre>  <result> = malloc <type>, uint <NumElements>     <i>; yields {type*}:result</i> | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1677 | <result> = malloc <type>                         <i>; yields {type*}:result</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1678 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1679 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1680 | <p>The '<tt>malloc</tt>' instruction allocates memory from the system | 
|  | 1681 | heap and returns a pointer to it.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1682 | <h5>Arguments:</h5> | 
| John Criswell | 6e4ca61 | 2004-02-24 16:13:56 +0000 | [diff] [blame] | 1683 | <p>The '<tt>malloc</tt>' instruction allocates <tt>sizeof(<type>)*NumElements</tt> | 
|  | 1684 | bytes of memory from the operating system and returns a pointer of the | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1685 | appropriate type to the program.  The second form of the instruction is | 
|  | 1686 | a shorter version of the first instruction that defaults to allocating | 
|  | 1687 | one element.</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1688 | <p>'<tt>type</tt>' must be a sized type.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1689 | <h5>Semantics:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1690 | <p>Memory is allocated using the system "<tt>malloc</tt>" function, and | 
|  | 1691 | a pointer is returned.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1692 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1693 | <pre>  %array  = malloc [4 x ubyte ]                    <i>; yields {[%4 x ubyte]*}:array</i> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1694 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1695 | %size   = <a | 
|  | 1696 | href="#i_add">add</a> uint 2, 2                          <i>; yields {uint}:size = uint 4</i> | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1697 | %array1 = malloc ubyte, uint 4                   <i>; yields {ubyte*}:array1</i> | 
|  | 1698 | %array2 = malloc [12 x ubyte], uint %size        <i>; yields {[12 x ubyte]*}:array2</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1699 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1700 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1701 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1702 | <div class="doc_subsubsection"> <a name="i_free">'<tt>free</tt>' | 
|  | 1703 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1704 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1705 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1706 | <pre>  free <type> <value>                              <i>; yields {void}</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1707 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1708 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1709 | <p>The '<tt>free</tt>' instruction returns memory back to the unused | 
|  | 1710 | memory heap, to be reallocated in the future.</p> | 
|  | 1711 | <p> </p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1712 | <h5>Arguments:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1713 | <p>'<tt>value</tt>' shall be a pointer value that points to a value | 
|  | 1714 | that was allocated with the '<tt><a href="#i_malloc">malloc</a></tt>' | 
|  | 1715 | instruction.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1716 | <h5>Semantics:</h5> | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 1717 | <p>Access to the memory pointed to by the pointer is no longer defined | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1718 | after this instruction executes.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1719 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1720 | <pre>  %array  = <a href="#i_malloc">malloc</a> [4 x ubyte]                    <i>; yields {[4 x ubyte]*}:array</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1721 | free   [4 x ubyte]* %array | 
|  | 1722 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1723 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1724 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1725 | <div class="doc_subsubsection"> <a name="i_alloca">'<tt>alloca</tt>' | 
|  | 1726 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1727 | <div class="doc_text"> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1728 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1729 | <pre>  <result> = alloca <type>, uint <NumElements>  <i>; yields {type*}:result</i> | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1730 | <result> = alloca <type>                      <i>; yields {type*}:result</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1731 | </pre> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1732 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1733 | <p>The '<tt>alloca</tt>' instruction allocates memory on the current | 
|  | 1734 | stack frame of the procedure that is live until the current function | 
|  | 1735 | returns to its caller.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1736 | <h5>Arguments:</h5> | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 1737 | <p>The '<tt>alloca</tt>' instruction allocates <tt>sizeof(<type>)*NumElements</tt> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1738 | bytes of memory on the runtime stack, returning a pointer of the | 
|  | 1739 | appropriate type to the program.  The second form of the instruction is | 
|  | 1740 | a shorter version of the first that defaults to allocating one element.</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1741 | <p>'<tt>type</tt>' may be any sized type.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1742 | <h5>Semantics:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1743 | <p>Memory is allocated, a pointer is returned.  '<tt>alloca</tt>'d | 
|  | 1744 | memory is automatically released when the function returns.  The '<tt>alloca</tt>' | 
|  | 1745 | instruction is commonly used to represent automatic variables that must | 
|  | 1746 | have an address available.  When the function returns (either with the <tt><a | 
|  | 1747 | href="#i_ret">ret</a></tt> or <tt><a href="#i_invoke">invoke</a></tt> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1748 | instructions), the memory is reclaimed.</p> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1749 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1750 | <pre>  %ptr = alloca int                              <i>; yields {int*}:ptr</i> | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1751 | %ptr = alloca int, uint 4                      <i>; yields {int*}:ptr</i> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1752 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1753 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1754 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1755 | <div class="doc_subsubsection"> <a name="i_load">'<tt>load</tt>' | 
|  | 1756 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1757 | <div class="doc_text"> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1758 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1759 | <pre>  <result> = load <ty>* <pointer><br>  <result> = volatile load <ty>* <pointer><br></pre> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1760 | <h5>Overview:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1761 | <p>The '<tt>load</tt>' instruction is used to read from memory.</p> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1762 | <h5>Arguments:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1763 | <p>The argument to the '<tt>load</tt>' instruction specifies the memory | 
|  | 1764 | address to load from.  The pointer must point to a <a | 
| Chris Lattner | e53e508 | 2004-06-03 22:57:15 +0000 | [diff] [blame] | 1765 | href="#t_firstclass">first class</a> type.  If the <tt>load</tt> is | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1766 | marked as <tt>volatile</tt> then the optimizer is not allowed to modify | 
|  | 1767 | the number or order of execution of this <tt>load</tt> with other | 
|  | 1768 | volatile <tt>load</tt> and <tt><a href="#i_store">store</a></tt> | 
|  | 1769 | instructions. </p> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1770 | <h5>Semantics:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1771 | <p>The location of memory pointed to is loaded.</p> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1772 | <h5>Examples:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1773 | <pre>  %ptr = <a href="#i_alloca">alloca</a> int                               <i>; yields {int*}:ptr</i> | 
|  | 1774 | <a | 
|  | 1775 | href="#i_store">store</a> int 3, int* %ptr                          <i>; yields {void}</i> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1776 | %val = load int* %ptr                           <i>; yields {int}:val = int 3</i> | 
|  | 1777 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1778 | </div> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1779 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1780 | <div class="doc_subsubsection"> <a name="i_store">'<tt>store</tt>' | 
|  | 1781 | Instruction</a> </div> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1782 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1783 | <pre>  store <ty> <value>, <ty>* <pointer>                   <i>; yields {void}</i> | 
| Chris Lattner | f065107 | 2003-09-08 18:27:49 +0000 | [diff] [blame] | 1784 | volatile store <ty> <value>, <ty>* <pointer>                   <i>; yields {void}</i> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1785 | </pre> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1786 | <h5>Overview:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1787 | <p>The '<tt>store</tt>' instruction is used to write to memory.</p> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1788 | <h5>Arguments:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1789 | <p>There are two arguments to the '<tt>store</tt>' instruction: a value | 
|  | 1790 | to store and an address to store it into.  The type of the '<tt><pointer></tt>' | 
|  | 1791 | operand must be a pointer to the type of the '<tt><value></tt>' | 
|  | 1792 | operand. If the <tt>store</tt> is marked as <tt>volatile</tt> then the | 
|  | 1793 | optimizer is not allowed to modify the number or order of execution of | 
|  | 1794 | this <tt>store</tt> with other volatile <tt>load</tt> and <tt><a | 
|  | 1795 | href="#i_store">store</a></tt> instructions.</p> | 
|  | 1796 | <h5>Semantics:</h5> | 
|  | 1797 | <p>The contents of memory are updated to contain '<tt><value></tt>' | 
|  | 1798 | at the location specified by the '<tt><pointer></tt>' operand.</p> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1799 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1800 | <pre>  %ptr = <a href="#i_alloca">alloca</a> int                               <i>; yields {int*}:ptr</i> | 
|  | 1801 | <a | 
|  | 1802 | href="#i_store">store</a> int 3, int* %ptr                          <i>; yields {void}</i> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1803 | %val = load int* %ptr                           <i>; yields {int}:val = int 3</i> | 
|  | 1804 | </pre> | 
| Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 1805 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1806 | <div class="doc_subsubsection"> | 
|  | 1807 | <a name="i_getelementptr">'<tt>getelementptr</tt>' Instruction</a> | 
|  | 1808 | </div> | 
|  | 1809 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1810 | <div class="doc_text"> | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1811 | <h5>Syntax:</h5> | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1812 | <pre> | 
|  | 1813 | <result> = getelementptr <ty>* <ptrval>{, <ty> <idx>}* | 
|  | 1814 | </pre> | 
|  | 1815 |  | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1816 | <h5>Overview:</h5> | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1817 |  | 
|  | 1818 | <p> | 
|  | 1819 | The '<tt>getelementptr</tt>' instruction is used to get the address of a | 
|  | 1820 | subelement of an aggregate data structure.</p> | 
|  | 1821 |  | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1822 | <h5>Arguments:</h5> | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1823 |  | 
|  | 1824 | <p>This instruction takes a list of integer constants that indicate what | 
|  | 1825 | elements of the aggregate object to index to.  The actual types of the arguments | 
|  | 1826 | provided depend on the type of the first pointer argument.  The | 
|  | 1827 | '<tt>getelementptr</tt>' instruction is used to index down through the type | 
|  | 1828 | levels of a structure.  When indexing into a structure, only <tt>uint</tt> | 
|  | 1829 | integer constants are allowed.  When indexing into an array or pointer | 
|  | 1830 | <tt>int</tt> and <tt>long</tt> indexes are allowed of any sign.</p> | 
|  | 1831 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1832 | <p>For example, let's consider a C code fragment and how it gets | 
|  | 1833 | compiled to LLVM:</p> | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1834 |  | 
|  | 1835 | <pre> | 
|  | 1836 | struct RT { | 
|  | 1837 | char A; | 
|  | 1838 | int B[10][20]; | 
|  | 1839 | char C; | 
|  | 1840 | }; | 
|  | 1841 | struct ST { | 
|  | 1842 | int X; | 
|  | 1843 | double Y; | 
|  | 1844 | struct RT Z; | 
|  | 1845 | }; | 
|  | 1846 |  | 
|  | 1847 | int *foo(struct ST *s) { | 
|  | 1848 | return &s[1].Z.B[5][13]; | 
|  | 1849 | } | 
|  | 1850 | </pre> | 
|  | 1851 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1852 | <p>The LLVM code generated by the GCC frontend is:</p> | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1853 |  | 
|  | 1854 | <pre> | 
|  | 1855 | %RT = type { sbyte, [10 x [20 x int]], sbyte } | 
|  | 1856 | %ST = type { int, double, %RT } | 
|  | 1857 |  | 
| Brian Gaeke | 7283e7c | 2004-07-02 21:08:14 +0000 | [diff] [blame] | 1858 | implementation | 
|  | 1859 |  | 
|  | 1860 | int* %foo(%ST* %s) { | 
|  | 1861 | entry: | 
|  | 1862 | %reg = getelementptr %ST* %s, int 1, uint 2, uint 1, int 5, int 13 | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1863 | ret int* %reg | 
|  | 1864 | } | 
|  | 1865 | </pre> | 
|  | 1866 |  | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1867 | <h5>Semantics:</h5> | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1868 |  | 
|  | 1869 | <p>The index types specified for the '<tt>getelementptr</tt>' instruction depend | 
| Chris Lattner | e53e508 | 2004-06-03 22:57:15 +0000 | [diff] [blame] | 1870 | on the pointer type that is being index into. <a href="#t_pointer">Pointer</a> | 
|  | 1871 | and <a href="#t_array">array</a> types require <tt>uint</tt>, <tt>int</tt>, | 
|  | 1872 | <tt>ulong</tt>, or <tt>long</tt> values, and <a href="#t_struct">structure</a> | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1873 | types require <tt>uint</tt> <b>constants</b>.</p> | 
|  | 1874 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1875 | <p>In the example above, the first index is indexing into the '<tt>%ST*</tt>' | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1876 | type, which is a pointer, yielding a '<tt>%ST</tt>' = '<tt>{ int, double, %RT | 
|  | 1877 | }</tt>' type, a structure.  The second index indexes into the third element of | 
|  | 1878 | the structure, yielding a '<tt>%RT</tt>' = '<tt>{ sbyte, [10 x [20 x int]], | 
|  | 1879 | sbyte }</tt>' type, another structure.  The third index indexes into the second | 
|  | 1880 | element of the structure, yielding a '<tt>[10 x [20 x int]]</tt>' type, an | 
|  | 1881 | array.  The two dimensions of the array are subscripted into, yielding an | 
|  | 1882 | '<tt>int</tt>' type.  The '<tt>getelementptr</tt>' instruction return a pointer | 
|  | 1883 | to this element, thus computing a value of '<tt>int*</tt>' type.</p> | 
|  | 1884 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1885 | <p>Note that it is perfectly legal to index partially through a | 
|  | 1886 | structure, returning a pointer to an inner element.  Because of this, | 
|  | 1887 | the LLVM code for the given testcase is equivalent to:</p> | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1888 |  | 
|  | 1889 | <pre> | 
| Chris Lattner | d4f6b17 | 2005-03-07 22:13:59 +0000 | [diff] [blame] | 1890 | int* %foo(%ST* %s) { | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1891 | %t1 = getelementptr %ST* %s, int 1                        <i>; yields %ST*:%t1</i> | 
|  | 1892 | %t2 = getelementptr %ST* %t1, int 0, uint 2               <i>; yields %RT*:%t2</i> | 
|  | 1893 | %t3 = getelementptr %RT* %t2, int 0, uint 1               <i>; yields [10 x [20 x int]]*:%t3</i> | 
|  | 1894 | %t4 = getelementptr [10 x [20 x int]]* %t3, int 0, int 5  <i>; yields [20 x int]*:%t4</i> | 
|  | 1895 | %t5 = getelementptr [20 x int]* %t4, int 0, int 13        <i>; yields int*:%t5</i> | 
|  | 1896 | ret int* %t5 | 
|  | 1897 | } | 
| Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 1898 | </pre> | 
| Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1899 | <h5>Example:</h5> | 
| Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 1900 | <pre> | 
|  | 1901 | <i>; yields [12 x ubyte]*:aptr</i> | 
|  | 1902 | %aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, uint 1 | 
|  | 1903 | </pre> | 
|  | 1904 |  | 
|  | 1905 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1906 | <!-- ======================================================================= --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1907 | <div class="doc_subsection"> <a name="otherops">Other Operations</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1908 | <div class="doc_text"> | 
| John Criswell | 4457dc9 | 2004-04-09 16:48:45 +0000 | [diff] [blame] | 1909 | <p>The instructions in this category are the "miscellaneous" | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1910 | instructions, which defy better classification.</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1911 | </div> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1912 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1913 | <div class="doc_subsubsection"> <a name="i_phi">'<tt>phi</tt>' | 
|  | 1914 | Instruction</a> </div> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1915 | <div class="doc_text"> | 
| Chris Lattner | 33ba0d9 | 2001-07-09 00:26:23 +0000 | [diff] [blame] | 1916 | <h5>Syntax:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1917 | <pre>  <result> = phi <ty> [ <val0>, <label0>], ...<br></pre> | 
| Chris Lattner | 33ba0d9 | 2001-07-09 00:26:23 +0000 | [diff] [blame] | 1918 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1919 | <p>The '<tt>phi</tt>' instruction is used to implement the φ node in | 
|  | 1920 | the SSA graph representing the function.</p> | 
| Chris Lattner | 33ba0d9 | 2001-07-09 00:26:23 +0000 | [diff] [blame] | 1921 | <h5>Arguments:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1922 | <p>The type of the incoming values are specified with the first type | 
|  | 1923 | field. After this, the '<tt>phi</tt>' instruction takes a list of pairs | 
|  | 1924 | as arguments, with one pair for each predecessor basic block of the | 
|  | 1925 | current block.  Only values of <a href="#t_firstclass">first class</a> | 
|  | 1926 | type may be used as the value arguments to the PHI node.  Only labels | 
|  | 1927 | may be used as the label arguments.</p> | 
|  | 1928 | <p>There must be no non-phi instructions between the start of a basic | 
|  | 1929 | block and the PHI instructions: i.e. PHI instructions must be first in | 
|  | 1930 | a basic block.</p> | 
| Chris Lattner | 33ba0d9 | 2001-07-09 00:26:23 +0000 | [diff] [blame] | 1931 | <h5>Semantics:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1932 | <p>At runtime, the '<tt>phi</tt>' instruction logically takes on the | 
|  | 1933 | value specified by the parameter, depending on which basic block we | 
|  | 1934 | came from in the last <a href="#terminators">terminator</a> instruction.</p> | 
| Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 1935 | <h5>Example:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1936 | <pre>Loop:       ; Infinite loop that counts from 0 on up...<br>  %indvar = phi uint [ 0, %LoopHeader ], [ %nextindvar, %Loop ]<br>  %nextindvar = add uint %indvar, 1<br>  br label %Loop<br></pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1937 | </div> | 
| Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 1938 |  | 
| Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 1939 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 1940 | <div class="doc_subsubsection"> | 
|  | 1941 | <a name="i_cast">'<tt>cast .. to</tt>' Instruction</a> | 
|  | 1942 | </div> | 
|  | 1943 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1944 | <div class="doc_text"> | 
| Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 1945 |  | 
| Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 1946 | <h5>Syntax:</h5> | 
| Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 1947 |  | 
|  | 1948 | <pre> | 
|  | 1949 | <result> = cast <ty> <value> to <ty2>             <i>; yields ty2</i> | 
| Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 1950 | </pre> | 
| Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 1951 |  | 
| Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 1952 | <h5>Overview:</h5> | 
| Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 1953 |  | 
|  | 1954 | <p> | 
|  | 1955 | The '<tt>cast</tt>' instruction is used as the primitive means to convert | 
|  | 1956 | integers to floating point, change data type sizes, and break type safety (by | 
|  | 1957 | casting pointers). | 
|  | 1958 | </p> | 
|  | 1959 |  | 
|  | 1960 |  | 
| Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 1961 | <h5>Arguments:</h5> | 
| Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 1962 |  | 
|  | 1963 | <p> | 
|  | 1964 | The '<tt>cast</tt>' instruction takes a value to cast, which must be a first | 
|  | 1965 | class value, and a type to cast it to, which must also be a <a | 
|  | 1966 | href="#t_firstclass">first class</a> type. | 
|  | 1967 | </p> | 
|  | 1968 |  | 
| Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 1969 | <h5>Semantics:</h5> | 
| Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 1970 |  | 
|  | 1971 | <p> | 
|  | 1972 | This instruction follows the C rules for explicit casts when determining how the | 
|  | 1973 | data being cast must change to fit in its new container. | 
|  | 1974 | </p> | 
|  | 1975 |  | 
|  | 1976 | <p> | 
|  | 1977 | When casting to bool, any value that would be considered true in the context of | 
|  | 1978 | a C '<tt>if</tt>' condition is converted to the boolean '<tt>true</tt>' values, | 
|  | 1979 | all else are '<tt>false</tt>'. | 
|  | 1980 | </p> | 
|  | 1981 |  | 
|  | 1982 | <p> | 
|  | 1983 | When extending an integral value from a type of one signness to another (for | 
|  | 1984 | example '<tt>sbyte</tt>' to '<tt>ulong</tt>'), the value is sign-extended if the | 
|  | 1985 | <b>source</b> value is signed, and zero-extended if the source value is | 
|  | 1986 | unsigned. <tt>bool</tt> values are always zero extended into either zero or | 
|  | 1987 | one. | 
|  | 1988 | </p> | 
|  | 1989 |  | 
| Chris Lattner | 33ba0d9 | 2001-07-09 00:26:23 +0000 | [diff] [blame] | 1990 | <h5>Example:</h5> | 
| Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 1991 |  | 
|  | 1992 | <pre> | 
|  | 1993 | %X = cast int 257 to ubyte              <i>; yields ubyte:1</i> | 
| Chris Lattner | 7bae395 | 2002-06-25 18:03:17 +0000 | [diff] [blame] | 1994 | %Y = cast int 123 to bool               <i>; yields bool:true</i> | 
| Chris Lattner | 33ba0d9 | 2001-07-09 00:26:23 +0000 | [diff] [blame] | 1995 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1996 | </div> | 
| Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 1997 |  | 
|  | 1998 | <!-- _______________________________________________________________________ --> | 
|  | 1999 | <div class="doc_subsubsection"> | 
|  | 2000 | <a name="i_select">'<tt>select</tt>' Instruction</a> | 
|  | 2001 | </div> | 
|  | 2002 |  | 
|  | 2003 | <div class="doc_text"> | 
|  | 2004 |  | 
|  | 2005 | <h5>Syntax:</h5> | 
|  | 2006 |  | 
|  | 2007 | <pre> | 
|  | 2008 | <result> = select bool <cond>, <ty> <val1>, <ty> <val2>             <i>; yields ty</i> | 
|  | 2009 | </pre> | 
|  | 2010 |  | 
|  | 2011 | <h5>Overview:</h5> | 
|  | 2012 |  | 
|  | 2013 | <p> | 
|  | 2014 | The '<tt>select</tt>' instruction is used to choose one value based on a | 
|  | 2015 | condition, without branching. | 
|  | 2016 | </p> | 
|  | 2017 |  | 
|  | 2018 |  | 
|  | 2019 | <h5>Arguments:</h5> | 
|  | 2020 |  | 
|  | 2021 | <p> | 
|  | 2022 | The '<tt>select</tt>' instruction requires a boolean value indicating the condition, and two values of the same <a href="#t_firstclass">first class</a> type. | 
|  | 2023 | </p> | 
|  | 2024 |  | 
|  | 2025 | <h5>Semantics:</h5> | 
|  | 2026 |  | 
|  | 2027 | <p> | 
|  | 2028 | If the boolean condition evaluates to true, the instruction returns the first | 
|  | 2029 | value argument, otherwise it returns the second value argument. | 
|  | 2030 | </p> | 
|  | 2031 |  | 
|  | 2032 | <h5>Example:</h5> | 
|  | 2033 |  | 
|  | 2034 | <pre> | 
|  | 2035 | %X = select bool true, ubyte 17, ubyte 42          <i>; yields ubyte:17</i> | 
|  | 2036 | </pre> | 
|  | 2037 | </div> | 
|  | 2038 |  | 
|  | 2039 |  | 
|  | 2040 |  | 
|  | 2041 |  | 
|  | 2042 |  | 
| Chris Lattner | 33ba0d9 | 2001-07-09 00:26:23 +0000 | [diff] [blame] | 2043 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2044 | <div class="doc_subsubsection"> | 
|  | 2045 | <a name="i_call">'<tt>call</tt>' Instruction</a> | 
|  | 2046 | </div> | 
|  | 2047 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2048 | <div class="doc_text"> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2049 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2050 | <h5>Syntax:</h5> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2051 | <pre> | 
|  | 2052 | <result> = [tail] call <ty>* <fnptrval>(<param list>) | 
|  | 2053 | </pre> | 
|  | 2054 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2055 | <h5>Overview:</h5> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2056 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2057 | <p>The '<tt>call</tt>' instruction represents a simple function call.</p> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2058 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2059 | <h5>Arguments:</h5> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2060 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2061 | <p>This instruction requires several arguments:</p> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2062 |  | 
| Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 2063 | <ol> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2064 | <li> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2065 | <p>The "tail" marker indicates whether the callee function accesses any | 
|  | 2066 | allocas or varargs in the caller.  If the "tail" marker is present, the | 
|  | 2067 | function call is eligible for tail call optimization.  Note that calls may | 
|  | 2068 | be marked "tail" even if they do not occur before a <a | 
|  | 2069 | href="#i_ret"><tt>ret</tt></a> instruction. | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2070 | </li> | 
|  | 2071 | <li> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2072 | <p>'<tt>ty</tt>': shall be the signature of the pointer to function value | 
|  | 2073 | being invoked.  The argument types must match the types implied by this | 
|  | 2074 | signature.</p> | 
|  | 2075 | </li> | 
|  | 2076 | <li> | 
|  | 2077 | <p>'<tt>fnptrval</tt>': An LLVM value containing a pointer to a function to | 
|  | 2078 | be invoked. In most cases, this is a direct function invocation, but | 
|  | 2079 | indirect <tt>call</tt>s are just as possible, calling an arbitrary pointer | 
|  | 2080 | to function values.</p> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2081 | </li> | 
|  | 2082 | <li> | 
|  | 2083 | <p>'<tt>function args</tt>': argument list whose types match the | 
| Reid Spencer | a7e302a | 2005-05-01 22:22:57 +0000 | [diff] [blame] | 2084 | function signature argument types. All arguments must be of | 
|  | 2085 | <a href="#t_firstclass">first class</a> type. If the function signature | 
|  | 2086 | indicates the function accepts a variable number of arguments, the extra | 
|  | 2087 | arguments can be specified.</p> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2088 | </li> | 
| Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 2089 | </ol> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2090 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2091 | <h5>Semantics:</h5> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2092 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2093 | <p>The '<tt>call</tt>' instruction is used to cause control flow to | 
|  | 2094 | transfer to a specified function, with its incoming arguments bound to | 
|  | 2095 | the specified values. Upon a '<tt><a href="#i_ret">ret</a></tt>' | 
|  | 2096 | instruction in the called function, control flow continues with the | 
|  | 2097 | instruction after the function call, and the return value of the | 
|  | 2098 | function is bound to the result argument.  This is a simpler case of | 
|  | 2099 | the <a href="#i_invoke">invoke</a> instruction.</p> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2100 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2101 | <h5>Example:</h5> | 
| Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame^] | 2102 |  | 
|  | 2103 | <pre> | 
|  | 2104 | %retval = call int %test(int %argc) | 
|  | 2105 | call int(sbyte*, ...) *%printf(sbyte* %msg, int 12, sbyte 42); | 
|  | 2106 | %X = tail call int %foo() | 
|  | 2107 | </pre> | 
|  | 2108 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2109 | </div> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2110 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2111 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2112 | <div class="doc_subsubsection"> | 
|  | 2113 | <a name="i_vanext">'<tt>vanext</tt>' Instruction</a> | 
|  | 2114 | </div> | 
|  | 2115 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2116 | <div class="doc_text"> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2117 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2118 | <h5>Syntax:</h5> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2119 |  | 
|  | 2120 | <pre> | 
|  | 2121 | <resultarglist> = vanext <va_list> <arglist>, <argty> | 
|  | 2122 | </pre> | 
|  | 2123 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2124 | <h5>Overview:</h5> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2125 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2126 | <p>The '<tt>vanext</tt>' instruction is used to access arguments passed | 
|  | 2127 | through the "variable argument" area of a function call.  It is used to | 
|  | 2128 | implement the <tt>va_arg</tt> macro in C.</p> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2129 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2130 | <h5>Arguments:</h5> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2131 |  | 
|  | 2132 | <p>This instruction takes a <tt>va_list</tt> value and the type of the | 
|  | 2133 | argument. It returns another <tt>va_list</tt>. The actual type of | 
|  | 2134 | <tt>va_list</tt> may be defined differently for different targets.  Most targets | 
|  | 2135 | use a <tt>va_list</tt> type of <tt>sbyte*</tt> or some other pointer type.</p> | 
|  | 2136 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2137 | <h5>Semantics:</h5> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2138 |  | 
|  | 2139 | <p>The '<tt>vanext</tt>' instruction advances the specified <tt>va_list</tt> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2140 | past an argument of the specified type.  In conjunction with the <a | 
|  | 2141 | href="#i_vaarg"><tt>vaarg</tt></a> instruction, it is used to implement | 
|  | 2142 | the <tt>va_arg</tt> macro available in C.  For more information, see | 
|  | 2143 | the variable argument handling <a href="#int_varargs">Intrinsic | 
|  | 2144 | Functions</a>.</p> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2145 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2146 | <p>It is legal for this instruction to be called in a function which | 
|  | 2147 | does not take a variable number of arguments, for example, the <tt>vfprintf</tt> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2148 | function.</p> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2149 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2150 | <p><tt>vanext</tt> is an LLVM instruction instead of an <a | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2151 | href="#intrinsics">intrinsic function</a> because it takes a type as an | 
|  | 2152 | argument.  The type refers to the current argument in the <tt>va_list</tt>, it | 
|  | 2153 | tells the compiler how far on the stack it needs to advance to find the next | 
|  | 2154 | argument</p> | 
|  | 2155 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2156 | <h5>Example:</h5> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2157 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2158 | <p>See the <a href="#int_varargs">variable argument processing</a> | 
|  | 2159 | section.</p> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2160 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2161 | </div> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2162 |  | 
| Chris Lattner | 8d1a81d | 2003-10-18 05:51:36 +0000 | [diff] [blame] | 2163 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2164 | <div class="doc_subsubsection"> | 
|  | 2165 | <a name="i_vaarg">'<tt>vaarg</tt>' Instruction</a> | 
|  | 2166 | </div> | 
|  | 2167 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2168 | <div class="doc_text"> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2169 |  | 
| Chris Lattner | 8d1a81d | 2003-10-18 05:51:36 +0000 | [diff] [blame] | 2170 | <h5>Syntax:</h5> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2171 |  | 
|  | 2172 | <pre> | 
|  | 2173 | <resultval> = vaarg <va_list> <arglist>, <argty> | 
|  | 2174 | </pre> | 
|  | 2175 |  | 
| Chris Lattner | 8d1a81d | 2003-10-18 05:51:36 +0000 | [diff] [blame] | 2176 | <h5>Overview:</h5> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2177 |  | 
|  | 2178 | <p>The '<tt>vaarg</tt>' instruction is used to access arguments passed through | 
|  | 2179 | the "variable argument" area of a function call.  It is used to implement the | 
|  | 2180 | <tt>va_arg</tt> macro in C.</p> | 
|  | 2181 |  | 
| Chris Lattner | 8d1a81d | 2003-10-18 05:51:36 +0000 | [diff] [blame] | 2182 | <h5>Arguments:</h5> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2183 |  | 
|  | 2184 | <p>This instruction takes a <tt>va_list</tt> value and the type of the | 
|  | 2185 | argument. It returns a value of the specified argument type.  Again, the actual | 
|  | 2186 | type of <tt>va_list</tt> is target specific.</p> | 
|  | 2187 |  | 
| Chris Lattner | 8d1a81d | 2003-10-18 05:51:36 +0000 | [diff] [blame] | 2188 | <h5>Semantics:</h5> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2189 |  | 
|  | 2190 | <p>The '<tt>vaarg</tt>' instruction loads an argument of the specified type from | 
|  | 2191 | the specified <tt>va_list</tt>.  In conjunction with the <a | 
|  | 2192 | href="#i_vanext"><tt>vanext</tt></a> instruction, it is used to implement the | 
|  | 2193 | <tt>va_arg</tt> macro available in C.  For more information, see the variable | 
|  | 2194 | argument handling <a href="#int_varargs">Intrinsic Functions</a>.</p> | 
|  | 2195 |  | 
|  | 2196 | <p>It is legal for this instruction to be called in a function which does not | 
|  | 2197 | take a variable number of arguments, for example, the <tt>vfprintf</tt> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2198 | function.</p> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2199 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2200 | <p><tt>vaarg</tt> is an LLVM instruction instead of an <a | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2201 | href="#intrinsics">intrinsic function</a> because it takes an type as an | 
|  | 2202 | argument.</p> | 
|  | 2203 |  | 
| Chris Lattner | 8d1a81d | 2003-10-18 05:51:36 +0000 | [diff] [blame] | 2204 | <h5>Example:</h5> | 
| Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 2205 |  | 
|  | 2206 | <p>See the <a href="#int_varargs">variable argument processing</a> section.</p> | 
|  | 2207 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2208 | </div> | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2209 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2210 | <!-- *********************************************************************** --> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2211 | <div class="doc_section"> <a name="intrinsics">Intrinsic Functions</a> </div> | 
|  | 2212 | <!-- *********************************************************************** --> | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2213 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2214 | <div class="doc_text"> | 
| Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 2215 |  | 
|  | 2216 | <p>LLVM supports the notion of an "intrinsic function".  These functions have | 
|  | 2217 | well known names and semantics, and are required to follow certain | 
|  | 2218 | restrictions. Overall, these instructions represent an extension mechanism for | 
|  | 2219 | the LLVM language that does not require changing all of the transformations in | 
|  | 2220 | LLVM to add to the language (or the bytecode reader/writer, the parser, | 
|  | 2221 | etc...).</p> | 
|  | 2222 |  | 
|  | 2223 | <p>Intrinsic function names must all start with an "<tt>llvm.</tt>" prefix, this | 
|  | 2224 | prefix is reserved in LLVM for intrinsic names, thus functions may not be named | 
|  | 2225 | this.  Intrinsic functions must always be external functions: you cannot define | 
|  | 2226 | the body of intrinsic functions.  Intrinsic functions may only be used in call | 
|  | 2227 | or invoke instructions: it is illegal to take the address of an intrinsic | 
|  | 2228 | function.  Additionally, because intrinsic functions are part of the LLVM | 
|  | 2229 | language, it is required that they all be documented here if any are added.</p> | 
|  | 2230 |  | 
|  | 2231 |  | 
|  | 2232 | <p> | 
|  | 2233 | Adding an intrinsic to LLVM is straight-forward if it is possible to express the | 
|  | 2234 | concept in LLVM directly (ie, code generator support is not _required_).  To do | 
|  | 2235 | this, extend the default implementation of the IntrinsicLowering class to handle | 
|  | 2236 | the intrinsic.  Code generators use this class to lower intrinsics they do not | 
|  | 2237 | understand to raw LLVM instructions that they do. | 
|  | 2238 | </p> | 
|  | 2239 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2240 | </div> | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2241 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2242 | <!-- ======================================================================= --> | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2243 | <div class="doc_subsection"> | 
|  | 2244 | <a name="int_varargs">Variable Argument Handling Intrinsics</a> | 
|  | 2245 | </div> | 
|  | 2246 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2247 | <div class="doc_text"> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2248 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2249 | <p>Variable argument support is defined in LLVM with the <a | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2250 | href="#i_vanext"><tt>vanext</tt></a> instruction and these three | 
|  | 2251 | intrinsic functions.  These functions are related to the similarly | 
|  | 2252 | named macros defined in the <tt><stdarg.h></tt> header file.</p> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2253 |  | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2254 | <p>All of these functions operate on arguments that use a | 
|  | 2255 | target-specific value type "<tt>va_list</tt>".  The LLVM assembly | 
|  | 2256 | language reference manual does not define what this type is, so all | 
|  | 2257 | transformations should be prepared to handle intrinsics with any type | 
|  | 2258 | used.</p> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2259 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2260 | <p>This example shows how the <a href="#i_vanext"><tt>vanext</tt></a> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2261 | instruction and the variable argument handling intrinsic functions are | 
|  | 2262 | used.</p> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2263 |  | 
| Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 2264 | <pre> | 
|  | 2265 | int %test(int %X, ...) { | 
|  | 2266 | ; Initialize variable argument processing | 
|  | 2267 | %ap = call sbyte* %<a href="#i_va_start">llvm.va_start</a>() | 
|  | 2268 |  | 
|  | 2269 | ; Read a single integer argument | 
|  | 2270 | %tmp = vaarg sbyte* %ap, int | 
|  | 2271 |  | 
|  | 2272 | ; Advance to the next argument | 
|  | 2273 | %ap2 = vanext sbyte* %ap, int | 
|  | 2274 |  | 
|  | 2275 | ; Demonstrate usage of llvm.va_copy and llvm.va_end | 
|  | 2276 | %aq = call sbyte* %<a href="#i_va_copy">llvm.va_copy</a>(sbyte* %ap2) | 
|  | 2277 | call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %aq) | 
|  | 2278 |  | 
|  | 2279 | ; Stop processing of arguments. | 
|  | 2280 | call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %ap2) | 
|  | 2281 | ret int %tmp | 
|  | 2282 | } | 
|  | 2283 | </pre> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2284 | </div> | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2285 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2286 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2287 | <div class="doc_subsubsection"> | 
|  | 2288 | <a name="i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a> | 
|  | 2289 | </div> | 
|  | 2290 |  | 
|  | 2291 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2292 | <div class="doc_text"> | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2293 | <h5>Syntax:</h5> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2294 | <pre>  declare <va_list> %llvm.va_start()<br></pre> | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2295 | <h5>Overview:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2296 | <p>The '<tt>llvm.va_start</tt>' intrinsic returns a new <tt><arglist></tt> | 
|  | 2297 | for subsequent use by the variable argument intrinsics.</p> | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2298 | <h5>Semantics:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2299 | <p>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2300 | macro available in C.  In a target-dependent way, it initializes and | 
|  | 2301 | returns a <tt>va_list</tt> element, so that the next <tt>vaarg</tt> | 
|  | 2302 | will produce the first variable argument passed to the function.  Unlike | 
|  | 2303 | the C <tt>va_start</tt> macro, this intrinsic does not need to know the | 
|  | 2304 | last argument of the function, the compiler can figure that out.</p> | 
|  | 2305 | <p>Note that this intrinsic function is only legal to be called from | 
|  | 2306 | within the body of a variable argument function.</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2307 | </div> | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2308 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2309 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2310 | <div class="doc_subsubsection"> | 
|  | 2311 | <a name="i_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a> | 
|  | 2312 | </div> | 
|  | 2313 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2314 | <div class="doc_text"> | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2315 | <h5>Syntax:</h5> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2316 | <pre>  declare void %llvm.va_end(<va_list> <arglist>)<br></pre> | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2317 | <h5>Overview:</h5> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2318 | <p>The '<tt>llvm.va_end</tt>' intrinsic destroys <tt><arglist></tt> | 
|  | 2319 | which has been initialized previously with <tt><a href="#i_va_start">llvm.va_start</a></tt> | 
|  | 2320 | or <tt><a href="#i_va_copy">llvm.va_copy</a></tt>.</p> | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2321 | <h5>Arguments:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2322 | <p>The argument is a <tt>va_list</tt> to destroy.</p> | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2323 | <h5>Semantics:</h5> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2324 | <p>The '<tt>llvm.va_end</tt>' intrinsic works just like the <tt>va_end</tt> | 
| Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2325 | macro available in C.  In a target-dependent way, it destroys the <tt>va_list</tt>. | 
|  | 2326 | Calls to <a href="#i_va_start"><tt>llvm.va_start</tt></a> and <a | 
|  | 2327 | href="#i_va_copy"><tt>llvm.va_copy</tt></a> must be matched exactly | 
|  | 2328 | with calls to <tt>llvm.va_end</tt>.</p> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2329 | </div> | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2330 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2331 | <!-- _______________________________________________________________________ --> | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2332 | <div class="doc_subsubsection"> | 
|  | 2333 | <a name="i_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a> | 
|  | 2334 | </div> | 
|  | 2335 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2336 | <div class="doc_text"> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2337 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2338 | <h5>Syntax:</h5> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2339 |  | 
|  | 2340 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2341 | declare <va_list> %llvm.va_copy(<va_list> <destarglist>) | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2342 | </pre> | 
|  | 2343 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2344 | <h5>Overview:</h5> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2345 |  | 
|  | 2346 | <p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position | 
|  | 2347 | from the source argument list to the destination argument list.</p> | 
|  | 2348 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2349 | <h5>Arguments:</h5> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2350 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2351 | <p>The argument is the <tt>va_list</tt> to copy.</p> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2352 |  | 
| Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 2353 | <h5>Semantics:</h5> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2354 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2355 | <p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2356 | macro available in C.  In a target-dependent way, it copies the source | 
|  | 2357 | <tt>va_list</tt> element into the returned list.  This intrinsic is necessary | 
| Chris Lattner | fcd3725 | 2004-06-21 22:52:48 +0000 | [diff] [blame] | 2358 | because the <tt><a href="#i_va_start">llvm.va_start</a></tt> intrinsic may be | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2359 | arbitrarily complex and require memory allocation, for example.</p> | 
|  | 2360 |  | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2361 | </div> | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2362 |  | 
| Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 2363 | <!-- ======================================================================= --> | 
|  | 2364 | <div class="doc_subsection"> | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2365 | <a name="int_gc">Accurate Garbage Collection Intrinsics</a> | 
|  | 2366 | </div> | 
|  | 2367 |  | 
|  | 2368 | <div class="doc_text"> | 
|  | 2369 |  | 
|  | 2370 | <p> | 
|  | 2371 | LLVM support for <a href="GarbageCollection.html">Accurate Garbage | 
|  | 2372 | Collection</a> requires the implementation and generation of these intrinsics. | 
|  | 2373 | These intrinsics allow identification of <a href="#i_gcroot">GC roots on the | 
|  | 2374 | stack</a>, as well as garbage collector implementations that require <a | 
|  | 2375 | href="#i_gcread">read</a> and <a href="#i_gcwrite">write</a> barriers. | 
|  | 2376 | Front-ends for type-safe garbage collected languages should generate these | 
|  | 2377 | intrinsics to make use of the LLVM garbage collectors.  For more details, see <a | 
|  | 2378 | href="GarbageCollection.html">Accurate Garbage Collection with LLVM</a>. | 
|  | 2379 | </p> | 
|  | 2380 | </div> | 
|  | 2381 |  | 
|  | 2382 | <!-- _______________________________________________________________________ --> | 
|  | 2383 | <div class="doc_subsubsection"> | 
|  | 2384 | <a name="i_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a> | 
|  | 2385 | </div> | 
|  | 2386 |  | 
|  | 2387 | <div class="doc_text"> | 
|  | 2388 |  | 
|  | 2389 | <h5>Syntax:</h5> | 
|  | 2390 |  | 
|  | 2391 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2392 | declare void %llvm.gcroot(<ty>** %ptrloc, <ty2>* %metadata) | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2393 | </pre> | 
|  | 2394 |  | 
|  | 2395 | <h5>Overview:</h5> | 
|  | 2396 |  | 
| John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 2397 | <p>The '<tt>llvm.gcroot</tt>' intrinsic declares the existence of a GC root to | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2398 | the code generator, and allows some metadata to be associated with it.</p> | 
|  | 2399 |  | 
|  | 2400 | <h5>Arguments:</h5> | 
|  | 2401 |  | 
|  | 2402 | <p>The first argument specifies the address of a stack object that contains the | 
|  | 2403 | root pointer.  The second pointer (which must be either a constant or a global | 
|  | 2404 | value address) contains the meta-data to be associated with the root.</p> | 
|  | 2405 |  | 
|  | 2406 | <h5>Semantics:</h5> | 
|  | 2407 |  | 
|  | 2408 | <p>At runtime, a call to this intrinsics stores a null pointer into the "ptrloc" | 
|  | 2409 | location.  At compile-time, the code generator generates information to allow | 
|  | 2410 | the runtime to find the pointer at GC safe points. | 
|  | 2411 | </p> | 
|  | 2412 |  | 
|  | 2413 | </div> | 
|  | 2414 |  | 
|  | 2415 |  | 
|  | 2416 | <!-- _______________________________________________________________________ --> | 
|  | 2417 | <div class="doc_subsubsection"> | 
|  | 2418 | <a name="i_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a> | 
|  | 2419 | </div> | 
|  | 2420 |  | 
|  | 2421 | <div class="doc_text"> | 
|  | 2422 |  | 
|  | 2423 | <h5>Syntax:</h5> | 
|  | 2424 |  | 
|  | 2425 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2426 | declare sbyte* %llvm.gcread(sbyte** %Ptr) | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2427 | </pre> | 
|  | 2428 |  | 
|  | 2429 | <h5>Overview:</h5> | 
|  | 2430 |  | 
|  | 2431 | <p>The '<tt>llvm.gcread</tt>' intrinsic identifies reads of references from heap | 
|  | 2432 | locations, allowing garbage collector implementations that require read | 
|  | 2433 | barriers.</p> | 
|  | 2434 |  | 
|  | 2435 | <h5>Arguments:</h5> | 
|  | 2436 |  | 
|  | 2437 | <p>The argument is the address to read from, which should be an address | 
|  | 2438 | allocated from the garbage collector.</p> | 
|  | 2439 |  | 
|  | 2440 | <h5>Semantics:</h5> | 
|  | 2441 |  | 
|  | 2442 | <p>The '<tt>llvm.gcread</tt>' intrinsic has the same semantics as a load | 
|  | 2443 | instruction, but may be replaced with substantially more complex code by the | 
|  | 2444 | garbage collector runtime, as needed.</p> | 
|  | 2445 |  | 
|  | 2446 | </div> | 
|  | 2447 |  | 
|  | 2448 |  | 
|  | 2449 | <!-- _______________________________________________________________________ --> | 
|  | 2450 | <div class="doc_subsubsection"> | 
|  | 2451 | <a name="i_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a> | 
|  | 2452 | </div> | 
|  | 2453 |  | 
|  | 2454 | <div class="doc_text"> | 
|  | 2455 |  | 
|  | 2456 | <h5>Syntax:</h5> | 
|  | 2457 |  | 
|  | 2458 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2459 | declare void %llvm.gcwrite(sbyte* %P1, sbyte** %P2) | 
| Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 2460 | </pre> | 
|  | 2461 |  | 
|  | 2462 | <h5>Overview:</h5> | 
|  | 2463 |  | 
|  | 2464 | <p>The '<tt>llvm.gcwrite</tt>' intrinsic identifies writes of references to heap | 
|  | 2465 | locations, allowing garbage collector implementations that require write | 
|  | 2466 | barriers (such as generational or reference counting collectors).</p> | 
|  | 2467 |  | 
|  | 2468 | <h5>Arguments:</h5> | 
|  | 2469 |  | 
|  | 2470 | <p>The first argument is the reference to store, and the second is the heap | 
|  | 2471 | location to store to.</p> | 
|  | 2472 |  | 
|  | 2473 | <h5>Semantics:</h5> | 
|  | 2474 |  | 
|  | 2475 | <p>The '<tt>llvm.gcwrite</tt>' intrinsic has the same semantics as a store | 
|  | 2476 | instruction, but may be replaced with substantially more complex code by the | 
|  | 2477 | garbage collector runtime, as needed.</p> | 
|  | 2478 |  | 
|  | 2479 | </div> | 
|  | 2480 |  | 
|  | 2481 |  | 
|  | 2482 |  | 
|  | 2483 | <!-- ======================================================================= --> | 
|  | 2484 | <div class="doc_subsection"> | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 2485 | <a name="int_codegen">Code Generator Intrinsics</a> | 
|  | 2486 | </div> | 
|  | 2487 |  | 
|  | 2488 | <div class="doc_text"> | 
|  | 2489 | <p> | 
|  | 2490 | These intrinsics are provided by LLVM to expose special features that may only | 
|  | 2491 | be implemented with code generator support. | 
|  | 2492 | </p> | 
|  | 2493 |  | 
|  | 2494 | </div> | 
|  | 2495 |  | 
|  | 2496 | <!-- _______________________________________________________________________ --> | 
|  | 2497 | <div class="doc_subsubsection"> | 
|  | 2498 | <a name="i_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a> | 
|  | 2499 | </div> | 
|  | 2500 |  | 
|  | 2501 | <div class="doc_text"> | 
|  | 2502 |  | 
|  | 2503 | <h5>Syntax:</h5> | 
|  | 2504 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2505 | declare void* %llvm.returnaddress(uint <level>) | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 2506 | </pre> | 
|  | 2507 |  | 
|  | 2508 | <h5>Overview:</h5> | 
|  | 2509 |  | 
|  | 2510 | <p> | 
|  | 2511 | The '<tt>llvm.returnaddress</tt>' intrinsic returns a target-specific value | 
|  | 2512 | indicating the return address of the current function or one of its callers. | 
|  | 2513 | </p> | 
|  | 2514 |  | 
|  | 2515 | <h5>Arguments:</h5> | 
|  | 2516 |  | 
|  | 2517 | <p> | 
|  | 2518 | The argument to this intrinsic indicates which function to return the address | 
|  | 2519 | for.  Zero indicates the calling function, one indicates its caller, etc.  The | 
|  | 2520 | argument is <b>required</b> to be a constant integer value. | 
|  | 2521 | </p> | 
|  | 2522 |  | 
|  | 2523 | <h5>Semantics:</h5> | 
|  | 2524 |  | 
|  | 2525 | <p> | 
|  | 2526 | The '<tt>llvm.returnaddress</tt>' intrinsic either returns a pointer indicating | 
|  | 2527 | the return address of the specified call frame, or zero if it cannot be | 
|  | 2528 | identified.  The value returned by this intrinsic is likely to be incorrect or 0 | 
|  | 2529 | for arguments other than zero, so it should only be used for debugging purposes. | 
|  | 2530 | </p> | 
|  | 2531 |  | 
|  | 2532 | <p> | 
|  | 2533 | Note that calling this intrinsic does not prevent function inlining or other | 
| Chris Lattner | b40bb38 | 2005-03-07 20:30:51 +0000 | [diff] [blame] | 2534 | aggressive transformations, so the value returned may not be that of the obvious | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 2535 | source-language caller. | 
|  | 2536 | </p> | 
|  | 2537 | </div> | 
|  | 2538 |  | 
|  | 2539 |  | 
|  | 2540 | <!-- _______________________________________________________________________ --> | 
|  | 2541 | <div class="doc_subsubsection"> | 
|  | 2542 | <a name="i_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a> | 
|  | 2543 | </div> | 
|  | 2544 |  | 
|  | 2545 | <div class="doc_text"> | 
|  | 2546 |  | 
|  | 2547 | <h5>Syntax:</h5> | 
|  | 2548 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2549 | declare void* %llvm.frameaddress(uint <level>) | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 2550 | </pre> | 
|  | 2551 |  | 
|  | 2552 | <h5>Overview:</h5> | 
|  | 2553 |  | 
|  | 2554 | <p> | 
|  | 2555 | The '<tt>llvm.frameaddress</tt>' intrinsic returns the target-specific frame | 
|  | 2556 | pointer value for the specified stack frame. | 
|  | 2557 | </p> | 
|  | 2558 |  | 
|  | 2559 | <h5>Arguments:</h5> | 
|  | 2560 |  | 
|  | 2561 | <p> | 
|  | 2562 | The argument to this intrinsic indicates which function to return the frame | 
|  | 2563 | pointer for.  Zero indicates the calling function, one indicates its caller, | 
|  | 2564 | etc.  The argument is <b>required</b> to be a constant integer value. | 
|  | 2565 | </p> | 
|  | 2566 |  | 
|  | 2567 | <h5>Semantics:</h5> | 
|  | 2568 |  | 
|  | 2569 | <p> | 
|  | 2570 | The '<tt>llvm.frameaddress</tt>' intrinsic either returns a pointer indicating | 
|  | 2571 | the frame address of the specified call frame, or zero if it cannot be | 
|  | 2572 | identified.  The value returned by this intrinsic is likely to be incorrect or 0 | 
|  | 2573 | for arguments other than zero, so it should only be used for debugging purposes. | 
|  | 2574 | </p> | 
|  | 2575 |  | 
|  | 2576 | <p> | 
|  | 2577 | Note that calling this intrinsic does not prevent function inlining or other | 
| Chris Lattner | b40bb38 | 2005-03-07 20:30:51 +0000 | [diff] [blame] | 2578 | aggressive transformations, so the value returned may not be that of the obvious | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 2579 | source-language caller. | 
|  | 2580 | </p> | 
|  | 2581 | </div> | 
|  | 2582 |  | 
| Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 2583 | <!-- _______________________________________________________________________ --> | 
|  | 2584 | <div class="doc_subsubsection"> | 
|  | 2585 | <a name="i_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a> | 
|  | 2586 | </div> | 
|  | 2587 |  | 
|  | 2588 | <div class="doc_text"> | 
|  | 2589 |  | 
|  | 2590 | <h5>Syntax:</h5> | 
|  | 2591 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2592 | declare void %llvm.prefetch(sbyte * <address>, | 
|  | 2593 | uint <rw>, uint <locality>) | 
| Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 2594 | </pre> | 
|  | 2595 |  | 
|  | 2596 | <h5>Overview:</h5> | 
|  | 2597 |  | 
|  | 2598 |  | 
|  | 2599 | <p> | 
|  | 2600 | The '<tt>llvm.prefetch</tt>' intrinsic is a hint to the code generator to insert | 
|  | 2601 | a prefetch instruction if supported, otherwise it is a noop.  Prefetches have no | 
| Chris Lattner | 2a61536 | 2005-02-28 19:47:14 +0000 | [diff] [blame] | 2602 | effect on the behavior of the program, but can change its performance | 
|  | 2603 | characteristics. | 
| Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 2604 | </p> | 
|  | 2605 |  | 
|  | 2606 | <h5>Arguments:</h5> | 
|  | 2607 |  | 
|  | 2608 | <p> | 
|  | 2609 | <tt>address</tt> is the address to be prefetched, <tt>rw</tt> is the specifier | 
|  | 2610 | determining if the fetch should be for a read (0) or write (1), and | 
|  | 2611 | <tt>locality</tt> is a temporal locality specifier ranging from (0) - no | 
| Chris Lattner | aeffb4a | 2005-03-07 20:31:38 +0000 | [diff] [blame] | 2612 | locality, to (3) - extremely local keep in cache.  The <tt>rw</tt> and | 
| Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 2613 | <tt>locality</tt> arguments must be constant integers. | 
|  | 2614 | </p> | 
|  | 2615 |  | 
|  | 2616 | <h5>Semantics:</h5> | 
|  | 2617 |  | 
|  | 2618 | <p> | 
|  | 2619 | This intrinsic does not modify the behavior of the program.  In particular, | 
|  | 2620 | prefetches cannot trap and do not produce a value.  On targets that support this | 
|  | 2621 | intrinsic, the prefetch can provide hints to the processor cache for better | 
|  | 2622 | performance. | 
|  | 2623 | </p> | 
|  | 2624 |  | 
|  | 2625 | </div> | 
|  | 2626 |  | 
| Andrew Lenharth | 7f4ec3b | 2005-03-28 20:05:49 +0000 | [diff] [blame] | 2627 | <!-- _______________________________________________________________________ --> | 
|  | 2628 | <div class="doc_subsubsection"> | 
|  | 2629 | <a name="i_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a> | 
|  | 2630 | </div> | 
|  | 2631 |  | 
|  | 2632 | <div class="doc_text"> | 
|  | 2633 |  | 
|  | 2634 | <h5>Syntax:</h5> | 
|  | 2635 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2636 | declare void %llvm.pcmarker( uint <id> ) | 
| Andrew Lenharth | 7f4ec3b | 2005-03-28 20:05:49 +0000 | [diff] [blame] | 2637 | </pre> | 
|  | 2638 |  | 
|  | 2639 | <h5>Overview:</h5> | 
|  | 2640 |  | 
|  | 2641 |  | 
|  | 2642 | <p> | 
|  | 2643 | The '<tt>llvm.pcmarker</tt>' intrinsic is a method to export a PC in a region of | 
|  | 2644 | code to simulators and other tools.  The method is target specific, but it is | 
|  | 2645 | expected that the marker will use exported symbols to transmit the PC of the marker. | 
|  | 2646 | The marker makes no guaranties that it will remain with any specific instruction | 
|  | 2647 | after optimizations.  It is possible that the presense of a marker will inhibit | 
|  | 2648 | optimizations.  The intended use is to be inserted after optmizations to allow | 
|  | 2649 | corrolations of simulation runs. | 
|  | 2650 | </p> | 
|  | 2651 |  | 
|  | 2652 | <h5>Arguments:</h5> | 
|  | 2653 |  | 
|  | 2654 | <p> | 
|  | 2655 | <tt>id</tt> is a numerical id identifying the marker. | 
|  | 2656 | </p> | 
|  | 2657 |  | 
|  | 2658 | <h5>Semantics:</h5> | 
|  | 2659 |  | 
|  | 2660 | <p> | 
|  | 2661 | This intrinsic does not modify the behavior of the program.  Backends that do not | 
|  | 2662 | support this intrinisic may ignore it. | 
|  | 2663 | </p> | 
|  | 2664 |  | 
|  | 2665 | </div> | 
|  | 2666 |  | 
| Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 2667 |  | 
| John Criswell | 7123e27 | 2004-04-09 16:43:20 +0000 | [diff] [blame] | 2668 | <!-- ======================================================================= --> | 
|  | 2669 | <div class="doc_subsection"> | 
|  | 2670 | <a name="int_os">Operating System Intrinsics</a> | 
|  | 2671 | </div> | 
|  | 2672 |  | 
|  | 2673 | <div class="doc_text"> | 
|  | 2674 | <p> | 
|  | 2675 | These intrinsics are provided by LLVM to support the implementation of | 
|  | 2676 | operating system level code. | 
|  | 2677 | </p> | 
|  | 2678 |  | 
|  | 2679 | </div> | 
| John Criswell | 183402a | 2004-04-12 15:02:16 +0000 | [diff] [blame] | 2680 |  | 
| John Criswell | cfd3bac | 2004-04-09 15:23:37 +0000 | [diff] [blame] | 2681 | <!-- _______________________________________________________________________ --> | 
|  | 2682 | <div class="doc_subsubsection"> | 
|  | 2683 | <a name="i_readport">'<tt>llvm.readport</tt>' Intrinsic</a> | 
|  | 2684 | </div> | 
|  | 2685 |  | 
|  | 2686 | <div class="doc_text"> | 
|  | 2687 |  | 
|  | 2688 | <h5>Syntax:</h5> | 
|  | 2689 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2690 | declare <integer type> %llvm.readport (<integer type> <address>) | 
| John Criswell | cfd3bac | 2004-04-09 15:23:37 +0000 | [diff] [blame] | 2691 | </pre> | 
|  | 2692 |  | 
|  | 2693 | <h5>Overview:</h5> | 
|  | 2694 |  | 
|  | 2695 | <p> | 
| John Criswell | 7123e27 | 2004-04-09 16:43:20 +0000 | [diff] [blame] | 2696 | The '<tt>llvm.readport</tt>' intrinsic reads data from the specified hardware | 
|  | 2697 | I/O port. | 
| John Criswell | cfd3bac | 2004-04-09 15:23:37 +0000 | [diff] [blame] | 2698 | </p> | 
|  | 2699 |  | 
|  | 2700 | <h5>Arguments:</h5> | 
|  | 2701 |  | 
|  | 2702 | <p> | 
| John Criswell | 7123e27 | 2004-04-09 16:43:20 +0000 | [diff] [blame] | 2703 | The argument to this intrinsic indicates the hardware I/O address from which | 
|  | 2704 | to read the data.  The address is in the hardware I/O address namespace (as | 
|  | 2705 | opposed to being a memory location for memory mapped I/O). | 
| John Criswell | cfd3bac | 2004-04-09 15:23:37 +0000 | [diff] [blame] | 2706 | </p> | 
|  | 2707 |  | 
|  | 2708 | <h5>Semantics:</h5> | 
|  | 2709 |  | 
|  | 2710 | <p> | 
| John Criswell | 7123e27 | 2004-04-09 16:43:20 +0000 | [diff] [blame] | 2711 | The '<tt>llvm.readport</tt>' intrinsic reads data from the hardware I/O port | 
|  | 2712 | specified by <i>address</i> and returns the value.  The address and return | 
|  | 2713 | value must be integers, but the size is dependent upon the platform upon which | 
|  | 2714 | the program is code generated.  For example, on x86, the address must be an | 
| Misha Brukman | cfa87bc | 2005-04-22 18:02:52 +0000 | [diff] [blame] | 2715 | unsigned 16-bit value, and the return value must be 8, 16, or 32 bits. | 
| John Criswell | cfd3bac | 2004-04-09 15:23:37 +0000 | [diff] [blame] | 2716 | </p> | 
|  | 2717 |  | 
|  | 2718 | </div> | 
|  | 2719 |  | 
|  | 2720 | <!-- _______________________________________________________________________ --> | 
|  | 2721 | <div class="doc_subsubsection"> | 
|  | 2722 | <a name="i_writeport">'<tt>llvm.writeport</tt>' Intrinsic</a> | 
|  | 2723 | </div> | 
|  | 2724 |  | 
|  | 2725 | <div class="doc_text"> | 
|  | 2726 |  | 
|  | 2727 | <h5>Syntax:</h5> | 
|  | 2728 | <pre> | 
| Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2729 | call void (<integer type>, <integer type>)* | 
|  | 2730 | %llvm.writeport (<integer type> <value>, | 
|  | 2731 | <integer type> <address>) | 
| John Criswell | cfd3bac | 2004-04-09 15:23:37 +0000 | [diff] [blame] | 2732 | </pre> | 
|  | 2733 |  | 
|  | 2734 | <h5>Overview:</h5> | 
|  | 2735 |  | 
|  | 2736 | <p> | 
| John Criswell | 7123e27 | 2004-04-09 16:43:20 +0000 | [diff] [blame] | 2737 | The '<tt>llvm.writeport</tt>' intrinsic writes data to the specified hardware | 
|  | 2738 | I/O port. | 
| John Criswell | cfd3bac | 2004-04-09 15:23:37 +0000 | [diff] [blame] | 2739 | </p> | 
|  | 2740 |  | 
|  | 2741 | <h5>Arguments:</h5> | 
|  | 2742 |  | 
|  | 2743 | <p> | 
| John Criswell | 96db6fc | 2004-04-12 16:33:19 +0000 | [diff] [blame] | 2744 | The first argument is the value to write to the I/O port. | 
| John Criswell | cfd3bac | 2004-04-09 15:23:37 +0000 | [diff] [blame] | 2745 | </p> | 
|  | 2746 |  | 
|  | 2747 | <p> | 
| John Criswell | 96db6fc | 2004-04-12 16:33:19 +0000 | [diff] [blame] | 2748 | The second argument indicates the hardware I/O address to which data should be | 
|  | 2749 | written.  The address is in the hardware I/O address namespace (as opposed to | 
|  | 2750 | being a memory location for memory mapped I/O). | 
| John Criswell | cfd3bac | 2004-04-09 15:23:37 +0000 | [diff] [blame] | 2751 | </p> | 
|  | 2752 |  | 
|  | 2753 | <h5>Semantics:</h5> | 
|  | 2754 |  | 
|  | 2755 | <p> | 
|  | 2756 | The '<tt>llvm.writeport</tt>' intrinsic writes <i>value</i> to the I/O port | 
|  | 2757 | specified by <i>address</i>.  The address and value must be integers, but the | 
|  | 2758 | size is dependent upon the platform upon which the program is code generated. | 
| Misha Brukman | cfa87bc | 2005-04-22 18:02:52 +0000 | [diff] [blame] | 2759 | For example, on x86, the address must be an unsigned 16-bit value, and the | 
| John Criswell | 7123e27 | 2004-04-09 16:43:20 +0000 | [diff] [blame] | 2760 | value written must be 8, 16, or 32 bits in length. | 
| John Criswell | cfd3bac | 2004-04-09 15:23:37 +0000 | [diff] [blame] | 2761 | </p> | 
|  | 2762 |  | 
|  | 2763 | </div> | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 2764 |  | 
| John Criswell | 183402a | 2004-04-12 15:02:16 +0000 | [diff] [blame] | 2765 | <!-- _______________________________________________________________________ --> | 
|  | 2766 | <div class="doc_subsubsection"> | 
|  | 2767 | <a name="i_readio">'<tt>llvm.readio</tt>' Intrinsic</a> | 
|  | 2768 | </div> | 
|  | 2769 |  | 
|  | 2770 | <div class="doc_text"> | 
|  | 2771 |  | 
|  | 2772 | <h5>Syntax:</h5> | 
|  | 2773 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2774 | declare <result> %llvm.readio (<ty> * <pointer>) | 
| John Criswell | 183402a | 2004-04-12 15:02:16 +0000 | [diff] [blame] | 2775 | </pre> | 
|  | 2776 |  | 
|  | 2777 | <h5>Overview:</h5> | 
|  | 2778 |  | 
|  | 2779 | <p> | 
|  | 2780 | The '<tt>llvm.readio</tt>' intrinsic reads data from a memory mapped I/O | 
|  | 2781 | address. | 
|  | 2782 | </p> | 
|  | 2783 |  | 
|  | 2784 | <h5>Arguments:</h5> | 
|  | 2785 |  | 
|  | 2786 | <p> | 
| John Criswell | 96db6fc | 2004-04-12 16:33:19 +0000 | [diff] [blame] | 2787 | The argument to this intrinsic is a pointer indicating the memory address from | 
|  | 2788 | which to read the data.  The data must be a | 
|  | 2789 | <a href="#t_firstclass">first class</a> type. | 
| John Criswell | 183402a | 2004-04-12 15:02:16 +0000 | [diff] [blame] | 2790 | </p> | 
|  | 2791 |  | 
|  | 2792 | <h5>Semantics:</h5> | 
|  | 2793 |  | 
|  | 2794 | <p> | 
|  | 2795 | The '<tt>llvm.readio</tt>' intrinsic reads data from a memory mapped I/O | 
| John Criswell | 96db6fc | 2004-04-12 16:33:19 +0000 | [diff] [blame] | 2796 | location specified by <i>pointer</i> and returns the value.  The argument must | 
|  | 2797 | be a pointer, and the return value must be a | 
|  | 2798 | <a href="#t_firstclass">first class</a> type.  However, certain architectures | 
| Misha Brukman | cfa87bc | 2005-04-22 18:02:52 +0000 | [diff] [blame] | 2799 | may not support I/O on all first class types.  For example, 32-bit processors | 
| John Criswell | 96db6fc | 2004-04-12 16:33:19 +0000 | [diff] [blame] | 2800 | may only support I/O on data types that are 32 bits or less. | 
| John Criswell | 183402a | 2004-04-12 15:02:16 +0000 | [diff] [blame] | 2801 | </p> | 
|  | 2802 |  | 
|  | 2803 | <p> | 
| John Criswell | 96db6fc | 2004-04-12 16:33:19 +0000 | [diff] [blame] | 2804 | This intrinsic enforces an in-order memory model for llvm.readio and | 
|  | 2805 | llvm.writeio calls on machines that use dynamic scheduling.  Dynamically | 
|  | 2806 | scheduled processors may execute loads and stores out of order, re-ordering at | 
|  | 2807 | run time accesses to memory mapped I/O registers.  Using these intrinsics | 
|  | 2808 | ensures that accesses to memory mapped I/O registers occur in program order. | 
| John Criswell | 183402a | 2004-04-12 15:02:16 +0000 | [diff] [blame] | 2809 | </p> | 
|  | 2810 |  | 
|  | 2811 | </div> | 
|  | 2812 |  | 
|  | 2813 | <!-- _______________________________________________________________________ --> | 
|  | 2814 | <div class="doc_subsubsection"> | 
|  | 2815 | <a name="i_writeio">'<tt>llvm.writeio</tt>' Intrinsic</a> | 
|  | 2816 | </div> | 
|  | 2817 |  | 
|  | 2818 | <div class="doc_text"> | 
|  | 2819 |  | 
|  | 2820 | <h5>Syntax:</h5> | 
|  | 2821 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 2822 | declare void %llvm.writeio (<ty1> <value>, <ty2> * <pointer>) | 
| John Criswell | 183402a | 2004-04-12 15:02:16 +0000 | [diff] [blame] | 2823 | </pre> | 
|  | 2824 |  | 
|  | 2825 | <h5>Overview:</h5> | 
|  | 2826 |  | 
|  | 2827 | <p> | 
|  | 2828 | The '<tt>llvm.writeio</tt>' intrinsic writes data to the specified memory | 
|  | 2829 | mapped I/O address. | 
|  | 2830 | </p> | 
|  | 2831 |  | 
|  | 2832 | <h5>Arguments:</h5> | 
|  | 2833 |  | 
|  | 2834 | <p> | 
| John Criswell | 96db6fc | 2004-04-12 16:33:19 +0000 | [diff] [blame] | 2835 | The first argument is the value to write to the memory mapped I/O location. | 
|  | 2836 | The second argument is a pointer indicating the memory address to which the | 
|  | 2837 | data should be written. | 
| John Criswell | 183402a | 2004-04-12 15:02:16 +0000 | [diff] [blame] | 2838 | </p> | 
|  | 2839 |  | 
|  | 2840 | <h5>Semantics:</h5> | 
|  | 2841 |  | 
|  | 2842 | <p> | 
|  | 2843 | The '<tt>llvm.writeio</tt>' intrinsic writes <i>value</i> to the memory mapped | 
| John Criswell | 96db6fc | 2004-04-12 16:33:19 +0000 | [diff] [blame] | 2844 | I/O address specified by <i>pointer</i>.  The value must be a | 
|  | 2845 | <a href="#t_firstclass">first class</a> type.  However, certain architectures | 
| Misha Brukman | cfa87bc | 2005-04-22 18:02:52 +0000 | [diff] [blame] | 2846 | may not support I/O on all first class types.  For example, 32-bit processors | 
| John Criswell | 96db6fc | 2004-04-12 16:33:19 +0000 | [diff] [blame] | 2847 | may only support I/O on data types that are 32 bits or less. | 
| John Criswell | 183402a | 2004-04-12 15:02:16 +0000 | [diff] [blame] | 2848 | </p> | 
|  | 2849 |  | 
|  | 2850 | <p> | 
| John Criswell | 96db6fc | 2004-04-12 16:33:19 +0000 | [diff] [blame] | 2851 | This intrinsic enforces an in-order memory model for llvm.readio and | 
|  | 2852 | llvm.writeio calls on machines that use dynamic scheduling.  Dynamically | 
|  | 2853 | scheduled processors may execute loads and stores out of order, re-ordering at | 
|  | 2854 | run time accesses to memory mapped I/O registers.  Using these intrinsics | 
|  | 2855 | ensures that accesses to memory mapped I/O registers occur in program order. | 
| John Criswell | 183402a | 2004-04-12 15:02:16 +0000 | [diff] [blame] | 2856 | </p> | 
|  | 2857 |  | 
|  | 2858 | </div> | 
|  | 2859 |  | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 2860 | <!-- ======================================================================= --> | 
|  | 2861 | <div class="doc_subsection"> | 
| Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 2862 | <a name="int_libc">Standard C Library Intrinsics</a> | 
|  | 2863 | </div> | 
|  | 2864 |  | 
|  | 2865 | <div class="doc_text"> | 
|  | 2866 | <p> | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 2867 | LLVM provides intrinsics for a few important standard C library functions. | 
|  | 2868 | These intrinsics allow source-language front-ends to pass information about the | 
|  | 2869 | alignment of the pointer arguments to the code generator, providing opportunity | 
|  | 2870 | for more efficient code generation. | 
| Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 2871 | </p> | 
|  | 2872 |  | 
|  | 2873 | </div> | 
|  | 2874 |  | 
|  | 2875 | <!-- _______________________________________________________________________ --> | 
|  | 2876 | <div class="doc_subsubsection"> | 
|  | 2877 | <a name="i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a> | 
|  | 2878 | </div> | 
|  | 2879 |  | 
|  | 2880 | <div class="doc_text"> | 
|  | 2881 |  | 
|  | 2882 | <h5>Syntax:</h5> | 
|  | 2883 | <pre> | 
| Reid Spencer | d462235 | 2005-04-26 20:41:16 +0000 | [diff] [blame] | 2884 | declare void %llvm.memcpy(sbyte* <dest>, sbyte* <src>, | 
|  | 2885 | uint <len>, uint <align>) | 
| Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 2886 | </pre> | 
|  | 2887 |  | 
|  | 2888 | <h5>Overview:</h5> | 
|  | 2889 |  | 
|  | 2890 | <p> | 
|  | 2891 | The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source | 
|  | 2892 | location to the destination location. | 
|  | 2893 | </p> | 
|  | 2894 |  | 
|  | 2895 | <p> | 
|  | 2896 | Note that, unlike the standard libc function, the <tt>llvm.memcpy</tt> intrinsic | 
|  | 2897 | does not return a value, and takes an extra alignment argument. | 
|  | 2898 | </p> | 
|  | 2899 |  | 
|  | 2900 | <h5>Arguments:</h5> | 
|  | 2901 |  | 
|  | 2902 | <p> | 
|  | 2903 | The first argument is a pointer to the destination, the second is a pointer to | 
|  | 2904 | the source.  The third argument is an (arbitrarily sized) integer argument | 
|  | 2905 | specifying the number of bytes to copy, and the fourth argument is the alignment | 
|  | 2906 | of the source and destination locations. | 
|  | 2907 | </p> | 
|  | 2908 |  | 
| Chris Lattner | 3301ced | 2004-02-12 21:18:15 +0000 | [diff] [blame] | 2909 | <p> | 
|  | 2910 | If the call to this intrinisic has an alignment value that is not 0 or 1, then | 
|  | 2911 | the caller guarantees that the size of the copy is a multiple of the alignment | 
|  | 2912 | and that both the source and destination pointers are aligned to that boundary. | 
|  | 2913 | </p> | 
|  | 2914 |  | 
| Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 2915 | <h5>Semantics:</h5> | 
|  | 2916 |  | 
|  | 2917 | <p> | 
|  | 2918 | The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source | 
|  | 2919 | location to the destination location, which are not allowed to overlap.  It | 
|  | 2920 | copies "len" bytes of memory over.  If the argument is known to be aligned to | 
|  | 2921 | some boundary, this can be specified as the fourth argument, otherwise it should | 
|  | 2922 | be set to 0 or 1. | 
|  | 2923 | </p> | 
|  | 2924 | </div> | 
|  | 2925 |  | 
|  | 2926 |  | 
| Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 2927 | <!-- _______________________________________________________________________ --> | 
|  | 2928 | <div class="doc_subsubsection"> | 
|  | 2929 | <a name="i_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a> | 
|  | 2930 | </div> | 
|  | 2931 |  | 
|  | 2932 | <div class="doc_text"> | 
|  | 2933 |  | 
|  | 2934 | <h5>Syntax:</h5> | 
|  | 2935 | <pre> | 
| Reid Spencer | d462235 | 2005-04-26 20:41:16 +0000 | [diff] [blame] | 2936 | declare void %llvm.memmove(sbyte* <dest>, sbyte* <src>, | 
|  | 2937 | uint <len>, uint <align>) | 
| Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 2938 | </pre> | 
|  | 2939 |  | 
|  | 2940 | <h5>Overview:</h5> | 
|  | 2941 |  | 
|  | 2942 | <p> | 
|  | 2943 | The '<tt>llvm.memmove</tt>' intrinsic moves a block of memory from the source | 
|  | 2944 | location to the destination location. It is similar to the '<tt>llvm.memcpy</tt>' | 
|  | 2945 | intrinsic but allows the two memory locations to overlap. | 
|  | 2946 | </p> | 
|  | 2947 |  | 
|  | 2948 | <p> | 
|  | 2949 | Note that, unlike the standard libc function, the <tt>llvm.memmove</tt> intrinsic | 
|  | 2950 | does not return a value, and takes an extra alignment argument. | 
|  | 2951 | </p> | 
|  | 2952 |  | 
|  | 2953 | <h5>Arguments:</h5> | 
|  | 2954 |  | 
|  | 2955 | <p> | 
|  | 2956 | The first argument is a pointer to the destination, the second is a pointer to | 
|  | 2957 | the source.  The third argument is an (arbitrarily sized) integer argument | 
|  | 2958 | specifying the number of bytes to copy, and the fourth argument is the alignment | 
|  | 2959 | of the source and destination locations. | 
|  | 2960 | </p> | 
|  | 2961 |  | 
| Chris Lattner | 3301ced | 2004-02-12 21:18:15 +0000 | [diff] [blame] | 2962 | <p> | 
|  | 2963 | If the call to this intrinisic has an alignment value that is not 0 or 1, then | 
|  | 2964 | the caller guarantees that the size of the copy is a multiple of the alignment | 
|  | 2965 | and that both the source and destination pointers are aligned to that boundary. | 
|  | 2966 | </p> | 
|  | 2967 |  | 
| Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 2968 | <h5>Semantics:</h5> | 
|  | 2969 |  | 
|  | 2970 | <p> | 
|  | 2971 | The '<tt>llvm.memmove</tt>' intrinsic copies a block of memory from the source | 
|  | 2972 | location to the destination location, which may overlap.  It | 
|  | 2973 | copies "len" bytes of memory over.  If the argument is known to be aligned to | 
|  | 2974 | some boundary, this can be specified as the fourth argument, otherwise it should | 
|  | 2975 | be set to 0 or 1. | 
|  | 2976 | </p> | 
|  | 2977 | </div> | 
|  | 2978 |  | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 2979 |  | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 2980 | <!-- _______________________________________________________________________ --> | 
|  | 2981 | <div class="doc_subsubsection"> | 
|  | 2982 | <a name="i_memset">'<tt>llvm.memset</tt>' Intrinsic</a> | 
|  | 2983 | </div> | 
|  | 2984 |  | 
|  | 2985 | <div class="doc_text"> | 
|  | 2986 |  | 
|  | 2987 | <h5>Syntax:</h5> | 
|  | 2988 | <pre> | 
| Reid Spencer | d462235 | 2005-04-26 20:41:16 +0000 | [diff] [blame] | 2989 | declare void %llvm.memset(sbyte* <dest>, ubyte <val>, | 
|  | 2990 | uint <len>, uint <align>) | 
| Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 2991 | </pre> | 
|  | 2992 |  | 
|  | 2993 | <h5>Overview:</h5> | 
|  | 2994 |  | 
|  | 2995 | <p> | 
|  | 2996 | The '<tt>llvm.memset</tt>' intrinsic fills a block of memory with a particular | 
|  | 2997 | byte value. | 
|  | 2998 | </p> | 
|  | 2999 |  | 
|  | 3000 | <p> | 
|  | 3001 | Note that, unlike the standard libc function, the <tt>llvm.memset</tt> intrinsic | 
|  | 3002 | does not return a value, and takes an extra alignment argument. | 
|  | 3003 | </p> | 
|  | 3004 |  | 
|  | 3005 | <h5>Arguments:</h5> | 
|  | 3006 |  | 
|  | 3007 | <p> | 
|  | 3008 | The first argument is a pointer to the destination to fill, the second is the | 
|  | 3009 | byte value to fill it with, the third argument is an (arbitrarily sized) integer | 
|  | 3010 | argument specifying the number of bytes to fill, and the fourth argument is the | 
|  | 3011 | known alignment of destination location. | 
|  | 3012 | </p> | 
|  | 3013 |  | 
|  | 3014 | <p> | 
|  | 3015 | If the call to this intrinisic has an alignment value that is not 0 or 1, then | 
|  | 3016 | the caller guarantees that the size of the copy is a multiple of the alignment | 
|  | 3017 | and that the destination pointer is aligned to that boundary. | 
|  | 3018 | </p> | 
|  | 3019 |  | 
|  | 3020 | <h5>Semantics:</h5> | 
|  | 3021 |  | 
|  | 3022 | <p> | 
|  | 3023 | The '<tt>llvm.memset</tt>' intrinsic fills "len" bytes of memory starting at the | 
|  | 3024 | destination location.  If the argument is known to be aligned to some boundary, | 
|  | 3025 | this can be specified as the fourth argument, otherwise it should be set to 0 or | 
|  | 3026 | 1. | 
|  | 3027 | </p> | 
|  | 3028 | </div> | 
|  | 3029 |  | 
|  | 3030 |  | 
| Chris Lattner | 3200628 | 2004-06-11 02:28:03 +0000 | [diff] [blame] | 3031 | <!-- _______________________________________________________________________ --> | 
|  | 3032 | <div class="doc_subsubsection"> | 
| Alkis Evlogimenos | 26bbe93 | 2004-06-13 01:16:15 +0000 | [diff] [blame] | 3033 | <a name="i_isunordered">'<tt>llvm.isunordered</tt>' Intrinsic</a> | 
|  | 3034 | </div> | 
|  | 3035 |  | 
|  | 3036 | <div class="doc_text"> | 
|  | 3037 |  | 
|  | 3038 | <h5>Syntax:</h5> | 
|  | 3039 | <pre> | 
| Reid Spencer | a8d451e | 2005-04-26 20:50:44 +0000 | [diff] [blame] | 3040 | declare bool %llvm.isunordered(<float or double> Val1, <float or double> Val2) | 
| Alkis Evlogimenos | 26bbe93 | 2004-06-13 01:16:15 +0000 | [diff] [blame] | 3041 | </pre> | 
|  | 3042 |  | 
|  | 3043 | <h5>Overview:</h5> | 
|  | 3044 |  | 
|  | 3045 | <p> | 
|  | 3046 | The '<tt>llvm.isunordered</tt>' intrinsic returns true if either or both of the | 
|  | 3047 | specified floating point values is a NAN. | 
|  | 3048 | </p> | 
|  | 3049 |  | 
|  | 3050 | <h5>Arguments:</h5> | 
|  | 3051 |  | 
|  | 3052 | <p> | 
|  | 3053 | The arguments are floating point numbers of the same type. | 
|  | 3054 | </p> | 
|  | 3055 |  | 
|  | 3056 | <h5>Semantics:</h5> | 
|  | 3057 |  | 
|  | 3058 | <p> | 
|  | 3059 | If either or both of the arguments is a SNAN or QNAN, it returns true, otherwise | 
|  | 3060 | false. | 
|  | 3061 | </p> | 
|  | 3062 | </div> | 
|  | 3063 |  | 
|  | 3064 |  | 
| Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 3065 | <!-- ======================================================================= --> | 
|  | 3066 | <div class="doc_subsection"> | 
|  | 3067 | <a name="int_count">Bit Counting Intrinsics</a> | 
|  | 3068 | </div> | 
|  | 3069 |  | 
|  | 3070 | <div class="doc_text"> | 
|  | 3071 | <p> | 
|  | 3072 | LLVM provides intrinsics for a few important bit counting operations. | 
|  | 3073 | These allow efficient code generation for some algorithms. | 
|  | 3074 | </p> | 
|  | 3075 |  | 
|  | 3076 | </div> | 
|  | 3077 |  | 
|  | 3078 | <!-- _______________________________________________________________________ --> | 
|  | 3079 | <div class="doc_subsubsection"> | 
|  | 3080 | <a name="int_ctpop">'<tt>llvm.ctpop</tt>' Intrinsic</a> | 
|  | 3081 | </div> | 
|  | 3082 |  | 
|  | 3083 | <div class="doc_text"> | 
|  | 3084 |  | 
|  | 3085 | <h5>Syntax:</h5> | 
|  | 3086 | <pre> | 
|  | 3087 | declare int %llvm.ctpop(int <src>) | 
|  | 3088 |  | 
|  | 3089 | </pre> | 
|  | 3090 |  | 
|  | 3091 | <h5>Overview:</h5> | 
|  | 3092 |  | 
|  | 3093 | <p> | 
|  | 3094 | The '<tt>llvm.ctpop</tt>' intrinsic counts the number of ones in a variable. | 
|  | 3095 | </p> | 
|  | 3096 |  | 
|  | 3097 | <h5>Arguments:</h5> | 
|  | 3098 |  | 
|  | 3099 | <p> | 
| Andrew Lenharth | 7ba1ea5 | 2005-05-04 14:58:31 +0000 | [diff] [blame] | 3100 | The only argument is the value to be counted.  The argument may be of any integer type. | 
| Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 3101 | </p> | 
|  | 3102 |  | 
|  | 3103 | <h5>Semantics:</h5> | 
|  | 3104 |  | 
|  | 3105 | <p> | 
|  | 3106 | The '<tt>llvm.ctpop</tt>' intrinsic counts the 1's in a variable. | 
|  | 3107 | </p> | 
|  | 3108 | </div> | 
|  | 3109 |  | 
|  | 3110 | <!-- _______________________________________________________________________ --> | 
|  | 3111 | <div class="doc_subsubsection"> | 
|  | 3112 | <a name="int_cttz">'<tt>llvm.cttz</tt>' Intrinsic</a> | 
|  | 3113 | </div> | 
|  | 3114 |  | 
|  | 3115 | <div class="doc_text"> | 
|  | 3116 |  | 
|  | 3117 | <h5>Syntax:</h5> | 
|  | 3118 | <pre> | 
|  | 3119 | declare int %llvm.cttz(int <src>) | 
|  | 3120 |  | 
|  | 3121 | </pre> | 
|  | 3122 |  | 
|  | 3123 | <h5>Overview:</h5> | 
|  | 3124 |  | 
|  | 3125 | <p> | 
|  | 3126 | The '<tt>llvm.cttz</tt>' intrinsic counts the number of trailing zeros. | 
|  | 3127 | </p> | 
|  | 3128 |  | 
|  | 3129 | <h5>Arguments:</h5> | 
|  | 3130 |  | 
|  | 3131 | <p> | 
| Andrew Lenharth | 7ba1ea5 | 2005-05-04 14:58:31 +0000 | [diff] [blame] | 3132 | The only argument is the value to be counted.  The argument may be of any integer type. | 
| Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 3133 | </p> | 
|  | 3134 |  | 
|  | 3135 | <h5>Semantics:</h5> | 
|  | 3136 |  | 
|  | 3137 | <p> | 
|  | 3138 | The '<tt>llvm.cttz</tt>' intrinsic counts the trailing zeros in a variable.  If the src == 0 | 
|  | 3139 | then the result is the size in bits of the type of src. | 
|  | 3140 | </p> | 
|  | 3141 | </div> | 
|  | 3142 |  | 
|  | 3143 | <!-- _______________________________________________________________________ --> | 
|  | 3144 | <div class="doc_subsubsection"> | 
|  | 3145 | <a name="int_ctlz">'<tt>llvm.ctlz</tt>' Intrinsic</a> | 
|  | 3146 | </div> | 
|  | 3147 |  | 
|  | 3148 | <div class="doc_text"> | 
|  | 3149 |  | 
|  | 3150 | <h5>Syntax:</h5> | 
|  | 3151 | <pre> | 
|  | 3152 | declare int %llvm.ctlz(int <src>) | 
|  | 3153 |  | 
|  | 3154 | </pre> | 
|  | 3155 |  | 
|  | 3156 | <h5>Overview:</h5> | 
|  | 3157 |  | 
|  | 3158 | <p> | 
|  | 3159 | The '<tt>llvm.ctlz</tt>' intrinsic counts the number of leading zeros in a variable. | 
|  | 3160 | </p> | 
|  | 3161 |  | 
|  | 3162 | <h5>Arguments:</h5> | 
|  | 3163 |  | 
|  | 3164 | <p> | 
| Andrew Lenharth | 7ba1ea5 | 2005-05-04 14:58:31 +0000 | [diff] [blame] | 3165 | The only argument is the value to be counted.  The argument may be of any integer type. | 
| Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 3166 | </p> | 
|  | 3167 |  | 
|  | 3168 | <h5>Semantics:</h5> | 
|  | 3169 |  | 
|  | 3170 | <p> | 
|  | 3171 | The '<tt>llvm.ctlz</tt>' intrinsic counts the leading zeros in a variable.  If the src == 0 | 
|  | 3172 | then the result is the size in bits of the type of src. | 
|  | 3173 | </p> | 
|  | 3174 | </div> | 
| Chris Lattner | 3200628 | 2004-06-11 02:28:03 +0000 | [diff] [blame] | 3175 |  | 
|  | 3176 |  | 
| Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 3177 | <!-- ======================================================================= --> | 
|  | 3178 | <div class="doc_subsection"> | 
|  | 3179 | <a name="int_debugger">Debugger Intrinsics</a> | 
|  | 3180 | </div> | 
|  | 3181 |  | 
|  | 3182 | <div class="doc_text"> | 
|  | 3183 | <p> | 
|  | 3184 | The LLVM debugger intrinsics (which all start with <tt>llvm.dbg.</tt> prefix), | 
|  | 3185 | are described in the <a | 
|  | 3186 | href="SourceLevelDebugging.html#format_common_intrinsics">LLVM Source Level | 
|  | 3187 | Debugging</a> document. | 
|  | 3188 | </p> | 
|  | 3189 | </div> | 
|  | 3190 |  | 
|  | 3191 |  | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3192 | <!-- *********************************************************************** --> | 
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3193 | <hr> | 
| Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 3194 | <address> | 
|  | 3195 | <a href="http://jigsaw.w3.org/css-validator/check/referer"><img | 
|  | 3196 | src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a> | 
|  | 3197 | <a href="http://validator.w3.org/check/referer"><img | 
|  | 3198 | src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a> | 
|  | 3199 |  | 
|  | 3200 | <a href="mailto:sabre@nondot.org">Chris Lattner</a><br> | 
|  | 3201 | <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br> | 
|  | 3202 | Last modified: $Date$ | 
|  | 3203 | </address> | 
| Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3204 | </body> | 
|  | 3205 | </html> |