Newer
Older
<p>Note that it is undefined to access an array out of bounds: array and
pointer indexes must always be within the defined bounds of the array type.
The one exception for this rules is zero length arrays. These arrays are
defined to be accessible as variable length arrays, which requires access
beyond the zero'th element.</p>
<pre>
<i>; yields [12 x ubyte]*:aptr</i>
%aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, uint 1
</pre>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"> <a name="otherops">Other Operations</a> </div>
<div class="doc_text">
<p>The instructions in this category are the "miscellaneous"
instructions, which defy better classification.</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection"> <a name="i_phi">'<tt>phi</tt>'
Instruction</a> </div>
<div class="doc_text">
<pre> <result> = phi <ty> [ <val0>, <label0>], ...<br></pre>
<h5>Overview:</h5>
<p>The '<tt>phi</tt>' instruction is used to implement the φ node in
the SSA graph representing the function.</p>
<h5>Arguments:</h5>
<p>The type of the incoming values are specified with the first type
field. After this, the '<tt>phi</tt>' instruction takes a list of pairs
as arguments, with one pair for each predecessor basic block of the
current block. Only values of <a href="#t_firstclass">first class</a>
type may be used as the value arguments to the PHI node. Only labels
may be used as the label arguments.</p>
<p>There must be no non-phi instructions between the start of a basic
block and the PHI instructions: i.e. PHI instructions must be first in
a basic block.</p>
<h5>Semantics:</h5>
<p>At runtime, the '<tt>phi</tt>' instruction logically takes on the
value specified by the parameter, depending on which basic block we
came from in the last <a href="#terminators">terminator</a> instruction.</p>
<h5>Example:</h5>
<pre>Loop: ; Infinite loop that counts from 0 on up...<br> %indvar = phi uint [ 0, %LoopHeader ], [ %nextindvar, %Loop ]<br> %nextindvar = add uint %indvar, 1<br> br label %Loop<br></pre>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_cast">'<tt>cast .. to</tt>' Instruction</a>
</div>
<div class="doc_text">
<pre>
<result> = cast <ty> <value> to <ty2> <i>; yields ty2</i>
<p>
The '<tt>cast</tt>' instruction is used as the primitive means to convert
integers to floating point, change data type sizes, and break type safety (by
casting pointers).
</p>
<p>
The '<tt>cast</tt>' instruction takes a value to cast, which must be a first
class value, and a type to cast it to, which must also be a <a
href="#t_firstclass">first class</a> type.
</p>
<p>
This instruction follows the C rules for explicit casts when determining how the
data being cast must change to fit in its new container.
</p>
<p>
When casting to bool, any value that would be considered true in the context of
a C '<tt>if</tt>' condition is converted to the boolean '<tt>true</tt>' values,
all else are '<tt>false</tt>'.
</p>
<p>
When extending an integral value from a type of one signness to another (for
example '<tt>sbyte</tt>' to '<tt>ulong</tt>'), the value is sign-extended if the
<b>source</b> value is signed, and zero-extended if the source value is
unsigned. <tt>bool</tt> values are always zero extended into either zero or
one.
</p>
<pre>
%X = cast int 257 to ubyte <i>; yields ubyte:1</i>
%Y = cast int 123 to bool <i>; yields bool:true</i>
</div>
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_select">'<tt>select</tt>' Instruction</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
<result> = select bool <cond>, <ty> <val1>, <ty> <val2> <i>; yields ty</i>
</pre>
<h5>Overview:</h5>
<p>
The '<tt>select</tt>' instruction is used to choose one value based on a
condition, without branching.
</p>
<h5>Arguments:</h5>
<p>
The '<tt>select</tt>' instruction requires a boolean value indicating the condition, and two values of the same <a href="#t_firstclass">first class</a> type.
</p>
<h5>Semantics:</h5>
<p>
If the boolean condition evaluates to true, the instruction returns the first
value argument; otherwise, it returns the second value argument.
</p>
<h5>Example:</h5>
<pre>
%X = select bool true, ubyte 17, ubyte 42 <i>; yields ubyte:17</i>
</pre>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_call">'<tt>call</tt>' Instruction</a>
</div>
<div class="doc_text">
<result> = [tail] call [<a href="#callingconv">cconv</a>] <ty>* <fnptrval>(<param list>)
<p>The '<tt>call</tt>' instruction represents a simple function call.</p>
<p>This instruction requires several arguments:</p>
<p>The optional "tail" marker indicates whether the callee function accesses
any allocas or varargs in the caller. If the "tail" marker is present, the
function call is eligible for tail call optimization. Note that calls may
be marked "tail" even if they do not occur before a <a
href="#i_ret"><tt>ret</tt></a> instruction.
</li>
<li>
<p>The optional "cconv" marker indicates which <a href="callingconv">calling
convention</a> the call should use. If none is specified, the call defaults
to using C calling conventions.
</li>
<li>
<p>'<tt>ty</tt>': shall be the signature of the pointer to function value
being invoked. The argument types must match the types implied by this
signature. This type can be omitted if the function is not varargs and
if the function type does not return a pointer to a function.</p>
<p>'<tt>fnptrval</tt>': An LLVM value containing a pointer to a function to
be invoked. In most cases, this is a direct function invocation, but
indirect <tt>call</tt>s are just as possible, calling an arbitrary pointer
to function value.</p>
</li>
<li>
<p>'<tt>function args</tt>': argument list whose types match the
function signature argument types. All arguments must be of
<a href="#t_firstclass">first class</a> type. If the function signature
indicates the function accepts a variable number of arguments, the extra
arguments can be specified.</p>
<p>The '<tt>call</tt>' instruction is used to cause control flow to
transfer to a specified function, with its incoming arguments bound to
the specified values. Upon a '<tt><a href="#i_ret">ret</a></tt>'
instruction in the called function, control flow continues with the
instruction after the function call, and the return value of the
function is bound to the result argument. This is a simpler case of
the <a href="#i_invoke">invoke</a> instruction.</p>
<pre>
%retval = call int %test(int %argc)
call int(sbyte*, ...) *%printf(sbyte* %msg, int 12, sbyte 42);
%X = tail call int %foo()
%Y = tail call <a href="#callingconv">fastcc</a> int %foo()
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_vaarg">'<tt>vaarg</tt>' Instruction</a>
</div>
<div class="doc_text">
Andrew Lenharth
committed
<resultval> = va_arg <va_list*> <arglist>, <argty>
Andrew Lenharth
committed
<p>The '<tt>va_arg</tt>' instruction is used to access arguments passed through
the "variable argument" area of a function call. It is used to implement the
<tt>va_arg</tt> macro in C.</p>
Andrew Lenharth
committed
<p>This instruction takes a <tt>va_list*</tt> value and the type of
the argument. It returns a value of the specified argument type and
increments the <tt>va_list</tt> to poin to the next argument. Again, the
actual type of <tt>va_list</tt> is target specific.</p>
Andrew Lenharth
committed
<p>The '<tt>va_arg</tt>' instruction loads an argument of the specified
type from the specified <tt>va_list</tt> and causes the
<tt>va_list</tt> to point to the next argument. For more information,
see the variable argument handling <a href="#int_varargs">Intrinsic
Functions</a>.</p>
<p>It is legal for this instruction to be called in a function which does not
take a variable number of arguments, for example, the <tt>vfprintf</tt>
function.</p>
Andrew Lenharth
committed
<p><tt>va_arg</tt> is an LLVM instruction instead of an <a
href="#intrinsics">intrinsic function</a> because it takes a type as an
<p>See the <a href="#int_varargs">variable argument processing</a> section.</p>
</div>
<!-- *********************************************************************** -->
<div class="doc_section"> <a name="intrinsics">Intrinsic Functions</a> </div>
<!-- *********************************************************************** -->
<div class="doc_text">
Chris Lattner
committed
<p>LLVM supports the notion of an "intrinsic function". These functions have
well known names and semantics and are required to follow certain
Chris Lattner
committed
restrictions. Overall, these instructions represent an extension mechanism for
the LLVM language that does not require changing all of the transformations in
LLVM to add to the language (or the bytecode reader/writer, the parser,
etc...).</p>
<p>Intrinsic function names must all start with an "<tt>llvm.</tt>" prefix. This
prefix is reserved in LLVM for intrinsic names; thus, functions may not be named
Chris Lattner
committed
this. Intrinsic functions must always be external functions: you cannot define
the body of intrinsic functions. Intrinsic functions may only be used in call
or invoke instructions: it is illegal to take the address of an intrinsic
function. Additionally, because intrinsic functions are part of the LLVM
language, it is required that they all be documented here if any are added.</p>
<p>To learn how to add an intrinsic function, please see the <a
href="ExtendingLLVM.html">Extending LLVM Guide</a>.
Chris Lattner
committed
</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="int_varargs">Variable Argument Handling Intrinsics</a>
</div>
<div class="doc_text">
<p>Variable argument support is defined in LLVM with the <a
href="#i_vanext"><tt>vanext</tt></a> instruction and these three
intrinsic functions. These functions are related to the similarly
named macros defined in the <tt><stdarg.h></tt> header file.</p>
<p>All of these functions operate on arguments that use a
target-specific value type "<tt>va_list</tt>". The LLVM assembly
language reference manual does not define what this type is, so all
transformations should be prepared to handle intrinsics with any type
used.</p>
<p>This example shows how the <a href="#i_vanext"><tt>vanext</tt></a>
instruction and the variable argument handling intrinsic functions are
used.</p>
Chris Lattner
committed
<pre>
int %test(int %X, ...) {
; Initialize variable argument processing
Andrew Lenharth
committed
%ap = alloca sbyte*
call void %<a href="#i_va_start">llvm.va_start</a>(sbyte** %ap)
Chris Lattner
committed
; Read a single integer argument
Andrew Lenharth
committed
%tmp = va_arg sbyte** %ap, int
Chris Lattner
committed
; Demonstrate usage of llvm.va_copy and llvm.va_end
Andrew Lenharth
committed
%aq = alloca sbyte*
Andrew Lenharth
committed
call void %<a href="#i_va_copy">llvm.va_copy</a>(sbyte** %aq, sbyte** %ap)
Andrew Lenharth
committed
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte** %aq)
Chris Lattner
committed
; Stop processing of arguments.
Andrew Lenharth
committed
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte** %ap)
Chris Lattner
committed
ret int %tmp
}
</pre>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a>
</div>
<div class="doc_text">
Andrew Lenharth
committed
<pre> declare void %llvm.va_start(<va_list>* <arglist>)<br></pre>
Andrew Lenharth
committed
<P>The '<tt>llvm.va_start</tt>' intrinsic initializes
<tt>*<arglist></tt> for subsequent use by <tt><a
href="#i_va_arg">va_arg</a></tt>.</p>
<h5>Arguments:</h5>
<P>The argument is a pointer to a <tt>va_list</tt> element to initialize.</p>
Andrew Lenharth
committed
<P>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt>
macro available in C. In a target-dependent way, it initializes the
<tt>va_list</tt> element the argument points to, so that the next call to
<tt>va_arg</tt> will produce the first variable argument passed to the function.
Unlike the C <tt>va_start</tt> macro, this intrinsic does not need to know the
last argument of the function, the compiler can figure that out.</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a>
</div>
<div class="doc_text">
Andrew Lenharth
committed
<pre> declare void %llvm.va_end(<va_list*> <arglist>)<br></pre>
<p>The '<tt>llvm.va_end</tt>' intrinsic destroys <tt><arglist></tt>
which has been initialized previously with <tt><a href="#i_va_start">llvm.va_start</a></tt>
or <tt><a href="#i_va_copy">llvm.va_copy</a></tt>.</p>
<p>The argument is a <tt>va_list</tt> to destroy.</p>
<p>The '<tt>llvm.va_end</tt>' intrinsic works just like the <tt>va_end</tt>
macro available in C. In a target-dependent way, it destroys the <tt>va_list</tt>.
Calls to <a href="#i_va_start"><tt>llvm.va_start</tt></a> and <a
href="#i_va_copy"><tt>llvm.va_copy</tt></a> must be matched exactly
with calls to <tt>llvm.va_end</tt>.</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a>
</div>
<div class="doc_text">
Andrew Lenharth
committed
declare void %llvm.va_copy(<va_list>* <destarglist>,
Andrew Lenharth
committed
<va_list>* <srcarglist>)
Andrew Lenharth
committed
<p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position from
the source argument list to the destination argument list.</p>
Andrew Lenharth
committed
<p>The first argument is a pointer to a <tt>va_list</tt> element to initialize.
Andrew Lenharth
committed
The second argument is a pointer to a <tt>va_list</tt> element to copy from.</p>
Andrew Lenharth
committed
Andrew Lenharth
committed
<p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt> macro
available in C. In a target-dependent way, it copies the source
<tt>va_list</tt> element into the destination list. This intrinsic is necessary
because the <tt><a href="i_va_begin">llvm.va_begin</a></tt> intrinsic may be
arbitrarily complex and require memory allocation, for example.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="int_gc">Accurate Garbage Collection Intrinsics</a>
</div>
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
<div class="doc_text">
<p>
LLVM support for <a href="GarbageCollection.html">Accurate Garbage
Collection</a> requires the implementation and generation of these intrinsics.
These intrinsics allow identification of <a href="#i_gcroot">GC roots on the
stack</a>, as well as garbage collector implementations that require <a
href="#i_gcread">read</a> and <a href="#i_gcwrite">write</a> barriers.
Front-ends for type-safe garbage collected languages should generate these
intrinsics to make use of the LLVM garbage collectors. For more details, see <a
href="GarbageCollection.html">Accurate Garbage Collection with LLVM</a>.
</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare void %llvm.gcroot(<ty>** %ptrloc, <ty2>* %metadata)
</pre>
<h5>Overview:</h5>
<p>The '<tt>llvm.gcroot</tt>' intrinsic declares the existence of a GC root to
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
the code generator, and allows some metadata to be associated with it.</p>
<h5>Arguments:</h5>
<p>The first argument specifies the address of a stack object that contains the
root pointer. The second pointer (which must be either a constant or a global
value address) contains the meta-data to be associated with the root.</p>
<h5>Semantics:</h5>
<p>At runtime, a call to this intrinsics stores a null pointer into the "ptrloc"
location. At compile-time, the code generator generates information to allow
the runtime to find the pointer at GC safe points.
</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare sbyte* %llvm.gcread(sbyte** %Ptr)
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
</pre>
<h5>Overview:</h5>
<p>The '<tt>llvm.gcread</tt>' intrinsic identifies reads of references from heap
locations, allowing garbage collector implementations that require read
barriers.</p>
<h5>Arguments:</h5>
<p>The argument is the address to read from, which should be an address
allocated from the garbage collector.</p>
<h5>Semantics:</h5>
<p>The '<tt>llvm.gcread</tt>' intrinsic has the same semantics as a load
instruction, but may be replaced with substantially more complex code by the
garbage collector runtime, as needed.</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare void %llvm.gcwrite(sbyte* %P1, sbyte** %P2)
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
</pre>
<h5>Overview:</h5>
<p>The '<tt>llvm.gcwrite</tt>' intrinsic identifies writes of references to heap
locations, allowing garbage collector implementations that require write
barriers (such as generational or reference counting collectors).</p>
<h5>Arguments:</h5>
<p>The first argument is the reference to store, and the second is the heap
location to store to.</p>
<h5>Semantics:</h5>
<p>The '<tt>llvm.gcwrite</tt>' intrinsic has the same semantics as a store
instruction, but may be replaced with substantially more complex code by the
garbage collector runtime, as needed.</p>
</div>
Chris Lattner
committed
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="int_codegen">Code Generator Intrinsics</a>
</div>
<div class="doc_text">
<p>
These intrinsics are provided by LLVM to expose special features that may only
be implemented with code generator support.
</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a>
Chris Lattner
committed
</div>
<div class="doc_text">
declare void* %llvm.returnaddress(uint <level>)
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.returnaddress</tt>' intrinsic returns a target-specific value
indicating the return address of the current function or one of its callers.
</p>
<h5>Arguments:</h5>
<p>
The argument to this intrinsic indicates which function to return the address
for. Zero indicates the calling function, one indicates its caller, etc. The
argument is <b>required</b> to be a constant integer value.
</p>
<h5>Semantics:</h5>
<p>
The '<tt>llvm.returnaddress</tt>' intrinsic either returns a pointer indicating
the return address of the specified call frame, or zero if it cannot be
identified. The value returned by this intrinsic is likely to be incorrect or 0
for arguments other than zero, so it should only be used for debugging purposes.
</p>
<p>
Note that calling this intrinsic does not prevent function inlining or other
aggressive transformations, so the value returned may not be that of the obvious
source-language caller.
</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare void* %llvm.frameaddress(uint <level>)
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.frameaddress</tt>' intrinsic returns the target-specific frame
pointer value for the specified stack frame.
</p>
<h5>Arguments:</h5>
<p>
The argument to this intrinsic indicates which function to return the frame
pointer for. Zero indicates the calling function, one indicates its caller,
etc. The argument is <b>required</b> to be a constant integer value.
</p>
<h5>Semantics:</h5>
<p>
The '<tt>llvm.frameaddress</tt>' intrinsic either returns a pointer indicating
the frame address of the specified call frame, or zero if it cannot be
identified. The value returned by this intrinsic is likely to be incorrect or 0
for arguments other than zero, so it should only be used for debugging purposes.
</p>
Chris Lattner
committed
<p>
Note that calling this intrinsic does not prevent function inlining or other
aggressive transformations, so the value returned may not be that of the obvious
source-language caller.
</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare void %llvm.prefetch(sbyte * <address>,
uint <rw>, uint <locality>)
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.prefetch</tt>' intrinsic is a hint to the code generator to insert
a prefetch instruction if supported; otherwise, it is a noop. Prefetches have
no
effect on the behavior of the program but can change its performance
</p>
<h5>Arguments:</h5>
<p>
<tt>address</tt> is the address to be prefetched, <tt>rw</tt> is the specifier
determining if the fetch should be for a read (0) or write (1), and
<tt>locality</tt> is a temporal locality specifier ranging from (0) - no
locality, to (3) - extremely local keep in cache. The <tt>rw</tt> and
<tt>locality</tt> arguments must be constant integers.
</p>
<h5>Semantics:</h5>
<p>
This intrinsic does not modify the behavior of the program. In particular,
prefetches cannot trap and do not produce a value. On targets that support this
intrinsic, the prefetch can provide hints to the processor cache for better
performance.
</p>
</div>
Andrew Lenharth
committed
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare void %llvm.pcmarker( uint <id> )
Andrew Lenharth
committed
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.pcmarker</tt>' intrinsic is a method to export a Program Counter
(PC) in a region of
Andrew Lenharth
committed
code to simulators and other tools. The method is target specific, but it is
expected that the marker will use exported symbols to transmit the PC of the marker.
The marker makes no guaranties that it will remain with any specific instruction
after optimizations. It is possible that the presense of a marker will inhibit
optimizations. The intended use is to be inserted after optmizations to allow
correlations of simulation runs.
Andrew Lenharth
committed
</p>
<h5>Arguments:</h5>
<p>
<tt>id</tt> is a numerical id identifying the marker.
</p>
<h5>Semantics:</h5>
<p>
This intrinsic does not modify the behavior of the program. Backends that do not
support this intrinisic may ignore it.
</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="int_os">Operating System Intrinsics</a>
</div>
<div class="doc_text">
<p>
These intrinsics are provided by LLVM to support the implementation of
operating system level code.
</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_readport">'<tt>llvm.readport</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare <integer type> %llvm.readport (<integer type> <address>)
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.readport</tt>' intrinsic reads data from the specified hardware
I/O port.
</p>
<h5>Arguments:</h5>
<p>
The argument to this intrinsic indicates the hardware I/O address from which
to read the data. The address is in the hardware I/O address namespace (as
opposed to being a memory location for memory mapped I/O).
</p>
<h5>Semantics:</h5>
<p>
The '<tt>llvm.readport</tt>' intrinsic reads data from the hardware I/O port
specified by <i>address</i> and returns the value. The address and return
value must be integers, but the size is dependent upon the platform upon which
the program is code generated. For example, on x86, the address must be an
unsigned 16-bit value, and the return value must be 8, 16, or 32 bits.
</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_writeport">'<tt>llvm.writeport</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
call void (<integer type>, <integer type>)*
%llvm.writeport (<integer type> <value>,
<integer type> <address>)
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.writeport</tt>' intrinsic writes data to the specified hardware
I/O port.
</p>
<h5>Arguments:</h5>
<p>
The first argument is the value to write to the I/O port.
</p>
<p>
The second argument indicates the hardware I/O address to which data should be
written. The address is in the hardware I/O address namespace (as opposed to
being a memory location for memory mapped I/O).
</p>
<h5>Semantics:</h5>
<p>
The '<tt>llvm.writeport</tt>' intrinsic writes <i>value</i> to the I/O port
specified by <i>address</i>. The address and value must be integers, but the
size is dependent upon the platform upon which the program is code generated.
For example, on x86, the address must be an unsigned 16-bit value, and the
value written must be 8, 16, or 32 bits in length.
</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_readio">'<tt>llvm.readio</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare <result> %llvm.readio (<ty> * <pointer>)
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.readio</tt>' intrinsic reads data from a memory mapped I/O
address.
</p>
<h5>Arguments:</h5>
<p>
The argument to this intrinsic is a pointer indicating the memory address from
which to read the data. The data must be a
<a href="#t_firstclass">first class</a> type.
</p>
<h5>Semantics:</h5>
<p>
The '<tt>llvm.readio</tt>' intrinsic reads data from a memory mapped I/O
location specified by <i>pointer</i> and returns the value. The argument must
be a pointer, and the return value must be a
<a href="#t_firstclass">first class</a> type. However, certain architectures
may not support I/O on all first class types. For example, 32-bit processors
may only support I/O on data types that are 32 bits or less.
</p>
<p>
This intrinsic enforces an in-order memory model for llvm.readio and
llvm.writeio calls on machines that use dynamic scheduling. Dynamically
scheduled processors may execute loads and stores out of order, re-ordering at
run time accesses to memory mapped I/O registers. Using these intrinsics
ensures that accesses to memory mapped I/O registers occur in program order.
</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_writeio">'<tt>llvm.writeio</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare void %llvm.writeio (<ty1> <value>, <ty2> * <pointer>)
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.writeio</tt>' intrinsic writes data to the specified memory
mapped I/O address.
</p>
<h5>Arguments:</h5>
<p>
The first argument is the value to write to the memory mapped I/O location.
The second argument is a pointer indicating the memory address to which the
data should be written.
</p>
<h5>Semantics:</h5>
<p>
The '<tt>llvm.writeio</tt>' intrinsic writes <i>value</i> to the memory mapped
I/O address specified by <i>pointer</i>. The value must be a
<a href="#t_firstclass">first class</a> type. However, certain architectures
may not support I/O on all first class types. For example, 32-bit processors
may only support I/O on data types that are 32 bits or less.
</p>
<p>
This intrinsic enforces an in-order memory model for llvm.readio and
llvm.writeio calls on machines that use dynamic scheduling. Dynamically
scheduled processors may execute loads and stores out of order, re-ordering at
run time accesses to memory mapped I/O registers. Using these intrinsics
ensures that accesses to memory mapped I/O registers occur in program order.
</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="int_libc">Standard C Library Intrinsics</a>
</div>
Chris Lattner
committed
<div class="doc_text">
<p>
LLVM provides intrinsics for a few important standard C library functions.
These intrinsics allow source-language front-ends to pass information about the
alignment of the pointer arguments to the code generator, providing opportunity
for more efficient code generation.
Chris Lattner
committed
</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare void %llvm.memcpy(sbyte* <dest>, sbyte* <src>,
uint <len>, uint <align>)
Chris Lattner
committed
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source
location to the destination location.
</p>
<p>
Note that, unlike the standard libc function, the <tt>llvm.memcpy</tt> intrinsic
does not return a value, and takes an extra alignment argument.
</p>
<h5>Arguments:</h5>
<p>
The first argument is a pointer to the destination, the second is a pointer to
the source. The third argument is an (arbitrarily sized) integer argument
specifying the number of bytes to copy, and the fourth argument is the alignment
of the source and destination locations.
</p>
Chris Lattner
committed
<p>
If the call to this intrinisic has an alignment value that is not 0 or 1, then
the caller guarantees that the size of the copy is a multiple of the alignment
and that both the source and destination pointers are aligned to that boundary.
</p>
Chris Lattner
committed
<h5>Semantics:</h5>
<p>
The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source
location to the destination location, which are not allowed to overlap. It
copies "len" bytes of memory over. If the argument is known to be aligned to
some boundary, this can be specified as the fourth argument, otherwise it should
be set to 0 or 1.
</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a>