MCPcopy Create free account
hub / github.com/google/gapid / Ctor

Method Ctor

core/codegen/module.go:286–307  ·  view source on GitHub ↗

Ctor creates and builds a new module constructor.

(priority int32, cb func(*Builder))

Source from the content-addressed store, hash-verified

284
285// Ctor creates and builds a new module constructor.
286func (m *Module) Ctor(priority int32, cb func(*Builder)) {
287 ctor := m.Function(m.Types.Void, "ctor")
288 ctor.Build(cb)
289
290 // TODO: Glob together multiple calls into a single table.
291 entryTy := m.ctx.StructType([]llvm.Type{
292 m.Types.Int32.llvmTy(),
293 llvm.PointerType(llvm.FunctionType(m.Types.Void.llvmTy(), []llvm.Type{}, false), 0),
294 }, false)
295
296 entries := []llvm.Value{
297 llvm.ConstStruct([]llvm.Value{
298 m.Scalar(priority).llvm,
299 ctor.llvm,
300 }, false),
301 }
302
303 table := llvm.ConstArray(entryTy, entries)
304 g := llvm.AddGlobal(m.llvm, table.Type(), "llvm.global_ctors")
305 g.SetInitializer(table)
306 g.SetLinkage(llvm.AppendingLinkage)
307}
308
309// Global is a global value.
310type Global struct {

Callers

nothing calls this directly

Calls 6

FunctionMethod · 0.95
ScalarMethod · 0.95
ConstStructMethod · 0.80
BuildMethod · 0.65
llvmTyMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected