diff --git a/llvm/_core.cpp b/llvm/_core.cpp index 73d6099..51b595c 100644 --- a/llvm/_core.cpp +++ b/llvm/_core.cpp @@ -607,8 +607,9 @@ _wrap_obj2obj(LLVMGetAlignment, LLVMValueRef, int) _wrap_objint2none(LLVMSetAlignment, LLVMValueRef) /*===-- Global Variables -------------------------------------------------===*/ - + _wrap_objobjstr2obj(LLVMAddGlobal, LLVMModuleRef, LLVMTypeRef, LLVMValueRef) +_wrap_objobjstrint2obj(LLVMAddGlobalInAddressSpace, LLVMModuleRef, LLVMTypeRef, LLVMValueRef) _wrap_objstr2obj(LLVMGetNamedGlobal, LLVMModuleRef, LLVMValueRef) _wrap_obj2obj(LLVMGetFirstGlobal, LLVMModuleRef, LLVMValueRef) _wrap_obj2obj(LLVMGetNextGlobal, LLVMValueRef, LLVMValueRef) @@ -1744,6 +1745,7 @@ static PyMethodDef core_methods[] = { /* Global Variables */ _method( LLVMAddGlobal ) + _method( LLVMAddGlobalInAddressSpace ) _method( LLVMGetNamedGlobal ) _method( LLVMGetFirstGlobal ) _method( LLVMGetNextGlobal ) diff --git a/llvm/core.py b/llvm/core.py index b9e156c..cc47662 100644 --- a/llvm/core.py +++ b/llvm/core.py @@ -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):