"git@repo.hca.bsc.es:rferrer/llvm-epi-0.8.git" did not exist on "4d5b5fe8129be3c605ded82e57dfcb9337b4fb73"
Newer
Older
<result> = setle <ty> <var1>, <var2> <i>; yields {bool}:result</i>
<result> = setge <ty> <var1>, <var2> <i>; yields {bool}:result</i>
</pre>
<h5>Overview:</h5>
The '<tt>set<i>cc</i></tt>' family of instructions returns a boolean value based on a comparison of their two operands.<p>
<h5>Arguments:</h5> The two arguments to the '<tt>set<i>cc</i></tt>'
instructions must be of <a href="#t_firstclass">first class</a> or <a
href="#t_pointer">pointer</a> type (it is not possible to compare
'<tt>label</tt>'s, '<tt>array</tt>'s, '<tt>structure</tt>' or '<tt>void</tt>'
values). Both arguments must have identical types.<p>
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
The '<tt>setlt</tt>', '<tt>setgt</tt>', '<tt>setle</tt>', and '<tt>setge</tt>' instructions do not operate on '<tt>bool</tt>' typed arguments.<p>
<h5>Semantics:</h5>
The '<tt>seteq</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if both operands are equal.<br>
The '<tt>setne</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if both operands are unequal.<br>
The '<tt>setlt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if the first operand is less than the second operand.<br>
The '<tt>setgt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if the first operand is greater than the second operand.<br>
The '<tt>setle</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if the first operand is less than or equal to the second operand.<br>
The '<tt>setge</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if the first operand is greater than or equal to the second operand.<p>
<h5>Example:</h5>
<pre>
<result> = seteq int 4, 5 <i>; yields {bool}:result = false</i>
<result> = setne float 4, 5 <i>; yields {bool}:result = true</i>
<result> = setlt uint 4, 5 <i>; yields {bool}:result = true</i>
<result> = setgt sbyte 4, 5 <i>; yields {bool}:result = false</i>
<result> = setle sbyte 4, 5 <i>; yields {bool}:result = true</i>
<result> = setge sbyte 4, 5 <i>; yields {bool}:result = false</i>
</pre>
<!-- ======================================================================= -->
</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
<tr><td> </td><td width="100%"> <font color="#EEEEFF" face="Georgia,Palatino"><b>
<a name="bitwiseops">Bitwise Binary Operations
</b></font></td></tr></table><ul>
Bitwise binary operators are used to do various forms of bit-twiddling in a
program. They are generally very efficient instructions, and can commonly be
strength reduced from other instructions. They require two operands, execute an
operation on them, and produce a single value. The resulting value of the
bitwise binary operators is always the same type as its first operand.<p>
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
<!-- _______________________________________________________________________ -->
</ul><a name="i_and"><h4><hr size=0>'<tt>and</tt>' Instruction</h4><ul>
<h5>Syntax:</h5>
<pre>
<result> = and <ty> <var1>, <var2> <i>; yields {ty}:result</i>
</pre>
<h5>Overview:</h5>
The '<tt>and</tt>' instruction returns the bitwise logical and of its two operands.<p>
<h5>Arguments:</h5>
The two arguments to the '<tt>and</tt>' instruction must be either <a href="#t_integral">integral</a> or <a href="#t_bool"><tt>bool</tt></a> values. Both arguments must have identical types.<p>
<h5>Semantics:</h5>
...<p>
<h5>Example:</h5>
<pre>
<result> = and int 4, %var <i>; yields {int}:result = 4 & %var</i>
<result> = and int 15, 40 <i>; yields {int}:result = 8</i>
<result> = and int 4, 8 <i>; yields {int}:result = 0</i>
</pre>
<!-- _______________________________________________________________________ -->
</ul><a name="i_or"><h4><hr size=0>'<tt>or</tt>' Instruction</h4><ul>
<h5>Syntax:</h5>
<pre>
<result> = or <ty> <var1>, <var2> <i>; yields {ty}:result</i>
</pre>
<h5>Overview:</h5> The '<tt>or</tt>' instruction returns the bitwise logical
inclusive or of its two operands.<p>
The two arguments to the '<tt>or</tt>' instruction must be either <a
href="#t_integral">integral</a> or <a href="#t_bool"><tt>bool</tt></a> values.
Both arguments must have identical types.<p>
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
<h5>Semantics:</h5>
...<p>
<h5>Example:</h5>
<pre>
<result> = or int 4, %var <i>; yields {int}:result = 4 | %var</i>
<result> = or int 15, 40 <i>; yields {int}:result = 47</i>
<result> = or int 4, 8 <i>; yields {int}:result = 12</i>
</pre>
<!-- _______________________________________________________________________ -->
</ul><a name="i_xor"><h4><hr size=0>'<tt>xor</tt>' Instruction</h4><ul>
<h5>Syntax:</h5>
<pre>
<result> = xor <ty> <var1>, <var2> <i>; yields {ty}:result</i>
</pre>
<h5>Overview:</h5>
The '<tt>xor</tt>' instruction returns the bitwise logical exclusive or of its
two operands.<p>
The two arguments to the '<tt>xor</tt>' instruction must be either <a
href="#t_integral">integral</a> or <a href="#t_bool"><tt>bool</tt></a> values.
Both arguments must have identical types.<p>
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
<h5>Semantics:</h5>
...<p>
<h5>Example:</h5>
<pre>
<result> = xor int 4, %var <i>; yields {int}:result = 4 ^ %var</i>
<result> = xor int 15, 40 <i>; yields {int}:result = 39</i>
<result> = xor int 4, 8 <i>; yields {int}:result = 12</i>
</pre>
<!-- _______________________________________________________________________ -->
</ul><a name="i_shl"><h4><hr size=0>'<tt>shl</tt>' Instruction</h4><ul>
<h5>Syntax:</h5>
<pre>
<result> = shl <ty> <var1>, ubyte <var2> <i>; yields {ty}:result</i>
</pre>
<h5>Overview:</h5>
The '<tt>shl</tt>' instruction returns the first operand shifted to the left a
specified number of bits.
The first argument to the '<tt>shl</tt>' instruction must be an <a
href="#t_integral">integral</a> type. The second argument must be an
'<tt>ubyte</tt>' type.<p>
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
<h5>Semantics:</h5>
... 0 bits are shifted into the emptied bit positions...<p>
<h5>Example:</h5>
<pre>
<result> = shl int 4, ubyte %var <i>; yields {int}:result = 4 << %var</i>
<result> = shl int 4, ubyte 2 <i>; yields {int}:result = 16</i>
<result> = shl int 1, ubyte 10 <i>; yields {int}:result = 1024</i>
</pre>
<!-- _______________________________________________________________________ -->
</ul><a name="i_shr"><h4><hr size=0>'<tt>shr</tt>' Instruction</h4><ul>
<h5>Syntax:</h5>
<pre>
<result> = shr <ty> <var1>, ubyte <var2> <i>; yields {ty}:result</i>
</pre>
<h5>Overview:</h5>
The '<tt>shr</tt>' instruction returns the first operand shifted to the right a specified number of bits.
<h5>Arguments:</h5>
The first argument to the '<tt>shr</tt>' instruction must be an <a href="#t_integral">integral</a> type. The second argument must be an '<tt>ubyte</tt>' type.<p>
<h5>Semantics:</h5>
... if the first argument is a <a href="#t_signed">signed</a> type, the most significant bit is duplicated in the newly free'd bit positions. If the first argument is unsigned, zeros shall fill the empty positions...<p>
<h5>Example:</h5>
<pre>
<result> = shr int 4, ubyte %var <i>; yields {int}:result = 4 >> %var</i>
<result> = shr int 4, ubyte 1 <i>; yields {int}:result = 2</i>
<result> = shr int 4, ubyte 2 <i>; yields {int}:result = 1</i>
<result> = shr int 4, ubyte 3 <i>; yields {int}:result = 0</i>
</pre>
<!-- ======================================================================= -->
</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
<tr><td> </td><td width="100%"> <font color="#EEEEFF" face="Georgia,Palatino"><b>
<a name="memoryops">Memory Access Operations
</b></font></td></tr></table><ul>
Accessing memory in SSA form is, well, sticky at best. This section describes how to read and write memory in LLVM.<p>
<!-- _______________________________________________________________________ -->
</ul><a name="i_malloc"><h4><hr size=0>'<tt>malloc</tt>' Instruction</h4><ul>
<h5>Syntax:</h5>
<pre>
<result> = malloc <type>, uint <NumElements> <i>; yields {type*}:result</i>
<result> = malloc <type> <i>; yields {type*}:result</i>
</pre>
<h5>Overview:</h5>
The '<tt>malloc</tt>' instruction allocates memory from the system heap and returns a pointer to it.<p>
<h5>Arguments:</h5>
The the '<tt>malloc</tt>' instruction allocates
<tt>sizeof(<type>)*NumElements</tt> bytes of memory from the operating
system, and returns a pointer of the appropriate type to the program. The
second form of the instruction is a shorter version of the first instruction
that defaults to allocating one element.<p>
'<tt>type</tt>' must be a sized type<p>
<h5>Semantics:</h5>
Memory is allocated, a pointer is returned.<p>
<h5>Example:</h5>
<pre>
%array = malloc [4 x ubyte ] <i>; yields {[%4 x ubyte]*}:array</i>
%size = <a href="#i_add">add</a> uint 2, 2 <i>; yields {uint}:size = uint 4</i>
%array1 = malloc ubyte, uint 4 <i>; yields {ubyte*}:array1</i>
%array2 = malloc [12 x ubyte], uint %size <i>; yields {[12 x ubyte]*}:array2</i>
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
</pre>
<!-- _______________________________________________________________________ -->
</ul><a name="i_free"><h4><hr size=0>'<tt>free</tt>' Instruction</h4><ul>
<h5>Syntax:</h5>
<pre>
free <type> <value> <i>; yields {void}</i>
</pre>
<h5>Overview:</h5>
The '<tt>free</tt>' instruction returns memory back to the unused memory heap, to be reallocated in the future.<p>
<h5>Arguments:</h5>
'<tt>value</tt>' shall be a pointer value that points to a value that was allocated with the '<tt><a href="#i_malloc">malloc</a></tt>' instruction.<p>
<h5>Semantics:</h5>
Memory is available for use after this point. The contents of the '<tt>value</tt>' pointer are undefined after this instruction.<p>
<h5>Example:</h5>
<pre>
%array = <a href="#i_malloc">malloc</a> [4 x ubyte] <i>; yields {[4 x ubyte]*}:array</i>
free [4 x ubyte]* %array
</pre>
<!-- _______________________________________________________________________ -->
</ul><a name="i_alloca"><h4><hr size=0>'<tt>alloca</tt>' Instruction</h4><ul>
<h5>Syntax:</h5>
<pre>
<result> = alloca <type>, uint <NumElements> <i>; yields {type*}:result</i>
<result> = alloca <type> <i>; yields {type*}:result</i>
The '<tt>alloca</tt>' instruction allocates memory on the current stack frame of
the procedure that is live until the current function returns to its caller.<p>
The the '<tt>alloca</tt>' instruction allocates
<tt>sizeof(<type>)*NumElements</tt> bytes of memory on the runtime stack,
returning a pointer of the appropriate type to the program. The second form of
the instruction is a shorter version of the first that defaults to allocating
one element.<p>
'<tt>type</tt>' may be any sized type.<p>
Memory is allocated, a pointer is returned. '<tt>alloca</tt>'d memory is
automatically released when the function returns. The '<tt>alloca</tt>'
instruction is commonly used to represent automatic variables that must have an
address available, as well as spilled variables.<p>
<h5>Example:</h5>
<pre>
%ptr = alloca int <i>; yields {int*}:ptr</i>
%ptr = alloca int, uint 4 <i>; yields {int*}:ptr</i>
</pre>
<!-- _______________________________________________________________________ -->
</ul><a name="i_load"><h4><hr size=0>'<tt>load</tt>' Instruction</h4><ul>
<h5>Syntax:</h5>
<pre>
<result> = load <ty>* <pointer>
</pre>
<h5>Overview:</h5>
The '<tt>load</tt>' instruction is used to read from memory.<p>
<h5>Arguments:</h5>
The argument to the '<tt>load</tt>' instruction specifies the memory address to load from. The pointer must point to a <a href="t_firstclass">first class</a> type.<p>
<h5>Semantics:</h5>
The location of memory pointed to is loaded.
<pre>
%ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
<a href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
%val = load int* %ptr <i>; yields {int}:val = int 3</i>
<!-- _______________________________________________________________________ -->
</ul><a name="i_store"><h4><hr size=0>'<tt>store</tt>' Instruction</h4><ul>
store <ty> <value>, <ty>* <pointer> <i>; yields {void}</i>
The '<tt>store</tt>' instruction is used to write to memory.<p>
There are two arguments to the '<tt>store</tt>' instruction: a value to store
and an address to store it into. The type of the '<tt><pointer></tt>'
operand must be a pointer to the type of the '<tt><value></tt>'
operand.<p>
<h5>Semantics:</h5> The contents of memory are updated to contain
'<tt><value></tt>' at the location specified by the
'<tt><pointer></tt>' operand.<p>
<pre>
%ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
<a href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
%val = load int* %ptr <i>; yields {int}:val = int 3</i>
</pre>
<!-- _______________________________________________________________________ -->
</ul><a name="i_getelementptr"><h4><hr size=0>'<tt>getelementptr</tt>' Instruction</h4><ul>
<result> = getelementptr <ty>* <ptrval>{, uint <aidx>|, ubyte <sidx>}*
The '<tt>getelementptr</tt>' instruction is used to get the address of a
subelement of an aggregate data structure. In addition to being present as an
explicit instruction, the '<tt>getelementptr</tt>' functionality is present in
both the '<tt><a href="#i_load">load</a></tt>' and '<tt><a
href="#i_store">store</a></tt>' instructions to allow more compact specification
of common expressions.<p>
This instruction takes a list of <tt>uint</tt> values and <tt>ubyte</tt>
constants that indicate what form of addressing to perform. The actual types of
the arguments provided depend on the type of the first pointer argument. The
'<tt>getelementptr</tt>' instruction is used to index down through the type
levels of a structure.<p>
TODO.
%aptr = getelementptr {int, [12 x ubyte]}* %sptr, 1 <i>; yields {[12 x ubyte]*}:aptr</i>
%ub = load [12x ubyte]* %aptr, 4 <i>;yields {ubyte}:ub</i>
</pre>
<!-- ======================================================================= -->
</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
<tr><td> </td><td width="100%"> <font color="#EEEEFF" face="Georgia,Palatino"><b>
<a name="otherops">Other Operations
</b></font></td></tr></table><ul>
The instructions in this catagory are the "miscellaneous" functions, that defy better classification.<p>
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
<!-- _______________________________________________________________________ -->
</ul><a name="i_cast"><h4><hr size=0>'<tt>cast .. to</tt>' Instruction</h4><ul>
<h1>TODO</h1>
<a name="logical_integrals">
Talk about what is considered true or false for integrals.
<h5>Syntax:</h5>
<pre>
</pre>
<h5>Overview:</h5>
<h5>Arguments:</h5>
<h5>Semantics:</h5>
<h5>Example:</h5>
<pre>
</pre>
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
<!-- _______________________________________________________________________ -->
</ul><a name="i_call"><h4><hr size=0>'<tt>call</tt>' Instruction</h4><ul>
<h5>Syntax:</h5>
<pre>
</pre>
<h5>Overview:</h5>
<h5>Arguments:</h5>
<h5>Semantics:</h5>
<h5>Example:</h5>
<pre>
%retval = call int %test(int %argc)
</pre>
<!-- _______________________________________________________________________ --></ul><a name="i_icall"><h3><hr size=0>'<tt>icall</tt>' Instruction</h3><ul>
Indirect calls are desperately needed to implement virtual function tables (C++, java) and function pointers (C, C++, ...).<p>
A new instruction <tt>icall</tt> or similar should be introduced to represent an indirect call.<p>
Example:
<pre>
%retval = icall int %funcptr(int %arg1) <i>; yields {int}:%retval</i>
</pre>
<!-- _______________________________________________________________________ -->
</ul><a name="i_phi"><h4><hr size=0>'<tt>phi</tt>' Instruction</h4><ul>
<h5>Syntax:</h5>
<pre>
</pre>
<h5>Overview:</h5>
<h5>Arguments:</h5>
<h5>Semantics:</h5>
<h5>Example:</h5>
<pre>
</pre>
<!-- *********************************************************************** -->
</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
<a name="related">Related Work
</b></font></td></tr></table><ul>
<!-- *********************************************************************** -->
Codesigned virtual machines.<p>
<dl>
<a name="rw_safetsa">
<dt>SafeTSA
<DD>Description here<p>
<a name="rw_java">
<dt><a href="http://www.javasoft.com">Java</a>
<DD>Desciption here<p>
<a name="rw_net">
<dt><a href="http://www.microsoft.com/net">Microsoft .net</a>
<DD>Desciption here<p>
<a name="rw_gccrtl">
<dt><a href="http://www.math.umn.edu/systems_guide/gcc-2.95.1/gcc_15.html">GNU RTL Intermediate Representation</a>
<DD>Desciption here<p>
<a name="rw_ia64">
<dt><a href="http://developer.intel.com/design/ia-64/index.htm">IA64 Architecture & Instruction Set</a>
<DD>Desciption here<p>
<a name="rw_mmix">
<dt><a href="http://www-cs-faculty.stanford.edu/~knuth/mmix-news.html">MMIX Instruction Set</a>
<DD>Desciption here<p>
<a name="rw_stroustrup">
<dt><a href="http://www.research.att.com/~bs/devXinterview.html">"Interview With Bjarne Stroustrup"</a>
<DD>This interview influenced the design and thought process behind LLVM in several ways, most notably the way that derived types are written in text format. See the question that starts with "you defined the C declarator syntax as an experiment that failed".<p>
</dl>
<!-- _______________________________________________________________________ -->
</ul><a name="rw_vectorization"><h3><hr size=0>Vectorized Architectures</h3><ul>
<dl>
<a name="rw_intel_simd">
<dt>Intel MMX, MMX2, SSE, SSE2
<DD>Description here<p>
<a name="rw_amd_simd">
<dt><a href="http://www.nondot.org/~sabre/os/H1ChipFeatures/3DNow!TechnologyManual.pdf">AMD 3Dnow!, 3Dnow! 2</a>
<DD>Desciption here<p>
<a name="rw_sun_simd">
<dt><a href="http://www.nondot.org/~sabre/os/H1ChipFeatures/VISInstructionSetUsersManual.pdf">Sun VIS ISA</a>
<DD>Desciption here<p>
</dl>
more...
<!-- *********************************************************************** -->
</ul>
<!-- *********************************************************************** -->
<hr>
<font size=-1>
<address><a href="mailto:sabre@nondot.org">Chris Lattner</a></address>
<!-- Created: Tue Jan 23 15:19:28 CST 2001 -->
<!-- hhmts start -->
Last modified: Fri May 3 14:39:52 CDT 2002