Skip to content

Commit 92f7635

Browse files
committed
ssa: clean code
1 parent 6e16e58 commit 92f7635

File tree

3 files changed

+3
-143
lines changed

3 files changed

+3
-143
lines changed

cl/compile.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,6 @@ func NewPackageEx(prog llssa.Program, patches Patches, rewrites map[string]strin
11401140
ctx.initFiles(pkgPath, files, pkgName == "C")
11411141
ctx.prog.SetPatch(ctx.patchType)
11421142
ctx.prog.SetCheckRuntimeNamed(ctx.checkRuntimeNamed)
1143-
ret.SetPatch(ctx.patchType)
11441143
ret.SetResolveLinkname(ctx.resolveLinkname)
11451144

11461145
if hasPatch {

runtime/internal/runtime/z_type.go

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -25,114 +25,6 @@ import (
2525
type Kind = abi.Kind
2626
type Type = abi.Type
2727

28-
// -----------------------------------------------------------------------------
29-
var (
30-
tyBasic [abi.UnsafePointer + 1]*Type
31-
)
32-
33-
func basicEqual(kind Kind, size uintptr) func(a, b unsafe.Pointer) bool {
34-
switch kind {
35-
case abi.Bool, abi.Int, abi.Int8, abi.Int16, abi.Int32, abi.Int64,
36-
abi.Uint, abi.Uint8, abi.Uint16, abi.Uint32, abi.Uint64, abi.Uintptr:
37-
switch size {
38-
case 1:
39-
return memequal8
40-
case 2:
41-
return memequal16
42-
case 4:
43-
return memequal32
44-
case 8:
45-
return memequal64
46-
}
47-
case abi.Float32:
48-
return f32equal
49-
case abi.Float64:
50-
return f64equal
51-
case abi.Complex64:
52-
return c64equal
53-
case abi.Complex128:
54-
return c128equal
55-
case abi.String:
56-
return strequal
57-
case abi.UnsafePointer:
58-
return memequalptr
59-
}
60-
panic("unreachable")
61-
}
62-
63-
func basicFlags(kind Kind) abi.TFlag {
64-
switch kind {
65-
case abi.Float32, abi.Float64, abi.Complex64, abi.Complex128, abi.String:
66-
return 0
67-
}
68-
return abi.TFlagRegularMemory
69-
}
70-
71-
func Basic(_kind Kind) *Type {
72-
kind := _kind & abi.KindMask
73-
if tyBasic[kind] == nil {
74-
name, size, align := basicTypeInfo(kind)
75-
var ptrBytes uintptr
76-
if kind == abi.String || kind == abi.UnsafePointer {
77-
ptrBytes = pointerSize
78-
}
79-
tyBasic[kind] = &Type{
80-
Size_: size,
81-
PtrBytes: ptrBytes,
82-
Hash: uint32(kind),
83-
Align_: uint8(align),
84-
FieldAlign_: uint8(align),
85-
Kind_: uint8(_kind),
86-
Equal: basicEqual(kind, size),
87-
TFlag: basicFlags(kind),
88-
Str_: name,
89-
}
90-
}
91-
return tyBasic[kind]
92-
}
93-
94-
func basicTypeInfo(kind abi.Kind) (string, uintptr, uintptr) {
95-
switch kind {
96-
case abi.Bool:
97-
return "bool", unsafe.Sizeof(false), unsafe.Alignof(false)
98-
case abi.Int:
99-
return "int", unsafe.Sizeof(0), unsafe.Alignof(0)
100-
case abi.Int8:
101-
return "int8", 1, 1
102-
case abi.Int16:
103-
return "int16", 2, 2
104-
case abi.Int32:
105-
return "int32", 4, 4
106-
case abi.Int64:
107-
return "int64", 8, 8
108-
case abi.Uint:
109-
return "uint", unsafe.Sizeof(uint(0)), unsafe.Alignof(uint(0))
110-
case abi.Uint8:
111-
return "uint8", 1, 1
112-
case abi.Uint16:
113-
return "uint16", 2, 2
114-
case abi.Uint32:
115-
return "uint32", 4, 4
116-
case abi.Uint64:
117-
return "uint64", 8, 8
118-
case abi.Uintptr:
119-
return "uintptr", unsafe.Sizeof(uintptr(0)), unsafe.Alignof(uintptr(0))
120-
case abi.Float32:
121-
return "float32", 4, 4
122-
case abi.Float64:
123-
return "float64", 8, 8
124-
case abi.Complex64:
125-
return "complex64", 8, 4
126-
case abi.Complex128:
127-
return "complex128", 16, 8
128-
case abi.String:
129-
return "string", unsafe.Sizeof(String{}), unsafe.Alignof("")
130-
case abi.UnsafePointer:
131-
return "unsafe.Pointer", unsafe.Sizeof(unsafe.Pointer(nil)), unsafe.Alignof(unsafe.Pointer(nil))
132-
}
133-
panic("unreachable")
134-
}
135-
13628
// -----------------------------------------------------------------------------
13729

13830
// StructField returns a struct field.
@@ -579,10 +471,6 @@ func (r *rtypes) addType(typ *Type) {
579471

580472
var rtypeList rtypes
581473

582-
func addType(typ *abi.Type) {
583-
rtypeList.addType(typ)
584-
}
585-
586474
func initTypes(typs *[]*abi.Type) {
587475
rtypeList.types = *typs
588476
}

ssa/package.go

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,12 @@ func (p Program) NewPackage(name, pkgPath string) Package {
435435
pyobjs := make(map[string]PyObjRef)
436436
pymods := make(map[string]Global)
437437
strs := make(map[string]llvm.Value)
438-
chkabi := make(map[types.Type]bool)
439438
glbDbgVars := make(map[Expr]bool)
440439
// Don't need reset p.needPyInit here
441440
// p.needPyInit = false
442441
ret := &aPackage{
443-
mod: mod, vars: gbls, fns: fns,
442+
mod: mod, Prog: p, vars: gbls, fns: fns,
444443
pyobjs: pyobjs, pymods: pymods, strs: strs,
445-
chkabi: chkabi, Prog: p,
446444
di: nil, cu: nil, glbDbgVars: glbDbgVars,
447445
export: make(map[string]string),
448446
}
@@ -709,9 +707,6 @@ type aPackage struct {
709707
pymods map[string]Global
710708
strs map[string]llvm.Value
711709
goStrs map[string]llvm.Value
712-
chkabi map[types.Type]bool
713-
afterb unsafe.Pointer
714-
patch func(types.Type) types.Type
715710
fnlink func(string) string
716711

717712
iRoutine int
@@ -785,41 +780,19 @@ func (p Package) String() string {
785780
return p.mod.String()
786781
}
787782

788-
// SetPatch sets a patch function.
789-
func (p Package) SetPatch(fn func(types.Type) types.Type) {
790-
p.patch = fn
791-
}
792-
793783
// SetResolveLinkname sets a function to resolve linkname.
794784
func (p Package) SetResolveLinkname(fn func(string) string) {
795785
p.fnlink = fn
796786
}
797787

798788
// -----------------------------------------------------------------------------
799789

800-
func (p Package) afterBuilder() Builder {
801-
if p.afterb == nil {
802-
fn := p.NewFunc(p.Path()+".init$after", NoArgsNoRet, InC)
803-
fnb := fn.MakeBody(1)
804-
p.afterb = unsafe.Pointer(fnb)
805-
}
806-
return Builder(p.afterb)
807-
}
808-
809790
// AfterInit is called after the package is initialized (init all packages that depends on).
810791
func (p Package) AfterInit(b Builder, ret BasicBlock) {
811-
doAfterb := p.afterb != nil
812792
doPyLoadModSyms := p.pyHasModSyms()
813-
if doAfterb || doPyLoadModSyms {
793+
if doPyLoadModSyms {
814794
b.SetBlockEx(ret, afterInit, false)
815-
if doAfterb {
816-
afterb := Builder(p.afterb)
817-
afterb.Return()
818-
b.Call(afterb.Func.Expr)
819-
}
820-
if doPyLoadModSyms {
821-
p.pyLoadModSyms(b)
822-
}
795+
p.pyLoadModSyms(b)
823796
}
824797
}
825798

0 commit comments

Comments
 (0)