1
2
3
4
5 package loong64
6
7 import (
8 "cmd/compile/internal/base"
9 "cmd/compile/internal/ir"
10 "cmd/compile/internal/objw"
11 "cmd/compile/internal/types"
12 "cmd/internal/obj"
13 "cmd/internal/obj/loong64"
14 )
15
16 func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog {
17 if cnt == 0 {
18 return p
19 }
20
21
22 off += base.Ctxt.Arch.FixedFrameSize
23
24 if cnt < int64(4*types.PtrSize) {
25 for i := int64(0); i < cnt; i += int64(types.PtrSize) {
26 p = pp.Append(p, loong64.AMOVV, obj.TYPE_REG, loong64.REGZERO, 0, obj.TYPE_MEM, loong64.REGSP, off+i)
27 }
28 } else if cnt <= int64(128*types.PtrSize) {
29 p = pp.Append(p, loong64.AADDV, obj.TYPE_CONST, 0, off, obj.TYPE_REG, loong64.REGRT1, 0)
30 p.Reg = loong64.REGSP
31 p = pp.Append(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
32 p.To.Name = obj.NAME_EXTERN
33 p.To.Sym = ir.Syms.Duffzero
34 p.To.Offset = 8 * (128 - cnt/int64(types.PtrSize))
35 } else {
36
37
38
39
40
41
42 p = pp.Append(p, loong64.AADDV, obj.TYPE_CONST, 0, off, obj.TYPE_REG, loong64.REGRT1, 0)
43 p.Reg = loong64.REGSP
44 p = pp.Append(p, loong64.AADDV, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, loong64.REGRT2, 0)
45 p.Reg = loong64.REGRT1
46 p = pp.Append(p, loong64.AMOVV, obj.TYPE_REG, loong64.REGZERO, 0, obj.TYPE_MEM, loong64.REGRT1, 0)
47 loop := p
48 p = pp.Append(p, loong64.AADDV, obj.TYPE_CONST, 0, int64(types.PtrSize), obj.TYPE_REG, loong64.REGRT1, 0)
49 p = pp.Append(p, loong64.ABNE, obj.TYPE_REG, loong64.REGRT1, 0, obj.TYPE_BRANCH, 0, 0)
50 p.Reg = loong64.REGRT2
51 p.To.SetTarget(loop)
52 }
53
54 return p
55 }
56
57 func ginsnop(pp *objw.Progs) *obj.Prog {
58 p := pp.Prog(loong64.ANOOP)
59 return p
60 }
61
View as plain text