]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/s390x: add FIDBR and FIEBR instructions
authorMichael Munday <munday@ca.ibm.com>
Fri, 26 Aug 2016 15:28:41 +0000 (11:28 -0400)
committerMichael Munday <munday@ca.ibm.com>
Fri, 26 Aug 2016 17:23:16 +0000 (17:23 +0000)
FIDBR and FIEBR can be used for floating-point to integer rounding.
The relevant functions (Ceil, Floor and Trunc) will be updated
in a future CL.

Change-Id: I5952d67ab29d5ef8923ff1143e17a8d30169d692
Reviewed-on: https://go-review.googlesource.com/27826
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 e902100dc5c50bbb2c5a1b0c024d533e131c55e0..4060f0878004ac91b843767a7c4137cd10252f7a 100644 (file)
@@ -178,6 +178,8 @@ TEXT main·foo(SB),7,$16-0 // TEXT main.foo(SB), 7, $16-0
        FABS    F1, F2                 // b3100021
        FSQRTS  F3, F4                 // b3140043
        FSQRT   F5, F15                // b31500f5
+       FIEBR   $0, F0, F1             // b3570010
+       FIDBR   $7, F2, F3             // b35f7032
 
        VL      (R15), V1              // e710f0000006
        VST     V1, (R15)              // e710f000000e
index 28b03d433fa43af208c951c1316c9e62ca9bd8ee..ed9a1972f0de57a5ffd23930a85f1130f6570d3a 100644 (file)
@@ -286,6 +286,8 @@ const (
        AFSUBS
        AFSQRT
        AFSQRTS
+       AFIEBR
+       AFIDBR
 
        // convert from int32/int64 to float/float64
        ACEFBRA
index c8367d6ecabdc7669e3146a9cbfaf9892989e011..4a8e619ac11af5877fdcbb0a6816fd6c894d3f17 100644 (file)
@@ -79,6 +79,8 @@ var Anames = []string{
        "FSUBS",
        "FSQRT",
        "FSQRTS",
+       "FIEBR",
+       "FIDBR",
        "CEFBRA",
        "CDFBRA",
        "CEGBRA",
index 0b0ed585e8989274da43712c4de71de85b558096..47c901f01e10236950f08c707eea9e118ecaecd4 100644 (file)
@@ -191,6 +191,7 @@ var optab = []Optab{
        Optab{AFMOVD, C_ZCON, C_NONE, C_NONE, C_FREG, 67, 0},
        Optab{ACEFBRA, C_REG, C_NONE, C_NONE, C_FREG, 82, 0},
        Optab{ACFEBRA, C_FREG, C_NONE, C_NONE, C_REG, 83, 0},
+       Optab{AFIEBR, C_SCON, C_FREG, C_NONE, C_FREG, 48, 0},
 
        // load symbol address (plus offset)
        Optab{AMOVD, C_SYMADDR, C_NONE, C_NONE, C_REG, 19, 0},
@@ -912,6 +913,8 @@ func buildop(ctxt *obj.Link) {
                        opset(ACLFDBR, r)
                        opset(ACLGEBR, r)
                        opset(ACLGDBR, r)
+               case AFIEBR:
+                       opset(AFIDBR, r)
                case ACMPBEQ:
                        opset(ACMPBGE, r)
                        opset(ACMPBGT, r)
@@ -3205,6 +3208,20 @@ func asmout(ctxt *obj.Link, asm *[]byte) {
                        zRRE(op_LCGR, uint32(p.To.Reg), uint32(r), asm)
                }
 
+       case 48: // floating-point round to integer
+               m3 := vregoff(ctxt, &p.From)
+               if 0 > m3 || m3 > 7 {
+                       ctxt.Diag("mask (%v) must be in the range [0, 7]", m3)
+               }
+               var opcode uint32
+               switch p.As {
+               case AFIEBR:
+                       opcode = op_FIEBR
+               case AFIDBR:
+                       opcode = op_FIDBR
+               }
+               zRRF(opcode, uint32(m3), 0, uint32(p.To.Reg), uint32(p.Reg), asm)
+
        case 67: // fmov $0 freg
                var opcode uint32
                switch p.As {