github.com/llir/llvm@v0.3.6/ir/module_global.go (about) 1 package ir 2 3 import ( 4 "github.com/llir/llvm/ir/constant" 5 "github.com/llir/llvm/ir/types" 6 ) 7 8 // --- [ Global variables ] ---------------------------------------------------- 9 10 // NewGlobal appends a new global variable declaration to the module based on 11 // the given global variable name and content type. 12 func (m *Module) NewGlobal(name string, contentType types.Type) *Global { 13 g := NewGlobal(name, contentType) 14 m.Globals = append(m.Globals, g) 15 return g 16 } 17 18 // NewGlobalDef appends a new global variable definition to the module based on 19 // the given global variable name and initial value. 20 func (m *Module) NewGlobalDef(name string, init constant.Constant) *Global { 21 g := NewGlobalDef(name, init) 22 m.Globals = append(m.Globals, g) 23 return g 24 }