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> |
Bill Wendling | 3d10a5a | 2009-07-20 01:03:30 +0000 | [diff] [blame] | 23 | <li><a href="#linkage">Linkage Types</a> |
| 24 | <ol> |
| 25 | <li><a href="#linkage_private">private</a></li> |
| 26 | <li><a href="#linkage_linker_private">linker_private</a></li> |
| 27 | <li><a href="#linkage_internal">internal</a></li> |
| 28 | <li><a href="#linkage_available_externally">available_externally</a></li> |
| 29 | <li><a href="#linkage_linkonce">linkonce</a></li> |
| 30 | <li><a href="#linkage_common">common</a></li> |
| 31 | <li><a href="#linkage_weak">weak</a></li> |
| 32 | <li><a href="#linkage_appending">appending</a></li> |
| 33 | <li><a href="#linkage_externweak">extern_weak</a></li> |
| 34 | <li><a href="#linkage_linkonce">linkonce_odr</a></li> |
| 35 | <li><a href="#linkage_weak">weak_odr</a></li> |
| 36 | <li><a href="#linkage_external">externally visible</a></li> |
| 37 | <li><a href="#linkage_dllimport">dllimport</a></li> |
| 38 | <li><a href="#linkage_dllexport">dllexport</a></li> |
| 39 | </ol> |
| 40 | </li> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 41 | <li><a href="#callingconv">Calling Conventions</a></li> |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 42 | <li><a href="#namedtypes">Named Types</a></li> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 43 | <li><a href="#globalvars">Global Variables</a></li> |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 44 | <li><a href="#functionstructure">Functions</a></li> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 45 | <li><a href="#aliasstructure">Aliases</a></li> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 46 | <li><a href="#paramattrs">Parameter Attributes</a></li> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 47 | <li><a href="#fnattrs">Function Attributes</a></li> |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 48 | <li><a href="#gc">Garbage Collector Names</a></li> |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 49 | <li><a href="#moduleasm">Module-Level Inline Assembly</a></li> |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 50 | <li><a href="#datalayout">Data Layout</a></li> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 51 | </ol> |
| 52 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 53 | <li><a href="#typesystem">Type System</a> |
| 54 | <ol> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 55 | <li><a href="#t_classifications">Type Classifications</a></li> |
Robert Bocchino | 7b81c75 | 2006-02-17 21:18:08 +0000 | [diff] [blame] | 56 | <li><a href="#t_primitive">Primitive Types</a> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 57 | <ol> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 58 | <li><a href="#t_floating">Floating Point Types</a></li> |
| 59 | <li><a href="#t_void">Void Type</a></li> |
| 60 | <li><a href="#t_label">Label Type</a></li> |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 61 | <li><a href="#t_metadata">Metadata Type</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 62 | </ol> |
| 63 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 64 | <li><a href="#t_derived">Derived Types</a> |
| 65 | <ol> |
Chris Lattner | b9488a6 | 2007-12-18 06:18:21 +0000 | [diff] [blame] | 66 | <li><a href="#t_integer">Integer Type</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 67 | <li><a href="#t_array">Array Type</a></li> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 68 | <li><a href="#t_function">Function Type</a></li> |
| 69 | <li><a href="#t_pointer">Pointer Type</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 70 | <li><a href="#t_struct">Structure Type</a></li> |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 71 | <li><a href="#t_pstruct">Packed Structure Type</a></li> |
Reid Spencer | 485bad1 | 2007-02-15 03:07:05 +0000 | [diff] [blame] | 72 | <li><a href="#t_vector">Vector Type</a></li> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 73 | <li><a href="#t_opaque">Opaque Type</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 74 | </ol> |
| 75 | </li> |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 76 | <li><a href="#t_uprefs">Type Up-references</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 77 | </ol> |
| 78 | </li> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 79 | <li><a href="#constants">Constants</a> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 80 | <ol> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 81 | <li><a href="#simpleconstants">Simple Constants</a></li> |
Chris Lattner | 7088279 | 2009-02-28 18:32:25 +0000 | [diff] [blame] | 82 | <li><a href="#complexconstants">Complex Constants</a></li> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 83 | <li><a href="#globalconstants">Global Variable and Function Addresses</a></li> |
| 84 | <li><a href="#undefvalues">Undefined Values</a></li> |
| 85 | <li><a href="#constantexprs">Constant Expressions</a></li> |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 86 | <li><a href="#metadata">Embedded Metadata</a></li> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 87 | </ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 88 | </li> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 89 | <li><a href="#othervalues">Other Values</a> |
| 90 | <ol> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 91 | <li><a href="#inlineasm">Inline Assembler Expressions</a></li> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 92 | </ol> |
| 93 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 94 | <li><a href="#instref">Instruction Reference</a> |
| 95 | <ol> |
| 96 | <li><a href="#terminators">Terminator Instructions</a> |
| 97 | <ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 98 | <li><a href="#i_ret">'<tt>ret</tt>' Instruction</a></li> |
| 99 | <li><a href="#i_br">'<tt>br</tt>' Instruction</a></li> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 100 | <li><a href="#i_switch">'<tt>switch</tt>' Instruction</a></li> |
| 101 | <li><a href="#i_invoke">'<tt>invoke</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 102 | <li><a href="#i_unwind">'<tt>unwind</tt>' Instruction</a></li> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 103 | <li><a href="#i_unreachable">'<tt>unreachable</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 104 | </ol> |
| 105 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 106 | <li><a href="#binaryops">Binary Operations</a> |
| 107 | <ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 108 | <li><a href="#i_add">'<tt>add</tt>' Instruction</a></li> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 109 | <li><a href="#i_fadd">'<tt>fadd</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 110 | <li><a href="#i_sub">'<tt>sub</tt>' Instruction</a></li> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 111 | <li><a href="#i_fsub">'<tt>fsub</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 112 | <li><a href="#i_mul">'<tt>mul</tt>' Instruction</a></li> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 113 | <li><a href="#i_fmul">'<tt>fmul</tt>' Instruction</a></li> |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 114 | <li><a href="#i_udiv">'<tt>udiv</tt>' Instruction</a></li> |
| 115 | <li><a href="#i_sdiv">'<tt>sdiv</tt>' Instruction</a></li> |
| 116 | <li><a href="#i_fdiv">'<tt>fdiv</tt>' Instruction</a></li> |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 117 | <li><a href="#i_urem">'<tt>urem</tt>' Instruction</a></li> |
| 118 | <li><a href="#i_srem">'<tt>srem</tt>' Instruction</a></li> |
| 119 | <li><a href="#i_frem">'<tt>frem</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 120 | </ol> |
| 121 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 122 | <li><a href="#bitwiseops">Bitwise Binary Operations</a> |
| 123 | <ol> |
Reid Spencer | 8e11bf8 | 2007-02-02 13:57:07 +0000 | [diff] [blame] | 124 | <li><a href="#i_shl">'<tt>shl</tt>' Instruction</a></li> |
| 125 | <li><a href="#i_lshr">'<tt>lshr</tt>' Instruction</a></li> |
| 126 | <li><a href="#i_ashr">'<tt>ashr</tt>' Instruction</a></li> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 127 | <li><a href="#i_and">'<tt>and</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 128 | <li><a href="#i_or">'<tt>or</tt>' Instruction</a></li> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 129 | <li><a href="#i_xor">'<tt>xor</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 130 | </ol> |
| 131 | </li> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 132 | <li><a href="#vectorops">Vector Operations</a> |
| 133 | <ol> |
| 134 | <li><a href="#i_extractelement">'<tt>extractelement</tt>' Instruction</a></li> |
| 135 | <li><a href="#i_insertelement">'<tt>insertelement</tt>' Instruction</a></li> |
| 136 | <li><a href="#i_shufflevector">'<tt>shufflevector</tt>' Instruction</a></li> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 137 | </ol> |
| 138 | </li> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 139 | <li><a href="#aggregateops">Aggregate Operations</a> |
| 140 | <ol> |
| 141 | <li><a href="#i_extractvalue">'<tt>extractvalue</tt>' Instruction</a></li> |
| 142 | <li><a href="#i_insertvalue">'<tt>insertvalue</tt>' Instruction</a></li> |
| 143 | </ol> |
| 144 | </li> |
Chris Lattner | 884a970 | 2006-08-15 00:45:58 +0000 | [diff] [blame] | 145 | <li><a href="#memoryops">Memory Access and Addressing Operations</a> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 146 | <ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 147 | <li><a href="#i_malloc">'<tt>malloc</tt>' Instruction</a></li> |
| 148 | <li><a href="#i_free">'<tt>free</tt>' Instruction</a></li> |
| 149 | <li><a href="#i_alloca">'<tt>alloca</tt>' Instruction</a></li> |
Robert Bocchino | 7b81c75 | 2006-02-17 21:18:08 +0000 | [diff] [blame] | 150 | <li><a href="#i_load">'<tt>load</tt>' Instruction</a></li> |
| 151 | <li><a href="#i_store">'<tt>store</tt>' Instruction</a></li> |
| 152 | <li><a href="#i_getelementptr">'<tt>getelementptr</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 153 | </ol> |
| 154 | </li> |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 155 | <li><a href="#convertops">Conversion Operations</a> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 156 | <ol> |
| 157 | <li><a href="#i_trunc">'<tt>trunc .. to</tt>' Instruction</a></li> |
| 158 | <li><a href="#i_zext">'<tt>zext .. to</tt>' Instruction</a></li> |
| 159 | <li><a href="#i_sext">'<tt>sext .. to</tt>' Instruction</a></li> |
| 160 | <li><a href="#i_fptrunc">'<tt>fptrunc .. to</tt>' Instruction</a></li> |
| 161 | <li><a href="#i_fpext">'<tt>fpext .. to</tt>' Instruction</a></li> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 162 | <li><a href="#i_fptoui">'<tt>fptoui .. to</tt>' Instruction</a></li> |
| 163 | <li><a href="#i_fptosi">'<tt>fptosi .. to</tt>' Instruction</a></li> |
| 164 | <li><a href="#i_uitofp">'<tt>uitofp .. to</tt>' Instruction</a></li> |
| 165 | <li><a href="#i_sitofp">'<tt>sitofp .. to</tt>' Instruction</a></li> |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 166 | <li><a href="#i_ptrtoint">'<tt>ptrtoint .. to</tt>' Instruction</a></li> |
| 167 | <li><a href="#i_inttoptr">'<tt>inttoptr .. to</tt>' Instruction</a></li> |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 168 | <li><a href="#i_bitcast">'<tt>bitcast .. to</tt>' Instruction</a></li> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 169 | </ol> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 170 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 171 | <li><a href="#otherops">Other Operations</a> |
| 172 | <ol> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 173 | <li><a href="#i_icmp">'<tt>icmp</tt>' Instruction</a></li> |
| 174 | <li><a href="#i_fcmp">'<tt>fcmp</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 175 | <li><a href="#i_phi">'<tt>phi</tt>' Instruction</a></li> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 176 | <li><a href="#i_select">'<tt>select</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 177 | <li><a href="#i_call">'<tt>call</tt>' Instruction</a></li> |
Chris Lattner | fb6977d | 2006-01-13 23:26:01 +0000 | [diff] [blame] | 178 | <li><a href="#i_va_arg">'<tt>va_arg</tt>' Instruction</a></li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 179 | </ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 180 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 181 | </ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 182 | </li> |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 183 | <li><a href="#intrinsics">Intrinsic Functions</a> |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 184 | <ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 185 | <li><a href="#int_varargs">Variable Argument Handling Intrinsics</a> |
| 186 | <ol> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 187 | <li><a href="#int_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a></li> |
| 188 | <li><a href="#int_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a></li> |
| 189 | <li><a href="#int_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 190 | </ol> |
| 191 | </li> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 192 | <li><a href="#int_gc">Accurate Garbage Collection Intrinsics</a> |
| 193 | <ol> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 194 | <li><a href="#int_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a></li> |
| 195 | <li><a href="#int_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a></li> |
| 196 | <li><a href="#int_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a></li> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 197 | </ol> |
| 198 | </li> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 199 | <li><a href="#int_codegen">Code Generator Intrinsics</a> |
| 200 | <ol> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 201 | <li><a href="#int_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a></li> |
| 202 | <li><a href="#int_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a></li> |
| 203 | <li><a href="#int_stacksave">'<tt>llvm.stacksave</tt>' Intrinsic</a></li> |
| 204 | <li><a href="#int_stackrestore">'<tt>llvm.stackrestore</tt>' Intrinsic</a></li> |
| 205 | <li><a href="#int_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a></li> |
| 206 | <li><a href="#int_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a></li> |
| 207 | <li><a href="#int_readcyclecounter"><tt>llvm.readcyclecounter</tt>' Intrinsic</a></li> |
John Criswell | 7123e27 | 2004-04-09 16:43:20 +0000 | [diff] [blame] | 208 | </ol> |
| 209 | </li> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 210 | <li><a href="#int_libc">Standard C Library Intrinsics</a> |
| 211 | <ol> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 212 | <li><a href="#int_memcpy">'<tt>llvm.memcpy.*</tt>' Intrinsic</a></li> |
| 213 | <li><a href="#int_memmove">'<tt>llvm.memmove.*</tt>' Intrinsic</a></li> |
| 214 | <li><a href="#int_memset">'<tt>llvm.memset.*</tt>' Intrinsic</a></li> |
| 215 | <li><a href="#int_sqrt">'<tt>llvm.sqrt.*</tt>' Intrinsic</a></li> |
| 216 | <li><a href="#int_powi">'<tt>llvm.powi.*</tt>' Intrinsic</a></li> |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 217 | <li><a href="#int_sin">'<tt>llvm.sin.*</tt>' Intrinsic</a></li> |
| 218 | <li><a href="#int_cos">'<tt>llvm.cos.*</tt>' Intrinsic</a></li> |
| 219 | <li><a href="#int_pow">'<tt>llvm.pow.*</tt>' Intrinsic</a></li> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 220 | </ol> |
| 221 | </li> |
Nate Begeman | 7e36c47 | 2006-01-13 23:26:38 +0000 | [diff] [blame] | 222 | <li><a href="#int_manip">Bit Manipulation Intrinsics</a> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 223 | <ol> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 224 | <li><a href="#int_bswap">'<tt>llvm.bswap.*</tt>' Intrinsics</a></li> |
Chris Lattner | 8a886be | 2006-01-16 22:34:14 +0000 | [diff] [blame] | 225 | <li><a href="#int_ctpop">'<tt>llvm.ctpop.*</tt>' Intrinsic </a></li> |
| 226 | <li><a href="#int_ctlz">'<tt>llvm.ctlz.*</tt>' Intrinsic </a></li> |
| 227 | <li><a href="#int_cttz">'<tt>llvm.cttz.*</tt>' Intrinsic </a></li> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 228 | </ol> |
| 229 | </li> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 230 | <li><a href="#int_overflow">Arithmetic with Overflow Intrinsics</a> |
| 231 | <ol> |
Bill Wendling | da01af7 | 2009-02-08 04:04:40 +0000 | [diff] [blame] | 232 | <li><a href="#int_sadd_overflow">'<tt>llvm.sadd.with.overflow.*</tt> Intrinsics</a></li> |
| 233 | <li><a href="#int_uadd_overflow">'<tt>llvm.uadd.with.overflow.*</tt> Intrinsics</a></li> |
| 234 | <li><a href="#int_ssub_overflow">'<tt>llvm.ssub.with.overflow.*</tt> Intrinsics</a></li> |
| 235 | <li><a href="#int_usub_overflow">'<tt>llvm.usub.with.overflow.*</tt> Intrinsics</a></li> |
| 236 | <li><a href="#int_smul_overflow">'<tt>llvm.smul.with.overflow.*</tt> Intrinsics</a></li> |
Bill Wendling | 41b485c | 2009-02-08 23:00:09 +0000 | [diff] [blame] | 237 | <li><a href="#int_umul_overflow">'<tt>llvm.umul.with.overflow.*</tt> Intrinsics</a></li> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 238 | </ol> |
| 239 | </li> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 240 | <li><a href="#int_debugger">Debugger intrinsics</a></li> |
Jim Laskey | dd4ef1b | 2007-03-14 19:31:19 +0000 | [diff] [blame] | 241 | <li><a href="#int_eh">Exception Handling intrinsics</a></li> |
Duncan Sands | f7331b3 | 2007-09-11 14:10:23 +0000 | [diff] [blame] | 242 | <li><a href="#int_trampoline">Trampoline Intrinsic</a> |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 243 | <ol> |
| 244 | <li><a href="#int_it">'<tt>llvm.init.trampoline</tt>' Intrinsic</a></li> |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 245 | </ol> |
| 246 | </li> |
Bill Wendling | 3c44f5b | 2008-11-18 22:10:53 +0000 | [diff] [blame] | 247 | <li><a href="#int_atomics">Atomic intrinsics</a> |
| 248 | <ol> |
| 249 | <li><a href="#int_memory_barrier"><tt>llvm.memory_barrier</tt></a></li> |
| 250 | <li><a href="#int_atomic_cmp_swap"><tt>llvm.atomic.cmp.swap</tt></a></li> |
| 251 | <li><a href="#int_atomic_swap"><tt>llvm.atomic.swap</tt></a></li> |
| 252 | <li><a href="#int_atomic_load_add"><tt>llvm.atomic.load.add</tt></a></li> |
| 253 | <li><a href="#int_atomic_load_sub"><tt>llvm.atomic.load.sub</tt></a></li> |
| 254 | <li><a href="#int_atomic_load_and"><tt>llvm.atomic.load.and</tt></a></li> |
| 255 | <li><a href="#int_atomic_load_nand"><tt>llvm.atomic.load.nand</tt></a></li> |
| 256 | <li><a href="#int_atomic_load_or"><tt>llvm.atomic.load.or</tt></a></li> |
| 257 | <li><a href="#int_atomic_load_xor"><tt>llvm.atomic.load.xor</tt></a></li> |
| 258 | <li><a href="#int_atomic_load_max"><tt>llvm.atomic.load.max</tt></a></li> |
| 259 | <li><a href="#int_atomic_load_min"><tt>llvm.atomic.load.min</tt></a></li> |
| 260 | <li><a href="#int_atomic_load_umax"><tt>llvm.atomic.load.umax</tt></a></li> |
| 261 | <li><a href="#int_atomic_load_umin"><tt>llvm.atomic.load.umin</tt></a></li> |
| 262 | </ol> |
| 263 | </li> |
Reid Spencer | 2067764 | 2007-07-20 19:59:11 +0000 | [diff] [blame] | 264 | <li><a href="#int_general">General intrinsics</a> |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 265 | <ol> |
Reid Spencer | 2067764 | 2007-07-20 19:59:11 +0000 | [diff] [blame] | 266 | <li><a href="#int_var_annotation"> |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 267 | '<tt>llvm.var.annotation</tt>' Intrinsic</a></li> |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 268 | <li><a href="#int_annotation"> |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 269 | '<tt>llvm.annotation.*</tt>' Intrinsic</a></li> |
Anton Korobeynikov | 4cb8618 | 2008-01-15 22:31:34 +0000 | [diff] [blame] | 270 | <li><a href="#int_trap"> |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 271 | '<tt>llvm.trap</tt>' Intrinsic</a></li> |
| 272 | <li><a href="#int_stackprotector"> |
| 273 | '<tt>llvm.stackprotector</tt>' Intrinsic</a></li> |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 274 | </ol> |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 275 | </li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 276 | </ol> |
| 277 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 278 | </ol> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 279 | |
| 280 | <div class="doc_author"> |
| 281 | <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a> |
| 282 | and <a href="mailto:vadve@cs.uiuc.edu">Vikram Adve</a></p> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 283 | </div> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 284 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 285 | <!-- *********************************************************************** --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 286 | <div class="doc_section"> <a name="abstract">Abstract </a></div> |
| 287 | <!-- *********************************************************************** --> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 288 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 289 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 290 | |
| 291 | <p>This document is a reference manual for the LLVM assembly language. LLVM is |
| 292 | a Static Single Assignment (SSA) based representation that provides type |
| 293 | safety, low-level operations, flexibility, and the capability of representing |
| 294 | 'all' high-level languages cleanly. It is the common code representation |
| 295 | used throughout all phases of the LLVM compilation strategy.</p> |
| 296 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 297 | </div> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 298 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 299 | <!-- *********************************************************************** --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 300 | <div class="doc_section"> <a name="introduction">Introduction</a> </div> |
| 301 | <!-- *********************************************************************** --> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 302 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 303 | <div class="doc_text"> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 304 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 305 | <p>The LLVM code representation is designed to be used in three different forms: |
| 306 | as an in-memory compiler IR, as an on-disk bitcode representation (suitable |
| 307 | for fast loading by a Just-In-Time compiler), and as a human readable |
| 308 | assembly language representation. This allows LLVM to provide a powerful |
| 309 | intermediate representation for efficient compiler transformations and |
| 310 | analysis, while providing a natural means to debug and visualize the |
| 311 | transformations. The three different forms of LLVM are all equivalent. This |
| 312 | document describes the human readable representation and notation.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 313 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 314 | <p>The LLVM representation aims to be light-weight and low-level while being |
| 315 | expressive, typed, and extensible at the same time. It aims to be a |
| 316 | "universal IR" of sorts, by being at a low enough level that high-level ideas |
| 317 | may be cleanly mapped to it (similar to how microprocessors are "universal |
| 318 | IR's", allowing many source languages to be mapped to them). By providing |
| 319 | type information, LLVM can be used as the target of optimizations: for |
| 320 | example, through pointer analysis, it can be proven that a C automatic |
| 321 | variable is never accessed outside of the current function... allowing it to |
| 322 | be promoted to a simple SSA value instead of a memory location.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 323 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 324 | </div> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 325 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 326 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 327 | <div class="doc_subsubsection"> <a name="wellformed">Well-Formedness</a> </div> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 328 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 329 | <div class="doc_text"> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 330 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 331 | <p>It is important to note that this document describes 'well formed' LLVM |
| 332 | assembly language. There is a difference between what the parser accepts and |
| 333 | what is considered 'well formed'. For example, the following instruction is |
| 334 | syntactically okay, but not well formed:</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 335 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 336 | <div class="doc_code"> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 337 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 338 | %x = <a href="#i_add">add</a> i32 1, %x |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 339 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 340 | </div> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 341 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 342 | <p>...because the definition of <tt>%x</tt> does not dominate all of its |
| 343 | uses. The LLVM infrastructure provides a verification pass that may be used |
| 344 | to verify that an LLVM module is well formed. This pass is automatically run |
| 345 | by the parser after parsing input assembly and by the optimizer before it |
| 346 | outputs bitcode. The violations pointed out by the verifier pass indicate |
| 347 | bugs in transformation passes or input to the parser.</p> |
| 348 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 349 | </div> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 350 | |
Chris Lattner | cc68939 | 2007-10-03 17:34:29 +0000 | [diff] [blame] | 351 | <!-- Describe the typesetting conventions here. --> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 352 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 353 | <!-- *********************************************************************** --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 354 | <div class="doc_section"> <a name="identifiers">Identifiers</a> </div> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 355 | <!-- *********************************************************************** --> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 356 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 357 | <div class="doc_text"> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 358 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 359 | <p>LLVM identifiers come in two basic types: global and local. Global |
| 360 | identifiers (functions, global variables) begin with the <tt>'@'</tt> |
| 361 | character. Local identifiers (register names, types) begin with |
| 362 | the <tt>'%'</tt> character. Additionally, there are three different formats |
| 363 | for identifiers, for different purposes:</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 364 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 365 | <ol> |
Reid Spencer | 2c45228 | 2007-08-07 14:34:28 +0000 | [diff] [blame] | 366 | <li>Named values are represented as a string of characters with their prefix. |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 367 | For example, <tt>%foo</tt>, <tt>@DivisionByZero</tt>, |
| 368 | <tt>%a.really.long.identifier</tt>. The actual regular expression used is |
| 369 | '<tt>[%@][a-zA-Z$._][a-zA-Z$._0-9]*</tt>'. Identifiers which require |
| 370 | other characters in their names can be surrounded with quotes. Special |
| 371 | characters may be escaped using <tt>"\xx"</tt> where <tt>xx</tt> is the |
| 372 | ASCII code for the character in hexadecimal. In this way, any character |
| 373 | can be used in a name value, even quotes themselves.</li> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 374 | |
Reid Spencer | 2c45228 | 2007-08-07 14:34:28 +0000 | [diff] [blame] | 375 | <li>Unnamed values are represented as an unsigned numeric value with their |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 376 | prefix. For example, <tt>%12</tt>, <tt>@2</tt>, <tt>%44</tt>.</li> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 377 | |
Reid Spencer | cc16dc3 | 2004-12-09 18:02:53 +0000 | [diff] [blame] | 378 | <li>Constants, which are described in a <a href="#constants">section about |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 379 | constants</a>, below.</li> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 380 | </ol> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 381 | |
Reid Spencer | 2c45228 | 2007-08-07 14:34:28 +0000 | [diff] [blame] | 382 | <p>LLVM requires that values start with a prefix for two reasons: Compilers |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 383 | don't need to worry about name clashes with reserved words, and the set of |
| 384 | reserved words may be expanded in the future without penalty. Additionally, |
| 385 | unnamed identifiers allow a compiler to quickly come up with a temporary |
| 386 | variable without having to avoid symbol table conflicts.</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 387 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 388 | <p>Reserved words in LLVM are very similar to reserved words in other |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 389 | languages. There are keywords for different opcodes |
| 390 | ('<tt><a href="#i_add">add</a></tt>', |
| 391 | '<tt><a href="#i_bitcast">bitcast</a></tt>', |
| 392 | '<tt><a href="#i_ret">ret</a></tt>', etc...), for primitive type names |
| 393 | ('<tt><a href="#t_void">void</a></tt>', |
| 394 | '<tt><a href="#t_primitive">i32</a></tt>', etc...), and others. These |
| 395 | reserved words cannot conflict with variable names, because none of them |
| 396 | start with a prefix character (<tt>'%'</tt> or <tt>'@'</tt>).</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 397 | |
| 398 | <p>Here is an example of LLVM code to multiply the integer variable |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 399 | '<tt>%X</tt>' by 8:</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 400 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 401 | <p>The easy way:</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 402 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 403 | <div class="doc_code"> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 404 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 405 | %result = <a href="#i_mul">mul</a> i32 %X, 8 |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 406 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 407 | </div> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 408 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 409 | <p>After strength reduction:</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 410 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 411 | <div class="doc_code"> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 412 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 413 | %result = <a href="#i_shl">shl</a> i32 %X, i8 3 |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 414 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 415 | </div> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 416 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 417 | <p>And the hard way:</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 418 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 419 | <div class="doc_code"> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 420 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 421 | <a href="#i_add">add</a> i32 %X, %X <i>; yields {i32}:%0</i> |
| 422 | <a href="#i_add">add</a> i32 %0, %0 <i>; yields {i32}:%1</i> |
| 423 | %result = <a href="#i_add">add</a> i32 %1, %1 |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 424 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 425 | </div> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 426 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 427 | <p>This last way of multiplying <tt>%X</tt> by 8 illustrates several important |
| 428 | lexical features of LLVM:</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 429 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 430 | <ol> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 431 | <li>Comments are delimited with a '<tt>;</tt>' and go until the end of |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 432 | line.</li> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 433 | |
| 434 | <li>Unnamed temporaries are created when the result of a computation is not |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 435 | assigned to a named value.</li> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 436 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 437 | <li>Unnamed temporaries are numbered sequentially</li> |
| 438 | </ol> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 439 | |
John Criswell | e4c57cc | 2005-05-12 16:52:32 +0000 | [diff] [blame] | 440 | <p>...and it also shows a convention that we follow in this document. When |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 441 | demonstrating instructions, we will follow an instruction with a comment that |
| 442 | defines the type and name of value produced. Comments are shown in italic |
| 443 | text.</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 444 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 445 | </div> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 446 | |
| 447 | <!-- *********************************************************************** --> |
| 448 | <div class="doc_section"> <a name="highlevel">High Level Structure</a> </div> |
| 449 | <!-- *********************************************************************** --> |
| 450 | |
| 451 | <!-- ======================================================================= --> |
| 452 | <div class="doc_subsection"> <a name="modulestructure">Module Structure</a> |
| 453 | </div> |
| 454 | |
| 455 | <div class="doc_text"> |
| 456 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 457 | <p>LLVM programs are composed of "Module"s, each of which is a translation unit |
| 458 | of the input programs. Each module consists of functions, global variables, |
| 459 | and symbol table entries. Modules may be combined together with the LLVM |
| 460 | linker, which merges function (and global variable) definitions, resolves |
| 461 | forward declarations, and merges symbol table entries. Here is an example of |
| 462 | the "hello world" module:</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 463 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 464 | <div class="doc_code"> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 465 | <pre><i>; Declare the string constant as a global constant...</i> |
Chris Lattner | a89e5f1 | 2007-06-12 17:00:26 +0000 | [diff] [blame] | 466 | <a href="#identifiers">@.LC0</a> = <a href="#linkage_internal">internal</a> <a |
| 467 | href="#globalvars">constant</a> <a href="#t_array">[13 x i8]</a> c"hello world\0A\00" <i>; [13 x i8]*</i> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 468 | |
| 469 | <i>; External declaration of the puts function</i> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 470 | <a href="#functionstructure">declare</a> i32 @puts(i8 *) <i>; i32(i8 *)* </i> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 471 | |
| 472 | <i>; Definition of main function</i> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 473 | define i32 @main() { <i>; i32()* </i> |
Dan Gohman | 2a08c53 | 2009-01-04 23:44:43 +0000 | [diff] [blame] | 474 | <i>; Convert [13 x i8]* to i8 *...</i> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 475 | %cast210 = <a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 476 | href="#i_getelementptr">getelementptr</a> [13 x i8]* @.LC0, i64 0, i64 0 <i>; i8 *</i> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 477 | |
| 478 | <i>; Call puts function to write out the string to stdout...</i> |
| 479 | <a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 480 | href="#i_call">call</a> i32 @puts(i8 * %cast210) <i>; i32</i> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 481 | <a |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 482 | href="#i_ret">ret</a> i32 0<br>}<br> |
| 483 | </pre> |
| 484 | </div> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 485 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 486 | <p>This example is made up of a <a href="#globalvars">global variable</a> named |
| 487 | "<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>" function, and |
| 488 | a <a href="#functionstructure">function definition</a> for |
| 489 | "<tt>main</tt>".</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 490 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 491 | <p>In general, a module is made up of a list of global values, where both |
| 492 | functions and global variables are global values. Global values are |
| 493 | represented by a pointer to a memory location (in this case, a pointer to an |
| 494 | array of char, and a pointer to a function), and have one of the |
| 495 | following <a href="#linkage">linkage types</a>.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 496 | |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 497 | </div> |
| 498 | |
| 499 | <!-- ======================================================================= --> |
| 500 | <div class="doc_subsection"> |
| 501 | <a name="linkage">Linkage Types</a> |
| 502 | </div> |
| 503 | |
| 504 | <div class="doc_text"> |
| 505 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 506 | <p>All Global Variables and Functions have one of the following types of |
| 507 | linkage:</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 508 | |
| 509 | <dl> |
Rafael Espindola | bb46f52 | 2009-01-15 20:18:42 +0000 | [diff] [blame] | 510 | <dt><tt><b><a name="linkage_private">private</a></b></tt>: </dt> |
| 511 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 512 | <dd>Global values with private linkage are only directly accessible by objects |
| 513 | in the current module. In particular, linking code into a module with an |
| 514 | private global value may cause the private to be renamed as necessary to |
| 515 | avoid collisions. Because the symbol is private to the module, all |
| 516 | references can be updated. This doesn't show up in any symbol table in the |
| 517 | object file.</dd> |
Rafael Espindola | bb46f52 | 2009-01-15 20:18:42 +0000 | [diff] [blame] | 518 | |
Bill Wendling | 3d10a5a | 2009-07-20 01:03:30 +0000 | [diff] [blame] | 519 | <dt><tt><b><a name="linkage_linker_private">linker_private</a></b></tt>: </dt> |
| 520 | |
| 521 | <dd>Similar to private, but the symbol is passed through the assembler and |
| 522 | removed by the linker after evaluation.</dd> |
| 523 | |
Dale Johannesen | 2307a7f | 2008-05-23 23:13:41 +0000 | [diff] [blame] | 524 | <dt><tt><b><a name="linkage_internal">internal</a></b></tt>: </dt> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 525 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 526 | <dd>Similar to private, but the value shows as a local symbol |
| 527 | (<tt>STB_LOCAL</tt> in the case of ELF) in the object file. This |
| 528 | corresponds to the notion of the '<tt>static</tt>' keyword in C.</dd> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 529 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 530 | <dt><tt><b><a name="linkage_available_externally">available_externally</a></b></tt>: </dt> |
Chris Lattner | 266c7bb | 2009-04-13 05:44:34 +0000 | [diff] [blame] | 531 | |
| 532 | <dd>Globals with "<tt>available_externally</tt>" linkage are never emitted |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 533 | into the object file corresponding to the LLVM module. They exist to |
| 534 | allow inlining and other optimizations to take place given knowledge of |
| 535 | the definition of the global, which is known to be somewhere outside the |
| 536 | module. Globals with <tt>available_externally</tt> linkage are allowed to |
| 537 | be discarded at will, and are otherwise the same as <tt>linkonce_odr</tt>. |
| 538 | This linkage type is only allowed on definitions, not declarations.</dd> |
Chris Lattner | 266c7bb | 2009-04-13 05:44:34 +0000 | [diff] [blame] | 539 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 540 | <dt><tt><b><a name="linkage_linkonce">linkonce</a></b></tt>: </dt> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 541 | |
Chris Lattner | 4887bd8 | 2007-01-14 06:51:48 +0000 | [diff] [blame] | 542 | <dd>Globals with "<tt>linkonce</tt>" linkage are merged with other globals of |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 543 | the same name when linkage occurs. This is typically used to implement |
| 544 | inline functions, templates, or other code which must be generated in each |
| 545 | translation unit that uses it. Unreferenced <tt>linkonce</tt> globals are |
| 546 | allowed to be discarded.</dd> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 547 | |
Dale Johannesen | 2307a7f | 2008-05-23 23:13:41 +0000 | [diff] [blame] | 548 | <dt><tt><b><a name="linkage_common">common</a></b></tt>: </dt> |
| 549 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 550 | <dd>"<tt>common</tt>" linkage is exactly the same as <tt>linkonce</tt> |
| 551 | linkage, except that unreferenced <tt>common</tt> globals may not be |
| 552 | discarded. This is used for globals that may be emitted in multiple |
| 553 | translation units, but that are not guaranteed to be emitted into every |
| 554 | translation unit that uses them. One example of this is tentative |
| 555 | definitions in C, such as "<tt>int X;</tt>" at global scope.</dd> |
Dale Johannesen | 2307a7f | 2008-05-23 23:13:41 +0000 | [diff] [blame] | 556 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 557 | <dt><tt><b><a name="linkage_weak">weak</a></b></tt>: </dt> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 558 | |
Dale Johannesen | 2307a7f | 2008-05-23 23:13:41 +0000 | [diff] [blame] | 559 | <dd>"<tt>weak</tt>" linkage is the same as <tt>common</tt> linkage, except |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 560 | that some targets may choose to emit different assembly sequences for them |
| 561 | for target-dependent reasons. This is used for globals that are declared |
| 562 | "weak" in C source code.</dd> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 563 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 564 | <dt><tt><b><a name="linkage_appending">appending</a></b></tt>: </dt> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 565 | |
| 566 | <dd>"<tt>appending</tt>" linkage may only be applied to global variables of |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 567 | pointer to array type. When two global variables with appending linkage |
| 568 | are linked together, the two global arrays are appended together. This is |
| 569 | the LLVM, typesafe, equivalent of having the system linker append together |
| 570 | "sections" with identical names when .o files are linked.</dd> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 571 | |
Anton Korobeynikov | 7f70559 | 2007-01-12 19:20:47 +0000 | [diff] [blame] | 572 | <dt><tt><b><a name="linkage_externweak">extern_weak</a></b></tt>: </dt> |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 573 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 574 | <dd>The semantics of this linkage follow the ELF object file model: the symbol |
| 575 | is weak until linked, if not linked, the symbol becomes null instead of |
| 576 | being an undefined reference.</dd> |
Anton Korobeynikov | 7f70559 | 2007-01-12 19:20:47 +0000 | [diff] [blame] | 577 | |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 578 | <dt><tt><b><a name="linkage_linkonce">linkonce_odr</a></b></tt>: </dt> |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 579 | <dt><tt><b><a name="linkage_weak">weak_odr</a></b></tt>: </dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 580 | |
| 581 | <dd>Some languages allow differing globals to be merged, such as two functions |
| 582 | with different semantics. Other languages, such as <tt>C++</tt>, ensure |
| 583 | that only equivalent globals are ever merged (the "one definition rule" - |
| 584 | "ODR"). Such languages can use the <tt>linkonce_odr</tt> |
| 585 | and <tt>weak_odr</tt> linkage types to indicate that the global will only |
| 586 | be merged with equivalent globals. These linkage types are otherwise the |
| 587 | same as their non-<tt>odr</tt> versions.</dd> |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 588 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 589 | <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] | 590 | |
| 591 | <dd>If none of the above identifiers are used, the global is externally |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 592 | visible, meaning that it participates in linkage and can be used to |
| 593 | resolve external symbol references.</dd> |
Reid Spencer | c891084 | 2007-04-11 23:49:50 +0000 | [diff] [blame] | 594 | </dl> |
Anton Korobeynikov | b74ed07 | 2006-09-14 18:23:27 +0000 | [diff] [blame] | 595 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 596 | <p>The next two types of linkage are targeted for Microsoft Windows platform |
| 597 | only. They are designed to support importing (exporting) symbols from (to) |
| 598 | DLLs (Dynamic Link Libraries).</p> |
Anton Korobeynikov | b74ed07 | 2006-09-14 18:23:27 +0000 | [diff] [blame] | 599 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 600 | <dl> |
Anton Korobeynikov | b74ed07 | 2006-09-14 18:23:27 +0000 | [diff] [blame] | 601 | <dt><tt><b><a name="linkage_dllimport">dllimport</a></b></tt>: </dt> |
| 602 | |
| 603 | <dd>"<tt>dllimport</tt>" linkage causes the compiler to reference a function |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 604 | or variable via a global pointer to a pointer that is set up by the DLL |
| 605 | exporting the symbol. On Microsoft Windows targets, the pointer name is |
| 606 | formed by combining <code>__imp_</code> and the function or variable |
| 607 | name.</dd> |
Anton Korobeynikov | b74ed07 | 2006-09-14 18:23:27 +0000 | [diff] [blame] | 608 | |
| 609 | <dt><tt><b><a name="linkage_dllexport">dllexport</a></b></tt>: </dt> |
| 610 | |
| 611 | <dd>"<tt>dllexport</tt>" linkage causes the compiler to provide a global |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 612 | pointer to a pointer in a DLL, so that it can be referenced with the |
| 613 | <tt>dllimport</tt> attribute. On Microsoft Windows targets, the pointer |
| 614 | name is formed by combining <code>__imp_</code> and the function or |
| 615 | variable name.</dd> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 616 | </dl> |
| 617 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 618 | <p>For example, since the "<tt>.LC0</tt>" variable is defined to be internal, if |
| 619 | another module defined a "<tt>.LC0</tt>" variable and was linked with this |
| 620 | one, one of the two would be renamed, preventing a collision. Since |
| 621 | "<tt>main</tt>" and "<tt>puts</tt>" are external (i.e., lacking any linkage |
| 622 | declarations), they are accessible outside of the current module.</p> |
| 623 | |
| 624 | <p>It is illegal for a function <i>declaration</i> to have any linkage type |
| 625 | other than "externally visible", <tt>dllimport</tt> |
| 626 | or <tt>extern_weak</tt>.</p> |
| 627 | |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 628 | <p>Aliases can have only <tt>external</tt>, <tt>internal</tt>, <tt>weak</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 629 | or <tt>weak_odr</tt> linkages.</p> |
| 630 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 631 | </div> |
| 632 | |
| 633 | <!-- ======================================================================= --> |
| 634 | <div class="doc_subsection"> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 635 | <a name="callingconv">Calling Conventions</a> |
| 636 | </div> |
| 637 | |
| 638 | <div class="doc_text"> |
| 639 | |
| 640 | <p>LLVM <a href="#functionstructure">functions</a>, <a href="#i_call">calls</a> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 641 | and <a href="#i_invoke">invokes</a> can all have an optional calling |
| 642 | convention specified for the call. The calling convention of any pair of |
| 643 | dynamic caller/callee must match, or the behavior of the program is |
| 644 | undefined. The following calling conventions are supported by LLVM, and more |
| 645 | may be added in the future:</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 646 | |
| 647 | <dl> |
| 648 | <dt><b>"<tt>ccc</tt>" - The C calling convention</b>:</dt> |
| 649 | |
| 650 | <dd>This calling convention (the default if no other calling convention is |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 651 | specified) matches the target C calling conventions. This calling |
| 652 | convention supports varargs function calls and tolerates some mismatch in |
| 653 | the declared prototype and implemented declaration of the function (as |
| 654 | does normal C).</dd> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 655 | |
| 656 | <dt><b>"<tt>fastcc</tt>" - The fast calling convention</b>:</dt> |
| 657 | |
| 658 | <dd>This calling convention attempts to make calls as fast as possible |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 659 | (e.g. by passing things in registers). This calling convention allows the |
| 660 | target to use whatever tricks it wants to produce fast code for the |
| 661 | target, without having to conform to an externally specified ABI |
| 662 | (Application Binary Interface). Implementations of this convention should |
| 663 | allow arbitrary <a href="CodeGenerator.html#tailcallopt">tail call |
| 664 | optimization</a> to be supported. This calling convention does not |
| 665 | support varargs and requires the prototype of all callees to exactly match |
| 666 | the prototype of the function definition.</dd> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 667 | |
| 668 | <dt><b>"<tt>coldcc</tt>" - The cold calling convention</b>:</dt> |
| 669 | |
| 670 | <dd>This calling convention attempts to make code in the caller as efficient |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 671 | as possible under the assumption that the call is not commonly executed. |
| 672 | As such, these calls often preserve all registers so that the call does |
| 673 | not break any live ranges in the caller side. This calling convention |
| 674 | does not support varargs and requires the prototype of all callees to |
| 675 | exactly match the prototype of the function definition.</dd> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 676 | |
Chris Lattner | cfe6b37 | 2005-05-07 01:46:40 +0000 | [diff] [blame] | 677 | <dt><b>"<tt>cc <<em>n</em>></tt>" - Numbered convention</b>:</dt> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 678 | |
| 679 | <dd>Any calling convention may be specified by number, allowing |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 680 | target-specific calling conventions to be used. Target specific calling |
| 681 | conventions start at 64.</dd> |
Chris Lattner | cfe6b37 | 2005-05-07 01:46:40 +0000 | [diff] [blame] | 682 | </dl> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 683 | |
| 684 | <p>More calling conventions can be added/defined on an as-needed basis, to |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 685 | support Pascal conventions or any other well-known target-independent |
| 686 | convention.</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 687 | |
| 688 | </div> |
| 689 | |
| 690 | <!-- ======================================================================= --> |
| 691 | <div class="doc_subsection"> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 692 | <a name="visibility">Visibility Styles</a> |
| 693 | </div> |
| 694 | |
| 695 | <div class="doc_text"> |
| 696 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 697 | <p>All Global Variables and Functions have one of the following visibility |
| 698 | styles:</p> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 699 | |
| 700 | <dl> |
| 701 | <dt><b>"<tt>default</tt>" - Default style</b>:</dt> |
| 702 | |
Chris Lattner | d3eda89 | 2008-08-05 18:29:16 +0000 | [diff] [blame] | 703 | <dd>On targets that use the ELF object file format, default visibility means |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 704 | that the declaration is visible to other modules and, in shared libraries, |
| 705 | means that the declared entity may be overridden. On Darwin, default |
| 706 | visibility means that the declaration is visible to other modules. Default |
| 707 | visibility corresponds to "external linkage" in the language.</dd> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 708 | |
| 709 | <dt><b>"<tt>hidden</tt>" - Hidden style</b>:</dt> |
| 710 | |
| 711 | <dd>Two declarations of an object with hidden visibility refer to the same |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 712 | object if they are in the same shared object. Usually, hidden visibility |
| 713 | indicates that the symbol will not be placed into the dynamic symbol |
| 714 | table, so no other module (executable or shared library) can reference it |
| 715 | directly.</dd> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 716 | |
Anton Korobeynikov | 6f9896f | 2007-04-29 18:35:00 +0000 | [diff] [blame] | 717 | <dt><b>"<tt>protected</tt>" - Protected style</b>:</dt> |
| 718 | |
| 719 | <dd>On ELF, protected visibility indicates that the symbol will be placed in |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 720 | the dynamic symbol table, but that references within the defining module |
| 721 | will bind to the local symbol. That is, the symbol cannot be overridden by |
| 722 | another module.</dd> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 723 | </dl> |
| 724 | |
| 725 | </div> |
| 726 | |
| 727 | <!-- ======================================================================= --> |
| 728 | <div class="doc_subsection"> |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 729 | <a name="namedtypes">Named Types</a> |
| 730 | </div> |
| 731 | |
| 732 | <div class="doc_text"> |
| 733 | |
| 734 | <p>LLVM IR allows you to specify name aliases for certain types. This can make |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 735 | it easier to read the IR and make the IR more condensed (particularly when |
| 736 | recursive types are involved). An example of a name specification is:</p> |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 737 | |
| 738 | <div class="doc_code"> |
| 739 | <pre> |
| 740 | %mytype = type { %mytype*, i32 } |
| 741 | </pre> |
| 742 | </div> |
| 743 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 744 | <p>You may give a name to any <a href="#typesystem">type</a> except |
| 745 | "<a href="t_void">void</a>". Type name aliases may be used anywhere a type |
| 746 | is expected with the syntax "%mytype".</p> |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 747 | |
| 748 | <p>Note that type names are aliases for the structural type that they indicate, |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 749 | and that you can therefore specify multiple names for the same type. This |
| 750 | often leads to confusing behavior when dumping out a .ll file. Since LLVM IR |
| 751 | uses structural typing, the name is not part of the type. When printing out |
| 752 | LLVM IR, the printer will pick <em>one name</em> to render all types of a |
| 753 | particular shape. This means that if you have code where two different |
| 754 | source types end up having the same LLVM type, that the dumper will sometimes |
| 755 | print the "wrong" or unexpected type. This is an important design point and |
| 756 | isn't going to change.</p> |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 757 | |
| 758 | </div> |
| 759 | |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 760 | <!-- ======================================================================= --> |
| 761 | <div class="doc_subsection"> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 762 | <a name="globalvars">Global Variables</a> |
| 763 | </div> |
| 764 | |
| 765 | <div class="doc_text"> |
| 766 | |
Chris Lattner | 3689a34 | 2005-02-12 19:30:21 +0000 | [diff] [blame] | 767 | <p>Global variables define regions of memory allocated at compilation time |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 768 | instead of run-time. Global variables may optionally be initialized, may |
| 769 | have an explicit section to be placed in, and may have an optional explicit |
| 770 | alignment specified. A variable may be defined as "thread_local", which |
| 771 | means that it will not be shared by threads (each thread will have a |
| 772 | separated copy of the variable). A variable may be defined as a global |
| 773 | "constant," which indicates that the contents of the variable |
| 774 | will <b>never</b> be modified (enabling better optimization, allowing the |
| 775 | global data to be placed in the read-only section of an executable, etc). |
| 776 | Note that variables that need runtime initialization cannot be marked |
| 777 | "constant" as there is a store to the variable.</p> |
Chris Lattner | 3689a34 | 2005-02-12 19:30:21 +0000 | [diff] [blame] | 778 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 779 | <p>LLVM explicitly allows <em>declarations</em> of global variables to be marked |
| 780 | constant, even if the final definition of the global is not. This capability |
| 781 | can be used to enable slightly better optimization of the program, but |
| 782 | requires the language definition to guarantee that optimizations based on the |
| 783 | 'constantness' are valid for the translation units that do not include the |
| 784 | definition.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 785 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 786 | <p>As SSA values, global variables define pointer values that are in scope |
| 787 | (i.e. they dominate) all basic blocks in the program. Global variables |
| 788 | always define a pointer to their "content" type because they describe a |
| 789 | region of memory, and all memory objects in LLVM are accessed through |
| 790 | pointers.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 791 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 792 | <p>A global variable may be declared to reside in a target-specific numbered |
| 793 | address space. For targets that support them, address spaces may affect how |
| 794 | optimizations are performed and/or what target instructions are used to |
| 795 | access the variable. The default address space is zero. The address space |
| 796 | qualifier must precede any other attributes.</p> |
Christopher Lamb | 284d992 | 2007-12-11 09:31:00 +0000 | [diff] [blame] | 797 | |
Chris Lattner | 88f6c46 | 2005-11-12 00:45:07 +0000 | [diff] [blame] | 798 | <p>LLVM allows an explicit section to be specified for globals. If the target |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 799 | supports it, it will emit globals to the section specified.</p> |
Chris Lattner | 88f6c46 | 2005-11-12 00:45:07 +0000 | [diff] [blame] | 800 | |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 801 | <p>An explicit alignment may be specified for a global. If not present, or if |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 802 | the alignment is set to zero, the alignment of the global is set by the |
| 803 | target to whatever it feels convenient. If an explicit alignment is |
| 804 | specified, the global is forced to have at least that much alignment. All |
| 805 | alignments must be a power of 2.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 806 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 807 | <p>For example, the following defines a global in a numbered address space with |
| 808 | an initializer, section, and alignment:</p> |
Chris Lattner | 68027ea | 2007-01-14 00:27:09 +0000 | [diff] [blame] | 809 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 810 | <div class="doc_code"> |
Chris Lattner | 68027ea | 2007-01-14 00:27:09 +0000 | [diff] [blame] | 811 | <pre> |
Dan Gohman | 398873c | 2009-01-11 00:40:00 +0000 | [diff] [blame] | 812 | @G = addrspace(5) constant float 1.0, section "foo", align 4 |
Chris Lattner | 68027ea | 2007-01-14 00:27:09 +0000 | [diff] [blame] | 813 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 814 | </div> |
Chris Lattner | 68027ea | 2007-01-14 00:27:09 +0000 | [diff] [blame] | 815 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 816 | </div> |
| 817 | |
| 818 | |
| 819 | <!-- ======================================================================= --> |
| 820 | <div class="doc_subsection"> |
| 821 | <a name="functionstructure">Functions</a> |
| 822 | </div> |
| 823 | |
| 824 | <div class="doc_text"> |
| 825 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 826 | <p>LLVM function definitions consist of the "<tt>define</tt>" keyord, an |
| 827 | optional <a href="#linkage">linkage type</a>, an optional |
| 828 | <a href="#visibility">visibility style</a>, an optional |
| 829 | <a href="#callingconv">calling convention</a>, a return type, an optional |
| 830 | <a href="#paramattrs">parameter attribute</a> for the return type, a function |
| 831 | name, a (possibly empty) argument list (each with optional |
| 832 | <a href="#paramattrs">parameter attributes</a>), optional |
| 833 | <a href="#fnattrs">function attributes</a>, an optional section, an optional |
| 834 | alignment, an optional <a href="#gc">garbage collector name</a>, an opening |
| 835 | curly brace, a list of basic blocks, and a closing curly brace.</p> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 836 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 837 | <p>LLVM function declarations consist of the "<tt>declare</tt>" keyword, an |
| 838 | optional <a href="#linkage">linkage type</a>, an optional |
| 839 | <a href="#visibility">visibility style</a>, an optional |
| 840 | <a href="#callingconv">calling convention</a>, a return type, an optional |
| 841 | <a href="#paramattrs">parameter attribute</a> for the return type, a function |
| 842 | name, a possibly empty list of arguments, an optional alignment, and an |
| 843 | optional <a href="#gc">garbage collector name</a>.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 844 | |
Chris Lattner | d3eda89 | 2008-08-05 18:29:16 +0000 | [diff] [blame] | 845 | <p>A function definition contains a list of basic blocks, forming the CFG |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 846 | (Control Flow Graph) for the function. Each basic block may optionally start |
| 847 | with a label (giving the basic block a symbol table entry), contains a list |
| 848 | of instructions, and ends with a <a href="#terminators">terminator</a> |
| 849 | instruction (such as a branch or function return).</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 850 | |
Chris Lattner | 4a3c901 | 2007-06-08 16:52:14 +0000 | [diff] [blame] | 851 | <p>The first basic block in a function is special in two ways: it is immediately |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 852 | executed on entrance to the function, and it is not allowed to have |
| 853 | predecessor basic blocks (i.e. there can not be any branches to the entry |
| 854 | block of a function). Because the block can have no predecessors, it also |
| 855 | cannot have any <a href="#i_phi">PHI nodes</a>.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 856 | |
Chris Lattner | 88f6c46 | 2005-11-12 00:45:07 +0000 | [diff] [blame] | 857 | <p>LLVM allows an explicit section to be specified for functions. If the target |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 858 | supports it, it will emit functions to the section specified.</p> |
Chris Lattner | 88f6c46 | 2005-11-12 00:45:07 +0000 | [diff] [blame] | 859 | |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 860 | <p>An explicit alignment may be specified for a function. If not present, or if |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 861 | the alignment is set to zero, the alignment of the function is set by the |
| 862 | target to whatever it feels convenient. If an explicit alignment is |
| 863 | specified, the function is forced to have at least that much alignment. All |
| 864 | alignments must be a power of 2.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 865 | |
Devang Patel | 307e8ab | 2008-10-07 17:48:33 +0000 | [diff] [blame] | 866 | <h5>Syntax:</h5> |
| 867 | |
| 868 | <div class="doc_code"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 869 | <pre> |
Chris Lattner | 50ad45c | 2008-10-13 16:55:18 +0000 | [diff] [blame] | 870 | define [<a href="#linkage">linkage</a>] [<a href="#visibility">visibility</a>] |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 871 | [<a href="#callingconv">cconv</a>] [<a href="#paramattrs">ret attrs</a>] |
| 872 | <ResultType> @<FunctionName> ([argument list]) |
| 873 | [<a href="#fnattrs">fn Attrs</a>] [section "name"] [align N] |
| 874 | [<a href="#gc">gc</a>] { ... } |
| 875 | </pre> |
Devang Patel | 307e8ab | 2008-10-07 17:48:33 +0000 | [diff] [blame] | 876 | </div> |
| 877 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 878 | </div> |
| 879 | |
Anton Korobeynikov | 8b0a8c8 | 2007-04-25 14:27:10 +0000 | [diff] [blame] | 880 | <!-- ======================================================================= --> |
| 881 | <div class="doc_subsection"> |
| 882 | <a name="aliasstructure">Aliases</a> |
| 883 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 884 | |
Anton Korobeynikov | 8b0a8c8 | 2007-04-25 14:27:10 +0000 | [diff] [blame] | 885 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 886 | |
| 887 | <p>Aliases act as "second name" for the aliasee value (which can be either |
| 888 | function, global variable, another alias or bitcast of global value). Aliases |
| 889 | may have an optional <a href="#linkage">linkage type</a>, and an |
| 890 | optional <a href="#visibility">visibility style</a>.</p> |
Anton Korobeynikov | 8b0a8c8 | 2007-04-25 14:27:10 +0000 | [diff] [blame] | 891 | |
| 892 | <h5>Syntax:</h5> |
| 893 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 894 | <div class="doc_code"> |
Bill Wendling | aac388b | 2007-05-29 09:42:13 +0000 | [diff] [blame] | 895 | <pre> |
Duncan Sands | 0b23ac1 | 2008-09-12 20:48:21 +0000 | [diff] [blame] | 896 | @<Name> = alias [Linkage] [Visibility] <AliaseeTy> @<Aliasee> |
Bill Wendling | aac388b | 2007-05-29 09:42:13 +0000 | [diff] [blame] | 897 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 898 | </div> |
Anton Korobeynikov | 8b0a8c8 | 2007-04-25 14:27:10 +0000 | [diff] [blame] | 899 | |
| 900 | </div> |
| 901 | |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 902 | <!-- ======================================================================= --> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 903 | <div class="doc_subsection"><a name="paramattrs">Parameter Attributes</a></div> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 904 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 905 | <div class="doc_text"> |
| 906 | |
| 907 | <p>The return type and each parameter of a function type may have a set of |
| 908 | <i>parameter attributes</i> associated with them. Parameter attributes are |
| 909 | used to communicate additional information about the result or parameters of |
| 910 | a function. Parameter attributes are considered to be part of the function, |
| 911 | not of the function type, so functions with different parameter attributes |
| 912 | can have the same function type.</p> |
| 913 | |
| 914 | <p>Parameter attributes are simple keywords that follow the type specified. If |
| 915 | multiple parameter attributes are needed, they are space separated. For |
| 916 | example:</p> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 917 | |
| 918 | <div class="doc_code"> |
| 919 | <pre> |
Nick Lewycky | b6a7d25 | 2009-02-15 23:06:14 +0000 | [diff] [blame] | 920 | declare i32 @printf(i8* noalias nocapture, ...) |
Chris Lattner | 66d922c | 2008-10-04 18:33:34 +0000 | [diff] [blame] | 921 | declare i32 @atoi(i8 zeroext) |
| 922 | declare signext i8 @returns_signed_char() |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 923 | </pre> |
| 924 | </div> |
| 925 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 926 | <p>Note that any attributes for the function result (<tt>nounwind</tt>, |
| 927 | <tt>readonly</tt>) come immediately after the argument list.</p> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 928 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 929 | <p>Currently, only the following parameter attributes are defined:</p> |
Chris Lattner | 47507de | 2008-01-11 06:20:47 +0000 | [diff] [blame] | 930 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 931 | <dl> |
| 932 | <dt><tt>zeroext</tt></dt> |
Chris Lattner | 47507de | 2008-01-11 06:20:47 +0000 | [diff] [blame] | 933 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 934 | <dd>This indicates to the code generator that the parameter or return value |
| 935 | should be zero-extended to a 32-bit value by the caller (for a parameter) |
| 936 | or the callee (for a return value).</dd> |
Chris Lattner | 47507de | 2008-01-11 06:20:47 +0000 | [diff] [blame] | 937 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 938 | <dt><tt>signext</tt></dt> |
Chris Lattner | 47507de | 2008-01-11 06:20:47 +0000 | [diff] [blame] | 939 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 940 | <dd>This indicates to the code generator that the parameter or return value |
| 941 | should be sign-extended to a 32-bit value by the caller (for a parameter) |
| 942 | or the callee (for a return value).</dd> |
Chris Lattner | 47507de | 2008-01-11 06:20:47 +0000 | [diff] [blame] | 943 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 944 | <dt><tt>inreg</tt></dt> |
Nick Lewycky | f23d0d3 | 2008-12-19 06:39:12 +0000 | [diff] [blame] | 945 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 946 | <dd>This indicates that this parameter or return value should be treated in a |
| 947 | special target-dependent fashion during while emitting code for a function |
| 948 | call or return (usually, by putting it in a register as opposed to memory, |
| 949 | though some targets use it to distinguish between two different kinds of |
| 950 | registers). Use of this attribute is target-specific.</dd> |
Chris Lattner | 47507de | 2008-01-11 06:20:47 +0000 | [diff] [blame] | 951 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 952 | <dt><tt><a name="byval">byval</a></tt></dt> |
| 953 | |
| 954 | <dd>This indicates that the pointer parameter should really be passed by value |
| 955 | to the function. The attribute implies that a hidden copy of the pointee |
| 956 | is made between the caller and the callee, so the callee is unable to |
| 957 | modify the value in the callee. This attribute is only valid on LLVM |
| 958 | pointer arguments. It is generally used to pass structs and arrays by |
| 959 | value, but is also valid on pointers to scalars. The copy is considered |
| 960 | to belong to the caller not the callee (for example, |
| 961 | <tt><a href="#readonly">readonly</a></tt> functions should not write to |
| 962 | <tt>byval</tt> parameters). This is not a valid attribute for return |
| 963 | values. The byval attribute also supports specifying an alignment with |
| 964 | the align attribute. This has a target-specific effect on the code |
| 965 | generator that usually indicates a desired alignment for the synthesized |
| 966 | stack slot.</dd> |
| 967 | |
| 968 | <dt><tt>sret</tt></dt> |
| 969 | |
| 970 | <dd>This indicates that the pointer parameter specifies the address of a |
| 971 | structure that is the return value of the function in the source program. |
| 972 | This pointer must be guaranteed by the caller to be valid: loads and |
| 973 | stores to the structure may be assumed by the callee to not to trap. This |
| 974 | may only be applied to the first parameter. This is not a valid attribute |
| 975 | for return values. </dd> |
| 976 | |
| 977 | <dt><tt>noalias</tt></dt> |
| 978 | |
| 979 | <dd>This indicates that the pointer does not alias any global or any other |
| 980 | parameter. The caller is responsible for ensuring that this is the |
| 981 | case. On a function return value, <tt>noalias</tt> additionally indicates |
| 982 | that the pointer does not alias any other pointers visible to the |
| 983 | caller. For further details, please see the discussion of the NoAlias |
| 984 | response in |
| 985 | <a href="http://llvm.org/docs/AliasAnalysis.html#MustMayNo">alias |
| 986 | analysis</a>.</dd> |
| 987 | |
| 988 | <dt><tt>nocapture</tt></dt> |
| 989 | |
| 990 | <dd>This indicates that the callee does not make any copies of the pointer |
| 991 | that outlive the callee itself. This is not a valid attribute for return |
| 992 | values.</dd> |
| 993 | |
| 994 | <dt><tt>nest</tt></dt> |
| 995 | |
| 996 | <dd>This indicates that the pointer parameter can be excised using the |
| 997 | <a href="#int_trampoline">trampoline intrinsics</a>. This is not a valid |
| 998 | attribute for return values.</dd> |
| 999 | </dl> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 1000 | |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 1001 | </div> |
| 1002 | |
| 1003 | <!-- ======================================================================= --> |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 1004 | <div class="doc_subsection"> |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 1005 | <a name="gc">Garbage Collector Names</a> |
| 1006 | </div> |
| 1007 | |
| 1008 | <div class="doc_text"> |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 1009 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1010 | <p>Each function may specify a garbage collector name, which is simply a |
| 1011 | string:</p> |
| 1012 | |
| 1013 | <div class="doc_code"> |
| 1014 | <pre> |
| 1015 | define void @f() gc "name" { ... |
| 1016 | </pre> |
| 1017 | </div> |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 1018 | |
| 1019 | <p>The compiler declares the supported values of <i>name</i>. Specifying a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1020 | collector which will cause the compiler to alter its output in order to |
| 1021 | support the named garbage collection algorithm.</p> |
| 1022 | |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 1023 | </div> |
| 1024 | |
| 1025 | <!-- ======================================================================= --> |
| 1026 | <div class="doc_subsection"> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1027 | <a name="fnattrs">Function Attributes</a> |
Devang Patel | f8b9481 | 2008-09-04 23:05:13 +0000 | [diff] [blame] | 1028 | </div> |
| 1029 | |
| 1030 | <div class="doc_text"> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1031 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1032 | <p>Function attributes are set to communicate additional information about a |
| 1033 | function. Function attributes are considered to be part of the function, not |
| 1034 | of the function type, so functions with different parameter attributes can |
| 1035 | have the same function type.</p> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1036 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1037 | <p>Function attributes are simple keywords that follow the type specified. If |
| 1038 | multiple attributes are needed, they are space separated. For example:</p> |
Devang Patel | f8b9481 | 2008-09-04 23:05:13 +0000 | [diff] [blame] | 1039 | |
| 1040 | <div class="doc_code"> |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1041 | <pre> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1042 | define void @f() noinline { ... } |
| 1043 | define void @f() alwaysinline { ... } |
| 1044 | define void @f() alwaysinline optsize { ... } |
| 1045 | define void @f() optsize |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1046 | </pre> |
Devang Patel | f8b9481 | 2008-09-04 23:05:13 +0000 | [diff] [blame] | 1047 | </div> |
| 1048 | |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1049 | <dl> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1050 | <dt><tt>alwaysinline</tt></dt> |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1051 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1052 | <dd>This attribute indicates that the inliner should attempt to inline this |
| 1053 | function into callers whenever possible, ignoring any active inlining size |
| 1054 | threshold for this caller.</dd> |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1055 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1056 | <dt><tt>noinline</tt></dt> |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1057 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1058 | <dd>This attribute indicates that the inliner should never inline this |
| 1059 | function in any situation. This attribute may not be used together with |
| 1060 | the <tt>alwaysinline</tt> attribute.</dd> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1061 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1062 | <dt><tt>optsize</tt></dt> |
Chris Lattner | 88d4b59 | 2008-10-04 18:23:17 +0000 | [diff] [blame] | 1063 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1064 | <dd>This attribute suggests that optimization passes and code generator passes |
| 1065 | make choices that keep the code size of this function low, and otherwise |
| 1066 | do optimizations specifically to reduce code size.</dd> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1067 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1068 | <dt><tt>noreturn</tt></dt> |
Bill Wendling | 31359ba | 2008-11-13 01:02:51 +0000 | [diff] [blame] | 1069 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1070 | <dd>This function attribute indicates that the function never returns |
| 1071 | normally. This produces undefined behavior at runtime if the function |
| 1072 | ever does dynamically return.</dd> |
Bill Wendling | 31359ba | 2008-11-13 01:02:51 +0000 | [diff] [blame] | 1073 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1074 | <dt><tt>nounwind</tt></dt> |
Bill Wendling | fbaa7ed | 2008-11-26 19:07:40 +0000 | [diff] [blame] | 1075 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1076 | <dd>This function attribute indicates that the function never returns with an |
| 1077 | unwind or exceptional control flow. If the function does unwind, its |
| 1078 | runtime behavior is undefined.</dd> |
Bill Wendling | fbaa7ed | 2008-11-26 19:07:40 +0000 | [diff] [blame] | 1079 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1080 | <dt><tt>readnone</tt></dt> |
Devang Patel | 5d96fda | 2009-06-12 19:45:19 +0000 | [diff] [blame] | 1081 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1082 | <dd>This attribute indicates that the function computes its result (or decides |
| 1083 | to unwind an exception) based strictly on its arguments, without |
| 1084 | dereferencing any pointer arguments or otherwise accessing any mutable |
| 1085 | state (e.g. memory, control registers, etc) visible to caller functions. |
| 1086 | It does not write through any pointer arguments |
| 1087 | (including <tt><a href="#byval">byval</a></tt> arguments) and never |
| 1088 | changes any state visible to callers. This means that it cannot unwind |
| 1089 | exceptions by calling the <tt>C++</tt> exception throwing methods, but |
| 1090 | could use the <tt>unwind</tt> instruction.</dd> |
Devang Patel | 5d96fda | 2009-06-12 19:45:19 +0000 | [diff] [blame] | 1091 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1092 | <dt><tt><a name="readonly">readonly</a></tt></dt> |
Devang Patel | 5d96fda | 2009-06-12 19:45:19 +0000 | [diff] [blame] | 1093 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1094 | <dd>This attribute indicates that the function does not write through any |
| 1095 | pointer arguments (including <tt><a href="#byval">byval</a></tt> |
| 1096 | arguments) or otherwise modify any state (e.g. memory, control registers, |
| 1097 | etc) visible to caller functions. It may dereference pointer arguments |
| 1098 | and read state that may be set in the caller. A readonly function always |
| 1099 | returns the same value (or unwinds an exception identically) when called |
| 1100 | with the same set of arguments and global state. It cannot unwind an |
| 1101 | exception by calling the <tt>C++</tt> exception throwing methods, but may |
| 1102 | use the <tt>unwind</tt> instruction.</dd> |
Anton Korobeynikov | c5ec8a7 | 2009-07-17 18:07:26 +0000 | [diff] [blame] | 1103 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1104 | <dt><tt><a name="ssp">ssp</a></tt></dt> |
| 1105 | |
| 1106 | <dd>This attribute indicates that the function should emit a stack smashing |
| 1107 | protector. It is in the form of a "canary"—a random value placed on |
| 1108 | the stack before the local variables that's checked upon return from the |
| 1109 | function to see if it has been overwritten. A heuristic is used to |
| 1110 | determine if a function needs stack protectors or not.<br> |
| 1111 | <br> |
| 1112 | If a function that has an <tt>ssp</tt> attribute is inlined into a |
| 1113 | function that doesn't have an <tt>ssp</tt> attribute, then the resulting |
| 1114 | function will have an <tt>ssp</tt> attribute.</dd> |
| 1115 | |
| 1116 | <dt><tt>sspreq</tt></dt> |
| 1117 | |
| 1118 | <dd>This attribute indicates that the function should <em>always</em> emit a |
| 1119 | stack smashing protector. This overrides |
| 1120 | the <tt><a href="#ssp">ssp</a></tt> function attribute. |
| 1121 | |
| 1122 | If a function that has an <tt>sspreq</tt> attribute is inlined into a |
| 1123 | function that doesn't have an <tt>sspreq</tt> attribute or which has |
| 1124 | an <tt>ssp</tt> attribute, then the resulting function will have |
| 1125 | an <tt>sspreq</tt> attribute.</dd> |
| 1126 | |
| 1127 | <dt><tt>noredzone</tt></dt> |
| 1128 | |
| 1129 | <dd>This attribute indicates that the code generator should not use a red |
| 1130 | zone, even if the target-specific ABI normally permits it.</dd> |
| 1131 | |
| 1132 | <dt><tt>noimplicitfloat</tt></dt> |
| 1133 | |
| 1134 | <dd>This attributes disables implicit floating point instructions.</dd> |
| 1135 | |
| 1136 | <dt><tt>naked</tt></dt> |
| 1137 | |
| 1138 | <dd>This attribute disables prologue / epilogue emission for the function. |
| 1139 | This can have very system-specific consequences.</dd> |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1140 | </dl> |
| 1141 | |
Devang Patel | f8b9481 | 2008-09-04 23:05:13 +0000 | [diff] [blame] | 1142 | </div> |
| 1143 | |
| 1144 | <!-- ======================================================================= --> |
| 1145 | <div class="doc_subsection"> |
Chris Lattner | 1eeeb0c | 2006-04-08 04:40:53 +0000 | [diff] [blame] | 1146 | <a name="moduleasm">Module-Level Inline Assembly</a> |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 1147 | </div> |
| 1148 | |
| 1149 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1150 | |
| 1151 | <p>Modules may contain "module-level inline asm" blocks, which corresponds to |
| 1152 | the GCC "file scope inline asm" blocks. These blocks are internally |
| 1153 | concatenated by LLVM and treated as a single unit, but may be separated in |
| 1154 | the <tt>.ll</tt> file if desired. The syntax is very simple:</p> |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 1155 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 1156 | <div class="doc_code"> |
| 1157 | <pre> |
| 1158 | module asm "inline asm code goes here" |
| 1159 | module asm "more can go here" |
| 1160 | </pre> |
| 1161 | </div> |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 1162 | |
| 1163 | <p>The strings can contain any character by escaping non-printable characters. |
| 1164 | The escape sequence used is simply "\xx" where "xx" is the two digit hex code |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1165 | for the number.</p> |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 1166 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1167 | <p>The inline asm code is simply printed to the machine code .s file when |
| 1168 | assembly code is generated.</p> |
| 1169 | |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 1170 | </div> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 1171 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1172 | <!-- ======================================================================= --> |
| 1173 | <div class="doc_subsection"> |
| 1174 | <a name="datalayout">Data Layout</a> |
| 1175 | </div> |
| 1176 | |
| 1177 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1178 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1179 | <p>A module may specify a target specific data layout string that specifies how |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1180 | data is to be laid out in memory. The syntax for the data layout is |
| 1181 | simply:</p> |
| 1182 | |
| 1183 | <div class="doc_code"> |
| 1184 | <pre> |
| 1185 | target datalayout = "<i>layout specification</i>" |
| 1186 | </pre> |
| 1187 | </div> |
| 1188 | |
| 1189 | <p>The <i>layout specification</i> consists of a list of specifications |
| 1190 | separated by the minus sign character ('-'). Each specification starts with |
| 1191 | a letter and may include other information after the letter to define some |
| 1192 | aspect of the data layout. The specifications accepted are as follows:</p> |
| 1193 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1194 | <dl> |
| 1195 | <dt><tt>E</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1196 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1197 | <dd>Specifies that the target lays out data in big-endian form. That is, the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1198 | bits with the most significance have the lowest address location.</dd> |
| 1199 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1200 | <dt><tt>e</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1201 | |
Chris Lattner | d3eda89 | 2008-08-05 18:29:16 +0000 | [diff] [blame] | 1202 | <dd>Specifies that the target lays out data in little-endian form. That is, |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1203 | the bits with the least significance have the lowest address |
| 1204 | location.</dd> |
| 1205 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1206 | <dt><tt>p:<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1207 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1208 | <dd>This specifies the <i>size</i> of a pointer and its <i>abi</i> and |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1209 | <i>preferred</i> alignments. All sizes are in bits. Specifying |
| 1210 | the <i>pref</i> alignment is optional. If omitted, the |
| 1211 | preceding <tt>:</tt> should be omitted too.</dd> |
| 1212 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1213 | <dt><tt>i<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1214 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1215 | <dd>This specifies the alignment for an integer type of a given bit |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1216 | <i>size</i>. The value of <i>size</i> must be in the range [1,2^23).</dd> |
| 1217 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1218 | <dt><tt>v<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1219 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1220 | <dd>This specifies the alignment for a vector type of a given bit |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1221 | <i>size</i>.</dd> |
| 1222 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1223 | <dt><tt>f<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1224 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1225 | <dd>This specifies the alignment for a floating point type of a given bit |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1226 | <i>size</i>. The value of <i>size</i> must be either 32 (float) or 64 |
| 1227 | (double).</dd> |
| 1228 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1229 | <dt><tt>a<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1230 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1231 | <dd>This specifies the alignment for an aggregate type of a given bit |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1232 | <i>size</i>.</dd> |
| 1233 | |
Daniel Dunbar | 87bde0b | 2009-06-08 22:17:53 +0000 | [diff] [blame] | 1234 | <dt><tt>s<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1235 | |
Daniel Dunbar | 87bde0b | 2009-06-08 22:17:53 +0000 | [diff] [blame] | 1236 | <dd>This specifies the alignment for a stack object of a given bit |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1237 | <i>size</i>.</dd> |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1238 | </dl> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1239 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1240 | <p>When constructing the data layout for a given target, LLVM starts with a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1241 | default set of specifications which are then (possibly) overriden by the |
| 1242 | specifications in the <tt>datalayout</tt> keyword. The default specifications |
| 1243 | are given in this list:</p> |
| 1244 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1245 | <ul> |
| 1246 | <li><tt>E</tt> - big endian</li> |
| 1247 | <li><tt>p:32:64:64</tt> - 32-bit pointers with 64-bit alignment</li> |
| 1248 | <li><tt>i1:8:8</tt> - i1 is 8-bit (byte) aligned</li> |
| 1249 | <li><tt>i8:8:8</tt> - i8 is 8-bit (byte) aligned</li> |
| 1250 | <li><tt>i16:16:16</tt> - i16 is 16-bit aligned</li> |
| 1251 | <li><tt>i32:32:32</tt> - i32 is 32-bit aligned</li> |
Chris Lattner | d3eda89 | 2008-08-05 18:29:16 +0000 | [diff] [blame] | 1252 | <li><tt>i64:32:64</tt> - i64 has ABI alignment of 32-bits but preferred |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1253 | alignment of 64-bits</li> |
| 1254 | <li><tt>f32:32:32</tt> - float is 32-bit aligned</li> |
| 1255 | <li><tt>f64:64:64</tt> - double is 64-bit aligned</li> |
| 1256 | <li><tt>v64:64:64</tt> - 64-bit vector is 64-bit aligned</li> |
| 1257 | <li><tt>v128:128:128</tt> - 128-bit vector is 128-bit aligned</li> |
| 1258 | <li><tt>a0:0:1</tt> - aggregates are 8-bit aligned</li> |
Daniel Dunbar | 87bde0b | 2009-06-08 22:17:53 +0000 | [diff] [blame] | 1259 | <li><tt>s0:64:64</tt> - stack objects are 64-bit aligned</li> |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1260 | </ul> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1261 | |
| 1262 | <p>When LLVM is determining the alignment for a given type, it uses the |
| 1263 | following rules:</p> |
| 1264 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1265 | <ol> |
| 1266 | <li>If the type sought is an exact match for one of the specifications, that |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1267 | specification is used.</li> |
| 1268 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1269 | <li>If no match is found, and the type sought is an integer type, then the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1270 | smallest integer type that is larger than the bitwidth of the sought type |
| 1271 | is used. If none of the specifications are larger than the bitwidth then |
| 1272 | the the largest integer type is used. For example, given the default |
| 1273 | specifications above, the i7 type will use the alignment of i8 (next |
| 1274 | largest) while both i65 and i256 will use the alignment of i64 (largest |
| 1275 | specified).</li> |
| 1276 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1277 | <li>If no match is found, and the type sought is a vector type, then the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1278 | largest vector type that is smaller than the sought vector type will be |
| 1279 | used as a fall back. This happens because <128 x double> can be |
| 1280 | implemented in terms of 64 <2 x double>, for example.</li> |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1281 | </ol> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1282 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1283 | </div> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 1284 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1285 | <!-- *********************************************************************** --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1286 | <div class="doc_section"> <a name="typesystem">Type System</a> </div> |
| 1287 | <!-- *********************************************************************** --> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 1288 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1289 | <div class="doc_text"> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 1290 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1291 | <p>The LLVM type system is one of the most important features of the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1292 | intermediate representation. Being typed enables a number of optimizations |
| 1293 | to be performed on the intermediate representation directly, without having |
| 1294 | to do extra analyses on the side before the transformation. A strong type |
| 1295 | system makes it easier to read the generated code and enables novel analyses |
| 1296 | and transformations that are not feasible to perform on normal three address |
| 1297 | code representations.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 1298 | |
| 1299 | </div> |
| 1300 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1301 | <!-- ======================================================================= --> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1302 | <div class="doc_subsection"> <a name="t_classifications">Type |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1303 | Classifications</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1304 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1305 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1306 | |
| 1307 | <p>The types fall into a few useful classifications:</p> |
Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1308 | |
| 1309 | <table border="1" cellspacing="0" cellpadding="4"> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1310 | <tbody> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1311 | <tr><th>Classification</th><th>Types</th></tr> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1312 | <tr> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1313 | <td><a href="#t_integer">integer</a></td> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1314 | <td><tt>i1, i2, i3, ... i8, ... i16, ... i32, ... i64, ... </tt></td> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1315 | </tr> |
| 1316 | <tr> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1317 | <td><a href="#t_floating">floating point</a></td> |
| 1318 | <td><tt>float, double, x86_fp80, fp128, ppc_fp128</tt></td> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1319 | </tr> |
| 1320 | <tr> |
| 1321 | <td><a name="t_firstclass">first class</a></td> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1322 | <td><a href="#t_integer">integer</a>, |
| 1323 | <a href="#t_floating">floating point</a>, |
| 1324 | <a href="#t_pointer">pointer</a>, |
Dan Gohman | 0066db6 | 2008-06-18 18:42:13 +0000 | [diff] [blame] | 1325 | <a href="#t_vector">vector</a>, |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 1326 | <a href="#t_struct">structure</a>, |
| 1327 | <a href="#t_array">array</a>, |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 1328 | <a href="#t_label">label</a>, |
| 1329 | <a href="#t_metadata">metadata</a>. |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 1330 | </td> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1331 | </tr> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1332 | <tr> |
| 1333 | <td><a href="#t_primitive">primitive</a></td> |
| 1334 | <td><a href="#t_label">label</a>, |
| 1335 | <a href="#t_void">void</a>, |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 1336 | <a href="#t_floating">floating point</a>, |
| 1337 | <a href="#t_metadata">metadata</a>.</td> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1338 | </tr> |
| 1339 | <tr> |
| 1340 | <td><a href="#t_derived">derived</a></td> |
| 1341 | <td><a href="#t_integer">integer</a>, |
| 1342 | <a href="#t_array">array</a>, |
| 1343 | <a href="#t_function">function</a>, |
| 1344 | <a href="#t_pointer">pointer</a>, |
| 1345 | <a href="#t_struct">structure</a>, |
| 1346 | <a href="#t_pstruct">packed structure</a>, |
| 1347 | <a href="#t_vector">vector</a>, |
| 1348 | <a href="#t_opaque">opaque</a>. |
Dan Gohman | 01ac101 | 2008-10-14 16:32:04 +0000 | [diff] [blame] | 1349 | </td> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1350 | </tr> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1351 | </tbody> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1352 | </table> |
Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1353 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1354 | <p>The <a href="#t_firstclass">first class</a> types are perhaps the most |
| 1355 | important. Values of these types are the only ones which can be produced by |
| 1356 | instructions, passed as arguments, or used as operands to instructions.</p> |
| 1357 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1358 | </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1359 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1360 | <!-- ======================================================================= --> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1361 | <div class="doc_subsection"> <a name="t_primitive">Primitive Types</a> </div> |
Chris Lattner | 8f8c7b7 | 2008-01-04 04:34:14 +0000 | [diff] [blame] | 1362 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1363 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1364 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1365 | <p>The primitive types are the fundamental building blocks of the LLVM |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1366 | system.</p> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1367 | |
Chris Lattner | 8f8c7b7 | 2008-01-04 04:34:14 +0000 | [diff] [blame] | 1368 | </div> |
| 1369 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1370 | <!-- _______________________________________________________________________ --> |
| 1371 | <div class="doc_subsubsection"> <a name="t_floating">Floating Point Types</a> </div> |
| 1372 | |
| 1373 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1374 | |
| 1375 | <table> |
| 1376 | <tbody> |
| 1377 | <tr><th>Type</th><th>Description</th></tr> |
| 1378 | <tr><td><tt>float</tt></td><td>32-bit floating point value</td></tr> |
| 1379 | <tr><td><tt>double</tt></td><td>64-bit floating point value</td></tr> |
| 1380 | <tr><td><tt>fp128</tt></td><td>128-bit floating point value (112-bit mantissa)</td></tr> |
| 1381 | <tr><td><tt>x86_fp80</tt></td><td>80-bit floating point value (X87)</td></tr> |
| 1382 | <tr><td><tt>ppc_fp128</tt></td><td>128-bit floating point value (two 64-bits)</td></tr> |
| 1383 | </tbody> |
| 1384 | </table> |
| 1385 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1386 | </div> |
| 1387 | |
| 1388 | <!-- _______________________________________________________________________ --> |
| 1389 | <div class="doc_subsubsection"> <a name="t_void">Void Type</a> </div> |
| 1390 | |
| 1391 | <div class="doc_text"> |
| 1392 | <h5>Overview:</h5> |
| 1393 | <p>The void type does not represent any value and has no size.</p> |
| 1394 | |
| 1395 | <h5>Syntax:</h5> |
| 1396 | |
| 1397 | <pre> |
| 1398 | void |
| 1399 | </pre> |
| 1400 | </div> |
| 1401 | |
| 1402 | <!-- _______________________________________________________________________ --> |
| 1403 | <div class="doc_subsubsection"> <a name="t_label">Label Type</a> </div> |
| 1404 | |
| 1405 | <div class="doc_text"> |
| 1406 | <h5>Overview:</h5> |
| 1407 | <p>The label type represents code labels.</p> |
| 1408 | |
| 1409 | <h5>Syntax:</h5> |
| 1410 | |
| 1411 | <pre> |
| 1412 | label |
| 1413 | </pre> |
| 1414 | </div> |
| 1415 | |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 1416 | <!-- _______________________________________________________________________ --> |
| 1417 | <div class="doc_subsubsection"> <a name="t_metadata">Metadata Type</a> </div> |
| 1418 | |
| 1419 | <div class="doc_text"> |
| 1420 | <h5>Overview:</h5> |
| 1421 | <p>The metadata type represents embedded metadata. The only derived type that |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1422 | may contain metadata is <tt>metadata*</tt> or a function type that returns or |
| 1423 | takes metadata typed parameters, but not pointer to metadata types.</p> |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 1424 | |
| 1425 | <h5>Syntax:</h5> |
| 1426 | |
| 1427 | <pre> |
| 1428 | metadata |
| 1429 | </pre> |
| 1430 | </div> |
| 1431 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1432 | |
| 1433 | <!-- ======================================================================= --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1434 | <div class="doc_subsection"> <a name="t_derived">Derived Types</a> </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1435 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1436 | <div class="doc_text"> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1437 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1438 | <p>The real power in LLVM comes from the derived types in the system. This is |
| 1439 | what allows a programmer to represent arrays, functions, pointers, and other |
| 1440 | useful types. Note that these derived types may be recursive: For example, |
| 1441 | it is possible to have a two dimensional array.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1442 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1443 | </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1444 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1445 | <!-- _______________________________________________________________________ --> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1446 | <div class="doc_subsubsection"> <a name="t_integer">Integer Type</a> </div> |
| 1447 | |
| 1448 | <div class="doc_text"> |
| 1449 | |
| 1450 | <h5>Overview:</h5> |
| 1451 | <p>The integer type is a very simple derived type that simply specifies an |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1452 | arbitrary bit width for the integer type desired. Any bit width from 1 bit to |
| 1453 | 2^23-1 (about 8 million) can be specified.</p> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1454 | |
| 1455 | <h5>Syntax:</h5> |
| 1456 | |
| 1457 | <pre> |
| 1458 | iN |
| 1459 | </pre> |
| 1460 | |
| 1461 | <p>The number of bits the integer will occupy is specified by the <tt>N</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1462 | value.</p> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1463 | |
| 1464 | <h5>Examples:</h5> |
| 1465 | <table class="layout"> |
Nick Lewycky | 86c4864 | 2009-05-24 02:46:06 +0000 | [diff] [blame] | 1466 | <tr class="layout"> |
| 1467 | <td class="left"><tt>i1</tt></td> |
| 1468 | <td class="left">a single-bit integer.</td> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1469 | </tr> |
Nick Lewycky | 86c4864 | 2009-05-24 02:46:06 +0000 | [diff] [blame] | 1470 | <tr class="layout"> |
| 1471 | <td class="left"><tt>i32</tt></td> |
| 1472 | <td class="left">a 32-bit integer.</td> |
| 1473 | </tr> |
| 1474 | <tr class="layout"> |
| 1475 | <td class="left"><tt>i1942652</tt></td> |
| 1476 | <td class="left">a really big integer of over 1 million bits.</td> |
| 1477 | </tr> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1478 | </table> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1479 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1480 | <p>Note that the code generator does not yet support large integer types to be |
| 1481 | used as function return types. The specific limit on how large a return type |
| 1482 | the code generator can currently handle is target-dependent; currently it's |
| 1483 | often 64 bits for 32-bit targets and 128 bits for 64-bit targets.</p> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1484 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 1485 | </div> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1486 | |
| 1487 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1488 | <div class="doc_subsubsection"> <a name="t_array">Array Type</a> </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1489 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1490 | <div class="doc_text"> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1491 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1492 | <h5>Overview:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1493 | <p>The array type is a very simple derived type that arranges elements |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1494 | sequentially in memory. The array type requires a size (number of elements) |
| 1495 | and an underlying data type.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1496 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1497 | <h5>Syntax:</h5> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1498 | |
| 1499 | <pre> |
| 1500 | [<# elements> x <elementtype>] |
| 1501 | </pre> |
| 1502 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1503 | <p>The number of elements is a constant integer value; <tt>elementtype</tt> may |
| 1504 | be any type with a size.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1505 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1506 | <h5>Examples:</h5> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1507 | <table class="layout"> |
| 1508 | <tr class="layout"> |
Chris Lattner | 23ff1f9 | 2007-12-19 05:04:11 +0000 | [diff] [blame] | 1509 | <td class="left"><tt>[40 x i32]</tt></td> |
| 1510 | <td class="left">Array of 40 32-bit integer values.</td> |
| 1511 | </tr> |
| 1512 | <tr class="layout"> |
| 1513 | <td class="left"><tt>[41 x i32]</tt></td> |
| 1514 | <td class="left">Array of 41 32-bit integer values.</td> |
| 1515 | </tr> |
| 1516 | <tr class="layout"> |
| 1517 | <td class="left"><tt>[4 x i8]</tt></td> |
| 1518 | <td class="left">Array of 4 8-bit integer values.</td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1519 | </tr> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1520 | </table> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1521 | <p>Here are some examples of multidimensional arrays:</p> |
| 1522 | <table class="layout"> |
| 1523 | <tr class="layout"> |
Chris Lattner | 23ff1f9 | 2007-12-19 05:04:11 +0000 | [diff] [blame] | 1524 | <td class="left"><tt>[3 x [4 x i32]]</tt></td> |
| 1525 | <td class="left">3x4 array of 32-bit integer values.</td> |
| 1526 | </tr> |
| 1527 | <tr class="layout"> |
| 1528 | <td class="left"><tt>[12 x [10 x float]]</tt></td> |
| 1529 | <td class="left">12x10 array of single precision floating point values.</td> |
| 1530 | </tr> |
| 1531 | <tr class="layout"> |
| 1532 | <td class="left"><tt>[2 x [3 x [4 x i16]]]</tt></td> |
| 1533 | <td class="left">2x3x4 array of 16-bit integer values.</td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1534 | </tr> |
| 1535 | </table> |
Chris Lattner | e67a951 | 2005-06-24 17:22:57 +0000 | [diff] [blame] | 1536 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1537 | <p>Note that 'variable sized arrays' can be implemented in LLVM with a zero |
| 1538 | length array. Normally, accesses past the end of an array are undefined in |
| 1539 | LLVM (e.g. it is illegal to access the 5th element of a 3 element array). As |
| 1540 | a special case, however, zero length arrays are recognized to be variable |
| 1541 | length. This allows implementation of 'pascal style arrays' with the LLVM |
| 1542 | type "<tt>{ i32, [0 x float]}</tt>", for example.</p> |
Chris Lattner | e67a951 | 2005-06-24 17:22:57 +0000 | [diff] [blame] | 1543 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1544 | <p>Note that the code generator does not yet support large aggregate types to be |
| 1545 | used as function return types. The specific limit on how large an aggregate |
| 1546 | return type the code generator can currently handle is target-dependent, and |
| 1547 | also dependent on the aggregate element types.</p> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1548 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1549 | </div> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1550 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1551 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1552 | <div class="doc_subsubsection"> <a name="t_function">Function Type</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1553 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1554 | <div class="doc_text"> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 1555 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1556 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1557 | <p>The function type can be thought of as a function signature. It consists of |
| 1558 | a return type and a list of formal parameter types. The return type of a |
| 1559 | function type is a scalar type, a void type, or a struct type. If the return |
| 1560 | type is a struct type then all struct elements must be of first class types, |
| 1561 | and the struct must have at least one element.</p> |
Devang Patel | c3fc6df | 2008-03-10 20:49:15 +0000 | [diff] [blame] | 1562 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1563 | <h5>Syntax:</h5> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 1564 | |
| 1565 | <pre> |
| 1566 | <returntype list> (<parameter list>) |
| 1567 | </pre> |
| 1568 | |
John Criswell | 0ec250c | 2005-10-24 16:17:18 +0000 | [diff] [blame] | 1569 | <p>...where '<tt><parameter list></tt>' is a comma-separated list of type |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1570 | specifiers. Optionally, the parameter list may include a type <tt>...</tt>, |
| 1571 | which indicates that the function takes a variable number of arguments. |
| 1572 | Variable argument functions can access their arguments with |
| 1573 | the <a href="#int_varargs">variable argument handling intrinsic</a> |
| 1574 | functions. '<tt><returntype list></tt>' is a comma-separated list of |
| 1575 | <a href="#t_firstclass">first class</a> type specifiers.</p> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 1576 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1577 | <h5>Examples:</h5> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1578 | <table class="layout"> |
| 1579 | <tr class="layout"> |
Reid Spencer | 92f8230 | 2006-12-31 07:18:34 +0000 | [diff] [blame] | 1580 | <td class="left"><tt>i32 (i32)</tt></td> |
| 1581 | <td class="left">function taking an <tt>i32</tt>, returning an <tt>i32</tt> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1582 | </td> |
Reid Spencer | 92f8230 | 2006-12-31 07:18:34 +0000 | [diff] [blame] | 1583 | </tr><tr class="layout"> |
Reid Spencer | 9445e9a | 2007-07-19 23:13:04 +0000 | [diff] [blame] | 1584 | <td class="left"><tt>float (i16 signext, i32 *) * |
Reid Spencer | f17a0b7 | 2006-12-31 07:20:23 +0000 | [diff] [blame] | 1585 | </tt></td> |
Reid Spencer | 92f8230 | 2006-12-31 07:18:34 +0000 | [diff] [blame] | 1586 | <td class="left"><a href="#t_pointer">Pointer</a> to a function that takes |
| 1587 | an <tt>i16</tt> that should be sign extended and a |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 1588 | <a href="#t_pointer">pointer</a> to <tt>i32</tt>, returning |
Reid Spencer | 92f8230 | 2006-12-31 07:18:34 +0000 | [diff] [blame] | 1589 | <tt>float</tt>. |
| 1590 | </td> |
| 1591 | </tr><tr class="layout"> |
| 1592 | <td class="left"><tt>i32 (i8*, ...)</tt></td> |
| 1593 | <td class="left">A vararg function that takes at least one |
Reid Spencer | a517338 | 2007-01-04 16:43:23 +0000 | [diff] [blame] | 1594 | <a href="#t_pointer">pointer</a> to <tt>i8 </tt> (char in C), |
Reid Spencer | 92f8230 | 2006-12-31 07:18:34 +0000 | [diff] [blame] | 1595 | which returns an integer. This is the signature for <tt>printf</tt> in |
| 1596 | LLVM. |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1597 | </td> |
Devang Patel | a582f40 | 2008-03-24 05:35:41 +0000 | [diff] [blame] | 1598 | </tr><tr class="layout"> |
| 1599 | <td class="left"><tt>{i32, i32} (i32)</tt></td> |
Misha Brukman | b0a57aa | 2008-11-27 06:41:20 +0000 | [diff] [blame] | 1600 | <td class="left">A function taking an <tt>i32</tt>, returning two |
| 1601 | <tt>i32</tt> values as an aggregate of type <tt>{ i32, i32 }</tt> |
Devang Patel | a582f40 | 2008-03-24 05:35:41 +0000 | [diff] [blame] | 1602 | </td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1603 | </tr> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1604 | </table> |
Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1605 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1606 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1607 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1608 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1609 | <div class="doc_subsubsection"> <a name="t_struct">Structure Type</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1610 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1611 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1612 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1613 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1614 | <p>The structure type is used to represent a collection of data members together |
| 1615 | in memory. The packing of the field types is defined to match the ABI of the |
| 1616 | underlying processor. The elements of a structure may be any type that has a |
| 1617 | size.</p> |
| 1618 | |
| 1619 | <p>Structures are accessed using '<tt><a href="#i_load">load</a></tt> and |
| 1620 | '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a field with |
| 1621 | the '<tt><a href="#i_getelementptr">getelementptr</a></tt>' instruction.</p> |
| 1622 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1623 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1624 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1625 | <pre> { <type list> }<br></pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1626 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1627 | <h5>Examples:</h5> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1628 | <table class="layout"> |
| 1629 | <tr class="layout"> |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 1630 | <td class="left"><tt>{ i32, i32, i32 }</tt></td> |
| 1631 | <td class="left">A triple of three <tt>i32</tt> values</td> |
| 1632 | </tr><tr class="layout"> |
| 1633 | <td class="left"><tt>{ float, i32 (i32) * }</tt></td> |
| 1634 | <td class="left">A pair, where the first element is a <tt>float</tt> and the |
| 1635 | second element is a <a href="#t_pointer">pointer</a> to a |
| 1636 | <a href="#t_function">function</a> that takes an <tt>i32</tt>, returning |
| 1637 | an <tt>i32</tt>.</td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1638 | </tr> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1639 | </table> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1640 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1641 | <p>Note that the code generator does not yet support large aggregate types to be |
| 1642 | used as function return types. The specific limit on how large an aggregate |
| 1643 | return type the code generator can currently handle is target-dependent, and |
| 1644 | also dependent on the aggregate element types.</p> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1645 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1646 | </div> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1647 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1648 | <!-- _______________________________________________________________________ --> |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1649 | <div class="doc_subsubsection"> <a name="t_pstruct">Packed Structure Type</a> |
| 1650 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1651 | |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1652 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1653 | |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1654 | <h5>Overview:</h5> |
| 1655 | <p>The packed structure type is used to represent a collection of data members |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1656 | together in memory. There is no padding between fields. Further, the |
| 1657 | alignment of a packed structure is 1 byte. The elements of a packed |
| 1658 | structure may be any type that has a size.</p> |
| 1659 | |
| 1660 | <p>Structures are accessed using '<tt><a href="#i_load">load</a></tt> and |
| 1661 | '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a field with |
| 1662 | the '<tt><a href="#i_getelementptr">getelementptr</a></tt>' instruction.</p> |
| 1663 | |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1664 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1665 | |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1666 | <pre> < { <type list> } > <br></pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1667 | |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1668 | <h5>Examples:</h5> |
| 1669 | <table class="layout"> |
| 1670 | <tr class="layout"> |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 1671 | <td class="left"><tt>< { i32, i32, i32 } ></tt></td> |
| 1672 | <td class="left">A triple of three <tt>i32</tt> values</td> |
| 1673 | </tr><tr class="layout"> |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1674 | <td class="left"> |
| 1675 | <tt>< { float, i32 (i32)* } ></tt></td> |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 1676 | <td class="left">A pair, where the first element is a <tt>float</tt> and the |
| 1677 | second element is a <a href="#t_pointer">pointer</a> to a |
| 1678 | <a href="#t_function">function</a> that takes an <tt>i32</tt>, returning |
| 1679 | an <tt>i32</tt>.</td> |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1680 | </tr> |
| 1681 | </table> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1682 | |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1683 | </div> |
| 1684 | |
| 1685 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1686 | <div class="doc_subsubsection"> <a name="t_pointer">Pointer Type</a> </div> |
Chris Lattner | 0fd4a27 | 2009-02-08 19:53:29 +0000 | [diff] [blame] | 1687 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1688 | <div class="doc_text"> |
| 1689 | |
| 1690 | <h5>Overview:</h5> |
| 1691 | <p>As in many languages, the pointer type represents a pointer or reference to |
| 1692 | another object, which must live in memory. Pointer types may have an optional |
| 1693 | address space attribute defining the target-specific numbered address space |
| 1694 | where the pointed-to object resides. The default address space is zero.</p> |
| 1695 | |
| 1696 | <p>Note that LLVM does not permit pointers to void (<tt>void*</tt>) nor does it |
| 1697 | permit pointers to labels (<tt>label*</tt>). Use <tt>i8*</tt> instead.</p> |
Chris Lattner | 0fd4a27 | 2009-02-08 19:53:29 +0000 | [diff] [blame] | 1698 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1699 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1700 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1701 | <pre> <type> *<br></pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1702 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1703 | <h5>Examples:</h5> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1704 | <table class="layout"> |
| 1705 | <tr class="layout"> |
Dan Gohman | 2a08c53 | 2009-01-04 23:44:43 +0000 | [diff] [blame] | 1706 | <td class="left"><tt>[4 x i32]*</tt></td> |
Chris Lattner | 23ff1f9 | 2007-12-19 05:04:11 +0000 | [diff] [blame] | 1707 | <td class="left">A <a href="#t_pointer">pointer</a> to <a |
| 1708 | href="#t_array">array</a> of four <tt>i32</tt> values.</td> |
| 1709 | </tr> |
| 1710 | <tr class="layout"> |
| 1711 | <td class="left"><tt>i32 (i32 *) *</tt></td> |
| 1712 | <td class="left"> A <a href="#t_pointer">pointer</a> to a <a |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 1713 | href="#t_function">function</a> that takes an <tt>i32*</tt>, returning an |
Chris Lattner | 23ff1f9 | 2007-12-19 05:04:11 +0000 | [diff] [blame] | 1714 | <tt>i32</tt>.</td> |
| 1715 | </tr> |
| 1716 | <tr class="layout"> |
| 1717 | <td class="left"><tt>i32 addrspace(5)*</tt></td> |
| 1718 | <td class="left">A <a href="#t_pointer">pointer</a> to an <tt>i32</tt> value |
| 1719 | that resides in address space #5.</td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1720 | </tr> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1721 | </table> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1722 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1723 | </div> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1724 | |
Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1725 | <!-- _______________________________________________________________________ --> |
Reid Spencer | 485bad1 | 2007-02-15 03:07:05 +0000 | [diff] [blame] | 1726 | <div class="doc_subsubsection"> <a name="t_vector">Vector Type</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1727 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1728 | <div class="doc_text"> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1729 | |
Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1730 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1731 | <p>A vector type is a simple derived type that represents a vector of elements. |
| 1732 | Vector types are used when multiple primitive data are operated in parallel |
| 1733 | using a single instruction (SIMD). A vector type requires a size (number of |
| 1734 | elements) and an underlying primitive data type. Vectors must have a power |
| 1735 | of two length (1, 2, 4, 8, 16 ...). Vector types are considered |
| 1736 | <a href="#t_firstclass">first class</a>.</p> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1737 | |
Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1738 | <h5>Syntax:</h5> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1739 | |
| 1740 | <pre> |
| 1741 | < <# elements> x <elementtype> > |
| 1742 | </pre> |
| 1743 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1744 | <p>The number of elements is a constant integer value; elementtype may be any |
| 1745 | integer or floating point type.</p> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1746 | |
Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1747 | <h5>Examples:</h5> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1748 | |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1749 | <table class="layout"> |
| 1750 | <tr class="layout"> |
Chris Lattner | 23ff1f9 | 2007-12-19 05:04:11 +0000 | [diff] [blame] | 1751 | <td class="left"><tt><4 x i32></tt></td> |
| 1752 | <td class="left">Vector of 4 32-bit integer values.</td> |
| 1753 | </tr> |
| 1754 | <tr class="layout"> |
| 1755 | <td class="left"><tt><8 x float></tt></td> |
| 1756 | <td class="left">Vector of 8 32-bit floating-point values.</td> |
| 1757 | </tr> |
| 1758 | <tr class="layout"> |
| 1759 | <td class="left"><tt><2 x i64></tt></td> |
| 1760 | <td class="left">Vector of 2 64-bit integer values.</td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1761 | </tr> |
| 1762 | </table> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1763 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1764 | <p>Note that the code generator does not yet support large vector types to be |
| 1765 | used as function return types. The specific limit on how large a vector |
| 1766 | return type codegen can currently handle is target-dependent; currently it's |
| 1767 | often a few times longer than a hardware vector register.</p> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1768 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1769 | </div> |
| 1770 | |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1771 | <!-- _______________________________________________________________________ --> |
| 1772 | <div class="doc_subsubsection"> <a name="t_opaque">Opaque Type</a> </div> |
| 1773 | <div class="doc_text"> |
| 1774 | |
| 1775 | <h5>Overview:</h5> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1776 | <p>Opaque types are used to represent unknown types in the system. This |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1777 | corresponds (for example) to the C notion of a forward declared structure |
| 1778 | type. In LLVM, opaque types can eventually be resolved to any type (not just |
| 1779 | a structure type).</p> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1780 | |
| 1781 | <h5>Syntax:</h5> |
| 1782 | |
| 1783 | <pre> |
| 1784 | opaque |
| 1785 | </pre> |
| 1786 | |
| 1787 | <h5>Examples:</h5> |
| 1788 | |
| 1789 | <table class="layout"> |
| 1790 | <tr class="layout"> |
Chris Lattner | 23ff1f9 | 2007-12-19 05:04:11 +0000 | [diff] [blame] | 1791 | <td class="left"><tt>opaque</tt></td> |
| 1792 | <td class="left">An opaque type.</td> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1793 | </tr> |
| 1794 | </table> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1795 | |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1796 | </div> |
| 1797 | |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1798 | <!-- ======================================================================= --> |
| 1799 | <div class="doc_subsection"> |
| 1800 | <a name="t_uprefs">Type Up-references</a> |
| 1801 | </div> |
| 1802 | |
| 1803 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1804 | |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1805 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1806 | <p>An "up reference" allows you to refer to a lexically enclosing type without |
| 1807 | requiring it to have a name. For instance, a structure declaration may |
| 1808 | contain a pointer to any of the types it is lexically a member of. Example |
| 1809 | of up references (with their equivalent as named type declarations) |
| 1810 | include:</p> |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1811 | |
| 1812 | <pre> |
Chris Lattner | 3060f5b | 2009-02-09 10:00:56 +0000 | [diff] [blame] | 1813 | { \2 * } %x = type { %x* } |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1814 | { \2 }* %y = type { %y }* |
| 1815 | \1* %z = type %z* |
| 1816 | </pre> |
| 1817 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1818 | <p>An up reference is needed by the asmprinter for printing out cyclic types |
| 1819 | when there is no declared name for a type in the cycle. Because the |
| 1820 | asmprinter does not want to print out an infinite type string, it needs a |
| 1821 | syntax to handle recursive types that have no names (all names are optional |
| 1822 | in llvm IR).</p> |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1823 | |
| 1824 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1825 | |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1826 | <pre> |
| 1827 | \<level> |
| 1828 | </pre> |
| 1829 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1830 | <p>The level is the count of the lexical type that is being referred to.</p> |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1831 | |
| 1832 | <h5>Examples:</h5> |
| 1833 | |
| 1834 | <table class="layout"> |
| 1835 | <tr class="layout"> |
| 1836 | <td class="left"><tt>\1*</tt></td> |
| 1837 | <td class="left">Self-referential pointer.</td> |
| 1838 | </tr> |
| 1839 | <tr class="layout"> |
| 1840 | <td class="left"><tt>{ { \3*, i8 }, i32 }</tt></td> |
| 1841 | <td class="left">Recursive structure where the upref refers to the out-most |
| 1842 | structure.</td> |
| 1843 | </tr> |
| 1844 | </table> |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1845 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1846 | </div> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1847 | |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1848 | <!-- *********************************************************************** --> |
| 1849 | <div class="doc_section"> <a name="constants">Constants</a> </div> |
| 1850 | <!-- *********************************************************************** --> |
| 1851 | |
| 1852 | <div class="doc_text"> |
| 1853 | |
| 1854 | <p>LLVM has several different basic types of constants. This section describes |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1855 | them all and their syntax.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1856 | |
| 1857 | </div> |
| 1858 | |
| 1859 | <!-- ======================================================================= --> |
Reid Spencer | cc16dc3 | 2004-12-09 18:02:53 +0000 | [diff] [blame] | 1860 | <div class="doc_subsection"><a name="simpleconstants">Simple Constants</a></div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1861 | |
| 1862 | <div class="doc_text"> |
| 1863 | |
| 1864 | <dl> |
| 1865 | <dt><b>Boolean constants</b></dt> |
| 1866 | |
| 1867 | <dd>The two strings '<tt>true</tt>' and '<tt>false</tt>' are both valid |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1868 | constants of the <tt><a href="#t_primitive">i1</a></tt> type.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1869 | |
| 1870 | <dt><b>Integer constants</b></dt> |
| 1871 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1872 | <dd>Standard integers (such as '4') are constants of |
| 1873 | the <a href="#t_integer">integer</a> type. Negative numbers may be used |
| 1874 | with integer types.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1875 | |
| 1876 | <dt><b>Floating point constants</b></dt> |
| 1877 | |
| 1878 | <dd>Floating point constants use standard decimal notation (e.g. 123.421), |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1879 | exponential notation (e.g. 1.23421e+2), or a more precise hexadecimal |
| 1880 | notation (see below). The assembler requires the exact decimal value of a |
| 1881 | floating-point constant. For example, the assembler accepts 1.25 but |
| 1882 | rejects 1.3 because 1.3 is a repeating decimal in binary. Floating point |
| 1883 | constants must have a <a href="#t_floating">floating point</a> type. </dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1884 | |
| 1885 | <dt><b>Null pointer constants</b></dt> |
| 1886 | |
John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 1887 | <dd>The identifier '<tt>null</tt>' is recognized as a null pointer constant |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1888 | and must be of <a href="#t_pointer">pointer type</a>.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1889 | </dl> |
| 1890 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1891 | <p>The one non-intuitive notation for constants is the hexadecimal form of |
| 1892 | floating point constants. For example, the form '<tt>double |
| 1893 | 0x432ff973cafa8000</tt>' is equivalent to (but harder to read than) |
| 1894 | '<tt>double 4.5e+15</tt>'. The only time hexadecimal floating point |
| 1895 | constants are required (and the only time that they are generated by the |
| 1896 | disassembler) is when a floating point constant must be emitted but it cannot |
| 1897 | be represented as a decimal floating point number in a reasonable number of |
| 1898 | digits. For example, NaN's, infinities, and other special values are |
| 1899 | represented in their IEEE hexadecimal format so that assembly and disassembly |
| 1900 | do not cause any bits to change in the constants.</p> |
| 1901 | |
Dale Johannesen | bd5e5a8 | 2009-02-11 22:14:51 +0000 | [diff] [blame] | 1902 | <p>When using the hexadecimal form, constants of types float and double are |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1903 | represented using the 16-digit form shown above (which matches the IEEE754 |
| 1904 | representation for double); float values must, however, be exactly |
| 1905 | representable as IEE754 single precision. Hexadecimal format is always used |
| 1906 | for long double, and there are three forms of long double. The 80-bit format |
| 1907 | used by x86 is represented as <tt>0xK</tt> followed by 20 hexadecimal digits. |
| 1908 | The 128-bit format used by PowerPC (two adjacent doubles) is represented |
| 1909 | by <tt>0xM</tt> followed by 32 hexadecimal digits. The IEEE 128-bit format |
| 1910 | is represented by <tt>0xL</tt> followed by 32 hexadecimal digits; no |
| 1911 | currently supported target uses this format. Long doubles will only work if |
| 1912 | they match the long double format on your target. All hexadecimal formats |
| 1913 | are big-endian (sign bit at the left).</p> |
| 1914 | |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1915 | </div> |
| 1916 | |
| 1917 | <!-- ======================================================================= --> |
Chris Lattner | 7088279 | 2009-02-28 18:32:25 +0000 | [diff] [blame] | 1918 | <div class="doc_subsection"> |
| 1919 | <a name="aggregateconstants"> <!-- old anchor --> |
| 1920 | <a name="complexconstants">Complex Constants</a></a> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1921 | </div> |
| 1922 | |
| 1923 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1924 | |
Chris Lattner | 7088279 | 2009-02-28 18:32:25 +0000 | [diff] [blame] | 1925 | <p>Complex constants are a (potentially recursive) combination of simple |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1926 | constants and smaller complex constants.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1927 | |
| 1928 | <dl> |
| 1929 | <dt><b>Structure constants</b></dt> |
| 1930 | |
| 1931 | <dd>Structure constants are represented with notation similar to structure |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1932 | type definitions (a comma separated list of elements, surrounded by braces |
| 1933 | (<tt>{}</tt>)). For example: "<tt>{ i32 4, float 17.0, i32* @G }</tt>", |
| 1934 | where "<tt>@G</tt>" is declared as "<tt>@G = external global i32</tt>". |
| 1935 | Structure constants must have <a href="#t_struct">structure type</a>, and |
| 1936 | the number and types of elements must match those specified by the |
| 1937 | type.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1938 | |
| 1939 | <dt><b>Array constants</b></dt> |
| 1940 | |
| 1941 | <dd>Array constants are represented with notation similar to array type |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1942 | definitions (a comma separated list of elements, surrounded by square |
| 1943 | brackets (<tt>[]</tt>)). For example: "<tt>[ i32 42, i32 11, i32 74 |
| 1944 | ]</tt>". Array constants must have <a href="#t_array">array type</a>, and |
| 1945 | the number and types of elements must match those specified by the |
| 1946 | type.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1947 | |
Reid Spencer | 485bad1 | 2007-02-15 03:07:05 +0000 | [diff] [blame] | 1948 | <dt><b>Vector constants</b></dt> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1949 | |
Reid Spencer | 485bad1 | 2007-02-15 03:07:05 +0000 | [diff] [blame] | 1950 | <dd>Vector constants are represented with notation similar to vector type |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1951 | definitions (a comma separated list of elements, surrounded by |
| 1952 | less-than/greater-than's (<tt><></tt>)). For example: "<tt>< i32 |
| 1953 | 42, i32 11, i32 74, i32 100 ></tt>". Vector constants must |
| 1954 | have <a href="#t_vector">vector type</a>, and the number and types of |
| 1955 | elements must match those specified by the type.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1956 | |
| 1957 | <dt><b>Zero initialization</b></dt> |
| 1958 | |
| 1959 | <dd>The string '<tt>zeroinitializer</tt>' can be used to zero initialize a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1960 | value to zero of <em>any</em> type, including scalar and aggregate types. |
| 1961 | This is often used to avoid having to print large zero initializers |
| 1962 | (e.g. for large arrays) and is always exactly equivalent to using explicit |
| 1963 | zero initializers.</dd> |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 1964 | |
| 1965 | <dt><b>Metadata node</b></dt> |
| 1966 | |
Nick Lewycky | 1e8c7a6 | 2009-05-30 16:08:30 +0000 | [diff] [blame] | 1967 | <dd>A metadata node is a structure-like constant with |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1968 | <a href="#t_metadata">metadata type</a>. For example: "<tt>metadata !{ |
| 1969 | i32 0, metadata !"test" }</tt>". Unlike other constants that are meant to |
| 1970 | be interpreted as part of the instruction stream, metadata is a place to |
| 1971 | attach additional information such as debug info.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1972 | </dl> |
| 1973 | |
| 1974 | </div> |
| 1975 | |
| 1976 | <!-- ======================================================================= --> |
| 1977 | <div class="doc_subsection"> |
| 1978 | <a name="globalconstants">Global Variable and Function Addresses</a> |
| 1979 | </div> |
| 1980 | |
| 1981 | <div class="doc_text"> |
| 1982 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 1983 | <p>The addresses of <a href="#globalvars">global variables</a> |
| 1984 | and <a href="#functionstructure">functions</a> are always implicitly valid |
| 1985 | (link-time) constants. These constants are explicitly referenced when |
| 1986 | the <a href="#identifiers">identifier for the global</a> is used and always |
| 1987 | have <a href="#t_pointer">pointer</a> type. For example, the following is a |
| 1988 | legal LLVM file:</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1989 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 1990 | <div class="doc_code"> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1991 | <pre> |
Chris Lattner | a18a424 | 2007-06-06 18:28:13 +0000 | [diff] [blame] | 1992 | @X = global i32 17 |
| 1993 | @Y = global i32 42 |
| 1994 | @Z = global [2 x i32*] [ i32* @X, i32* @Y ] |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1995 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 1996 | </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1997 | |
| 1998 | </div> |
| 1999 | |
| 2000 | <!-- ======================================================================= --> |
Reid Spencer | 2dc45b8 | 2004-12-09 18:13:12 +0000 | [diff] [blame] | 2001 | <div class="doc_subsection"><a name="undefvalues">Undefined Values</a></div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2002 | <div class="doc_text"> |
| 2003 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2004 | <p>The string '<tt>undef</tt>' is recognized as a type-less constant that has no |
| 2005 | specific value. Undefined values may be of any type and be used anywhere a |
| 2006 | constant is permitted.</p> |
| 2007 | |
| 2008 | <p>Undefined values indicate to the compiler that the program is well defined no |
| 2009 | matter what value is used, giving the compiler more freedom to optimize.</p> |
| 2010 | |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2011 | </div> |
| 2012 | |
| 2013 | <!-- ======================================================================= --> |
| 2014 | <div class="doc_subsection"><a name="constantexprs">Constant Expressions</a> |
| 2015 | </div> |
| 2016 | |
| 2017 | <div class="doc_text"> |
| 2018 | |
| 2019 | <p>Constant expressions are used to allow expressions involving other constants |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2020 | to be used as constants. Constant expressions may be of |
| 2021 | any <a href="#t_firstclass">first class</a> type and may involve any LLVM |
| 2022 | operation that does not have side effects (e.g. load and call are not |
| 2023 | supported). The following is the syntax for constant expressions:</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2024 | |
| 2025 | <dl> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2026 | <dt><b><tt>trunc ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2027 | |
| 2028 | <dd>Truncate a constant to another type. The bit size of CST must be larger |
| 2029 | than the bit size of TYPE. Both types must be integers.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2030 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2031 | <dt><b><tt>zext ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2032 | |
| 2033 | <dd>Zero extend a constant to another type. The bit size of CST must be |
| 2034 | smaller or equal to the bit size of TYPE. Both types must be |
| 2035 | integers.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2036 | |
| 2037 | <dt><b><tt>sext ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2038 | |
| 2039 | <dd>Sign extend a constant to another type. The bit size of CST must be |
| 2040 | smaller or equal to the bit size of TYPE. Both types must be |
| 2041 | integers.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2042 | |
| 2043 | <dt><b><tt>fptrunc ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2044 | |
| 2045 | <dd>Truncate a floating point constant to another floating point type. The |
| 2046 | size of CST must be larger than the size of TYPE. Both types must be |
| 2047 | floating point.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2048 | |
| 2049 | <dt><b><tt>fpext ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2050 | |
| 2051 | <dd>Floating point extend a constant to another type. The size of CST must be |
| 2052 | smaller or equal to the size of TYPE. Both types must be floating |
| 2053 | point.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2054 | |
Reid Spencer | 1539a1c | 2007-07-31 14:40:14 +0000 | [diff] [blame] | 2055 | <dt><b><tt>fptoui ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2056 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2057 | <dd>Convert a floating point constant to the corresponding unsigned integer |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2058 | constant. TYPE must be a scalar or vector integer type. CST must be of |
| 2059 | scalar or vector floating point type. Both CST and TYPE must be scalars, |
| 2060 | or vectors of the same number of elements. If the value won't fit in the |
| 2061 | integer type, the results are undefined.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2062 | |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 2063 | <dt><b><tt>fptosi ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2064 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2065 | <dd>Convert a floating point constant to the corresponding signed integer |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2066 | constant. TYPE must be a scalar or vector integer type. CST must be of |
| 2067 | scalar or vector floating point type. Both CST and TYPE must be scalars, |
| 2068 | or vectors of the same number of elements. If the value won't fit in the |
| 2069 | integer type, the results are undefined.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2070 | |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 2071 | <dt><b><tt>uitofp ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2072 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2073 | <dd>Convert an unsigned integer constant to the corresponding floating point |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2074 | constant. TYPE must be a scalar or vector floating point type. CST must be |
| 2075 | of scalar or vector integer type. Both CST and TYPE must be scalars, or |
| 2076 | vectors of the same number of elements. If the value won't fit in the |
| 2077 | floating point type, the results are undefined.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2078 | |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 2079 | <dt><b><tt>sitofp ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2080 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2081 | <dd>Convert a signed integer constant to the corresponding floating point |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2082 | constant. TYPE must be a scalar or vector floating point type. CST must be |
| 2083 | of scalar or vector integer type. Both CST and TYPE must be scalars, or |
| 2084 | vectors of the same number of elements. If the value won't fit in the |
| 2085 | floating point type, the results are undefined.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2086 | |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 2087 | <dt><b><tt>ptrtoint ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2088 | |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 2089 | <dd>Convert a pointer typed constant to the corresponding integer constant |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2090 | <tt>TYPE</tt> must be an integer type. <tt>CST</tt> must be of pointer |
| 2091 | type. The <tt>CST</tt> value is zero extended, truncated, or unchanged to |
| 2092 | make it fit in <tt>TYPE</tt>.</dd> |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 2093 | |
| 2094 | <dt><b><tt>inttoptr ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2095 | |
| 2096 | <dd>Convert a integer constant to a pointer constant. TYPE must be a pointer |
| 2097 | type. CST must be of integer type. The CST value is zero extended, |
| 2098 | truncated, or unchanged to make it fit in a pointer size. This one is |
| 2099 | <i>really</i> dangerous!</dd> |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 2100 | |
| 2101 | <dt><b><tt>bitcast ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2102 | |
Chris Lattner | 03bbad6 | 2009-02-28 18:27:03 +0000 | [diff] [blame] | 2103 | <dd>Convert a constant, CST, to another TYPE. The constraints of the operands |
| 2104 | are the same as those for the <a href="#i_bitcast">bitcast |
| 2105 | instruction</a>.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2106 | |
| 2107 | <dt><b><tt>getelementptr ( CSTPTR, IDX0, IDX1, ... )</tt></b></dt> |
| 2108 | |
| 2109 | <dd>Perform the <a href="#i_getelementptr">getelementptr operation</a> on |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2110 | constants. As with the <a href="#i_getelementptr">getelementptr</a> |
| 2111 | instruction, the index list may have zero or more indexes, which are |
| 2112 | required to make sense for the type of "CSTPTR".</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2113 | |
Robert Bocchino | 9fbe145 | 2006-01-10 19:31:34 +0000 | [diff] [blame] | 2114 | <dt><b><tt>select ( COND, VAL1, VAL2 )</tt></b></dt> |
| 2115 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2116 | <dd>Perform the <a href="#i_select">select operation</a> on constants.</dd> |
Reid Spencer | 01c4259 | 2006-12-04 19:23:19 +0000 | [diff] [blame] | 2117 | |
| 2118 | <dt><b><tt>icmp COND ( VAL1, VAL2 )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2119 | |
Reid Spencer | 01c4259 | 2006-12-04 19:23:19 +0000 | [diff] [blame] | 2120 | <dd>Performs the <a href="#i_icmp">icmp operation</a> on constants.</dd> |
| 2121 | |
| 2122 | <dt><b><tt>fcmp COND ( VAL1, VAL2 )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2123 | |
Reid Spencer | 01c4259 | 2006-12-04 19:23:19 +0000 | [diff] [blame] | 2124 | <dd>Performs the <a href="#i_fcmp">fcmp operation</a> on constants.</dd> |
Robert Bocchino | 9fbe145 | 2006-01-10 19:31:34 +0000 | [diff] [blame] | 2125 | |
| 2126 | <dt><b><tt>extractelement ( VAL, IDX )</tt></b></dt> |
| 2127 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2128 | <dd>Perform the <a href="#i_extractelement">extractelement operation</a> on |
| 2129 | constants.</dd> |
Robert Bocchino | 9fbe145 | 2006-01-10 19:31:34 +0000 | [diff] [blame] | 2130 | |
Robert Bocchino | 05ccd70 | 2006-01-15 20:48:27 +0000 | [diff] [blame] | 2131 | <dt><b><tt>insertelement ( VAL, ELT, IDX )</tt></b></dt> |
| 2132 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2133 | <dd>Perform the <a href="#i_insertelement">insertelement operation</a> on |
| 2134 | constants.</dd> |
Chris Lattner | c198954 | 2006-04-08 00:13:41 +0000 | [diff] [blame] | 2135 | |
| 2136 | <dt><b><tt>shufflevector ( VEC1, VEC2, IDXMASK )</tt></b></dt> |
| 2137 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2138 | <dd>Perform the <a href="#i_shufflevector">shufflevector operation</a> on |
| 2139 | constants.</dd> |
Chris Lattner | c198954 | 2006-04-08 00:13:41 +0000 | [diff] [blame] | 2140 | |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2141 | <dt><b><tt>OPCODE ( LHS, RHS )</tt></b></dt> |
| 2142 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2143 | <dd>Perform the specified operation of the LHS and RHS constants. OPCODE may |
| 2144 | be any of the <a href="#binaryops">binary</a> |
| 2145 | or <a href="#bitwiseops">bitwise binary</a> operations. The constraints |
| 2146 | on operands are the same as those for the corresponding instruction |
| 2147 | (e.g. no bitwise operations on floating point values are allowed).</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2148 | </dl> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2149 | |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2150 | </div> |
Chris Lattner | 9ee5d22 | 2004-03-08 16:49:10 +0000 | [diff] [blame] | 2151 | |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2152 | <!-- ======================================================================= --> |
| 2153 | <div class="doc_subsection"><a name="metadata">Embedded Metadata</a> |
| 2154 | </div> |
| 2155 | |
| 2156 | <div class="doc_text"> |
| 2157 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2158 | <p>Embedded metadata provides a way to attach arbitrary data to the instruction |
| 2159 | stream without affecting the behaviour of the program. There are two |
| 2160 | metadata primitives, strings and nodes. All metadata has the |
| 2161 | <tt>metadata</tt> type and is identified in syntax by a preceding exclamation |
| 2162 | point ('<tt>!</tt>').</p> |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2163 | |
| 2164 | <p>A metadata string is a string surrounded by double quotes. It can contain |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2165 | any character by escaping non-printable characters with "\xx" where "xx" is |
| 2166 | the two digit hex code. For example: "<tt>!"test\00"</tt>".</p> |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2167 | |
| 2168 | <p>Metadata nodes are represented with notation similar to structure constants |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2169 | (a comma separated list of elements, surrounded by braces and preceeded by an |
| 2170 | exclamation point). For example: "<tt>!{ metadata !"test\00", i32 |
| 2171 | 10}</tt>".</p> |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2172 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2173 | <p>A metadata node will attempt to track changes to the values it holds. In the |
| 2174 | event that a value is deleted, it will be replaced with a typeless |
| 2175 | "<tt>null</tt>", such as "<tt>metadata !{null, i32 10}</tt>".</p> |
Nick Lewycky | cb33799 | 2009-05-10 20:57:05 +0000 | [diff] [blame] | 2176 | |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2177 | <p>Optimizations may rely on metadata to provide additional information about |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2178 | the program that isn't available in the instructions, or that isn't easily |
| 2179 | computable. Similarly, the code generator may expect a certain metadata |
| 2180 | format to be used to express debugging information.</p> |
| 2181 | |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2182 | </div> |
| 2183 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2184 | <!-- *********************************************************************** --> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2185 | <div class="doc_section"> <a name="othervalues">Other Values</a> </div> |
| 2186 | <!-- *********************************************************************** --> |
| 2187 | |
| 2188 | <!-- ======================================================================= --> |
| 2189 | <div class="doc_subsection"> |
| 2190 | <a name="inlineasm">Inline Assembler Expressions</a> |
| 2191 | </div> |
| 2192 | |
| 2193 | <div class="doc_text"> |
| 2194 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2195 | <p>LLVM supports inline assembler expressions (as opposed |
| 2196 | to <a href="#moduleasm"> Module-Level Inline Assembly</a>) through the use of |
| 2197 | a special value. This value represents the inline assembler as a string |
| 2198 | (containing the instructions to emit), a list of operand constraints (stored |
| 2199 | as a string), and a flag that indicates whether or not the inline asm |
| 2200 | expression has side effects. An example inline assembler expression is:</p> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2201 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2202 | <div class="doc_code"> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2203 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2204 | i32 (i32) asm "bswap $0", "=r,r" |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2205 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2206 | </div> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2207 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2208 | <p>Inline assembler expressions may <b>only</b> be used as the callee operand of |
| 2209 | a <a href="#i_call"><tt>call</tt> instruction</a>. Thus, typically we |
| 2210 | have:</p> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2211 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2212 | <div class="doc_code"> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2213 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2214 | %X = call i32 asm "<a href="#int_bswap">bswap</a> $0", "=r,r"(i32 %Y) |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2215 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2216 | </div> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2217 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2218 | <p>Inline asms with side effects not visible in the constraint list must be |
| 2219 | marked as having side effects. This is done through the use of the |
| 2220 | '<tt>sideeffect</tt>' keyword, like so:</p> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2221 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2222 | <div class="doc_code"> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2223 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2224 | call void asm sideeffect "eieio", ""() |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2225 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2226 | </div> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2227 | |
| 2228 | <p>TODO: The format of the asm and constraints string still need to be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2229 | documented here. Constraints on what can be done (e.g. duplication, moving, |
| 2230 | etc need to be documented). This is probably best done by reference to |
| 2231 | another document that covers inline asm from a holistic perspective.</p> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2232 | |
| 2233 | </div> |
| 2234 | |
| 2235 | <!-- *********************************************************************** --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2236 | <div class="doc_section"> <a name="instref">Instruction Reference</a> </div> |
| 2237 | <!-- *********************************************************************** --> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2238 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2239 | <div class="doc_text"> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2240 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2241 | <p>The LLVM instruction set consists of several different classifications of |
| 2242 | instructions: <a href="#terminators">terminator |
| 2243 | instructions</a>, <a href="#binaryops">binary instructions</a>, |
| 2244 | <a href="#bitwiseops">bitwise binary instructions</a>, |
| 2245 | <a href="#memoryops">memory instructions</a>, and |
| 2246 | <a href="#otherops">other instructions</a>.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2247 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2248 | </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2249 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2250 | <!-- ======================================================================= --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2251 | <div class="doc_subsection"> <a name="terminators">Terminator |
| 2252 | Instructions</a> </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2253 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2254 | <div class="doc_text"> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2255 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2256 | <p>As mentioned <a href="#functionstructure">previously</a>, every basic block |
| 2257 | in a program ends with a "Terminator" instruction, which indicates which |
| 2258 | block should be executed after the current block is finished. These |
| 2259 | terminator instructions typically yield a '<tt>void</tt>' value: they produce |
| 2260 | control flow, not values (the one exception being the |
| 2261 | '<a href="#i_invoke"><tt>invoke</tt></a>' instruction).</p> |
| 2262 | |
| 2263 | <p>There are six different terminator instructions: the |
| 2264 | '<a href="#i_ret"><tt>ret</tt></a>' instruction, the |
| 2265 | '<a href="#i_br"><tt>br</tt></a>' instruction, the |
| 2266 | '<a href="#i_switch"><tt>switch</tt></a>' instruction, the |
| 2267 | '<a href="#i_invoke"><tt>invoke</tt></a>' instruction, the |
| 2268 | '<a href="#i_unwind"><tt>unwind</tt></a>' instruction, and the |
| 2269 | '<a href="#i_unreachable"><tt>unreachable</tt></a>' instruction.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2270 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2271 | </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2272 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2273 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2274 | <div class="doc_subsubsection"> <a name="i_ret">'<tt>ret</tt>' |
| 2275 | Instruction</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2276 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2277 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2278 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2279 | <h5>Syntax:</h5> |
Dan Gohman | b1e6b96 | 2008-10-04 19:00:07 +0000 | [diff] [blame] | 2280 | <pre> |
| 2281 | 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] | 2282 | ret void <i>; Return from void function</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2283 | </pre> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2284 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2285 | <h5>Overview:</h5> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2286 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2287 | <p>The '<tt>ret</tt>' instruction is used to return control flow (and optionally |
| 2288 | a value) from a function back to the caller.</p> |
| 2289 | |
| 2290 | <p>There are two forms of the '<tt>ret</tt>' instruction: one that returns a |
| 2291 | value and then causes control flow, and one that just causes control flow to |
| 2292 | occur.</p> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2293 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2294 | <h5>Arguments:</h5> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2295 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2296 | <p>The '<tt>ret</tt>' instruction optionally accepts a single argument, the |
| 2297 | return value. The type of the return value must be a |
| 2298 | '<a href="#t_firstclass">first class</a>' type.</p> |
Dan Gohman | b1e6b96 | 2008-10-04 19:00:07 +0000 | [diff] [blame] | 2299 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2300 | <p>A function is not <a href="#wellformed">well formed</a> if it it has a |
| 2301 | non-void return type and contains a '<tt>ret</tt>' instruction with no return |
| 2302 | value or a return value with a type that does not match its type, or if it |
| 2303 | has a void return type and contains a '<tt>ret</tt>' instruction with a |
| 2304 | return value.</p> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2305 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2306 | <h5>Semantics:</h5> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2307 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2308 | <p>When the '<tt>ret</tt>' instruction is executed, control flow returns back to |
| 2309 | the calling function's context. If the caller is a |
| 2310 | "<a href="#i_call"><tt>call</tt></a>" instruction, execution continues at the |
| 2311 | instruction after the call. If the caller was an |
| 2312 | "<a href="#i_invoke"><tt>invoke</tt></a>" instruction, execution continues at |
| 2313 | the beginning of the "normal" destination block. If the instruction returns |
| 2314 | a value, that value shall set the call or invoke instruction's return |
| 2315 | value.</p> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2316 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2317 | <h5>Example:</h5> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2318 | |
| 2319 | <pre> |
| 2320 | ret i32 5 <i>; Return an integer value of 5</i> |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 2321 | ret void <i>; Return from a void function</i> |
Bill Wendling | 0a4bbbf | 2009-02-28 22:12:54 +0000 | [diff] [blame] | 2322 | ret { i32, i8 } { i32 4, i8 2 } <i>; Return a struct of values 4 and 2</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2323 | </pre> |
Dan Gohman | f3e60bd | 2009-01-12 23:12:39 +0000 | [diff] [blame] | 2324 | |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 2325 | <p>Note that the code generator does not yet fully support large |
| 2326 | return values. The specific sizes that are currently supported are |
| 2327 | dependent on the target. For integers, on 32-bit targets the limit |
| 2328 | is often 64 bits, and on 64-bit targets the limit is often 128 bits. |
| 2329 | For aggregate types, the current limits are dependent on the element |
| 2330 | types; for example targets are often limited to 2 total integer |
| 2331 | elements and 2 total floating-point elements.</p> |
Dan Gohman | f3e60bd | 2009-01-12 23:12:39 +0000 | [diff] [blame] | 2332 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2333 | </div> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2334 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2335 | <div class="doc_subsubsection"> <a name="i_br">'<tt>br</tt>' Instruction</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2336 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2337 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2338 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2339 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2340 | <pre> |
| 2341 | br i1 <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] | 2342 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2343 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2344 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2345 | <p>The '<tt>br</tt>' instruction is used to cause control flow to transfer to a |
| 2346 | different basic block in the current function. There are two forms of this |
| 2347 | instruction, corresponding to a conditional branch and an unconditional |
| 2348 | branch.</p> |
| 2349 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2350 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2351 | <p>The conditional branch form of the '<tt>br</tt>' instruction takes a single |
| 2352 | '<tt>i1</tt>' value and two '<tt>label</tt>' values. The unconditional form |
| 2353 | of the '<tt>br</tt>' instruction takes a single '<tt>label</tt>' value as a |
| 2354 | target.</p> |
| 2355 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2356 | <h5>Semantics:</h5> |
Reid Spencer | c78f337 | 2007-01-12 03:35:51 +0000 | [diff] [blame] | 2357 | <p>Upon execution of a conditional '<tt>br</tt>' instruction, the '<tt>i1</tt>' |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2358 | argument is evaluated. If the value is <tt>true</tt>, control flows to the |
| 2359 | '<tt>iftrue</tt>' <tt>label</tt> argument. If "cond" is <tt>false</tt>, |
| 2360 | control flows to the '<tt>iffalse</tt>' <tt>label</tt> argument.</p> |
| 2361 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2362 | <h5>Example:</h5> |
Chris Lattner | 60150a3 | 2009-05-09 18:11:50 +0000 | [diff] [blame] | 2363 | <pre>Test:<br> %cond = <a href="#i_icmp">icmp</a> eq i32 %a, %b<br> br i1 %cond, label %IfEqual, label %IfUnequal<br>IfEqual:<br> <a |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 2364 | href="#i_ret">ret</a> i32 1<br>IfUnequal:<br> <a href="#i_ret">ret</a> i32 0<br></pre> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2365 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2366 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2367 | <!-- _______________________________________________________________________ --> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2368 | <div class="doc_subsubsection"> |
| 2369 | <a name="i_switch">'<tt>switch</tt>' Instruction</a> |
| 2370 | </div> |
| 2371 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2372 | <div class="doc_text"> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2373 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2374 | <h5>Syntax:</h5> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2375 | <pre> |
| 2376 | switch <intty> <value>, label <defaultdest> [ <intty> <val>, label <dest> ... ] |
| 2377 | </pre> |
| 2378 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2379 | <h5>Overview:</h5> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2380 | <p>The '<tt>switch</tt>' instruction is used to transfer control flow to one of |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2381 | several different places. It is a generalization of the '<tt>br</tt>' |
| 2382 | instruction, allowing a branch to occur to one of many possible |
| 2383 | destinations.</p> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2384 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2385 | <h5>Arguments:</h5> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2386 | <p>The '<tt>switch</tt>' instruction uses three parameters: an integer |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2387 | comparison value '<tt>value</tt>', a default '<tt>label</tt>' destination, |
| 2388 | and an array of pairs of comparison value constants and '<tt>label</tt>'s. |
| 2389 | The table is not allowed to contain duplicate constant entries.</p> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2390 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2391 | <h5>Semantics:</h5> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2392 | <p>The <tt>switch</tt> instruction specifies a table of values and |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2393 | destinations. When the '<tt>switch</tt>' instruction is executed, this table |
| 2394 | is searched for the given value. If the value is found, control flow is |
| 2395 | transfered to the corresponding destination; otherwise, control flow is |
| 2396 | transfered to the default destination.</p> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2397 | |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2398 | <h5>Implementation:</h5> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2399 | <p>Depending on properties of the target machine and the particular |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2400 | <tt>switch</tt> instruction, this instruction may be code generated in |
| 2401 | different ways. For example, it could be generated as a series of chained |
| 2402 | conditional branches or with a lookup table.</p> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2403 | |
| 2404 | <h5>Example:</h5> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2405 | <pre> |
| 2406 | <i>; Emulate a conditional br instruction</i> |
Reid Spencer | c78f337 | 2007-01-12 03:35:51 +0000 | [diff] [blame] | 2407 | %Val = <a href="#i_zext">zext</a> i1 %value to i32 |
Dan Gohman | 2a08c53 | 2009-01-04 23:44:43 +0000 | [diff] [blame] | 2408 | switch i32 %Val, label %truedest [ i32 0, label %falsedest ] |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2409 | |
| 2410 | <i>; Emulate an unconditional br instruction</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 2411 | switch i32 0, label %dest [ ] |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2412 | |
| 2413 | <i>; Implement a jump table:</i> |
Dan Gohman | 2a08c53 | 2009-01-04 23:44:43 +0000 | [diff] [blame] | 2414 | switch i32 %val, label %otherwise [ i32 0, label %onzero |
| 2415 | i32 1, label %onone |
| 2416 | i32 2, label %ontwo ] |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2417 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2418 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2419 | </div> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2420 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2421 | <!-- _______________________________________________________________________ --> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2422 | <div class="doc_subsubsection"> |
| 2423 | <a name="i_invoke">'<tt>invoke</tt>' Instruction</a> |
| 2424 | </div> |
| 2425 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2426 | <div class="doc_text"> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2427 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2428 | <h5>Syntax:</h5> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2429 | <pre> |
Devang Patel | 307e8ab | 2008-10-07 17:48:33 +0000 | [diff] [blame] | 2430 | <result> = invoke [<a href="#callingconv">cconv</a>] [<a href="#paramattrs">ret attrs</a>] <ptr to function ty> <function ptr val>(<function args>) [<a href="#fnattrs">fn attrs</a>] |
Chris Lattner | 76b8a33 | 2006-05-14 18:23:06 +0000 | [diff] [blame] | 2431 | to label <normal label> unwind label <exception label> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2432 | </pre> |
| 2433 | |
Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 2434 | <h5>Overview:</h5> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2435 | <p>The '<tt>invoke</tt>' instruction causes control to transfer to a specified |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2436 | function, with the possibility of control flow transfer to either the |
| 2437 | '<tt>normal</tt>' label or the '<tt>exception</tt>' label. If the callee |
| 2438 | function returns with the "<tt><a href="#i_ret">ret</a></tt>" instruction, |
| 2439 | control flow will return to the "normal" label. If the callee (or any |
| 2440 | indirect callees) returns with the "<a href="#i_unwind"><tt>unwind</tt></a>" |
| 2441 | instruction, control is interrupted and continued at the dynamically nearest |
| 2442 | "exception" label.</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2443 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2444 | <h5>Arguments:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2445 | <p>This instruction requires several arguments:</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2446 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2447 | <ol> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2448 | <li>The optional "cconv" marker indicates which <a href="#callingconv">calling |
| 2449 | convention</a> the call should use. If none is specified, the call |
| 2450 | defaults to using C calling conventions.</li> |
Devang Patel | f642f47 | 2008-10-06 18:50:38 +0000 | [diff] [blame] | 2451 | |
| 2452 | <li>The optional <a href="#paramattrs">Parameter Attributes</a> list for |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2453 | return values. Only '<tt>zeroext</tt>', '<tt>signext</tt>', and |
| 2454 | '<tt>inreg</tt>' attributes are valid here.</li> |
Devang Patel | f642f47 | 2008-10-06 18:50:38 +0000 | [diff] [blame] | 2455 | |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2456 | <li>'<tt>ptr to function ty</tt>': shall be the signature of the pointer to |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2457 | function value being invoked. In most cases, this is a direct function |
| 2458 | invocation, but indirect <tt>invoke</tt>s are just as possible, branching |
| 2459 | off an arbitrary pointer to function value.</li> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2460 | |
| 2461 | <li>'<tt>function ptr val</tt>': An LLVM value containing a pointer to a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2462 | function to be invoked. </li> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2463 | |
| 2464 | <li>'<tt>function args</tt>': argument list whose types match the function |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2465 | signature argument types. If the function signature indicates the |
| 2466 | function accepts a variable number of arguments, the extra arguments can |
| 2467 | be specified.</li> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2468 | |
| 2469 | <li>'<tt>normal label</tt>': the label reached when the called function |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2470 | executes a '<tt><a href="#i_ret">ret</a></tt>' instruction. </li> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2471 | |
| 2472 | <li>'<tt>exception label</tt>': the label reached when a callee returns with |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2473 | the <a href="#i_unwind"><tt>unwind</tt></a> instruction. </li> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2474 | |
Devang Patel | 307e8ab | 2008-10-07 17:48:33 +0000 | [diff] [blame] | 2475 | <li>The optional <a href="#fnattrs">function attributes</a> list. Only |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2476 | '<tt>noreturn</tt>', '<tt>nounwind</tt>', '<tt>readonly</tt>' and |
| 2477 | '<tt>readnone</tt>' attributes are valid here.</li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2478 | </ol> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2479 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2480 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2481 | <p>This instruction is designed to operate as a standard |
| 2482 | '<tt><a href="#i_call">call</a></tt>' instruction in most regards. The |
| 2483 | primary difference is that it establishes an association with a label, which |
| 2484 | is used by the runtime library to unwind the stack.</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2485 | |
| 2486 | <p>This instruction is used in languages with destructors to ensure that proper |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2487 | cleanup is performed in the case of either a <tt>longjmp</tt> or a thrown |
| 2488 | exception. Additionally, this is important for implementation of |
| 2489 | '<tt>catch</tt>' clauses in high-level languages that support them.</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2490 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2491 | <p>For the purposes of the SSA form, the definition of the value returned by the |
| 2492 | '<tt>invoke</tt>' instruction is deemed to occur on the edge from the current |
| 2493 | block to the "normal" label. If the callee unwinds then no return value is |
| 2494 | available.</p> |
Dan Gohman | f96a499 | 2009-05-22 21:47:08 +0000 | [diff] [blame] | 2495 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2496 | <h5>Example:</h5> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2497 | <pre> |
Nick Lewycky | d703f65 | 2008-03-16 07:18:12 +0000 | [diff] [blame] | 2498 | %retval = invoke i32 @Test(i32 15) to label %Continue |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 2499 | unwind label %TestCleanup <i>; {i32}:retval set</i> |
Nick Lewycky | d703f65 | 2008-03-16 07:18:12 +0000 | [diff] [blame] | 2500 | %retval = invoke <a href="#callingconv">coldcc</a> i32 %Testfnptr(i32 15) to label %Continue |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 2501 | unwind label %TestCleanup <i>; {i32}:retval set</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2502 | </pre> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2503 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2504 | </div> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2505 | |
Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 2506 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2507 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2508 | <div class="doc_subsubsection"> <a name="i_unwind">'<tt>unwind</tt>' |
| 2509 | Instruction</a> </div> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2510 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2511 | <div class="doc_text"> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2512 | |
Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 2513 | <h5>Syntax:</h5> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2514 | <pre> |
| 2515 | unwind |
| 2516 | </pre> |
| 2517 | |
Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 2518 | <h5>Overview:</h5> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2519 | <p>The '<tt>unwind</tt>' instruction unwinds the stack, continuing control flow |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2520 | at the first callee in the dynamic call stack which used |
| 2521 | an <a href="#i_invoke"><tt>invoke</tt></a> instruction to perform the call. |
| 2522 | This is primarily used to implement exception handling.</p> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2523 | |
Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 2524 | <h5>Semantics:</h5> |
Chris Lattner | 72ed200 | 2008-04-19 21:01:16 +0000 | [diff] [blame] | 2525 | <p>The '<tt>unwind</tt>' instruction causes execution of the current function to |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2526 | immediately halt. The dynamic call stack is then searched for the |
| 2527 | first <a href="#i_invoke"><tt>invoke</tt></a> instruction on the call stack. |
| 2528 | Once found, execution continues at the "exceptional" destination block |
| 2529 | specified by the <tt>invoke</tt> instruction. If there is no <tt>invoke</tt> |
| 2530 | instruction in the dynamic call chain, undefined behavior results.</p> |
| 2531 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2532 | </div> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2533 | |
| 2534 | <!-- _______________________________________________________________________ --> |
| 2535 | |
| 2536 | <div class="doc_subsubsection"> <a name="i_unreachable">'<tt>unreachable</tt>' |
| 2537 | Instruction</a> </div> |
| 2538 | |
| 2539 | <div class="doc_text"> |
| 2540 | |
| 2541 | <h5>Syntax:</h5> |
| 2542 | <pre> |
| 2543 | unreachable |
| 2544 | </pre> |
| 2545 | |
| 2546 | <h5>Overview:</h5> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2547 | <p>The '<tt>unreachable</tt>' instruction has no defined semantics. This |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2548 | instruction is used to inform the optimizer that a particular portion of the |
| 2549 | code is not reachable. This can be used to indicate that the code after a |
| 2550 | no-return function cannot be reached, and other facts.</p> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2551 | |
| 2552 | <h5>Semantics:</h5> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2553 | <p>The '<tt>unreachable</tt>' instruction has no defined semantics.</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2554 | |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2555 | </div> |
| 2556 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2557 | <!-- ======================================================================= --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2558 | <div class="doc_subsection"> <a name="binaryops">Binary Operations</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2559 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2560 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2561 | |
| 2562 | <p>Binary operators are used to do most of the computation in a program. They |
| 2563 | require two operands of the same type, execute an operation on them, and |
| 2564 | produce a single value. The operands might represent multiple data, as is |
| 2565 | the case with the <a href="#t_vector">vector</a> data type. The result value |
| 2566 | has the same type as its operands.</p> |
| 2567 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2568 | <p>There are several different binary operators:</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2569 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2570 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2571 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2572 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2573 | <div class="doc_subsubsection"> |
| 2574 | <a name="i_add">'<tt>add</tt>' Instruction</a> |
| 2575 | </div> |
| 2576 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2577 | <div class="doc_text"> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2578 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2579 | <h5>Syntax:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2580 | <pre> |
Gabor Greif | fb224a2 | 2008-08-07 21:46:00 +0000 | [diff] [blame] | 2581 | <result> = add <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2582 | </pre> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2583 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2584 | <h5>Overview:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2585 | <p>The '<tt>add</tt>' instruction returns the sum of its two operands.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2586 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2587 | <h5>Arguments:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2588 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2589 | <p>The two arguments to the '<tt>add</tt>' instruction must |
| 2590 | be <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of |
| 2591 | integer values. Both arguments must have identical types.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2592 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2593 | <h5>Semantics:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2594 | <p>The value produced is the integer sum of the two operands.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2595 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2596 | <p>If the sum has unsigned overflow, the result returned is the mathematical |
| 2597 | result modulo 2<sup>n</sup>, where n is the bit width of the result.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2598 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2599 | <p>Because LLVM integers use a two's complement representation, this instruction |
| 2600 | is appropriate for both signed and unsigned integers.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2601 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2602 | <h5>Example:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2603 | <pre> |
| 2604 | <result> = add i32 4, %var <i>; yields {i32}:result = 4 + %var</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2605 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2606 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2607 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2608 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2609 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2610 | <div class="doc_subsubsection"> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2611 | <a name="i_fadd">'<tt>fadd</tt>' Instruction</a> |
| 2612 | </div> |
| 2613 | |
| 2614 | <div class="doc_text"> |
| 2615 | |
| 2616 | <h5>Syntax:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2617 | <pre> |
| 2618 | <result> = fadd <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
| 2619 | </pre> |
| 2620 | |
| 2621 | <h5>Overview:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2622 | <p>The '<tt>fadd</tt>' instruction returns the sum of its two operands.</p> |
| 2623 | |
| 2624 | <h5>Arguments:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2625 | <p>The two arguments to the '<tt>fadd</tt>' instruction must be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2626 | <a href="#t_floating">floating point</a> or <a href="#t_vector">vector</a> of |
| 2627 | floating point values. Both arguments must have identical types.</p> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2628 | |
| 2629 | <h5>Semantics:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2630 | <p>The value produced is the floating point sum of the two operands.</p> |
| 2631 | |
| 2632 | <h5>Example:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2633 | <pre> |
| 2634 | <result> = fadd float 4.0, %var <i>; yields {float}:result = 4.0 + %var</i> |
| 2635 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2636 | |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2637 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2638 | |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2639 | <!-- _______________________________________________________________________ --> |
| 2640 | <div class="doc_subsubsection"> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2641 | <a name="i_sub">'<tt>sub</tt>' Instruction</a> |
| 2642 | </div> |
| 2643 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2644 | <div class="doc_text"> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2645 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2646 | <h5>Syntax:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2647 | <pre> |
Gabor Greif | fb224a2 | 2008-08-07 21:46:00 +0000 | [diff] [blame] | 2648 | <result> = sub <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2649 | </pre> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2650 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2651 | <h5>Overview:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2652 | <p>The '<tt>sub</tt>' instruction returns the difference of its two |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2653 | operands.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2654 | |
| 2655 | <p>Note that the '<tt>sub</tt>' instruction is used to represent the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2656 | '<tt>neg</tt>' instruction present in most other intermediate |
| 2657 | representations.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2658 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2659 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2660 | <p>The two arguments to the '<tt>sub</tt>' instruction must |
| 2661 | be <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of |
| 2662 | integer values. Both arguments must have identical types.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2663 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2664 | <h5>Semantics:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2665 | <p>The value produced is the integer difference of the two operands.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2666 | |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2667 | <p>If the difference has unsigned overflow, the result returned is the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2668 | mathematical result modulo 2<sup>n</sup>, where n is the bit width of the |
| 2669 | result.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2670 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2671 | <p>Because LLVM integers use a two's complement representation, this instruction |
| 2672 | is appropriate for both signed and unsigned integers.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2673 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2674 | <h5>Example:</h5> |
Bill Wendling | aac388b | 2007-05-29 09:42:13 +0000 | [diff] [blame] | 2675 | <pre> |
| 2676 | <result> = sub i32 4, %var <i>; yields {i32}:result = 4 - %var</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 2677 | <result> = sub i32 0, %val <i>; yields {i32}:result = -%var</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2678 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2679 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2680 | </div> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2681 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2682 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2683 | <div class="doc_subsubsection"> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2684 | <a name="i_fsub">'<tt>fsub</tt>' Instruction</a> |
| 2685 | </div> |
| 2686 | |
| 2687 | <div class="doc_text"> |
| 2688 | |
| 2689 | <h5>Syntax:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2690 | <pre> |
| 2691 | <result> = fsub <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
| 2692 | </pre> |
| 2693 | |
| 2694 | <h5>Overview:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2695 | <p>The '<tt>fsub</tt>' instruction returns the difference of its two |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2696 | operands.</p> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2697 | |
| 2698 | <p>Note that the '<tt>fsub</tt>' instruction is used to represent the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2699 | '<tt>fneg</tt>' instruction present in most other intermediate |
| 2700 | representations.</p> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2701 | |
| 2702 | <h5>Arguments:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2703 | <p>The two arguments to the '<tt>fsub</tt>' instruction must be <a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2704 | <a href="#t_floating">floating point</a> or <a href="#t_vector">vector</a> of |
| 2705 | floating point values. Both arguments must have identical types.</p> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2706 | |
| 2707 | <h5>Semantics:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2708 | <p>The value produced is the floating point difference of the two operands.</p> |
| 2709 | |
| 2710 | <h5>Example:</h5> |
| 2711 | <pre> |
| 2712 | <result> = fsub float 4.0, %var <i>; yields {float}:result = 4.0 - %var</i> |
| 2713 | <result> = fsub float -0.0, %val <i>; yields {float}:result = -%var</i> |
| 2714 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2715 | |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2716 | </div> |
| 2717 | |
| 2718 | <!-- _______________________________________________________________________ --> |
| 2719 | <div class="doc_subsubsection"> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2720 | <a name="i_mul">'<tt>mul</tt>' Instruction</a> |
| 2721 | </div> |
| 2722 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2723 | <div class="doc_text"> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2724 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2725 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2726 | <pre> |
| 2727 | <result> = mul <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2728 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2729 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2730 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2731 | <p>The '<tt>mul</tt>' instruction returns the product of its two operands.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2732 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2733 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2734 | <p>The two arguments to the '<tt>mul</tt>' instruction must |
| 2735 | be <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of |
| 2736 | integer values. Both arguments must have identical types.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2737 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2738 | <h5>Semantics:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2739 | <p>The value produced is the integer product of the two operands.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2740 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2741 | <p>If the result of the multiplication has unsigned overflow, the result |
| 2742 | returned is the mathematical result modulo 2<sup>n</sup>, where n is the bit |
| 2743 | width of the result.</p> |
| 2744 | |
| 2745 | <p>Because LLVM integers use a two's complement representation, and the result |
| 2746 | is the same width as the operands, this instruction returns the correct |
| 2747 | result for both signed and unsigned integers. If a full product |
| 2748 | (e.g. <tt>i32</tt>x<tt>i32</tt>-><tt>i64</tt>) is needed, the operands should |
| 2749 | be sign-extended or zero-extended as appropriate to the width of the full |
| 2750 | product.</p> |
| 2751 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2752 | <h5>Example:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2753 | <pre> |
| 2754 | <result> = mul i32 4, %var <i>; yields {i32}:result = 4 * %var</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2755 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2756 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2757 | </div> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2758 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2759 | <!-- _______________________________________________________________________ --> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2760 | <div class="doc_subsubsection"> |
| 2761 | <a name="i_fmul">'<tt>fmul</tt>' Instruction</a> |
| 2762 | </div> |
| 2763 | |
| 2764 | <div class="doc_text"> |
| 2765 | |
| 2766 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2767 | <pre> |
| 2768 | <result> = fmul <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2769 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2770 | |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2771 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2772 | <p>The '<tt>fmul</tt>' instruction returns the product of its two operands.</p> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2773 | |
| 2774 | <h5>Arguments:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2775 | <p>The two arguments to the '<tt>fmul</tt>' instruction must be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2776 | <a href="#t_floating">floating point</a> or <a href="#t_vector">vector</a> of |
| 2777 | floating point values. Both arguments must have identical types.</p> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2778 | |
| 2779 | <h5>Semantics:</h5> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2780 | <p>The value produced is the floating point product of the two operands.</p> |
| 2781 | |
| 2782 | <h5>Example:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2783 | <pre> |
| 2784 | <result> = fmul float 4.0, %var <i>; yields {float}:result = 4.0 * %var</i> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2785 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2786 | |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 2787 | </div> |
| 2788 | |
| 2789 | <!-- _______________________________________________________________________ --> |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2790 | <div class="doc_subsubsection"> <a name="i_udiv">'<tt>udiv</tt>' Instruction |
| 2791 | </a></div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2792 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2793 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2794 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2795 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2796 | <pre> |
| 2797 | <result> = udiv <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2798 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2799 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2800 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2801 | <p>The '<tt>udiv</tt>' instruction returns the quotient of its two operands.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2802 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2803 | <h5>Arguments:</h5> |
| 2804 | <p>The two arguments to the '<tt>udiv</tt>' instruction must be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2805 | <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of integer |
| 2806 | values. Both arguments must have identical types.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2807 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2808 | <h5>Semantics:</h5> |
Chris Lattner | 5ec8983 | 2008-01-28 00:36:27 +0000 | [diff] [blame] | 2809 | <p>The value produced is the unsigned integer quotient of the two operands.</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2810 | |
Chris Lattner | 5ec8983 | 2008-01-28 00:36:27 +0000 | [diff] [blame] | 2811 | <p>Note that unsigned integer division and signed integer division are distinct |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2812 | operations; for signed integer division, use '<tt>sdiv</tt>'.</p> |
| 2813 | |
Chris Lattner | 5ec8983 | 2008-01-28 00:36:27 +0000 | [diff] [blame] | 2814 | <p>Division by zero leads to undefined behavior.</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2815 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2816 | <h5>Example:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2817 | <pre> |
| 2818 | <result> = udiv i32 4, %var <i>; yields {i32}:result = 4 / %var</i> |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2819 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2820 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2821 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2822 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2823 | <!-- _______________________________________________________________________ --> |
| 2824 | <div class="doc_subsubsection"> <a name="i_sdiv">'<tt>sdiv</tt>' Instruction |
| 2825 | </a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2826 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2827 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2828 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2829 | <h5>Syntax:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2830 | <pre> |
Gabor Greif | fb224a2 | 2008-08-07 21:46:00 +0000 | [diff] [blame] | 2831 | <result> = sdiv <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2832 | </pre> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2833 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2834 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2835 | <p>The '<tt>sdiv</tt>' instruction returns the quotient of its two operands.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2836 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2837 | <h5>Arguments:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2838 | <p>The two arguments to the '<tt>sdiv</tt>' instruction must be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2839 | <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of integer |
| 2840 | values. Both arguments must have identical types.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2841 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2842 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2843 | <p>The value produced is the signed integer quotient of the two operands rounded |
| 2844 | towards zero.</p> |
| 2845 | |
Chris Lattner | 5ec8983 | 2008-01-28 00:36:27 +0000 | [diff] [blame] | 2846 | <p>Note that signed integer division and unsigned integer division are distinct |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2847 | operations; for unsigned integer division, use '<tt>udiv</tt>'.</p> |
| 2848 | |
Chris Lattner | 5ec8983 | 2008-01-28 00:36:27 +0000 | [diff] [blame] | 2849 | <p>Division by zero leads to undefined behavior. Overflow also leads to |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2850 | undefined behavior; this is a rare case, but can occur, for example, by doing |
| 2851 | a 32-bit division of -2147483648 by -1.</p> |
| 2852 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2853 | <h5>Example:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2854 | <pre> |
| 2855 | <result> = sdiv i32 4, %var <i>; yields {i32}:result = 4 / %var</i> |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2856 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2857 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2858 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2859 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2860 | <!-- _______________________________________________________________________ --> |
| 2861 | <div class="doc_subsubsection"> <a name="i_fdiv">'<tt>fdiv</tt>' |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2862 | Instruction</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2863 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2864 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2865 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2866 | <h5>Syntax:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2867 | <pre> |
Gabor Greif | fb224a2 | 2008-08-07 21:46:00 +0000 | [diff] [blame] | 2868 | <result> = fdiv <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2869 | </pre> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2870 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2871 | <h5>Overview:</h5> |
| 2872 | <p>The '<tt>fdiv</tt>' instruction returns the quotient of its two operands.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2873 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2874 | <h5>Arguments:</h5> |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 2875 | <p>The two arguments to the '<tt>fdiv</tt>' instruction must be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2876 | <a href="#t_floating">floating point</a> or <a href="#t_vector">vector</a> of |
| 2877 | floating point values. Both arguments must have identical types.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2878 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2879 | <h5>Semantics:</h5> |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2880 | <p>The value produced is the floating point quotient of the two operands.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2881 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2882 | <h5>Example:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2883 | <pre> |
| 2884 | <result> = fdiv float 4.0, %var <i>; yields {float}:result = 4.0 / %var</i> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2885 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2886 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2887 | </div> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2888 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2889 | <!-- _______________________________________________________________________ --> |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2890 | <div class="doc_subsubsection"> <a name="i_urem">'<tt>urem</tt>' Instruction</a> |
| 2891 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2892 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2893 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2894 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2895 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2896 | <pre> |
| 2897 | <result> = urem <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2898 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2899 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2900 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2901 | <p>The '<tt>urem</tt>' instruction returns the remainder from the unsigned |
| 2902 | division of its two arguments.</p> |
| 2903 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2904 | <h5>Arguments:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2905 | <p>The two arguments to the '<tt>urem</tt>' instruction must be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2906 | <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of integer |
| 2907 | values. Both arguments must have identical types.</p> |
| 2908 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2909 | <h5>Semantics:</h5> |
| 2910 | <p>This instruction returns the unsigned integer <i>remainder</i> of a division. |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2911 | This instruction always performs an unsigned division to get the |
| 2912 | remainder.</p> |
| 2913 | |
Chris Lattner | 5ec8983 | 2008-01-28 00:36:27 +0000 | [diff] [blame] | 2914 | <p>Note that unsigned integer remainder and signed integer remainder are |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2915 | distinct operations; for signed integer remainder, use '<tt>srem</tt>'.</p> |
| 2916 | |
Chris Lattner | 5ec8983 | 2008-01-28 00:36:27 +0000 | [diff] [blame] | 2917 | <p>Taking the remainder of a division by zero leads to undefined behavior.</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2918 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2919 | <h5>Example:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2920 | <pre> |
| 2921 | <result> = urem i32 4, %var <i>; yields {i32}:result = 4 % %var</i> |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2922 | </pre> |
| 2923 | |
| 2924 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2925 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2926 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2927 | <div class="doc_subsubsection"> |
| 2928 | <a name="i_srem">'<tt>srem</tt>' Instruction</a> |
| 2929 | </div> |
| 2930 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2931 | <div class="doc_text"> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2932 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2933 | <h5>Syntax:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2934 | <pre> |
Gabor Greif | fb224a2 | 2008-08-07 21:46:00 +0000 | [diff] [blame] | 2935 | <result> = srem <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2936 | </pre> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2937 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2938 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2939 | <p>The '<tt>srem</tt>' instruction returns the remainder from the signed |
| 2940 | division of its two operands. This instruction can also take |
| 2941 | <a href="#t_vector">vector</a> versions of the values in which case the |
| 2942 | elements must be integers.</p> |
Chris Lattner | c7d3ab3 | 2008-01-04 04:33:49 +0000 | [diff] [blame] | 2943 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2944 | <h5>Arguments:</h5> |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2945 | <p>The two arguments to the '<tt>srem</tt>' instruction must be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2946 | <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of integer |
| 2947 | values. Both arguments must have identical types.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2948 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2949 | <h5>Semantics:</h5> |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2950 | <p>This instruction returns the <i>remainder</i> of a division (where the result |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2951 | has the same sign as the dividend, <tt>op1</tt>), not the <i>modulo</i> |
| 2952 | operator (where the result has the same sign as the divisor, <tt>op2</tt>) of |
| 2953 | a value. For more information about the difference, |
| 2954 | see <a href="http://mathforum.org/dr.math/problems/anne.4.28.99.html">The |
| 2955 | Math Forum</a>. For a table of how this is implemented in various languages, |
| 2956 | please see <a href="http://en.wikipedia.org/wiki/Modulo_operation"> |
| 2957 | Wikipedia: modulo operation</a>.</p> |
| 2958 | |
Chris Lattner | 5ec8983 | 2008-01-28 00:36:27 +0000 | [diff] [blame] | 2959 | <p>Note that signed integer remainder and unsigned integer remainder are |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2960 | distinct operations; for unsigned integer remainder, use '<tt>urem</tt>'.</p> |
| 2961 | |
Chris Lattner | 5ec8983 | 2008-01-28 00:36:27 +0000 | [diff] [blame] | 2962 | <p>Taking the remainder of a division by zero leads to undefined behavior. |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2963 | Overflow also leads to undefined behavior; this is a rare case, but can |
| 2964 | occur, for example, by taking the remainder of a 32-bit division of |
| 2965 | -2147483648 by -1. (The remainder doesn't actually overflow, but this rule |
| 2966 | lets srem be implemented using instructions that return both the result of |
| 2967 | the division and the remainder.)</p> |
| 2968 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2969 | <h5>Example:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2970 | <pre> |
| 2971 | <result> = srem i32 4, %var <i>; yields {i32}:result = 4 % %var</i> |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2972 | </pre> |
| 2973 | |
| 2974 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2975 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2976 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2977 | <div class="doc_subsubsection"> |
| 2978 | <a name="i_frem">'<tt>frem</tt>' Instruction</a> </div> |
| 2979 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2980 | <div class="doc_text"> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2981 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2982 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2983 | <pre> |
| 2984 | <result> = frem <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2985 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2986 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2987 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2988 | <p>The '<tt>frem</tt>' instruction returns the remainder from the division of |
| 2989 | its two operands.</p> |
| 2990 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2991 | <h5>Arguments:</h5> |
| 2992 | <p>The two arguments to the '<tt>frem</tt>' instruction must be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2993 | <a href="#t_floating">floating point</a> or <a href="#t_vector">vector</a> of |
| 2994 | floating point values. Both arguments must have identical types.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2995 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 2996 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 2997 | <p>This instruction returns the <i>remainder</i> of a division. The remainder |
| 2998 | has the same sign as the dividend.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2999 | |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 3000 | <h5>Example:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3001 | <pre> |
| 3002 | <result> = frem float 4.0, %var <i>; yields {float}:result = 4.0 % %var</i> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 3003 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3004 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3005 | </div> |
Robert Bocchino | 7b81c75 | 2006-02-17 21:18:08 +0000 | [diff] [blame] | 3006 | |
Reid Spencer | 8e11bf8 | 2007-02-02 13:57:07 +0000 | [diff] [blame] | 3007 | <!-- ======================================================================= --> |
| 3008 | <div class="doc_subsection"> <a name="bitwiseops">Bitwise Binary |
| 3009 | Operations</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3010 | |
Reid Spencer | 8e11bf8 | 2007-02-02 13:57:07 +0000 | [diff] [blame] | 3011 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3012 | |
| 3013 | <p>Bitwise binary operators are used to do various forms of bit-twiddling in a |
| 3014 | program. They are generally very efficient instructions and can commonly be |
| 3015 | strength reduced from other instructions. They require two operands of the |
| 3016 | same type, execute an operation on them, and produce a single value. The |
| 3017 | resulting value is the same type as its operands.</p> |
| 3018 | |
Reid Spencer | 8e11bf8 | 2007-02-02 13:57:07 +0000 | [diff] [blame] | 3019 | </div> |
| 3020 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3021 | <!-- _______________________________________________________________________ --> |
| 3022 | <div class="doc_subsubsection"> <a name="i_shl">'<tt>shl</tt>' |
| 3023 | Instruction</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3024 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3025 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3026 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3027 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3028 | <pre> |
| 3029 | <result> = shl <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3030 | </pre> |
Chris Lattner | 6ccc2d5 | 2007-10-03 21:01:14 +0000 | [diff] [blame] | 3031 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3032 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3033 | <p>The '<tt>shl</tt>' instruction returns the first operand shifted to the left |
| 3034 | a specified number of bits.</p> |
Chris Lattner | 6ccc2d5 | 2007-10-03 21:01:14 +0000 | [diff] [blame] | 3035 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3036 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3037 | <p>Both arguments to the '<tt>shl</tt>' instruction must be the |
| 3038 | same <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of |
| 3039 | integer type. '<tt>op2</tt>' is treated as an unsigned value.</p> |
Chris Lattner | 6ccc2d5 | 2007-10-03 21:01:14 +0000 | [diff] [blame] | 3040 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3041 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3042 | <p>The value produced is <tt>op1</tt> * 2<sup><tt>op2</tt></sup> mod |
| 3043 | 2<sup>n</sup>, where <tt>n</tt> is the width of the result. If <tt>op2</tt> |
| 3044 | is (statically or dynamically) negative or equal to or larger than the number |
| 3045 | of bits in <tt>op1</tt>, the result is undefined. If the arguments are |
| 3046 | vectors, each vector element of <tt>op1</tt> is shifted by the corresponding |
| 3047 | shift amount in <tt>op2</tt>.</p> |
Chris Lattner | 6ccc2d5 | 2007-10-03 21:01:14 +0000 | [diff] [blame] | 3048 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3049 | <h5>Example:</h5> |
| 3050 | <pre> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3051 | <result> = shl i32 4, %var <i>; yields {i32}: 4 << %var</i> |
| 3052 | <result> = shl i32 4, 2 <i>; yields {i32}: 16</i> |
| 3053 | <result> = shl i32 1, 10 <i>; yields {i32}: 1024</i> |
Chris Lattner | 6ccc2d5 | 2007-10-03 21:01:14 +0000 | [diff] [blame] | 3054 | <result> = shl i32 1, 32 <i>; undefined</i> |
Mon P Wang | e9f1015 | 2008-12-09 05:46:39 +0000 | [diff] [blame] | 3055 | <result> = shl <2 x i32> < i32 1, i32 1>, < i32 1, i32 2> <i>; yields: result=<2 x i32> < i32 2, i32 4></i> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3056 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3057 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3058 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3059 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3060 | <!-- _______________________________________________________________________ --> |
| 3061 | <div class="doc_subsubsection"> <a name="i_lshr">'<tt>lshr</tt>' |
| 3062 | Instruction</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3063 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3064 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3065 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3066 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3067 | <pre> |
| 3068 | <result> = lshr <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3069 | </pre> |
| 3070 | |
| 3071 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3072 | <p>The '<tt>lshr</tt>' instruction (logical shift right) returns the first |
| 3073 | operand shifted to the right a specified number of bits with zero fill.</p> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3074 | |
| 3075 | <h5>Arguments:</h5> |
| 3076 | <p>Both arguments to the '<tt>lshr</tt>' instruction must be the same |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3077 | <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of integer |
| 3078 | type. '<tt>op2</tt>' is treated as an unsigned value.</p> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3079 | |
| 3080 | <h5>Semantics:</h5> |
| 3081 | <p>This instruction always performs a logical shift right operation. The most |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3082 | significant bits of the result will be filled with zero bits after the shift. |
| 3083 | If <tt>op2</tt> is (statically or dynamically) equal to or larger than the |
| 3084 | number of bits in <tt>op1</tt>, the result is undefined. If the arguments are |
| 3085 | vectors, each vector element of <tt>op1</tt> is shifted by the corresponding |
| 3086 | shift amount in <tt>op2</tt>.</p> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3087 | |
| 3088 | <h5>Example:</h5> |
| 3089 | <pre> |
| 3090 | <result> = lshr i32 4, 1 <i>; yields {i32}:result = 2</i> |
| 3091 | <result> = lshr i32 4, 2 <i>; yields {i32}:result = 1</i> |
| 3092 | <result> = lshr i8 4, 3 <i>; yields {i8}:result = 0</i> |
| 3093 | <result> = lshr i8 -2, 1 <i>; yields {i8}:result = 0x7FFFFFFF </i> |
Chris Lattner | 6ccc2d5 | 2007-10-03 21:01:14 +0000 | [diff] [blame] | 3094 | <result> = lshr i32 1, 32 <i>; undefined</i> |
Mon P Wang | e9f1015 | 2008-12-09 05:46:39 +0000 | [diff] [blame] | 3095 | <result> = lshr <2 x i32> < i32 -2, i32 4>, < i32 1, i32 2> <i>; yields: result=<2 x i32> < i32 0x7FFFFFFF, i32 1></i> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3096 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3097 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3098 | </div> |
| 3099 | |
Reid Spencer | 8e11bf8 | 2007-02-02 13:57:07 +0000 | [diff] [blame] | 3100 | <!-- _______________________________________________________________________ --> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3101 | <div class="doc_subsubsection"> <a name="i_ashr">'<tt>ashr</tt>' |
| 3102 | Instruction</a> </div> |
| 3103 | <div class="doc_text"> |
| 3104 | |
| 3105 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3106 | <pre> |
| 3107 | <result> = ashr <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3108 | </pre> |
| 3109 | |
| 3110 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3111 | <p>The '<tt>ashr</tt>' instruction (arithmetic shift right) returns the first |
| 3112 | operand shifted to the right a specified number of bits with sign |
| 3113 | extension.</p> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3114 | |
| 3115 | <h5>Arguments:</h5> |
| 3116 | <p>Both arguments to the '<tt>ashr</tt>' instruction must be the same |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3117 | <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of integer |
| 3118 | type. '<tt>op2</tt>' is treated as an unsigned value.</p> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3119 | |
| 3120 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3121 | <p>This instruction always performs an arithmetic shift right operation, The |
| 3122 | most significant bits of the result will be filled with the sign bit |
| 3123 | of <tt>op1</tt>. If <tt>op2</tt> is (statically or dynamically) equal to or |
| 3124 | larger than the number of bits in <tt>op1</tt>, the result is undefined. If |
| 3125 | the arguments are vectors, each vector element of <tt>op1</tt> is shifted by |
| 3126 | the corresponding shift amount in <tt>op2</tt>.</p> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3127 | |
| 3128 | <h5>Example:</h5> |
| 3129 | <pre> |
| 3130 | <result> = ashr i32 4, 1 <i>; yields {i32}:result = 2</i> |
| 3131 | <result> = ashr i32 4, 2 <i>; yields {i32}:result = 1</i> |
| 3132 | <result> = ashr i8 4, 3 <i>; yields {i8}:result = 0</i> |
| 3133 | <result> = ashr i8 -2, 1 <i>; yields {i8}:result = -1</i> |
Chris Lattner | 6ccc2d5 | 2007-10-03 21:01:14 +0000 | [diff] [blame] | 3134 | <result> = ashr i32 1, 32 <i>; undefined</i> |
Mon P Wang | e9f1015 | 2008-12-09 05:46:39 +0000 | [diff] [blame] | 3135 | <result> = ashr <2 x i32> < i32 -2, i32 4>, < i32 1, i32 3> <i>; yields: result=<2 x i32> < i32 -1, i32 0></i> |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3136 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3137 | |
Reid Spencer | 569f2fa | 2007-01-31 21:39:12 +0000 | [diff] [blame] | 3138 | </div> |
| 3139 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3140 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 3141 | <div class="doc_subsubsection"> <a name="i_and">'<tt>and</tt>' |
| 3142 | Instruction</a> </div> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3143 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3144 | <div class="doc_text"> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3145 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3146 | <h5>Syntax:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3147 | <pre> |
Gabor Greif | fb224a2 | 2008-08-07 21:46:00 +0000 | [diff] [blame] | 3148 | <result> = and <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3149 | </pre> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3150 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3151 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3152 | <p>The '<tt>and</tt>' instruction returns the bitwise logical and of its two |
| 3153 | operands.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3154 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3155 | <h5>Arguments:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3156 | <p>The two arguments to the '<tt>and</tt>' instruction must be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3157 | <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of integer |
| 3158 | values. Both arguments must have identical types.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3159 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3160 | <h5>Semantics:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3161 | <p>The truth table used for the '<tt>and</tt>' instruction is:</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3162 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3163 | <table border="1" cellspacing="0" cellpadding="4"> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 3164 | <tbody> |
| 3165 | <tr> |
| 3166 | <td>In0</td> |
| 3167 | <td>In1</td> |
| 3168 | <td>Out</td> |
| 3169 | </tr> |
| 3170 | <tr> |
| 3171 | <td>0</td> |
| 3172 | <td>0</td> |
| 3173 | <td>0</td> |
| 3174 | </tr> |
| 3175 | <tr> |
| 3176 | <td>0</td> |
| 3177 | <td>1</td> |
| 3178 | <td>0</td> |
| 3179 | </tr> |
| 3180 | <tr> |
| 3181 | <td>1</td> |
| 3182 | <td>0</td> |
| 3183 | <td>0</td> |
| 3184 | </tr> |
| 3185 | <tr> |
| 3186 | <td>1</td> |
| 3187 | <td>1</td> |
| 3188 | <td>1</td> |
| 3189 | </tr> |
| 3190 | </tbody> |
| 3191 | </table> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3192 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3193 | <h5>Example:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3194 | <pre> |
| 3195 | <result> = and i32 4, %var <i>; yields {i32}:result = 4 & %var</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3196 | <result> = and i32 15, 40 <i>; yields {i32}:result = 8</i> |
| 3197 | <result> = and i32 4, 8 <i>; yields {i32}:result = 0</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3198 | </pre> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3199 | </div> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3200 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 3201 | <div class="doc_subsubsection"> <a name="i_or">'<tt>or</tt>' Instruction</a> </div> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3202 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3203 | <div class="doc_text"> |
| 3204 | |
| 3205 | <h5>Syntax:</h5> |
| 3206 | <pre> |
| 3207 | <result> = or <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
| 3208 | </pre> |
| 3209 | |
| 3210 | <h5>Overview:</h5> |
| 3211 | <p>The '<tt>or</tt>' instruction returns the bitwise logical inclusive or of its |
| 3212 | two operands.</p> |
| 3213 | |
| 3214 | <h5>Arguments:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3215 | <p>The two arguments to the '<tt>or</tt>' instruction must be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3216 | <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of integer |
| 3217 | values. Both arguments must have identical types.</p> |
| 3218 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3219 | <h5>Semantics:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3220 | <p>The truth table used for the '<tt>or</tt>' instruction is:</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3221 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 3222 | <table border="1" cellspacing="0" cellpadding="4"> |
| 3223 | <tbody> |
| 3224 | <tr> |
| 3225 | <td>In0</td> |
| 3226 | <td>In1</td> |
| 3227 | <td>Out</td> |
| 3228 | </tr> |
| 3229 | <tr> |
| 3230 | <td>0</td> |
| 3231 | <td>0</td> |
| 3232 | <td>0</td> |
| 3233 | </tr> |
| 3234 | <tr> |
| 3235 | <td>0</td> |
| 3236 | <td>1</td> |
| 3237 | <td>1</td> |
| 3238 | </tr> |
| 3239 | <tr> |
| 3240 | <td>1</td> |
| 3241 | <td>0</td> |
| 3242 | <td>1</td> |
| 3243 | </tr> |
| 3244 | <tr> |
| 3245 | <td>1</td> |
| 3246 | <td>1</td> |
| 3247 | <td>1</td> |
| 3248 | </tr> |
| 3249 | </tbody> |
| 3250 | </table> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3251 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3252 | <h5>Example:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3253 | <pre> |
| 3254 | <result> = or i32 4, %var <i>; yields {i32}:result = 4 | %var</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3255 | <result> = or i32 15, 40 <i>; yields {i32}:result = 47</i> |
| 3256 | <result> = or i32 4, 8 <i>; yields {i32}:result = 12</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3257 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3258 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3259 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3260 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3261 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 3262 | <div class="doc_subsubsection"> <a name="i_xor">'<tt>xor</tt>' |
| 3263 | Instruction</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3264 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3265 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3266 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3267 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3268 | <pre> |
| 3269 | <result> = xor <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3270 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3271 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3272 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3273 | <p>The '<tt>xor</tt>' instruction returns the bitwise logical exclusive or of |
| 3274 | its two operands. The <tt>xor</tt> is used to implement the "one's |
| 3275 | complement" operation, which is the "~" operator in C.</p> |
| 3276 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3277 | <h5>Arguments:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3278 | <p>The two arguments to the '<tt>xor</tt>' instruction must be |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3279 | <a href="#t_integer">integer</a> or <a href="#t_vector">vector</a> of integer |
| 3280 | values. Both arguments must have identical types.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 3281 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3282 | <h5>Semantics:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3283 | <p>The truth table used for the '<tt>xor</tt>' instruction is:</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3284 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 3285 | <table border="1" cellspacing="0" cellpadding="4"> |
| 3286 | <tbody> |
| 3287 | <tr> |
| 3288 | <td>In0</td> |
| 3289 | <td>In1</td> |
| 3290 | <td>Out</td> |
| 3291 | </tr> |
| 3292 | <tr> |
| 3293 | <td>0</td> |
| 3294 | <td>0</td> |
| 3295 | <td>0</td> |
| 3296 | </tr> |
| 3297 | <tr> |
| 3298 | <td>0</td> |
| 3299 | <td>1</td> |
| 3300 | <td>1</td> |
| 3301 | </tr> |
| 3302 | <tr> |
| 3303 | <td>1</td> |
| 3304 | <td>0</td> |
| 3305 | <td>1</td> |
| 3306 | </tr> |
| 3307 | <tr> |
| 3308 | <td>1</td> |
| 3309 | <td>1</td> |
| 3310 | <td>0</td> |
| 3311 | </tr> |
| 3312 | </tbody> |
| 3313 | </table> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3314 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3315 | <h5>Example:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3316 | <pre> |
| 3317 | <result> = xor i32 4, %var <i>; yields {i32}:result = 4 ^ %var</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3318 | <result> = xor i32 15, 40 <i>; yields {i32}:result = 39</i> |
| 3319 | <result> = xor i32 4, 8 <i>; yields {i32}:result = 12</i> |
| 3320 | <result> = xor i32 %V, -1 <i>; yields {i32}:result = ~%V</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3321 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3322 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3323 | </div> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3324 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3325 | <!-- ======================================================================= --> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3326 | <div class="doc_subsection"> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3327 | <a name="vectorops">Vector Operations</a> |
| 3328 | </div> |
| 3329 | |
| 3330 | <div class="doc_text"> |
| 3331 | |
| 3332 | <p>LLVM supports several instructions to represent vector operations in a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3333 | target-independent manner. These instructions cover the element-access and |
| 3334 | vector-specific operations needed to process vectors effectively. While LLVM |
| 3335 | does directly support these vector operations, many sophisticated algorithms |
| 3336 | will want to use target-specific intrinsics to take full advantage of a |
| 3337 | specific target.</p> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3338 | |
| 3339 | </div> |
| 3340 | |
| 3341 | <!-- _______________________________________________________________________ --> |
| 3342 | <div class="doc_subsubsection"> |
| 3343 | <a name="i_extractelement">'<tt>extractelement</tt>' Instruction</a> |
| 3344 | </div> |
| 3345 | |
| 3346 | <div class="doc_text"> |
| 3347 | |
| 3348 | <h5>Syntax:</h5> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3349 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3350 | <result> = extractelement <n x <ty>> <val>, i32 <idx> <i>; yields <ty></i> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3351 | </pre> |
| 3352 | |
| 3353 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3354 | <p>The '<tt>extractelement</tt>' instruction extracts a single scalar element |
| 3355 | from a vector at a specified index.</p> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3356 | |
| 3357 | |
| 3358 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3359 | <p>The first operand of an '<tt>extractelement</tt>' instruction is a value |
| 3360 | of <a href="#t_vector">vector</a> type. The second operand is an index |
| 3361 | indicating the position from which to extract the element. The index may be |
| 3362 | a variable.</p> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3363 | |
| 3364 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3365 | <p>The result is a scalar of the same type as the element type of |
| 3366 | <tt>val</tt>. Its value is the value at position <tt>idx</tt> of |
| 3367 | <tt>val</tt>. If <tt>idx</tt> exceeds the length of <tt>val</tt>, the |
| 3368 | results are undefined.</p> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3369 | |
| 3370 | <h5>Example:</h5> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3371 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3372 | %result = extractelement <4 x i32> %vec, i32 0 <i>; yields i32</i> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3373 | </pre> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3374 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3375 | </div> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3376 | |
| 3377 | <!-- _______________________________________________________________________ --> |
| 3378 | <div class="doc_subsubsection"> |
| 3379 | <a name="i_insertelement">'<tt>insertelement</tt>' Instruction</a> |
| 3380 | </div> |
| 3381 | |
| 3382 | <div class="doc_text"> |
| 3383 | |
| 3384 | <h5>Syntax:</h5> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3385 | <pre> |
Dan Gohman | f3480b9 | 2008-05-12 23:38:42 +0000 | [diff] [blame] | 3386 | <result> = insertelement <n x <ty>> <val>, <ty> <elt>, i32 <idx> <i>; yields <n x <ty>></i> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3387 | </pre> |
| 3388 | |
| 3389 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3390 | <p>The '<tt>insertelement</tt>' instruction inserts a scalar element into a |
| 3391 | vector at a specified index.</p> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3392 | |
| 3393 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3394 | <p>The first operand of an '<tt>insertelement</tt>' instruction is a value |
| 3395 | of <a href="#t_vector">vector</a> type. The second operand is a scalar value |
| 3396 | whose type must equal the element type of the first operand. The third |
| 3397 | operand is an index indicating the position at which to insert the value. |
| 3398 | The index may be a variable.</p> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3399 | |
| 3400 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3401 | <p>The result is a vector of the same type as <tt>val</tt>. Its element values |
| 3402 | are those of <tt>val</tt> except at position <tt>idx</tt>, where it gets the |
| 3403 | value <tt>elt</tt>. If <tt>idx</tt> exceeds the length of <tt>val</tt>, the |
| 3404 | results are undefined.</p> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3405 | |
| 3406 | <h5>Example:</h5> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3407 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3408 | %result = insertelement <4 x i32> %vec, i32 1, i32 0 <i>; yields <4 x i32></i> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3409 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3410 | |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3411 | </div> |
| 3412 | |
| 3413 | <!-- _______________________________________________________________________ --> |
| 3414 | <div class="doc_subsubsection"> |
| 3415 | <a name="i_shufflevector">'<tt>shufflevector</tt>' Instruction</a> |
| 3416 | </div> |
| 3417 | |
| 3418 | <div class="doc_text"> |
| 3419 | |
| 3420 | <h5>Syntax:</h5> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3421 | <pre> |
Mon P Wang | aeb06d2 | 2008-11-10 04:46:22 +0000 | [diff] [blame] | 3422 | <result> = shufflevector <n x <ty>> <v1>, <n x <ty>> <v2>, <m x i32> <mask> <i>; yields <m x <ty>></i> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3423 | </pre> |
| 3424 | |
| 3425 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3426 | <p>The '<tt>shufflevector</tt>' instruction constructs a permutation of elements |
| 3427 | from two input vectors, returning a vector with the same element type as the |
| 3428 | input and length that is the same as the shuffle mask.</p> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3429 | |
| 3430 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3431 | <p>The first two operands of a '<tt>shufflevector</tt>' instruction are vectors |
| 3432 | with types that match each other. The third argument is a shuffle mask whose |
| 3433 | element type is always 'i32'. The result of the instruction is a vector |
| 3434 | whose length is the same as the shuffle mask and whose element type is the |
| 3435 | same as the element type of the first two operands.</p> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3436 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3437 | <p>The shuffle mask operand is required to be a constant vector with either |
| 3438 | constant integer or undef values.</p> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3439 | |
| 3440 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3441 | <p>The elements of the two input vectors are numbered from left to right across |
| 3442 | both of the vectors. The shuffle mask operand specifies, for each element of |
| 3443 | the result vector, which element of the two input vectors the result element |
| 3444 | gets. The element selector may be undef (meaning "don't care") and the |
| 3445 | second operand may be undef if performing a shuffle from only one vector.</p> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3446 | |
| 3447 | <h5>Example:</h5> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3448 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3449 | %result = shufflevector <4 x i32> %v1, <4 x i32> %v2, |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 3450 | <4 x i32> <i32 0, i32 4, i32 1, i32 5> <i>; yields <4 x i32></i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3451 | %result = shufflevector <4 x i32> %v1, <4 x i32> undef, |
| 3452 | <4 x i32> <i32 0, i32 1, i32 2, i32 3> <i>; yields <4 x i32></i> - Identity shuffle. |
Mon P Wang | aeb06d2 | 2008-11-10 04:46:22 +0000 | [diff] [blame] | 3453 | %result = shufflevector <8 x i32> %v1, <8 x i32> undef, |
| 3454 | <4 x i32> <i32 0, i32 1, i32 2, i32 3> <i>; yields <4 x i32></i> |
| 3455 | %result = shufflevector <4 x i32> %v1, <4 x i32> %v2, |
| 3456 | <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7 > <i>; yields <8 x i32></i> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3457 | </pre> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3458 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3459 | </div> |
Tanya Lattner | 0947429 | 2006-04-14 19:24:33 +0000 | [diff] [blame] | 3460 | |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 3461 | <!-- ======================================================================= --> |
| 3462 | <div class="doc_subsection"> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3463 | <a name="aggregateops">Aggregate Operations</a> |
| 3464 | </div> |
| 3465 | |
| 3466 | <div class="doc_text"> |
| 3467 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3468 | <p>LLVM supports several instructions for working with aggregate values.</p> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3469 | |
| 3470 | </div> |
| 3471 | |
| 3472 | <!-- _______________________________________________________________________ --> |
| 3473 | <div class="doc_subsubsection"> |
| 3474 | <a name="i_extractvalue">'<tt>extractvalue</tt>' Instruction</a> |
| 3475 | </div> |
| 3476 | |
| 3477 | <div class="doc_text"> |
| 3478 | |
| 3479 | <h5>Syntax:</h5> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3480 | <pre> |
| 3481 | <result> = extractvalue <aggregate type> <val>, <idx>{, <idx>}* |
| 3482 | </pre> |
| 3483 | |
| 3484 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3485 | <p>The '<tt>extractvalue</tt>' instruction extracts the value of a struct field |
| 3486 | or array element from an aggregate value.</p> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3487 | |
| 3488 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3489 | <p>The first operand of an '<tt>extractvalue</tt>' instruction is a value |
| 3490 | of <a href="#t_struct">struct</a> or <a href="#t_array">array</a> type. The |
| 3491 | operands are constant indices to specify which value to extract in a similar |
| 3492 | manner as indices in a |
| 3493 | '<tt><a href="#i_getelementptr">getelementptr</a></tt>' instruction.</p> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3494 | |
| 3495 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3496 | <p>The result is the value at the position in the aggregate specified by the |
| 3497 | index operands.</p> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3498 | |
| 3499 | <h5>Example:</h5> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3500 | <pre> |
Dan Gohman | 81a0c0b | 2008-05-31 00:58:22 +0000 | [diff] [blame] | 3501 | %result = extractvalue {i32, float} %agg, 0 <i>; yields i32</i> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3502 | </pre> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3503 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3504 | </div> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3505 | |
| 3506 | <!-- _______________________________________________________________________ --> |
| 3507 | <div class="doc_subsubsection"> |
| 3508 | <a name="i_insertvalue">'<tt>insertvalue</tt>' Instruction</a> |
| 3509 | </div> |
| 3510 | |
| 3511 | <div class="doc_text"> |
| 3512 | |
| 3513 | <h5>Syntax:</h5> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3514 | <pre> |
Dan Gohman | 81a0c0b | 2008-05-31 00:58:22 +0000 | [diff] [blame] | 3515 | <result> = insertvalue <aggregate type> <val>, <ty> <val>, <idx> <i>; yields <n x <ty>></i> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3516 | </pre> |
| 3517 | |
| 3518 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3519 | <p>The '<tt>insertvalue</tt>' instruction inserts a value into a struct field or |
| 3520 | array element in an aggregate.</p> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3521 | |
| 3522 | |
| 3523 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3524 | <p>The first operand of an '<tt>insertvalue</tt>' instruction is a value |
| 3525 | of <a href="#t_struct">struct</a> or <a href="#t_array">array</a> type. The |
| 3526 | second operand is a first-class value to insert. The following operands are |
| 3527 | constant indices indicating the position at which to insert the value in a |
| 3528 | similar manner as indices in a |
| 3529 | '<tt><a href="#i_getelementptr">getelementptr</a></tt>' instruction. The |
| 3530 | value to insert must have the same type as the value identified by the |
| 3531 | indices.</p> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3532 | |
| 3533 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3534 | <p>The result is an aggregate of the same type as <tt>val</tt>. Its value is |
| 3535 | that of <tt>val</tt> except that the value at the position specified by the |
| 3536 | indices is that of <tt>elt</tt>.</p> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3537 | |
| 3538 | <h5>Example:</h5> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3539 | <pre> |
Dan Gohman | 52bb2db | 2008-06-23 15:26:37 +0000 | [diff] [blame] | 3540 | %result = insertvalue {i32, float} %agg, i32 1, 0 <i>; yields {i32, float}</i> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3541 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3542 | |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 3543 | </div> |
| 3544 | |
| 3545 | |
| 3546 | <!-- ======================================================================= --> |
| 3547 | <div class="doc_subsection"> |
Chris Lattner | 884a970 | 2006-08-15 00:45:58 +0000 | [diff] [blame] | 3548 | <a name="memoryops">Memory Access and Addressing Operations</a> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3549 | </div> |
| 3550 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3551 | <div class="doc_text"> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3552 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3553 | <p>A key design point of an SSA-based representation is how it represents |
| 3554 | memory. In LLVM, no memory locations are in SSA form, which makes things |
| 3555 | very simple. This section describes how to read, write, allocate, and free |
| 3556 | memory in LLVM.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3557 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3558 | </div> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3559 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3560 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3561 | <div class="doc_subsubsection"> |
| 3562 | <a name="i_malloc">'<tt>malloc</tt>' Instruction</a> |
| 3563 | </div> |
| 3564 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3565 | <div class="doc_text"> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3566 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3567 | <h5>Syntax:</h5> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3568 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3569 | <result> = malloc <type>[, i32 <NumElements>][, align <alignment>] <i>; yields {type*}:result</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3570 | </pre> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3571 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3572 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3573 | <p>The '<tt>malloc</tt>' instruction allocates memory from the system heap and |
| 3574 | returns a pointer to it. The object is always allocated in the generic |
| 3575 | address space (address space zero).</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3576 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3577 | <h5>Arguments:</h5> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3578 | <p>The '<tt>malloc</tt>' instruction allocates |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3579 | <tt>sizeof(<type>)*NumElements</tt> bytes of memory from the operating |
| 3580 | system and returns a pointer of the appropriate type to the program. If |
| 3581 | "NumElements" is specified, it is the number of elements allocated, otherwise |
| 3582 | "NumElements" is defaulted to be one. If a constant alignment is specified, |
| 3583 | the value result of the allocation is guaranteed to be aligned to at least |
| 3584 | that boundary. If not specified, or if zero, the target can choose to align |
| 3585 | the allocation on any convenient boundary compatible with the type.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3586 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3587 | <p>'<tt>type</tt>' must be a sized type.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3588 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3589 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3590 | <p>Memory is allocated using the system "<tt>malloc</tt>" function, and a |
| 3591 | pointer is returned. The result of a zero byte allocation is undefined. The |
| 3592 | result is null if there is insufficient memory available.</p> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3593 | |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3594 | <h5>Example:</h5> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3595 | <pre> |
Dan Gohman | 81e2167 | 2009-01-04 23:49:44 +0000 | [diff] [blame] | 3596 | %array = malloc [4 x i8] <i>; yields {[%4 x i8]*}:array</i> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3597 | |
Bill Wendling | aac388b | 2007-05-29 09:42:13 +0000 | [diff] [blame] | 3598 | %size = <a href="#i_add">add</a> i32 2, 2 <i>; yields {i32}:size = i32 4</i> |
| 3599 | %array1 = malloc i8, i32 4 <i>; yields {i8*}:array1</i> |
| 3600 | %array2 = malloc [12 x i8], i32 %size <i>; yields {[12 x i8]*}:array2</i> |
| 3601 | %array3 = malloc i32, i32 4, align 1024 <i>; yields {i32*}:array3</i> |
| 3602 | %array4 = malloc i32, align 1024 <i>; yields {i32*}:array4</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3603 | </pre> |
Dan Gohman | f3e60bd | 2009-01-12 23:12:39 +0000 | [diff] [blame] | 3604 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3605 | <p>Note that the code generator does not yet respect the alignment value.</p> |
Dan Gohman | f3e60bd | 2009-01-12 23:12:39 +0000 | [diff] [blame] | 3606 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3607 | </div> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3608 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3609 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3610 | <div class="doc_subsubsection"> |
| 3611 | <a name="i_free">'<tt>free</tt>' Instruction</a> |
| 3612 | </div> |
| 3613 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3614 | <div class="doc_text"> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3615 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3616 | <h5>Syntax:</h5> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3617 | <pre> |
Dan Gohman | 81e2167 | 2009-01-04 23:49:44 +0000 | [diff] [blame] | 3618 | free <type> <value> <i>; yields {void}</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3619 | </pre> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3620 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3621 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3622 | <p>The '<tt>free</tt>' instruction returns memory back to the unused memory heap |
| 3623 | to be reallocated in the future.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3624 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3625 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3626 | <p>'<tt>value</tt>' shall be a pointer value that points to a value that was |
| 3627 | allocated with the '<tt><a href="#i_malloc">malloc</a></tt>' instruction.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3628 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3629 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3630 | <p>Access to the memory pointed to by the pointer is no longer defined after |
| 3631 | this instruction executes. If the pointer is null, the operation is a |
| 3632 | noop.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3633 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3634 | <h5>Example:</h5> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3635 | <pre> |
Dan Gohman | 81e2167 | 2009-01-04 23:49:44 +0000 | [diff] [blame] | 3636 | %array = <a href="#i_malloc">malloc</a> [4 x i8] <i>; yields {[4 x i8]*}:array</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3637 | free [4 x i8]* %array |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3638 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3639 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3640 | </div> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3641 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3642 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3643 | <div class="doc_subsubsection"> |
| 3644 | <a name="i_alloca">'<tt>alloca</tt>' Instruction</a> |
| 3645 | </div> |
| 3646 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3647 | <div class="doc_text"> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3648 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3649 | <h5>Syntax:</h5> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3650 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3651 | <result> = alloca <type>[, i32 <NumElements>][, align <alignment>] <i>; yields {type*}:result</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3652 | </pre> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3653 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3654 | <h5>Overview:</h5> |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 3655 | <p>The '<tt>alloca</tt>' instruction allocates memory on the stack frame of the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3656 | currently executing function, to be automatically released when this function |
| 3657 | returns to its caller. The object is always allocated in the generic address |
| 3658 | space (address space zero).</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3659 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3660 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3661 | <p>The '<tt>alloca</tt>' instruction |
| 3662 | allocates <tt>sizeof(<type>)*NumElements</tt> bytes of memory on the |
| 3663 | runtime stack, returning a pointer of the appropriate type to the program. |
| 3664 | If "NumElements" is specified, it is the number of elements allocated, |
| 3665 | otherwise "NumElements" is defaulted to be one. If a constant alignment is |
| 3666 | specified, the value result of the allocation is guaranteed to be aligned to |
| 3667 | at least that boundary. If not specified, or if zero, the target can choose |
| 3668 | to align the allocation on any convenient boundary compatible with the |
| 3669 | type.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3670 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3671 | <p>'<tt>type</tt>' may be any sized type.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3672 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3673 | <h5>Semantics:</h5> |
Bill Wendling | 871eb0a | 2009-05-08 20:49:29 +0000 | [diff] [blame] | 3674 | <p>Memory is allocated; a pointer is returned. The operation is undefined if |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3675 | there is insufficient stack space for the allocation. '<tt>alloca</tt>'d |
| 3676 | memory is automatically released when the function returns. The |
| 3677 | '<tt>alloca</tt>' instruction is commonly used to represent automatic |
| 3678 | variables that must have an address available. When the function returns |
| 3679 | (either with the <tt><a href="#i_ret">ret</a></tt> |
| 3680 | or <tt><a href="#i_unwind">unwind</a></tt> instructions), the memory is |
| 3681 | reclaimed. Allocating zero bytes is legal, but the result is undefined.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3682 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3683 | <h5>Example:</h5> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3684 | <pre> |
Dan Gohman | 81e2167 | 2009-01-04 23:49:44 +0000 | [diff] [blame] | 3685 | %ptr = alloca i32 <i>; yields {i32*}:ptr</i> |
| 3686 | %ptr = alloca i32, i32 4 <i>; yields {i32*}:ptr</i> |
| 3687 | %ptr = alloca i32, i32 4, align 1024 <i>; yields {i32*}:ptr</i> |
| 3688 | %ptr = alloca i32, align 1024 <i>; yields {i32*}:ptr</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3689 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3690 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3691 | </div> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 3692 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3693 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 3694 | <div class="doc_subsubsection"> <a name="i_load">'<tt>load</tt>' |
| 3695 | Instruction</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3696 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3697 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3698 | |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3699 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3700 | <pre> |
| 3701 | <result> = load <ty>* <pointer>[, align <alignment>] |
| 3702 | <result> = volatile load <ty>* <pointer>[, align <alignment>] |
| 3703 | </pre> |
| 3704 | |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3705 | <h5>Overview:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3706 | <p>The '<tt>load</tt>' instruction is used to read from memory.</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3707 | |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3708 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3709 | <p>The argument to the '<tt>load</tt>' instruction specifies the memory address |
| 3710 | from which to load. The pointer must point to |
| 3711 | a <a href="#t_firstclass">first class</a> type. If the <tt>load</tt> is |
| 3712 | marked as <tt>volatile</tt>, then the optimizer is not allowed to modify the |
| 3713 | number or order of execution of this <tt>load</tt> with other |
| 3714 | volatile <tt>load</tt> and <tt><a href="#i_store">store</a></tt> |
| 3715 | instructions. </p> |
| 3716 | |
| 3717 | <p>The optional constant "align" argument specifies the alignment of the |
| 3718 | operation (that is, the alignment of the memory address). A value of 0 or an |
| 3719 | omitted "align" argument means that the operation has the preferential |
| 3720 | alignment for the target. It is the responsibility of the code emitter to |
| 3721 | ensure that the alignment information is correct. Overestimating the |
| 3722 | alignment results in an undefined behavior. Underestimating the alignment may |
| 3723 | produce less efficient code. An alignment of 1 is always safe.</p> |
| 3724 | |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3725 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3726 | <p>The location of memory pointed to is loaded. If the value being loaded is of |
| 3727 | scalar type then the number of bytes read does not exceed the minimum number |
| 3728 | of bytes needed to hold all bits of the type. For example, loading an |
| 3729 | <tt>i24</tt> reads at most three bytes. When loading a value of a type like |
| 3730 | <tt>i20</tt> with a size that is not an integral number of bytes, the result |
| 3731 | is undefined if the value was not originally written using a store of the |
| 3732 | same type.</p> |
| 3733 | |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3734 | <h5>Examples:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3735 | <pre> |
| 3736 | %ptr = <a href="#i_alloca">alloca</a> i32 <i>; yields {i32*}:ptr</i> |
| 3737 | <a href="#i_store">store</a> i32 3, i32* %ptr <i>; yields {void}</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3738 | %val = load i32* %ptr <i>; yields {i32}:val = i32 3</i> |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3739 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3740 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3741 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3742 | |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3743 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 3744 | <div class="doc_subsubsection"> <a name="i_store">'<tt>store</tt>' |
| 3745 | Instruction</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3746 | |
Reid Spencer | 035ab57 | 2006-11-09 21:18:01 +0000 | [diff] [blame] | 3747 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3748 | |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3749 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3750 | <pre> |
| 3751 | store <ty> <value>, <ty>* <pointer>[, align <alignment>] <i>; yields {void}</i> |
Christopher Lamb | 2330e4d | 2007-04-21 08:16:25 +0000 | [diff] [blame] | 3752 | volatile store <ty> <value>, <ty>* <pointer>[, align <alignment>] <i>; yields {void}</i> |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3753 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3754 | |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3755 | <h5>Overview:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3756 | <p>The '<tt>store</tt>' instruction is used to write to memory.</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3757 | |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3758 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3759 | <p>There are two arguments to the '<tt>store</tt>' instruction: a value to store |
| 3760 | and an address at which to store it. The type of the |
| 3761 | '<tt><pointer></tt>' operand must be a pointer to |
| 3762 | the <a href="#t_firstclass">first class</a> type of the |
| 3763 | '<tt><value></tt>' operand. If the <tt>store</tt> is marked |
| 3764 | as <tt>volatile</tt>, then the optimizer is not allowed to modify the number |
| 3765 | or order of execution of this <tt>store</tt> with other |
| 3766 | volatile <tt>load</tt> and <tt><a href="#i_store">store</a></tt> |
| 3767 | instructions.</p> |
| 3768 | |
| 3769 | <p>The optional constant "align" argument specifies the alignment of the |
| 3770 | operation (that is, the alignment of the memory address). A value of 0 or an |
| 3771 | omitted "align" argument means that the operation has the preferential |
| 3772 | alignment for the target. It is the responsibility of the code emitter to |
| 3773 | ensure that the alignment information is correct. Overestimating the |
| 3774 | alignment results in an undefined behavior. Underestimating the alignment may |
| 3775 | produce less efficient code. An alignment of 1 is always safe.</p> |
| 3776 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 3777 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3778 | <p>The contents of memory are updated to contain '<tt><value></tt>' at the |
| 3779 | location specified by the '<tt><pointer></tt>' operand. If |
| 3780 | '<tt><value></tt>' is of scalar type then the number of bytes written |
| 3781 | does not exceed the minimum number of bytes needed to hold all bits of the |
| 3782 | type. For example, storing an <tt>i24</tt> writes at most three bytes. When |
| 3783 | writing a value of a type like <tt>i20</tt> with a size that is not an |
| 3784 | integral number of bytes, it is unspecified what happens to the extra bits |
| 3785 | that do not belong to the type, but they will typically be overwritten.</p> |
| 3786 | |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3787 | <h5>Example:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3788 | <pre> |
| 3789 | %ptr = <a href="#i_alloca">alloca</a> i32 <i>; yields {i32*}:ptr</i> |
Bill Wendling | 8c6c72d | 2007-10-22 05:10:05 +0000 | [diff] [blame] | 3790 | store i32 3, i32* %ptr <i>; yields {void}</i> |
| 3791 | %val = <a href="#i_load">load</a> i32* %ptr <i>; yields {i32}:val = i32 3</i> |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3792 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3793 | |
Reid Spencer | 47ce179 | 2006-11-09 21:15:49 +0000 | [diff] [blame] | 3794 | </div> |
| 3795 | |
Chris Lattner | 2b7d320 | 2002-05-06 03:03:22 +0000 | [diff] [blame] | 3796 | <!-- _______________________________________________________________________ --> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3797 | <div class="doc_subsubsection"> |
| 3798 | <a name="i_getelementptr">'<tt>getelementptr</tt>' Instruction</a> |
| 3799 | </div> |
| 3800 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3801 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3802 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 3803 | <h5>Syntax:</h5> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3804 | <pre> |
Matthijs Kooijman | e49d0bc | 2008-10-13 13:44:15 +0000 | [diff] [blame] | 3805 | <result> = getelementptr <pty>* <ptrval>{, <ty> <idx>}* |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3806 | </pre> |
| 3807 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 3808 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3809 | <p>The '<tt>getelementptr</tt>' instruction is used to get the address of a |
| 3810 | subelement of an aggregate data structure. It performs address calculation |
| 3811 | only and does not access memory.</p> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3812 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 3813 | <h5>Arguments:</h5> |
Matthijs Kooijman | e49d0bc | 2008-10-13 13:44:15 +0000 | [diff] [blame] | 3814 | <p>The first argument is always a pointer, and forms the basis of the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3815 | calculation. The remaining arguments are indices, that indicate which of the |
| 3816 | elements of the aggregate object are indexed. The interpretation of each |
| 3817 | index is dependent on the type being indexed into. The first index always |
| 3818 | indexes the pointer value given as the first argument, the second index |
| 3819 | indexes a value of the type pointed to (not necessarily the value directly |
| 3820 | pointed to, since the first index can be non-zero), etc. The first type |
| 3821 | indexed into must be a pointer value, subsequent types can be arrays, vectors |
| 3822 | and structs. Note that subsequent types being indexed into can never be |
| 3823 | pointers, since that would require loading the pointer before continuing |
| 3824 | calculation.</p> |
Matthijs Kooijman | e49d0bc | 2008-10-13 13:44:15 +0000 | [diff] [blame] | 3825 | |
| 3826 | <p>The type of each index argument depends on the type it is indexing into. |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3827 | When indexing into a (packed) structure, only <tt>i32</tt> integer |
| 3828 | <b>constants</b> are allowed. When indexing into an array, pointer or |
| 3829 | vector, integers of any width are allowed (also non-constants).</p> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3830 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3831 | <p>For example, let's consider a C code fragment and how it gets compiled to |
| 3832 | LLVM:</p> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3833 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 3834 | <div class="doc_code"> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3835 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 3836 | struct RT { |
| 3837 | char A; |
Chris Lattner | cabc846 | 2007-05-29 15:43:56 +0000 | [diff] [blame] | 3838 | int B[10][20]; |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 3839 | char C; |
| 3840 | }; |
| 3841 | struct ST { |
Chris Lattner | cabc846 | 2007-05-29 15:43:56 +0000 | [diff] [blame] | 3842 | int X; |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 3843 | double Y; |
| 3844 | struct RT Z; |
| 3845 | }; |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3846 | |
Chris Lattner | cabc846 | 2007-05-29 15:43:56 +0000 | [diff] [blame] | 3847 | int *foo(struct ST *s) { |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 3848 | return &s[1].Z.B[5][13]; |
| 3849 | } |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3850 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 3851 | </div> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3852 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3853 | <p>The LLVM code generated by the GCC frontend is:</p> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3854 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 3855 | <div class="doc_code"> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3856 | <pre> |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 3857 | %RT = <a href="#namedtypes">type</a> { i8 , [10 x [20 x i32]], i8 } |
| 3858 | %ST = <a href="#namedtypes">type</a> { i32, double, %RT } |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3859 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 3860 | define i32* %foo(%ST* %s) { |
| 3861 | entry: |
| 3862 | %reg = getelementptr %ST* %s, i32 1, i32 2, i32 1, i32 5, i32 13 |
| 3863 | ret i32* %reg |
| 3864 | } |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3865 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 3866 | </div> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3867 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 3868 | <h5>Semantics:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3869 | <p>In the example above, the first index is indexing into the '<tt>%ST*</tt>' |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3870 | type, which is a pointer, yielding a '<tt>%ST</tt>' = '<tt>{ i32, double, %RT |
| 3871 | }</tt>' type, a structure. The second index indexes into the third element |
| 3872 | of the structure, yielding a '<tt>%RT</tt>' = '<tt>{ i8 , [10 x [20 x i32]], |
| 3873 | i8 }</tt>' type, another structure. The third index indexes into the second |
| 3874 | element of the structure, yielding a '<tt>[10 x [20 x i32]]</tt>' type, an |
| 3875 | array. The two dimensions of the array are subscripted into, yielding an |
| 3876 | '<tt>i32</tt>' type. The '<tt>getelementptr</tt>' instruction returns a |
| 3877 | pointer to this element, thus computing a value of '<tt>i32*</tt>' type.</p> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3878 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3879 | <p>Note that it is perfectly legal to index partially through a structure, |
| 3880 | returning a pointer to an inner element. Because of this, the LLVM code for |
| 3881 | the given testcase is equivalent to:</p> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3882 | |
| 3883 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3884 | define i32* %foo(%ST* %s) { |
| 3885 | %t1 = getelementptr %ST* %s, i32 1 <i>; yields %ST*:%t1</i> |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 3886 | %t2 = getelementptr %ST* %t1, i32 0, i32 2 <i>; yields %RT*:%t2</i> |
| 3887 | %t3 = getelementptr %RT* %t2, i32 0, i32 1 <i>; yields [10 x [20 x i32]]*:%t3</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3888 | %t4 = getelementptr [10 x [20 x i32]]* %t3, i32 0, i32 5 <i>; yields [20 x i32]*:%t4</i> |
| 3889 | %t5 = getelementptr [20 x i32]* %t4, i32 0, i32 13 <i>; yields i32*:%t5</i> |
| 3890 | ret i32* %t5 |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3891 | } |
Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 3892 | </pre> |
Chris Lattner | e67a951 | 2005-06-24 17:22:57 +0000 | [diff] [blame] | 3893 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3894 | <p>Note that it is undefined to access an array out of bounds: array and pointer |
| 3895 | indexes must always be within the defined bounds of the array type when |
| 3896 | accessed with an instruction that dereferences the pointer (e.g. a load or |
| 3897 | store instruction). The one exception for this rule is zero length arrays. |
| 3898 | These arrays are defined to be accessible as variable length arrays, which |
| 3899 | requires access beyond the zero'th element.</p> |
Chris Lattner | e67a951 | 2005-06-24 17:22:57 +0000 | [diff] [blame] | 3900 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3901 | <p>The getelementptr instruction is often confusing. For some more insight into |
| 3902 | how it works, see <a href="GetElementPtr.html">the getelementptr FAQ</a>.</p> |
Chris Lattner | 884a970 | 2006-08-15 00:45:58 +0000 | [diff] [blame] | 3903 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 3904 | <h5>Example:</h5> |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3905 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3906 | <i>; yields [12 x i8]*:aptr</i> |
Matthijs Kooijman | e49d0bc | 2008-10-13 13:44:15 +0000 | [diff] [blame] | 3907 | %aptr = getelementptr {i32, [12 x i8]}* %saptr, i64 0, i32 1 |
| 3908 | <i>; yields i8*:vptr</i> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 3909 | %vptr = getelementptr {i32, <2 x i8>}* %svptr, i64 0, i32 1, i32 1 |
Matthijs Kooijman | e49d0bc | 2008-10-13 13:44:15 +0000 | [diff] [blame] | 3910 | <i>; yields i8*:eptr</i> |
| 3911 | %eptr = getelementptr [12 x i8]* %aptr, i64 0, i32 1 |
Sanjiv Gupta | 9f805c2 | 2009-04-25 07:27:44 +0000 | [diff] [blame] | 3912 | <i>; yields i32*:iptr</i> |
Sanjiv Gupta | 16ffa80 | 2009-04-24 16:38:13 +0000 | [diff] [blame] | 3913 | %iptr = getelementptr [10 x i32]* @arr, i16 0, i16 0 |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3914 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3915 | |
Chris Lattner | f74d5c7 | 2004-04-05 01:30:49 +0000 | [diff] [blame] | 3916 | </div> |
Reid Spencer | 47ce179 | 2006-11-09 21:15:49 +0000 | [diff] [blame] | 3917 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 3918 | <!-- ======================================================================= --> |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 3919 | <div class="doc_subsection"> <a name="convertops">Conversion Operations</a> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3920 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3921 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3922 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3923 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 3924 | <p>The instructions in this category are the conversion instructions (casting) |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3925 | which all take a single operand and a type. They perform various bit |
| 3926 | conversions on the operand.</p> |
| 3927 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 3928 | </div> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 3929 | |
Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 3930 | <!-- _______________________________________________________________________ --> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 3931 | <div class="doc_subsubsection"> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 3932 | <a name="i_trunc">'<tt>trunc .. to</tt>' Instruction</a> |
| 3933 | </div> |
| 3934 | <div class="doc_text"> |
| 3935 | |
| 3936 | <h5>Syntax:</h5> |
| 3937 | <pre> |
| 3938 | <result> = trunc <ty> <value> to <ty2> <i>; yields ty2</i> |
| 3939 | </pre> |
| 3940 | |
| 3941 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3942 | <p>The '<tt>trunc</tt>' instruction truncates its operand to the |
| 3943 | type <tt>ty2</tt>.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 3944 | |
| 3945 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3946 | <p>The '<tt>trunc</tt>' instruction takes a <tt>value</tt> to trunc, which must |
| 3947 | be an <a href="#t_integer">integer</a> type, and a type that specifies the |
| 3948 | size and type of the result, which must be |
| 3949 | an <a href="#t_integer">integer</a> type. The bit size of <tt>value</tt> must |
| 3950 | be larger than the bit size of <tt>ty2</tt>. Equal sized types are not |
| 3951 | allowed.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 3952 | |
| 3953 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3954 | <p>The '<tt>trunc</tt>' instruction truncates the high order bits |
| 3955 | in <tt>value</tt> and converts the remaining bits to <tt>ty2</tt>. Since the |
| 3956 | source size must be larger than the destination size, <tt>trunc</tt> cannot |
| 3957 | be a <i>no-op cast</i>. It will always truncate bits.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 3958 | |
| 3959 | <h5>Example:</h5> |
| 3960 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3961 | %X = trunc i32 257 to i8 <i>; yields i8:1</i> |
Reid Spencer | c78f337 | 2007-01-12 03:35:51 +0000 | [diff] [blame] | 3962 | %Y = trunc i32 123 to i1 <i>; yields i1:true</i> |
| 3963 | %Y = trunc i32 122 to i1 <i>; yields i1:false</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 3964 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3965 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 3966 | </div> |
| 3967 | |
| 3968 | <!-- _______________________________________________________________________ --> |
| 3969 | <div class="doc_subsubsection"> |
| 3970 | <a name="i_zext">'<tt>zext .. to</tt>' Instruction</a> |
| 3971 | </div> |
| 3972 | <div class="doc_text"> |
| 3973 | |
| 3974 | <h5>Syntax:</h5> |
| 3975 | <pre> |
| 3976 | <result> = zext <ty> <value> to <ty2> <i>; yields ty2</i> |
| 3977 | </pre> |
| 3978 | |
| 3979 | <h5>Overview:</h5> |
| 3980 | <p>The '<tt>zext</tt>' instruction zero extends its operand to type |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3981 | <tt>ty2</tt>.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 3982 | |
| 3983 | |
| 3984 | <h5>Arguments:</h5> |
| 3985 | <p>The '<tt>zext</tt>' instruction takes a value to cast, which must be of |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3986 | <a href="#t_integer">integer</a> type, and a type to cast it to, which must |
| 3987 | also be of <a href="#t_integer">integer</a> type. The bit size of the |
| 3988 | <tt>value</tt> must be smaller than the bit size of the destination type, |
| 3989 | <tt>ty2</tt>.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 3990 | |
| 3991 | <h5>Semantics:</h5> |
| 3992 | <p>The <tt>zext</tt> fills the high order bits of the <tt>value</tt> with zero |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 3993 | bits until it reaches the size of the destination type, <tt>ty2</tt>.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 3994 | |
Reid Spencer | b592952 | 2007-01-12 15:46:11 +0000 | [diff] [blame] | 3995 | <p>When zero extending from i1, the result will always be either 0 or 1.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 3996 | |
| 3997 | <h5>Example:</h5> |
| 3998 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 3999 | %X = zext i32 257 to i64 <i>; yields i64:257</i> |
Reid Spencer | c78f337 | 2007-01-12 03:35:51 +0000 | [diff] [blame] | 4000 | %Y = zext i1 true to i32 <i>; yields i32:1</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4001 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4002 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4003 | </div> |
| 4004 | |
| 4005 | <!-- _______________________________________________________________________ --> |
| 4006 | <div class="doc_subsubsection"> |
| 4007 | <a name="i_sext">'<tt>sext .. to</tt>' Instruction</a> |
| 4008 | </div> |
| 4009 | <div class="doc_text"> |
| 4010 | |
| 4011 | <h5>Syntax:</h5> |
| 4012 | <pre> |
| 4013 | <result> = sext <ty> <value> to <ty2> <i>; yields ty2</i> |
| 4014 | </pre> |
| 4015 | |
| 4016 | <h5>Overview:</h5> |
| 4017 | <p>The '<tt>sext</tt>' sign extends <tt>value</tt> to the type <tt>ty2</tt>.</p> |
| 4018 | |
| 4019 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4020 | <p>The '<tt>sext</tt>' instruction takes a value to cast, which must be of |
| 4021 | <a href="#t_integer">integer</a> type, and a type to cast it to, which must |
| 4022 | also be of <a href="#t_integer">integer</a> type. The bit size of the |
| 4023 | <tt>value</tt> must be smaller than the bit size of the destination type, |
| 4024 | <tt>ty2</tt>.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4025 | |
| 4026 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4027 | <p>The '<tt>sext</tt>' instruction performs a sign extension by copying the sign |
| 4028 | bit (highest order bit) of the <tt>value</tt> until it reaches the bit size |
| 4029 | of the type <tt>ty2</tt>.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4030 | |
Reid Spencer | c78f337 | 2007-01-12 03:35:51 +0000 | [diff] [blame] | 4031 | <p>When sign extending from i1, the extension always results in -1 or 0.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4032 | |
| 4033 | <h5>Example:</h5> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4034 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 4035 | %X = sext i8 -1 to i16 <i>; yields i16 :65535</i> |
Reid Spencer | c78f337 | 2007-01-12 03:35:51 +0000 | [diff] [blame] | 4036 | %Y = sext i1 true to i32 <i>; yields i32:-1</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4037 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4038 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4039 | </div> |
| 4040 | |
| 4041 | <!-- _______________________________________________________________________ --> |
| 4042 | <div class="doc_subsubsection"> |
Reid Spencer | 3fa91b0 | 2006-11-09 21:48:10 +0000 | [diff] [blame] | 4043 | <a name="i_fptrunc">'<tt>fptrunc .. to</tt>' Instruction</a> |
| 4044 | </div> |
| 4045 | |
| 4046 | <div class="doc_text"> |
| 4047 | |
| 4048 | <h5>Syntax:</h5> |
Reid Spencer | 3fa91b0 | 2006-11-09 21:48:10 +0000 | [diff] [blame] | 4049 | <pre> |
| 4050 | <result> = fptrunc <ty> <value> to <ty2> <i>; yields ty2</i> |
| 4051 | </pre> |
| 4052 | |
| 4053 | <h5>Overview:</h5> |
| 4054 | <p>The '<tt>fptrunc</tt>' instruction truncates <tt>value</tt> to type |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4055 | <tt>ty2</tt>.</p> |
Reid Spencer | 3fa91b0 | 2006-11-09 21:48:10 +0000 | [diff] [blame] | 4056 | |
| 4057 | <h5>Arguments:</h5> |
| 4058 | <p>The '<tt>fptrunc</tt>' instruction takes a <a href="#t_floating">floating |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4059 | point</a> value to cast and a <a href="#t_floating">floating point</a> type |
| 4060 | to cast it to. The size of <tt>value</tt> must be larger than the size of |
| 4061 | <tt>ty2</tt>. This implies that <tt>fptrunc</tt> cannot be used to make a |
| 4062 | <i>no-op cast</i>.</p> |
Reid Spencer | 3fa91b0 | 2006-11-09 21:48:10 +0000 | [diff] [blame] | 4063 | |
| 4064 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4065 | <p>The '<tt>fptrunc</tt>' instruction truncates a <tt>value</tt> from a larger |
| 4066 | <a href="#t_floating">floating point</a> type to a smaller |
| 4067 | <a href="#t_floating">floating point</a> type. If the value cannot fit |
| 4068 | within the destination type, <tt>ty2</tt>, then the results are |
| 4069 | undefined.</p> |
Reid Spencer | 3fa91b0 | 2006-11-09 21:48:10 +0000 | [diff] [blame] | 4070 | |
| 4071 | <h5>Example:</h5> |
| 4072 | <pre> |
| 4073 | %X = fptrunc double 123.0 to float <i>; yields float:123.0</i> |
| 4074 | %Y = fptrunc double 1.0E+300 to float <i>; yields undefined</i> |
| 4075 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4076 | |
Reid Spencer | 3fa91b0 | 2006-11-09 21:48:10 +0000 | [diff] [blame] | 4077 | </div> |
| 4078 | |
| 4079 | <!-- _______________________________________________________________________ --> |
| 4080 | <div class="doc_subsubsection"> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4081 | <a name="i_fpext">'<tt>fpext .. to</tt>' Instruction</a> |
| 4082 | </div> |
| 4083 | <div class="doc_text"> |
| 4084 | |
| 4085 | <h5>Syntax:</h5> |
| 4086 | <pre> |
| 4087 | <result> = fpext <ty> <value> to <ty2> <i>; yields ty2</i> |
| 4088 | </pre> |
| 4089 | |
| 4090 | <h5>Overview:</h5> |
| 4091 | <p>The '<tt>fpext</tt>' extends a floating point <tt>value</tt> to a larger |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4092 | floating point value.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4093 | |
| 4094 | <h5>Arguments:</h5> |
| 4095 | <p>The '<tt>fpext</tt>' instruction takes a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4096 | <a href="#t_floating">floating point</a> <tt>value</tt> to cast, and |
| 4097 | a <a href="#t_floating">floating point</a> type to cast it to. The source |
| 4098 | type must be smaller than the destination type.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4099 | |
| 4100 | <h5>Semantics:</h5> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 4101 | <p>The '<tt>fpext</tt>' instruction extends the <tt>value</tt> from a smaller |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4102 | <a href="#t_floating">floating point</a> type to a larger |
| 4103 | <a href="#t_floating">floating point</a> type. The <tt>fpext</tt> cannot be |
| 4104 | used to make a <i>no-op cast</i> because it always changes bits. Use |
| 4105 | <tt>bitcast</tt> to make a <i>no-op cast</i> for a floating point cast.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4106 | |
| 4107 | <h5>Example:</h5> |
| 4108 | <pre> |
| 4109 | %X = fpext float 3.1415 to double <i>; yields double:3.1415</i> |
| 4110 | %Y = fpext float 1.0 to float <i>; yields float:1.0 (no-op)</i> |
| 4111 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4112 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4113 | </div> |
| 4114 | |
| 4115 | <!-- _______________________________________________________________________ --> |
| 4116 | <div class="doc_subsubsection"> |
Reid Spencer | 24d6da5 | 2007-01-21 00:29:26 +0000 | [diff] [blame] | 4117 | <a name="i_fptoui">'<tt>fptoui .. to</tt>' Instruction</a> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4118 | </div> |
| 4119 | <div class="doc_text"> |
| 4120 | |
| 4121 | <h5>Syntax:</h5> |
| 4122 | <pre> |
Reid Spencer | 1539a1c | 2007-07-31 14:40:14 +0000 | [diff] [blame] | 4123 | <result> = fptoui <ty> <value> to <ty2> <i>; yields ty2</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4124 | </pre> |
| 4125 | |
| 4126 | <h5>Overview:</h5> |
Reid Spencer | 1539a1c | 2007-07-31 14:40:14 +0000 | [diff] [blame] | 4127 | <p>The '<tt>fptoui</tt>' converts a floating point <tt>value</tt> to its |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4128 | unsigned integer equivalent of type <tt>ty2</tt>.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4129 | |
| 4130 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4131 | <p>The '<tt>fptoui</tt>' instruction takes a value to cast, which must be a |
| 4132 | scalar or vector <a href="#t_floating">floating point</a> value, and a type |
| 4133 | to cast it to <tt>ty2</tt>, which must be an <a href="#t_integer">integer</a> |
| 4134 | type. If <tt>ty</tt> is a vector floating point type, <tt>ty2</tt> must be a |
| 4135 | vector integer type with the same number of elements as <tt>ty</tt></p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4136 | |
| 4137 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4138 | <p>The '<tt>fptoui</tt>' instruction converts its |
| 4139 | <a href="#t_floating">floating point</a> operand into the nearest (rounding |
| 4140 | towards zero) unsigned integer value. If the value cannot fit |
| 4141 | in <tt>ty2</tt>, the results are undefined.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4142 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4143 | <h5>Example:</h5> |
| 4144 | <pre> |
Reid Spencer | 1539a1c | 2007-07-31 14:40:14 +0000 | [diff] [blame] | 4145 | %X = fptoui double 123.0 to i32 <i>; yields i32:123</i> |
Chris Lattner | 8851904 | 2007-09-22 03:17:52 +0000 | [diff] [blame] | 4146 | %Y = fptoui float 1.0E+300 to i1 <i>; yields undefined:1</i> |
Reid Spencer | 1539a1c | 2007-07-31 14:40:14 +0000 | [diff] [blame] | 4147 | %X = fptoui float 1.04E+17 to i8 <i>; yields undefined:1</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4148 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4149 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4150 | </div> |
| 4151 | |
| 4152 | <!-- _______________________________________________________________________ --> |
| 4153 | <div class="doc_subsubsection"> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 4154 | <a name="i_fptosi">'<tt>fptosi .. to</tt>' Instruction</a> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4155 | </div> |
| 4156 | <div class="doc_text"> |
| 4157 | |
| 4158 | <h5>Syntax:</h5> |
| 4159 | <pre> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 4160 | <result> = fptosi <ty> <value> to <ty2> <i>; yields ty2</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4161 | </pre> |
| 4162 | |
| 4163 | <h5>Overview:</h5> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 4164 | <p>The '<tt>fptosi</tt>' instruction converts |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4165 | <a href="#t_floating">floating point</a> <tt>value</tt> to |
| 4166 | type <tt>ty2</tt>.</p> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4167 | |
Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 4168 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4169 | <p>The '<tt>fptosi</tt>' instruction takes a value to cast, which must be a |
| 4170 | scalar or vector <a href="#t_floating">floating point</a> value, and a type |
| 4171 | to cast it to <tt>ty2</tt>, which must be an <a href="#t_integer">integer</a> |
| 4172 | type. If <tt>ty</tt> is a vector floating point type, <tt>ty2</tt> must be a |
| 4173 | vector integer type with the same number of elements as <tt>ty</tt></p> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4174 | |
Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 4175 | <h5>Semantics:</h5> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 4176 | <p>The '<tt>fptosi</tt>' instruction converts its |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4177 | <a href="#t_floating">floating point</a> operand into the nearest (rounding |
| 4178 | towards zero) signed integer value. If the value cannot fit in <tt>ty2</tt>, |
| 4179 | the results are undefined.</p> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4180 | |
Chris Lattner | 33ba0d9 | 2001-07-09 00:26:23 +0000 | [diff] [blame] | 4181 | <h5>Example:</h5> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4182 | <pre> |
Reid Spencer | c78f337 | 2007-01-12 03:35:51 +0000 | [diff] [blame] | 4183 | %X = fptosi double -123.0 to i32 <i>; yields i32:-123</i> |
Chris Lattner | 8851904 | 2007-09-22 03:17:52 +0000 | [diff] [blame] | 4184 | %Y = fptosi float 1.0E-247 to i1 <i>; yields undefined:1</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 4185 | %X = fptosi float 1.04E+17 to i8 <i>; yields undefined:1</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4186 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4187 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4188 | </div> |
| 4189 | |
| 4190 | <!-- _______________________________________________________________________ --> |
| 4191 | <div class="doc_subsubsection"> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 4192 | <a name="i_uitofp">'<tt>uitofp .. to</tt>' Instruction</a> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4193 | </div> |
| 4194 | <div class="doc_text"> |
| 4195 | |
| 4196 | <h5>Syntax:</h5> |
| 4197 | <pre> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 4198 | <result> = uitofp <ty> <value> to <ty2> <i>; yields ty2</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4199 | </pre> |
| 4200 | |
| 4201 | <h5>Overview:</h5> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 4202 | <p>The '<tt>uitofp</tt>' instruction regards <tt>value</tt> as an unsigned |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4203 | integer and converts that value to the <tt>ty2</tt> type.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4204 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4205 | <h5>Arguments:</h5> |
Nate Begeman | b348d18 | 2007-11-17 03:58:34 +0000 | [diff] [blame] | 4206 | <p>The '<tt>uitofp</tt>' instruction takes a value to cast, which must be a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4207 | scalar or vector <a href="#t_integer">integer</a> value, and a type to cast |
| 4208 | it to <tt>ty2</tt>, which must be an <a href="#t_floating">floating point</a> |
| 4209 | type. If <tt>ty</tt> is a vector integer type, <tt>ty2</tt> must be a vector |
| 4210 | floating point type with the same number of elements as <tt>ty</tt></p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4211 | |
| 4212 | <h5>Semantics:</h5> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 4213 | <p>The '<tt>uitofp</tt>' instruction interprets its operand as an unsigned |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4214 | integer quantity and converts it to the corresponding floating point |
| 4215 | value. If the value cannot fit in the floating point value, the results are |
| 4216 | undefined.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4217 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4218 | <h5>Example:</h5> |
| 4219 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 4220 | %X = uitofp i32 257 to float <i>; yields float:257.0</i> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 4221 | %Y = uitofp i8 -1 to double <i>; yields double:255.0</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4222 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4223 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4224 | </div> |
| 4225 | |
| 4226 | <!-- _______________________________________________________________________ --> |
| 4227 | <div class="doc_subsubsection"> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 4228 | <a name="i_sitofp">'<tt>sitofp .. to</tt>' Instruction</a> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4229 | </div> |
| 4230 | <div class="doc_text"> |
| 4231 | |
| 4232 | <h5>Syntax:</h5> |
| 4233 | <pre> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 4234 | <result> = sitofp <ty> <value> to <ty2> <i>; yields ty2</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4235 | </pre> |
| 4236 | |
| 4237 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4238 | <p>The '<tt>sitofp</tt>' instruction regards <tt>value</tt> as a signed integer |
| 4239 | and converts that value to the <tt>ty2</tt> type.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4240 | |
| 4241 | <h5>Arguments:</h5> |
Nate Begeman | b348d18 | 2007-11-17 03:58:34 +0000 | [diff] [blame] | 4242 | <p>The '<tt>sitofp</tt>' instruction takes a value to cast, which must be a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4243 | scalar or vector <a href="#t_integer">integer</a> value, and a type to cast |
| 4244 | it to <tt>ty2</tt>, which must be an <a href="#t_floating">floating point</a> |
| 4245 | type. If <tt>ty</tt> is a vector integer type, <tt>ty2</tt> must be a vector |
| 4246 | floating point type with the same number of elements as <tt>ty</tt></p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4247 | |
| 4248 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4249 | <p>The '<tt>sitofp</tt>' instruction interprets its operand as a signed integer |
| 4250 | quantity and converts it to the corresponding floating point value. If the |
| 4251 | value cannot fit in the floating point value, the results are undefined.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4252 | |
| 4253 | <h5>Example:</h5> |
| 4254 | <pre> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 4255 | %X = sitofp i32 257 to float <i>; yields float:257.0</i> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 4256 | %Y = sitofp i8 -1 to double <i>; yields double:-1.0</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4257 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4258 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4259 | </div> |
| 4260 | |
| 4261 | <!-- _______________________________________________________________________ --> |
| 4262 | <div class="doc_subsubsection"> |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 4263 | <a name="i_ptrtoint">'<tt>ptrtoint .. to</tt>' Instruction</a> |
| 4264 | </div> |
| 4265 | <div class="doc_text"> |
| 4266 | |
| 4267 | <h5>Syntax:</h5> |
| 4268 | <pre> |
| 4269 | <result> = ptrtoint <ty> <value> to <ty2> <i>; yields ty2</i> |
| 4270 | </pre> |
| 4271 | |
| 4272 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4273 | <p>The '<tt>ptrtoint</tt>' instruction converts the pointer <tt>value</tt> to |
| 4274 | the integer type <tt>ty2</tt>.</p> |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 4275 | |
| 4276 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4277 | <p>The '<tt>ptrtoint</tt>' instruction takes a <tt>value</tt> to cast, which |
| 4278 | must be a <a href="#t_pointer">pointer</a> value, and a type to cast it to |
| 4279 | <tt>ty2</tt>, which must be an <a href="#t_integer">integer</a> type.</p> |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 4280 | |
| 4281 | <h5>Semantics:</h5> |
| 4282 | <p>The '<tt>ptrtoint</tt>' instruction converts <tt>value</tt> to integer type |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4283 | <tt>ty2</tt> by interpreting the pointer value as an integer and either |
| 4284 | truncating or zero extending that value to the size of the integer type. If |
| 4285 | <tt>value</tt> is smaller than <tt>ty2</tt> then a zero extension is done. If |
| 4286 | <tt>value</tt> is larger than <tt>ty2</tt> then a truncation is done. If they |
| 4287 | are the same size, then nothing is done (<i>no-op cast</i>) other than a type |
| 4288 | change.</p> |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 4289 | |
| 4290 | <h5>Example:</h5> |
| 4291 | <pre> |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 4292 | %X = ptrtoint i32* %X to i8 <i>; yields truncation on 32-bit architecture</i> |
| 4293 | %Y = ptrtoint i32* %x to i64 <i>; yields zero extension on 32-bit architecture</i> |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 4294 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4295 | |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 4296 | </div> |
| 4297 | |
| 4298 | <!-- _______________________________________________________________________ --> |
| 4299 | <div class="doc_subsubsection"> |
| 4300 | <a name="i_inttoptr">'<tt>inttoptr .. to</tt>' Instruction</a> |
| 4301 | </div> |
| 4302 | <div class="doc_text"> |
| 4303 | |
| 4304 | <h5>Syntax:</h5> |
| 4305 | <pre> |
| 4306 | <result> = inttoptr <ty> <value> to <ty2> <i>; yields ty2</i> |
| 4307 | </pre> |
| 4308 | |
| 4309 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4310 | <p>The '<tt>inttoptr</tt>' instruction converts an integer <tt>value</tt> to a |
| 4311 | pointer type, <tt>ty2</tt>.</p> |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 4312 | |
| 4313 | <h5>Arguments:</h5> |
Duncan Sands | 8036ca4 | 2007-03-30 12:22:09 +0000 | [diff] [blame] | 4314 | <p>The '<tt>inttoptr</tt>' instruction takes an <a href="#t_integer">integer</a> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4315 | value to cast, and a type to cast it to, which must be a |
| 4316 | <a href="#t_pointer">pointer</a> type.</p> |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 4317 | |
| 4318 | <h5>Semantics:</h5> |
| 4319 | <p>The '<tt>inttoptr</tt>' instruction converts <tt>value</tt> to type |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4320 | <tt>ty2</tt> by applying either a zero extension or a truncation depending on |
| 4321 | the size of the integer <tt>value</tt>. If <tt>value</tt> is larger than the |
| 4322 | size of a pointer then a truncation is done. If <tt>value</tt> is smaller |
| 4323 | than the size of a pointer then a zero extension is done. If they are the |
| 4324 | same size, nothing is done (<i>no-op cast</i>).</p> |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 4325 | |
| 4326 | <h5>Example:</h5> |
| 4327 | <pre> |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 4328 | %X = inttoptr i32 255 to i32* <i>; yields zero extension on 64-bit architecture</i> |
| 4329 | %X = inttoptr i32 255 to i32* <i>; yields no-op on 32-bit architecture</i> |
| 4330 | %Y = inttoptr i64 0 to i32* <i>; yields truncation on 32-bit architecture</i> |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 4331 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4332 | |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 4333 | </div> |
| 4334 | |
| 4335 | <!-- _______________________________________________________________________ --> |
| 4336 | <div class="doc_subsubsection"> |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 4337 | <a name="i_bitcast">'<tt>bitcast .. to</tt>' Instruction</a> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4338 | </div> |
| 4339 | <div class="doc_text"> |
| 4340 | |
| 4341 | <h5>Syntax:</h5> |
| 4342 | <pre> |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 4343 | <result> = bitcast <ty> <value> to <ty2> <i>; yields ty2</i> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4344 | </pre> |
| 4345 | |
| 4346 | <h5>Overview:</h5> |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 4347 | <p>The '<tt>bitcast</tt>' instruction converts <tt>value</tt> to type |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4348 | <tt>ty2</tt> without changing any bits.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4349 | |
| 4350 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4351 | <p>The '<tt>bitcast</tt>' instruction takes a value to cast, which must be a |
| 4352 | non-aggregate first class value, and a type to cast it to, which must also be |
| 4353 | a non-aggregate <a href="#t_firstclass">first class</a> type. The bit sizes |
| 4354 | of <tt>value</tt> and the destination type, <tt>ty2</tt>, must be |
| 4355 | identical. If the source type is a pointer, the destination type must also be |
| 4356 | a pointer. This instruction supports bitwise conversion of vectors to |
| 4357 | integers and to vectors of other types (as long as they have the same |
| 4358 | size).</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4359 | |
| 4360 | <h5>Semantics:</h5> |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 4361 | <p>The '<tt>bitcast</tt>' instruction converts <tt>value</tt> to type |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4362 | <tt>ty2</tt>. It is always a <i>no-op cast</i> because no bits change with |
| 4363 | this conversion. The conversion is done as if the <tt>value</tt> had been |
| 4364 | stored to memory and read back as type <tt>ty2</tt>. Pointer types may only |
| 4365 | be converted to other pointer types with this instruction. To convert |
| 4366 | pointers to other types, use the <a href="#i_inttoptr">inttoptr</a> or |
| 4367 | <a href="#i_ptrtoint">ptrtoint</a> instructions first.</p> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 4368 | |
| 4369 | <h5>Example:</h5> |
| 4370 | <pre> |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 4371 | %X = bitcast i8 255 to i8 <i>; yields i8 :-1</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 4372 | %Y = bitcast i32* %x to sint* <i>; yields sint*:%x</i> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 4373 | %Z = bitcast <2 x int> %V to i64; <i>; yields i64: %V</i> |
Chris Lattner | 33ba0d9 | 2001-07-09 00:26:23 +0000 | [diff] [blame] | 4374 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4375 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4376 | </div> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4377 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 4378 | <!-- ======================================================================= --> |
| 4379 | <div class="doc_subsection"> <a name="otherops">Other Operations</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4380 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 4381 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4382 | |
| 4383 | <p>The instructions in this category are the "miscellaneous" instructions, which |
| 4384 | defy better classification.</p> |
| 4385 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 4386 | </div> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4387 | |
| 4388 | <!-- _______________________________________________________________________ --> |
| 4389 | <div class="doc_subsubsection"><a name="i_icmp">'<tt>icmp</tt>' Instruction</a> |
| 4390 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4391 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4392 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4393 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4394 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4395 | <pre> |
| 4396 | <result> = icmp <cond> <ty> <op1>, <op2> <i>; yields {i1} or {<N x i1>}:result</i> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4397 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4398 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4399 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4400 | <p>The '<tt>icmp</tt>' instruction returns a boolean value or a vector of |
| 4401 | boolean values based on comparison of its two integer, integer vector, or |
| 4402 | pointer operands.</p> |
| 4403 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4404 | <h5>Arguments:</h5> |
| 4405 | <p>The '<tt>icmp</tt>' instruction takes three operands. The first operand is |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4406 | the condition code indicating the kind of comparison to perform. It is not a |
| 4407 | value, just a keyword. The possible condition code are:</p> |
| 4408 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4409 | <ol> |
| 4410 | <li><tt>eq</tt>: equal</li> |
| 4411 | <li><tt>ne</tt>: not equal </li> |
| 4412 | <li><tt>ugt</tt>: unsigned greater than</li> |
| 4413 | <li><tt>uge</tt>: unsigned greater or equal</li> |
| 4414 | <li><tt>ult</tt>: unsigned less than</li> |
| 4415 | <li><tt>ule</tt>: unsigned less or equal</li> |
| 4416 | <li><tt>sgt</tt>: signed greater than</li> |
| 4417 | <li><tt>sge</tt>: signed greater or equal</li> |
| 4418 | <li><tt>slt</tt>: signed less than</li> |
| 4419 | <li><tt>sle</tt>: signed less or equal</li> |
| 4420 | </ol> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4421 | |
Chris Lattner | 3b19d65 | 2007-01-15 01:54:13 +0000 | [diff] [blame] | 4422 | <p>The remaining two arguments must be <a href="#t_integer">integer</a> or |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4423 | <a href="#t_pointer">pointer</a> or integer <a href="#t_vector">vector</a> |
| 4424 | typed. They must also be identical types.</p> |
| 4425 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4426 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4427 | <p>The '<tt>icmp</tt>' compares <tt>op1</tt> and <tt>op2</tt> according to the |
| 4428 | condition code given as <tt>cond</tt>. The comparison performed always yields |
| 4429 | either an <a href="#t_primitive"><tt>i1</tt></a> or vector of <tt>i1</tt> |
| 4430 | result, as follows:</p> |
| 4431 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4432 | <ol> |
| 4433 | <li><tt>eq</tt>: yields <tt>true</tt> if the operands are equal, |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4434 | <tt>false</tt> otherwise. No sign interpretation is necessary or |
| 4435 | performed.</li> |
| 4436 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4437 | <li><tt>ne</tt>: yields <tt>true</tt> if the operands are unequal, |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4438 | <tt>false</tt> otherwise. No sign interpretation is necessary or |
| 4439 | performed.</li> |
| 4440 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4441 | <li><tt>ugt</tt>: interprets the operands as unsigned values and yields |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4442 | <tt>true</tt> if <tt>op1</tt> is greater than <tt>op2</tt>.</li> |
| 4443 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4444 | <li><tt>uge</tt>: interprets the operands as unsigned values and yields |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4445 | <tt>true</tt> if <tt>op1</tt> is greater than or equal |
| 4446 | to <tt>op2</tt>.</li> |
| 4447 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4448 | <li><tt>ult</tt>: interprets the operands as unsigned values and yields |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4449 | <tt>true</tt> if <tt>op1</tt> is less than <tt>op2</tt>.</li> |
| 4450 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4451 | <li><tt>ule</tt>: interprets the operands as unsigned values and yields |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4452 | <tt>true</tt> if <tt>op1</tt> is less than or equal to <tt>op2</tt>.</li> |
| 4453 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4454 | <li><tt>sgt</tt>: interprets the operands as signed values and yields |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4455 | <tt>true</tt> if <tt>op1</tt> is greater than <tt>op2</tt>.</li> |
| 4456 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4457 | <li><tt>sge</tt>: interprets the operands as signed values and yields |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4458 | <tt>true</tt> if <tt>op1</tt> is greater than or equal |
| 4459 | to <tt>op2</tt>.</li> |
| 4460 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4461 | <li><tt>slt</tt>: interprets the operands as signed values and yields |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4462 | <tt>true</tt> if <tt>op1</tt> is less than <tt>op2</tt>.</li> |
| 4463 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4464 | <li><tt>sle</tt>: interprets the operands as signed values and yields |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4465 | <tt>true</tt> if <tt>op1</tt> is less than or equal to <tt>op2</tt>.</li> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4466 | </ol> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4467 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4468 | <p>If the operands are <a href="#t_pointer">pointer</a> typed, the pointer |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4469 | values are compared as if they were integers.</p> |
| 4470 | |
| 4471 | <p>If the operands are integer vectors, then they are compared element by |
| 4472 | element. The result is an <tt>i1</tt> vector with the same number of elements |
| 4473 | as the values being compared. Otherwise, the result is an <tt>i1</tt>.</p> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4474 | |
| 4475 | <h5>Example:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4476 | <pre> |
| 4477 | <result> = icmp eq i32 4, 5 <i>; yields: result=false</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 4478 | <result> = icmp ne float* %X, %X <i>; yields: result=false</i> |
| 4479 | <result> = icmp ult i16 4, 5 <i>; yields: result=true</i> |
| 4480 | <result> = icmp sgt i16 4, 5 <i>; yields: result=false</i> |
| 4481 | <result> = icmp ule i16 -4, 5 <i>; yields: result=false</i> |
| 4482 | <result> = icmp sge i16 4, 5 <i>; yields: result=false</i> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4483 | </pre> |
Dan Gohman | c766f72 | 2009-01-22 01:39:38 +0000 | [diff] [blame] | 4484 | |
| 4485 | <p>Note that the code generator does not yet support vector types with |
| 4486 | the <tt>icmp</tt> instruction.</p> |
| 4487 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4488 | </div> |
| 4489 | |
| 4490 | <!-- _______________________________________________________________________ --> |
| 4491 | <div class="doc_subsubsection"><a name="i_fcmp">'<tt>fcmp</tt>' Instruction</a> |
| 4492 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4493 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4494 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4495 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4496 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4497 | <pre> |
| 4498 | <result> = fcmp <cond> <ty> <op1>, <op2> <i>; yields {i1} or {<N x i1>}:result</i> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4499 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4500 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4501 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4502 | <p>The '<tt>fcmp</tt>' instruction returns a boolean value or vector of boolean |
| 4503 | values based on comparison of its operands.</p> |
| 4504 | |
| 4505 | <p>If the operands are floating point scalars, then the result type is a boolean |
| 4506 | (<a href="#t_primitive"><tt>i1</tt></a>).</p> |
| 4507 | |
| 4508 | <p>If the operands are floating point vectors, then the result type is a vector |
| 4509 | of boolean with the same number of elements as the operands being |
| 4510 | compared.</p> |
| 4511 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4512 | <h5>Arguments:</h5> |
| 4513 | <p>The '<tt>fcmp</tt>' instruction takes three operands. The first operand is |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4514 | the condition code indicating the kind of comparison to perform. It is not a |
| 4515 | value, just a keyword. The possible condition code are:</p> |
| 4516 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4517 | <ol> |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4518 | <li><tt>false</tt>: no comparison, always returns false</li> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4519 | <li><tt>oeq</tt>: ordered and equal</li> |
| 4520 | <li><tt>ogt</tt>: ordered and greater than </li> |
| 4521 | <li><tt>oge</tt>: ordered and greater than or equal</li> |
| 4522 | <li><tt>olt</tt>: ordered and less than </li> |
| 4523 | <li><tt>ole</tt>: ordered and less than or equal</li> |
| 4524 | <li><tt>one</tt>: ordered and not equal</li> |
| 4525 | <li><tt>ord</tt>: ordered (no nans)</li> |
| 4526 | <li><tt>ueq</tt>: unordered or equal</li> |
| 4527 | <li><tt>ugt</tt>: unordered or greater than </li> |
| 4528 | <li><tt>uge</tt>: unordered or greater than or equal</li> |
| 4529 | <li><tt>ult</tt>: unordered or less than </li> |
| 4530 | <li><tt>ule</tt>: unordered or less than or equal</li> |
| 4531 | <li><tt>une</tt>: unordered or not equal</li> |
| 4532 | <li><tt>uno</tt>: unordered (either nans)</li> |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4533 | <li><tt>true</tt>: no comparison, always returns true</li> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4534 | </ol> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4535 | |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 4536 | <p><i>Ordered</i> means that neither operand is a QNAN while |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4537 | <i>unordered</i> means that either operand may be a QNAN.</p> |
| 4538 | |
| 4539 | <p>Each of <tt>val1</tt> and <tt>val2</tt> arguments must be either |
| 4540 | a <a href="#t_floating">floating point</a> type or |
| 4541 | a <a href="#t_vector">vector</a> of floating point type. They must have |
| 4542 | identical types.</p> |
| 4543 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4544 | <h5>Semantics:</h5> |
Gabor Greif | fb224a2 | 2008-08-07 21:46:00 +0000 | [diff] [blame] | 4545 | <p>The '<tt>fcmp</tt>' instruction compares <tt>op1</tt> and <tt>op2</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4546 | according to the condition code given as <tt>cond</tt>. If the operands are |
| 4547 | vectors, then the vectors are compared element by element. Each comparison |
| 4548 | performed always yields an <a href="#t_primitive">i1</a> result, as |
| 4549 | follows:</p> |
| 4550 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4551 | <ol> |
| 4552 | <li><tt>false</tt>: always yields <tt>false</tt>, regardless of operands.</li> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4553 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4554 | <li><tt>oeq</tt>: yields <tt>true</tt> if both operands are not a QNAN and |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4555 | <tt>op1</tt> is equal to <tt>op2</tt>.</li> |
| 4556 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4557 | <li><tt>ogt</tt>: yields <tt>true</tt> if both operands are not a QNAN and |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4558 | <tt>op1</tt> is greather than <tt>op2</tt>.</li> |
| 4559 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4560 | <li><tt>oge</tt>: yields <tt>true</tt> if both operands are not a QNAN and |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4561 | <tt>op1</tt> is greater than or equal to <tt>op2</tt>.</li> |
| 4562 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4563 | <li><tt>olt</tt>: yields <tt>true</tt> if both operands are not a QNAN and |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4564 | <tt>op1</tt> is less than <tt>op2</tt>.</li> |
| 4565 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4566 | <li><tt>ole</tt>: yields <tt>true</tt> if both operands are not a QNAN and |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4567 | <tt>op1</tt> is less than or equal to <tt>op2</tt>.</li> |
| 4568 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4569 | <li><tt>one</tt>: yields <tt>true</tt> if both operands are not a QNAN and |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4570 | <tt>op1</tt> is not equal to <tt>op2</tt>.</li> |
| 4571 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4572 | <li><tt>ord</tt>: yields <tt>true</tt> if both operands are not a QNAN.</li> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4573 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4574 | <li><tt>ueq</tt>: yields <tt>true</tt> if either operand is a QNAN or |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4575 | <tt>op1</tt> is equal to <tt>op2</tt>.</li> |
| 4576 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4577 | <li><tt>ugt</tt>: yields <tt>true</tt> if either operand is a QNAN or |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4578 | <tt>op1</tt> is greater than <tt>op2</tt>.</li> |
| 4579 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4580 | <li><tt>uge</tt>: yields <tt>true</tt> if either operand is a QNAN or |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4581 | <tt>op1</tt> is greater than or equal to <tt>op2</tt>.</li> |
| 4582 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4583 | <li><tt>ult</tt>: yields <tt>true</tt> if either operand is a QNAN or |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4584 | <tt>op1</tt> is less than <tt>op2</tt>.</li> |
| 4585 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4586 | <li><tt>ule</tt>: yields <tt>true</tt> if either operand is a QNAN or |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4587 | <tt>op1</tt> is less than or equal to <tt>op2</tt>.</li> |
| 4588 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4589 | <li><tt>une</tt>: yields <tt>true</tt> if either operand is a QNAN or |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4590 | <tt>op1</tt> is not equal to <tt>op2</tt>.</li> |
| 4591 | |
Reid Spencer | b7f2628 | 2006-11-19 03:00:14 +0000 | [diff] [blame] | 4592 | <li><tt>uno</tt>: yields <tt>true</tt> if either operand is a QNAN.</li> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4593 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4594 | <li><tt>true</tt>: always yields <tt>true</tt>, regardless of operands.</li> |
| 4595 | </ol> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4596 | |
| 4597 | <h5>Example:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4598 | <pre> |
| 4599 | <result> = fcmp oeq float 4.0, 5.0 <i>; yields: result=false</i> |
Dan Gohman | f72fb67 | 2008-09-09 01:02:47 +0000 | [diff] [blame] | 4600 | <result> = fcmp one float 4.0, 5.0 <i>; yields: result=true</i> |
| 4601 | <result> = fcmp olt float 4.0, 5.0 <i>; yields: result=true</i> |
| 4602 | <result> = fcmp ueq double 1.0, 2.0 <i>; yields: result=false</i> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4603 | </pre> |
Dan Gohman | c766f72 | 2009-01-22 01:39:38 +0000 | [diff] [blame] | 4604 | |
| 4605 | <p>Note that the code generator does not yet support vector types with |
| 4606 | the <tt>fcmp</tt> instruction.</p> |
| 4607 | |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 4608 | </div> |
| 4609 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 4610 | <!-- _______________________________________________________________________ --> |
Nate Begeman | ac80ade | 2008-05-12 19:01:56 +0000 | [diff] [blame] | 4611 | <div class="doc_subsubsection"> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 4612 | <a name="i_phi">'<tt>phi</tt>' Instruction</a> |
| 4613 | </div> |
| 4614 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 4615 | <div class="doc_text"> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 4616 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 4617 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4618 | <pre> |
| 4619 | <result> = phi <ty> [ <val0>, <label0>], ... |
| 4620 | </pre> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 4621 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 4622 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4623 | <p>The '<tt>phi</tt>' instruction is used to implement the φ node in the |
| 4624 | SSA graph representing the function.</p> |
| 4625 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 4626 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4627 | <p>The type of the incoming values is specified with the first type field. After |
| 4628 | this, the '<tt>phi</tt>' instruction takes a list of pairs as arguments, with |
| 4629 | one pair for each predecessor basic block of the current block. Only values |
| 4630 | of <a href="#t_firstclass">first class</a> type may be used as the value |
| 4631 | arguments to the PHI node. Only labels may be used as the label |
| 4632 | arguments.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 4633 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4634 | <p>There must be no non-phi instructions between the start of a basic block and |
| 4635 | the PHI instructions: i.e. PHI instructions must be first in a basic |
| 4636 | block.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 4637 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4638 | <p>For the purposes of the SSA form, the use of each incoming value is deemed to |
| 4639 | occur on the edge from the corresponding predecessor block to the current |
| 4640 | block (but after any definition of an '<tt>invoke</tt>' instruction's return |
| 4641 | value on the same edge).</p> |
Jay Foad | d244909 | 2009-06-03 10:20:10 +0000 | [diff] [blame] | 4642 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 4643 | <h5>Semantics:</h5> |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 4644 | <p>At runtime, the '<tt>phi</tt>' instruction logically takes on the value |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4645 | specified by the pair corresponding to the predecessor basic block that |
| 4646 | executed just prior to the current block.</p> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 4647 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 4648 | <h5>Example:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 4649 | <pre> |
| 4650 | Loop: ; Infinite loop that counts from 0 on up... |
| 4651 | %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ] |
| 4652 | %nextindvar = add i32 %indvar, 1 |
| 4653 | br label %Loop |
| 4654 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4655 | |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 4656 | </div> |
| 4657 | |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4658 | <!-- _______________________________________________________________________ --> |
| 4659 | <div class="doc_subsubsection"> |
| 4660 | <a name="i_select">'<tt>select</tt>' Instruction</a> |
| 4661 | </div> |
| 4662 | |
| 4663 | <div class="doc_text"> |
| 4664 | |
| 4665 | <h5>Syntax:</h5> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4666 | <pre> |
Dan Gohman | f72fb67 | 2008-09-09 01:02:47 +0000 | [diff] [blame] | 4667 | <result> = select <i>selty</i> <cond>, <ty> <val1>, <ty> <val2> <i>; yields ty</i> |
| 4668 | |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 4669 | <i>selty</i> is either i1 or {<N x i1>} |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4670 | </pre> |
| 4671 | |
| 4672 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4673 | <p>The '<tt>select</tt>' instruction is used to choose one value based on a |
| 4674 | condition, without branching.</p> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4675 | |
| 4676 | |
| 4677 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4678 | <p>The '<tt>select</tt>' instruction requires an 'i1' value or a vector of 'i1' |
| 4679 | values indicating the condition, and two values of the |
| 4680 | same <a href="#t_firstclass">first class</a> type. If the val1/val2 are |
| 4681 | vectors and the condition is a scalar, then entire vectors are selected, not |
| 4682 | individual elements.</p> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4683 | |
| 4684 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4685 | <p>If the condition is an i1 and it evaluates to 1, the instruction returns the |
| 4686 | first value argument; otherwise, it returns the second value argument.</p> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4687 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4688 | <p>If the condition is a vector of i1, then the value arguments must be vectors |
| 4689 | of the same size, and the selection is done element by element.</p> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4690 | |
| 4691 | <h5>Example:</h5> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4692 | <pre> |
Reid Spencer | c78f337 | 2007-01-12 03:35:51 +0000 | [diff] [blame] | 4693 | %X = select i1 true, i8 17, i8 42 <i>; yields i8:17</i> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4694 | </pre> |
Dan Gohman | c766f72 | 2009-01-22 01:39:38 +0000 | [diff] [blame] | 4695 | |
| 4696 | <p>Note that the code generator does not yet support conditions |
| 4697 | with vector type.</p> |
| 4698 | |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 4699 | </div> |
| 4700 | |
Robert Bocchino | 05ccd70 | 2006-01-15 20:48:27 +0000 | [diff] [blame] | 4701 | <!-- _______________________________________________________________________ --> |
| 4702 | <div class="doc_subsubsection"> |
Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame] | 4703 | <a name="i_call">'<tt>call</tt>' Instruction</a> |
| 4704 | </div> |
| 4705 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4706 | <div class="doc_text"> |
Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame] | 4707 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 4708 | <h5>Syntax:</h5> |
Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame] | 4709 | <pre> |
Devang Patel | 307e8ab | 2008-10-07 17:48:33 +0000 | [diff] [blame] | 4710 | <result> = [tail] call [<a href="#callingconv">cconv</a>] [<a href="#paramattrs">ret attrs</a>] <ty> [<fnty>*] <fnptrval>(<function args>) [<a href="#fnattrs">fn attrs</a>] |
Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame] | 4711 | </pre> |
| 4712 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 4713 | <h5>Overview:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4714 | <p>The '<tt>call</tt>' instruction represents a simple function call.</p> |
Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame] | 4715 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 4716 | <h5>Arguments:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4717 | <p>This instruction requires several arguments:</p> |
Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame] | 4718 | |
Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 4719 | <ol> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4720 | <li>The optional "tail" marker indicates whether the callee function accesses |
| 4721 | any allocas or varargs in the caller. If the "tail" marker is present, |
| 4722 | the function call is eligible for tail call optimization. Note that calls |
| 4723 | may be marked "tail" even if they do not occur before |
| 4724 | a <a href="#i_ret"><tt>ret</tt></a> instruction.</li> |
Devang Patel | f642f47 | 2008-10-06 18:50:38 +0000 | [diff] [blame] | 4725 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4726 | <li>The optional "cconv" marker indicates which <a href="#callingconv">calling |
| 4727 | convention</a> the call should use. If none is specified, the call |
| 4728 | defaults to using C calling conventions.</li> |
Devang Patel | f642f47 | 2008-10-06 18:50:38 +0000 | [diff] [blame] | 4729 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4730 | <li>The optional <a href="#paramattrs">Parameter Attributes</a> list for |
| 4731 | return values. Only '<tt>zeroext</tt>', '<tt>signext</tt>', and |
| 4732 | '<tt>inreg</tt>' attributes are valid here.</li> |
| 4733 | |
| 4734 | <li>'<tt>ty</tt>': the type of the call instruction itself which is also the |
| 4735 | type of the return value. Functions that return no value are marked |
| 4736 | <tt><a href="#t_void">void</a></tt>.</li> |
| 4737 | |
| 4738 | <li>'<tt>fnty</tt>': shall be the signature of the pointer to function value |
| 4739 | being invoked. The argument types must match the types implied by this |
| 4740 | signature. This type can be omitted if the function is not varargs and if |
| 4741 | the function type does not return a pointer to a function.</li> |
| 4742 | |
| 4743 | <li>'<tt>fnptrval</tt>': An LLVM value containing a pointer to a function to |
| 4744 | be invoked. In most cases, this is a direct function invocation, but |
| 4745 | indirect <tt>call</tt>s are just as possible, calling an arbitrary pointer |
| 4746 | to function value.</li> |
| 4747 | |
| 4748 | <li>'<tt>function args</tt>': argument list whose types match the function |
| 4749 | signature argument types. All arguments must be of |
| 4750 | <a href="#t_firstclass">first class</a> type. If the function signature |
| 4751 | indicates the function accepts a variable number of arguments, the extra |
| 4752 | arguments can be specified.</li> |
| 4753 | |
| 4754 | <li>The optional <a href="#fnattrs">function attributes</a> list. Only |
| 4755 | '<tt>noreturn</tt>', '<tt>nounwind</tt>', '<tt>readonly</tt>' and |
| 4756 | '<tt>readnone</tt>' attributes are valid here.</li> |
Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 4757 | </ol> |
Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame] | 4758 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 4759 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4760 | <p>The '<tt>call</tt>' instruction is used to cause control flow to transfer to |
| 4761 | a specified function, with its incoming arguments bound to the specified |
| 4762 | values. Upon a '<tt><a href="#i_ret">ret</a></tt>' instruction in the called |
| 4763 | function, control flow continues with the instruction after the function |
| 4764 | call, and the return value of the function is bound to the result |
| 4765 | argument.</p> |
Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame] | 4766 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 4767 | <h5>Example:</h5> |
Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame] | 4768 | <pre> |
Nick Lewycky | db7e3c9 | 2007-09-08 13:57:50 +0000 | [diff] [blame] | 4769 | %retval = call i32 @test(i32 %argc) |
Chris Lattner | 772fccf | 2008-03-21 17:24:17 +0000 | [diff] [blame] | 4770 | call i32 (i8 *, ...)* @printf(i8 * %msg, i32 12, i8 42) <i>; yields i32</i> |
| 4771 | %X = tail call i32 @foo() <i>; yields i32</i> |
| 4772 | %Y = tail call <a href="#callingconv">fastcc</a> i32 @foo() <i>; yields i32</i> |
| 4773 | call void %foo(i8 97 signext) |
Devang Patel | c3fc6df | 2008-03-10 20:49:15 +0000 | [diff] [blame] | 4774 | |
| 4775 | %struct.A = type { i32, i8 } |
Devang Patel | f642f47 | 2008-10-06 18:50:38 +0000 | [diff] [blame] | 4776 | %r = call %struct.A @foo() <i>; yields { 32, i8 }</i> |
Dan Gohman | b1e6b96 | 2008-10-04 19:00:07 +0000 | [diff] [blame] | 4777 | %gr = extractvalue %struct.A %r, 0 <i>; yields i32</i> |
| 4778 | %gr1 = extractvalue %struct.A %r, 1 <i>; yields i8</i> |
Chris Lattner | 85a350f | 2008-10-08 06:26:11 +0000 | [diff] [blame] | 4779 | %Z = call void @foo() noreturn <i>; indicates that %foo never returns normally</i> |
Matthijs Kooijman | cb73d19 | 2008-10-07 10:03:45 +0000 | [diff] [blame] | 4780 | %ZZ = call zeroext i32 @bar() <i>; Return value is %zero extended</i> |
Chris Lattner | 2bff524 | 2005-05-06 05:47:36 +0000 | [diff] [blame] | 4781 | </pre> |
| 4782 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4783 | </div> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4784 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 4785 | <!-- _______________________________________________________________________ --> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4786 | <div class="doc_subsubsection"> |
Chris Lattner | fb6977d | 2006-01-13 23:26:01 +0000 | [diff] [blame] | 4787 | <a name="i_va_arg">'<tt>va_arg</tt>' Instruction</a> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4788 | </div> |
| 4789 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4790 | <div class="doc_text"> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4791 | |
Chris Lattner | 8d1a81d | 2003-10-18 05:51:36 +0000 | [diff] [blame] | 4792 | <h5>Syntax:</h5> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4793 | <pre> |
Andrew Lenharth | 8bf607a | 2005-06-18 18:28:17 +0000 | [diff] [blame] | 4794 | <resultval> = va_arg <va_list*> <arglist>, <argty> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4795 | </pre> |
| 4796 | |
Chris Lattner | 8d1a81d | 2003-10-18 05:51:36 +0000 | [diff] [blame] | 4797 | <h5>Overview:</h5> |
Andrew Lenharth | 8bf607a | 2005-06-18 18:28:17 +0000 | [diff] [blame] | 4798 | <p>The '<tt>va_arg</tt>' instruction is used to access arguments passed through |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4799 | the "variable argument" area of a function call. It is used to implement the |
| 4800 | <tt>va_arg</tt> macro in C.</p> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4801 | |
Chris Lattner | 8d1a81d | 2003-10-18 05:51:36 +0000 | [diff] [blame] | 4802 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4803 | <p>This instruction takes a <tt>va_list*</tt> value and the type of the |
| 4804 | argument. It returns a value of the specified argument type and increments |
| 4805 | the <tt>va_list</tt> to point to the next argument. The actual type |
| 4806 | of <tt>va_list</tt> is target specific.</p> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4807 | |
Chris Lattner | 8d1a81d | 2003-10-18 05:51:36 +0000 | [diff] [blame] | 4808 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4809 | <p>The '<tt>va_arg</tt>' instruction loads an argument of the specified type |
| 4810 | from the specified <tt>va_list</tt> and causes the <tt>va_list</tt> to point |
| 4811 | to the next argument. For more information, see the variable argument |
| 4812 | handling <a href="#int_varargs">Intrinsic Functions</a>.</p> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4813 | |
| 4814 | <p>It is legal for this instruction to be called in a function which does not |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4815 | take a variable number of arguments, for example, the <tt>vfprintf</tt> |
| 4816 | function.</p> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4817 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4818 | <p><tt>va_arg</tt> is an LLVM instruction instead of |
| 4819 | an <a href="#intrinsics">intrinsic function</a> because it takes a type as an |
| 4820 | argument.</p> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4821 | |
Chris Lattner | 8d1a81d | 2003-10-18 05:51:36 +0000 | [diff] [blame] | 4822 | <h5>Example:</h5> |
Chris Lattner | e19d7a7 | 2004-09-27 21:51:25 +0000 | [diff] [blame] | 4823 | <p>See the <a href="#int_varargs">variable argument processing</a> section.</p> |
| 4824 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4825 | <p>Note that the code generator does not yet fully support va_arg on many |
| 4826 | targets. Also, it does not currently support va_arg with aggregate types on |
| 4827 | any target.</p> |
Dan Gohman | f3e60bd | 2009-01-12 23:12:39 +0000 | [diff] [blame] | 4828 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4829 | </div> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4830 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 4831 | <!-- *********************************************************************** --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 4832 | <div class="doc_section"> <a name="intrinsics">Intrinsic Functions</a> </div> |
| 4833 | <!-- *********************************************************************** --> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4834 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4835 | <div class="doc_text"> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4836 | |
| 4837 | <p>LLVM supports the notion of an "intrinsic function". These functions have |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4838 | well known names and semantics and are required to follow certain |
| 4839 | restrictions. Overall, these intrinsics represent an extension mechanism for |
| 4840 | the LLVM language that does not require changing all of the transformations |
| 4841 | in LLVM when adding to the language (or the bitcode reader/writer, the |
| 4842 | parser, etc...).</p> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4843 | |
John Criswell | fc6b895 | 2005-05-16 16:17:45 +0000 | [diff] [blame] | 4844 | <p>Intrinsic function names must all start with an "<tt>llvm.</tt>" prefix. This |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4845 | prefix is reserved in LLVM for intrinsic names; thus, function names may not |
| 4846 | begin with this prefix. Intrinsic functions must always be external |
| 4847 | functions: you cannot define the body of intrinsic functions. Intrinsic |
| 4848 | functions may only be used in call or invoke instructions: it is illegal to |
| 4849 | take the address of an intrinsic function. Additionally, because intrinsic |
| 4850 | functions are part of the LLVM language, it is required if any are added that |
| 4851 | they be documented here.</p> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4852 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4853 | <p>Some intrinsic functions can be overloaded, i.e., the intrinsic represents a |
| 4854 | family of functions that perform the same operation but on different data |
| 4855 | types. Because LLVM can represent over 8 million different integer types, |
| 4856 | overloading is used commonly to allow an intrinsic function to operate on any |
| 4857 | integer type. One or more of the argument types or the result type can be |
| 4858 | overloaded to accept any integer type. Argument types may also be defined as |
| 4859 | exactly matching a previous argument's type or the result type. This allows |
| 4860 | an intrinsic function which accepts multiple arguments, but needs all of them |
| 4861 | to be of the same type, to only be overloaded with respect to a single |
| 4862 | argument or the result.</p> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4863 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4864 | <p>Overloaded intrinsics will have the names of its overloaded argument types |
| 4865 | encoded into its function name, each preceded by a period. Only those types |
| 4866 | which are overloaded result in a name suffix. Arguments whose type is matched |
| 4867 | against another type do not. For example, the <tt>llvm.ctpop</tt> function |
| 4868 | can take an integer of any width and returns an integer of exactly the same |
| 4869 | integer width. This leads to a family of functions such as |
| 4870 | <tt>i8 @llvm.ctpop.i8(i8 %val)</tt> and <tt>i29 @llvm.ctpop.i29(i29 |
| 4871 | %val)</tt>. Only one type, the return type, is overloaded, and only one type |
| 4872 | suffix is required. Because the argument's type is matched against the return |
| 4873 | type, it does not require its own name suffix.</p> |
Reid Spencer | 409e28f | 2007-04-01 08:04:23 +0000 | [diff] [blame] | 4874 | |
| 4875 | <p>To learn how to add an intrinsic function, please see the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4876 | <a href="ExtendingLLVM.html">Extending LLVM Guide</a>.</p> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4877 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4878 | </div> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4879 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 4880 | <!-- ======================================================================= --> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4881 | <div class="doc_subsection"> |
| 4882 | <a name="int_varargs">Variable Argument Handling Intrinsics</a> |
| 4883 | </div> |
| 4884 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4885 | <div class="doc_text"> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 4886 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4887 | <p>Variable argument support is defined in LLVM with |
| 4888 | the <a href="#i_va_arg"><tt>va_arg</tt></a> instruction and these three |
| 4889 | intrinsic functions. These functions are related to the similarly named |
| 4890 | macros defined in the <tt><stdarg.h></tt> header file.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 4891 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4892 | <p>All of these functions operate on arguments that use a target-specific value |
| 4893 | type "<tt>va_list</tt>". The LLVM assembly language reference manual does |
| 4894 | not define what this type is, so all transformations should be prepared to |
| 4895 | handle these functions regardless of the type used.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 4896 | |
Chris Lattner | 374ab30 | 2006-05-15 17:26:46 +0000 | [diff] [blame] | 4897 | <p>This example shows how the <a href="#i_va_arg"><tt>va_arg</tt></a> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4898 | instruction and the variable argument handling intrinsic functions are |
| 4899 | used.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 4900 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 4901 | <div class="doc_code"> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4902 | <pre> |
Anton Korobeynikov | 5d522f3 | 2007-03-21 23:58:04 +0000 | [diff] [blame] | 4903 | define i32 @test(i32 %X, ...) { |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4904 | ; Initialize variable argument processing |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 4905 | %ap = alloca i8* |
Chris Lattner | b75137d | 2007-01-08 07:55:15 +0000 | [diff] [blame] | 4906 | %ap2 = bitcast i8** %ap to i8* |
Anton Korobeynikov | 5d522f3 | 2007-03-21 23:58:04 +0000 | [diff] [blame] | 4907 | call void @llvm.va_start(i8* %ap2) |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4908 | |
| 4909 | ; Read a single integer argument |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 4910 | %tmp = va_arg i8** %ap, i32 |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4911 | |
| 4912 | ; Demonstrate usage of llvm.va_copy and llvm.va_end |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 4913 | %aq = alloca i8* |
Chris Lattner | b75137d | 2007-01-08 07:55:15 +0000 | [diff] [blame] | 4914 | %aq2 = bitcast i8** %aq to i8* |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 4915 | call void @llvm.va_copy(i8* %aq2, i8* %ap2) |
Anton Korobeynikov | 5d522f3 | 2007-03-21 23:58:04 +0000 | [diff] [blame] | 4916 | call void @llvm.va_end(i8* %aq2) |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4917 | |
| 4918 | ; Stop processing of arguments. |
Anton Korobeynikov | 5d522f3 | 2007-03-21 23:58:04 +0000 | [diff] [blame] | 4919 | call void @llvm.va_end(i8* %ap2) |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 4920 | ret i32 %tmp |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4921 | } |
Anton Korobeynikov | 5d522f3 | 2007-03-21 23:58:04 +0000 | [diff] [blame] | 4922 | |
| 4923 | declare void @llvm.va_start(i8*) |
| 4924 | declare void @llvm.va_copy(i8*, i8*) |
| 4925 | declare void @llvm.va_end(i8*) |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 4926 | </pre> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4927 | </div> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4928 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 4929 | </div> |
| 4930 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 4931 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4932 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 4933 | <a name="int_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4934 | </div> |
| 4935 | |
| 4936 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4937 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4938 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 4939 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4940 | <pre> |
| 4941 | declare void %llvm.va_start(i8* <arglist>) |
| 4942 | </pre> |
| 4943 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 4944 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4945 | <p>The '<tt>llvm.va_start</tt>' intrinsic initializes <tt>*<arglist></tt> |
| 4946 | for subsequent use by <tt><a href="#i_va_arg">va_arg</a></tt>.</p> |
Andrew Lenharth | 8bf607a | 2005-06-18 18:28:17 +0000 | [diff] [blame] | 4947 | |
| 4948 | <h5>Arguments:</h5> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 4949 | <p>The argument is a pointer to a <tt>va_list</tt> element to initialize.</p> |
Andrew Lenharth | 8bf607a | 2005-06-18 18:28:17 +0000 | [diff] [blame] | 4950 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 4951 | <h5>Semantics:</h5> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 4952 | <p>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4953 | macro available in C. In a target-dependent way, it initializes |
| 4954 | the <tt>va_list</tt> element to which the argument points, so that the next |
| 4955 | call to <tt>va_arg</tt> will produce the first variable argument passed to |
| 4956 | the function. Unlike the C <tt>va_start</tt> macro, this intrinsic does not |
| 4957 | need to know the last argument of the function as the compiler can figure |
| 4958 | that out.</p> |
Andrew Lenharth | 8bf607a | 2005-06-18 18:28:17 +0000 | [diff] [blame] | 4959 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4960 | </div> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4961 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 4962 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4963 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 4964 | <a name="int_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4965 | </div> |
| 4966 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4967 | <div class="doc_text"> |
Chris Lattner | b75137d | 2007-01-08 07:55:15 +0000 | [diff] [blame] | 4968 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4969 | <h5>Syntax:</h5> |
| 4970 | <pre> |
| 4971 | declare void @llvm.va_end(i8* <arglist>) |
| 4972 | </pre> |
| 4973 | |
| 4974 | <h5>Overview:</h5> |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 4975 | <p>The '<tt>llvm.va_end</tt>' intrinsic destroys <tt>*<arglist></tt>, |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4976 | which has been initialized previously |
| 4977 | with <tt><a href="#int_va_start">llvm.va_start</a></tt> |
| 4978 | or <tt><a href="#i_va_copy">llvm.va_copy</a></tt>.</p> |
Chris Lattner | b75137d | 2007-01-08 07:55:15 +0000 | [diff] [blame] | 4979 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 4980 | <h5>Arguments:</h5> |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 4981 | <p>The argument is a pointer to a <tt>va_list</tt> to destroy.</p> |
Chris Lattner | b75137d | 2007-01-08 07:55:15 +0000 | [diff] [blame] | 4982 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 4983 | <h5>Semantics:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4984 | <p>The '<tt>llvm.va_end</tt>' intrinsic works just like the <tt>va_end</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 4985 | macro available in C. In a target-dependent way, it destroys |
| 4986 | the <tt>va_list</tt> element to which the argument points. Calls |
| 4987 | to <a href="#int_va_start"><tt>llvm.va_start</tt></a> |
| 4988 | and <a href="#int_va_copy"> <tt>llvm.va_copy</tt></a> must be matched exactly |
| 4989 | with calls to <tt>llvm.va_end</tt>.</p> |
Chris Lattner | b75137d | 2007-01-08 07:55:15 +0000 | [diff] [blame] | 4990 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4991 | </div> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4992 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 4993 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4994 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 4995 | <a name="int_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 4996 | </div> |
| 4997 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 4998 | <div class="doc_text"> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 4999 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 5000 | <h5>Syntax:</h5> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5001 | <pre> |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5002 | declare void @llvm.va_copy(i8* <destarglist>, i8* <srcarglist>) |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5003 | </pre> |
| 5004 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 5005 | <h5>Overview:</h5> |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 5006 | <p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5007 | from the source argument list to the destination argument list.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5008 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 5009 | <h5>Arguments:</h5> |
Andrew Lenharth | 8bf607a | 2005-06-18 18:28:17 +0000 | [diff] [blame] | 5010 | <p>The first argument is a pointer to a <tt>va_list</tt> element to initialize. |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5011 | The second argument is a pointer to a <tt>va_list</tt> element to copy |
| 5012 | from.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5013 | |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 5014 | <h5>Semantics:</h5> |
Jeff Cohen | b627eab | 2007-04-29 01:07:00 +0000 | [diff] [blame] | 5015 | <p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5016 | macro available in C. In a target-dependent way, it copies the |
| 5017 | source <tt>va_list</tt> element into the destination <tt>va_list</tt> |
| 5018 | element. This intrinsic is necessary because |
| 5019 | the <tt><a href="#int_va_start"> llvm.va_start</a></tt> intrinsic may be |
| 5020 | arbitrarily complex and require, for example, memory allocation.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5021 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 5022 | </div> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 5023 | |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5024 | <!-- ======================================================================= --> |
| 5025 | <div class="doc_subsection"> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5026 | <a name="int_gc">Accurate Garbage Collection Intrinsics</a> |
| 5027 | </div> |
| 5028 | |
| 5029 | <div class="doc_text"> |
| 5030 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5031 | <p>LLVM support for <a href="GarbageCollection.html">Accurate Garbage |
Chris Lattner | d3eda89 | 2008-08-05 18:29:16 +0000 | [diff] [blame] | 5032 | Collection</a> (GC) requires the implementation and generation of these |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5033 | intrinsics. These intrinsics allow identification of <a href="#int_gcroot">GC |
| 5034 | roots on the stack</a>, as well as garbage collector implementations that |
| 5035 | require <a href="#int_gcread">read</a> and <a href="#int_gcwrite">write</a> |
| 5036 | barriers. Front-ends for type-safe garbage collected languages should generate |
| 5037 | these intrinsics to make use of the LLVM garbage collectors. For more details, |
| 5038 | see <a href="GarbageCollection.html">Accurate Garbage Collection with |
| 5039 | LLVM</a>.</p> |
Christopher Lamb | 303dae9 | 2007-12-17 01:00:21 +0000 | [diff] [blame] | 5040 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5041 | <p>The garbage collection intrinsics only operate on objects in the generic |
| 5042 | address space (address space zero).</p> |
Christopher Lamb | 303dae9 | 2007-12-17 01:00:21 +0000 | [diff] [blame] | 5043 | |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5044 | </div> |
| 5045 | |
| 5046 | <!-- _______________________________________________________________________ --> |
| 5047 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5048 | <a name="int_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5049 | </div> |
| 5050 | |
| 5051 | <div class="doc_text"> |
| 5052 | |
| 5053 | <h5>Syntax:</h5> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5054 | <pre> |
Chris Lattner | 1df4f75 | 2007-09-21 17:30:40 +0000 | [diff] [blame] | 5055 | declare void @llvm.gcroot(i8** %ptrloc, i8* %metadata) |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5056 | </pre> |
| 5057 | |
| 5058 | <h5>Overview:</h5> |
John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 5059 | <p>The '<tt>llvm.gcroot</tt>' intrinsic declares the existence of a GC root to |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5060 | the code generator, and allows some metadata to be associated with it.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5061 | |
| 5062 | <h5>Arguments:</h5> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5063 | <p>The first argument specifies the address of a stack object that contains the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5064 | root pointer. The second pointer (which must be either a constant or a |
| 5065 | global value address) contains the meta-data to be associated with the |
| 5066 | root.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5067 | |
| 5068 | <h5>Semantics:</h5> |
Chris Lattner | 05d6709 | 2008-04-24 05:59:56 +0000 | [diff] [blame] | 5069 | <p>At runtime, a call to this intrinsic stores a null pointer into the "ptrloc" |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5070 | location. At compile-time, the code generator generates information to allow |
| 5071 | the runtime to find the pointer at GC safe points. The '<tt>llvm.gcroot</tt>' |
| 5072 | intrinsic may only be used in a function which <a href="#gc">specifies a GC |
| 5073 | algorithm</a>.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5074 | |
| 5075 | </div> |
| 5076 | |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5077 | <!-- _______________________________________________________________________ --> |
| 5078 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5079 | <a name="int_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5080 | </div> |
| 5081 | |
| 5082 | <div class="doc_text"> |
| 5083 | |
| 5084 | <h5>Syntax:</h5> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5085 | <pre> |
Chris Lattner | 1df4f75 | 2007-09-21 17:30:40 +0000 | [diff] [blame] | 5086 | declare i8* @llvm.gcread(i8* %ObjPtr, i8** %Ptr) |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5087 | </pre> |
| 5088 | |
| 5089 | <h5>Overview:</h5> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5090 | <p>The '<tt>llvm.gcread</tt>' intrinsic identifies reads of references from heap |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5091 | locations, allowing garbage collector implementations that require read |
| 5092 | barriers.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5093 | |
| 5094 | <h5>Arguments:</h5> |
Chris Lattner | 80626e9 | 2006-03-14 20:02:51 +0000 | [diff] [blame] | 5095 | <p>The second argument is the address to read from, which should be an address |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5096 | allocated from the garbage collector. The first object is a pointer to the |
| 5097 | start of the referenced object, if needed by the language runtime (otherwise |
| 5098 | null).</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5099 | |
| 5100 | <h5>Semantics:</h5> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5101 | <p>The '<tt>llvm.gcread</tt>' intrinsic has the same semantics as a load |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5102 | instruction, but may be replaced with substantially more complex code by the |
| 5103 | garbage collector runtime, as needed. The '<tt>llvm.gcread</tt>' intrinsic |
| 5104 | may only be used in a function which <a href="#gc">specifies a GC |
| 5105 | algorithm</a>.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5106 | |
| 5107 | </div> |
| 5108 | |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5109 | <!-- _______________________________________________________________________ --> |
| 5110 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5111 | <a name="int_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5112 | </div> |
| 5113 | |
| 5114 | <div class="doc_text"> |
| 5115 | |
| 5116 | <h5>Syntax:</h5> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5117 | <pre> |
Chris Lattner | 1df4f75 | 2007-09-21 17:30:40 +0000 | [diff] [blame] | 5118 | declare void @llvm.gcwrite(i8* %P1, i8* %Obj, i8** %P2) |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5119 | </pre> |
| 5120 | |
| 5121 | <h5>Overview:</h5> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5122 | <p>The '<tt>llvm.gcwrite</tt>' intrinsic identifies writes of references to heap |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5123 | locations, allowing garbage collector implementations that require write |
| 5124 | barriers (such as generational or reference counting collectors).</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5125 | |
| 5126 | <h5>Arguments:</h5> |
Chris Lattner | 80626e9 | 2006-03-14 20:02:51 +0000 | [diff] [blame] | 5127 | <p>The first argument is the reference to store, the second is the start of the |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5128 | object to store it to, and the third is the address of the field of Obj to |
| 5129 | store to. If the runtime does not require a pointer to the object, Obj may |
| 5130 | be null.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5131 | |
| 5132 | <h5>Semantics:</h5> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5133 | <p>The '<tt>llvm.gcwrite</tt>' intrinsic has the same semantics as a store |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5134 | instruction, but may be replaced with substantially more complex code by the |
| 5135 | garbage collector runtime, as needed. The '<tt>llvm.gcwrite</tt>' intrinsic |
| 5136 | may only be used in a function which <a href="#gc">specifies a GC |
| 5137 | algorithm</a>.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5138 | |
| 5139 | </div> |
| 5140 | |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 5141 | <!-- ======================================================================= --> |
| 5142 | <div class="doc_subsection"> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5143 | <a name="int_codegen">Code Generator Intrinsics</a> |
| 5144 | </div> |
| 5145 | |
| 5146 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5147 | |
| 5148 | <p>These intrinsics are provided by LLVM to expose special features that may |
| 5149 | only be implemented with code generator support.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5150 | |
| 5151 | </div> |
| 5152 | |
| 5153 | <!-- _______________________________________________________________________ --> |
| 5154 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5155 | <a name="int_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5156 | </div> |
| 5157 | |
| 5158 | <div class="doc_text"> |
| 5159 | |
| 5160 | <h5>Syntax:</h5> |
| 5161 | <pre> |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5162 | declare i8 *@llvm.returnaddress(i32 <level>) |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5163 | </pre> |
| 5164 | |
| 5165 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5166 | <p>The '<tt>llvm.returnaddress</tt>' intrinsic attempts to compute a |
| 5167 | target-specific value indicating the return address of the current function |
| 5168 | or one of its callers.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5169 | |
| 5170 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5171 | <p>The argument to this intrinsic indicates which function to return the address |
| 5172 | for. Zero indicates the calling function, one indicates its caller, etc. |
| 5173 | The argument is <b>required</b> to be a constant integer value.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5174 | |
| 5175 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5176 | <p>The '<tt>llvm.returnaddress</tt>' intrinsic either returns a pointer |
| 5177 | indicating the return address of the specified call frame, or zero if it |
| 5178 | cannot be identified. The value returned by this intrinsic is likely to be |
| 5179 | incorrect or 0 for arguments other than zero, so it should only be used for |
| 5180 | debugging purposes.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5181 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5182 | <p>Note that calling this intrinsic does not prevent function inlining or other |
| 5183 | aggressive transformations, so the value returned may not be that of the |
| 5184 | obvious source-language caller.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5185 | |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5186 | </div> |
| 5187 | |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5188 | <!-- _______________________________________________________________________ --> |
| 5189 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5190 | <a name="int_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5191 | </div> |
| 5192 | |
| 5193 | <div class="doc_text"> |
| 5194 | |
| 5195 | <h5>Syntax:</h5> |
| 5196 | <pre> |
Chris Lattner | 1df4f75 | 2007-09-21 17:30:40 +0000 | [diff] [blame] | 5197 | declare i8 *@llvm.frameaddress(i32 <level>) |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5198 | </pre> |
| 5199 | |
| 5200 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5201 | <p>The '<tt>llvm.frameaddress</tt>' intrinsic attempts to return the |
| 5202 | target-specific frame pointer value for the specified stack frame.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5203 | |
| 5204 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5205 | <p>The argument to this intrinsic indicates which function to return the frame |
| 5206 | pointer for. Zero indicates the calling function, one indicates its caller, |
| 5207 | etc. The argument is <b>required</b> to be a constant integer value.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5208 | |
| 5209 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5210 | <p>The '<tt>llvm.frameaddress</tt>' intrinsic either returns a pointer |
| 5211 | indicating the frame address of the specified call frame, or zero if it |
| 5212 | cannot be identified. The value returned by this intrinsic is likely to be |
| 5213 | incorrect or 0 for arguments other than zero, so it should only be used for |
| 5214 | debugging purposes.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5215 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5216 | <p>Note that calling this intrinsic does not prevent function inlining or other |
| 5217 | aggressive transformations, so the value returned may not be that of the |
| 5218 | obvious source-language caller.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5219 | |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5220 | </div> |
| 5221 | |
Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 5222 | <!-- _______________________________________________________________________ --> |
| 5223 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5224 | <a name="int_stacksave">'<tt>llvm.stacksave</tt>' Intrinsic</a> |
Chris Lattner | 57e1f39 | 2006-01-13 02:03:13 +0000 | [diff] [blame] | 5225 | </div> |
| 5226 | |
| 5227 | <div class="doc_text"> |
| 5228 | |
| 5229 | <h5>Syntax:</h5> |
| 5230 | <pre> |
Chris Lattner | 1df4f75 | 2007-09-21 17:30:40 +0000 | [diff] [blame] | 5231 | declare i8 *@llvm.stacksave() |
Chris Lattner | 57e1f39 | 2006-01-13 02:03:13 +0000 | [diff] [blame] | 5232 | </pre> |
| 5233 | |
| 5234 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5235 | <p>The '<tt>llvm.stacksave</tt>' intrinsic is used to remember the current state |
| 5236 | of the function stack, for use |
| 5237 | with <a href="#int_stackrestore"> <tt>llvm.stackrestore</tt></a>. This is |
| 5238 | useful for implementing language features like scoped automatic variable |
| 5239 | sized arrays in C99.</p> |
Chris Lattner | 57e1f39 | 2006-01-13 02:03:13 +0000 | [diff] [blame] | 5240 | |
| 5241 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5242 | <p>This intrinsic returns a opaque pointer value that can be passed |
| 5243 | to <a href="#int_stackrestore"><tt>llvm.stackrestore</tt></a>. When |
| 5244 | an <tt>llvm.stackrestore</tt> intrinsic is executed with a value saved |
| 5245 | from <tt>llvm.stacksave</tt>, it effectively restores the state of the stack |
| 5246 | to the state it was in when the <tt>llvm.stacksave</tt> intrinsic executed. |
| 5247 | In practice, this pops any <a href="#i_alloca">alloca</a> blocks from the |
| 5248 | stack that were allocated after the <tt>llvm.stacksave</tt> was executed.</p> |
Chris Lattner | 57e1f39 | 2006-01-13 02:03:13 +0000 | [diff] [blame] | 5249 | |
| 5250 | </div> |
| 5251 | |
| 5252 | <!-- _______________________________________________________________________ --> |
| 5253 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5254 | <a name="int_stackrestore">'<tt>llvm.stackrestore</tt>' Intrinsic</a> |
Chris Lattner | 57e1f39 | 2006-01-13 02:03:13 +0000 | [diff] [blame] | 5255 | </div> |
| 5256 | |
| 5257 | <div class="doc_text"> |
| 5258 | |
| 5259 | <h5>Syntax:</h5> |
| 5260 | <pre> |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5261 | declare void @llvm.stackrestore(i8 * %ptr) |
Chris Lattner | 57e1f39 | 2006-01-13 02:03:13 +0000 | [diff] [blame] | 5262 | </pre> |
| 5263 | |
| 5264 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5265 | <p>The '<tt>llvm.stackrestore</tt>' intrinsic is used to restore the state of |
| 5266 | the function stack to the state it was in when the |
| 5267 | corresponding <a href="#int_stacksave"><tt>llvm.stacksave</tt></a> intrinsic |
| 5268 | executed. This is useful for implementing language features like scoped |
| 5269 | automatic variable sized arrays in C99.</p> |
Chris Lattner | 57e1f39 | 2006-01-13 02:03:13 +0000 | [diff] [blame] | 5270 | |
| 5271 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5272 | <p>See the description |
| 5273 | for <a href="#int_stacksave"><tt>llvm.stacksave</tt></a>.</p> |
Chris Lattner | 57e1f39 | 2006-01-13 02:03:13 +0000 | [diff] [blame] | 5274 | |
| 5275 | </div> |
| 5276 | |
Chris Lattner | 57e1f39 | 2006-01-13 02:03:13 +0000 | [diff] [blame] | 5277 | <!-- _______________________________________________________________________ --> |
| 5278 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5279 | <a name="int_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a> |
Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 5280 | </div> |
| 5281 | |
| 5282 | <div class="doc_text"> |
| 5283 | |
| 5284 | <h5>Syntax:</h5> |
| 5285 | <pre> |
Chris Lattner | 1df4f75 | 2007-09-21 17:30:40 +0000 | [diff] [blame] | 5286 | declare void @llvm.prefetch(i8* <address>, i32 <rw>, i32 <locality>) |
Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 5287 | </pre> |
| 5288 | |
| 5289 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5290 | <p>The '<tt>llvm.prefetch</tt>' intrinsic is a hint to the code generator to |
| 5291 | insert a prefetch instruction if supported; otherwise, it is a noop. |
| 5292 | Prefetches have no effect on the behavior of the program but can change its |
| 5293 | performance characteristics.</p> |
Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 5294 | |
| 5295 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5296 | <p><tt>address</tt> is the address to be prefetched, <tt>rw</tt> is the |
| 5297 | specifier determining if the fetch should be for a read (0) or write (1), |
| 5298 | and <tt>locality</tt> is a temporal locality specifier ranging from (0) - no |
| 5299 | locality, to (3) - extremely local keep in cache. The <tt>rw</tt> |
| 5300 | and <tt>locality</tt> arguments must be constant integers.</p> |
Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 5301 | |
| 5302 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5303 | <p>This intrinsic does not modify the behavior of the program. In particular, |
| 5304 | prefetches cannot trap and do not produce a value. On targets that support |
| 5305 | this intrinsic, the prefetch can provide hints to the processor cache for |
| 5306 | better performance.</p> |
Chris Lattner | 9a9d7ac | 2005-02-28 19:24:19 +0000 | [diff] [blame] | 5307 | |
| 5308 | </div> |
| 5309 | |
Andrew Lenharth | 7f4ec3b | 2005-03-28 20:05:49 +0000 | [diff] [blame] | 5310 | <!-- _______________________________________________________________________ --> |
| 5311 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5312 | <a name="int_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a> |
Andrew Lenharth | 7f4ec3b | 2005-03-28 20:05:49 +0000 | [diff] [blame] | 5313 | </div> |
| 5314 | |
| 5315 | <div class="doc_text"> |
| 5316 | |
| 5317 | <h5>Syntax:</h5> |
| 5318 | <pre> |
Chris Lattner | 1df4f75 | 2007-09-21 17:30:40 +0000 | [diff] [blame] | 5319 | declare void @llvm.pcmarker(i32 <id>) |
Andrew Lenharth | 7f4ec3b | 2005-03-28 20:05:49 +0000 | [diff] [blame] | 5320 | </pre> |
| 5321 | |
| 5322 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5323 | <p>The '<tt>llvm.pcmarker</tt>' intrinsic is a method to export a Program |
| 5324 | Counter (PC) in a region of code to simulators and other tools. The method |
| 5325 | is target specific, but it is expected that the marker will use exported |
| 5326 | symbols to transmit the PC of the marker. The marker makes no guarantees |
| 5327 | that it will remain with any specific instruction after optimizations. It is |
| 5328 | possible that the presence of a marker will inhibit optimizations. The |
| 5329 | intended use is to be inserted after optimizations to allow correlations of |
| 5330 | simulation runs.</p> |
Andrew Lenharth | 7f4ec3b | 2005-03-28 20:05:49 +0000 | [diff] [blame] | 5331 | |
| 5332 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5333 | <p><tt>id</tt> is a numerical id identifying the marker.</p> |
Andrew Lenharth | 7f4ec3b | 2005-03-28 20:05:49 +0000 | [diff] [blame] | 5334 | |
| 5335 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5336 | <p>This intrinsic does not modify the behavior of the program. Backends that do |
| 5337 | not support this intrinisic may ignore it.</p> |
Andrew Lenharth | 7f4ec3b | 2005-03-28 20:05:49 +0000 | [diff] [blame] | 5338 | |
| 5339 | </div> |
| 5340 | |
Andrew Lenharth | 51b8d54 | 2005-11-11 16:47:30 +0000 | [diff] [blame] | 5341 | <!-- _______________________________________________________________________ --> |
| 5342 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5343 | <a name="int_readcyclecounter">'<tt>llvm.readcyclecounter</tt>' Intrinsic</a> |
Andrew Lenharth | 51b8d54 | 2005-11-11 16:47:30 +0000 | [diff] [blame] | 5344 | </div> |
| 5345 | |
| 5346 | <div class="doc_text"> |
| 5347 | |
| 5348 | <h5>Syntax:</h5> |
| 5349 | <pre> |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5350 | declare i64 @llvm.readcyclecounter( ) |
Andrew Lenharth | 51b8d54 | 2005-11-11 16:47:30 +0000 | [diff] [blame] | 5351 | </pre> |
| 5352 | |
| 5353 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5354 | <p>The '<tt>llvm.readcyclecounter</tt>' intrinsic provides access to the cycle |
| 5355 | counter register (or similar low latency, high accuracy clocks) on those |
| 5356 | targets that support it. On X86, it should map to RDTSC. On Alpha, it |
| 5357 | should map to RPCC. As the backing counters overflow quickly (on the order |
| 5358 | of 9 seconds on alpha), this should only be used for small timings.</p> |
Andrew Lenharth | 51b8d54 | 2005-11-11 16:47:30 +0000 | [diff] [blame] | 5359 | |
| 5360 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5361 | <p>When directly supported, reading the cycle counter should not modify any |
| 5362 | memory. Implementations are allowed to either return a application specific |
| 5363 | value or a system wide value. On backends without support, this is lowered |
| 5364 | to a constant 0.</p> |
Andrew Lenharth | 51b8d54 | 2005-11-11 16:47:30 +0000 | [diff] [blame] | 5365 | |
| 5366 | </div> |
| 5367 | |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5368 | <!-- ======================================================================= --> |
| 5369 | <div class="doc_subsection"> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5370 | <a name="int_libc">Standard C Library Intrinsics</a> |
| 5371 | </div> |
| 5372 | |
| 5373 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5374 | |
| 5375 | <p>LLVM provides intrinsics for a few important standard C library functions. |
| 5376 | These intrinsics allow source-language front-ends to pass information about |
| 5377 | the alignment of the pointer arguments to the code generator, providing |
| 5378 | opportunity for more efficient code generation.</p> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5379 | |
| 5380 | </div> |
| 5381 | |
| 5382 | <!-- _______________________________________________________________________ --> |
| 5383 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5384 | <a name="int_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5385 | </div> |
| 5386 | |
| 5387 | <div class="doc_text"> |
| 5388 | |
| 5389 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5390 | <p>This is an overloaded intrinsic. You can use <tt>llvm.memcpy</tt> on any |
| 5391 | integer bit width. Not all targets support all bit widths however.</p> |
| 5392 | |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5393 | <pre> |
Chris Lattner | 824b958 | 2008-11-21 16:42:48 +0000 | [diff] [blame] | 5394 | declare void @llvm.memcpy.i8(i8 * <dest>, i8 * <src>, |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5395 | i8 <len>, i32 <align>) |
Chris Lattner | 824b958 | 2008-11-21 16:42:48 +0000 | [diff] [blame] | 5396 | declare void @llvm.memcpy.i16(i8 * <dest>, i8 * <src>, |
| 5397 | i16 <len>, i32 <align>) |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5398 | declare void @llvm.memcpy.i32(i8 * <dest>, i8 * <src>, |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 5399 | i32 <len>, i32 <align>) |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5400 | declare void @llvm.memcpy.i64(i8 * <dest>, i8 * <src>, |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 5401 | i64 <len>, i32 <align>) |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5402 | </pre> |
| 5403 | |
| 5404 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5405 | <p>The '<tt>llvm.memcpy.*</tt>' intrinsics copy a block of memory from the |
| 5406 | source location to the destination location.</p> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5407 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5408 | <p>Note that, unlike the standard libc function, the <tt>llvm.memcpy.*</tt> |
| 5409 | intrinsics do not return a value, and takes an extra alignment argument.</p> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5410 | |
| 5411 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5412 | <p>The first argument is a pointer to the destination, the second is a pointer |
| 5413 | to the source. The third argument is an integer argument specifying the |
| 5414 | number of bytes to copy, and the fourth argument is the alignment of the |
| 5415 | source and destination locations.</p> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5416 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5417 | <p>If the call to this intrinisic has an alignment value that is not 0 or 1, |
| 5418 | then the caller guarantees that both the source and destination pointers are |
| 5419 | aligned to that boundary.</p> |
Chris Lattner | 3301ced | 2004-02-12 21:18:15 +0000 | [diff] [blame] | 5420 | |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5421 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5422 | <p>The '<tt>llvm.memcpy.*</tt>' intrinsics copy a block of memory from the |
| 5423 | source location to the destination location, which are not allowed to |
| 5424 | overlap. It copies "len" bytes of memory over. If the argument is known to |
| 5425 | be aligned to some boundary, this can be specified as the fourth argument, |
| 5426 | otherwise it should be set to 0 or 1.</p> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5427 | |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 5428 | </div> |
| 5429 | |
Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 5430 | <!-- _______________________________________________________________________ --> |
| 5431 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5432 | <a name="int_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a> |
Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 5433 | </div> |
| 5434 | |
| 5435 | <div class="doc_text"> |
| 5436 | |
| 5437 | <h5>Syntax:</h5> |
Chris Lattner | 824b958 | 2008-11-21 16:42:48 +0000 | [diff] [blame] | 5438 | <p>This is an overloaded intrinsic. You can use llvm.memmove on any integer bit |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5439 | width. Not all targets support all bit widths however.</p> |
| 5440 | |
Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 5441 | <pre> |
Chris Lattner | 824b958 | 2008-11-21 16:42:48 +0000 | [diff] [blame] | 5442 | declare void @llvm.memmove.i8(i8 * <dest>, i8 * <src>, |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5443 | i8 <len>, i32 <align>) |
Chris Lattner | 824b958 | 2008-11-21 16:42:48 +0000 | [diff] [blame] | 5444 | declare void @llvm.memmove.i16(i8 * <dest>, i8 * <src>, |
| 5445 | i16 <len>, i32 <align>) |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5446 | declare void @llvm.memmove.i32(i8 * <dest>, i8 * <src>, |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 5447 | i32 <len>, i32 <align>) |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5448 | declare void @llvm.memmove.i64(i8 * <dest>, i8 * <src>, |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 5449 | i64 <len>, i32 <align>) |
Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 5450 | </pre> |
| 5451 | |
| 5452 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5453 | <p>The '<tt>llvm.memmove.*</tt>' intrinsics move a block of memory from the |
| 5454 | source location to the destination location. It is similar to the |
| 5455 | '<tt>llvm.memcpy</tt>' intrinsic but allows the two memory locations to |
| 5456 | overlap.</p> |
Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 5457 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5458 | <p>Note that, unlike the standard libc function, the <tt>llvm.memmove.*</tt> |
| 5459 | intrinsics do not return a value, and takes an extra alignment argument.</p> |
Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 5460 | |
| 5461 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5462 | <p>The first argument is a pointer to the destination, the second is a pointer |
| 5463 | to the source. The third argument is an integer argument specifying the |
| 5464 | number of bytes to copy, and the fourth argument is the alignment of the |
| 5465 | source and destination locations.</p> |
Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 5466 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5467 | <p>If the call to this intrinisic has an alignment value that is not 0 or 1, |
| 5468 | then the caller guarantees that the source and destination pointers are |
| 5469 | aligned to that boundary.</p> |
Chris Lattner | 3301ced | 2004-02-12 21:18:15 +0000 | [diff] [blame] | 5470 | |
Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 5471 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5472 | <p>The '<tt>llvm.memmove.*</tt>' intrinsics copy a block of memory from the |
| 5473 | source location to the destination location, which may overlap. It copies |
| 5474 | "len" bytes of memory over. If the argument is known to be aligned to some |
| 5475 | boundary, this can be specified as the fourth argument, otherwise it should |
| 5476 | be set to 0 or 1.</p> |
Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 5477 | |
Chris Lattner | 0eb51b4 | 2004-02-12 18:10:10 +0000 | [diff] [blame] | 5478 | </div> |
| 5479 | |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5480 | <!-- _______________________________________________________________________ --> |
| 5481 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5482 | <a name="int_memset">'<tt>llvm.memset.*</tt>' Intrinsics</a> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5483 | </div> |
| 5484 | |
| 5485 | <div class="doc_text"> |
| 5486 | |
| 5487 | <h5>Syntax:</h5> |
Chris Lattner | 824b958 | 2008-11-21 16:42:48 +0000 | [diff] [blame] | 5488 | <p>This is an overloaded intrinsic. You can use llvm.memset on any integer bit |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5489 | width. Not all targets support all bit widths however.</p> |
| 5490 | |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5491 | <pre> |
Chris Lattner | 824b958 | 2008-11-21 16:42:48 +0000 | [diff] [blame] | 5492 | declare void @llvm.memset.i8(i8 * <dest>, i8 <val>, |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5493 | i8 <len>, i32 <align>) |
Chris Lattner | 824b958 | 2008-11-21 16:42:48 +0000 | [diff] [blame] | 5494 | declare void @llvm.memset.i16(i8 * <dest>, i8 <val>, |
| 5495 | i16 <len>, i32 <align>) |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5496 | declare void @llvm.memset.i32(i8 * <dest>, i8 <val>, |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 5497 | i32 <len>, i32 <align>) |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5498 | declare void @llvm.memset.i64(i8 * <dest>, i8 <val>, |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 5499 | i64 <len>, i32 <align>) |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5500 | </pre> |
| 5501 | |
| 5502 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5503 | <p>The '<tt>llvm.memset.*</tt>' intrinsics fill a block of memory with a |
| 5504 | particular byte value.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5505 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5506 | <p>Note that, unlike the standard libc function, the <tt>llvm.memset</tt> |
| 5507 | intrinsic does not return a value, and takes an extra alignment argument.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5508 | |
| 5509 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5510 | <p>The first argument is a pointer to the destination to fill, the second is the |
| 5511 | byte value to fill it with, the third argument is an integer argument |
| 5512 | specifying the number of bytes to fill, and the fourth argument is the known |
| 5513 | alignment of destination location.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5514 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5515 | <p>If the call to this intrinisic has an alignment value that is not 0 or 1, |
| 5516 | then the caller guarantees that the destination pointer is aligned to that |
| 5517 | boundary.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5518 | |
| 5519 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5520 | <p>The '<tt>llvm.memset.*</tt>' intrinsics fill "len" bytes of memory starting |
| 5521 | at the destination location. If the argument is known to be aligned to some |
| 5522 | boundary, this can be specified as the fourth argument, otherwise it should |
| 5523 | be set to 0 or 1.</p> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5524 | |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 5525 | </div> |
| 5526 | |
Chris Lattner | 3200628 | 2004-06-11 02:28:03 +0000 | [diff] [blame] | 5527 | <!-- _______________________________________________________________________ --> |
| 5528 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5529 | <a name="int_sqrt">'<tt>llvm.sqrt.*</tt>' Intrinsic</a> |
Chris Lattner | a4d7414 | 2005-07-21 01:29:16 +0000 | [diff] [blame] | 5530 | </div> |
| 5531 | |
| 5532 | <div class="doc_text"> |
| 5533 | |
| 5534 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5535 | <p>This is an overloaded intrinsic. You can use <tt>llvm.sqrt</tt> on any |
| 5536 | floating point or vector of floating point type. Not all targets support all |
| 5537 | types however.</p> |
| 5538 | |
Chris Lattner | a4d7414 | 2005-07-21 01:29:16 +0000 | [diff] [blame] | 5539 | <pre> |
Dale Johannesen | 408f9c1 | 2007-10-02 17:47:38 +0000 | [diff] [blame] | 5540 | declare float @llvm.sqrt.f32(float %Val) |
| 5541 | declare double @llvm.sqrt.f64(double %Val) |
| 5542 | declare x86_fp80 @llvm.sqrt.f80(x86_fp80 %Val) |
| 5543 | declare fp128 @llvm.sqrt.f128(fp128 %Val) |
| 5544 | declare ppc_fp128 @llvm.sqrt.ppcf128(ppc_fp128 %Val) |
Chris Lattner | a4d7414 | 2005-07-21 01:29:16 +0000 | [diff] [blame] | 5545 | </pre> |
| 5546 | |
| 5547 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5548 | <p>The '<tt>llvm.sqrt</tt>' intrinsics return the sqrt of the specified operand, |
| 5549 | returning the same value as the libm '<tt>sqrt</tt>' functions would. |
| 5550 | Unlike <tt>sqrt</tt> in libm, however, <tt>llvm.sqrt</tt> has undefined |
| 5551 | behavior for negative numbers other than -0.0 (which allows for better |
| 5552 | optimization, because there is no need to worry about errno being |
| 5553 | set). <tt>llvm.sqrt(-0.0)</tt> is defined to return -0.0 like IEEE sqrt.</p> |
Chris Lattner | a4d7414 | 2005-07-21 01:29:16 +0000 | [diff] [blame] | 5554 | |
| 5555 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5556 | <p>The argument and return value are floating point numbers of the same |
| 5557 | type.</p> |
Chris Lattner | a4d7414 | 2005-07-21 01:29:16 +0000 | [diff] [blame] | 5558 | |
| 5559 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5560 | <p>This function returns the sqrt of the specified operand if it is a |
| 5561 | nonnegative floating point number.</p> |
Chris Lattner | a4d7414 | 2005-07-21 01:29:16 +0000 | [diff] [blame] | 5562 | |
Chris Lattner | a4d7414 | 2005-07-21 01:29:16 +0000 | [diff] [blame] | 5563 | </div> |
| 5564 | |
Chris Lattner | f4d252d | 2006-09-08 06:34:02 +0000 | [diff] [blame] | 5565 | <!-- _______________________________________________________________________ --> |
| 5566 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5567 | <a name="int_powi">'<tt>llvm.powi.*</tt>' Intrinsic</a> |
Chris Lattner | f4d252d | 2006-09-08 06:34:02 +0000 | [diff] [blame] | 5568 | </div> |
| 5569 | |
| 5570 | <div class="doc_text"> |
| 5571 | |
| 5572 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5573 | <p>This is an overloaded intrinsic. You can use <tt>llvm.powi</tt> on any |
| 5574 | floating point or vector of floating point type. Not all targets support all |
| 5575 | types however.</p> |
| 5576 | |
Chris Lattner | f4d252d | 2006-09-08 06:34:02 +0000 | [diff] [blame] | 5577 | <pre> |
Dale Johannesen | 408f9c1 | 2007-10-02 17:47:38 +0000 | [diff] [blame] | 5578 | declare float @llvm.powi.f32(float %Val, i32 %power) |
| 5579 | declare double @llvm.powi.f64(double %Val, i32 %power) |
| 5580 | declare x86_fp80 @llvm.powi.f80(x86_fp80 %Val, i32 %power) |
| 5581 | declare fp128 @llvm.powi.f128(fp128 %Val, i32 %power) |
| 5582 | declare ppc_fp128 @llvm.powi.ppcf128(ppc_fp128 %Val, i32 %power) |
Chris Lattner | f4d252d | 2006-09-08 06:34:02 +0000 | [diff] [blame] | 5583 | </pre> |
| 5584 | |
| 5585 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5586 | <p>The '<tt>llvm.powi.*</tt>' intrinsics return the first operand raised to the |
| 5587 | specified (positive or negative) power. The order of evaluation of |
| 5588 | multiplications is not defined. When a vector of floating point type is |
| 5589 | used, the second argument remains a scalar integer value.</p> |
Chris Lattner | f4d252d | 2006-09-08 06:34:02 +0000 | [diff] [blame] | 5590 | |
| 5591 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5592 | <p>The second argument is an integer power, and the first is a value to raise to |
| 5593 | that power.</p> |
Chris Lattner | f4d252d | 2006-09-08 06:34:02 +0000 | [diff] [blame] | 5594 | |
| 5595 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5596 | <p>This function returns the first value raised to the second power with an |
| 5597 | unspecified sequence of rounding operations.</p> |
Chris Lattner | f4d252d | 2006-09-08 06:34:02 +0000 | [diff] [blame] | 5598 | |
Chris Lattner | f4d252d | 2006-09-08 06:34:02 +0000 | [diff] [blame] | 5599 | </div> |
| 5600 | |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5601 | <!-- _______________________________________________________________________ --> |
| 5602 | <div class="doc_subsubsection"> |
| 5603 | <a name="int_sin">'<tt>llvm.sin.*</tt>' Intrinsic</a> |
| 5604 | </div> |
| 5605 | |
| 5606 | <div class="doc_text"> |
| 5607 | |
| 5608 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5609 | <p>This is an overloaded intrinsic. You can use <tt>llvm.sin</tt> on any |
| 5610 | floating point or vector of floating point type. Not all targets support all |
| 5611 | types however.</p> |
| 5612 | |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5613 | <pre> |
| 5614 | declare float @llvm.sin.f32(float %Val) |
| 5615 | declare double @llvm.sin.f64(double %Val) |
| 5616 | declare x86_fp80 @llvm.sin.f80(x86_fp80 %Val) |
| 5617 | declare fp128 @llvm.sin.f128(fp128 %Val) |
| 5618 | declare ppc_fp128 @llvm.sin.ppcf128(ppc_fp128 %Val) |
| 5619 | </pre> |
| 5620 | |
| 5621 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5622 | <p>The '<tt>llvm.sin.*</tt>' intrinsics return the sine of the operand.</p> |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5623 | |
| 5624 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5625 | <p>The argument and return value are floating point numbers of the same |
| 5626 | type.</p> |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5627 | |
| 5628 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5629 | <p>This function returns the sine of the specified operand, returning the same |
| 5630 | values as the libm <tt>sin</tt> functions would, and handles error conditions |
| 5631 | in the same way.</p> |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5632 | |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5633 | </div> |
| 5634 | |
| 5635 | <!-- _______________________________________________________________________ --> |
| 5636 | <div class="doc_subsubsection"> |
| 5637 | <a name="int_cos">'<tt>llvm.cos.*</tt>' Intrinsic</a> |
| 5638 | </div> |
| 5639 | |
| 5640 | <div class="doc_text"> |
| 5641 | |
| 5642 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5643 | <p>This is an overloaded intrinsic. You can use <tt>llvm.cos</tt> on any |
| 5644 | floating point or vector of floating point type. Not all targets support all |
| 5645 | types however.</p> |
| 5646 | |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5647 | <pre> |
| 5648 | declare float @llvm.cos.f32(float %Val) |
| 5649 | declare double @llvm.cos.f64(double %Val) |
| 5650 | declare x86_fp80 @llvm.cos.f80(x86_fp80 %Val) |
| 5651 | declare fp128 @llvm.cos.f128(fp128 %Val) |
| 5652 | declare ppc_fp128 @llvm.cos.ppcf128(ppc_fp128 %Val) |
| 5653 | </pre> |
| 5654 | |
| 5655 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5656 | <p>The '<tt>llvm.cos.*</tt>' intrinsics return the cosine of the operand.</p> |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5657 | |
| 5658 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5659 | <p>The argument and return value are floating point numbers of the same |
| 5660 | type.</p> |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5661 | |
| 5662 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5663 | <p>This function returns the cosine of the specified operand, returning the same |
| 5664 | values as the libm <tt>cos</tt> functions would, and handles error conditions |
| 5665 | in the same way.</p> |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5666 | |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5667 | </div> |
| 5668 | |
| 5669 | <!-- _______________________________________________________________________ --> |
| 5670 | <div class="doc_subsubsection"> |
| 5671 | <a name="int_pow">'<tt>llvm.pow.*</tt>' Intrinsic</a> |
| 5672 | </div> |
| 5673 | |
| 5674 | <div class="doc_text"> |
| 5675 | |
| 5676 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5677 | <p>This is an overloaded intrinsic. You can use <tt>llvm.pow</tt> on any |
| 5678 | floating point or vector of floating point type. Not all targets support all |
| 5679 | types however.</p> |
| 5680 | |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5681 | <pre> |
| 5682 | declare float @llvm.pow.f32(float %Val, float %Power) |
| 5683 | declare double @llvm.pow.f64(double %Val, double %Power) |
| 5684 | declare x86_fp80 @llvm.pow.f80(x86_fp80 %Val, x86_fp80 %Power) |
| 5685 | declare fp128 @llvm.pow.f128(fp128 %Val, fp128 %Power) |
| 5686 | declare ppc_fp128 @llvm.pow.ppcf128(ppc_fp128 %Val, ppc_fp128 Power) |
| 5687 | </pre> |
| 5688 | |
| 5689 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5690 | <p>The '<tt>llvm.pow.*</tt>' intrinsics return the first operand raised to the |
| 5691 | specified (positive or negative) power.</p> |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5692 | |
| 5693 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5694 | <p>The second argument is a floating point power, and the first is a value to |
| 5695 | raise to that power.</p> |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5696 | |
| 5697 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5698 | <p>This function returns the first value raised to the second power, returning |
| 5699 | the same values as the libm <tt>pow</tt> functions would, and handles error |
| 5700 | conditions in the same way.</p> |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5701 | |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 5702 | </div> |
| 5703 | |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5704 | <!-- ======================================================================= --> |
| 5705 | <div class="doc_subsection"> |
Nate Begeman | 7e36c47 | 2006-01-13 23:26:38 +0000 | [diff] [blame] | 5706 | <a name="int_manip">Bit Manipulation Intrinsics</a> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5707 | </div> |
| 5708 | |
| 5709 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5710 | |
| 5711 | <p>LLVM provides intrinsics for a few important bit manipulation operations. |
| 5712 | These allow efficient code generation for some algorithms.</p> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5713 | |
| 5714 | </div> |
| 5715 | |
| 5716 | <!-- _______________________________________________________________________ --> |
| 5717 | <div class="doc_subsubsection"> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 5718 | <a name="int_bswap">'<tt>llvm.bswap.*</tt>' Intrinsics</a> |
Nate Begeman | 7e36c47 | 2006-01-13 23:26:38 +0000 | [diff] [blame] | 5719 | </div> |
| 5720 | |
| 5721 | <div class="doc_text"> |
| 5722 | |
| 5723 | <h5>Syntax:</h5> |
Reid Spencer | 409e28f | 2007-04-01 08:04:23 +0000 | [diff] [blame] | 5724 | <p>This is an overloaded intrinsic function. You can use bswap on any integer |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5725 | type that is an even number of bytes (i.e. BitWidth % 16 == 0).</p> |
| 5726 | |
Nate Begeman | 7e36c47 | 2006-01-13 23:26:38 +0000 | [diff] [blame] | 5727 | <pre> |
Chandler Carruth | 6994040 | 2007-08-04 01:51:18 +0000 | [diff] [blame] | 5728 | declare i16 @llvm.bswap.i16(i16 <id>) |
| 5729 | declare i32 @llvm.bswap.i32(i32 <id>) |
| 5730 | declare i64 @llvm.bswap.i64(i64 <id>) |
Nate Begeman | 7e36c47 | 2006-01-13 23:26:38 +0000 | [diff] [blame] | 5731 | </pre> |
| 5732 | |
| 5733 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5734 | <p>The '<tt>llvm.bswap</tt>' family of intrinsics is used to byte swap integer |
| 5735 | values with an even number of bytes (positive multiple of 16 bits). These |
| 5736 | are useful for performing operations on data that is not in the target's |
| 5737 | native byte order.</p> |
Nate Begeman | 7e36c47 | 2006-01-13 23:26:38 +0000 | [diff] [blame] | 5738 | |
| 5739 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5740 | <p>The <tt>llvm.bswap.i16</tt> intrinsic returns an i16 value that has the high |
| 5741 | and low byte of the input i16 swapped. Similarly, |
| 5742 | the <tt>llvm.bswap.i32</tt> intrinsic returns an i32 value that has the four |
| 5743 | bytes of the input i32 swapped, so that if the input bytes are numbered 0, 1, |
| 5744 | 2, 3 then the returned i32 will have its bytes in 3, 2, 1, 0 order. |
| 5745 | The <tt>llvm.bswap.i48</tt>, <tt>llvm.bswap.i64</tt> and other intrinsics |
| 5746 | extend this concept to additional even-byte lengths (6 bytes, 8 bytes and |
| 5747 | more, respectively).</p> |
Nate Begeman | 7e36c47 | 2006-01-13 23:26:38 +0000 | [diff] [blame] | 5748 | |
| 5749 | </div> |
| 5750 | |
| 5751 | <!-- _______________________________________________________________________ --> |
| 5752 | <div class="doc_subsubsection"> |
Reid Spencer | 0b11820 | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 5753 | <a name="int_ctpop">'<tt>llvm.ctpop.*</tt>' Intrinsic</a> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5754 | </div> |
| 5755 | |
| 5756 | <div class="doc_text"> |
| 5757 | |
| 5758 | <h5>Syntax:</h5> |
Reid Spencer | 409e28f | 2007-04-01 08:04:23 +0000 | [diff] [blame] | 5759 | <p>This is an overloaded intrinsic. You can use llvm.ctpop on any integer bit |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5760 | width. Not all targets support all bit widths however.</p> |
| 5761 | |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5762 | <pre> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5763 | declare i8 @llvm.ctpop.i8(i8 <src>) |
Chandler Carruth | 6994040 | 2007-08-04 01:51:18 +0000 | [diff] [blame] | 5764 | declare i16 @llvm.ctpop.i16(i16 <src>) |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5765 | declare i32 @llvm.ctpop.i32(i32 <src>) |
Chandler Carruth | 6994040 | 2007-08-04 01:51:18 +0000 | [diff] [blame] | 5766 | declare i64 @llvm.ctpop.i64(i64 <src>) |
| 5767 | declare i256 @llvm.ctpop.i256(i256 <src>) |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5768 | </pre> |
| 5769 | |
| 5770 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5771 | <p>The '<tt>llvm.ctpop</tt>' family of intrinsics counts the number of bits set |
| 5772 | in a value.</p> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5773 | |
| 5774 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5775 | <p>The only argument is the value to be counted. The argument may be of any |
| 5776 | integer type. The return type must match the argument type.</p> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5777 | |
| 5778 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5779 | <p>The '<tt>llvm.ctpop</tt>' intrinsic counts the 1's in a variable.</p> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5780 | |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5781 | </div> |
| 5782 | |
| 5783 | <!-- _______________________________________________________________________ --> |
| 5784 | <div class="doc_subsubsection"> |
Chris Lattner | 8a886be | 2006-01-16 22:34:14 +0000 | [diff] [blame] | 5785 | <a name="int_ctlz">'<tt>llvm.ctlz.*</tt>' Intrinsic</a> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5786 | </div> |
| 5787 | |
| 5788 | <div class="doc_text"> |
| 5789 | |
| 5790 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5791 | <p>This is an overloaded intrinsic. You can use <tt>llvm.ctlz</tt> on any |
| 5792 | integer bit width. Not all targets support all bit widths however.</p> |
| 5793 | |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5794 | <pre> |
Chandler Carruth | 6994040 | 2007-08-04 01:51:18 +0000 | [diff] [blame] | 5795 | declare i8 @llvm.ctlz.i8 (i8 <src>) |
| 5796 | declare i16 @llvm.ctlz.i16(i16 <src>) |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5797 | declare i32 @llvm.ctlz.i32(i32 <src>) |
Chandler Carruth | 6994040 | 2007-08-04 01:51:18 +0000 | [diff] [blame] | 5798 | declare i64 @llvm.ctlz.i64(i64 <src>) |
| 5799 | declare i256 @llvm.ctlz.i256(i256 <src>) |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5800 | </pre> |
| 5801 | |
| 5802 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5803 | <p>The '<tt>llvm.ctlz</tt>' family of intrinsic functions counts the number of |
| 5804 | leading zeros in a variable.</p> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5805 | |
| 5806 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5807 | <p>The only argument is the value to be counted. The argument may be of any |
| 5808 | integer type. The return type must match the argument type.</p> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5809 | |
| 5810 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5811 | <p>The '<tt>llvm.ctlz</tt>' intrinsic counts the leading (most significant) |
| 5812 | zeros in a variable. If the src == 0 then the result is the size in bits of |
| 5813 | the type of src. For example, <tt>llvm.ctlz(i32 2) = 30</tt>.</p> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5814 | |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 5815 | </div> |
Chris Lattner | 3200628 | 2004-06-11 02:28:03 +0000 | [diff] [blame] | 5816 | |
Chris Lattner | eff29ab | 2005-05-15 19:39:26 +0000 | [diff] [blame] | 5817 | <!-- _______________________________________________________________________ --> |
| 5818 | <div class="doc_subsubsection"> |
Chris Lattner | 8a886be | 2006-01-16 22:34:14 +0000 | [diff] [blame] | 5819 | <a name="int_cttz">'<tt>llvm.cttz.*</tt>' Intrinsic</a> |
Chris Lattner | eff29ab | 2005-05-15 19:39:26 +0000 | [diff] [blame] | 5820 | </div> |
| 5821 | |
| 5822 | <div class="doc_text"> |
| 5823 | |
| 5824 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5825 | <p>This is an overloaded intrinsic. You can use <tt>llvm.cttz</tt> on any |
| 5826 | integer bit width. Not all targets support all bit widths however.</p> |
| 5827 | |
Chris Lattner | eff29ab | 2005-05-15 19:39:26 +0000 | [diff] [blame] | 5828 | <pre> |
Chandler Carruth | 6994040 | 2007-08-04 01:51:18 +0000 | [diff] [blame] | 5829 | declare i8 @llvm.cttz.i8 (i8 <src>) |
| 5830 | declare i16 @llvm.cttz.i16(i16 <src>) |
Anton Korobeynikov | ec43a06 | 2007-03-22 00:02:17 +0000 | [diff] [blame] | 5831 | declare i32 @llvm.cttz.i32(i32 <src>) |
Chandler Carruth | 6994040 | 2007-08-04 01:51:18 +0000 | [diff] [blame] | 5832 | declare i64 @llvm.cttz.i64(i64 <src>) |
| 5833 | declare i256 @llvm.cttz.i256(i256 <src>) |
Chris Lattner | eff29ab | 2005-05-15 19:39:26 +0000 | [diff] [blame] | 5834 | </pre> |
| 5835 | |
| 5836 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5837 | <p>The '<tt>llvm.cttz</tt>' family of intrinsic functions counts the number of |
| 5838 | trailing zeros.</p> |
Chris Lattner | eff29ab | 2005-05-15 19:39:26 +0000 | [diff] [blame] | 5839 | |
| 5840 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5841 | <p>The only argument is the value to be counted. The argument may be of any |
| 5842 | integer type. The return type must match the argument type.</p> |
Chris Lattner | eff29ab | 2005-05-15 19:39:26 +0000 | [diff] [blame] | 5843 | |
| 5844 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5845 | <p>The '<tt>llvm.cttz</tt>' intrinsic counts the trailing (least significant) |
| 5846 | zeros in a variable. If the src == 0 then the result is the size in bits of |
| 5847 | the type of src. For example, <tt>llvm.cttz(2) = 1</tt>.</p> |
Chris Lattner | eff29ab | 2005-05-15 19:39:26 +0000 | [diff] [blame] | 5848 | |
Chris Lattner | eff29ab | 2005-05-15 19:39:26 +0000 | [diff] [blame] | 5849 | </div> |
| 5850 | |
Bill Wendling | da01af7 | 2009-02-08 04:04:40 +0000 | [diff] [blame] | 5851 | <!-- ======================================================================= --> |
| 5852 | <div class="doc_subsection"> |
| 5853 | <a name="int_overflow">Arithmetic with Overflow Intrinsics</a> |
| 5854 | </div> |
| 5855 | |
| 5856 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5857 | |
| 5858 | <p>LLVM provides intrinsics for some arithmetic with overflow operations.</p> |
Bill Wendling | da01af7 | 2009-02-08 04:04:40 +0000 | [diff] [blame] | 5859 | |
| 5860 | </div> |
| 5861 | |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5862 | <!-- _______________________________________________________________________ --> |
| 5863 | <div class="doc_subsubsection"> |
Bill Wendling | da01af7 | 2009-02-08 04:04:40 +0000 | [diff] [blame] | 5864 | <a name="int_sadd_overflow">'<tt>llvm.sadd.with.overflow.*</tt>' Intrinsics</a> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5865 | </div> |
| 5866 | |
| 5867 | <div class="doc_text"> |
| 5868 | |
| 5869 | <h5>Syntax:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5870 | <p>This is an overloaded intrinsic. You can use <tt>llvm.sadd.with.overflow</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5871 | on any integer bit width.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5872 | |
| 5873 | <pre> |
| 5874 | declare {i16, i1} @llvm.sadd.with.overflow.i16(i16 %a, i16 %b) |
| 5875 | declare {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b) |
| 5876 | declare {i64, i1} @llvm.sadd.with.overflow.i64(i64 %a, i64 %b) |
| 5877 | </pre> |
| 5878 | |
| 5879 | <h5>Overview:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5880 | <p>The '<tt>llvm.sadd.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5881 | a signed addition of the two arguments, and indicate whether an overflow |
| 5882 | occurred during the signed summation.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5883 | |
| 5884 | <h5>Arguments:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5885 | <p>The arguments (%a and %b) and the first element of the result structure may |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5886 | be of integer types of any bit width, but they must have the same bit |
| 5887 | width. The second element of the result structure must be of |
| 5888 | type <tt>i1</tt>. <tt>%a</tt> and <tt>%b</tt> are the two values that will |
| 5889 | undergo signed addition.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5890 | |
| 5891 | <h5>Semantics:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5892 | <p>The '<tt>llvm.sadd.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5893 | a signed addition of the two variables. They return a structure — the |
| 5894 | first element of which is the signed summation, and the second element of |
| 5895 | which is a bit specifying if the signed summation resulted in an |
| 5896 | overflow.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5897 | |
| 5898 | <h5>Examples:</h5> |
| 5899 | <pre> |
| 5900 | %res = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b) |
| 5901 | %sum = extractvalue {i32, i1} %res, 0 |
| 5902 | %obit = extractvalue {i32, i1} %res, 1 |
| 5903 | br i1 %obit, label %overflow, label %normal |
| 5904 | </pre> |
| 5905 | |
| 5906 | </div> |
| 5907 | |
| 5908 | <!-- _______________________________________________________________________ --> |
| 5909 | <div class="doc_subsubsection"> |
Bill Wendling | da01af7 | 2009-02-08 04:04:40 +0000 | [diff] [blame] | 5910 | <a name="int_uadd_overflow">'<tt>llvm.uadd.with.overflow.*</tt>' Intrinsics</a> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5911 | </div> |
| 5912 | |
| 5913 | <div class="doc_text"> |
| 5914 | |
| 5915 | <h5>Syntax:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5916 | <p>This is an overloaded intrinsic. You can use <tt>llvm.uadd.with.overflow</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5917 | on any integer bit width.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5918 | |
| 5919 | <pre> |
| 5920 | declare {i16, i1} @llvm.uadd.with.overflow.i16(i16 %a, i16 %b) |
| 5921 | declare {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b) |
| 5922 | declare {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 %b) |
| 5923 | </pre> |
| 5924 | |
| 5925 | <h5>Overview:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5926 | <p>The '<tt>llvm.uadd.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5927 | an unsigned addition of the two arguments, and indicate whether a carry |
| 5928 | occurred during the unsigned summation.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5929 | |
| 5930 | <h5>Arguments:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5931 | <p>The arguments (%a and %b) and the first element of the result structure may |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5932 | be of integer types of any bit width, but they must have the same bit |
| 5933 | width. The second element of the result structure must be of |
| 5934 | type <tt>i1</tt>. <tt>%a</tt> and <tt>%b</tt> are the two values that will |
| 5935 | undergo unsigned addition.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5936 | |
| 5937 | <h5>Semantics:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5938 | <p>The '<tt>llvm.uadd.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5939 | an unsigned addition of the two arguments. They return a structure — |
| 5940 | the first element of which is the sum, and the second element of which is a |
| 5941 | bit specifying if the unsigned summation resulted in a carry.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5942 | |
| 5943 | <h5>Examples:</h5> |
| 5944 | <pre> |
| 5945 | %res = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b) |
| 5946 | %sum = extractvalue {i32, i1} %res, 0 |
| 5947 | %obit = extractvalue {i32, i1} %res, 1 |
| 5948 | br i1 %obit, label %carry, label %normal |
| 5949 | </pre> |
| 5950 | |
| 5951 | </div> |
| 5952 | |
| 5953 | <!-- _______________________________________________________________________ --> |
| 5954 | <div class="doc_subsubsection"> |
Bill Wendling | da01af7 | 2009-02-08 04:04:40 +0000 | [diff] [blame] | 5955 | <a name="int_ssub_overflow">'<tt>llvm.ssub.with.overflow.*</tt>' Intrinsics</a> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5956 | </div> |
| 5957 | |
| 5958 | <div class="doc_text"> |
| 5959 | |
| 5960 | <h5>Syntax:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5961 | <p>This is an overloaded intrinsic. You can use <tt>llvm.ssub.with.overflow</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5962 | on any integer bit width.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5963 | |
| 5964 | <pre> |
| 5965 | declare {i16, i1} @llvm.ssub.with.overflow.i16(i16 %a, i16 %b) |
| 5966 | declare {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b) |
| 5967 | declare {i64, i1} @llvm.ssub.with.overflow.i64(i64 %a, i64 %b) |
| 5968 | </pre> |
| 5969 | |
| 5970 | <h5>Overview:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5971 | <p>The '<tt>llvm.ssub.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5972 | a signed subtraction of the two arguments, and indicate whether an overflow |
| 5973 | occurred during the signed subtraction.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5974 | |
| 5975 | <h5>Arguments:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5976 | <p>The arguments (%a and %b) and the first element of the result structure may |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5977 | be of integer types of any bit width, but they must have the same bit |
| 5978 | width. The second element of the result structure must be of |
| 5979 | type <tt>i1</tt>. <tt>%a</tt> and <tt>%b</tt> are the two values that will |
| 5980 | undergo signed subtraction.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5981 | |
| 5982 | <h5>Semantics:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5983 | <p>The '<tt>llvm.ssub.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 5984 | a signed subtraction of the two arguments. They return a structure — |
| 5985 | the first element of which is the subtraction, and the second element of |
| 5986 | which is a bit specifying if the signed subtraction resulted in an |
| 5987 | overflow.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 5988 | |
| 5989 | <h5>Examples:</h5> |
| 5990 | <pre> |
| 5991 | %res = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b) |
| 5992 | %sum = extractvalue {i32, i1} %res, 0 |
| 5993 | %obit = extractvalue {i32, i1} %res, 1 |
| 5994 | br i1 %obit, label %overflow, label %normal |
| 5995 | </pre> |
| 5996 | |
| 5997 | </div> |
| 5998 | |
| 5999 | <!-- _______________________________________________________________________ --> |
| 6000 | <div class="doc_subsubsection"> |
Bill Wendling | da01af7 | 2009-02-08 04:04:40 +0000 | [diff] [blame] | 6001 | <a name="int_usub_overflow">'<tt>llvm.usub.with.overflow.*</tt>' Intrinsics</a> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6002 | </div> |
| 6003 | |
| 6004 | <div class="doc_text"> |
| 6005 | |
| 6006 | <h5>Syntax:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6007 | <p>This is an overloaded intrinsic. You can use <tt>llvm.usub.with.overflow</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6008 | on any integer bit width.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6009 | |
| 6010 | <pre> |
| 6011 | declare {i16, i1} @llvm.usub.with.overflow.i16(i16 %a, i16 %b) |
| 6012 | declare {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b) |
| 6013 | declare {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b) |
| 6014 | </pre> |
| 6015 | |
| 6016 | <h5>Overview:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6017 | <p>The '<tt>llvm.usub.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6018 | an unsigned subtraction of the two arguments, and indicate whether an |
| 6019 | overflow occurred during the unsigned subtraction.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6020 | |
| 6021 | <h5>Arguments:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6022 | <p>The arguments (%a and %b) and the first element of the result structure may |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6023 | be of integer types of any bit width, but they must have the same bit |
| 6024 | width. The second element of the result structure must be of |
| 6025 | type <tt>i1</tt>. <tt>%a</tt> and <tt>%b</tt> are the two values that will |
| 6026 | undergo unsigned subtraction.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6027 | |
| 6028 | <h5>Semantics:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6029 | <p>The '<tt>llvm.usub.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6030 | an unsigned subtraction of the two arguments. They return a structure — |
| 6031 | the first element of which is the subtraction, and the second element of |
| 6032 | which is a bit specifying if the unsigned subtraction resulted in an |
| 6033 | overflow.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6034 | |
| 6035 | <h5>Examples:</h5> |
| 6036 | <pre> |
| 6037 | %res = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b) |
| 6038 | %sum = extractvalue {i32, i1} %res, 0 |
| 6039 | %obit = extractvalue {i32, i1} %res, 1 |
| 6040 | br i1 %obit, label %overflow, label %normal |
| 6041 | </pre> |
| 6042 | |
| 6043 | </div> |
| 6044 | |
| 6045 | <!-- _______________________________________________________________________ --> |
| 6046 | <div class="doc_subsubsection"> |
Bill Wendling | da01af7 | 2009-02-08 04:04:40 +0000 | [diff] [blame] | 6047 | <a name="int_smul_overflow">'<tt>llvm.smul.with.overflow.*</tt>' Intrinsics</a> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6048 | </div> |
| 6049 | |
| 6050 | <div class="doc_text"> |
| 6051 | |
| 6052 | <h5>Syntax:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6053 | <p>This is an overloaded intrinsic. You can use <tt>llvm.smul.with.overflow</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6054 | on any integer bit width.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6055 | |
| 6056 | <pre> |
| 6057 | declare {i16, i1} @llvm.smul.with.overflow.i16(i16 %a, i16 %b) |
| 6058 | declare {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b) |
| 6059 | declare {i64, i1} @llvm.smul.with.overflow.i64(i64 %a, i64 %b) |
| 6060 | </pre> |
| 6061 | |
| 6062 | <h5>Overview:</h5> |
| 6063 | |
| 6064 | <p>The '<tt>llvm.smul.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6065 | a signed multiplication of the two arguments, and indicate whether an |
| 6066 | overflow occurred during the signed multiplication.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6067 | |
| 6068 | <h5>Arguments:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6069 | <p>The arguments (%a and %b) and the first element of the result structure may |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6070 | be of integer types of any bit width, but they must have the same bit |
| 6071 | width. The second element of the result structure must be of |
| 6072 | type <tt>i1</tt>. <tt>%a</tt> and <tt>%b</tt> are the two values that will |
| 6073 | undergo signed multiplication.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6074 | |
| 6075 | <h5>Semantics:</h5> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6076 | <p>The '<tt>llvm.smul.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6077 | a signed multiplication of the two arguments. They return a structure — |
| 6078 | the first element of which is the multiplication, and the second element of |
| 6079 | which is a bit specifying if the signed multiplication resulted in an |
| 6080 | overflow.</p> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 6081 | |
| 6082 | <h5>Examples:</h5> |
| 6083 | <pre> |
| 6084 | %res = call {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b) |
| 6085 | %sum = extractvalue {i32, i1} %res, 0 |
| 6086 | %obit = extractvalue {i32, i1} %res, 1 |
| 6087 | br i1 %obit, label %overflow, label %normal |
| 6088 | </pre> |
| 6089 | |
Reid Spencer | f86037f | 2007-04-11 23:23:49 +0000 | [diff] [blame] | 6090 | </div> |
| 6091 | |
Bill Wendling | 41b485c | 2009-02-08 23:00:09 +0000 | [diff] [blame] | 6092 | <!-- _______________________________________________________________________ --> |
| 6093 | <div class="doc_subsubsection"> |
| 6094 | <a name="int_umul_overflow">'<tt>llvm.umul.with.overflow.*</tt>' Intrinsics</a> |
| 6095 | </div> |
| 6096 | |
| 6097 | <div class="doc_text"> |
| 6098 | |
| 6099 | <h5>Syntax:</h5> |
Bill Wendling | 41b485c | 2009-02-08 23:00:09 +0000 | [diff] [blame] | 6100 | <p>This is an overloaded intrinsic. You can use <tt>llvm.umul.with.overflow</tt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6101 | on any integer bit width.</p> |
Bill Wendling | 41b485c | 2009-02-08 23:00:09 +0000 | [diff] [blame] | 6102 | |
| 6103 | <pre> |
| 6104 | declare {i16, i1} @llvm.umul.with.overflow.i16(i16 %a, i16 %b) |
| 6105 | declare {i32, i1} @llvm.umul.with.overflow.i32(i32 %a, i32 %b) |
| 6106 | declare {i64, i1} @llvm.umul.with.overflow.i64(i64 %a, i64 %b) |
| 6107 | </pre> |
| 6108 | |
| 6109 | <h5>Overview:</h5> |
Bill Wendling | 41b485c | 2009-02-08 23:00:09 +0000 | [diff] [blame] | 6110 | <p>The '<tt>llvm.umul.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6111 | a unsigned multiplication of the two arguments, and indicate whether an |
| 6112 | overflow occurred during the unsigned multiplication.</p> |
Bill Wendling | 41b485c | 2009-02-08 23:00:09 +0000 | [diff] [blame] | 6113 | |
| 6114 | <h5>Arguments:</h5> |
Bill Wendling | 41b485c | 2009-02-08 23:00:09 +0000 | [diff] [blame] | 6115 | <p>The arguments (%a and %b) and the first element of the result structure may |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6116 | be of integer types of any bit width, but they must have the same bit |
| 6117 | width. The second element of the result structure must be of |
| 6118 | type <tt>i1</tt>. <tt>%a</tt> and <tt>%b</tt> are the two values that will |
| 6119 | undergo unsigned multiplication.</p> |
Bill Wendling | 41b485c | 2009-02-08 23:00:09 +0000 | [diff] [blame] | 6120 | |
| 6121 | <h5>Semantics:</h5> |
Bill Wendling | 41b485c | 2009-02-08 23:00:09 +0000 | [diff] [blame] | 6122 | <p>The '<tt>llvm.umul.with.overflow</tt>' family of intrinsic functions perform |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6123 | an unsigned multiplication of the two arguments. They return a structure |
| 6124 | — the first element of which is the multiplication, and the second |
| 6125 | element of which is a bit specifying if the unsigned multiplication resulted |
| 6126 | in an overflow.</p> |
Bill Wendling | 41b485c | 2009-02-08 23:00:09 +0000 | [diff] [blame] | 6127 | |
| 6128 | <h5>Examples:</h5> |
| 6129 | <pre> |
| 6130 | %res = call {i32, i1} @llvm.umul.with.overflow.i32(i32 %a, i32 %b) |
| 6131 | %sum = extractvalue {i32, i1} %res, 0 |
| 6132 | %obit = extractvalue {i32, i1} %res, 1 |
| 6133 | br i1 %obit, label %overflow, label %normal |
| 6134 | </pre> |
| 6135 | |
| 6136 | </div> |
| 6137 | |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 6138 | <!-- ======================================================================= --> |
| 6139 | <div class="doc_subsection"> |
| 6140 | <a name="int_debugger">Debugger Intrinsics</a> |
| 6141 | </div> |
| 6142 | |
| 6143 | <div class="doc_text"> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 6144 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6145 | <p>The LLVM debugger intrinsics (which all start with <tt>llvm.dbg.</tt> |
| 6146 | prefix), are described in |
| 6147 | the <a href="SourceLevelDebugging.html#format_common_intrinsics">LLVM Source |
| 6148 | Level Debugging</a> document.</p> |
| 6149 | |
| 6150 | </div> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 6151 | |
Jim Laskey | dd4ef1b | 2007-03-14 19:31:19 +0000 | [diff] [blame] | 6152 | <!-- ======================================================================= --> |
| 6153 | <div class="doc_subsection"> |
| 6154 | <a name="int_eh">Exception Handling Intrinsics</a> |
| 6155 | </div> |
| 6156 | |
| 6157 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6158 | |
| 6159 | <p>The LLVM exception handling intrinsics (which all start with |
| 6160 | <tt>llvm.eh.</tt> prefix), are described in |
| 6161 | the <a href="ExceptionHandling.html#format_common_intrinsics">LLVM Exception |
| 6162 | Handling</a> document.</p> |
| 6163 | |
Jim Laskey | dd4ef1b | 2007-03-14 19:31:19 +0000 | [diff] [blame] | 6164 | </div> |
| 6165 | |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 6166 | <!-- ======================================================================= --> |
| 6167 | <div class="doc_subsection"> |
Duncan Sands | f7331b3 | 2007-09-11 14:10:23 +0000 | [diff] [blame] | 6168 | <a name="int_trampoline">Trampoline Intrinsic</a> |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 6169 | </div> |
| 6170 | |
| 6171 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6172 | |
| 6173 | <p>This intrinsic makes it possible to excise one parameter, marked with |
| 6174 | the <tt>nest</tt> attribute, from a function. The result is a callable |
| 6175 | function pointer lacking the nest parameter - the caller does not need to |
| 6176 | provide a value for it. Instead, the value to use is stored in advance in a |
| 6177 | "trampoline", a block of memory usually allocated on the stack, which also |
| 6178 | contains code to splice the nest value into the argument list. This is used |
| 6179 | to implement the GCC nested function address extension.</p> |
| 6180 | |
| 6181 | <p>For example, if the function is |
| 6182 | <tt>i32 f(i8* nest %c, i32 %x, i32 %y)</tt> then the resulting function |
| 6183 | pointer has signature <tt>i32 (i32, i32)*</tt>. It can be created as |
| 6184 | follows:</p> |
| 6185 | |
| 6186 | <div class="doc_code"> |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 6187 | <pre> |
Duncan Sands | f7331b3 | 2007-09-11 14:10:23 +0000 | [diff] [blame] | 6188 | %tramp = alloca [10 x i8], align 4 ; size and alignment only correct for X86 |
| 6189 | %tramp1 = getelementptr [10 x i8]* %tramp, i32 0, i32 0 |
| 6190 | %p = call i8* @llvm.init.trampoline( i8* %tramp1, i8* bitcast (i32 (i8* nest , i32, i32)* @f to i8*), i8* %nval ) |
| 6191 | %fp = bitcast i8* %p to i32 (i32, i32)* |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 6192 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6193 | </div> |
| 6194 | |
| 6195 | <p>The call <tt>%val = call i32 %fp( i32 %x, i32 %y )</tt> is then equivalent |
| 6196 | to <tt>%val = call i32 %f( i8* %nval, i32 %x, i32 %y )</tt>.</p> |
| 6197 | |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 6198 | </div> |
| 6199 | |
| 6200 | <!-- _______________________________________________________________________ --> |
| 6201 | <div class="doc_subsubsection"> |
| 6202 | <a name="int_it">'<tt>llvm.init.trampoline</tt>' Intrinsic</a> |
| 6203 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6204 | |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 6205 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6206 | |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 6207 | <h5>Syntax:</h5> |
| 6208 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6209 | declare i8* @llvm.init.trampoline(i8* <tramp>, i8* <func>, i8* <nval>) |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 6210 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6211 | |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 6212 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6213 | <p>This fills the memory pointed to by <tt>tramp</tt> with code and returns a |
| 6214 | function pointer suitable for executing it.</p> |
| 6215 | |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 6216 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6217 | <p>The <tt>llvm.init.trampoline</tt> intrinsic takes three arguments, all |
| 6218 | pointers. The <tt>tramp</tt> argument must point to a sufficiently large and |
| 6219 | sufficiently aligned block of memory; this memory is written to by the |
| 6220 | intrinsic. Note that the size and the alignment are target-specific - LLVM |
| 6221 | currently provides no portable way of determining them, so a front-end that |
| 6222 | generates this intrinsic needs to have some target-specific knowledge. |
| 6223 | The <tt>func</tt> argument must hold a function bitcast to |
| 6224 | an <tt>i8*</tt>.</p> |
| 6225 | |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 6226 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6227 | <p>The block of memory pointed to by <tt>tramp</tt> is filled with target |
| 6228 | dependent code, turning it into a function. A pointer to this function is |
| 6229 | returned, but needs to be bitcast to an <a href="#int_trampoline">appropriate |
| 6230 | function pointer type</a> before being called. The new function's signature |
| 6231 | is the same as that of <tt>func</tt> with any arguments marked with |
| 6232 | the <tt>nest</tt> attribute removed. At most one such <tt>nest</tt> argument |
| 6233 | is allowed, and it must be of pointer type. Calling the new function is |
| 6234 | equivalent to calling <tt>func</tt> with the same argument list, but |
| 6235 | with <tt>nval</tt> used for the missing <tt>nest</tt> argument. If, after |
| 6236 | calling <tt>llvm.init.trampoline</tt>, the memory pointed to |
| 6237 | by <tt>tramp</tt> is modified, then the effect of any later call to the |
| 6238 | returned function pointer is undefined.</p> |
| 6239 | |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 6240 | </div> |
| 6241 | |
| 6242 | <!-- ======================================================================= --> |
| 6243 | <div class="doc_subsection"> |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6244 | <a name="int_atomics">Atomic Operations and Synchronization Intrinsics</a> |
| 6245 | </div> |
| 6246 | |
| 6247 | <div class="doc_text"> |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6248 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6249 | <p>These intrinsic functions expand the "universal IR" of LLVM to represent |
| 6250 | hardware constructs for atomic operations and memory synchronization. This |
| 6251 | provides an interface to the hardware, not an interface to the programmer. It |
| 6252 | is aimed at a low enough level to allow any programming models or APIs |
| 6253 | (Application Programming Interfaces) which need atomic behaviors to map |
| 6254 | cleanly onto it. It is also modeled primarily on hardware behavior. Just as |
| 6255 | hardware provides a "universal IR" for source languages, it also provides a |
| 6256 | starting point for developing a "universal" atomic operation and |
| 6257 | synchronization IR.</p> |
| 6258 | |
| 6259 | <p>These do <em>not</em> form an API such as high-level threading libraries, |
| 6260 | software transaction memory systems, atomic primitives, and intrinsic |
| 6261 | functions as found in BSD, GNU libc, atomic_ops, APR, and other system and |
| 6262 | application libraries. The hardware interface provided by LLVM should allow |
| 6263 | a clean implementation of all of these APIs and parallel programming models. |
| 6264 | No one model or paradigm should be selected above others unless the hardware |
| 6265 | itself ubiquitously does so.</p> |
| 6266 | |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6267 | </div> |
| 6268 | |
| 6269 | <!-- _______________________________________________________________________ --> |
| 6270 | <div class="doc_subsubsection"> |
| 6271 | <a name="int_memory_barrier">'<tt>llvm.memory.barrier</tt>' Intrinsic</a> |
| 6272 | </div> |
| 6273 | <div class="doc_text"> |
| 6274 | <h5>Syntax:</h5> |
| 6275 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6276 | declare void @llvm.memory.barrier( i1 <ll>, i1 <ls>, i1 <sl>, i1 <ss>, i1 <device> ) |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6277 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6278 | |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6279 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6280 | <p>The <tt>llvm.memory.barrier</tt> intrinsic guarantees ordering between |
| 6281 | specific pairs of memory access types.</p> |
| 6282 | |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6283 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6284 | <p>The <tt>llvm.memory.barrier</tt> intrinsic requires five boolean arguments. |
| 6285 | The first four arguments enables a specific barrier as listed below. The |
| 6286 | fith argument specifies that the barrier applies to io or device or uncached |
| 6287 | memory.</p> |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6288 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6289 | <ul> |
| 6290 | <li><tt>ll</tt>: load-load barrier</li> |
| 6291 | <li><tt>ls</tt>: load-store barrier</li> |
| 6292 | <li><tt>sl</tt>: store-load barrier</li> |
| 6293 | <li><tt>ss</tt>: store-store barrier</li> |
| 6294 | <li><tt>device</tt>: barrier applies to device and uncached memory also.</li> |
| 6295 | </ul> |
| 6296 | |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6297 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6298 | <p>This intrinsic causes the system to enforce some ordering constraints upon |
| 6299 | the loads and stores of the program. This barrier does not |
| 6300 | indicate <em>when</em> any events will occur, it only enforces |
| 6301 | an <em>order</em> in which they occur. For any of the specified pairs of load |
| 6302 | and store operations (f.ex. load-load, or store-load), all of the first |
| 6303 | operations preceding the barrier will complete before any of the second |
| 6304 | operations succeeding the barrier begin. Specifically the semantics for each |
| 6305 | pairing is as follows:</p> |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6306 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6307 | <ul> |
| 6308 | <li><tt>ll</tt>: All loads before the barrier must complete before any load |
| 6309 | after the barrier begins.</li> |
| 6310 | <li><tt>ls</tt>: All loads before the barrier must complete before any |
| 6311 | store after the barrier begins.</li> |
| 6312 | <li><tt>ss</tt>: All stores before the barrier must complete before any |
| 6313 | store after the barrier begins.</li> |
| 6314 | <li><tt>sl</tt>: All stores before the barrier must complete before any |
| 6315 | load after the barrier begins.</li> |
| 6316 | </ul> |
| 6317 | |
| 6318 | <p>These semantics are applied with a logical "and" behavior when more than one |
| 6319 | is enabled in a single memory barrier intrinsic.</p> |
| 6320 | |
| 6321 | <p>Backends may implement stronger barriers than those requested when they do |
| 6322 | not support as fine grained a barrier as requested. Some architectures do |
| 6323 | not need all types of barriers and on such architectures, these become |
| 6324 | noops.</p> |
| 6325 | |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6326 | <h5>Example:</h5> |
| 6327 | <pre> |
| 6328 | %ptr = malloc i32 |
| 6329 | store i32 4, %ptr |
| 6330 | |
| 6331 | %result1 = load i32* %ptr <i>; yields {i32}:result1 = 4</i> |
| 6332 | call void @llvm.memory.barrier( i1 false, i1 true, i1 false, i1 false ) |
| 6333 | <i>; guarantee the above finishes</i> |
| 6334 | store i32 8, %ptr <i>; before this begins</i> |
| 6335 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6336 | |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6337 | </div> |
| 6338 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6339 | <!-- _______________________________________________________________________ --> |
| 6340 | <div class="doc_subsubsection"> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6341 | <a name="int_atomic_cmp_swap">'<tt>llvm.atomic.cmp.swap.*</tt>' Intrinsic</a> |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6342 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6343 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6344 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6345 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6346 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6347 | <p>This is an overloaded intrinsic. You can use <tt>llvm.atomic.cmp.swap</tt> on |
| 6348 | any integer bit width and for different address spaces. Not all targets |
| 6349 | support all bit widths however.</p> |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6350 | |
| 6351 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6352 | declare i8 @llvm.atomic.cmp.swap.i8.p0i8( i8* <ptr>, i8 <cmp>, i8 <val> ) |
| 6353 | declare i16 @llvm.atomic.cmp.swap.i16.p0i16( i16* <ptr>, i16 <cmp>, i16 <val> ) |
| 6354 | declare i32 @llvm.atomic.cmp.swap.i32.p0i32( i32* <ptr>, i32 <cmp>, i32 <val> ) |
| 6355 | declare i64 @llvm.atomic.cmp.swap.i64.p0i64( i64* <ptr>, i64 <cmp>, i64 <val> ) |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6356 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6357 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6358 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6359 | <p>This loads a value in memory and compares it to a given value. If they are |
| 6360 | equal, it stores a new value into the memory.</p> |
| 6361 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6362 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6363 | <p>The <tt>llvm.atomic.cmp.swap</tt> intrinsic takes three arguments. The result |
| 6364 | as well as both <tt>cmp</tt> and <tt>val</tt> must be integer values with the |
| 6365 | same bit width. The <tt>ptr</tt> argument must be a pointer to a value of |
| 6366 | this integer type. While any bit width integer may be used, targets may only |
| 6367 | lower representations they support in hardware.</p> |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6368 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6369 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6370 | <p>This entire intrinsic must be executed atomically. It first loads the value |
| 6371 | in memory pointed to by <tt>ptr</tt> and compares it with the |
| 6372 | value <tt>cmp</tt>. If they are equal, <tt>val</tt> is stored into the |
| 6373 | memory. The loaded value is yielded in all cases. This provides the |
| 6374 | equivalent of an atomic compare-and-swap operation within the SSA |
| 6375 | framework.</p> |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6376 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6377 | <h5>Examples:</h5> |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6378 | <pre> |
| 6379 | %ptr = malloc i32 |
| 6380 | store i32 4, %ptr |
| 6381 | |
| 6382 | %val1 = add i32 4, 4 |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6383 | %result1 = call i32 @llvm.atomic.cmp.swap.i32.p0i32( i32* %ptr, i32 4, %val1 ) |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6384 | <i>; yields {i32}:result1 = 4</i> |
| 6385 | %stored1 = icmp eq i32 %result1, 4 <i>; yields {i1}:stored1 = true</i> |
| 6386 | %memval1 = load i32* %ptr <i>; yields {i32}:memval1 = 8</i> |
| 6387 | |
| 6388 | %val2 = add i32 1, 1 |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6389 | %result2 = call i32 @llvm.atomic.cmp.swap.i32.p0i32( i32* %ptr, i32 5, %val2 ) |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6390 | <i>; yields {i32}:result2 = 8</i> |
| 6391 | %stored2 = icmp eq i32 %result2, 5 <i>; yields {i1}:stored2 = false</i> |
| 6392 | |
| 6393 | %memval2 = load i32* %ptr <i>; yields {i32}:memval2 = 8</i> |
| 6394 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6395 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6396 | </div> |
| 6397 | |
| 6398 | <!-- _______________________________________________________________________ --> |
| 6399 | <div class="doc_subsubsection"> |
| 6400 | <a name="int_atomic_swap">'<tt>llvm.atomic.swap.*</tt>' Intrinsic</a> |
| 6401 | </div> |
| 6402 | <div class="doc_text"> |
| 6403 | <h5>Syntax:</h5> |
| 6404 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6405 | <p>This is an overloaded intrinsic. You can use <tt>llvm.atomic.swap</tt> on any |
| 6406 | integer bit width. Not all targets support all bit widths however.</p> |
| 6407 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6408 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6409 | declare i8 @llvm.atomic.swap.i8.p0i8( i8* <ptr>, i8 <val> ) |
| 6410 | declare i16 @llvm.atomic.swap.i16.p0i16( i16* <ptr>, i16 <val> ) |
| 6411 | declare i32 @llvm.atomic.swap.i32.p0i32( i32* <ptr>, i32 <val> ) |
| 6412 | declare i64 @llvm.atomic.swap.i64.p0i64( i64* <ptr>, i64 <val> ) |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6413 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6414 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6415 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6416 | <p>This intrinsic loads the value stored in memory at <tt>ptr</tt> and yields |
| 6417 | the value from memory. It then stores the value in <tt>val</tt> in the memory |
| 6418 | at <tt>ptr</tt>.</p> |
| 6419 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6420 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6421 | <p>The <tt>llvm.atomic.swap</tt> intrinsic takes two arguments. Both |
| 6422 | the <tt>val</tt> argument and the result must be integers of the same bit |
| 6423 | width. The first argument, <tt>ptr</tt>, must be a pointer to a value of this |
| 6424 | integer type. The targets may only lower integer representations they |
| 6425 | support.</p> |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6426 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6427 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6428 | <p>This intrinsic loads the value pointed to by <tt>ptr</tt>, yields it, and |
| 6429 | stores <tt>val</tt> back into <tt>ptr</tt> atomically. This provides the |
| 6430 | equivalent of an atomic swap operation within the SSA framework.</p> |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6431 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6432 | <h5>Examples:</h5> |
| 6433 | <pre> |
| 6434 | %ptr = malloc i32 |
| 6435 | store i32 4, %ptr |
| 6436 | |
| 6437 | %val1 = add i32 4, 4 |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6438 | %result1 = call i32 @llvm.atomic.swap.i32.p0i32( i32* %ptr, i32 %val1 ) |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6439 | <i>; yields {i32}:result1 = 4</i> |
| 6440 | %stored1 = icmp eq i32 %result1, 4 <i>; yields {i1}:stored1 = true</i> |
| 6441 | %memval1 = load i32* %ptr <i>; yields {i32}:memval1 = 8</i> |
| 6442 | |
| 6443 | %val2 = add i32 1, 1 |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6444 | %result2 = call i32 @llvm.atomic.swap.i32.p0i32( i32* %ptr, i32 %val2 ) |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6445 | <i>; yields {i32}:result2 = 8</i> |
| 6446 | |
| 6447 | %stored2 = icmp eq i32 %result2, 8 <i>; yields {i1}:stored2 = true</i> |
| 6448 | %memval2 = load i32* %ptr <i>; yields {i32}:memval2 = 2</i> |
| 6449 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6450 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6451 | </div> |
| 6452 | |
| 6453 | <!-- _______________________________________________________________________ --> |
| 6454 | <div class="doc_subsubsection"> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6455 | <a name="int_atomic_load_add">'<tt>llvm.atomic.load.add.*</tt>' Intrinsic</a> |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6456 | |
| 6457 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6458 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6459 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6460 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6461 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6462 | <p>This is an overloaded intrinsic. You can use <tt>llvm.atomic.load.add</tt> on |
| 6463 | any integer bit width. Not all targets support all bit widths however.</p> |
| 6464 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6465 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6466 | declare i8 @llvm.atomic.load.add.i8..p0i8( i8* <ptr>, i8 <delta> ) |
| 6467 | declare i16 @llvm.atomic.load.add.i16..p0i16( i16* <ptr>, i16 <delta> ) |
| 6468 | declare i32 @llvm.atomic.load.add.i32..p0i32( i32* <ptr>, i32 <delta> ) |
| 6469 | declare i64 @llvm.atomic.load.add.i64..p0i64( i64* <ptr>, i64 <delta> ) |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6470 | </pre> |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6471 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6472 | <h5>Overview:</h5> |
| 6473 | <p>This intrinsic adds <tt>delta</tt> to the value stored in memory |
| 6474 | at <tt>ptr</tt>. It yields the original value at <tt>ptr</tt>.</p> |
| 6475 | |
| 6476 | <h5>Arguments:</h5> |
| 6477 | <p>The intrinsic takes two arguments, the first a pointer to an integer value |
| 6478 | and the second an integer value. The result is also an integer value. These |
| 6479 | integer types can have any bit width, but they must all have the same bit |
| 6480 | width. The targets may only lower integer representations they support.</p> |
| 6481 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6482 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6483 | <p>This intrinsic does a series of operations atomically. It first loads the |
| 6484 | value stored at <tt>ptr</tt>. It then adds <tt>delta</tt>, stores the result |
| 6485 | to <tt>ptr</tt>. It yields the original value stored at <tt>ptr</tt>.</p> |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6486 | |
| 6487 | <h5>Examples:</h5> |
| 6488 | <pre> |
| 6489 | %ptr = malloc i32 |
| 6490 | store i32 4, %ptr |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6491 | %result1 = call i32 @llvm.atomic.load.add.i32.p0i32( i32* %ptr, i32 4 ) |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6492 | <i>; yields {i32}:result1 = 4</i> |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6493 | %result2 = call i32 @llvm.atomic.load.add.i32.p0i32( i32* %ptr, i32 2 ) |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6494 | <i>; yields {i32}:result2 = 8</i> |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6495 | %result3 = call i32 @llvm.atomic.load.add.i32.p0i32( i32* %ptr, i32 5 ) |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6496 | <i>; yields {i32}:result3 = 10</i> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6497 | %memval1 = load i32* %ptr <i>; yields {i32}:memval1 = 15</i> |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6498 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6499 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 6500 | </div> |
| 6501 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6502 | <!-- _______________________________________________________________________ --> |
| 6503 | <div class="doc_subsubsection"> |
| 6504 | <a name="int_atomic_load_sub">'<tt>llvm.atomic.load.sub.*</tt>' Intrinsic</a> |
| 6505 | |
| 6506 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6507 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6508 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6509 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6510 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6511 | <p>This is an overloaded intrinsic. You can use <tt>llvm.atomic.load.sub</tt> on |
| 6512 | any integer bit width and for different address spaces. Not all targets |
| 6513 | support all bit widths however.</p> |
| 6514 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6515 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6516 | declare i8 @llvm.atomic.load.sub.i8.p0i32( i8* <ptr>, i8 <delta> ) |
| 6517 | declare i16 @llvm.atomic.load.sub.i16.p0i32( i16* <ptr>, i16 <delta> ) |
| 6518 | declare i32 @llvm.atomic.load.sub.i32.p0i32( i32* <ptr>, i32 <delta> ) |
| 6519 | declare i64 @llvm.atomic.load.sub.i64.p0i32( i64* <ptr>, i64 <delta> ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6520 | </pre> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6521 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6522 | <h5>Overview:</h5> |
| 6523 | <p>This intrinsic subtracts <tt>delta</tt> to the value stored in memory at |
| 6524 | <tt>ptr</tt>. It yields the original value at <tt>ptr</tt>.</p> |
| 6525 | |
| 6526 | <h5>Arguments:</h5> |
| 6527 | <p>The intrinsic takes two arguments, the first a pointer to an integer value |
| 6528 | and the second an integer value. The result is also an integer value. These |
| 6529 | integer types can have any bit width, but they must all have the same bit |
| 6530 | width. The targets may only lower integer representations they support.</p> |
| 6531 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6532 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6533 | <p>This intrinsic does a series of operations atomically. It first loads the |
| 6534 | value stored at <tt>ptr</tt>. It then subtracts <tt>delta</tt>, stores the |
| 6535 | result to <tt>ptr</tt>. It yields the original value stored |
| 6536 | at <tt>ptr</tt>.</p> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6537 | |
| 6538 | <h5>Examples:</h5> |
| 6539 | <pre> |
| 6540 | %ptr = malloc i32 |
| 6541 | store i32 8, %ptr |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6542 | %result1 = call i32 @llvm.atomic.load.sub.i32.p0i32( i32* %ptr, i32 4 ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6543 | <i>; yields {i32}:result1 = 8</i> |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6544 | %result2 = call i32 @llvm.atomic.load.sub.i32.p0i32( i32* %ptr, i32 2 ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6545 | <i>; yields {i32}:result2 = 4</i> |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6546 | %result3 = call i32 @llvm.atomic.load.sub.i32.p0i32( i32* %ptr, i32 5 ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6547 | <i>; yields {i32}:result3 = 2</i> |
| 6548 | %memval1 = load i32* %ptr <i>; yields {i32}:memval1 = -3</i> |
| 6549 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6550 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6551 | </div> |
| 6552 | |
| 6553 | <!-- _______________________________________________________________________ --> |
| 6554 | <div class="doc_subsubsection"> |
| 6555 | <a name="int_atomic_load_and">'<tt>llvm.atomic.load.and.*</tt>' Intrinsic</a><br> |
| 6556 | <a name="int_atomic_load_nand">'<tt>llvm.atomic.load.nand.*</tt>' Intrinsic</a><br> |
| 6557 | <a name="int_atomic_load_or">'<tt>llvm.atomic.load.or.*</tt>' Intrinsic</a><br> |
| 6558 | <a name="int_atomic_load_xor">'<tt>llvm.atomic.load.xor.*</tt>' Intrinsic</a><br> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6559 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6560 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6561 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6562 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6563 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6564 | <p>These are overloaded intrinsics. You can |
| 6565 | use <tt>llvm.atomic.load_and</tt>, <tt>llvm.atomic.load_nand</tt>, |
| 6566 | <tt>llvm.atomic.load_or</tt>, and <tt>llvm.atomic.load_xor</tt> on any integer |
| 6567 | bit width and for different address spaces. Not all targets support all bit |
| 6568 | widths however.</p> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6569 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6570 | <pre> |
| 6571 | declare i8 @llvm.atomic.load.and.i8.p0i8( i8* <ptr>, i8 <delta> ) |
| 6572 | declare i16 @llvm.atomic.load.and.i16.p0i16( i16* <ptr>, i16 <delta> ) |
| 6573 | declare i32 @llvm.atomic.load.and.i32.p0i32( i32* <ptr>, i32 <delta> ) |
| 6574 | declare i64 @llvm.atomic.load.and.i64.p0i64( i64* <ptr>, i64 <delta> ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6575 | </pre> |
| 6576 | |
| 6577 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6578 | declare i8 @llvm.atomic.load.or.i8.p0i8( i8* <ptr>, i8 <delta> ) |
| 6579 | declare i16 @llvm.atomic.load.or.i16.p0i16( i16* <ptr>, i16 <delta> ) |
| 6580 | declare i32 @llvm.atomic.load.or.i32.p0i32( i32* <ptr>, i32 <delta> ) |
| 6581 | declare i64 @llvm.atomic.load.or.i64.p0i64( i64* <ptr>, i64 <delta> ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6582 | </pre> |
| 6583 | |
| 6584 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6585 | declare i8 @llvm.atomic.load.nand.i8.p0i32( i8* <ptr>, i8 <delta> ) |
| 6586 | declare i16 @llvm.atomic.load.nand.i16.p0i32( i16* <ptr>, i16 <delta> ) |
| 6587 | declare i32 @llvm.atomic.load.nand.i32.p0i32( i32* <ptr>, i32 <delta> ) |
| 6588 | declare i64 @llvm.atomic.load.nand.i64.p0i32( i64* <ptr>, i64 <delta> ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6589 | </pre> |
| 6590 | |
| 6591 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6592 | declare i8 @llvm.atomic.load.xor.i8.p0i32( i8* <ptr>, i8 <delta> ) |
| 6593 | declare i16 @llvm.atomic.load.xor.i16.p0i32( i16* <ptr>, i16 <delta> ) |
| 6594 | declare i32 @llvm.atomic.load.xor.i32.p0i32( i32* <ptr>, i32 <delta> ) |
| 6595 | declare i64 @llvm.atomic.load.xor.i64.p0i32( i64* <ptr>, i64 <delta> ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6596 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6597 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6598 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6599 | <p>These intrinsics bitwise the operation (and, nand, or, xor) <tt>delta</tt> to |
| 6600 | the value stored in memory at <tt>ptr</tt>. It yields the original value |
| 6601 | at <tt>ptr</tt>.</p> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6602 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6603 | <h5>Arguments:</h5> |
| 6604 | <p>These intrinsics take two arguments, the first a pointer to an integer value |
| 6605 | and the second an integer value. The result is also an integer value. These |
| 6606 | integer types can have any bit width, but they must all have the same bit |
| 6607 | width. The targets may only lower integer representations they support.</p> |
| 6608 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6609 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6610 | <p>These intrinsics does a series of operations atomically. They first load the |
| 6611 | value stored at <tt>ptr</tt>. They then do the bitwise |
| 6612 | operation <tt>delta</tt>, store the result to <tt>ptr</tt>. They yield the |
| 6613 | original value stored at <tt>ptr</tt>.</p> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6614 | |
| 6615 | <h5>Examples:</h5> |
| 6616 | <pre> |
| 6617 | %ptr = malloc i32 |
| 6618 | store i32 0x0F0F, %ptr |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6619 | %result0 = call i32 @llvm.atomic.load.nand.i32.p0i32( i32* %ptr, i32 0xFF ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6620 | <i>; yields {i32}:result0 = 0x0F0F</i> |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6621 | %result1 = call i32 @llvm.atomic.load.and.i32.p0i32( i32* %ptr, i32 0xFF ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6622 | <i>; yields {i32}:result1 = 0xFFFFFFF0</i> |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6623 | %result2 = call i32 @llvm.atomic.load.or.i32.p0i32( i32* %ptr, i32 0F ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6624 | <i>; yields {i32}:result2 = 0xF0</i> |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6625 | %result3 = call i32 @llvm.atomic.load.xor.i32.p0i32( i32* %ptr, i32 0F ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6626 | <i>; yields {i32}:result3 = FF</i> |
| 6627 | %memval1 = load i32* %ptr <i>; yields {i32}:memval1 = F0</i> |
| 6628 | </pre> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6629 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6630 | </div> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6631 | |
| 6632 | <!-- _______________________________________________________________________ --> |
| 6633 | <div class="doc_subsubsection"> |
| 6634 | <a name="int_atomic_load_max">'<tt>llvm.atomic.load.max.*</tt>' Intrinsic</a><br> |
| 6635 | <a name="int_atomic_load_min">'<tt>llvm.atomic.load.min.*</tt>' Intrinsic</a><br> |
| 6636 | <a name="int_atomic_load_umax">'<tt>llvm.atomic.load.umax.*</tt>' Intrinsic</a><br> |
| 6637 | <a name="int_atomic_load_umin">'<tt>llvm.atomic.load.umin.*</tt>' Intrinsic</a><br> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6638 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6639 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6640 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6641 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6642 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6643 | <p>These are overloaded intrinsics. You can use <tt>llvm.atomic.load_max</tt>, |
| 6644 | <tt>llvm.atomic.load_min</tt>, <tt>llvm.atomic.load_umax</tt>, and |
| 6645 | <tt>llvm.atomic.load_umin</tt> on any integer bit width and for different |
| 6646 | address spaces. Not all targets support all bit widths however.</p> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6647 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6648 | <pre> |
| 6649 | declare i8 @llvm.atomic.load.max.i8.p0i8( i8* <ptr>, i8 <delta> ) |
| 6650 | declare i16 @llvm.atomic.load.max.i16.p0i16( i16* <ptr>, i16 <delta> ) |
| 6651 | declare i32 @llvm.atomic.load.max.i32.p0i32( i32* <ptr>, i32 <delta> ) |
| 6652 | declare i64 @llvm.atomic.load.max.i64.p0i64( i64* <ptr>, i64 <delta> ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6653 | </pre> |
| 6654 | |
| 6655 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6656 | declare i8 @llvm.atomic.load.min.i8.p0i8( i8* <ptr>, i8 <delta> ) |
| 6657 | declare i16 @llvm.atomic.load.min.i16.p0i16( i16* <ptr>, i16 <delta> ) |
| 6658 | declare i32 @llvm.atomic.load.min.i32..p0i32( i32* <ptr>, i32 <delta> ) |
| 6659 | declare i64 @llvm.atomic.load.min.i64..p0i64( i64* <ptr>, i64 <delta> ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6660 | </pre> |
| 6661 | |
| 6662 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6663 | declare i8 @llvm.atomic.load.umax.i8.p0i8( i8* <ptr>, i8 <delta> ) |
| 6664 | declare i16 @llvm.atomic.load.umax.i16.p0i16( i16* <ptr>, i16 <delta> ) |
| 6665 | declare i32 @llvm.atomic.load.umax.i32.p0i32( i32* <ptr>, i32 <delta> ) |
| 6666 | declare i64 @llvm.atomic.load.umax.i64.p0i64( i64* <ptr>, i64 <delta> ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6667 | </pre> |
| 6668 | |
| 6669 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6670 | declare i8 @llvm.atomic.load.umin.i8..p0i8( i8* <ptr>, i8 <delta> ) |
| 6671 | declare i16 @llvm.atomic.load.umin.i16.p0i16( i16* <ptr>, i16 <delta> ) |
| 6672 | declare i32 @llvm.atomic.load.umin.i32..p0i32( i32* <ptr>, i32 <delta> ) |
| 6673 | declare i64 @llvm.atomic.load.umin.i64..p0i64( i64* <ptr>, i64 <delta> ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6674 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6675 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6676 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6677 | <p>These intrinsics takes the signed or unsigned minimum or maximum of |
| 6678 | <tt>delta</tt> and the value stored in memory at <tt>ptr</tt>. It yields the |
| 6679 | original value at <tt>ptr</tt>.</p> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6680 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6681 | <h5>Arguments:</h5> |
| 6682 | <p>These intrinsics take two arguments, the first a pointer to an integer value |
| 6683 | and the second an integer value. The result is also an integer value. These |
| 6684 | integer types can have any bit width, but they must all have the same bit |
| 6685 | width. The targets may only lower integer representations they support.</p> |
| 6686 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6687 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6688 | <p>These intrinsics does a series of operations atomically. They first load the |
| 6689 | value stored at <tt>ptr</tt>. They then do the signed or unsigned min or |
| 6690 | max <tt>delta</tt> and the value, store the result to <tt>ptr</tt>. They |
| 6691 | yield the original value stored at <tt>ptr</tt>.</p> |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6692 | |
| 6693 | <h5>Examples:</h5> |
| 6694 | <pre> |
| 6695 | %ptr = malloc i32 |
| 6696 | store i32 7, %ptr |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6697 | %result0 = call i32 @llvm.atomic.load.min.i32.p0i32( i32* %ptr, i32 -2 ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6698 | <i>; yields {i32}:result0 = 7</i> |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6699 | %result1 = call i32 @llvm.atomic.load.max.i32.p0i32( i32* %ptr, i32 8 ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6700 | <i>; yields {i32}:result1 = -2</i> |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6701 | %result2 = call i32 @llvm.atomic.load.umin.i32.p0i32( i32* %ptr, i32 10 ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6702 | <i>; yields {i32}:result2 = 8</i> |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 6703 | %result3 = call i32 @llvm.atomic.load.umax.i32.p0i32( i32* %ptr, i32 30 ) |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6704 | <i>; yields {i32}:result3 = 8</i> |
| 6705 | %memval1 = load i32* %ptr <i>; yields {i32}:memval1 = 30</i> |
| 6706 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6707 | |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 6708 | </div> |
Andrew Lenharth | 22c5c1b | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 6709 | |
| 6710 | <!-- ======================================================================= --> |
| 6711 | <div class="doc_subsection"> |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 6712 | <a name="int_general">General Intrinsics</a> |
| 6713 | </div> |
| 6714 | |
| 6715 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6716 | |
| 6717 | <p>This class of intrinsics is designed to be generic and has no specific |
| 6718 | purpose.</p> |
| 6719 | |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 6720 | </div> |
| 6721 | |
| 6722 | <!-- _______________________________________________________________________ --> |
| 6723 | <div class="doc_subsubsection"> |
| 6724 | <a name="int_var_annotation">'<tt>llvm.var.annotation</tt>' Intrinsic</a> |
| 6725 | </div> |
| 6726 | |
| 6727 | <div class="doc_text"> |
| 6728 | |
| 6729 | <h5>Syntax:</h5> |
| 6730 | <pre> |
Tanya Lattner | d2e8442 | 2007-06-18 23:42:37 +0000 | [diff] [blame] | 6731 | declare void @llvm.var.annotation(i8* <val>, i8* <str>, i8* <str>, i32 <int> ) |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 6732 | </pre> |
| 6733 | |
| 6734 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6735 | <p>The '<tt>llvm.var.annotation</tt>' intrinsic.</p> |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 6736 | |
| 6737 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6738 | <p>The first argument is a pointer to a value, the second is a pointer to a |
| 6739 | global string, the third is a pointer to a global string which is the source |
| 6740 | file name, and the last argument is the line number.</p> |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 6741 | |
| 6742 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6743 | <p>This intrinsic allows annotation of local variables with arbitrary strings. |
| 6744 | This can be useful for special purpose optimizations that want to look for |
| 6745 | these annotations. These have no other defined use, they are ignored by code |
| 6746 | generation and optimization.</p> |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 6747 | |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 6748 | </div> |
| 6749 | |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 6750 | <!-- _______________________________________________________________________ --> |
| 6751 | <div class="doc_subsubsection"> |
Tanya Lattner | e1a8da0 | 2007-09-21 23:57:59 +0000 | [diff] [blame] | 6752 | <a name="int_annotation">'<tt>llvm.annotation.*</tt>' Intrinsic</a> |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 6753 | </div> |
| 6754 | |
| 6755 | <div class="doc_text"> |
| 6756 | |
| 6757 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6758 | <p>This is an overloaded intrinsic. You can use '<tt>llvm.annotation</tt>' on |
| 6759 | any integer bit width.</p> |
| 6760 | |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 6761 | <pre> |
Tanya Lattner | d3989a8 | 2007-09-22 00:03:01 +0000 | [diff] [blame] | 6762 | declare i8 @llvm.annotation.i8(i8 <val>, i8* <str>, i8* <str>, i32 <int> ) |
| 6763 | declare i16 @llvm.annotation.i16(i16 <val>, i8* <str>, i8* <str>, i32 <int> ) |
| 6764 | declare i32 @llvm.annotation.i32(i32 <val>, i8* <str>, i8* <str>, i32 <int> ) |
| 6765 | declare i64 @llvm.annotation.i64(i64 <val>, i8* <str>, i8* <str>, i32 <int> ) |
| 6766 | declare i256 @llvm.annotation.i256(i256 <val>, i8* <str>, i8* <str>, i32 <int> ) |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 6767 | </pre> |
| 6768 | |
| 6769 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6770 | <p>The '<tt>llvm.annotation</tt>' intrinsic.</p> |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 6771 | |
| 6772 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6773 | <p>The first argument is an integer value (result of some expression), the |
| 6774 | second is a pointer to a global string, the third is a pointer to a global |
| 6775 | string which is the source file name, and the last argument is the line |
| 6776 | number. It returns the value of the first argument.</p> |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 6777 | |
| 6778 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6779 | <p>This intrinsic allows annotations to be put on arbitrary expressions with |
| 6780 | arbitrary strings. This can be useful for special purpose optimizations that |
| 6781 | want to look for these annotations. These have no other defined use, they |
| 6782 | are ignored by code generation and optimization.</p> |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 6783 | |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 6784 | </div> |
Jim Laskey | dd4ef1b | 2007-03-14 19:31:19 +0000 | [diff] [blame] | 6785 | |
Anton Korobeynikov | 4cb8618 | 2008-01-15 22:31:34 +0000 | [diff] [blame] | 6786 | <!-- _______________________________________________________________________ --> |
| 6787 | <div class="doc_subsubsection"> |
| 6788 | <a name="int_trap">'<tt>llvm.trap</tt>' Intrinsic</a> |
| 6789 | </div> |
| 6790 | |
| 6791 | <div class="doc_text"> |
| 6792 | |
| 6793 | <h5>Syntax:</h5> |
| 6794 | <pre> |
| 6795 | declare void @llvm.trap() |
| 6796 | </pre> |
| 6797 | |
| 6798 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6799 | <p>The '<tt>llvm.trap</tt>' intrinsic.</p> |
Anton Korobeynikov | 4cb8618 | 2008-01-15 22:31:34 +0000 | [diff] [blame] | 6800 | |
| 6801 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6802 | <p>None.</p> |
Anton Korobeynikov | 4cb8618 | 2008-01-15 22:31:34 +0000 | [diff] [blame] | 6803 | |
| 6804 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6805 | <p>This intrinsics is lowered to the target dependent trap instruction. If the |
| 6806 | target does not have a trap instruction, this intrinsic will be lowered to |
| 6807 | the call of the <tt>abort()</tt> function.</p> |
Anton Korobeynikov | 4cb8618 | 2008-01-15 22:31:34 +0000 | [diff] [blame] | 6808 | |
Anton Korobeynikov | 4cb8618 | 2008-01-15 22:31:34 +0000 | [diff] [blame] | 6809 | </div> |
| 6810 | |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 6811 | <!-- _______________________________________________________________________ --> |
| 6812 | <div class="doc_subsubsection"> |
Misha Brukman | dccb025 | 2008-11-22 23:55:29 +0000 | [diff] [blame] | 6813 | <a name="int_stackprotector">'<tt>llvm.stackprotector</tt>' Intrinsic</a> |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 6814 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6815 | |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 6816 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6817 | |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 6818 | <h5>Syntax:</h5> |
| 6819 | <pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6820 | declare void @llvm.stackprotector( i8* <guard>, i8** <slot> ) |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 6821 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6822 | |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 6823 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6824 | <p>The <tt>llvm.stackprotector</tt> intrinsic takes the <tt>guard</tt> and |
| 6825 | stores it onto the stack at <tt>slot</tt>. The stack slot is adjusted to |
| 6826 | ensure that it is placed on the stack before local variables.</p> |
| 6827 | |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 6828 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6829 | <p>The <tt>llvm.stackprotector</tt> intrinsic requires two pointer |
| 6830 | arguments. The first argument is the value loaded from the stack |
| 6831 | guard <tt>@__stack_chk_guard</tt>. The second variable is an <tt>alloca</tt> |
| 6832 | that has enough space to hold the value of the guard.</p> |
| 6833 | |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 6834 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame^] | 6835 | <p>This intrinsic causes the prologue/epilogue inserter to force the position of |
| 6836 | the <tt>AllocaInst</tt> stack slot to be before local variables on the |
| 6837 | stack. This is to ensure that if a local variable on the stack is |
| 6838 | overwritten, it will destroy the value of the guard. When the function exits, |
| 6839 | the guard on the stack is checked against the original guard. If they're |
| 6840 | different, then the program aborts by calling the <tt>__stack_chk_fail()</tt> |
| 6841 | function.</p> |
| 6842 | |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 6843 | </div> |
| 6844 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 6845 | <!-- *********************************************************************** --> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 6846 | <hr> |
Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 6847 | <address> |
| 6848 | <a href="http://jigsaw.w3.org/css-validator/check/referer"><img |
Misha Brukman | 4440870 | 2008-12-11 17:34:48 +0000 | [diff] [blame] | 6849 | src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a> |
Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 6850 | <a href="http://validator.w3.org/check/referer"><img |
Misha Brukman | 4440870 | 2008-12-11 17:34:48 +0000 | [diff] [blame] | 6851 | src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a> |
Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 6852 | |
| 6853 | <a href="mailto:sabre@nondot.org">Chris Lattner</a><br> |
Reid Spencer | 05fe4b0 | 2006-03-14 05:39:39 +0000 | [diff] [blame] | 6854 | <a href="http://llvm.org">The LLVM Compiler Infrastructure</a><br> |
Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 6855 | Last modified: $Date$ |
| 6856 | </address> |
Chris Lattner | c7d3ab3 | 2008-01-04 04:33:49 +0000 | [diff] [blame] | 6857 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 6858 | </body> |
| 6859 | </html> |