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

Subversion Repositories hf-risc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 serginhofr
# memset, optimized for RISC-V
2
# Andrew Waterman
3
# 2012/10/15
4
 
5
.text
6
.global memset
7
memset:
8
  li a6, 15
9
  move a4, a0
10
  bleu a2, a6, .Ltiny
11
  and a5, a4, 15
12
  bnez a5, .Lmisaligned
13
 
14
.Laligned:
15
  bnez a1, .Lwordify
16
 
17
.Lwordified:
18
  and a3, a2, ~15
19
  and a2, a2, 15
20
  add a3, a3, a4
21
 
22
#ifdef __riscv64
23
1:sd a1, 0(a4)
24
  sd a1, 8(a4)
25
#else
26
1:sw a1, 0(a4)
27
  sw a1, 4(a4)
28
  sw a1, 8(a4)
29
  sw a1, 12(a4)
30
#endif
31
  add a4, a4, 16
32
  bltu a4, a3, 1b
33
 
34
  bnez a2, .Ltiny
35
  ret
36
 
37
.Ltiny:
38
  sub a3, a6, a2
39
  sll a3, a3, 2
40
1:auipc t0, %pcrel_hi(.Ltable)
41
  add a3, a3, t0
42
.option push
43
.option norvc
44
.Ltable_misaligned:
45
  jr a3, %pcrel_lo(1b)
46
.Ltable:
47
  sb a1,14(a4)
48
  sb a1,13(a4)
49
  sb a1,12(a4)
50
  sb a1,11(a4)
51
  sb a1,10(a4)
52
  sb a1, 9(a4)
53
  sb a1, 8(a4)
54
  sb a1, 7(a4)
55
  sb a1, 6(a4)
56
  sb a1, 5(a4)
57
  sb a1, 4(a4)
58
  sb a1, 3(a4)
59
  sb a1, 2(a4)
60
  sb a1, 1(a4)
61
  sb a1, 0(a4)
62
.option pop
63
  ret
64
 
65
.Lwordify:
66
  and a1, a1, 0xFF
67
  sll a3, a1, 8
68
  or  a1, a1, a3
69
  sll a3, a1, 16
70
  or  a1, a1, a3
71
#ifdef __riscv64
72
  sll a3, a1, 32
73
  or  a1, a1, a3
74
#endif
75
  j .Lwordified
76
 
77
.Lmisaligned:
78
  sll a3, a5, 2
79
1:auipc t0, %pcrel_hi(.Ltable_misaligned)
80
  add a3, a3, t0
81
  mv t0, ra
82
  jalr a3, %pcrel_lo(1b)
83
  mv ra, t0
84
 
85
  add a5, a5, -16
86
  sub a4, a4, a5
87
  add a2, a2, a5
88
  bleu a2, a6, .Ltiny
89
  j .Laligned

powered by: WebSVN 2.1.0

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