Merge remote-tracking branch 'gop/main' into q
This commit is contained in:
11
cl/_testdata/untyped/in.go
Normal file
11
cl/_testdata/untyped/in.go
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
const c = 100
|
||||||
|
|
||||||
|
var a float64 = 1
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if c > 100 {
|
||||||
|
a = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
32
cl/_testdata/untyped/out.ll
Normal file
32
cl/_testdata/untyped/out.ll
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
; ModuleID = 'main'
|
||||||
|
source_filename = "main"
|
||||||
|
|
||||||
|
@main.a = global ptr null
|
||||||
|
@"main.init$guard" = global ptr null
|
||||||
|
|
||||||
|
define void @main.init() {
|
||||||
|
_llgo_0:
|
||||||
|
%0 = load i1, ptr @"main.init$guard", align 1
|
||||||
|
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||||
|
|
||||||
|
_llgo_1: ; preds = %_llgo_0
|
||||||
|
store i1 true, ptr @"main.init$guard", align 1
|
||||||
|
store double 1.000000e+00, ptr @main.a, align 8
|
||||||
|
br label %_llgo_2
|
||||||
|
|
||||||
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @main() {
|
||||||
|
_llgo_0:
|
||||||
|
call void @main.init()
|
||||||
|
br i1 false, label %_llgo_1, label %_llgo_2
|
||||||
|
|
||||||
|
_llgo_1: ; preds = %_llgo_0
|
||||||
|
store double 0.000000e+00, ptr @main.a, align 8
|
||||||
|
br label %_llgo_2
|
||||||
|
|
||||||
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||||
|
ret void
|
||||||
|
}
|
||||||
@@ -484,7 +484,7 @@ func (p *context) compileValue(b llssa.Builder, v ssa.Value) llssa.Expr {
|
|||||||
g := p.varOf(v)
|
g := p.varOf(v)
|
||||||
return g.Expr
|
return g.Expr
|
||||||
case *ssa.Const:
|
case *ssa.Const:
|
||||||
t := v.Type()
|
t := types.Default(v.Type())
|
||||||
return b.Const(v.Value, p.prog.Type(t))
|
return b.Const(v.Value, p.prog.Type(t))
|
||||||
}
|
}
|
||||||
panic(fmt.Sprintf("compileValue: unknown value - %T\n", v))
|
panic(fmt.Sprintf("compileValue: unknown value - %T\n", v))
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ func (b Builder) Const(v constant.Value, typ Type) Expr {
|
|||||||
if v == nil {
|
if v == nil {
|
||||||
return prog.Null(typ)
|
return prog.Null(typ)
|
||||||
}
|
}
|
||||||
switch t := types.Default(typ.t).(type) {
|
switch t := typ.t.(type) {
|
||||||
case *types.Basic:
|
case *types.Basic:
|
||||||
kind := t.Kind()
|
kind := t.Kind()
|
||||||
switch {
|
switch {
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ func (p Program) tyInt64() llvm.Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p Program) toLLVMType(typ types.Type) Type {
|
func (p Program) toLLVMType(typ types.Type) Type {
|
||||||
switch t := types.Default(typ).(type) {
|
switch t := typ.(type) {
|
||||||
case *types.Basic:
|
case *types.Basic:
|
||||||
switch t.Kind() {
|
switch t.Kind() {
|
||||||
case types.Int:
|
case types.Int:
|
||||||
|
|||||||
Reference in New Issue
Block a user