]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/asm: add 'insert program mask' instruction for s390x
authorMichael Munday <mike.munday@ibm.com>
Thu, 7 Mar 2019 13:18:38 +0000 (13:18 +0000)
committerMichael Munday <mike.munday@ibm.com>
Fri, 29 Mar 2019 17:34:06 +0000 (17:34 +0000)
This CL adds the 'insert program mask' (IPM) instruction to s390x.
IPM stores the current program mask (which contains the condition
code) into a general purpose register.

This instruction will be useful when implementing intrinsics for
the arithmetic functions in the math/bits package. We can also
potentially use it to convert some condition codes into bool
values.

The condition code can be saved and restored using an instruction
sequence such as:

  IPM  R4          // save condition code to R4
  ...
  TMLH R4, $0x3000 // restore condition code from R4

We can also use IPM to save the carry bit to a register using an
instruction sequence such as:

  IPM     R4                   // save condition code to R4
  RISBLGZ $31, $31, $3, R4, R4 // isolate carry bit in R4

Change-Id: I169d450b6ea1a7ff8c0286115ddc42618da8a2f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/165997
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/asm/internal/asm/testdata/s390x.s
src/cmd/internal/obj/s390x/a.out.go
src/cmd/internal/obj/s390x/anames.go
src/cmd/internal/obj/s390x/asmz.go

index 0e50303d70e34b3af652087ce571b8b9d9859a33..fbe1203aaaef59caf94285951f5517630fc782cd 100644 (file)
@@ -219,6 +219,9 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
        TMLH    R3, $0                 // a7300000
        TMLL    R4, $32768             // a7418000
 
+       IPM     R3                     // b2220030
+       IPM     R12                    // b22200c0
+
        BNE     0(PC)                  // a7740000
        BEQ     0(PC)                  // a7840000
        BLT     0(PC)                  // a7440000
index af321f6131a96d76691eb6bf746693bd980567d1..fb246cbc47001b6f192c6aeff4a5d7a5bc625c6d 100644 (file)
@@ -366,6 +366,9 @@ const (
        ATMLH
        ATMLL
 
+       // insert program mask
+       AIPM
+
        // compare and swap
        ACS
        ACSG
index 9cea9f962d93d776cb75848e80f0b451f2df06e6..3a21e90ab1f15aa5aa1a84d3c7a22f075d42fc29 100644 (file)
@@ -120,6 +120,7 @@ var Anames = []string{
        "TMHL",
        "TMLH",
        "TMLL",
+       "IPM",
        "CS",
        "CSG",
        "SYNC",
index 7d49103be6fb602ccfbfa88c7f93accecc9c50e2..4c938eadcc8ccb53155b21820c660408589f8ad5 100644 (file)
@@ -260,6 +260,9 @@ var optab = []Optab{
        // test under mask
        Optab{ATMHH, C_REG, C_NONE, C_NONE, C_ANDCON, 91, 0},
 
+       // insert program mask
+       Optab{AIPM, C_REG, C_NONE, C_NONE, C_NONE, 92, 0},
+
        // 32-bit access registers
        Optab{AMOVW, C_AREG, C_NONE, C_NONE, C_REG, 68, 0},
        Optab{AMOVWZ, C_AREG, C_NONE, C_NONE, C_REG, 68, 0},
@@ -3766,6 +3769,9 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
                }
                zRI(opcode, uint32(p.From.Reg), uint32(c.vregoff(&p.To)), asm)
 
+       case 92: // insert program mask
+               zRRE(op_IPM, uint32(p.From.Reg), 0, asm)
+
        case 93: // GOT lookup
                v := c.vregoff(&p.To)
                if v != 0 {