Sergey Arseev uploaded a change:
https://go-review.googlesource.com/16479
cmd/internal/obj/x86: Added support for TSX instructions.
Transactional memory, will later be used for semaphore implementation. Nacl
not supported yet.
Change-Id: Ic18453dcaa08d07bb217c0b95461584f007d518b
---
M src/cmd/asm/internal/arch/arch.go
M src/cmd/internal/obj/x86/a.out.go
M src/cmd/internal/obj/x86/anames.go
M src/cmd/internal/obj/x86/asm6.go
4 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/src/cmd/asm/internal/arch/arch.go
b/src/cmd/asm/internal/arch/arch.go
index 04622e6..4162a81 100644
--- a/src/cmd/asm/internal/arch/arch.go
+++ b/src/cmd/asm/internal/arch/arch.go
@@ -78,7 +78,7 @@
}
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 {
diff --git a/src/cmd/internal/obj/x86/a.out.go
b/src/cmd/internal/obj/x86/a.out.go
index 108ca6a..4c10344 100644
--- a/src/cmd/internal/obj/x86/a.out.go
+++ b/src/cmd/internal/obj/x86/a.out.go
@@ -762,6 +762,14 @@
AFUCOMI
AFUCOMIP
+ //TSX
+ AXACQUIRE
+ AXRELEASE
+ AXBEGIN
+ AXEND
+ AXABORT
+ AXTEST
+
ALAST
)
diff --git a/src/cmd/internal/obj/x86/anames.go
b/src/cmd/internal/obj/x86/anames.go
index c075a15..520d24c 100644
--- a/src/cmd/internal/obj/x86/anames.go
+++ b/src/cmd/internal/obj/x86/anames.go
@@ -700,5 +700,11 @@
"FCOMIP",
"FUCOMI",
"FUCOMIP",
+ "XACQUIRE",
+ "XRELEASE",
+ "XBEGIN",
+ "XEND",
+ "XABORT",
+ "XTEST",
"LAST",
}
diff --git a/src/cmd/internal/obj/x86/asm6.go
b/src/cmd/internal/obj/x86/asm6.go
index f03df5b..0629e23 100644
--- a/src/cmd/internal/obj/x86/asm6.go
+++ b/src/cmd/internal/obj/x86/asm6.go
@@ -741,6 +741,14 @@
{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
@@ -1497,6 +1505,12 @@
{AMOVHDU, yxmov_vex, Pvex2, [23]uint8{0x6f, 0x7f}},
{AMOVNTHD, yxr_ml_vex, Pvex1, [23]uint8{0xe7}},
{AMOVHDA, yxmov_vex, Pvex1, [23]uint8{0x6f, 0x7f}},
+ {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}},
@@ -1707,7 +1721,7 @@
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)
@@ -3343,6 +3357,10 @@
}
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:]
@@ -3564,6 +3582,10 @@
// 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")
@@ -3594,7 +3616,7 @@
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:]
@@ -3607,6 +3629,9 @@
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:]
@@ -3632,7 +3657,7 @@
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:]
--
https://go-review.googlesource.com/16479