OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [machine/] [x86_64/] [memset.S] - Blame information for rev 207

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * ====================================================
3
 * Copyright (C) 2007 by Ellips BV. All rights reserved.
4
 *
5
 * Permission to use, copy, modify, and distribute this
6
 * software is freely granted, provided that this notice
7
 * is preserved.
8
 * ====================================================
9
 */
10
 
11
  #include "x86_64mach.h"
12
 
13
  .global SYM (memset)
14
  SOTYPE_FUNCTION(memset)
15
 
16
SYM (memset):
17
  movq    rdi, r9                 /* Save return value */
18
  movq    rsi, rax
19
  movq    rdx, rcx
20
  cmpq    $16, rdx
21
  jb      byte_set
22
 
23
  movq    rdi, r8                 /* Align on quad word boundary */
24
  andq    $7, r8
25
  jz      quadword_aligned
26
  movq    $8, rcx
27
  subq    r8, rcx
28
  subq    rcx, rdx
29
  rep     stosb
30
  movq    rdx, rcx
31
 
32
quadword_aligned:
33
  movabs  $0x0101010101010101, r8
34
  movzbl  sil, eax
35
  imul    r8, rax
36
  cmpq    $256, rdx
37
  jb      quadword_set
38
 
39
  shrq    $7, rcx                 /* Store 128 bytes at a time with minimum cache polution */
40
 
41
  .p2align 4
42
loop:
43
  movntiq rax,     (rdi)
44
  movntiq rax,   8 (rdi)
45
  movntiq rax,  16 (rdi)
46
  movntiq rax,  24 (rdi)
47
  movntiq rax,  32 (rdi)
48
  movntiq rax,  40 (rdi)
49
  movntiq rax,  48 (rdi)
50
  movntiq rax,  56 (rdi)
51
  movntiq rax,  64 (rdi)
52
  movntiq rax,  72 (rdi)
53
  movntiq rax,  80 (rdi)
54
  movntiq rax,  88 (rdi)
55
  movntiq rax,  96 (rdi)
56
  movntiq rax, 104 (rdi)
57
  movntiq rax, 112 (rdi)
58
  movntiq rax, 120 (rdi)
59
 
60
  leaq    128 (rdi), rdi
61
 
62
  dec     rcx
63
  jnz     loop
64
 
65
  sfence
66
  movq    rdx, rcx
67
  andq    $127, rcx
68
  rep     stosb
69
  movq    r9, rax
70
  ret
71
 
72
 
73
byte_set:
74
  rep     stosb
75
  movq    r9, rax
76
  ret
77
 
78
 
79
quadword_set:
80
  shrq    $3, rcx
81
  .p2align 4
82
  rep     stosq
83
  movq    rdx, rcx
84
  andq    $7, rcx
85
  rep     stosb                   /* Store the remaining bytes */
86
  movq    r9, rax
87
  ret
88
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.