support complex debug info
This commit is contained in:
@@ -11,24 +11,24 @@ type E struct {
|
|||||||
i int
|
i int
|
||||||
}
|
}
|
||||||
type StructWithAllTypeFields struct {
|
type StructWithAllTypeFields struct {
|
||||||
i8 int8
|
i8 int8
|
||||||
i16 int16
|
i16 int16
|
||||||
i32 int32
|
i32 int32
|
||||||
i64 int64
|
i64 int64
|
||||||
i int
|
i int
|
||||||
u8 uint8
|
u8 uint8
|
||||||
u16 uint16
|
u16 uint16
|
||||||
u32 uint32
|
u32 uint32
|
||||||
u64 uint64
|
u64 uint64
|
||||||
u uint
|
u uint
|
||||||
f32 float32
|
f32 float32
|
||||||
f64 float64
|
f64 float64
|
||||||
b bool
|
b bool
|
||||||
// c64 complex64
|
c64 complex64
|
||||||
// c128 complex128
|
c128 complex128
|
||||||
// slice []int
|
// slice []int
|
||||||
// arr [3]int
|
// arr [3]int
|
||||||
// s string
|
// s string
|
||||||
e E
|
e E
|
||||||
// pf *StructWithAllTypeFields // resursive
|
// pf *StructWithAllTypeFields // resursive
|
||||||
// pi *int
|
// pi *int
|
||||||
@@ -68,8 +68,8 @@ func FuncWithAllTypeParams(
|
|||||||
f32 float32,
|
f32 float32,
|
||||||
f64 float64,
|
f64 float64,
|
||||||
b bool,
|
b bool,
|
||||||
// c64 complex64,
|
c64 complex64,
|
||||||
// c128 complex128,
|
c128 complex128,
|
||||||
// slice []int,
|
// slice []int,
|
||||||
// arr [3]int,
|
// arr [3]int,
|
||||||
// s string,
|
// s string,
|
||||||
@@ -86,7 +86,8 @@ func FuncWithAllTypeParams(
|
|||||||
println(
|
println(
|
||||||
i8, i16, i32, i64, i, u8, u16, u32, u64, u,
|
i8, i16, i32, i64, i, u8, u16, u32, u64, u,
|
||||||
f32, f64, b,
|
f32, f64, b,
|
||||||
// c64, c128, slice, arr[0:],
|
c64, c128,
|
||||||
|
// slice, arr[0:],
|
||||||
// s, &e, &f, pf, pi, intr, m, c, err,
|
// s, &e, &f, pf, pi, intr, m, c, err,
|
||||||
// fn,
|
// fn,
|
||||||
)
|
)
|
||||||
@@ -96,21 +97,21 @@ func FuncWithAllTypeParams(
|
|||||||
func main() {
|
func main() {
|
||||||
i := 100
|
i := 100
|
||||||
s := StructWithAllTypeFields{
|
s := StructWithAllTypeFields{
|
||||||
i8: 1,
|
i8: 1,
|
||||||
i16: 2,
|
i16: 2,
|
||||||
i32: 3,
|
i32: 3,
|
||||||
i64: 4,
|
i64: 4,
|
||||||
i: 5,
|
i: 5,
|
||||||
u8: 6,
|
u8: 6,
|
||||||
u16: 7,
|
u16: 7,
|
||||||
u32: 8,
|
u32: 8,
|
||||||
u64: 9,
|
u64: 9,
|
||||||
u: 10,
|
u: 10,
|
||||||
f32: 11,
|
f32: 11,
|
||||||
f64: 12,
|
f64: 12,
|
||||||
b: true,
|
b: true,
|
||||||
// c64: 13 + 14i,
|
c64: 13 + 14i,
|
||||||
// c128: 15 + 16i,
|
c128: 15 + 16i,
|
||||||
// slice: []int{21, 22, 23},
|
// slice: []int{21, 22, 23},
|
||||||
// arr: [3]int{24, 25, 26},
|
// arr: [3]int{24, 25, 26},
|
||||||
// s: "hello",
|
// s: "hello",
|
||||||
@@ -132,7 +133,8 @@ func main() {
|
|||||||
i, err := FuncWithAllTypeParams(
|
i, err := FuncWithAllTypeParams(
|
||||||
s.i8, s.i16, s.i32, s.i64, s.i, s.u8, s.u16, s.u32, s.u64, s.u,
|
s.i8, s.i16, s.i32, s.i64, s.i, s.u8, s.u16, s.u32, s.u64, s.u,
|
||||||
s.f32, s.f64, s.b,
|
s.f32, s.f64, s.b,
|
||||||
// s.c64, s.c128, s.slice, s.arr, s.s,
|
s.c64, s.c128,
|
||||||
|
// s.slice, s.arr, s.s,
|
||||||
s.e, s,
|
s.e, s,
|
||||||
// s.pf, s.pi,
|
// s.pf, s.pi,
|
||||||
// s.intr, s.m, s.c, s.err,
|
// s.intr, s.m, s.c, s.err,
|
||||||
|
|||||||
59
ssa/di.go
59
ssa/di.go
@@ -133,7 +133,7 @@ func (b diBuilder) createType(ty Type, pos token.Position) DIType {
|
|||||||
} else if t.Info()&types.IsFloat != 0 {
|
} else if t.Info()&types.IsFloat != 0 {
|
||||||
encoding = llvm.DW_ATE_float
|
encoding = llvm.DW_ATE_float
|
||||||
} else if t.Info()&types.IsComplex != 0 {
|
} else if t.Info()&types.IsComplex != 0 {
|
||||||
encoding = llvm.DW_ATE_complex_float
|
return b.createComplexType(ty)
|
||||||
} else if t.Info()&types.IsString != 0 {
|
} else if t.Info()&types.IsString != 0 {
|
||||||
typ = b.di.CreateBasicType(llvm.DIBasicType{
|
typ = b.di.CreateBasicType(llvm.DIBasicType{
|
||||||
Name: "string",
|
Name: "string",
|
||||||
@@ -264,6 +264,49 @@ func (b diBuilder) createBasicType(t Type) DIType {
|
|||||||
})}
|
})}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b diBuilder) createComplexType(t Type) DIType {
|
||||||
|
var tfield Type
|
||||||
|
if t.RawType().(*types.Basic).Kind() == types.Complex128 {
|
||||||
|
tfield = b.prog.Float64()
|
||||||
|
} else {
|
||||||
|
tfield = b.prog.Float32()
|
||||||
|
}
|
||||||
|
traw := tfield.RawType().Underlying()
|
||||||
|
return &aDIType{ll: b.di.CreateStructType(
|
||||||
|
llvm.Metadata{},
|
||||||
|
llvm.DIStructType{
|
||||||
|
Name: t.RawType().String(),
|
||||||
|
File: llvm.Metadata{},
|
||||||
|
Line: 0,
|
||||||
|
SizeInBits: b.prog.SizeOf(t) * 8,
|
||||||
|
AlignInBits: uint32(b.prog.sizes.Alignof(t.RawType()) * 8),
|
||||||
|
Elements: []llvm.Metadata{
|
||||||
|
b.di.CreateMemberType(
|
||||||
|
llvm.Metadata{},
|
||||||
|
llvm.DIMemberType{
|
||||||
|
Name: "real",
|
||||||
|
File: llvm.Metadata{},
|
||||||
|
Line: 0,
|
||||||
|
SizeInBits: b.prog.SizeOf(tfield) * 8,
|
||||||
|
AlignInBits: uint32(b.prog.sizes.Alignof(traw) * 8),
|
||||||
|
Type: b.diType(tfield, token.Position{}).ll,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
b.di.CreateMemberType(
|
||||||
|
llvm.Metadata{},
|
||||||
|
llvm.DIMemberType{
|
||||||
|
Name: "imag",
|
||||||
|
File: llvm.Metadata{},
|
||||||
|
Line: 0,
|
||||||
|
SizeInBits: b.prog.SizeOf(tfield) * 8,
|
||||||
|
AlignInBits: uint32(b.prog.sizes.Alignof(traw) * 8),
|
||||||
|
Type: b.diType(tfield, token.Position{}).ll,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
})}
|
||||||
|
}
|
||||||
|
|
||||||
func (b diBuilder) createPointerType(ty Type, pos token.Position) DIType {
|
func (b diBuilder) createPointerType(ty Type, pos token.Position) DIType {
|
||||||
return &aDIType{ll: b.di.CreatePointerType(llvm.DIPointerType{
|
return &aDIType{ll: b.di.CreatePointerType(llvm.DIPointerType{
|
||||||
Pointee: b.diType(ty, pos).ll,
|
Pointee: b.diType(ty, pos).ll,
|
||||||
@@ -433,7 +476,17 @@ func (b Builder) allocatedVar(v Expr) (Expr, bool) {
|
|||||||
}
|
}
|
||||||
t := v.Type.RawType().Underlying()
|
t := v.Type.RawType().Underlying()
|
||||||
var ty Type
|
var ty Type
|
||||||
switch t.(type) {
|
switch t := t.(type) {
|
||||||
|
case *types.Basic:
|
||||||
|
if t.Info()&types.IsComplex != 0 {
|
||||||
|
if t.Kind() == types.Complex128 {
|
||||||
|
ty = b.Prog.Complex128()
|
||||||
|
} else {
|
||||||
|
ty = b.Prog.Complex64()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return v, false
|
||||||
|
}
|
||||||
case *types.Struct:
|
case *types.Struct:
|
||||||
ty = v.Type
|
ty = v.Type
|
||||||
case *types.Slice:
|
case *types.Slice:
|
||||||
@@ -462,8 +515,6 @@ func skipType(t types.Type) bool {
|
|||||||
case *types.Basic:
|
case *types.Basic:
|
||||||
if t.Info()&types.IsString != 0 {
|
if t.Info()&types.IsString != 0 {
|
||||||
return true
|
return true
|
||||||
} else if t.Info()&types.IsComplex != 0 {
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user