Merge pull request #539 from visualfc/bineq
ssa: fix binop closure/funcdecl
This commit is contained in:
@@ -10,10 +10,15 @@ func init() {
|
||||
fn3 := func() { println(n) }
|
||||
var fn4 func() int
|
||||
assert(test != nil)
|
||||
assert(nil != test)
|
||||
assert(fn1 != nil)
|
||||
assert(nil != fn1)
|
||||
assert(fn2 != nil)
|
||||
assert(nil != fn2)
|
||||
assert(fn3 != nil)
|
||||
assert(nil != fn3)
|
||||
assert(fn4 == nil)
|
||||
assert(nil == fn4)
|
||||
}
|
||||
|
||||
// array
|
||||
|
||||
@@ -96,7 +96,15 @@ _llgo_0:
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
%7 = extractvalue { ptr, ptr } %6, 0
|
||||
%8 = icmp ne ptr %7, null
|
||||
call void @main.assert(i1 %8)
|
||||
%9 = extractvalue { ptr, ptr } %6, 0
|
||||
%10 = icmp ne ptr null, %9
|
||||
call void @main.assert(i1 %10)
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
ret void
|
||||
|
||||
27
ssa/expr.go
27
ssa/expr.go
@@ -501,12 +501,6 @@ func (b Builder) BinOp(op token.Token, x, y Expr) Expr {
|
||||
case vkUnsigned, vkPtr:
|
||||
pred := uintPredOpToLLVM[op-predOpBase]
|
||||
return Expr{llvm.CreateICmp(b.impl, pred, x.impl, y.impl), tret}
|
||||
case vkMap:
|
||||
switch op {
|
||||
case token.EQL, token.NEQ:
|
||||
pred := uintPredOpToLLVM[op-predOpBase]
|
||||
return Expr{llvm.CreateICmp(b.impl, pred, x.impl, y.impl), tret}
|
||||
}
|
||||
case vkFloat:
|
||||
pred := floatPredOpToLLVM[op-predOpBase]
|
||||
return Expr{llvm.CreateFCmp(b.impl, pred, x.impl, y.impl), tret}
|
||||
@@ -554,21 +548,18 @@ func (b Builder) BinOp(op token.Token, x, y Expr) Expr {
|
||||
}
|
||||
case vkClosure:
|
||||
x = b.Field(x, 0)
|
||||
if y.kind == vkClosure {
|
||||
y = b.Field(y, 0)
|
||||
}
|
||||
fallthrough
|
||||
case vkFuncPtr, vkFuncDecl, vkChan, vkMap:
|
||||
if y.kind == vkClosure {
|
||||
y = b.Field(y, 0)
|
||||
fallthrough
|
||||
case vkFuncPtr, vkFuncDecl:
|
||||
switch op {
|
||||
case token.EQL: // TODO(xsw): check this code
|
||||
return b.Prog.BoolVal(x.impl.IsNull() == y.impl.IsNull())
|
||||
case token.NEQ:
|
||||
return b.Prog.BoolVal(x.impl.IsNull() != y.impl.IsNull())
|
||||
}
|
||||
case vkChan:
|
||||
switch op {
|
||||
case token.EQL:
|
||||
return Expr{llvm.CreateICmp(b.impl, llvm.IntEQ, x.impl, y.impl), tret}
|
||||
case token.NEQ:
|
||||
return Expr{llvm.CreateICmp(b.impl, llvm.IntNE, x.impl, y.impl), tret}
|
||||
case token.EQL, token.NEQ:
|
||||
pred := uintPredOpToLLVM[op-predOpBase]
|
||||
return Expr{llvm.CreateICmp(b.impl, pred, x.impl, y.impl), tret}
|
||||
}
|
||||
case vkArray:
|
||||
typ := x.raw.Type.(*types.Array)
|
||||
|
||||
Reference in New Issue
Block a user