Skip to content

Commit

Permalink
I think this is less error prone
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <[email protected]>
  • Loading branch information
mathetake committed Mar 6, 2024
1 parent 232eb01 commit c367b44
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions internal/engine/wazevo/backend/isa/amd64/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1082,8 +1082,23 @@ func (m *machine) lowerAtomicCas(addr, exp, repl ssa.Value, size uint64, ret ssa
}

func (m *machine) clearHigherBitsForAtomic(r regalloc.VReg, valSize uint64, resultType ssa.Type) {
if byte(valSize) < resultType.Size() {
m.insert(m.allocateInstr().asAluRmiR(aluRmiROpcodeAnd, newOperandImm32(uint32((1<<(8*valSize))-1)), r, false))
switch resultType {
case ssa.TypeI32:
switch valSize {
case 1:
m.insert(m.allocateInstr().asMovzxRmR(extModeBL, newOperandReg(r), r))
case 2:
m.insert(m.allocateInstr().asMovzxRmR(extModeWL, newOperandReg(r), r))
}
case ssa.TypeI64:
switch valSize {
case 1:
m.insert(m.allocateInstr().asMovzxRmR(extModeBQ, newOperandReg(r), r))
case 2:
m.insert(m.allocateInstr().asMovzxRmR(extModeWQ, newOperandReg(r), r))
case 4:
m.insert(m.allocateInstr().asMovzxRmR(extModeLQ, newOperandReg(r), r))
}
}
}

Expand Down

0 comments on commit c367b44

Please sign in to comment.