blob: bf93f6000992bd9303e63821858bd653f997a9c2 [file] [log] [blame]
Daniel Dunbarb3a69012009-06-26 16:47:03 +00001Compiler-RT
2================================
3
4This directory and its subdirectories contain source code for the compiler
5support routines.
6
7Compiler-RT is open source software. You may freely distribute it under the
8terms of the license agreement found in LICENSE.txt.
9
10================================
11
12This is a replacment library for libgcc. Each function is contained
13in its own file. Each function has a corresponding unit test under
14test/Unit.
15
16A rudimentary script to test each file is in the file called
17test/Unit/test.
18
19Here is the specification for this library:
20
21http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc
22
23Here is a synopsis of the contents of this library:
24
25typedef int si_int;
26typedef unsigned su_int;
27
28typedef long long di_int;
29typedef unsigned long long du_int;
30
31// Integral bit manipulation
32
33di_int __ashldi3(di_int a, si_int b); // a << b
34di_int __ashrdi3(di_int a, si_int b); // a >> b arithmetic (sign fill)
35di_int __lshrdi3(di_int a, si_int b); // a >> b logical (zero fill)
36
37si_int __clzsi2(si_int a); // count leading zeroes
38si_int __clzdi2(di_int a); // count leading zeroes
39si_int __ctzsi2(si_int a); // count trailing zeroes
40si_int __ctzdi2(di_int a); // count trailing zeroes
41
42si_int __ffsdi2(di_int a); // find least significant 1 bit
43
44si_int __paritysi2(si_int a); // bit parity
45si_int __paritydi2(di_int a); // bit parity
46
47si_int __popcountsi2(si_int a); // bit population
48si_int __popcountdi2(di_int a); // bit population
49
50// Integral arithmetic
51
52di_int __negdi2 (di_int a); // -a
53di_int __muldi3 (di_int a, di_int b); // a * b
54di_int __divdi3 (di_int a, di_int b); // a / b signed
55du_int __udivdi3 (du_int a, du_int b); // a / b unsigned
56di_int __moddi3 (di_int a, di_int b); // a % b signed
57du_int __umoddi3 (du_int a, du_int b); // a % b unsigned
58du_int __udivmoddi4(du_int a, du_int b, du_int* rem); // a / b, *rem = a % b
59
60// Integral arithmetic with trapping overflow
61
62si_int __absvsi2(si_int a); // abs(a)
63di_int __absvdi2(di_int a); // abs(a)
64
65si_int __negvsi2(si_int a); // -a
66di_int __negvdi2(di_int a); // -a
67
68si_int __addvsi3(si_int a, si_int b); // a + b
69di_int __addvdi3(di_int a, di_int b); // a + b
70
71si_int __subvsi3(si_int a, si_int b); // a - b
72di_int __subvdi3(di_int a, di_int b); // a - b
73
74si_int __mulvsi3(si_int a, si_int b); // a * b
75di_int __mulvdi3(di_int a, di_int b); // a * b
76
77// Integral comparison: a < b -> 0
78// a == b -> 1
79// a > b -> 2
80
81si_int __cmpdi2 (di_int a, di_int b);
82si_int __ucmpdi2(du_int a, du_int b);
83
84// Integral / floating point conversion
85
86di_int __fixsfdi( float a);
87di_int __fixdfdi( double a);
88di_int __fixxfdi(long double a);
89
90su_int __fixunssfsi( float a);
91su_int __fixunsdfsi( double a);
92su_int __fixunsxfsi(long double a);
93
94du_int __fixunssfdi( float a);
95du_int __fixunsdfdi( double a);
96du_int __fixunsxfdi(long double a);
97
98float __floatdisf(di_int a);
99double __floatdidf(di_int a);
100long double __floatdixf(di_int a);
101
102float __floatundisf(du_int a);
103double __floatundidf(du_int a);
104long double __floatundixf(du_int a);
105
106// Floating point raised to integer power
107
108float __powisf2( float a, si_int b); // a ^ b
109double __powidf2( double a, si_int b); // a ^ b
110long double __powixf2(long double a, si_int b); // a ^ b
111
112// Complex arithmetic
113
114// (a + ib) * (c + id)
115
116 float _Complex __mulsc3( float a, float b, float c, float d);
117 double _Complex __muldc3(double a, double b, double c, double d);
118long double _Complex __mulxc3(long double a, long double b,
119 long double c, long double d);
120
121// (a + ib) / (c + id)
122
123 float _Complex __divsc3( float a, float b, float c, float d);
124 double _Complex __divdc3(double a, double b, double c, double d);
125long double _Complex __divxc3(long double a, long double b,
126 long double c, long double d);
127
128Preconditions are listed for each function at the definition when there are any.
129Any preconditions reflect the specification at
130http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc.
131
132Assumptions are listed in "int_lib.h", and in individual files. Where possible
133assumptions are checked at compile time.