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> |
Bill Wendling | 987e7eb | 2009-07-20 02:41:50 +0000 | [diff] [blame] | 25 | <li><a href="#linkage_private">'<tt>private</tt>' Linkage</a></li> |
| 26 | <li><a href="#linkage_linker_private">'<tt>linker_private</tt>' Linkage</a></li> |
| 27 | <li><a href="#linkage_internal">'<tt>internal</tt>' Linkage</a></li> |
| 28 | <li><a href="#linkage_available_externally">'<tt>available_externally</tt>' Linkage</a></li> |
| 29 | <li><a href="#linkage_linkonce">'<tt>linkonce</tt>' Linkage</a></li> |
| 30 | <li><a href="#linkage_common">'<tt>common</tt>' Linkage</a></li> |
| 31 | <li><a href="#linkage_weak">'<tt>weak</tt>' Linkage</a></li> |
| 32 | <li><a href="#linkage_appending">'<tt>appending</tt>' Linkage</a></li> |
| 33 | <li><a href="#linkage_externweak">'<tt>extern_weak</tt>' Linkage</a></li> |
| 34 | <li><a href="#linkage_linkonce">'<tt>linkonce_odr</tt>' Linkage</a></li> |
| 35 | <li><a href="#linkage_weak">'<tt>weak_odr</tt>' Linkage</a></li> |
| 36 | <li><a href="#linkage_external">'<tt>externally visible</tt>' Linkage</a></li> |
| 37 | <li><a href="#linkage_dllimport">'<tt>dllimport</tt>' Linkage</a></li> |
| 38 | <li><a href="#linkage_dllexport">'<tt>dllexport</tt>' Linkage</a></li> |
Bill Wendling | 3d10a5a | 2009-07-20 01:03:30 +0000 | [diff] [blame] | 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 | 857755c | 2009-07-20 05:55:19 +0000 | [diff] [blame] | 94 | <li><a href="#intrinsic_globals">Intrinsic Global Variables</a> |
| 95 | <ol> |
| 96 | <li><a href="#intg_used">The '<tt>llvm.used</tt>' Global Variable</a></li> |
| 97 | <li><a href="#intg_global_ctors">The '<tt>llvm.global_ctors</tt>' |
| 98 | Global Variable</a></li> |
| 99 | <li><a href="#intg_global_dtors">The '<tt>llvm.global_dtors</tt>' |
| 100 | Global Variable</a></li> |
| 101 | </ol> |
| 102 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 103 | <li><a href="#instref">Instruction Reference</a> |
| 104 | <ol> |
| 105 | <li><a href="#terminators">Terminator Instructions</a> |
| 106 | <ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 107 | <li><a href="#i_ret">'<tt>ret</tt>' Instruction</a></li> |
| 108 | <li><a href="#i_br">'<tt>br</tt>' Instruction</a></li> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 109 | <li><a href="#i_switch">'<tt>switch</tt>' Instruction</a></li> |
| 110 | <li><a href="#i_invoke">'<tt>invoke</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 111 | <li><a href="#i_unwind">'<tt>unwind</tt>' Instruction</a></li> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 112 | <li><a href="#i_unreachable">'<tt>unreachable</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 113 | </ol> |
| 114 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 115 | <li><a href="#binaryops">Binary Operations</a> |
| 116 | <ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 117 | <li><a href="#i_add">'<tt>add</tt>' Instruction</a></li> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 118 | <li><a href="#i_fadd">'<tt>fadd</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 119 | <li><a href="#i_sub">'<tt>sub</tt>' Instruction</a></li> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 120 | <li><a href="#i_fsub">'<tt>fsub</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 121 | <li><a href="#i_mul">'<tt>mul</tt>' Instruction</a></li> |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 122 | <li><a href="#i_fmul">'<tt>fmul</tt>' Instruction</a></li> |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 123 | <li><a href="#i_udiv">'<tt>udiv</tt>' Instruction</a></li> |
| 124 | <li><a href="#i_sdiv">'<tt>sdiv</tt>' Instruction</a></li> |
| 125 | <li><a href="#i_fdiv">'<tt>fdiv</tt>' Instruction</a></li> |
Reid Spencer | 0a783f7 | 2006-11-02 01:53:59 +0000 | [diff] [blame] | 126 | <li><a href="#i_urem">'<tt>urem</tt>' Instruction</a></li> |
| 127 | <li><a href="#i_srem">'<tt>srem</tt>' Instruction</a></li> |
| 128 | <li><a href="#i_frem">'<tt>frem</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 129 | </ol> |
| 130 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 131 | <li><a href="#bitwiseops">Bitwise Binary Operations</a> |
| 132 | <ol> |
Reid Spencer | 8e11bf8 | 2007-02-02 13:57:07 +0000 | [diff] [blame] | 133 | <li><a href="#i_shl">'<tt>shl</tt>' Instruction</a></li> |
| 134 | <li><a href="#i_lshr">'<tt>lshr</tt>' Instruction</a></li> |
| 135 | <li><a href="#i_ashr">'<tt>ashr</tt>' Instruction</a></li> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 136 | <li><a href="#i_and">'<tt>and</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 137 | <li><a href="#i_or">'<tt>or</tt>' Instruction</a></li> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 138 | <li><a href="#i_xor">'<tt>xor</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 139 | </ol> |
| 140 | </li> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 141 | <li><a href="#vectorops">Vector Operations</a> |
| 142 | <ol> |
| 143 | <li><a href="#i_extractelement">'<tt>extractelement</tt>' Instruction</a></li> |
| 144 | <li><a href="#i_insertelement">'<tt>insertelement</tt>' Instruction</a></li> |
| 145 | <li><a href="#i_shufflevector">'<tt>shufflevector</tt>' Instruction</a></li> |
Chris Lattner | 3df241e | 2006-04-08 23:07:04 +0000 | [diff] [blame] | 146 | </ol> |
| 147 | </li> |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 148 | <li><a href="#aggregateops">Aggregate Operations</a> |
| 149 | <ol> |
| 150 | <li><a href="#i_extractvalue">'<tt>extractvalue</tt>' Instruction</a></li> |
| 151 | <li><a href="#i_insertvalue">'<tt>insertvalue</tt>' Instruction</a></li> |
| 152 | </ol> |
| 153 | </li> |
Chris Lattner | 884a970 | 2006-08-15 00:45:58 +0000 | [diff] [blame] | 154 | <li><a href="#memoryops">Memory Access and Addressing Operations</a> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 155 | <ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 156 | <li><a href="#i_malloc">'<tt>malloc</tt>' Instruction</a></li> |
| 157 | <li><a href="#i_free">'<tt>free</tt>' Instruction</a></li> |
| 158 | <li><a href="#i_alloca">'<tt>alloca</tt>' Instruction</a></li> |
Robert Bocchino | 7b81c75 | 2006-02-17 21:18:08 +0000 | [diff] [blame] | 159 | <li><a href="#i_load">'<tt>load</tt>' Instruction</a></li> |
| 160 | <li><a href="#i_store">'<tt>store</tt>' Instruction</a></li> |
| 161 | <li><a href="#i_getelementptr">'<tt>getelementptr</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 162 | </ol> |
| 163 | </li> |
Reid Spencer | 2fd21e6 | 2006-11-08 01:18:52 +0000 | [diff] [blame] | 164 | <li><a href="#convertops">Conversion Operations</a> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 165 | <ol> |
| 166 | <li><a href="#i_trunc">'<tt>trunc .. to</tt>' Instruction</a></li> |
| 167 | <li><a href="#i_zext">'<tt>zext .. to</tt>' Instruction</a></li> |
| 168 | <li><a href="#i_sext">'<tt>sext .. to</tt>' Instruction</a></li> |
| 169 | <li><a href="#i_fptrunc">'<tt>fptrunc .. to</tt>' Instruction</a></li> |
| 170 | <li><a href="#i_fpext">'<tt>fpext .. to</tt>' Instruction</a></li> |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 171 | <li><a href="#i_fptoui">'<tt>fptoui .. to</tt>' Instruction</a></li> |
| 172 | <li><a href="#i_fptosi">'<tt>fptosi .. to</tt>' Instruction</a></li> |
| 173 | <li><a href="#i_uitofp">'<tt>uitofp .. to</tt>' Instruction</a></li> |
| 174 | <li><a href="#i_sitofp">'<tt>sitofp .. to</tt>' Instruction</a></li> |
Reid Spencer | 7267925 | 2006-11-11 21:00:47 +0000 | [diff] [blame] | 175 | <li><a href="#i_ptrtoint">'<tt>ptrtoint .. to</tt>' Instruction</a></li> |
| 176 | <li><a href="#i_inttoptr">'<tt>inttoptr .. to</tt>' Instruction</a></li> |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 177 | <li><a href="#i_bitcast">'<tt>bitcast .. to</tt>' Instruction</a></li> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 178 | </ol> |
Dan Gohman | 0e451ce | 2008-10-14 16:51:45 +0000 | [diff] [blame] | 179 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 180 | <li><a href="#otherops">Other Operations</a> |
| 181 | <ol> |
Reid Spencer | f3a70a6 | 2006-11-18 21:50:54 +0000 | [diff] [blame] | 182 | <li><a href="#i_icmp">'<tt>icmp</tt>' Instruction</a></li> |
| 183 | <li><a href="#i_fcmp">'<tt>fcmp</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 184 | <li><a href="#i_phi">'<tt>phi</tt>' Instruction</a></li> |
Chris Lattner | cc37aae | 2004-03-12 05:50:16 +0000 | [diff] [blame] | 185 | <li><a href="#i_select">'<tt>select</tt>' Instruction</a></li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 186 | <li><a href="#i_call">'<tt>call</tt>' Instruction</a></li> |
Chris Lattner | fb6977d | 2006-01-13 23:26:01 +0000 | [diff] [blame] | 187 | <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] | 188 | </ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 189 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 190 | </ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 191 | </li> |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 192 | <li><a href="#intrinsics">Intrinsic Functions</a> |
Chris Lattner | d9ad5b3 | 2003-05-08 04:57:36 +0000 | [diff] [blame] | 193 | <ol> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 194 | <li><a href="#int_varargs">Variable Argument Handling Intrinsics</a> |
| 195 | <ol> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 196 | <li><a href="#int_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a></li> |
| 197 | <li><a href="#int_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a></li> |
| 198 | <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] | 199 | </ol> |
| 200 | </li> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 201 | <li><a href="#int_gc">Accurate Garbage Collection Intrinsics</a> |
| 202 | <ol> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 203 | <li><a href="#int_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a></li> |
| 204 | <li><a href="#int_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a></li> |
| 205 | <li><a href="#int_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a></li> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 206 | </ol> |
| 207 | </li> |
Chris Lattner | 1061064 | 2004-02-14 04:08:35 +0000 | [diff] [blame] | 208 | <li><a href="#int_codegen">Code Generator Intrinsics</a> |
| 209 | <ol> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 210 | <li><a href="#int_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a></li> |
| 211 | <li><a href="#int_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a></li> |
| 212 | <li><a href="#int_stacksave">'<tt>llvm.stacksave</tt>' Intrinsic</a></li> |
| 213 | <li><a href="#int_stackrestore">'<tt>llvm.stackrestore</tt>' Intrinsic</a></li> |
| 214 | <li><a href="#int_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a></li> |
| 215 | <li><a href="#int_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a></li> |
| 216 | <li><a href="#int_readcyclecounter"><tt>llvm.readcyclecounter</tt>' Intrinsic</a></li> |
John Criswell | 7123e27 | 2004-04-09 16:43:20 +0000 | [diff] [blame] | 217 | </ol> |
| 218 | </li> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 219 | <li><a href="#int_libc">Standard C Library Intrinsics</a> |
| 220 | <ol> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 221 | <li><a href="#int_memcpy">'<tt>llvm.memcpy.*</tt>' Intrinsic</a></li> |
| 222 | <li><a href="#int_memmove">'<tt>llvm.memmove.*</tt>' Intrinsic</a></li> |
| 223 | <li><a href="#int_memset">'<tt>llvm.memset.*</tt>' Intrinsic</a></li> |
| 224 | <li><a href="#int_sqrt">'<tt>llvm.sqrt.*</tt>' Intrinsic</a></li> |
| 225 | <li><a href="#int_powi">'<tt>llvm.powi.*</tt>' Intrinsic</a></li> |
Dan Gohman | 91c284c | 2007-10-15 20:30:11 +0000 | [diff] [blame] | 226 | <li><a href="#int_sin">'<tt>llvm.sin.*</tt>' Intrinsic</a></li> |
| 227 | <li><a href="#int_cos">'<tt>llvm.cos.*</tt>' Intrinsic</a></li> |
| 228 | <li><a href="#int_pow">'<tt>llvm.pow.*</tt>' Intrinsic</a></li> |
Chris Lattner | 33aec9e | 2004-02-12 17:01:32 +0000 | [diff] [blame] | 229 | </ol> |
| 230 | </li> |
Nate Begeman | 7e36c47 | 2006-01-13 23:26:38 +0000 | [diff] [blame] | 231 | <li><a href="#int_manip">Bit Manipulation Intrinsics</a> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 232 | <ol> |
Reid Spencer | a3e435f | 2007-04-04 02:42:35 +0000 | [diff] [blame] | 233 | <li><a href="#int_bswap">'<tt>llvm.bswap.*</tt>' Intrinsics</a></li> |
Chris Lattner | 8a886be | 2006-01-16 22:34:14 +0000 | [diff] [blame] | 234 | <li><a href="#int_ctpop">'<tt>llvm.ctpop.*</tt>' Intrinsic </a></li> |
| 235 | <li><a href="#int_ctlz">'<tt>llvm.ctlz.*</tt>' Intrinsic </a></li> |
| 236 | <li><a href="#int_cttz">'<tt>llvm.cttz.*</tt>' Intrinsic </a></li> |
Andrew Lenharth | ec370fd | 2005-05-03 18:01:48 +0000 | [diff] [blame] | 237 | </ol> |
| 238 | </li> |
Bill Wendling | ac1df8e | 2009-02-08 01:40:31 +0000 | [diff] [blame] | 239 | <li><a href="#int_overflow">Arithmetic with Overflow Intrinsics</a> |
| 240 | <ol> |
Bill Wendling | da01af7 | 2009-02-08 04:04:40 +0000 | [diff] [blame] | 241 | <li><a href="#int_sadd_overflow">'<tt>llvm.sadd.with.overflow.*</tt> Intrinsics</a></li> |
| 242 | <li><a href="#int_uadd_overflow">'<tt>llvm.uadd.with.overflow.*</tt> Intrinsics</a></li> |
| 243 | <li><a href="#int_ssub_overflow">'<tt>llvm.ssub.with.overflow.*</tt> Intrinsics</a></li> |
| 244 | <li><a href="#int_usub_overflow">'<tt>llvm.usub.with.overflow.*</tt> Intrinsics</a></li> |
| 245 | <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] | 246 | <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] | 247 | </ol> |
| 248 | </li> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 249 | <li><a href="#int_debugger">Debugger intrinsics</a></li> |
Jim Laskey | dd4ef1b | 2007-03-14 19:31:19 +0000 | [diff] [blame] | 250 | <li><a href="#int_eh">Exception Handling intrinsics</a></li> |
Duncan Sands | f7331b3 | 2007-09-11 14:10:23 +0000 | [diff] [blame] | 251 | <li><a href="#int_trampoline">Trampoline Intrinsic</a> |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 252 | <ol> |
| 253 | <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] | 254 | </ol> |
| 255 | </li> |
Bill Wendling | 3c44f5b | 2008-11-18 22:10:53 +0000 | [diff] [blame] | 256 | <li><a href="#int_atomics">Atomic intrinsics</a> |
| 257 | <ol> |
| 258 | <li><a href="#int_memory_barrier"><tt>llvm.memory_barrier</tt></a></li> |
| 259 | <li><a href="#int_atomic_cmp_swap"><tt>llvm.atomic.cmp.swap</tt></a></li> |
| 260 | <li><a href="#int_atomic_swap"><tt>llvm.atomic.swap</tt></a></li> |
| 261 | <li><a href="#int_atomic_load_add"><tt>llvm.atomic.load.add</tt></a></li> |
| 262 | <li><a href="#int_atomic_load_sub"><tt>llvm.atomic.load.sub</tt></a></li> |
| 263 | <li><a href="#int_atomic_load_and"><tt>llvm.atomic.load.and</tt></a></li> |
| 264 | <li><a href="#int_atomic_load_nand"><tt>llvm.atomic.load.nand</tt></a></li> |
| 265 | <li><a href="#int_atomic_load_or"><tt>llvm.atomic.load.or</tt></a></li> |
| 266 | <li><a href="#int_atomic_load_xor"><tt>llvm.atomic.load.xor</tt></a></li> |
| 267 | <li><a href="#int_atomic_load_max"><tt>llvm.atomic.load.max</tt></a></li> |
| 268 | <li><a href="#int_atomic_load_min"><tt>llvm.atomic.load.min</tt></a></li> |
| 269 | <li><a href="#int_atomic_load_umax"><tt>llvm.atomic.load.umax</tt></a></li> |
| 270 | <li><a href="#int_atomic_load_umin"><tt>llvm.atomic.load.umin</tt></a></li> |
| 271 | </ol> |
| 272 | </li> |
Reid Spencer | 2067764 | 2007-07-20 19:59:11 +0000 | [diff] [blame] | 273 | <li><a href="#int_general">General intrinsics</a> |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 274 | <ol> |
Reid Spencer | 2067764 | 2007-07-20 19:59:11 +0000 | [diff] [blame] | 275 | <li><a href="#int_var_annotation"> |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 276 | '<tt>llvm.var.annotation</tt>' Intrinsic</a></li> |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 277 | <li><a href="#int_annotation"> |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 278 | '<tt>llvm.annotation.*</tt>' Intrinsic</a></li> |
Anton Korobeynikov | 4cb8618 | 2008-01-15 22:31:34 +0000 | [diff] [blame] | 279 | <li><a href="#int_trap"> |
Bill Wendling | 69e4adb | 2008-11-19 05:56:17 +0000 | [diff] [blame] | 280 | '<tt>llvm.trap</tt>' Intrinsic</a></li> |
| 281 | <li><a href="#int_stackprotector"> |
| 282 | '<tt>llvm.stackprotector</tt>' Intrinsic</a></li> |
Tanya Lattner | b636788 | 2007-09-21 22:59:12 +0000 | [diff] [blame] | 283 | </ol> |
Tanya Lattner | 6d806e9 | 2007-06-15 20:50:54 +0000 | [diff] [blame] | 284 | </li> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 285 | </ol> |
| 286 | </li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 287 | </ol> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 288 | |
| 289 | <div class="doc_author"> |
| 290 | <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a> |
| 291 | and <a href="mailto:vadve@cs.uiuc.edu">Vikram Adve</a></p> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 292 | </div> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 293 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 294 | <!-- *********************************************************************** --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 295 | <div class="doc_section"> <a name="abstract">Abstract </a></div> |
| 296 | <!-- *********************************************************************** --> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 297 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 298 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 299 | |
| 300 | <p>This document is a reference manual for the LLVM assembly language. LLVM is |
| 301 | a Static Single Assignment (SSA) based representation that provides type |
| 302 | safety, low-level operations, flexibility, and the capability of representing |
| 303 | 'all' high-level languages cleanly. It is the common code representation |
| 304 | used throughout all phases of the LLVM compilation strategy.</p> |
| 305 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 306 | </div> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 307 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 308 | <!-- *********************************************************************** --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 309 | <div class="doc_section"> <a name="introduction">Introduction</a> </div> |
| 310 | <!-- *********************************************************************** --> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 311 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 312 | <div class="doc_text"> |
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 code representation is designed to be used in three different forms: |
| 315 | as an in-memory compiler IR, as an on-disk bitcode representation (suitable |
| 316 | for fast loading by a Just-In-Time compiler), and as a human readable |
| 317 | assembly language representation. This allows LLVM to provide a powerful |
| 318 | intermediate representation for efficient compiler transformations and |
| 319 | analysis, while providing a natural means to debug and visualize the |
| 320 | transformations. The three different forms of LLVM are all equivalent. This |
| 321 | document describes the human readable representation and notation.</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 322 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 323 | <p>The LLVM representation aims to be light-weight and low-level while being |
| 324 | expressive, typed, and extensible at the same time. It aims to be a |
| 325 | "universal IR" of sorts, by being at a low enough level that high-level ideas |
| 326 | may be cleanly mapped to it (similar to how microprocessors are "universal |
| 327 | IR's", allowing many source languages to be mapped to them). By providing |
| 328 | type information, LLVM can be used as the target of optimizations: for |
| 329 | example, through pointer analysis, it can be proven that a C automatic |
| 330 | variable is never accessed outside of the current function... allowing it to |
| 331 | 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] | 332 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 333 | </div> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 334 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 335 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 336 | <div class="doc_subsubsection"> <a name="wellformed">Well-Formedness</a> </div> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 337 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 338 | <div class="doc_text"> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 339 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 340 | <p>It is important to note that this document describes 'well formed' LLVM |
| 341 | assembly language. There is a difference between what the parser accepts and |
| 342 | what is considered 'well formed'. For example, the following instruction is |
| 343 | syntactically okay, but not well formed:</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 344 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 345 | <div class="doc_code"> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 346 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 347 | %x = <a href="#i_add">add</a> i32 1, %x |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 348 | </pre> |
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 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 351 | <p>...because the definition of <tt>%x</tt> does not dominate all of its |
| 352 | uses. The LLVM infrastructure provides a verification pass that may be used |
| 353 | to verify that an LLVM module is well formed. This pass is automatically run |
| 354 | by the parser after parsing input assembly and by the optimizer before it |
| 355 | outputs bitcode. The violations pointed out by the verifier pass indicate |
| 356 | bugs in transformation passes or input to the parser.</p> |
| 357 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 358 | </div> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 359 | |
Chris Lattner | cc68939 | 2007-10-03 17:34:29 +0000 | [diff] [blame] | 360 | <!-- Describe the typesetting conventions here. --> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 361 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 362 | <!-- *********************************************************************** --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 363 | <div class="doc_section"> <a name="identifiers">Identifiers</a> </div> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 364 | <!-- *********************************************************************** --> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 365 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 366 | <div class="doc_text"> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 367 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 368 | <p>LLVM identifiers come in two basic types: global and local. Global |
| 369 | identifiers (functions, global variables) begin with the <tt>'@'</tt> |
| 370 | character. Local identifiers (register names, types) begin with |
| 371 | the <tt>'%'</tt> character. Additionally, there are three different formats |
| 372 | for identifiers, for different purposes:</p> |
Chris Lattner | d792391 | 2004-05-23 21:06:01 +0000 | [diff] [blame] | 373 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 374 | <ol> |
Reid Spencer | 2c45228 | 2007-08-07 14:34:28 +0000 | [diff] [blame] | 375 | <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] | 376 | For example, <tt>%foo</tt>, <tt>@DivisionByZero</tt>, |
| 377 | <tt>%a.really.long.identifier</tt>. The actual regular expression used is |
| 378 | '<tt>[%@][a-zA-Z$._][a-zA-Z$._0-9]*</tt>'. Identifiers which require |
| 379 | other characters in their names can be surrounded with quotes. Special |
| 380 | characters may be escaped using <tt>"\xx"</tt> where <tt>xx</tt> is the |
| 381 | ASCII code for the character in hexadecimal. In this way, any character |
| 382 | can be used in a name value, even quotes themselves.</li> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 383 | |
Reid Spencer | 2c45228 | 2007-08-07 14:34:28 +0000 | [diff] [blame] | 384 | <li>Unnamed values are represented as an unsigned numeric value with their |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 385 | 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] | 386 | |
Reid Spencer | cc16dc3 | 2004-12-09 18:02:53 +0000 | [diff] [blame] | 387 | <li>Constants, which are described in a <a href="#constants">section about |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 388 | constants</a>, below.</li> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 389 | </ol> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 390 | |
Reid Spencer | 2c45228 | 2007-08-07 14:34:28 +0000 | [diff] [blame] | 391 | <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] | 392 | don't need to worry about name clashes with reserved words, and the set of |
| 393 | reserved words may be expanded in the future without penalty. Additionally, |
| 394 | unnamed identifiers allow a compiler to quickly come up with a temporary |
| 395 | variable without having to avoid symbol table conflicts.</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 396 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 397 | <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] | 398 | languages. There are keywords for different opcodes |
| 399 | ('<tt><a href="#i_add">add</a></tt>', |
| 400 | '<tt><a href="#i_bitcast">bitcast</a></tt>', |
| 401 | '<tt><a href="#i_ret">ret</a></tt>', etc...), for primitive type names |
| 402 | ('<tt><a href="#t_void">void</a></tt>', |
| 403 | '<tt><a href="#t_primitive">i32</a></tt>', etc...), and others. These |
| 404 | reserved words cannot conflict with variable names, because none of them |
| 405 | start with a prefix character (<tt>'%'</tt> or <tt>'@'</tt>).</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 406 | |
| 407 | <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] | 408 | '<tt>%X</tt>' by 8:</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 409 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 410 | <p>The easy way:</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 411 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 412 | <div class="doc_code"> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 413 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 414 | %result = <a href="#i_mul">mul</a> i32 %X, 8 |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 415 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 416 | </div> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 417 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 418 | <p>After strength reduction:</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 419 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 420 | <div class="doc_code"> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 421 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 422 | %result = <a href="#i_shl">shl</a> i32 %X, i8 3 |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 423 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 424 | </div> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 425 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 426 | <p>And the hard way:</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 427 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 428 | <div class="doc_code"> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 429 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 430 | <a href="#i_add">add</a> i32 %X, %X <i>; yields {i32}:%0</i> |
| 431 | <a href="#i_add">add</a> i32 %0, %0 <i>; yields {i32}:%1</i> |
| 432 | %result = <a href="#i_add">add</a> i32 %1, %1 |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 433 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 434 | </div> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 435 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 436 | <p>This last way of multiplying <tt>%X</tt> by 8 illustrates several important |
| 437 | lexical features of LLVM:</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 438 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 439 | <ol> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 440 | <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] | 441 | line.</li> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 442 | |
| 443 | <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] | 444 | assigned to a named value.</li> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 445 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 446 | <li>Unnamed temporaries are numbered sequentially</li> |
| 447 | </ol> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 448 | |
John Criswell | e4c57cc | 2005-05-12 16:52:32 +0000 | [diff] [blame] | 449 | <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] | 450 | demonstrating instructions, we will follow an instruction with a comment that |
| 451 | defines the type and name of value produced. Comments are shown in italic |
| 452 | text.</p> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 453 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 454 | </div> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 455 | |
| 456 | <!-- *********************************************************************** --> |
| 457 | <div class="doc_section"> <a name="highlevel">High Level Structure</a> </div> |
| 458 | <!-- *********************************************************************** --> |
| 459 | |
| 460 | <!-- ======================================================================= --> |
| 461 | <div class="doc_subsection"> <a name="modulestructure">Module Structure</a> |
| 462 | </div> |
| 463 | |
| 464 | <div class="doc_text"> |
| 465 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 466 | <p>LLVM programs are composed of "Module"s, each of which is a translation unit |
| 467 | of the input programs. Each module consists of functions, global variables, |
| 468 | and symbol table entries. Modules may be combined together with the LLVM |
| 469 | linker, which merges function (and global variable) definitions, resolves |
| 470 | forward declarations, and merges symbol table entries. Here is an example of |
| 471 | the "hello world" module:</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 472 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 473 | <div class="doc_code"> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 474 | <pre><i>; Declare the string constant as a global constant...</i> |
Chris Lattner | a89e5f1 | 2007-06-12 17:00:26 +0000 | [diff] [blame] | 475 | <a href="#identifiers">@.LC0</a> = <a href="#linkage_internal">internal</a> <a |
| 476 | 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] | 477 | |
| 478 | <i>; External declaration of the puts function</i> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 479 | <a href="#functionstructure">declare</a> i32 @puts(i8 *) <i>; i32(i8 *)* </i> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 480 | |
| 481 | <i>; Definition of main function</i> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 482 | define i32 @main() { <i>; i32()* </i> |
Dan Gohman | 2a08c53 | 2009-01-04 23:44:43 +0000 | [diff] [blame] | 483 | <i>; Convert [13 x i8]* to i8 *...</i> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 484 | %cast210 = <a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 485 | 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] | 486 | |
| 487 | <i>; Call puts function to write out the string to stdout...</i> |
| 488 | <a |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 489 | href="#i_call">call</a> i32 @puts(i8 * %cast210) <i>; i32</i> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 490 | <a |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 491 | href="#i_ret">ret</a> i32 0<br>}<br> |
| 492 | </pre> |
| 493 | </div> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 494 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 495 | <p>This example is made up of a <a href="#globalvars">global variable</a> named |
| 496 | "<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>" function, and |
| 497 | a <a href="#functionstructure">function definition</a> for |
| 498 | "<tt>main</tt>".</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 499 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 500 | <p>In general, a module is made up of a list of global values, where both |
| 501 | functions and global variables are global values. Global values are |
| 502 | represented by a pointer to a memory location (in this case, a pointer to an |
| 503 | array of char, and a pointer to a function), and have one of the |
| 504 | following <a href="#linkage">linkage types</a>.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 505 | |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 506 | </div> |
| 507 | |
| 508 | <!-- ======================================================================= --> |
| 509 | <div class="doc_subsection"> |
| 510 | <a name="linkage">Linkage Types</a> |
| 511 | </div> |
| 512 | |
| 513 | <div class="doc_text"> |
| 514 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 515 | <p>All Global Variables and Functions have one of the following types of |
| 516 | linkage:</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 517 | |
| 518 | <dl> |
Rafael Espindola | bb46f52 | 2009-01-15 20:18:42 +0000 | [diff] [blame] | 519 | <dt><tt><b><a name="linkage_private">private</a></b></tt>: </dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 520 | <dd>Global values with private linkage are only directly accessible by objects |
| 521 | in the current module. In particular, linking code into a module with an |
| 522 | private global value may cause the private to be renamed as necessary to |
| 523 | avoid collisions. Because the symbol is private to the module, all |
| 524 | references can be updated. This doesn't show up in any symbol table in the |
| 525 | object file.</dd> |
Rafael Espindola | bb46f52 | 2009-01-15 20:18:42 +0000 | [diff] [blame] | 526 | |
Bill Wendling | 3d10a5a | 2009-07-20 01:03:30 +0000 | [diff] [blame] | 527 | <dt><tt><b><a name="linkage_linker_private">linker_private</a></b></tt>: </dt> |
Bill Wendling | 3d10a5a | 2009-07-20 01:03:30 +0000 | [diff] [blame] | 528 | <dd>Similar to private, but the symbol is passed through the assembler and |
| 529 | removed by the linker after evaluation.</dd> |
| 530 | |
Dale Johannesen | 2307a7f | 2008-05-23 23:13:41 +0000 | [diff] [blame] | 531 | <dt><tt><b><a name="linkage_internal">internal</a></b></tt>: </dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 532 | <dd>Similar to private, but the value shows as a local symbol |
| 533 | (<tt>STB_LOCAL</tt> in the case of ELF) in the object file. This |
| 534 | 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] | 535 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 536 | <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] | 537 | <dd>Globals with "<tt>available_externally</tt>" linkage are never emitted |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 538 | into the object file corresponding to the LLVM module. They exist to |
| 539 | allow inlining and other optimizations to take place given knowledge of |
| 540 | the definition of the global, which is known to be somewhere outside the |
| 541 | module. Globals with <tt>available_externally</tt> linkage are allowed to |
| 542 | be discarded at will, and are otherwise the same as <tt>linkonce_odr</tt>. |
| 543 | This linkage type is only allowed on definitions, not declarations.</dd> |
Chris Lattner | 266c7bb | 2009-04-13 05:44:34 +0000 | [diff] [blame] | 544 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 545 | <dt><tt><b><a name="linkage_linkonce">linkonce</a></b></tt>: </dt> |
Chris Lattner | 4887bd8 | 2007-01-14 06:51:48 +0000 | [diff] [blame] | 546 | <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] | 547 | the same name when linkage occurs. This is typically used to implement |
| 548 | inline functions, templates, or other code which must be generated in each |
| 549 | translation unit that uses it. Unreferenced <tt>linkonce</tt> globals are |
| 550 | allowed to be discarded.</dd> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 551 | |
Dale Johannesen | 2307a7f | 2008-05-23 23:13:41 +0000 | [diff] [blame] | 552 | <dt><tt><b><a name="linkage_common">common</a></b></tt>: </dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 553 | <dd>"<tt>common</tt>" linkage is exactly the same as <tt>linkonce</tt> |
| 554 | linkage, except that unreferenced <tt>common</tt> globals may not be |
| 555 | discarded. This is used for globals that may be emitted in multiple |
| 556 | translation units, but that are not guaranteed to be emitted into every |
| 557 | translation unit that uses them. One example of this is tentative |
| 558 | 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] | 559 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 560 | <dt><tt><b><a name="linkage_weak">weak</a></b></tt>: </dt> |
Dale Johannesen | 2307a7f | 2008-05-23 23:13:41 +0000 | [diff] [blame] | 561 | <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] | 562 | that some targets may choose to emit different assembly sequences for them |
| 563 | for target-dependent reasons. This is used for globals that are declared |
| 564 | "weak" in C source code.</dd> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 565 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 566 | <dt><tt><b><a name="linkage_appending">appending</a></b></tt>: </dt> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 567 | <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] | 568 | pointer to array type. When two global variables with appending linkage |
| 569 | are linked together, the two global arrays are appended together. This is |
| 570 | the LLVM, typesafe, equivalent of having the system linker append together |
| 571 | "sections" with identical names when .o files are linked.</dd> |
Chris Lattner | e5d947b | 2004-12-09 16:36:40 +0000 | [diff] [blame] | 572 | |
Anton Korobeynikov | 7f70559 | 2007-01-12 19:20:47 +0000 | [diff] [blame] | 573 | <dt><tt><b><a name="linkage_externweak">extern_weak</a></b></tt>: </dt> |
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 | <dd>Some languages allow differing globals to be merged, such as two functions |
| 581 | with different semantics. Other languages, such as <tt>C++</tt>, ensure |
| 582 | that only equivalent globals are ever merged (the "one definition rule" - |
| 583 | "ODR"). Such languages can use the <tt>linkonce_odr</tt> |
| 584 | and <tt>weak_odr</tt> linkage types to indicate that the global will only |
| 585 | be merged with equivalent globals. These linkage types are otherwise the |
| 586 | same as their non-<tt>odr</tt> versions.</dd> |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 587 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 588 | <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] | 589 | <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] | 590 | visible, meaning that it participates in linkage and can be used to |
| 591 | resolve external symbol references.</dd> |
Reid Spencer | c891084 | 2007-04-11 23:49:50 +0000 | [diff] [blame] | 592 | </dl> |
Anton Korobeynikov | b74ed07 | 2006-09-14 18:23:27 +0000 | [diff] [blame] | 593 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 594 | <p>The next two types of linkage are targeted for Microsoft Windows platform |
| 595 | only. They are designed to support importing (exporting) symbols from (to) |
| 596 | DLLs (Dynamic Link Libraries).</p> |
Anton Korobeynikov | b74ed07 | 2006-09-14 18:23:27 +0000 | [diff] [blame] | 597 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 598 | <dl> |
Anton Korobeynikov | b74ed07 | 2006-09-14 18:23:27 +0000 | [diff] [blame] | 599 | <dt><tt><b><a name="linkage_dllimport">dllimport</a></b></tt>: </dt> |
Anton Korobeynikov | b74ed07 | 2006-09-14 18:23:27 +0000 | [diff] [blame] | 600 | <dd>"<tt>dllimport</tt>" linkage causes the compiler to reference a function |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 601 | or variable via a global pointer to a pointer that is set up by the DLL |
| 602 | exporting the symbol. On Microsoft Windows targets, the pointer name is |
| 603 | formed by combining <code>__imp_</code> and the function or variable |
| 604 | name.</dd> |
Anton Korobeynikov | b74ed07 | 2006-09-14 18:23:27 +0000 | [diff] [blame] | 605 | |
| 606 | <dt><tt><b><a name="linkage_dllexport">dllexport</a></b></tt>: </dt> |
Anton Korobeynikov | b74ed07 | 2006-09-14 18:23:27 +0000 | [diff] [blame] | 607 | <dd>"<tt>dllexport</tt>" linkage causes the compiler to provide a global |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 608 | pointer to a pointer in a DLL, so that it can be referenced with the |
| 609 | <tt>dllimport</tt> attribute. On Microsoft Windows targets, the pointer |
| 610 | name is formed by combining <code>__imp_</code> and the function or |
| 611 | variable name.</dd> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 612 | </dl> |
| 613 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 614 | <p>For example, since the "<tt>.LC0</tt>" variable is defined to be internal, if |
| 615 | another module defined a "<tt>.LC0</tt>" variable and was linked with this |
| 616 | one, one of the two would be renamed, preventing a collision. Since |
| 617 | "<tt>main</tt>" and "<tt>puts</tt>" are external (i.e., lacking any linkage |
| 618 | declarations), they are accessible outside of the current module.</p> |
| 619 | |
| 620 | <p>It is illegal for a function <i>declaration</i> to have any linkage type |
| 621 | other than "externally visible", <tt>dllimport</tt> |
| 622 | or <tt>extern_weak</tt>.</p> |
| 623 | |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 624 | <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] | 625 | or <tt>weak_odr</tt> linkages.</p> |
| 626 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 627 | </div> |
| 628 | |
| 629 | <!-- ======================================================================= --> |
| 630 | <div class="doc_subsection"> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 631 | <a name="callingconv">Calling Conventions</a> |
| 632 | </div> |
| 633 | |
| 634 | <div class="doc_text"> |
| 635 | |
| 636 | <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] | 637 | and <a href="#i_invoke">invokes</a> can all have an optional calling |
| 638 | convention specified for the call. The calling convention of any pair of |
| 639 | dynamic caller/callee must match, or the behavior of the program is |
| 640 | undefined. The following calling conventions are supported by LLVM, and more |
| 641 | may be added in the future:</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 642 | |
| 643 | <dl> |
| 644 | <dt><b>"<tt>ccc</tt>" - The C calling convention</b>:</dt> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 645 | <dd>This calling convention (the default if no other calling convention is |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 646 | specified) matches the target C calling conventions. This calling |
| 647 | convention supports varargs function calls and tolerates some mismatch in |
| 648 | the declared prototype and implemented declaration of the function (as |
| 649 | does normal C).</dd> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 650 | |
| 651 | <dt><b>"<tt>fastcc</tt>" - The fast calling convention</b>:</dt> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 652 | <dd>This calling convention attempts to make calls as fast as possible |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 653 | (e.g. by passing things in registers). This calling convention allows the |
| 654 | target to use whatever tricks it wants to produce fast code for the |
| 655 | target, without having to conform to an externally specified ABI |
| 656 | (Application Binary Interface). Implementations of this convention should |
| 657 | allow arbitrary <a href="CodeGenerator.html#tailcallopt">tail call |
| 658 | optimization</a> to be supported. This calling convention does not |
| 659 | support varargs and requires the prototype of all callees to exactly match |
| 660 | the prototype of the function definition.</dd> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 661 | |
| 662 | <dt><b>"<tt>coldcc</tt>" - The cold calling convention</b>:</dt> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 663 | <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] | 664 | as possible under the assumption that the call is not commonly executed. |
| 665 | As such, these calls often preserve all registers so that the call does |
| 666 | not break any live ranges in the caller side. This calling convention |
| 667 | does not support varargs and requires the prototype of all callees to |
| 668 | exactly match the prototype of the function definition.</dd> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 669 | |
Chris Lattner | cfe6b37 | 2005-05-07 01:46:40 +0000 | [diff] [blame] | 670 | <dt><b>"<tt>cc <<em>n</em>></tt>" - Numbered convention</b>:</dt> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 671 | <dd>Any calling convention may be specified by number, allowing |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 672 | target-specific calling conventions to be used. Target specific calling |
| 673 | conventions start at 64.</dd> |
Chris Lattner | cfe6b37 | 2005-05-07 01:46:40 +0000 | [diff] [blame] | 674 | </dl> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 675 | |
| 676 | <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] | 677 | support Pascal conventions or any other well-known target-independent |
| 678 | convention.</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 679 | |
| 680 | </div> |
| 681 | |
| 682 | <!-- ======================================================================= --> |
| 683 | <div class="doc_subsection"> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 684 | <a name="visibility">Visibility Styles</a> |
| 685 | </div> |
| 686 | |
| 687 | <div class="doc_text"> |
| 688 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 689 | <p>All Global Variables and Functions have one of the following visibility |
| 690 | styles:</p> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 691 | |
| 692 | <dl> |
| 693 | <dt><b>"<tt>default</tt>" - Default style</b>:</dt> |
Chris Lattner | d3eda89 | 2008-08-05 18:29:16 +0000 | [diff] [blame] | 694 | <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] | 695 | that the declaration is visible to other modules and, in shared libraries, |
| 696 | means that the declared entity may be overridden. On Darwin, default |
| 697 | visibility means that the declaration is visible to other modules. Default |
| 698 | visibility corresponds to "external linkage" in the language.</dd> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 699 | |
| 700 | <dt><b>"<tt>hidden</tt>" - Hidden style</b>:</dt> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 701 | <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] | 702 | object if they are in the same shared object. Usually, hidden visibility |
| 703 | indicates that the symbol will not be placed into the dynamic symbol |
| 704 | table, so no other module (executable or shared library) can reference it |
| 705 | directly.</dd> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 706 | |
Anton Korobeynikov | 6f9896f | 2007-04-29 18:35:00 +0000 | [diff] [blame] | 707 | <dt><b>"<tt>protected</tt>" - Protected style</b>:</dt> |
Anton Korobeynikov | 6f9896f | 2007-04-29 18:35:00 +0000 | [diff] [blame] | 708 | <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] | 709 | the dynamic symbol table, but that references within the defining module |
| 710 | will bind to the local symbol. That is, the symbol cannot be overridden by |
| 711 | another module.</dd> |
Anton Korobeynikov | 8cea37b | 2007-01-23 12:35:46 +0000 | [diff] [blame] | 712 | </dl> |
| 713 | |
| 714 | </div> |
| 715 | |
| 716 | <!-- ======================================================================= --> |
| 717 | <div class="doc_subsection"> |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 718 | <a name="namedtypes">Named Types</a> |
| 719 | </div> |
| 720 | |
| 721 | <div class="doc_text"> |
| 722 | |
| 723 | <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] | 724 | it easier to read the IR and make the IR more condensed (particularly when |
| 725 | recursive types are involved). An example of a name specification is:</p> |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 726 | |
| 727 | <div class="doc_code"> |
| 728 | <pre> |
| 729 | %mytype = type { %mytype*, i32 } |
| 730 | </pre> |
| 731 | </div> |
| 732 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 733 | <p>You may give a name to any <a href="#typesystem">type</a> except |
| 734 | "<a href="t_void">void</a>". Type name aliases may be used anywhere a type |
| 735 | is expected with the syntax "%mytype".</p> |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 736 | |
| 737 | <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] | 738 | and that you can therefore specify multiple names for the same type. This |
| 739 | often leads to confusing behavior when dumping out a .ll file. Since LLVM IR |
| 740 | uses structural typing, the name is not part of the type. When printing out |
| 741 | LLVM IR, the printer will pick <em>one name</em> to render all types of a |
| 742 | particular shape. This means that if you have code where two different |
| 743 | source types end up having the same LLVM type, that the dumper will sometimes |
| 744 | print the "wrong" or unexpected type. This is an important design point and |
| 745 | isn't going to change.</p> |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 746 | |
| 747 | </div> |
| 748 | |
Chris Lattner | e7886e4 | 2009-01-11 20:53:49 +0000 | [diff] [blame] | 749 | <!-- ======================================================================= --> |
| 750 | <div class="doc_subsection"> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 751 | <a name="globalvars">Global Variables</a> |
| 752 | </div> |
| 753 | |
| 754 | <div class="doc_text"> |
| 755 | |
Chris Lattner | 3689a34 | 2005-02-12 19:30:21 +0000 | [diff] [blame] | 756 | <p>Global variables define regions of memory allocated at compilation time |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 757 | instead of run-time. Global variables may optionally be initialized, may |
| 758 | have an explicit section to be placed in, and may have an optional explicit |
| 759 | alignment specified. A variable may be defined as "thread_local", which |
| 760 | means that it will not be shared by threads (each thread will have a |
| 761 | separated copy of the variable). A variable may be defined as a global |
| 762 | "constant," which indicates that the contents of the variable |
| 763 | will <b>never</b> be modified (enabling better optimization, allowing the |
| 764 | global data to be placed in the read-only section of an executable, etc). |
| 765 | Note that variables that need runtime initialization cannot be marked |
| 766 | "constant" as there is a store to the variable.</p> |
Chris Lattner | 3689a34 | 2005-02-12 19:30:21 +0000 | [diff] [blame] | 767 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 768 | <p>LLVM explicitly allows <em>declarations</em> of global variables to be marked |
| 769 | constant, even if the final definition of the global is not. This capability |
| 770 | can be used to enable slightly better optimization of the program, but |
| 771 | requires the language definition to guarantee that optimizations based on the |
| 772 | 'constantness' are valid for the translation units that do not include the |
| 773 | definition.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 774 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 775 | <p>As SSA values, global variables define pointer values that are in scope |
| 776 | (i.e. they dominate) all basic blocks in the program. Global variables |
| 777 | always define a pointer to their "content" type because they describe a |
| 778 | region of memory, and all memory objects in LLVM are accessed through |
| 779 | pointers.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 780 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 781 | <p>A global variable may be declared to reside in a target-specific numbered |
| 782 | address space. For targets that support them, address spaces may affect how |
| 783 | optimizations are performed and/or what target instructions are used to |
| 784 | access the variable. The default address space is zero. The address space |
| 785 | qualifier must precede any other attributes.</p> |
Christopher Lamb | 284d992 | 2007-12-11 09:31:00 +0000 | [diff] [blame] | 786 | |
Chris Lattner | 88f6c46 | 2005-11-12 00:45:07 +0000 | [diff] [blame] | 787 | <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] | 788 | supports it, it will emit globals to the section specified.</p> |
Chris Lattner | 88f6c46 | 2005-11-12 00:45:07 +0000 | [diff] [blame] | 789 | |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 790 | <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] | 791 | the alignment is set to zero, the alignment of the global is set by the |
| 792 | target to whatever it feels convenient. If an explicit alignment is |
| 793 | specified, the global is forced to have at least that much alignment. All |
| 794 | alignments must be a power of 2.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 795 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 796 | <p>For example, the following defines a global in a numbered address space with |
| 797 | an initializer, section, and alignment:</p> |
Chris Lattner | 68027ea | 2007-01-14 00:27:09 +0000 | [diff] [blame] | 798 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 799 | <div class="doc_code"> |
Chris Lattner | 68027ea | 2007-01-14 00:27:09 +0000 | [diff] [blame] | 800 | <pre> |
Dan Gohman | 398873c | 2009-01-11 00:40:00 +0000 | [diff] [blame] | 801 | @G = addrspace(5) constant float 1.0, section "foo", align 4 |
Chris Lattner | 68027ea | 2007-01-14 00:27:09 +0000 | [diff] [blame] | 802 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 803 | </div> |
Chris Lattner | 68027ea | 2007-01-14 00:27:09 +0000 | [diff] [blame] | 804 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 805 | </div> |
| 806 | |
| 807 | |
| 808 | <!-- ======================================================================= --> |
| 809 | <div class="doc_subsection"> |
| 810 | <a name="functionstructure">Functions</a> |
| 811 | </div> |
| 812 | |
| 813 | <div class="doc_text"> |
| 814 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 815 | <p>LLVM function definitions consist of the "<tt>define</tt>" keyord, an |
| 816 | optional <a href="#linkage">linkage type</a>, an optional |
| 817 | <a href="#visibility">visibility style</a>, an optional |
| 818 | <a href="#callingconv">calling convention</a>, a return type, an optional |
| 819 | <a href="#paramattrs">parameter attribute</a> for the return type, a function |
| 820 | name, a (possibly empty) argument list (each with optional |
| 821 | <a href="#paramattrs">parameter attributes</a>), optional |
| 822 | <a href="#fnattrs">function attributes</a>, an optional section, an optional |
| 823 | alignment, an optional <a href="#gc">garbage collector name</a>, an opening |
| 824 | 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] | 825 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 826 | <p>LLVM function declarations consist of the "<tt>declare</tt>" keyword, 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 list of arguments, an optional alignment, and an |
| 832 | optional <a href="#gc">garbage collector name</a>.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 833 | |
Chris Lattner | d3eda89 | 2008-08-05 18:29:16 +0000 | [diff] [blame] | 834 | <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] | 835 | (Control Flow Graph) for the function. Each basic block may optionally start |
| 836 | with a label (giving the basic block a symbol table entry), contains a list |
| 837 | of instructions, and ends with a <a href="#terminators">terminator</a> |
| 838 | instruction (such as a branch or function return).</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 839 | |
Chris Lattner | 4a3c901 | 2007-06-08 16:52:14 +0000 | [diff] [blame] | 840 | <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] | 841 | executed on entrance to the function, and it is not allowed to have |
| 842 | predecessor basic blocks (i.e. there can not be any branches to the entry |
| 843 | block of a function). Because the block can have no predecessors, it also |
| 844 | cannot have any <a href="#i_phi">PHI nodes</a>.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 845 | |
Chris Lattner | 88f6c46 | 2005-11-12 00:45:07 +0000 | [diff] [blame] | 846 | <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] | 847 | supports it, it will emit functions to the section specified.</p> |
Chris Lattner | 88f6c46 | 2005-11-12 00:45:07 +0000 | [diff] [blame] | 848 | |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 849 | <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] | 850 | the alignment is set to zero, the alignment of the function is set by the |
| 851 | target to whatever it feels convenient. If an explicit alignment is |
| 852 | specified, the function is forced to have at least that much alignment. All |
| 853 | alignments must be a power of 2.</p> |
Chris Lattner | 2cbdc45 | 2005-11-06 08:02:57 +0000 | [diff] [blame] | 854 | |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 855 | <h5>Syntax:</h5> |
Devang Patel | 307e8ab | 2008-10-07 17:48:33 +0000 | [diff] [blame] | 856 | <div class="doc_code"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 857 | <pre> |
Chris Lattner | 50ad45c | 2008-10-13 16:55:18 +0000 | [diff] [blame] | 858 | define [<a href="#linkage">linkage</a>] [<a href="#visibility">visibility</a>] |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 859 | [<a href="#callingconv">cconv</a>] [<a href="#paramattrs">ret attrs</a>] |
| 860 | <ResultType> @<FunctionName> ([argument list]) |
| 861 | [<a href="#fnattrs">fn Attrs</a>] [section "name"] [align N] |
| 862 | [<a href="#gc">gc</a>] { ... } |
| 863 | </pre> |
Devang Patel | 307e8ab | 2008-10-07 17:48:33 +0000 | [diff] [blame] | 864 | </div> |
| 865 | |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 866 | </div> |
| 867 | |
Anton Korobeynikov | 8b0a8c8 | 2007-04-25 14:27:10 +0000 | [diff] [blame] | 868 | <!-- ======================================================================= --> |
| 869 | <div class="doc_subsection"> |
| 870 | <a name="aliasstructure">Aliases</a> |
| 871 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 872 | |
Anton Korobeynikov | 8b0a8c8 | 2007-04-25 14:27:10 +0000 | [diff] [blame] | 873 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 874 | |
| 875 | <p>Aliases act as "second name" for the aliasee value (which can be either |
| 876 | function, global variable, another alias or bitcast of global value). Aliases |
| 877 | may have an optional <a href="#linkage">linkage type</a>, and an |
| 878 | optional <a href="#visibility">visibility style</a>.</p> |
Anton Korobeynikov | 8b0a8c8 | 2007-04-25 14:27:10 +0000 | [diff] [blame] | 879 | |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 880 | <h5>Syntax:</h5> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 881 | <div class="doc_code"> |
Bill Wendling | aac388b | 2007-05-29 09:42:13 +0000 | [diff] [blame] | 882 | <pre> |
Duncan Sands | 0b23ac1 | 2008-09-12 20:48:21 +0000 | [diff] [blame] | 883 | @<Name> = alias [Linkage] [Visibility] <AliaseeTy> @<Aliasee> |
Bill Wendling | aac388b | 2007-05-29 09:42:13 +0000 | [diff] [blame] | 884 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 885 | </div> |
Anton Korobeynikov | 8b0a8c8 | 2007-04-25 14:27:10 +0000 | [diff] [blame] | 886 | |
| 887 | </div> |
| 888 | |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 889 | <!-- ======================================================================= --> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 890 | <div class="doc_subsection"><a name="paramattrs">Parameter Attributes</a></div> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 891 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 892 | <div class="doc_text"> |
| 893 | |
| 894 | <p>The return type and each parameter of a function type may have a set of |
| 895 | <i>parameter attributes</i> associated with them. Parameter attributes are |
| 896 | used to communicate additional information about the result or parameters of |
| 897 | a function. Parameter attributes are considered to be part of the function, |
| 898 | not of the function type, so functions with different parameter attributes |
| 899 | can have the same function type.</p> |
| 900 | |
| 901 | <p>Parameter attributes are simple keywords that follow the type specified. If |
| 902 | multiple parameter attributes are needed, they are space separated. For |
| 903 | example:</p> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 904 | |
| 905 | <div class="doc_code"> |
| 906 | <pre> |
Nick Lewycky | b6a7d25 | 2009-02-15 23:06:14 +0000 | [diff] [blame] | 907 | declare i32 @printf(i8* noalias nocapture, ...) |
Chris Lattner | 66d922c | 2008-10-04 18:33:34 +0000 | [diff] [blame] | 908 | declare i32 @atoi(i8 zeroext) |
| 909 | declare signext i8 @returns_signed_char() |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 910 | </pre> |
| 911 | </div> |
| 912 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 913 | <p>Note that any attributes for the function result (<tt>nounwind</tt>, |
| 914 | <tt>readonly</tt>) come immediately after the argument list.</p> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 915 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 916 | <p>Currently, only the following parameter attributes are defined:</p> |
Chris Lattner | 47507de | 2008-01-11 06:20:47 +0000 | [diff] [blame] | 917 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 918 | <dl> |
| 919 | <dt><tt>zeroext</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 920 | <dd>This indicates to the code generator that the parameter or return value |
| 921 | should be zero-extended to a 32-bit value by the caller (for a parameter) |
| 922 | or the callee (for a return value).</dd> |
Chris Lattner | 47507de | 2008-01-11 06:20:47 +0000 | [diff] [blame] | 923 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 924 | <dt><tt>signext</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 925 | <dd>This indicates to the code generator that the parameter or return value |
| 926 | should be sign-extended to a 32-bit value by the caller (for a parameter) |
| 927 | or the callee (for a return value).</dd> |
Chris Lattner | 47507de | 2008-01-11 06:20:47 +0000 | [diff] [blame] | 928 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 929 | <dt><tt>inreg</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 930 | <dd>This indicates that this parameter or return value should be treated in a |
| 931 | special target-dependent fashion during while emitting code for a function |
| 932 | call or return (usually, by putting it in a register as opposed to memory, |
| 933 | though some targets use it to distinguish between two different kinds of |
| 934 | registers). Use of this attribute is target-specific.</dd> |
Chris Lattner | 47507de | 2008-01-11 06:20:47 +0000 | [diff] [blame] | 935 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 936 | <dt><tt><a name="byval">byval</a></tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 937 | <dd>This indicates that the pointer parameter should really be passed by value |
| 938 | to the function. The attribute implies that a hidden copy of the pointee |
| 939 | is made between the caller and the callee, so the callee is unable to |
| 940 | modify the value in the callee. This attribute is only valid on LLVM |
| 941 | pointer arguments. It is generally used to pass structs and arrays by |
| 942 | value, but is also valid on pointers to scalars. The copy is considered |
| 943 | to belong to the caller not the callee (for example, |
| 944 | <tt><a href="#readonly">readonly</a></tt> functions should not write to |
| 945 | <tt>byval</tt> parameters). This is not a valid attribute for return |
| 946 | values. The byval attribute also supports specifying an alignment with |
| 947 | the align attribute. This has a target-specific effect on the code |
| 948 | generator that usually indicates a desired alignment for the synthesized |
| 949 | stack slot.</dd> |
| 950 | |
| 951 | <dt><tt>sret</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 952 | <dd>This indicates that the pointer parameter specifies the address of a |
| 953 | structure that is the return value of the function in the source program. |
| 954 | This pointer must be guaranteed by the caller to be valid: loads and |
| 955 | stores to the structure may be assumed by the callee to not to trap. This |
| 956 | may only be applied to the first parameter. This is not a valid attribute |
| 957 | for return values. </dd> |
| 958 | |
| 959 | <dt><tt>noalias</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 960 | <dd>This indicates that the pointer does not alias any global or any other |
| 961 | parameter. The caller is responsible for ensuring that this is the |
| 962 | case. On a function return value, <tt>noalias</tt> additionally indicates |
| 963 | that the pointer does not alias any other pointers visible to the |
| 964 | caller. For further details, please see the discussion of the NoAlias |
| 965 | response in |
| 966 | <a href="http://llvm.org/docs/AliasAnalysis.html#MustMayNo">alias |
| 967 | analysis</a>.</dd> |
| 968 | |
| 969 | <dt><tt>nocapture</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 970 | <dd>This indicates that the callee does not make any copies of the pointer |
| 971 | that outlive the callee itself. This is not a valid attribute for return |
| 972 | values.</dd> |
| 973 | |
| 974 | <dt><tt>nest</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 975 | <dd>This indicates that the pointer parameter can be excised using the |
| 976 | <a href="#int_trampoline">trampoline intrinsics</a>. This is not a valid |
| 977 | attribute for return values.</dd> |
| 978 | </dl> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 979 | |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 980 | </div> |
| 981 | |
| 982 | <!-- ======================================================================= --> |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 983 | <div class="doc_subsection"> |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 984 | <a name="gc">Garbage Collector Names</a> |
| 985 | </div> |
| 986 | |
| 987 | <div class="doc_text"> |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 988 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 989 | <p>Each function may specify a garbage collector name, which is simply a |
| 990 | string:</p> |
| 991 | |
| 992 | <div class="doc_code"> |
| 993 | <pre> |
| 994 | define void @f() gc "name" { ... |
| 995 | </pre> |
| 996 | </div> |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 997 | |
| 998 | <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] | 999 | collector which will cause the compiler to alter its output in order to |
| 1000 | support the named garbage collection algorithm.</p> |
| 1001 | |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 1002 | </div> |
| 1003 | |
| 1004 | <!-- ======================================================================= --> |
| 1005 | <div class="doc_subsection"> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1006 | <a name="fnattrs">Function Attributes</a> |
Devang Patel | f8b9481 | 2008-09-04 23:05:13 +0000 | [diff] [blame] | 1007 | </div> |
| 1008 | |
| 1009 | <div class="doc_text"> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1010 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1011 | <p>Function attributes are set to communicate additional information about a |
| 1012 | function. Function attributes are considered to be part of the function, not |
| 1013 | of the function type, so functions with different parameter attributes can |
| 1014 | have the same function type.</p> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1015 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1016 | <p>Function attributes are simple keywords that follow the type specified. If |
| 1017 | multiple attributes are needed, they are space separated. For example:</p> |
Devang Patel | f8b9481 | 2008-09-04 23:05:13 +0000 | [diff] [blame] | 1018 | |
| 1019 | <div class="doc_code"> |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1020 | <pre> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1021 | define void @f() noinline { ... } |
| 1022 | define void @f() alwaysinline { ... } |
| 1023 | define void @f() alwaysinline optsize { ... } |
| 1024 | define void @f() optsize |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1025 | </pre> |
Devang Patel | f8b9481 | 2008-09-04 23:05:13 +0000 | [diff] [blame] | 1026 | </div> |
| 1027 | |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1028 | <dl> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1029 | <dt><tt>alwaysinline</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1030 | <dd>This attribute indicates that the inliner should attempt to inline this |
| 1031 | function into callers whenever possible, ignoring any active inlining size |
| 1032 | threshold for this caller.</dd> |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1033 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1034 | <dt><tt>noinline</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1035 | <dd>This attribute indicates that the inliner should never inline this |
| 1036 | function in any situation. This attribute may not be used together with |
| 1037 | the <tt>alwaysinline</tt> attribute.</dd> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1038 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1039 | <dt><tt>optsize</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1040 | <dd>This attribute suggests that optimization passes and code generator passes |
| 1041 | make choices that keep the code size of this function low, and otherwise |
| 1042 | do optimizations specifically to reduce code size.</dd> |
Devang Patel | 2c9c3e7 | 2008-09-26 23:51:19 +0000 | [diff] [blame] | 1043 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1044 | <dt><tt>noreturn</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1045 | <dd>This function attribute indicates that the function never returns |
| 1046 | normally. This produces undefined behavior at runtime if the function |
| 1047 | ever does dynamically return.</dd> |
Bill Wendling | 31359ba | 2008-11-13 01:02:51 +0000 | [diff] [blame] | 1048 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1049 | <dt><tt>nounwind</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1050 | <dd>This function attribute indicates that the function never returns with an |
| 1051 | unwind or exceptional control flow. If the function does unwind, its |
| 1052 | runtime behavior is undefined.</dd> |
Bill Wendling | fbaa7ed | 2008-11-26 19:07:40 +0000 | [diff] [blame] | 1053 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1054 | <dt><tt>readnone</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1055 | <dd>This attribute indicates that the function computes its result (or decides |
| 1056 | to unwind an exception) based strictly on its arguments, without |
| 1057 | dereferencing any pointer arguments or otherwise accessing any mutable |
| 1058 | state (e.g. memory, control registers, etc) visible to caller functions. |
| 1059 | It does not write through any pointer arguments |
| 1060 | (including <tt><a href="#byval">byval</a></tt> arguments) and never |
| 1061 | changes any state visible to callers. This means that it cannot unwind |
| 1062 | exceptions by calling the <tt>C++</tt> exception throwing methods, but |
| 1063 | could use the <tt>unwind</tt> instruction.</dd> |
Devang Patel | 5d96fda | 2009-06-12 19:45:19 +0000 | [diff] [blame] | 1064 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1065 | <dt><tt><a name="readonly">readonly</a></tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1066 | <dd>This attribute indicates that the function does not write through any |
| 1067 | pointer arguments (including <tt><a href="#byval">byval</a></tt> |
| 1068 | arguments) or otherwise modify any state (e.g. memory, control registers, |
| 1069 | etc) visible to caller functions. It may dereference pointer arguments |
| 1070 | and read state that may be set in the caller. A readonly function always |
| 1071 | returns the same value (or unwinds an exception identically) when called |
| 1072 | with the same set of arguments and global state. It cannot unwind an |
| 1073 | exception by calling the <tt>C++</tt> exception throwing methods, but may |
| 1074 | use the <tt>unwind</tt> instruction.</dd> |
Anton Korobeynikov | c5ec8a7 | 2009-07-17 18:07:26 +0000 | [diff] [blame] | 1075 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1076 | <dt><tt><a name="ssp">ssp</a></tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1077 | <dd>This attribute indicates that the function should emit a stack smashing |
| 1078 | protector. It is in the form of a "canary"—a random value placed on |
| 1079 | the stack before the local variables that's checked upon return from the |
| 1080 | function to see if it has been overwritten. A heuristic is used to |
| 1081 | determine if a function needs stack protectors or not.<br> |
| 1082 | <br> |
| 1083 | If a function that has an <tt>ssp</tt> attribute is inlined into a |
| 1084 | function that doesn't have an <tt>ssp</tt> attribute, then the resulting |
| 1085 | function will have an <tt>ssp</tt> attribute.</dd> |
| 1086 | |
| 1087 | <dt><tt>sspreq</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1088 | <dd>This attribute indicates that the function should <em>always</em> emit a |
| 1089 | stack smashing protector. This overrides |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 1090 | the <tt><a href="#ssp">ssp</a></tt> function attribute.<br> |
| 1091 | <br> |
| 1092 | If a function that has an <tt>sspreq</tt> attribute is inlined into a |
| 1093 | function that doesn't have an <tt>sspreq</tt> attribute or which has |
| 1094 | an <tt>ssp</tt> attribute, then the resulting function will have |
| 1095 | an <tt>sspreq</tt> attribute.</dd> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1096 | |
| 1097 | <dt><tt>noredzone</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1098 | <dd>This attribute indicates that the code generator should not use a red |
| 1099 | zone, even if the target-specific ABI normally permits it.</dd> |
| 1100 | |
| 1101 | <dt><tt>noimplicitfloat</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1102 | <dd>This attributes disables implicit floating point instructions.</dd> |
| 1103 | |
| 1104 | <dt><tt>naked</tt></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1105 | <dd>This attribute disables prologue / epilogue emission for the function. |
| 1106 | This can have very system-specific consequences.</dd> |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1107 | </dl> |
| 1108 | |
Devang Patel | f8b9481 | 2008-09-04 23:05:13 +0000 | [diff] [blame] | 1109 | </div> |
| 1110 | |
| 1111 | <!-- ======================================================================= --> |
| 1112 | <div class="doc_subsection"> |
Chris Lattner | 1eeeb0c | 2006-04-08 04:40:53 +0000 | [diff] [blame] | 1113 | <a name="moduleasm">Module-Level Inline Assembly</a> |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 1114 | </div> |
| 1115 | |
| 1116 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1117 | |
| 1118 | <p>Modules may contain "module-level inline asm" blocks, which corresponds to |
| 1119 | the GCC "file scope inline asm" blocks. These blocks are internally |
| 1120 | concatenated by LLVM and treated as a single unit, but may be separated in |
| 1121 | 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] | 1122 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 1123 | <div class="doc_code"> |
| 1124 | <pre> |
| 1125 | module asm "inline asm code goes here" |
| 1126 | module asm "more can go here" |
| 1127 | </pre> |
| 1128 | </div> |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 1129 | |
| 1130 | <p>The strings can contain any character by escaping non-printable characters. |
| 1131 | 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] | 1132 | for the number.</p> |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 1133 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1134 | <p>The inline asm code is simply printed to the machine code .s file when |
| 1135 | assembly code is generated.</p> |
| 1136 | |
Chris Lattner | 4e9aba7 | 2006-01-23 23:23:47 +0000 | [diff] [blame] | 1137 | </div> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 1138 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1139 | <!-- ======================================================================= --> |
| 1140 | <div class="doc_subsection"> |
| 1141 | <a name="datalayout">Data Layout</a> |
| 1142 | </div> |
| 1143 | |
| 1144 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1145 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1146 | <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] | 1147 | data is to be laid out in memory. The syntax for the data layout is |
| 1148 | simply:</p> |
| 1149 | |
| 1150 | <div class="doc_code"> |
| 1151 | <pre> |
| 1152 | target datalayout = "<i>layout specification</i>" |
| 1153 | </pre> |
| 1154 | </div> |
| 1155 | |
| 1156 | <p>The <i>layout specification</i> consists of a list of specifications |
| 1157 | separated by the minus sign character ('-'). Each specification starts with |
| 1158 | a letter and may include other information after the letter to define some |
| 1159 | aspect of the data layout. The specifications accepted are as follows:</p> |
| 1160 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1161 | <dl> |
| 1162 | <dt><tt>E</tt></dt> |
| 1163 | <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] | 1164 | bits with the most significance have the lowest address location.</dd> |
| 1165 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1166 | <dt><tt>e</tt></dt> |
Chris Lattner | d3eda89 | 2008-08-05 18:29:16 +0000 | [diff] [blame] | 1167 | <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] | 1168 | the bits with the least significance have the lowest address |
| 1169 | location.</dd> |
| 1170 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1171 | <dt><tt>p:<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
| 1172 | <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] | 1173 | <i>preferred</i> alignments. All sizes are in bits. Specifying |
| 1174 | the <i>pref</i> alignment is optional. If omitted, the |
| 1175 | preceding <tt>:</tt> should be omitted too.</dd> |
| 1176 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1177 | <dt><tt>i<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
| 1178 | <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] | 1179 | <i>size</i>. The value of <i>size</i> must be in the range [1,2^23).</dd> |
| 1180 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1181 | <dt><tt>v<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
| 1182 | <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] | 1183 | <i>size</i>.</dd> |
| 1184 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1185 | <dt><tt>f<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
| 1186 | <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] | 1187 | <i>size</i>. The value of <i>size</i> must be either 32 (float) or 64 |
| 1188 | (double).</dd> |
| 1189 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1190 | <dt><tt>a<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
| 1191 | <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] | 1192 | <i>size</i>.</dd> |
| 1193 | |
Daniel Dunbar | 87bde0b | 2009-06-08 22:17:53 +0000 | [diff] [blame] | 1194 | <dt><tt>s<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt> |
| 1195 | <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] | 1196 | <i>size</i>.</dd> |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1197 | </dl> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1198 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1199 | <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] | 1200 | default set of specifications which are then (possibly) overriden by the |
| 1201 | specifications in the <tt>datalayout</tt> keyword. The default specifications |
| 1202 | are given in this list:</p> |
| 1203 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1204 | <ul> |
| 1205 | <li><tt>E</tt> - big endian</li> |
| 1206 | <li><tt>p:32:64:64</tt> - 32-bit pointers with 64-bit alignment</li> |
| 1207 | <li><tt>i1:8:8</tt> - i1 is 8-bit (byte) aligned</li> |
| 1208 | <li><tt>i8:8:8</tt> - i8 is 8-bit (byte) aligned</li> |
| 1209 | <li><tt>i16:16:16</tt> - i16 is 16-bit aligned</li> |
| 1210 | <li><tt>i32:32:32</tt> - i32 is 32-bit aligned</li> |
Chris Lattner | d3eda89 | 2008-08-05 18:29:16 +0000 | [diff] [blame] | 1211 | <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] | 1212 | alignment of 64-bits</li> |
| 1213 | <li><tt>f32:32:32</tt> - float is 32-bit aligned</li> |
| 1214 | <li><tt>f64:64:64</tt> - double is 64-bit aligned</li> |
| 1215 | <li><tt>v64:64:64</tt> - 64-bit vector is 64-bit aligned</li> |
| 1216 | <li><tt>v128:128:128</tt> - 128-bit vector is 128-bit aligned</li> |
| 1217 | <li><tt>a0:0:1</tt> - aggregates are 8-bit aligned</li> |
Daniel Dunbar | 87bde0b | 2009-06-08 22:17:53 +0000 | [diff] [blame] | 1218 | <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] | 1219 | </ul> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1220 | |
| 1221 | <p>When LLVM is determining the alignment for a given type, it uses the |
| 1222 | following rules:</p> |
| 1223 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1224 | <ol> |
| 1225 | <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] | 1226 | specification is used.</li> |
| 1227 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1228 | <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] | 1229 | smallest integer type that is larger than the bitwidth of the sought type |
| 1230 | is used. If none of the specifications are larger than the bitwidth then |
| 1231 | the the largest integer type is used. For example, given the default |
| 1232 | specifications above, the i7 type will use the alignment of i8 (next |
| 1233 | largest) while both i65 and i256 will use the alignment of i64 (largest |
| 1234 | specified).</li> |
| 1235 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1236 | <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] | 1237 | largest vector type that is smaller than the sought vector type will be |
| 1238 | used as a fall back. This happens because <128 x double> can be |
| 1239 | implemented in terms of 64 <2 x double>, for example.</li> |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1240 | </ol> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1241 | |
Reid Spencer | de15194 | 2007-02-19 23:54:10 +0000 | [diff] [blame] | 1242 | </div> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 1243 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1244 | <!-- *********************************************************************** --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1245 | <div class="doc_section"> <a name="typesystem">Type System</a> </div> |
| 1246 | <!-- *********************************************************************** --> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 1247 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1248 | <div class="doc_text"> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 1249 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1250 | <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] | 1251 | intermediate representation. Being typed enables a number of optimizations |
| 1252 | to be performed on the intermediate representation directly, without having |
| 1253 | to do extra analyses on the side before the transformation. A strong type |
| 1254 | system makes it easier to read the generated code and enables novel analyses |
| 1255 | and transformations that are not feasible to perform on normal three address |
| 1256 | code representations.</p> |
Chris Lattner | fa73021 | 2004-12-09 16:11:40 +0000 | [diff] [blame] | 1257 | |
| 1258 | </div> |
| 1259 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1260 | <!-- ======================================================================= --> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1261 | <div class="doc_subsection"> <a name="t_classifications">Type |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1262 | Classifications</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1263 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1264 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1265 | |
| 1266 | <p>The types fall into a few useful classifications:</p> |
Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1267 | |
| 1268 | <table border="1" cellspacing="0" cellpadding="4"> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1269 | <tbody> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1270 | <tr><th>Classification</th><th>Types</th></tr> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1271 | <tr> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1272 | <td><a href="#t_integer">integer</a></td> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1273 | <td><tt>i1, i2, i3, ... i8, ... i16, ... i32, ... i64, ... </tt></td> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1274 | </tr> |
| 1275 | <tr> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1276 | <td><a href="#t_floating">floating point</a></td> |
| 1277 | <td><tt>float, double, x86_fp80, fp128, ppc_fp128</tt></td> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1278 | </tr> |
| 1279 | <tr> |
| 1280 | <td><a name="t_firstclass">first class</a></td> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1281 | <td><a href="#t_integer">integer</a>, |
| 1282 | <a href="#t_floating">floating point</a>, |
| 1283 | <a href="#t_pointer">pointer</a>, |
Dan Gohman | 0066db6 | 2008-06-18 18:42:13 +0000 | [diff] [blame] | 1284 | <a href="#t_vector">vector</a>, |
Dan Gohman | a334d5f | 2008-05-12 23:51:09 +0000 | [diff] [blame] | 1285 | <a href="#t_struct">structure</a>, |
| 1286 | <a href="#t_array">array</a>, |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 1287 | <a href="#t_label">label</a>, |
| 1288 | <a href="#t_metadata">metadata</a>. |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 1289 | </td> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1290 | </tr> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1291 | <tr> |
| 1292 | <td><a href="#t_primitive">primitive</a></td> |
| 1293 | <td><a href="#t_label">label</a>, |
| 1294 | <a href="#t_void">void</a>, |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 1295 | <a href="#t_floating">floating point</a>, |
| 1296 | <a href="#t_metadata">metadata</a>.</td> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1297 | </tr> |
| 1298 | <tr> |
| 1299 | <td><a href="#t_derived">derived</a></td> |
| 1300 | <td><a href="#t_integer">integer</a>, |
| 1301 | <a href="#t_array">array</a>, |
| 1302 | <a href="#t_function">function</a>, |
| 1303 | <a href="#t_pointer">pointer</a>, |
| 1304 | <a href="#t_struct">structure</a>, |
| 1305 | <a href="#t_pstruct">packed structure</a>, |
| 1306 | <a href="#t_vector">vector</a>, |
| 1307 | <a href="#t_opaque">opaque</a>. |
Dan Gohman | 01ac101 | 2008-10-14 16:32:04 +0000 | [diff] [blame] | 1308 | </td> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1309 | </tr> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1310 | </tbody> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1311 | </table> |
Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1312 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1313 | <p>The <a href="#t_firstclass">first class</a> types are perhaps the most |
| 1314 | important. Values of these types are the only ones which can be produced by |
| 1315 | instructions, passed as arguments, or used as operands to instructions.</p> |
| 1316 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1317 | </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1318 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1319 | <!-- ======================================================================= --> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1320 | <div class="doc_subsection"> <a name="t_primitive">Primitive Types</a> </div> |
Chris Lattner | 8f8c7b7 | 2008-01-04 04:34:14 +0000 | [diff] [blame] | 1321 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1322 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1323 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1324 | <p>The primitive types are the fundamental building blocks of the LLVM |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1325 | system.</p> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1326 | |
Chris Lattner | 8f8c7b7 | 2008-01-04 04:34:14 +0000 | [diff] [blame] | 1327 | </div> |
| 1328 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1329 | <!-- _______________________________________________________________________ --> |
| 1330 | <div class="doc_subsubsection"> <a name="t_floating">Floating Point Types</a> </div> |
| 1331 | |
| 1332 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1333 | |
| 1334 | <table> |
| 1335 | <tbody> |
| 1336 | <tr><th>Type</th><th>Description</th></tr> |
| 1337 | <tr><td><tt>float</tt></td><td>32-bit floating point value</td></tr> |
| 1338 | <tr><td><tt>double</tt></td><td>64-bit floating point value</td></tr> |
| 1339 | <tr><td><tt>fp128</tt></td><td>128-bit floating point value (112-bit mantissa)</td></tr> |
| 1340 | <tr><td><tt>x86_fp80</tt></td><td>80-bit floating point value (X87)</td></tr> |
| 1341 | <tr><td><tt>ppc_fp128</tt></td><td>128-bit floating point value (two 64-bits)</td></tr> |
| 1342 | </tbody> |
| 1343 | </table> |
| 1344 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1345 | </div> |
| 1346 | |
| 1347 | <!-- _______________________________________________________________________ --> |
| 1348 | <div class="doc_subsubsection"> <a name="t_void">Void Type</a> </div> |
| 1349 | |
| 1350 | <div class="doc_text"> |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 1351 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1352 | <h5>Overview:</h5> |
| 1353 | <p>The void type does not represent any value and has no size.</p> |
| 1354 | |
| 1355 | <h5>Syntax:</h5> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1356 | <pre> |
| 1357 | void |
| 1358 | </pre> |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 1359 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1360 | </div> |
| 1361 | |
| 1362 | <!-- _______________________________________________________________________ --> |
| 1363 | <div class="doc_subsubsection"> <a name="t_label">Label Type</a> </div> |
| 1364 | |
| 1365 | <div class="doc_text"> |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 1366 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1367 | <h5>Overview:</h5> |
| 1368 | <p>The label type represents code labels.</p> |
| 1369 | |
| 1370 | <h5>Syntax:</h5> |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1371 | <pre> |
| 1372 | label |
| 1373 | </pre> |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 1374 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1375 | </div> |
| 1376 | |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 1377 | <!-- _______________________________________________________________________ --> |
| 1378 | <div class="doc_subsubsection"> <a name="t_metadata">Metadata Type</a> </div> |
| 1379 | |
| 1380 | <div class="doc_text"> |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 1381 | |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 1382 | <h5>Overview:</h5> |
| 1383 | <p>The metadata type represents embedded metadata. The only derived type that |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1384 | may contain metadata is <tt>metadata*</tt> or a function type that returns or |
| 1385 | takes metadata typed parameters, but not pointer to metadata types.</p> |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 1386 | |
| 1387 | <h5>Syntax:</h5> |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 1388 | <pre> |
| 1389 | metadata |
| 1390 | </pre> |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 1391 | |
Nick Lewycky | 7a0370f | 2009-05-30 05:06:04 +0000 | [diff] [blame] | 1392 | </div> |
| 1393 | |
Chris Lattner | 4f69f46 | 2008-01-04 04:32:38 +0000 | [diff] [blame] | 1394 | |
| 1395 | <!-- ======================================================================= --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1396 | <div class="doc_subsection"> <a name="t_derived">Derived Types</a> </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1397 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1398 | <div class="doc_text"> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1399 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1400 | <p>The real power in LLVM comes from the derived types in the system. This is |
| 1401 | what allows a programmer to represent arrays, functions, pointers, and other |
| 1402 | useful types. Note that these derived types may be recursive: For example, |
| 1403 | it is possible to have a two dimensional array.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1404 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1405 | </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1406 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1407 | <!-- _______________________________________________________________________ --> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1408 | <div class="doc_subsubsection"> <a name="t_integer">Integer Type</a> </div> |
| 1409 | |
| 1410 | <div class="doc_text"> |
| 1411 | |
| 1412 | <h5>Overview:</h5> |
| 1413 | <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] | 1414 | arbitrary bit width for the integer type desired. Any bit width from 1 bit to |
| 1415 | 2^23-1 (about 8 million) can be specified.</p> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1416 | |
| 1417 | <h5>Syntax:</h5> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1418 | <pre> |
| 1419 | iN |
| 1420 | </pre> |
| 1421 | |
| 1422 | <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] | 1423 | value.</p> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1424 | |
| 1425 | <h5>Examples:</h5> |
| 1426 | <table class="layout"> |
Nick Lewycky | 86c4864 | 2009-05-24 02:46:06 +0000 | [diff] [blame] | 1427 | <tr class="layout"> |
| 1428 | <td class="left"><tt>i1</tt></td> |
| 1429 | <td class="left">a single-bit integer.</td> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1430 | </tr> |
Nick Lewycky | 86c4864 | 2009-05-24 02:46:06 +0000 | [diff] [blame] | 1431 | <tr class="layout"> |
| 1432 | <td class="left"><tt>i32</tt></td> |
| 1433 | <td class="left">a 32-bit integer.</td> |
| 1434 | </tr> |
| 1435 | <tr class="layout"> |
| 1436 | <td class="left"><tt>i1942652</tt></td> |
| 1437 | <td class="left">a really big integer of over 1 million bits.</td> |
| 1438 | </tr> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1439 | </table> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1440 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1441 | <p>Note that the code generator does not yet support large integer types to be |
| 1442 | used as function return types. The specific limit on how large a return type |
| 1443 | the code generator can currently handle is target-dependent; currently it's |
| 1444 | 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] | 1445 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 1446 | </div> |
Reid Spencer | 2b91631 | 2007-05-16 18:44:01 +0000 | [diff] [blame] | 1447 | |
| 1448 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1449 | <div class="doc_subsubsection"> <a name="t_array">Array Type</a> </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1450 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1451 | <div class="doc_text"> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1452 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1453 | <h5>Overview:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1454 | <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] | 1455 | sequentially in memory. The array type requires a size (number of elements) |
| 1456 | and an underlying data type.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1457 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1458 | <h5>Syntax:</h5> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1459 | <pre> |
| 1460 | [<# elements> x <elementtype>] |
| 1461 | </pre> |
| 1462 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1463 | <p>The number of elements is a constant integer value; <tt>elementtype</tt> may |
| 1464 | be any type with a size.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1465 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1466 | <h5>Examples:</h5> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1467 | <table class="layout"> |
| 1468 | <tr class="layout"> |
Chris Lattner | 23ff1f9 | 2007-12-19 05:04:11 +0000 | [diff] [blame] | 1469 | <td class="left"><tt>[40 x i32]</tt></td> |
| 1470 | <td class="left">Array of 40 32-bit integer values.</td> |
| 1471 | </tr> |
| 1472 | <tr class="layout"> |
| 1473 | <td class="left"><tt>[41 x i32]</tt></td> |
| 1474 | <td class="left">Array of 41 32-bit integer values.</td> |
| 1475 | </tr> |
| 1476 | <tr class="layout"> |
| 1477 | <td class="left"><tt>[4 x i8]</tt></td> |
| 1478 | <td class="left">Array of 4 8-bit integer values.</td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1479 | </tr> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1480 | </table> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1481 | <p>Here are some examples of multidimensional arrays:</p> |
| 1482 | <table class="layout"> |
| 1483 | <tr class="layout"> |
Chris Lattner | 23ff1f9 | 2007-12-19 05:04:11 +0000 | [diff] [blame] | 1484 | <td class="left"><tt>[3 x [4 x i32]]</tt></td> |
| 1485 | <td class="left">3x4 array of 32-bit integer values.</td> |
| 1486 | </tr> |
| 1487 | <tr class="layout"> |
| 1488 | <td class="left"><tt>[12 x [10 x float]]</tt></td> |
| 1489 | <td class="left">12x10 array of single precision floating point values.</td> |
| 1490 | </tr> |
| 1491 | <tr class="layout"> |
| 1492 | <td class="left"><tt>[2 x [3 x [4 x i16]]]</tt></td> |
| 1493 | <td class="left">2x3x4 array of 16-bit integer values.</td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1494 | </tr> |
| 1495 | </table> |
Chris Lattner | e67a951 | 2005-06-24 17:22:57 +0000 | [diff] [blame] | 1496 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1497 | <p>Note that 'variable sized arrays' can be implemented in LLVM with a zero |
| 1498 | length array. Normally, accesses past the end of an array are undefined in |
| 1499 | LLVM (e.g. it is illegal to access the 5th element of a 3 element array). As |
| 1500 | a special case, however, zero length arrays are recognized to be variable |
| 1501 | length. This allows implementation of 'pascal style arrays' with the LLVM |
| 1502 | type "<tt>{ i32, [0 x float]}</tt>", for example.</p> |
Chris Lattner | e67a951 | 2005-06-24 17:22:57 +0000 | [diff] [blame] | 1503 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1504 | <p>Note that the code generator does not yet support large aggregate types to be |
| 1505 | used as function return types. The specific limit on how large an aggregate |
| 1506 | return type the code generator can currently handle is target-dependent, and |
| 1507 | also dependent on the aggregate element types.</p> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1508 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1509 | </div> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1510 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1511 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1512 | <div class="doc_subsubsection"> <a name="t_function">Function Type</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1513 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1514 | <div class="doc_text"> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 1515 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1516 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1517 | <p>The function type can be thought of as a function signature. It consists of |
| 1518 | a return type and a list of formal parameter types. The return type of a |
| 1519 | function type is a scalar type, a void type, or a struct type. If the return |
| 1520 | type is a struct type then all struct elements must be of first class types, |
| 1521 | and the struct must have at least one element.</p> |
Devang Patel | c3fc6df | 2008-03-10 20:49:15 +0000 | [diff] [blame] | 1522 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1523 | <h5>Syntax:</h5> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 1524 | <pre> |
| 1525 | <returntype list> (<parameter list>) |
| 1526 | </pre> |
| 1527 | |
John Criswell | 0ec250c | 2005-10-24 16:17:18 +0000 | [diff] [blame] | 1528 | <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] | 1529 | specifiers. Optionally, the parameter list may include a type <tt>...</tt>, |
| 1530 | which indicates that the function takes a variable number of arguments. |
| 1531 | Variable argument functions can access their arguments with |
| 1532 | the <a href="#int_varargs">variable argument handling intrinsic</a> |
| 1533 | functions. '<tt><returntype list></tt>' is a comma-separated list of |
| 1534 | <a href="#t_firstclass">first class</a> type specifiers.</p> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 1535 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1536 | <h5>Examples:</h5> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1537 | <table class="layout"> |
| 1538 | <tr class="layout"> |
Reid Spencer | 92f8230 | 2006-12-31 07:18:34 +0000 | [diff] [blame] | 1539 | <td class="left"><tt>i32 (i32)</tt></td> |
| 1540 | <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] | 1541 | </td> |
Reid Spencer | 92f8230 | 2006-12-31 07:18:34 +0000 | [diff] [blame] | 1542 | </tr><tr class="layout"> |
Reid Spencer | 9445e9a | 2007-07-19 23:13:04 +0000 | [diff] [blame] | 1543 | <td class="left"><tt>float (i16 signext, i32 *) * |
Reid Spencer | f17a0b7 | 2006-12-31 07:20:23 +0000 | [diff] [blame] | 1544 | </tt></td> |
Reid Spencer | 92f8230 | 2006-12-31 07:18:34 +0000 | [diff] [blame] | 1545 | <td class="left"><a href="#t_pointer">Pointer</a> to a function that takes |
| 1546 | an <tt>i16</tt> that should be sign extended and a |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 1547 | <a href="#t_pointer">pointer</a> to <tt>i32</tt>, returning |
Reid Spencer | 92f8230 | 2006-12-31 07:18:34 +0000 | [diff] [blame] | 1548 | <tt>float</tt>. |
| 1549 | </td> |
| 1550 | </tr><tr class="layout"> |
| 1551 | <td class="left"><tt>i32 (i8*, ...)</tt></td> |
| 1552 | <td class="left">A vararg function that takes at least one |
Reid Spencer | a517338 | 2007-01-04 16:43:23 +0000 | [diff] [blame] | 1553 | <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] | 1554 | which returns an integer. This is the signature for <tt>printf</tt> in |
| 1555 | LLVM. |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1556 | </td> |
Devang Patel | a582f40 | 2008-03-24 05:35:41 +0000 | [diff] [blame] | 1557 | </tr><tr class="layout"> |
| 1558 | <td class="left"><tt>{i32, i32} (i32)</tt></td> |
Misha Brukman | b0a57aa | 2008-11-27 06:41:20 +0000 | [diff] [blame] | 1559 | <td class="left">A function taking an <tt>i32</tt>, returning two |
| 1560 | <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] | 1561 | </td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1562 | </tr> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1563 | </table> |
Misha Brukman | daa4cb0 | 2004-03-01 17:47:27 +0000 | [diff] [blame] | 1564 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1565 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1566 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1567 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1568 | <div class="doc_subsubsection"> <a name="t_struct">Structure Type</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1569 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1570 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1571 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1572 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1573 | <p>The structure type is used to represent a collection of data members together |
| 1574 | in memory. The packing of the field types is defined to match the ABI of the |
| 1575 | underlying processor. The elements of a structure may be any type that has a |
| 1576 | size.</p> |
| 1577 | |
| 1578 | <p>Structures are accessed using '<tt><a href="#i_load">load</a></tt> and |
| 1579 | '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a field with |
| 1580 | the '<tt><a href="#i_getelementptr">getelementptr</a></tt>' instruction.</p> |
| 1581 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1582 | <h5>Syntax:</h5> |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 1583 | <pre> |
| 1584 | { <type list> } |
| 1585 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1586 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1587 | <h5>Examples:</h5> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1588 | <table class="layout"> |
| 1589 | <tr class="layout"> |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 1590 | <td class="left"><tt>{ i32, i32, i32 }</tt></td> |
| 1591 | <td class="left">A triple of three <tt>i32</tt> values</td> |
| 1592 | </tr><tr class="layout"> |
| 1593 | <td class="left"><tt>{ float, i32 (i32) * }</tt></td> |
| 1594 | <td class="left">A pair, where the first element is a <tt>float</tt> and the |
| 1595 | second element is a <a href="#t_pointer">pointer</a> to a |
| 1596 | <a href="#t_function">function</a> that takes an <tt>i32</tt>, returning |
| 1597 | an <tt>i32</tt>.</td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1598 | </tr> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1599 | </table> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1600 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1601 | <p>Note that the code generator does not yet support large aggregate types to be |
| 1602 | used as function return types. The specific limit on how large an aggregate |
| 1603 | return type the code generator can currently handle is target-dependent, and |
| 1604 | also dependent on the aggregate element types.</p> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1605 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1606 | </div> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1607 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1608 | <!-- _______________________________________________________________________ --> |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1609 | <div class="doc_subsubsection"> <a name="t_pstruct">Packed Structure Type</a> |
| 1610 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1611 | |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1612 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1613 | |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1614 | <h5>Overview:</h5> |
| 1615 | <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] | 1616 | together in memory. There is no padding between fields. Further, the |
| 1617 | alignment of a packed structure is 1 byte. The elements of a packed |
| 1618 | structure may be any type that has a size.</p> |
| 1619 | |
| 1620 | <p>Structures are accessed using '<tt><a href="#i_load">load</a></tt> and |
| 1621 | '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a field with |
| 1622 | the '<tt><a href="#i_getelementptr">getelementptr</a></tt>' instruction.</p> |
| 1623 | |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1624 | <h5>Syntax:</h5> |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 1625 | <pre> |
| 1626 | < { <type list> } > |
| 1627 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1628 | |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1629 | <h5>Examples:</h5> |
| 1630 | <table class="layout"> |
| 1631 | <tr class="layout"> |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 1632 | <td class="left"><tt>< { i32, i32, i32 } ></tt></td> |
| 1633 | <td class="left">A triple of three <tt>i32</tt> values</td> |
| 1634 | </tr><tr class="layout"> |
Bill Wendling | e36dccc | 2008-09-07 10:26:33 +0000 | [diff] [blame] | 1635 | <td class="left"> |
| 1636 | <tt>< { float, i32 (i32)* } ></tt></td> |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 1637 | <td class="left">A pair, where the first element is a <tt>float</tt> and the |
| 1638 | second element is a <a href="#t_pointer">pointer</a> to a |
| 1639 | <a href="#t_function">function</a> that takes an <tt>i32</tt>, returning |
| 1640 | an <tt>i32</tt>.</td> |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1641 | </tr> |
| 1642 | </table> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1643 | |
Andrew Lenharth | 75e1068 | 2006-12-08 17:13:00 +0000 | [diff] [blame] | 1644 | </div> |
| 1645 | |
| 1646 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 1647 | <div class="doc_subsubsection"> <a name="t_pointer">Pointer Type</a> </div> |
Chris Lattner | 0fd4a27 | 2009-02-08 19:53:29 +0000 | [diff] [blame] | 1648 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1649 | <div class="doc_text"> |
| 1650 | |
| 1651 | <h5>Overview:</h5> |
| 1652 | <p>As in many languages, the pointer type represents a pointer or reference to |
| 1653 | another object, which must live in memory. Pointer types may have an optional |
| 1654 | address space attribute defining the target-specific numbered address space |
| 1655 | where the pointed-to object resides. The default address space is zero.</p> |
| 1656 | |
| 1657 | <p>Note that LLVM does not permit pointers to void (<tt>void*</tt>) nor does it |
| 1658 | 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] | 1659 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1660 | <h5>Syntax:</h5> |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 1661 | <pre> |
| 1662 | <type> * |
| 1663 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1664 | |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 1665 | <h5>Examples:</h5> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1666 | <table class="layout"> |
| 1667 | <tr class="layout"> |
Dan Gohman | 2a08c53 | 2009-01-04 23:44:43 +0000 | [diff] [blame] | 1668 | <td class="left"><tt>[4 x i32]*</tt></td> |
Chris Lattner | 23ff1f9 | 2007-12-19 05:04:11 +0000 | [diff] [blame] | 1669 | <td class="left">A <a href="#t_pointer">pointer</a> to <a |
| 1670 | href="#t_array">array</a> of four <tt>i32</tt> values.</td> |
| 1671 | </tr> |
| 1672 | <tr class="layout"> |
| 1673 | <td class="left"><tt>i32 (i32 *) *</tt></td> |
| 1674 | <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] | 1675 | 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] | 1676 | <tt>i32</tt>.</td> |
| 1677 | </tr> |
| 1678 | <tr class="layout"> |
| 1679 | <td class="left"><tt>i32 addrspace(5)*</tt></td> |
| 1680 | <td class="left">A <a href="#t_pointer">pointer</a> to an <tt>i32</tt> value |
| 1681 | that resides in address space #5.</td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1682 | </tr> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1683 | </table> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1684 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1685 | </div> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1686 | |
Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1687 | <!-- _______________________________________________________________________ --> |
Reid Spencer | 485bad1 | 2007-02-15 03:07:05 +0000 | [diff] [blame] | 1688 | <div class="doc_subsubsection"> <a name="t_vector">Vector Type</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1689 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1690 | <div class="doc_text"> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1691 | |
Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1692 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1693 | <p>A vector type is a simple derived type that represents a vector of elements. |
| 1694 | Vector types are used when multiple primitive data are operated in parallel |
| 1695 | using a single instruction (SIMD). A vector type requires a size (number of |
| 1696 | elements) and an underlying primitive data type. Vectors must have a power |
| 1697 | of two length (1, 2, 4, 8, 16 ...). Vector types are considered |
| 1698 | <a href="#t_firstclass">first class</a>.</p> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1699 | |
Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1700 | <h5>Syntax:</h5> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1701 | <pre> |
| 1702 | < <# elements> x <elementtype> > |
| 1703 | </pre> |
| 1704 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1705 | <p>The number of elements is a constant integer value; elementtype may be any |
| 1706 | integer or floating point type.</p> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1707 | |
Chris Lattner | a58561b | 2004-08-12 19:12:28 +0000 | [diff] [blame] | 1708 | <h5>Examples:</h5> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1709 | <table class="layout"> |
| 1710 | <tr class="layout"> |
Chris Lattner | 23ff1f9 | 2007-12-19 05:04:11 +0000 | [diff] [blame] | 1711 | <td class="left"><tt><4 x i32></tt></td> |
| 1712 | <td class="left">Vector of 4 32-bit integer values.</td> |
| 1713 | </tr> |
| 1714 | <tr class="layout"> |
| 1715 | <td class="left"><tt><8 x float></tt></td> |
| 1716 | <td class="left">Vector of 8 32-bit floating-point values.</td> |
| 1717 | </tr> |
| 1718 | <tr class="layout"> |
| 1719 | <td class="left"><tt><2 x i64></tt></td> |
| 1720 | <td class="left">Vector of 2 64-bit integer values.</td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 1721 | </tr> |
| 1722 | </table> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1723 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1724 | <p>Note that the code generator does not yet support large vector types to be |
| 1725 | used as function return types. The specific limit on how large a vector |
| 1726 | return type codegen can currently handle is target-dependent; currently it's |
| 1727 | often a few times longer than a hardware vector register.</p> |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 1728 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 1729 | </div> |
| 1730 | |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1731 | <!-- _______________________________________________________________________ --> |
| 1732 | <div class="doc_subsubsection"> <a name="t_opaque">Opaque Type</a> </div> |
| 1733 | <div class="doc_text"> |
| 1734 | |
| 1735 | <h5>Overview:</h5> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1736 | <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] | 1737 | corresponds (for example) to the C notion of a forward declared structure |
| 1738 | type. In LLVM, opaque types can eventually be resolved to any type (not just |
| 1739 | a structure type).</p> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1740 | |
| 1741 | <h5>Syntax:</h5> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1742 | <pre> |
| 1743 | opaque |
| 1744 | </pre> |
| 1745 | |
| 1746 | <h5>Examples:</h5> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1747 | <table class="layout"> |
| 1748 | <tr class="layout"> |
Chris Lattner | 23ff1f9 | 2007-12-19 05:04:11 +0000 | [diff] [blame] | 1749 | <td class="left"><tt>opaque</tt></td> |
| 1750 | <td class="left">An opaque type.</td> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1751 | </tr> |
| 1752 | </table> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1753 | |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1754 | </div> |
| 1755 | |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1756 | <!-- ======================================================================= --> |
| 1757 | <div class="doc_subsection"> |
| 1758 | <a name="t_uprefs">Type Up-references</a> |
| 1759 | </div> |
| 1760 | |
| 1761 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1762 | |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1763 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1764 | <p>An "up reference" allows you to refer to a lexically enclosing type without |
| 1765 | requiring it to have a name. For instance, a structure declaration may |
| 1766 | contain a pointer to any of the types it is lexically a member of. Example |
| 1767 | of up references (with their equivalent as named type declarations) |
| 1768 | include:</p> |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1769 | |
| 1770 | <pre> |
Chris Lattner | 3060f5b | 2009-02-09 10:00:56 +0000 | [diff] [blame] | 1771 | { \2 * } %x = type { %x* } |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1772 | { \2 }* %y = type { %y }* |
| 1773 | \1* %z = type %z* |
| 1774 | </pre> |
| 1775 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1776 | <p>An up reference is needed by the asmprinter for printing out cyclic types |
| 1777 | when there is no declared name for a type in the cycle. Because the |
| 1778 | asmprinter does not want to print out an infinite type string, it needs a |
| 1779 | syntax to handle recursive types that have no names (all names are optional |
| 1780 | in llvm IR).</p> |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1781 | |
| 1782 | <h5>Syntax:</h5> |
| 1783 | <pre> |
| 1784 | \<level> |
| 1785 | </pre> |
| 1786 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1787 | <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] | 1788 | |
| 1789 | <h5>Examples:</h5> |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1790 | <table class="layout"> |
| 1791 | <tr class="layout"> |
| 1792 | <td class="left"><tt>\1*</tt></td> |
| 1793 | <td class="left">Self-referential pointer.</td> |
| 1794 | </tr> |
| 1795 | <tr class="layout"> |
| 1796 | <td class="left"><tt>{ { \3*, i8 }, i32 }</tt></td> |
| 1797 | <td class="left">Recursive structure where the upref refers to the out-most |
| 1798 | structure.</td> |
| 1799 | </tr> |
| 1800 | </table> |
Chris Lattner | 242d61d | 2009-02-02 07:32:36 +0000 | [diff] [blame] | 1801 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1802 | </div> |
Chris Lattner | 69c11bb | 2005-04-25 17:34:15 +0000 | [diff] [blame] | 1803 | |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1804 | <!-- *********************************************************************** --> |
| 1805 | <div class="doc_section"> <a name="constants">Constants</a> </div> |
| 1806 | <!-- *********************************************************************** --> |
| 1807 | |
| 1808 | <div class="doc_text"> |
| 1809 | |
| 1810 | <p>LLVM has several different basic types of constants. This section describes |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1811 | them all and their syntax.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1812 | |
| 1813 | </div> |
| 1814 | |
| 1815 | <!-- ======================================================================= --> |
Reid Spencer | cc16dc3 | 2004-12-09 18:02:53 +0000 | [diff] [blame] | 1816 | <div class="doc_subsection"><a name="simpleconstants">Simple Constants</a></div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1817 | |
| 1818 | <div class="doc_text"> |
| 1819 | |
| 1820 | <dl> |
| 1821 | <dt><b>Boolean constants</b></dt> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1822 | <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] | 1823 | 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] | 1824 | |
| 1825 | <dt><b>Integer constants</b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1826 | <dd>Standard integers (such as '4') are constants of |
| 1827 | the <a href="#t_integer">integer</a> type. Negative numbers may be used |
| 1828 | with integer types.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1829 | |
| 1830 | <dt><b>Floating point constants</b></dt> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1831 | <dd>Floating point constants use standard decimal notation (e.g. 123.421), |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1832 | exponential notation (e.g. 1.23421e+2), or a more precise hexadecimal |
| 1833 | notation (see below). The assembler requires the exact decimal value of a |
| 1834 | floating-point constant. For example, the assembler accepts 1.25 but |
| 1835 | rejects 1.3 because 1.3 is a repeating decimal in binary. Floating point |
| 1836 | 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] | 1837 | |
| 1838 | <dt><b>Null pointer constants</b></dt> |
John Criswell | 9e2485c | 2004-12-10 15:51:16 +0000 | [diff] [blame] | 1839 | <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] | 1840 | and must be of <a href="#t_pointer">pointer type</a>.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1841 | </dl> |
| 1842 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1843 | <p>The one non-intuitive notation for constants is the hexadecimal form of |
| 1844 | floating point constants. For example, the form '<tt>double |
| 1845 | 0x432ff973cafa8000</tt>' is equivalent to (but harder to read than) |
| 1846 | '<tt>double 4.5e+15</tt>'. The only time hexadecimal floating point |
| 1847 | constants are required (and the only time that they are generated by the |
| 1848 | disassembler) is when a floating point constant must be emitted but it cannot |
| 1849 | be represented as a decimal floating point number in a reasonable number of |
| 1850 | digits. For example, NaN's, infinities, and other special values are |
| 1851 | represented in their IEEE hexadecimal format so that assembly and disassembly |
| 1852 | do not cause any bits to change in the constants.</p> |
| 1853 | |
Dale Johannesen | bd5e5a8 | 2009-02-11 22:14:51 +0000 | [diff] [blame] | 1854 | <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] | 1855 | represented using the 16-digit form shown above (which matches the IEEE754 |
| 1856 | representation for double); float values must, however, be exactly |
| 1857 | representable as IEE754 single precision. Hexadecimal format is always used |
| 1858 | for long double, and there are three forms of long double. The 80-bit format |
| 1859 | used by x86 is represented as <tt>0xK</tt> followed by 20 hexadecimal digits. |
| 1860 | The 128-bit format used by PowerPC (two adjacent doubles) is represented |
| 1861 | by <tt>0xM</tt> followed by 32 hexadecimal digits. The IEEE 128-bit format |
| 1862 | is represented by <tt>0xL</tt> followed by 32 hexadecimal digits; no |
| 1863 | currently supported target uses this format. Long doubles will only work if |
| 1864 | they match the long double format on your target. All hexadecimal formats |
| 1865 | are big-endian (sign bit at the left).</p> |
| 1866 | |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1867 | </div> |
| 1868 | |
| 1869 | <!-- ======================================================================= --> |
Chris Lattner | 7088279 | 2009-02-28 18:32:25 +0000 | [diff] [blame] | 1870 | <div class="doc_subsection"> |
Bill Wendling | d9fe298 | 2009-07-20 02:32:41 +0000 | [diff] [blame] | 1871 | <a name="aggregateconstants"></a> <!-- old anchor --> |
| 1872 | <a name="complexconstants">Complex Constants</a> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1873 | </div> |
| 1874 | |
| 1875 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1876 | |
Chris Lattner | 7088279 | 2009-02-28 18:32:25 +0000 | [diff] [blame] | 1877 | <p>Complex constants are a (potentially recursive) combination of simple |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1878 | constants and smaller complex constants.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1879 | |
| 1880 | <dl> |
| 1881 | <dt><b>Structure constants</b></dt> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1882 | <dd>Structure constants are represented with notation similar to structure |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1883 | type definitions (a comma separated list of elements, surrounded by braces |
| 1884 | (<tt>{}</tt>)). For example: "<tt>{ i32 4, float 17.0, i32* @G }</tt>", |
| 1885 | where "<tt>@G</tt>" is declared as "<tt>@G = external global i32</tt>". |
| 1886 | Structure constants must have <a href="#t_struct">structure type</a>, and |
| 1887 | the number and types of elements must match those specified by the |
| 1888 | type.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1889 | |
| 1890 | <dt><b>Array constants</b></dt> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1891 | <dd>Array constants are represented with notation similar to array type |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1892 | definitions (a comma separated list of elements, surrounded by square |
| 1893 | brackets (<tt>[]</tt>)). For example: "<tt>[ i32 42, i32 11, i32 74 |
| 1894 | ]</tt>". Array constants must have <a href="#t_array">array type</a>, and |
| 1895 | the number and types of elements must match those specified by the |
| 1896 | type.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1897 | |
Reid Spencer | 485bad1 | 2007-02-15 03:07:05 +0000 | [diff] [blame] | 1898 | <dt><b>Vector constants</b></dt> |
Reid Spencer | 485bad1 | 2007-02-15 03:07:05 +0000 | [diff] [blame] | 1899 | <dd>Vector constants are represented with notation similar to vector type |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1900 | definitions (a comma separated list of elements, surrounded by |
| 1901 | less-than/greater-than's (<tt><></tt>)). For example: "<tt>< i32 |
| 1902 | 42, i32 11, i32 74, i32 100 ></tt>". Vector constants must |
| 1903 | have <a href="#t_vector">vector type</a>, and the number and types of |
| 1904 | elements must match those specified by the type.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1905 | |
| 1906 | <dt><b>Zero initialization</b></dt> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1907 | <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] | 1908 | value to zero of <em>any</em> type, including scalar and aggregate types. |
| 1909 | This is often used to avoid having to print large zero initializers |
| 1910 | (e.g. for large arrays) and is always exactly equivalent to using explicit |
| 1911 | zero initializers.</dd> |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 1912 | |
| 1913 | <dt><b>Metadata node</b></dt> |
Nick Lewycky | 1e8c7a6 | 2009-05-30 16:08:30 +0000 | [diff] [blame] | 1914 | <dd>A metadata node is a structure-like constant with |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1915 | <a href="#t_metadata">metadata type</a>. For example: "<tt>metadata !{ |
| 1916 | i32 0, metadata !"test" }</tt>". Unlike other constants that are meant to |
| 1917 | be interpreted as part of the instruction stream, metadata is a place to |
| 1918 | attach additional information such as debug info.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1919 | </dl> |
| 1920 | |
| 1921 | </div> |
| 1922 | |
| 1923 | <!-- ======================================================================= --> |
| 1924 | <div class="doc_subsection"> |
| 1925 | <a name="globalconstants">Global Variable and Function Addresses</a> |
| 1926 | </div> |
| 1927 | |
| 1928 | <div class="doc_text"> |
| 1929 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1930 | <p>The addresses of <a href="#globalvars">global variables</a> |
| 1931 | and <a href="#functionstructure">functions</a> are always implicitly valid |
| 1932 | (link-time) constants. These constants are explicitly referenced when |
| 1933 | the <a href="#identifiers">identifier for the global</a> is used and always |
| 1934 | have <a href="#t_pointer">pointer</a> type. For example, the following is a |
| 1935 | legal LLVM file:</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1936 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 1937 | <div class="doc_code"> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1938 | <pre> |
Chris Lattner | a18a424 | 2007-06-06 18:28:13 +0000 | [diff] [blame] | 1939 | @X = global i32 17 |
| 1940 | @Y = global i32 42 |
| 1941 | @Z = global [2 x i32*] [ i32* @X, i32* @Y ] |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1942 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 1943 | </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1944 | |
| 1945 | </div> |
| 1946 | |
| 1947 | <!-- ======================================================================= --> |
Reid Spencer | 2dc45b8 | 2004-12-09 18:13:12 +0000 | [diff] [blame] | 1948 | <div class="doc_subsection"><a name="undefvalues">Undefined Values</a></div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1949 | <div class="doc_text"> |
| 1950 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1951 | <p>The string '<tt>undef</tt>' is recognized as a type-less constant that has no |
| 1952 | specific value. Undefined values may be of any type and be used anywhere a |
| 1953 | constant is permitted.</p> |
| 1954 | |
| 1955 | <p>Undefined values indicate to the compiler that the program is well defined no |
| 1956 | matter what value is used, giving the compiler more freedom to optimize.</p> |
| 1957 | |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1958 | </div> |
| 1959 | |
| 1960 | <!-- ======================================================================= --> |
| 1961 | <div class="doc_subsection"><a name="constantexprs">Constant Expressions</a> |
| 1962 | </div> |
| 1963 | |
| 1964 | <div class="doc_text"> |
| 1965 | |
| 1966 | <p>Constant expressions are used to allow expressions involving other constants |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1967 | to be used as constants. Constant expressions may be of |
| 1968 | any <a href="#t_firstclass">first class</a> type and may involve any LLVM |
| 1969 | operation that does not have side effects (e.g. load and call are not |
| 1970 | supported). The following is the syntax for constant expressions:</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1971 | |
| 1972 | <dl> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 1973 | <dt><b><tt>trunc ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1974 | <dd>Truncate a constant to another type. The bit size of CST must be larger |
| 1975 | than the bit size of TYPE. Both types must be integers.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 1976 | |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 1977 | <dt><b><tt>zext ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1978 | <dd>Zero extend a constant to another type. The bit size of CST must be |
| 1979 | smaller or equal to the bit size of TYPE. Both types must be |
| 1980 | integers.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 1981 | |
| 1982 | <dt><b><tt>sext ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1983 | <dd>Sign extend a constant to another type. The bit size of CST must be |
| 1984 | smaller or equal to the bit size of TYPE. Both types must be |
| 1985 | integers.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 1986 | |
| 1987 | <dt><b><tt>fptrunc ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1988 | <dd>Truncate a floating point constant to another floating point type. The |
| 1989 | size of CST must be larger than the size of TYPE. Both types must be |
| 1990 | floating point.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 1991 | |
| 1992 | <dt><b><tt>fpext ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1993 | <dd>Floating point extend a constant to another type. The size of CST must be |
| 1994 | smaller or equal to the size of TYPE. Both types must be floating |
| 1995 | point.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 1996 | |
Reid Spencer | 1539a1c | 2007-07-31 14:40:14 +0000 | [diff] [blame] | 1997 | <dt><b><tt>fptoui ( CST to TYPE )</tt></b></dt> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 1998 | <dd>Convert a floating point constant to the corresponding unsigned integer |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 1999 | constant. TYPE must be a scalar or vector integer type. CST must be of |
| 2000 | scalar or vector floating point type. Both CST and TYPE must be scalars, |
| 2001 | or vectors of the same number of elements. If the value won't fit in the |
| 2002 | integer type, the results are undefined.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2003 | |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 2004 | <dt><b><tt>fptosi ( CST to TYPE )</tt></b></dt> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2005 | <dd>Convert a floating point constant to the corresponding signed integer |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2006 | constant. TYPE must be a scalar or vector integer type. CST must be of |
| 2007 | scalar or vector floating point type. Both CST and TYPE must be scalars, |
| 2008 | or vectors of the same number of elements. If the value won't fit in the |
| 2009 | integer type, the results are undefined.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2010 | |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 2011 | <dt><b><tt>uitofp ( CST to TYPE )</tt></b></dt> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2012 | <dd>Convert an unsigned integer constant to the corresponding floating point |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2013 | constant. TYPE must be a scalar or vector floating point type. CST must be |
| 2014 | of scalar or vector integer type. Both CST and TYPE must be scalars, or |
| 2015 | vectors of the same number of elements. If the value won't fit in the |
| 2016 | floating point type, the results are undefined.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2017 | |
Reid Spencer | d444879 | 2006-11-09 23:03:26 +0000 | [diff] [blame] | 2018 | <dt><b><tt>sitofp ( CST to TYPE )</tt></b></dt> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2019 | <dd>Convert a signed integer constant to the corresponding floating point |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2020 | constant. TYPE must be a scalar or vector floating point type. CST must be |
| 2021 | of scalar or vector integer type. Both CST and TYPE must be scalars, or |
| 2022 | vectors of the same number of elements. If the value won't fit in the |
| 2023 | floating point type, the results are undefined.</dd> |
Reid Spencer | 9dee3ac | 2006-11-08 01:11:31 +0000 | [diff] [blame] | 2024 | |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 2025 | <dt><b><tt>ptrtoint ( CST to TYPE )</tt></b></dt> |
| 2026 | <dd>Convert a pointer typed constant to the corresponding integer constant |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2027 | <tt>TYPE</tt> must be an integer type. <tt>CST</tt> must be of pointer |
| 2028 | type. The <tt>CST</tt> value is zero extended, truncated, or unchanged to |
| 2029 | make it fit in <tt>TYPE</tt>.</dd> |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 2030 | |
| 2031 | <dt><b><tt>inttoptr ( CST to TYPE )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2032 | <dd>Convert a integer constant to a pointer constant. TYPE must be a pointer |
| 2033 | type. CST must be of integer type. The CST value is zero extended, |
| 2034 | truncated, or unchanged to make it fit in a pointer size. This one is |
| 2035 | <i>really</i> dangerous!</dd> |
Reid Spencer | 5c0ef47 | 2006-11-11 23:08:07 +0000 | [diff] [blame] | 2036 | |
| 2037 | <dt><b><tt>bitcast ( CST to TYPE )</tt></b></dt> |
Chris Lattner | 03bbad6 | 2009-02-28 18:27:03 +0000 | [diff] [blame] | 2038 | <dd>Convert a constant, CST, to another TYPE. The constraints of the operands |
| 2039 | are the same as those for the <a href="#i_bitcast">bitcast |
| 2040 | instruction</a>.</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2041 | |
| 2042 | <dt><b><tt>getelementptr ( CSTPTR, IDX0, IDX1, ... )</tt></b></dt> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2043 | <dd>Perform the <a href="#i_getelementptr">getelementptr operation</a> on |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2044 | constants. As with the <a href="#i_getelementptr">getelementptr</a> |
| 2045 | instruction, the index list may have zero or more indexes, which are |
| 2046 | required to make sense for the type of "CSTPTR".</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2047 | |
Robert Bocchino | 9fbe145 | 2006-01-10 19:31:34 +0000 | [diff] [blame] | 2048 | <dt><b><tt>select ( COND, VAL1, VAL2 )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2049 | <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] | 2050 | |
| 2051 | <dt><b><tt>icmp COND ( VAL1, VAL2 )</tt></b></dt> |
| 2052 | <dd>Performs the <a href="#i_icmp">icmp operation</a> on constants.</dd> |
| 2053 | |
| 2054 | <dt><b><tt>fcmp COND ( VAL1, VAL2 )</tt></b></dt> |
| 2055 | <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] | 2056 | |
| 2057 | <dt><b><tt>extractelement ( VAL, IDX )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2058 | <dd>Perform the <a href="#i_extractelement">extractelement operation</a> on |
| 2059 | constants.</dd> |
Robert Bocchino | 9fbe145 | 2006-01-10 19:31:34 +0000 | [diff] [blame] | 2060 | |
Robert Bocchino | 05ccd70 | 2006-01-15 20:48:27 +0000 | [diff] [blame] | 2061 | <dt><b><tt>insertelement ( VAL, ELT, IDX )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2062 | <dd>Perform the <a href="#i_insertelement">insertelement operation</a> on |
| 2063 | constants.</dd> |
Chris Lattner | c198954 | 2006-04-08 00:13:41 +0000 | [diff] [blame] | 2064 | |
| 2065 | <dt><b><tt>shufflevector ( VEC1, VEC2, IDXMASK )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2066 | <dd>Perform the <a href="#i_shufflevector">shufflevector operation</a> on |
| 2067 | constants.</dd> |
Chris Lattner | c198954 | 2006-04-08 00:13:41 +0000 | [diff] [blame] | 2068 | |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2069 | <dt><b><tt>OPCODE ( LHS, RHS )</tt></b></dt> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2070 | <dd>Perform the specified operation of the LHS and RHS constants. OPCODE may |
| 2071 | be any of the <a href="#binaryops">binary</a> |
| 2072 | or <a href="#bitwiseops">bitwise binary</a> operations. The constraints |
| 2073 | on operands are the same as those for the corresponding instruction |
| 2074 | (e.g. no bitwise operations on floating point values are allowed).</dd> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2075 | </dl> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2076 | |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2077 | </div> |
Chris Lattner | 9ee5d22 | 2004-03-08 16:49:10 +0000 | [diff] [blame] | 2078 | |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2079 | <!-- ======================================================================= --> |
| 2080 | <div class="doc_subsection"><a name="metadata">Embedded Metadata</a> |
| 2081 | </div> |
| 2082 | |
| 2083 | <div class="doc_text"> |
| 2084 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2085 | <p>Embedded metadata provides a way to attach arbitrary data to the instruction |
| 2086 | stream without affecting the behaviour of the program. There are two |
| 2087 | metadata primitives, strings and nodes. All metadata has the |
| 2088 | <tt>metadata</tt> type and is identified in syntax by a preceding exclamation |
| 2089 | point ('<tt>!</tt>').</p> |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2090 | |
| 2091 | <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] | 2092 | any character by escaping non-printable characters with "\xx" where "xx" is |
| 2093 | the two digit hex code. For example: "<tt>!"test\00"</tt>".</p> |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2094 | |
| 2095 | <p>Metadata nodes are represented with notation similar to structure constants |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2096 | (a comma separated list of elements, surrounded by braces and preceeded by an |
| 2097 | exclamation point). For example: "<tt>!{ metadata !"test\00", i32 |
| 2098 | 10}</tt>".</p> |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2099 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2100 | <p>A metadata node will attempt to track changes to the values it holds. In the |
| 2101 | event that a value is deleted, it will be replaced with a typeless |
| 2102 | "<tt>null</tt>", such as "<tt>metadata !{null, i32 10}</tt>".</p> |
Nick Lewycky | cb33799 | 2009-05-10 20:57:05 +0000 | [diff] [blame] | 2103 | |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2104 | <p>Optimizations may rely on metadata to provide additional information about |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2105 | the program that isn't available in the instructions, or that isn't easily |
| 2106 | computable. Similarly, the code generator may expect a certain metadata |
| 2107 | format to be used to express debugging information.</p> |
| 2108 | |
Nick Lewycky | 21cc446 | 2009-04-04 07:22:01 +0000 | [diff] [blame] | 2109 | </div> |
| 2110 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2111 | <!-- *********************************************************************** --> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2112 | <div class="doc_section"> <a name="othervalues">Other Values</a> </div> |
| 2113 | <!-- *********************************************************************** --> |
| 2114 | |
| 2115 | <!-- ======================================================================= --> |
| 2116 | <div class="doc_subsection"> |
| 2117 | <a name="inlineasm">Inline Assembler Expressions</a> |
| 2118 | </div> |
| 2119 | |
| 2120 | <div class="doc_text"> |
| 2121 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2122 | <p>LLVM supports inline assembler expressions (as opposed |
| 2123 | to <a href="#moduleasm"> Module-Level Inline Assembly</a>) through the use of |
| 2124 | a special value. This value represents the inline assembler as a string |
| 2125 | (containing the instructions to emit), a list of operand constraints (stored |
| 2126 | as a string), and a flag that indicates whether or not the inline asm |
| 2127 | expression has side effects. An example inline assembler expression is:</p> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2128 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2129 | <div class="doc_code"> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2130 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2131 | i32 (i32) asm "bswap $0", "=r,r" |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2132 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2133 | </div> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2134 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2135 | <p>Inline assembler expressions may <b>only</b> be used as the callee operand of |
| 2136 | a <a href="#i_call"><tt>call</tt> instruction</a>. Thus, typically we |
| 2137 | have:</p> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2138 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2139 | <div class="doc_code"> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2140 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2141 | %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] | 2142 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2143 | </div> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2144 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2145 | <p>Inline asms with side effects not visible in the constraint list must be |
| 2146 | marked as having side effects. This is done through the use of the |
| 2147 | '<tt>sideeffect</tt>' keyword, like so:</p> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2148 | |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2149 | <div class="doc_code"> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2150 | <pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2151 | call void asm sideeffect "eieio", ""() |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2152 | </pre> |
Bill Wendling | 2f7a8b0 | 2007-05-29 09:04:49 +0000 | [diff] [blame] | 2153 | </div> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2154 | |
| 2155 | <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] | 2156 | documented here. Constraints on what can be done (e.g. duplication, moving, |
| 2157 | etc need to be documented). This is probably best done by reference to |
| 2158 | another document that covers inline asm from a holistic perspective.</p> |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2159 | |
| 2160 | </div> |
| 2161 | |
Chris Lattner | 857755c | 2009-07-20 05:55:19 +0000 | [diff] [blame] | 2162 | |
| 2163 | <!-- *********************************************************************** --> |
| 2164 | <div class="doc_section"> |
| 2165 | <a name="intrinsic_globals">Intrinsic Global Variables</a> |
| 2166 | </div> |
| 2167 | <!-- *********************************************************************** --> |
| 2168 | |
| 2169 | <p>LLVM has a number of "magic" global variables that contain data that affect |
| 2170 | code generation or other IR semantics. These are documented here. All globals |
| 2171 | of this sort should have a section specified as "llvm.metadata". This section |
| 2172 | and all globals that start with "llvm." are reserved for LLVM.</p> |
| 2173 | |
| 2174 | <!-- ======================================================================= --> |
| 2175 | <div class="doc_subsection"> |
| 2176 | <a name="intg_used">The '<tt>llvm.used</tt>' Global Variable</a> |
| 2177 | </div> |
| 2178 | |
| 2179 | <div class="doc_text"> |
| 2180 | |
| 2181 | <p>The <tt>@llvm.used</tt> global is an array with i8* element type which has <a |
| 2182 | href="#linkage_appending">appending linkage</a>. This array contains a list of |
| 2183 | pointers to global variables and functions which may optionally have a pointer |
| 2184 | cast formed of bitcast or getelementptr. For example, a legal use of it is:</p> |
| 2185 | |
| 2186 | <pre> |
| 2187 | @X = global i8 4 |
| 2188 | @Y = global i32 123 |
| 2189 | |
| 2190 | @llvm.used = appending global [2 x i8*] [ |
| 2191 | i8* @X, |
| 2192 | i8* bitcast (i32* @Y to i8*) |
| 2193 | ], section "llvm.metadata" |
| 2194 | </pre> |
| 2195 | |
| 2196 | <p>If a global variable appears in the <tt>@llvm.used</tt> list, then the |
| 2197 | compiler, assembler, and linker are required to treat the symbol as if there is |
| 2198 | a reference to the global that it cannot see. For example, if a variable has |
| 2199 | internal linkage and no references other than that from the <tt>@llvm.used</tt> |
| 2200 | list, it cannot be deleted. This is commonly used to represent references from |
| 2201 | inline asms and other things the compiler cannot "see", and corresponds to |
| 2202 | "attribute((used))" in GNU C.</p> |
| 2203 | |
| 2204 | <p>On some targets, the code generator must emit a directive to the assembler or |
| 2205 | object file to prevent the assembler and linker from molesting the symbol.</p> |
| 2206 | |
| 2207 | </div> |
| 2208 | |
| 2209 | <!-- ======================================================================= --> |
| 2210 | <div class="doc_subsection"> |
| 2211 | <a name="intg_global_ctors">The '<tt>llvm.global_ctors</tt>' Global Variable</a> |
| 2212 | </div> |
| 2213 | |
| 2214 | <div class="doc_text"> |
| 2215 | |
| 2216 | <p>TODO: Describe this.</p> |
| 2217 | |
| 2218 | </div> |
| 2219 | |
| 2220 | <!-- ======================================================================= --> |
| 2221 | <div class="doc_subsection"> |
| 2222 | <a name="intg_global_dtors">The '<tt>llvm.global_dtors</tt>' Global Variable</a> |
| 2223 | </div> |
| 2224 | |
| 2225 | <div class="doc_text"> |
| 2226 | |
| 2227 | <p>TODO: Describe this.</p> |
| 2228 | |
| 2229 | </div> |
| 2230 | |
| 2231 | |
Chris Lattner | e87d653 | 2006-01-25 23:47:57 +0000 | [diff] [blame] | 2232 | <!-- *********************************************************************** --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2233 | <div class="doc_section"> <a name="instref">Instruction Reference</a> </div> |
| 2234 | <!-- *********************************************************************** --> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2235 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2236 | <div class="doc_text"> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2237 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2238 | <p>The LLVM instruction set consists of several different classifications of |
| 2239 | instructions: <a href="#terminators">terminator |
| 2240 | instructions</a>, <a href="#binaryops">binary instructions</a>, |
| 2241 | <a href="#bitwiseops">bitwise binary instructions</a>, |
| 2242 | <a href="#memoryops">memory instructions</a>, and |
| 2243 | <a href="#otherops">other instructions</a>.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2244 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2245 | </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2246 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2247 | <!-- ======================================================================= --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2248 | <div class="doc_subsection"> <a name="terminators">Terminator |
| 2249 | Instructions</a> </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2250 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2251 | <div class="doc_text"> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2252 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2253 | <p>As mentioned <a href="#functionstructure">previously</a>, every basic block |
| 2254 | in a program ends with a "Terminator" instruction, which indicates which |
| 2255 | block should be executed after the current block is finished. These |
| 2256 | terminator instructions typically yield a '<tt>void</tt>' value: they produce |
| 2257 | control flow, not values (the one exception being the |
| 2258 | '<a href="#i_invoke"><tt>invoke</tt></a>' instruction).</p> |
| 2259 | |
| 2260 | <p>There are six different terminator instructions: the |
| 2261 | '<a href="#i_ret"><tt>ret</tt></a>' instruction, the |
| 2262 | '<a href="#i_br"><tt>br</tt></a>' instruction, the |
| 2263 | '<a href="#i_switch"><tt>switch</tt></a>' instruction, the |
| 2264 | '<a href="#i_invoke"><tt>invoke</tt></a>' instruction, the |
| 2265 | '<a href="#i_unwind"><tt>unwind</tt></a>' instruction, and the |
| 2266 | '<a href="#i_unreachable"><tt>unreachable</tt></a>' instruction.</p> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2267 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2268 | </div> |
Chris Lattner | c3f5976 | 2004-12-09 17:30:23 +0000 | [diff] [blame] | 2269 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2270 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2271 | <div class="doc_subsubsection"> <a name="i_ret">'<tt>ret</tt>' |
| 2272 | Instruction</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2273 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2274 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2275 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2276 | <h5>Syntax:</h5> |
Dan Gohman | b1e6b96 | 2008-10-04 19:00:07 +0000 | [diff] [blame] | 2277 | <pre> |
| 2278 | 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] | 2279 | ret void <i>; Return from void function</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2280 | </pre> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2281 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2282 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2283 | <p>The '<tt>ret</tt>' instruction is used to return control flow (and optionally |
| 2284 | a value) from a function back to the caller.</p> |
| 2285 | |
| 2286 | <p>There are two forms of the '<tt>ret</tt>' instruction: one that returns a |
| 2287 | value and then causes control flow, and one that just causes control flow to |
| 2288 | occur.</p> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2289 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2290 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2291 | <p>The '<tt>ret</tt>' instruction optionally accepts a single argument, the |
| 2292 | return value. The type of the return value must be a |
| 2293 | '<a href="#t_firstclass">first class</a>' type.</p> |
Dan Gohman | b1e6b96 | 2008-10-04 19:00:07 +0000 | [diff] [blame] | 2294 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2295 | <p>A function is not <a href="#wellformed">well formed</a> if it it has a |
| 2296 | non-void return type and contains a '<tt>ret</tt>' instruction with no return |
| 2297 | value or a return value with a type that does not match its type, or if it |
| 2298 | has a void return type and contains a '<tt>ret</tt>' instruction with a |
| 2299 | return value.</p> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2300 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2301 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2302 | <p>When the '<tt>ret</tt>' instruction is executed, control flow returns back to |
| 2303 | the calling function's context. If the caller is a |
| 2304 | "<a href="#i_call"><tt>call</tt></a>" instruction, execution continues at the |
| 2305 | instruction after the call. If the caller was an |
| 2306 | "<a href="#i_invoke"><tt>invoke</tt></a>" instruction, execution continues at |
| 2307 | the beginning of the "normal" destination block. If the instruction returns |
| 2308 | a value, that value shall set the call or invoke instruction's return |
| 2309 | value.</p> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2310 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2311 | <h5>Example:</h5> |
Chris Lattner | f4cde4e | 2008-04-23 04:59:35 +0000 | [diff] [blame] | 2312 | <pre> |
| 2313 | ret i32 5 <i>; Return an integer value of 5</i> |
Chris Lattner | 7faa883 | 2002-04-14 06:13:44 +0000 | [diff] [blame] | 2314 | ret void <i>; Return from a void function</i> |
Bill Wendling | 0a4bbbf | 2009-02-28 22:12:54 +0000 | [diff] [blame] | 2315 | 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] | 2316 | </pre> |
Dan Gohman | f3e60bd | 2009-01-12 23:12:39 +0000 | [diff] [blame] | 2317 | |
Dan Gohman | d8791e5 | 2009-01-24 15:58:40 +0000 | [diff] [blame] | 2318 | <p>Note that the code generator does not yet fully support large |
| 2319 | return values. The specific sizes that are currently supported are |
| 2320 | dependent on the target. For integers, on 32-bit targets the limit |
| 2321 | is often 64 bits, and on 64-bit targets the limit is often 128 bits. |
| 2322 | For aggregate types, the current limits are dependent on the element |
| 2323 | types; for example targets are often limited to 2 total integer |
| 2324 | elements and 2 total floating-point elements.</p> |
Dan Gohman | f3e60bd | 2009-01-12 23:12:39 +0000 | [diff] [blame] | 2325 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2326 | </div> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2327 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2328 | <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] | 2329 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2330 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2331 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2332 | <h5>Syntax:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2333 | <pre> |
| 2334 | 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] | 2335 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2336 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2337 | <h5>Overview:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2338 | <p>The '<tt>br</tt>' instruction is used to cause control flow to transfer to a |
| 2339 | different basic block in the current function. There are two forms of this |
| 2340 | instruction, corresponding to a conditional branch and an unconditional |
| 2341 | branch.</p> |
| 2342 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2343 | <h5>Arguments:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2344 | <p>The conditional branch form of the '<tt>br</tt>' instruction takes a single |
| 2345 | '<tt>i1</tt>' value and two '<tt>label</tt>' values. The unconditional form |
| 2346 | of the '<tt>br</tt>' instruction takes a single '<tt>label</tt>' value as a |
| 2347 | target.</p> |
| 2348 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2349 | <h5>Semantics:</h5> |
Reid Spencer | c78f337 | 2007-01-12 03:35:51 +0000 | [diff] [blame] | 2350 | <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] | 2351 | argument is evaluated. If the value is <tt>true</tt>, control flows to the |
| 2352 | '<tt>iftrue</tt>' <tt>label</tt> argument. If "cond" is <tt>false</tt>, |
| 2353 | control flows to the '<tt>iffalse</tt>' <tt>label</tt> argument.</p> |
| 2354 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2355 | <h5>Example:</h5> |
Bill Wendling | c39e3e0 | 2009-07-20 02:39:26 +0000 | [diff] [blame] | 2356 | <pre> |
| 2357 | Test: |
| 2358 | %cond = <a href="#i_icmp">icmp</a> eq i32 %a, %b |
| 2359 | br i1 %cond, label %IfEqual, label %IfUnequal |
| 2360 | IfEqual: |
| 2361 | <a href="#i_ret">ret</a> i32 1 |
| 2362 | IfUnequal: |
| 2363 | <a href="#i_ret">ret</a> i32 0 |
| 2364 | </pre> |
| 2365 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2366 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2367 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2368 | <!-- _______________________________________________________________________ --> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2369 | <div class="doc_subsubsection"> |
| 2370 | <a name="i_switch">'<tt>switch</tt>' Instruction</a> |
| 2371 | </div> |
| 2372 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2373 | <div class="doc_text"> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2374 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2375 | <h5>Syntax:</h5> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2376 | <pre> |
| 2377 | switch <intty> <value>, label <defaultdest> [ <intty> <val>, label <dest> ... ] |
| 2378 | </pre> |
| 2379 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2380 | <h5>Overview:</h5> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2381 | <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] | 2382 | several different places. It is a generalization of the '<tt>br</tt>' |
| 2383 | instruction, allowing a branch to occur to one of many possible |
| 2384 | destinations.</p> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2385 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2386 | <h5>Arguments:</h5> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2387 | <p>The '<tt>switch</tt>' instruction uses three parameters: an integer |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2388 | comparison value '<tt>value</tt>', a default '<tt>label</tt>' destination, |
| 2389 | and an array of pairs of comparison value constants and '<tt>label</tt>'s. |
| 2390 | The table is not allowed to contain duplicate constant entries.</p> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2391 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2392 | <h5>Semantics:</h5> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2393 | <p>The <tt>switch</tt> instruction specifies a table of values and |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2394 | destinations. When the '<tt>switch</tt>' instruction is executed, this table |
| 2395 | is searched for the given value. If the value is found, control flow is |
| 2396 | transfered to the corresponding destination; otherwise, control flow is |
| 2397 | transfered to the default destination.</p> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2398 | |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2399 | <h5>Implementation:</h5> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2400 | <p>Depending on properties of the target machine and the particular |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2401 | <tt>switch</tt> instruction, this instruction may be code generated in |
| 2402 | different ways. For example, it could be generated as a series of chained |
| 2403 | conditional branches or with a lookup table.</p> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2404 | |
| 2405 | <h5>Example:</h5> |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2406 | <pre> |
| 2407 | <i>; Emulate a conditional br instruction</i> |
Reid Spencer | c78f337 | 2007-01-12 03:35:51 +0000 | [diff] [blame] | 2408 | %Val = <a href="#i_zext">zext</a> i1 %value to i32 |
Dan Gohman | 2a08c53 | 2009-01-04 23:44:43 +0000 | [diff] [blame] | 2409 | switch i32 %Val, label %truedest [ i32 0, label %falsedest ] |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2410 | |
| 2411 | <i>; Emulate an unconditional br instruction</i> |
Reid Spencer | ca86e16 | 2006-12-31 07:07:53 +0000 | [diff] [blame] | 2412 | switch i32 0, label %dest [ ] |
Chris Lattner | c88c17b | 2004-02-24 04:54:45 +0000 | [diff] [blame] | 2413 | |
| 2414 | <i>; Implement a jump table:</i> |
Dan Gohman | 2a08c53 | 2009-01-04 23:44:43 +0000 | [diff] [blame] | 2415 | switch i32 %val, label %otherwise [ i32 0, label %onzero |
| 2416 | i32 1, label %onone |
| 2417 | i32 2, label %ontwo ] |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2418 | </pre> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2419 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2420 | </div> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2421 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2422 | <!-- _______________________________________________________________________ --> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2423 | <div class="doc_subsubsection"> |
| 2424 | <a name="i_invoke">'<tt>invoke</tt>' Instruction</a> |
| 2425 | </div> |
| 2426 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2427 | <div class="doc_text"> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2428 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2429 | <h5>Syntax:</h5> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2430 | <pre> |
Devang Patel | 307e8ab | 2008-10-07 17:48:33 +0000 | [diff] [blame] | 2431 | <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] | 2432 | to label <normal label> unwind label <exception label> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2433 | </pre> |
| 2434 | |
Chris Lattner | 6536cfe | 2002-05-06 22:08:29 +0000 | [diff] [blame] | 2435 | <h5>Overview:</h5> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2436 | <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] | 2437 | function, with the possibility of control flow transfer to either the |
| 2438 | '<tt>normal</tt>' label or the '<tt>exception</tt>' label. If the callee |
| 2439 | function returns with the "<tt><a href="#i_ret">ret</a></tt>" instruction, |
| 2440 | control flow will return to the "normal" label. If the callee (or any |
| 2441 | indirect callees) returns with the "<a href="#i_unwind"><tt>unwind</tt></a>" |
| 2442 | instruction, control is interrupted and continued at the dynamically nearest |
| 2443 | "exception" label.</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2444 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2445 | <h5>Arguments:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2446 | <p>This instruction requires several arguments:</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2447 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2448 | <ol> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2449 | <li>The optional "cconv" marker indicates which <a href="#callingconv">calling |
| 2450 | convention</a> the call should use. If none is specified, the call |
| 2451 | defaults to using C calling conventions.</li> |
Devang Patel | f642f47 | 2008-10-06 18:50:38 +0000 | [diff] [blame] | 2452 | |
| 2453 | <li>The optional <a href="#paramattrs">Parameter Attributes</a> list for |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2454 | return values. Only '<tt>zeroext</tt>', '<tt>signext</tt>', and |
| 2455 | '<tt>inreg</tt>' attributes are valid here.</li> |
Devang Patel | f642f47 | 2008-10-06 18:50:38 +0000 | [diff] [blame] | 2456 | |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2457 | <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] | 2458 | function value being invoked. In most cases, this is a direct function |
| 2459 | invocation, but indirect <tt>invoke</tt>s are just as possible, branching |
| 2460 | off an arbitrary pointer to function value.</li> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2461 | |
| 2462 | <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] | 2463 | function to be invoked. </li> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2464 | |
| 2465 | <li>'<tt>function args</tt>': argument list whose types match the function |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2466 | signature argument types. If the function signature indicates the |
| 2467 | function accepts a variable number of arguments, the extra arguments can |
| 2468 | be specified.</li> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2469 | |
| 2470 | <li>'<tt>normal label</tt>': the label reached when the called function |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2471 | executes a '<tt><a href="#i_ret">ret</a></tt>' instruction. </li> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2472 | |
| 2473 | <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] | 2474 | the <a href="#i_unwind"><tt>unwind</tt></a> instruction. </li> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2475 | |
Devang Patel | 307e8ab | 2008-10-07 17:48:33 +0000 | [diff] [blame] | 2476 | <li>The optional <a href="#fnattrs">function attributes</a> list. Only |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2477 | '<tt>noreturn</tt>', '<tt>nounwind</tt>', '<tt>readonly</tt>' and |
| 2478 | '<tt>readnone</tt>' attributes are valid here.</li> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2479 | </ol> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2480 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2481 | <h5>Semantics:</h5> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2482 | <p>This instruction is designed to operate as a standard |
| 2483 | '<tt><a href="#i_call">call</a></tt>' instruction in most regards. The |
| 2484 | primary difference is that it establishes an association with a label, which |
| 2485 | is used by the runtime library to unwind the stack.</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2486 | |
| 2487 | <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] | 2488 | cleanup is performed in the case of either a <tt>longjmp</tt> or a thrown |
| 2489 | exception. Additionally, this is important for implementation of |
| 2490 | '<tt>catch</tt>' clauses in high-level languages that support them.</p> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2491 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2492 | <p>For the purposes of the SSA form, the definition of the value returned by the |
| 2493 | '<tt>invoke</tt>' instruction is deemed to occur on the edge from the current |
| 2494 | block to the "normal" label. If the callee unwinds then no return value is |
| 2495 | available.</p> |
Dan Gohman | f96a499 | 2009-05-22 21:47:08 +0000 | [diff] [blame] | 2496 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2497 | <h5>Example:</h5> |
Chris Lattner | bad10ee | 2005-05-06 22:57:40 +0000 | [diff] [blame] | 2498 | <pre> |
Nick Lewycky | d703f65 | 2008-03-16 07:18:12 +0000 | [diff] [blame] | 2499 | %retval = invoke i32 @Test(i32 15) to label %Continue |
Jeff Cohen | 6f1cc77 | 2007-04-22 01:17:39 +0000 | [diff] [blame] | 2500 | unwind label %TestCleanup <i>; {i32}:retval set</i> |
Nick Lewycky | d703f65 | 2008-03-16 07:18:12 +0000 | [diff] [blame] | 2501 | %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] | 2502 | unwind label %TestCleanup <i>; {i32}:retval set</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2503 | </pre> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2504 | |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2505 | </div> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2506 | |
Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 2507 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2508 | |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2509 | <div class="doc_subsubsection"> <a name="i_unwind">'<tt>unwind</tt>' |
| 2510 | Instruction</a> </div> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2511 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2512 | <div class="doc_text"> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2513 | |
Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 2514 | <h5>Syntax:</h5> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2515 | <pre> |
| 2516 | unwind |
| 2517 | </pre> |
| 2518 | |
Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 2519 | <h5>Overview:</h5> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2520 | <p>The '<tt>unwind</tt>' instruction unwinds the stack, continuing control flow |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2521 | at the first callee in the dynamic call stack which used |
| 2522 | an <a href="#i_invoke"><tt>invoke</tt></a> instruction to perform the call. |
| 2523 | This is primarily used to implement exception handling.</p> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2524 | |
Chris Lattner | 27f71f2 | 2003-09-03 00:41:47 +0000 | [diff] [blame] | 2525 | <h5>Semantics:</h5> |
Chris Lattner | 72ed200 | 2008-04-19 21:01:16 +0000 | [diff] [blame] | 2526 | <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] | 2527 | immediately halt. The dynamic call stack is then searched for the |
| 2528 | first <a href="#i_invoke"><tt>invoke</tt></a> instruction on the call stack. |
| 2529 | Once found, execution continues at the "exceptional" destination block |
| 2530 | specified by the <tt>invoke</tt> instruction. If there is no <tt>invoke</tt> |
| 2531 | instruction in the dynamic call chain, undefined behavior results.</p> |
| 2532 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2533 | </div> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2534 | |
| 2535 | <!-- _______________________________________________________________________ --> |
| 2536 | |
| 2537 | <div class="doc_subsubsection"> <a name="i_unreachable">'<tt>unreachable</tt>' |
| 2538 | Instruction</a> </div> |
| 2539 | |
| 2540 | <div class="doc_text"> |
| 2541 | |
| 2542 | <h5>Syntax:</h5> |
| 2543 | <pre> |
| 2544 | unreachable |
| 2545 | </pre> |
| 2546 | |
| 2547 | <h5>Overview:</h5> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2548 | <p>The '<tt>unreachable</tt>' instruction has no defined semantics. This |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2549 | instruction is used to inform the optimizer that a particular portion of the |
| 2550 | code is not reachable. This can be used to indicate that the code after a |
| 2551 | no-return function cannot be reached, and other facts.</p> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2552 | |
| 2553 | <h5>Semantics:</h5> |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2554 | <p>The '<tt>unreachable</tt>' instruction has no defined semantics.</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2555 | |
Chris Lattner | 35eca58 | 2004-10-16 18:04:13 +0000 | [diff] [blame] | 2556 | </div> |
| 2557 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2558 | <!-- ======================================================================= --> |
Chris Lattner | 261efe9 | 2003-11-25 01:02:51 +0000 | [diff] [blame] | 2559 | <div class="doc_subsection"> <a name="binaryops">Binary Operations</a> </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2560 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2561 | <div class="doc_text"> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2562 | |
| 2563 | <p>Binary operators are used to do most of the computation in a program. They |
| 2564 | require two operands of the same type, execute an operation on them, and |
| 2565 | produce a single value. The operands might represent multiple data, as is |
| 2566 | the case with the <a href="#t_vector">vector</a> data type. The result value |
| 2567 | has the same type as its operands.</p> |
| 2568 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2569 | <p>There are several different binary operators:</p> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2570 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2571 | </div> |
Bill Wendling | e910b4c | 2009-07-20 02:29:24 +0000 | [diff] [blame] | 2572 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2573 | <!-- _______________________________________________________________________ --> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2574 | <div class="doc_subsubsection"> |
| 2575 | <a name="i_add">'<tt>add</tt>' Instruction</a> |
| 2576 | </div> |
| 2577 | |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2578 | <div class="doc_text"> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2579 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2580 | <h5>Syntax:</h5> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2581 | <pre> |
Gabor Greif | fb224a2 | 2008-08-07 21:46:00 +0000 | [diff] [blame] | 2582 | <result> = add <ty> <op1>, <op2> <i>; yields {ty}:result</i> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2583 | </pre> |
Chris Lattner | 5568e94 | 2008-05-20 20:48:21 +0000 | [diff] [blame] | 2584 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2585 | <h5>Overview:</h5> |
Misha Brukman | 9d0919f | 2003-11-08 01:05:38 +0000 | [diff] [blame] | 2586 | <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] | 2587 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2588 | <h5>Arguments:</h5> |
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> |
Bill Wendling | d9fe298 | 2009-07-20 02:32:41 +0000 | [diff] [blame] | 2703 | <p>The two arguments to the '<tt>fsub</tt>' instruction must be |
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> |