| |
| |
| |
|
|
| package s390x |
|
|
| import ( |
| "cmd/compile/internal/base" |
| "cmd/compile/internal/objw" |
| "cmd/internal/obj" |
| "cmd/internal/obj/s390x" |
| ) |
|
|
| |
| |
| |
| |
| const clearLoopCutoff = 1024 |
|
|
| |
| func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { |
| if cnt == 0 { |
| return p |
| } |
|
|
| |
| off += base.Ctxt.Arch.FixedFrameSize |
| reg := int16(s390x.REGSP) |
|
|
| |
| |
| |
| if off < 0 || off > 4096-clearLoopCutoff || cnt > clearLoopCutoff { |
| p = pp.Append(p, s390x.AADD, obj.TYPE_CONST, 0, off, obj.TYPE_REG, s390x.REGRT1, 0) |
| p.Reg = int16(s390x.REGSP) |
| reg = s390x.REGRT1 |
| off = 0 |
| } |
|
|
| |
| if cnt > clearLoopCutoff { |
| ireg := int16(s390x.REGRT2) |
| p = pp.Append(p, s390x.AMOVD, obj.TYPE_CONST, 0, cnt/256, obj.TYPE_REG, ireg, 0) |
| p = pp.Append(p, s390x.ACLEAR, obj.TYPE_CONST, 0, 256, obj.TYPE_MEM, reg, off) |
| pl := p |
| p = pp.Append(p, s390x.AADD, obj.TYPE_CONST, 0, 256, obj.TYPE_REG, reg, 0) |
| p = pp.Append(p, s390x.ABRCTG, obj.TYPE_REG, ireg, 0, obj.TYPE_BRANCH, 0, 0) |
| p.To.SetTarget(pl) |
| cnt = cnt % 256 |
| } |
|
|
| |
| for cnt > 0 { |
| n := cnt |
|
|
| |
| if n > 256 { |
| n = 256 |
| } |
|
|
| switch n { |
| |
| case 8, 4, 2, 1: |
| ins := s390x.AMOVB |
| switch n { |
| case 8: |
| ins = s390x.AMOVD |
| case 4: |
| ins = s390x.AMOVW |
| case 2: |
| ins = s390x.AMOVH |
| } |
| p = pp.Append(p, ins, obj.TYPE_CONST, 0, 0, obj.TYPE_MEM, reg, off) |
|
|
| |
| default: |
| p = pp.Append(p, s390x.ACLEAR, obj.TYPE_CONST, 0, n, obj.TYPE_MEM, reg, off) |
| } |
|
|
| cnt -= n |
| off += n |
| } |
|
|
| return p |
| } |
|
|
| func ginsnop(pp *objw.Progs) *obj.Prog { |
| return pp.Prog(s390x.ANOPH) |
| } |
|
|