Skip to content

Commit

Permalink
here we go
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
  • Loading branch information
mathetake committed May 6, 2024
1 parent 6cb2763 commit 3df6408
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
16 changes: 8 additions & 8 deletions internal/engine/wazevo/backend/isa/amd64/instr.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ func (i *instruction) String() string {
}
return fmt.Sprintf("lock xadd.%s %s, %s", suffix, i.op1.format(true), i.op2.format(true))

case keepAlive:
return fmt.Sprintf("keepAlive %s", i.op1.format(true))
case nopUseReg:
return fmt.Sprintf("nop_use_reg %s", i.op1.format(true))

default:
panic(fmt.Sprintf("BUG: %d", int(i.kind)))
Expand Down Expand Up @@ -860,8 +860,8 @@ const (
// lockxadd is xadd https://www.felixcloutier.com/x86/xadd with a lock prefix.
lockxadd

// keepAlive is a meta instruction that uses one register and does nothing.
keepAlive
// nopUseReg is a meta instruction that uses one register and does nothing.
nopUseReg

instrMax
)
Expand All @@ -871,8 +871,8 @@ func (i *instruction) asMFence() *instruction {
return i
}

func (i *instruction) asKeepAlive(r regalloc.VReg) *instruction {
i.kind = keepAlive
func (i *instruction) asNopUseReg(r regalloc.VReg) *instruction {
i.kind = nopUseReg
i.op1 = newOperandReg(r)
return i
}
Expand Down Expand Up @@ -2366,7 +2366,7 @@ var defKinds = [instrMax]defKind{
lockcmpxchg: defKindNone,
lockxadd: defKindNone,
neg: defKindNone,
keepAlive: defKindNone,
nopUseReg: defKindNone,
}

// String implements fmt.Stringer.
Expand Down Expand Up @@ -2449,7 +2449,7 @@ var useKinds = [instrMax]useKind{
lockcmpxchg: useKindRaxOp1RegOp2,
lockxadd: useKindOp1RegOp2,
neg: useKindOp1,
keepAlive: useKindOp1,
nopUseReg: useKindOp1,
}

func (u useKind) String() string {
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/wazevo/backend/isa/amd64/instr_encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func (i *instruction) encode(c backend.Compiler) (needsLabelResolution bool) {
switch kind := i.kind; kind {
case nop0, sourceOffsetInfo, defineUninitializedReg, fcvtToSintSequence, fcvtToUintSequence, keepAlive:
case nop0, sourceOffsetInfo, defineUninitializedReg, fcvtToSintSequence, fcvtToUintSequence, nopUseReg:
case ret:
encodeRet(c)
case imm:
Expand Down
8 changes: 7 additions & 1 deletion internal/engine/wazevo/backend/isa/amd64/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ func (m *machine) lowerAtomicRmw(op ssa.AtomicRmwOp, addr, val ssa.Value, size u
}

// valCopied must be alive at the end of the loop.
m.insert(m.allocateInstr().asKeepAlive(valCopied))
m.insert(m.allocateInstr().asNopUseReg(valCopied))

// At this point, accumulator contains the result.
m.clearHigherBitsForAtomic(accumulator, size, ret.Type())
Expand Down Expand Up @@ -1798,6 +1798,12 @@ func (m *machine) lowerCall(si *ssa.Instruction) {
m.insert(callInd)
}

if isMemmove {
for i := regalloc.RealReg(0); i < 16; i++ {
m.insert(m.allocateInstr().asNopUseReg(regInfo.RealRegToVReg[xmm0+i]))
}
}

var index int
r1, rs := si.Returns()
if r1.Valid() {
Expand Down

0 comments on commit 3df6408

Please sign in to comment.