From fdf907c96cc4cd677ef2931a022e265ff957c852 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 13 Apr 2018 22:17:49 +0200 Subject: [PATCH] Add some more binops --- tgo.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tgo.go b/tgo.go index 50b579e1..6c6845fe 100644 --- a/tgo.go +++ b/tgo.go @@ -346,8 +346,20 @@ func (c *Compiler) parseBinOp(frame *Frame, binop *ssa.BinOp) (llvm.Value, error // Go specific. Calculate "and not" with x & (~y) inv := c.builder.CreateNot(y, "") // ~y return c.builder.CreateAnd(x, inv, ""), nil + case token.EQL: // == + return c.builder.CreateICmp(llvm.IntEQ, x, y, ""), nil + case token.NEQ: // != + return c.builder.CreateICmp(llvm.IntNE, x, y, ""), nil + case token.LSS: // < + return c.builder.CreateICmp(llvm.IntSLT, x, y, ""), nil // TODO: ULT + case token.LEQ: // <= + return c.builder.CreateICmp(llvm.IntSLE, x, y, ""), nil // TODO: ULE + case token.GTR: // > + return c.builder.CreateICmp(llvm.IntSGT, x, y, ""), nil // TODO: UGT + case token.GEQ: // >= + return c.builder.CreateICmp(llvm.IntSGE, x, y, ""), nil // TODO: UGE default: - return llvm.Value{}, errors.New("todo: unknown binop: " + fmt.Sprintf("%#v", binop)) + return llvm.Value{}, errors.New("unknown binop") } }