MCPcopy
hub / github.com/tinygo-org/tinygo / LowerInterfaces

Function LowerInterfaces

transform/interface-lowering.go:111–137  ·  view source on GitHub ↗

LowerInterfaces lowers all intermediate interface calls and globals that are emitted by the compiler as higher-level intrinsics. They need some lowering before LLVM can work on them. This is done so that a few cleanup passes can run before assigning the final type codes.

(mod llvm.Module, config *compileopts.Config)

Source from the content-addressed store, hash-verified

109// before LLVM can work on them. This is done so that a few cleanup passes can
110// run before assigning the final type codes.
111func LowerInterfaces(mod llvm.Module, config *compileopts.Config) error {
112 ctx := mod.Context()
113 targetData := llvm.NewTargetData(mod.DataLayout())
114 defer targetData.Dispose()
115 p := &lowerInterfacesPass{
116 mod: mod,
117 config: config,
118 builder: ctx.NewBuilder(),
119 ctx: ctx,
120 targetData: targetData,
121 uintptrType: mod.Context().IntType(targetData.PointerSize() * 8),
122 ptrType: llvm.PointerType(ctx.Int8Type(), 0),
123 types: make(map[string]*typeInfo),
124 signatures: make(map[string]*signatureInfo),
125 interfaces: make(map[string]*interfaceInfo),
126 }
127 defer p.builder.Dispose()
128
129 if config.Debug() {
130 p.dibuilder = llvm.NewDIBuilder(mod)
131 defer p.dibuilder.Destroy()
132 defer p.dibuilder.Finalize()
133 p.difiles = make(map[string]llvm.Metadata)
134 }
135
136 return p.run()
137}
138
139// run runs the pass itself.
140func (p *lowerInterfacesPass) run() error {

Callers 2

TestInterfaceLoweringFunction · 0.92
OptimizeFunction · 0.85

Calls 3

runMethod · 0.95
DebugMethod · 0.80
ContextMethod · 0.65

Tested by 1

TestInterfaceLoweringFunction · 0.74