Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
<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">
<pre> <result> = call <ty>* <fnptrval>(<param list>)<br></pre>
<p>The '<tt>call</tt>' instruction represents a simple function call.</p>
<p>This instruction requires several arguments:</p>
<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.</p>
</li>
<li>
<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 values.</p>
</li>
<li>
<p>'<tt>function args</tt>': argument list whose types match the
function signature argument types. If the function signature
indicates the function accepts a variable number of arguments, the
extra arguments can be specified.</p>
</li>
<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)<br> call int(sbyte*, ...) *%printf(sbyte* %msg, int 12, sbyte 42);<br></pre>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_vanext">'<tt>vanext</tt>' Instruction</a>
</div>
<div class="doc_text">
<pre>
<resultarglist> = vanext <va_list> <arglist>, <argty>
</pre>
<p>The '<tt>vanext</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>
<p>This instruction takes a <tt>va_list</tt> value and the type of the
argument. It returns another <tt>va_list</tt>. The actual type of
<tt>va_list</tt> may be defined differently for different targets. Most targets
use a <tt>va_list</tt> type of <tt>sbyte*</tt> or some other pointer type.</p>
<p>The '<tt>vanext</tt>' instruction advances the specified <tt>va_list</tt>
past an argument of the specified type. In conjunction with the <a
href="#i_vaarg"><tt>vaarg</tt></a> instruction, it is used to implement
the <tt>va_arg</tt> macro available in C. 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>
<p><tt>vanext</tt> is an LLVM instruction instead of an <a
href="#intrinsics">intrinsic function</a> because it takes a type as an
argument. The type refers to the current argument in the <tt>va_list</tt>, it
tells the compiler how far on the stack it needs to advance to find the next
argument</p>
<p>See the <a href="#int_varargs">variable argument processing</a>
section.</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_vaarg">'<tt>vaarg</tt>' Instruction</a>
</div>
<div class="doc_text">
<pre>
<resultval> = vaarg <va_list> <arglist>, <argty>
</pre>
<p>The '<tt>vaarg</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>
<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. Again, the actual
type of <tt>va_list</tt> is target specific.</p>
<p>The '<tt>vaarg</tt>' instruction loads an argument of the specified type from
the specified <tt>va_list</tt>. In conjunction with the <a
href="#i_vanext"><tt>vanext</tt></a> instruction, it is used to implement the
<tt>va_arg</tt> macro available in C. 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>
<p><tt>vaarg</tt> is an LLVM instruction instead of an <a
href="#intrinsics">intrinsic function</a> because it takes an type as an
argument.</p>
<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
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
<p>LLVM supports the notion of an "intrinsic function". These functions have
well known names and semantics, and are required to follow certain
restrictions. Overall, these instructions represent an extension mechanism for
the LLVM language that does not require changing all of the transformations in
LLVM to add to the language (or the bytecode reader/writer, the parser,
etc...).</p>
<p>Intrinsic function names must all start with an "<tt>llvm.</tt>" prefix, this
prefix is reserved in LLVM for intrinsic names, thus functions may not be named
this. Intrinsic functions must always be external functions: you cannot define
the body of intrinsic functions. Intrinsic functions may only be used in call
or invoke instructions: it is illegal to take the address of an intrinsic
function. Additionally, because intrinsic functions are part of the LLVM
language, it is required that they all be documented here if any are added.</p>
<p>
Adding an intrinsic to LLVM is straight-forward if it is possible to express the
concept in LLVM directly (ie, code generator support is not _required_). To do
this, extend the default implementation of the IntrinsicLowering class to handle
the intrinsic. Code generators use this class to lower intrinsics they do not
understand to raw LLVM instructions that they do.
</p>
</div>
<!-- ======================================================================= -->
<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
%ap = call sbyte* %<a href="#i_va_start">llvm.va_start</a>()
; Read a single integer argument
%tmp = vaarg sbyte* %ap, int
; Advance to the next argument
%ap2 = vanext sbyte* %ap, int
; Demonstrate usage of llvm.va_copy and llvm.va_end
%aq = call sbyte* %<a href="#i_va_copy">llvm.va_copy</a>(sbyte* %ap2)
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %aq)
; Stop processing of arguments.
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %ap2)
ret int %tmp
}
</pre>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<pre> call <va_list> ()* %llvm.va_start()<br></pre>
<p>The '<tt>llvm.va_start</tt>' intrinsic returns a new <tt><arglist></tt>
for subsequent use by the variable argument intrinsics.</p>
<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 and
returns a <tt>va_list</tt> element, so that the next <tt>vaarg</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>
<p>Note that this intrinsic function is only legal to be called from
within the body of a variable argument function.</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<pre> call void (<va_list>)* %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">
call <va_list> (<va_list>)* %llvm.va_copy(<va_list> <destarglist>)
<p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position
from the source argument list to the destination argument list.</p>
<p>The argument is the <tt>va_list</tt> to copy.</p>
<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 returned list. This intrinsic is necessary
because the <tt><a href="#i_va_start">llvm.va_start</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>
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
<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>
call void (<ty>**, <ty2>*)* %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
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
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>
call sbyte* (sbyte**)* %llvm.gcread(sbyte** %Ptr)
</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>
call void (sbyte*, sbyte**)* %llvm.gcwrite(sbyte* %P1, sbyte** %P2)
</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">
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
2495
2496
2497
2498
2499
<h5>Syntax:</h5>
<pre>
call void* ()* %llvm.returnaddress(uint <level>)
</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
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
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
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>
call void* ()* %llvm.frameaddress(uint <level>)
</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>
call void (sbyte *, uint, uint)* %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
characteristics.
</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
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
call void (uint)* %llvm.pcmarker( uint <id> )
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.pcmarker</tt>' intrinsic is a method to export a PC in a region of
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
corrolations of simulation runs.
</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>
call <integer type> (<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>
call <result> (<ty>*)* %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>
call void (<ty1>, <ty2>*)* %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
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
</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>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare void %llvm.memmove(sbyte* <dest>, sbyte* <src>,
uint <len>, uint <align>)
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.memmove</tt>' intrinsic moves a block of memory from the source
location to the destination location. It is similar to the '<tt>llvm.memcpy</tt>'
intrinsic but allows the two memory locations to overlap.
</p>
<p>
Note that, unlike the standard libc function, the <tt>llvm.memmove</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>
<h5>Semantics:</h5>
<p>
The '<tt>llvm.memmove</tt>' intrinsic copies a block of memory from the source
location to the destination location, which may 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_memset">'<tt>llvm.memset</tt>' Intrinsic</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre>
declare void %llvm.memset(sbyte* <dest>, ubyte <val>,
uint <len>, uint <align>)
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
</pre>
<h5>Overview:</h5>
<p>
The '<tt>llvm.memset</tt>' intrinsic fills a block of memory with a particular
byte value.
</p>
<p>
Note that, unlike the standard libc function, the <tt>llvm.memset</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 to fill, the second is the
byte value to fill it with, the third argument is an (arbitrarily sized) integer
argument specifying the number of bytes to fill, and the fourth argument is the
known alignment of destination location.
</p>
<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 the destination pointer is aligned to that boundary.
</p>
<h5>Semantics:</h5>
<p>
The '<tt>llvm.memset</tt>' intrinsic fills "len" bytes of memory starting at the
destination location. 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_isunordered">'<tt>llvm.isunordered</tt>' Intrinsic</a>