提交 fed1a25a 编写于 作者: 3 3dgen

支持 ^&

上级 babd47c4
......@@ -489,6 +489,9 @@ func (g *functionGenerator) genBinOp(inst *ssa.BinOp) ([]wat.Inst, wir.ValueType
case token.SHR:
return g.module.EmitBinOp(x.value, y.value, wat.OpCodeShr)
case token.AND_NOT:
return g.module.EmitBinOp(x.value, y.value, wat.OpCodeAndNot)
default:
logger.Fatalf("Todo: %v, type: %T, token:%v", inst, x.value, inst.Op)
return nil, nil
......
......@@ -170,6 +170,13 @@ func (m *Module) EmitBinOp(x, y Value, op wat.OpCode) (insts []wat.Inst, ret_typ
insts = append(insts, wat.NewInstShr(toWatType(rtype)))
ret_type = m.I32
case wat.OpCodeAndNot:
insts = append(insts, x.EmitPush()...)
insts = append(insts, y.EmitPush()...)
insts = append(insts, NewConst("-1", y.Type()).EmitPush()...)
insts = append(insts, wat.NewInstXor(toWatType(rtype)))
insts = append(insts, wat.NewInstAnd(toWatType(rtype)))
default:
logger.Fatal("Todo")
}
......
......@@ -94,6 +94,7 @@ const (
OpCodeXor
OpCodeShl
OpCodeShr
OpCodeAndNot
)
/**************************************
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册