Add address-space control to global-variable

This commit is contained in:
Siu Kwan Lam 2012-10-26 14:08:33 -05:00
commit daa62d9f78
2 changed files with 7 additions and 5 deletions

View file

@ -478,9 +478,9 @@ class Module(llvm.Ownable, llvm.Cacheable):
return _make_type(ptr, kind)
return None
def add_global_variable(self, ty, name):
def add_global_variable(self, ty, name, addrspace=0):
"""Add a global variable of given type with given name."""
return GlobalVariable.new(self, ty, name)
return GlobalVariable.new(self, ty, name, addrspace)
def get_global_variable_named(self, name):
"""Return a GlobalVariable object for the given name."""
@ -1337,10 +1337,10 @@ class GlobalValue(Constant):
class GlobalVariable(GlobalValue):
@staticmethod
def new(module, ty, name):
def new(module, ty, name, addrspace=0):
check_is_module(module)
check_is_type(ty)
return _make_value(_core.LLVMAddGlobal(module.ptr, ty.ptr, name))
return _make_value(_core.LLVMAddGlobalInAddressSpace(module.ptr, ty.ptr, name, addrspace))
@staticmethod
def get(module, name):