OpenCores
URL https://opencores.org/ocsvn/hf-risc/hf-risc/trunk

Subversion Repositories hf-risc

[/] [hf-risc/] [trunk/] [tools/] [riscv-gnu-toolchain-master/] [glibc/] [sysdeps/] [riscv/] [memset.S] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 serginhofr
/* Copyright (C) 2014 Free Software Foundation, Inc.
2
   Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley.
3
   This file is part of the GNU C Library.
4
 
5
   The GNU C Library is free software; you can redistribute it and/or
6
   modify it under the terms of the GNU Lesser General Public
7
   License as published by the Free Software Foundation; either
8
   version 2.1 of the License, or (at your option) any later version.
9
 
10
   The GNU C Library is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Lesser General Public License for more details.
14
 
15
   You should have received a copy of the GNU Lesser General Public
16
   License along with the GNU C Library.  If not, see
17
   .  */
18
 
19
#include 
20
#include 
21
 
22
ENTRY(memset)
23
  li a6, 15
24
  move a4, a0
25
  bleu a2, a6, .Ltiny
26
  and a5, a4, 15
27
  bnez a5, .Lmisaligned
28
 
29
.Laligned:
30
  bnez a1, .Lwordify
31
 
32
.Lwordified:
33
  and a3, a2, ~15
34
  and a2, a2, 15
35
  add a3, a3, a4
36
 
37
#ifdef __riscv64
38
1:sd a1, 0(a4)
39
  sd a1, 8(a4)
40
#else
41
1:sw a1, 0(a4)
42
  sw a1, 4(a4)
43
  sw a1, 8(a4)
44
  sw a1, 12(a4)
45
#endif
46
  add a4, a4, 16
47
  bltu a4, a3, 1b
48
 
49
  bnez a2, .Ltiny
50
  ret
51
 
52
.Ltiny:
53
  sub a3, a6, a2
54
  sll a3, a3, 2
55
1:auipc t0, %pcrel_hi(.Ltable)
56
  add a3, a3, t0
57
.option push
58
.option norvc
59
.Ltable_misaligned:
60
  jr a3, %pcrel_lo(1b)
61
.Ltable:
62
  sb a1,14(a4)
63
  sb a1,13(a4)
64
  sb a1,12(a4)
65
  sb a1,11(a4)
66
  sb a1,10(a4)
67
  sb a1, 9(a4)
68
  sb a1, 8(a4)
69
  sb a1, 7(a4)
70
  sb a1, 6(a4)
71
  sb a1, 5(a4)
72
  sb a1, 4(a4)
73
  sb a1, 3(a4)
74
  sb a1, 2(a4)
75
  sb a1, 1(a4)
76
  sb a1, 0(a4)
77
.option pop
78
  ret
79
 
80
.Lwordify:
81
  and a1, a1, 0xFF
82
  sll a3, a1, 8
83
  or  a1, a1, a3
84
  sll a3, a1, 16
85
  or  a1, a1, a3
86
#ifdef __riscv64
87
  sll a3, a1, 32
88
  or  a1, a1, a3
89
#endif
90
  j .Lwordified
91
 
92
.Lmisaligned:
93
  sll a3, a5, 2
94
1:auipc t0, %pcrel_hi(.Ltable_misaligned)
95
  add a3, a3, t0
96
  mv t0, ra
97
  jalr a3, %pcrel_lo(1b)
98
  mv ra, t0
99
 
100
  add a5, a5, -16
101
  sub a4, a4, a5
102
  add a2, a2, a5
103
  bleu a2, a6, .Ltiny
104
  j .Laligned
105
END(memset)
106
 
107
weak_alias(memset, __GI_memset)

powered by: WebSVN 2.1.0

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