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)
| 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. |
| 111 | func 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. |
| 140 | func (p *lowerInterfacesPass) run() error { |