Skip to content

Commit f435811

Browse files
abner-chencsophie-zhao
authored andcommitted
cmd/compile, cmd/internal, runtime: change the registers used by the duff device for loong64
Add R21 to the allocatable registers, use R20 and R21 in duff device. This CL is in preparation for subsequent regABI support. Updates #40724 Co-authored-by: Xiaolin Zhao <[email protected]> Change-Id: If1661adc0f766925fbe74827a369797f95fa28a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/521775 Reviewed-by: David Chase <[email protected]> Run-TryBot: David Chase <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Meidan Li <[email protected]> Reviewed-by: Than McIntosh <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 4f55a5a commit f435811

File tree

6 files changed

+885
-885
lines changed

6 files changed

+885
-885
lines changed

src/cmd/compile/internal/loong64/ssa.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
362362
p.To.Type = obj.TYPE_REG
363363
p.To.Reg = v.Reg()
364364
case ssa.OpLOONG64DUFFZERO:
365-
// runtime.duffzero expects start address in R19
365+
// runtime.duffzero expects start address in R20
366366
p := s.Prog(obj.ADUFFZERO)
367367
p.To.Type = obj.TYPE_MEM
368368
p.To.Name = obj.NAME_EXTERN

src/cmd/compile/internal/ssa/_gen/LOONG64Ops.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func init() {
123123

124124
// Common individual register masks
125125
var (
126-
gp = buildReg("R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R23 R24 R25 R26 R27 R28 R29 R31") // R1 is LR, R2 is thread pointer, R3 is stack pointer, R21-unused, R22 is g, R30 is REGTMP
126+
gp = buildReg("R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31") // R1 is LR, R2 is thread pointer, R3 is stack pointer, R22 is g, R30 is REGTMP
127127
gpg = gp | buildReg("g")
128128
gpsp = gp | buildReg("SP")
129129
gpspg = gpg | buildReg("SP")
@@ -283,22 +283,22 @@ func init() {
283283
// arg1 = mem
284284
// auxint = offset into duffzero code to start executing
285285
// returns mem
286-
// R19 aka loong64.REGRT1 changed as side effect
286+
// R20 aka loong64.REGRT1 changed as side effect
287287
{
288288
name: "DUFFZERO",
289289
aux: "Int64",
290290
argLength: 2,
291291
reg: regInfo{
292-
inputs: []regMask{buildReg("R19")},
293-
clobbers: buildReg("R19 R1"),
292+
inputs: []regMask{buildReg("R20")},
293+
clobbers: buildReg("R20 R1"),
294294
},
295295
typ: "Mem",
296296
faultOnNilArg0: true,
297297
},
298298

299299
// duffcopy
300-
// arg0 = address of dst memory (in R20, changed as side effect) REGRT2
301-
// arg1 = address of src memory (in R19, changed as side effect) REGRT1
300+
// arg0 = address of dst memory (in R21, changed as side effect)
301+
// arg1 = address of src memory (in R20, changed as side effect)
302302
// arg2 = mem
303303
// auxint = offset into duffcopy code to start executing
304304
// returns mem
@@ -307,54 +307,54 @@ func init() {
307307
aux: "Int64",
308308
argLength: 3,
309309
reg: regInfo{
310-
inputs: []regMask{buildReg("R20"), buildReg("R19")},
311-
clobbers: buildReg("R19 R20 R1"),
310+
inputs: []regMask{buildReg("R21"), buildReg("R20")},
311+
clobbers: buildReg("R20 R21 R1"),
312312
},
313313
typ: "Mem",
314314
faultOnNilArg0: true,
315315
faultOnNilArg1: true,
316316
},
317317

318318
// large or unaligned zeroing
319-
// arg0 = address of memory to zero (in R19, changed as side effect)
319+
// arg0 = address of memory to zero (in R20, changed as side effect)
320320
// arg1 = address of the last element to zero
321321
// arg2 = mem
322322
// auxint = alignment
323323
// returns mem
324-
// MOVx R0, (R19)
325-
// ADDV $sz, R19
326-
// BGEU Rarg1, R19, -2(PC)
324+
// MOVx R0, (R20)
325+
// ADDV $sz, R20
326+
// BGEU Rarg1, R20, -2(PC)
327327
{
328328
name: "LoweredZero",
329329
aux: "Int64",
330330
argLength: 3,
331331
reg: regInfo{
332-
inputs: []regMask{buildReg("R19"), gp},
333-
clobbers: buildReg("R19"),
332+
inputs: []regMask{buildReg("R20"), gp},
333+
clobbers: buildReg("R20"),
334334
},
335335
typ: "Mem",
336336
faultOnNilArg0: true,
337337
},
338338

339339
// large or unaligned move
340-
// arg0 = address of dst memory (in R20, changed as side effect)
341-
// arg1 = address of src memory (in R19, changed as side effect)
340+
// arg0 = address of dst memory (in R21, changed as side effect)
341+
// arg1 = address of src memory (in R20, changed as side effect)
342342
// arg2 = address of the last element of src
343343
// arg3 = mem
344344
// auxint = alignment
345345
// returns mem
346-
// MOVx (R19), Rtmp
347-
// MOVx Rtmp, (R20)
348-
// ADDV $sz, R19
346+
// MOVx (R20), Rtmp
347+
// MOVx Rtmp, (R21)
349348
// ADDV $sz, R20
350-
// BGEU Rarg2, R19, -4(PC)
349+
// ADDV $sz, R21
350+
// BGEU Rarg2, R20, -4(PC)
351351
{
352352
name: "LoweredMove",
353353
aux: "Int64",
354354
argLength: 4,
355355
reg: regInfo{
356-
inputs: []regMask{buildReg("R20"), buildReg("R19"), gp},
357-
clobbers: buildReg("R19 R20"),
356+
inputs: []regMask{buildReg("R21"), buildReg("R20"), gp},
357+
clobbers: buildReg("R20 R21"),
358358
},
359359
typ: "Mem",
360360
faultOnNilArg0: true,

0 commit comments

Comments
 (0)