mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Initial import
This commit is contained in:
commit
c91b3c5006
14915 changed files with 590219 additions and 0 deletions
43
third_party/compiler_rt/nexgen32e/chkstk.S
vendored
Normal file
43
third_party/compiler_rt/nexgen32e/chkstk.S
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
|
||||
#include "third_party/compiler_rt/assembly.h"
|
||||
|
||||
// _chkstk routine
|
||||
// This routine is windows specific
|
||||
// http://msdn.microsoft.com/en-us/library/ms648426.aspx
|
||||
|
||||
// Notes from r227519
|
||||
// MSVC x64s __chkstk and cygmings ___chkstk_ms do not adjust %rsp
|
||||
// themselves. It also does not clobber %rax so we can reuse it when
|
||||
// adjusting %rsp.
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
.section .yoink
|
||||
nop huge_compiler_rt_license
|
||||
.previous
|
||||
|
||||
.text
|
||||
.balign 4
|
||||
DEFINE_COMPILERRT_FUNCTION(___chkstk_ms)
|
||||
push %rcx
|
||||
push %rax
|
||||
cmp $0x1000,%rax
|
||||
lea 24(%rsp),%rcx
|
||||
jb 1f
|
||||
2:
|
||||
sub $0x1000,%rcx
|
||||
test %rcx,(%rcx)
|
||||
sub $0x1000,%rax
|
||||
cmp $0x1000,%rax
|
||||
ja 2b
|
||||
1:
|
||||
sub %rax,%rcx
|
||||
test %rcx,(%rcx)
|
||||
pop %rax
|
||||
pop %rcx
|
||||
ret
|
||||
END_COMPILERRT_FUNCTION(___chkstk_ms)
|
||||
|
||||
#endif // __x86_64__
|
46
third_party/compiler_rt/nexgen32e/chkstk2.S
vendored
Normal file
46
third_party/compiler_rt/nexgen32e/chkstk2.S
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
|
||||
#include "third_party/compiler_rt/assembly.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
.section .yoink
|
||||
nop huge_compiler_rt_license
|
||||
.previous
|
||||
|
||||
// _chkstk (_alloca) routine - probe stack between %rsp and (%rsp-%rax) in 4k increments,
|
||||
// then decrement %rsp by %rax. Preserves all registers except %rsp and flags.
|
||||
// This routine is windows specific
|
||||
// http://msdn.microsoft.com/en-us/library/ms648426.aspx
|
||||
|
||||
.text
|
||||
.balign 4
|
||||
DEFINE_COMPILERRT_FUNCTION(__alloca)
|
||||
mov %rcx,%rax // x64 _alloca is a normal function with parameter in rcx
|
||||
// fallthrough
|
||||
DEFINE_COMPILERRT_FUNCTION(___chkstk)
|
||||
push %rcx
|
||||
cmp $0x1000,%rax
|
||||
lea 16(%rsp),%rcx // rsp before calling this routine -> rcx
|
||||
jb 1f
|
||||
2:
|
||||
sub $0x1000,%rcx
|
||||
test %rcx,(%rcx)
|
||||
sub $0x1000,%rax
|
||||
cmp $0x1000,%rax
|
||||
ja 2b
|
||||
1:
|
||||
sub %rax,%rcx
|
||||
test %rcx,(%rcx)
|
||||
|
||||
lea 8(%rsp),%rax // load pointer to the return address into rax
|
||||
mov %rcx,%rsp // install the new top of stack pointer into rsp
|
||||
mov -8(%rax),%rcx // restore rcx
|
||||
push (%rax) // push return address onto the stack
|
||||
sub %rsp,%rax // restore the original value in rax
|
||||
ret
|
||||
END_COMPILERRT_FUNCTION(___chkstk)
|
||||
END_COMPILERRT_FUNCTION(__alloca)
|
||||
|
||||
#endif // __x86_64__
|
19
third_party/compiler_rt/nexgen32e/floatdidf.c
vendored
Normal file
19
third_party/compiler_rt/nexgen32e/floatdidf.c
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* clang-format off */
|
||||
/* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*/
|
||||
|
||||
STATIC_YOINK("huge_compiler_rt_license");
|
||||
|
||||
/* double __floatdidf(di_int a); */
|
||||
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
|
||||
#include "third_party/compiler_rt/int_lib.h"
|
||||
|
||||
double __floatdidf(int64_t a)
|
||||
{
|
||||
return (double)a;
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
17
third_party/compiler_rt/nexgen32e/floatdisf.c
vendored
Normal file
17
third_party/compiler_rt/nexgen32e/floatdisf.c
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* clang-format off */
|
||||
/* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*/
|
||||
|
||||
STATIC_YOINK("huge_compiler_rt_license");
|
||||
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
|
||||
#include "third_party/compiler_rt/int_lib.h"
|
||||
|
||||
float __floatdisf(int64_t a)
|
||||
{
|
||||
return (float)a;
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
19
third_party/compiler_rt/nexgen32e/floatdixf.c
vendored
Normal file
19
third_party/compiler_rt/nexgen32e/floatdixf.c
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* clang-format off */
|
||||
/* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*/
|
||||
|
||||
STATIC_YOINK("huge_compiler_rt_license");
|
||||
|
||||
/* long double __floatdixf(di_int a); */
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
#include "third_party/compiler_rt/int_lib.h"
|
||||
|
||||
long double __floatdixf(int64_t a)
|
||||
{
|
||||
return (long double)a;
|
||||
}
|
||||
|
||||
#endif /* __i386__ */
|
56
third_party/compiler_rt/nexgen32e/floatundidf.S
vendored
Normal file
56
third_party/compiler_rt/nexgen32e/floatundidf.S
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
//===-- floatundidf.S - Implement __floatundidf for x86_64 ----------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __floatundidf for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/compiler_rt/assembly.h"
|
||||
|
||||
// double __floatundidf(du_int a);
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
.section .yoink
|
||||
nop huge_compiler_rt_license
|
||||
.previous
|
||||
|
||||
CONST_SECTION
|
||||
|
||||
.balign 16
|
||||
twop52:
|
||||
.quad 0x4330000000000000
|
||||
|
||||
.balign 16
|
||||
twop84_plus_twop52:
|
||||
.quad 0x4530000000100000
|
||||
|
||||
.balign 16
|
||||
twop84:
|
||||
.quad 0x4530000000000000
|
||||
|
||||
#define REL_ADDR(_a) (_a)(%rip)
|
||||
|
||||
.text
|
||||
.balign 4
|
||||
DEFINE_COMPILERRT_FUNCTION(__floatundidf)
|
||||
movd %edi, %xmm0 // low 32 bits of a
|
||||
shrq $32, %rdi // high 32 bits of a
|
||||
orq REL_ADDR(twop84), %rdi // 0x1p84 + a_hi (no rounding occurs)
|
||||
orpd REL_ADDR(twop52), %xmm0 // 0x1p52 + a_lo (no rounding occurs)
|
||||
movd %rdi, %xmm1
|
||||
subsd REL_ADDR(twop84_plus_twop52), %xmm1 // a_hi - 0x1p52 (no rounding occurs)
|
||||
addsd %xmm1, %xmm0 // a_hi + a_lo (round happens here)
|
||||
ret
|
||||
END_COMPILERRT_FUNCTION(__floatundidf)
|
||||
|
||||
#endif // __x86_64__
|
||||
|
||||
NO_EXEC_STACK_DIRECTIVE
|
||||
|
42
third_party/compiler_rt/nexgen32e/floatundisf.S
vendored
Normal file
42
third_party/compiler_rt/nexgen32e/floatundisf.S
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
|
||||
#include "third_party/compiler_rt/assembly.h"
|
||||
|
||||
// float __floatundisf(du_int a);
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
.section .yoink
|
||||
nop huge_compiler_rt_license
|
||||
.previous
|
||||
|
||||
CONST_SECTION
|
||||
|
||||
.balign 16
|
||||
two:
|
||||
.single 2.0
|
||||
|
||||
#define REL_ADDR(_a) (_a)(%rip)
|
||||
|
||||
.text
|
||||
.balign 4
|
||||
DEFINE_COMPILERRT_FUNCTION(__floatundisf)
|
||||
movq $1, %rsi
|
||||
testq %rdi, %rdi
|
||||
js 1f
|
||||
cvtsi2ssq %rdi, %xmm0
|
||||
ret
|
||||
|
||||
1: andq %rdi, %rsi
|
||||
shrq %rdi
|
||||
orq %rsi, %rdi
|
||||
cvtsi2ssq %rdi, %xmm0
|
||||
mulss REL_ADDR(two), %xmm0
|
||||
ret
|
||||
END_COMPILERRT_FUNCTION(__floatundisf)
|
||||
|
||||
#endif // __x86_64__
|
||||
|
||||
NO_EXEC_STACK_DIRECTIVE
|
||||
|
75
third_party/compiler_rt/nexgen32e/floatundixf.S
vendored
Normal file
75
third_party/compiler_rt/nexgen32e/floatundixf.S
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
|
||||
#include "third_party/compiler_rt/assembly.h"
|
||||
|
||||
// long double __floatundixf(du_int a);
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
.section .yoink
|
||||
nop huge_compiler_rt_license
|
||||
.previous
|
||||
|
||||
CONST_SECTION
|
||||
|
||||
.balign 16
|
||||
twop64:
|
||||
.quad 0x43f0000000000000
|
||||
|
||||
#define REL_ADDR(_a) (_a)(%rip)
|
||||
|
||||
.text
|
||||
|
||||
.balign 4
|
||||
DEFINE_COMPILERRT_FUNCTION(__floatundixf)
|
||||
movq %rdi, -8(%rsp)
|
||||
fildq -8(%rsp)
|
||||
test %rdi, %rdi
|
||||
js 1f
|
||||
ret
|
||||
1: faddl REL_ADDR(twop64)
|
||||
ret
|
||||
END_COMPILERRT_FUNCTION(__floatundixf)
|
||||
|
||||
#endif // __x86_64__
|
||||
|
||||
|
||||
/* Branch-free implementation is ever so slightly slower, but more beautiful.
|
||||
It is likely superior for inlining, so I kept it around for future reference.
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
CONST_SECTION
|
||||
|
||||
.balign 4
|
||||
twop52:
|
||||
.quad 0x4330000000000000
|
||||
twop84_plus_twop52_neg:
|
||||
.quad 0xc530000000100000
|
||||
twop84:
|
||||
.quad 0x4530000000000000
|
||||
|
||||
#define REL_ADDR(_a) (_a)(%rip)
|
||||
|
||||
.text
|
||||
.balign 4
|
||||
DEFINE_COMPILERRT_FUNCTION(__floatundixf)
|
||||
movl %edi, %esi // low 32 bits of input
|
||||
shrq $32, %rdi // hi 32 bits of input
|
||||
orq REL_ADDR(twop84), %rdi // 2^84 + hi (as a double)
|
||||
orq REL_ADDR(twop52), %rsi // 2^52 + lo (as a double)
|
||||
movq %rdi, -8(%rsp)
|
||||
movq %rsi, -16(%rsp)
|
||||
fldl REL_ADDR(twop84_plus_twop52_neg)
|
||||
faddl -8(%rsp) // hi - 2^52 (as double extended, no rounding occurs)
|
||||
faddl -16(%rsp) // hi + lo (as double extended)
|
||||
ret
|
||||
END_COMPILERRT_FUNCTION(__floatundixf)
|
||||
|
||||
#endif // __x86_64__
|
||||
|
||||
*/
|
||||
|
||||
NO_EXEC_STACK_DIRECTIVE
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue