]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/x86: add support for TSX instructions
authorsergey.arseev <sergey.arseev@intel.com>
Mon, 2 Nov 2015 11:53:31 +0000 (14:53 +0300)
committerRuss Cox <rsc@golang.org>
Thu, 26 Nov 2015 16:39:00 +0000 (16:39 +0000)
Transactional memory, will later be used for semaphore implementation.
Nacl not supported yet.

Change-Id: Ic18453dcaa08d07bb217c0b95461584f007d518b
Reviewed-on: https://go-review.googlesource.com/16479
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/asm/internal/arch/arch.go
src/cmd/internal/obj/x86/a.out.go
src/cmd/internal/obj/x86/anames.go
src/cmd/internal/obj/x86/asm6.go

index cc1aab6ad505aa6668fbc594d1c20c99c98b9302..b6a51a837c07d5dedfafb9d7924144d9135f2ea1 100644 (file)
@@ -87,7 +87,7 @@ func Set(GOARCH string) *Arch {
 }
 
 func jumpX86(word string) bool {
-       return word[0] == 'J' || word == "CALL" || strings.HasPrefix(word, "LOOP")
+       return word[0] == 'J' || word == "CALL" || strings.HasPrefix(word, "LOOP") || word == "XBEGIN"
 }
 
 func archX86(linkArch *obj.LinkArch) *Arch {
index 73abe3b705b08e45395d2d559881649a7cb4e1c8..5ea5c9d79ee3a597e8ce89967c80086eb38a021d 100644 (file)
@@ -768,6 +768,14 @@ const (
        AFUCOMI
        AFUCOMIP
 
+       // TSX
+       AXACQUIRE
+       AXRELEASE
+       AXBEGIN
+       AXEND
+       AXABORT
+       AXTEST
+
        ALAST
 )
 
index d94d7eaff13b409f33a6e1c5bb13ada0f344d5ee..9eb57b04cd896bdfa80b2d94a66c5a774338134d 100644 (file)
@@ -706,5 +706,11 @@ var Anames = []string{
        "FCOMIP",
        "FUCOMI",
        "FUCOMIP",
+       "XACQUIRE",
+       "XRELEASE",
+       "XBEGIN",
+       "XEND",
+       "XABORT",
+       "XTEST",
        "LAST",
 }
index 19aee0df446a74673bd16ba792c03ff057bd5f37..8bb4dff2629544ea5415990c2ecefc645075c0cb 100644 (file)
@@ -757,6 +757,14 @@ var yaes2 = []ytab{
        {Yu8, Yxm, Yxr, Zibm_r, 2},
 }
 
+var yxbegin = []ytab{
+       {Ynone, Ynone, Ybr, Zjmp, 1},
+}
+
+var yxabort = []ytab{
+       {Yu8, Ynone, Ynone, Zib_, 1},
+}
+
 /*
  * You are doasm, holding in your hand a Prog* with p->as set to, say, ACRC32,
  * and p->from and p->to as operands (Addr*).  The linker scans optab to find
@@ -1519,6 +1527,12 @@ var optab =
        {AVPAND, yxm_xm_xm, Pvex1, [23]uint8{0xdb, 0xdb}},
        {AVPBROADCASTB, yml_xr_vex, Pvex3, [23]uint8{0x78, 0x78}},
        {AVPTEST, yml_xr_vex, Pvex3, [23]uint8{0x17, 0x17}},
+       {AXACQUIRE, ynone, Px, [23]uint8{0xf2}},
+       {AXRELEASE, ynone, Px, [23]uint8{0xf3}},
+       {AXBEGIN, yxbegin, Px, [23]uint8{0xc7, 0xf8}},
+       {AXABORT, yxabort, Px, [23]uint8{0xc6, 0xf8}},
+       {AXEND, ynone, Px, [23]uint8{0x0f, 01, 0xd5}},
+       {AXTEST, ynone, Px, [23]uint8{0x0f, 01, 0xd6}},
        {obj.AUSEFIELD, ynop, Px, [23]uint8{0, 0}},
        {obj.ATYPE, nil, 0, [23]uint8{}},
        {obj.AFUNCDATA, yfuncdata, Px, [23]uint8{0, 0}},
@@ -1729,7 +1743,7 @@ func span6(ctxt *obj.Link, s *obj.LSym) {
                                                q.Back ^= 2
                                        }
 
-                                       if q.As == AJCXZL {
+                                       if q.As == AJCXZL || q.As == AXBEGIN {
                                                s.P[q.Pc+2] = byte(v)
                                        } else {
                                                s.P[q.Pc+1] = byte(v)
@@ -3432,6 +3446,10 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
                                }
                                ctxt.Andptr[0] = byte(op)
                                ctxt.Andptr = ctxt.Andptr[1:]
+                               if p.As == AXABORT {
+                                       ctxt.Andptr[0] = byte(o.op[z+1])
+                                       ctxt.Andptr = ctxt.Andptr[1:]
+                               }
                                ctxt.Andptr[0] = byte(vaddr(ctxt, p, a, nil))
                                ctxt.Andptr = ctxt.Andptr[1:]
 
@@ -3653,6 +3671,10 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
 
                        // TODO: jump across functions needs reloc
                        case Zbr, Zjmp, Zloop:
+                               if p.As == AXBEGIN {
+                                       ctxt.Andptr[0] = byte(op)
+                                       ctxt.Andptr = ctxt.Andptr[1:]
+                               }
                                if p.To.Sym != nil {
                                        if yt.zcase != Zjmp {
                                                ctxt.Diag("branch to ATEXT")
@@ -3683,7 +3705,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
 
                                if p.Back&1 != 0 {
                                        v = q.Pc - (p.Pc + 2)
-                                       if v >= -128 {
+                                       if v >= -128 && p.As != AXBEGIN {
                                                if p.As == AJCXZL {
                                                        ctxt.Andptr[0] = 0x67
                                                        ctxt.Andptr = ctxt.Andptr[1:]
@@ -3696,6 +3718,9 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
                                                ctxt.Diag("loop too far: %v", p)
                                        } else {
                                                v -= 5 - 2
+                                               if p.As == AXBEGIN {
+                                                       v--
+                                               }
                                                if yt.zcase == Zbr {
                                                        ctxt.Andptr[0] = 0x0f
                                                        ctxt.Andptr = ctxt.Andptr[1:]
@@ -3721,7 +3746,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
                                p.Forwd = q.Rel
 
                                q.Rel = p
-                               if p.Back&2 != 0 { // short
+                               if p.Back&2 != 0 && p.As != AXBEGIN { // short
                                        if p.As == AJCXZL {
                                                ctxt.Andptr[0] = 0x67
                                                ctxt.Andptr = ctxt.Andptr[1:]