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

@ -607,8 +607,9 @@ _wrap_obj2obj(LLVMGetAlignment, LLVMValueRef, int)
_wrap_objint2none(LLVMSetAlignment, LLVMValueRef) _wrap_objint2none(LLVMSetAlignment, LLVMValueRef)
/*===-- Global Variables -------------------------------------------------===*/ /*===-- Global Variables -------------------------------------------------===*/
_wrap_objobjstr2obj(LLVMAddGlobal, LLVMModuleRef, LLVMTypeRef, LLVMValueRef) _wrap_objobjstr2obj(LLVMAddGlobal, LLVMModuleRef, LLVMTypeRef, LLVMValueRef)
_wrap_objobjstrint2obj(LLVMAddGlobalInAddressSpace, LLVMModuleRef, LLVMTypeRef, LLVMValueRef)
_wrap_objstr2obj(LLVMGetNamedGlobal, LLVMModuleRef, LLVMValueRef) _wrap_objstr2obj(LLVMGetNamedGlobal, LLVMModuleRef, LLVMValueRef)
_wrap_obj2obj(LLVMGetFirstGlobal, LLVMModuleRef, LLVMValueRef) _wrap_obj2obj(LLVMGetFirstGlobal, LLVMModuleRef, LLVMValueRef)
_wrap_obj2obj(LLVMGetNextGlobal, LLVMValueRef, LLVMValueRef) _wrap_obj2obj(LLVMGetNextGlobal, LLVMValueRef, LLVMValueRef)
@ -1744,6 +1745,7 @@ static PyMethodDef core_methods[] = {
/* Global Variables */ /* Global Variables */
_method( LLVMAddGlobal ) _method( LLVMAddGlobal )
_method( LLVMAddGlobalInAddressSpace )
_method( LLVMGetNamedGlobal ) _method( LLVMGetNamedGlobal )
_method( LLVMGetFirstGlobal ) _method( LLVMGetFirstGlobal )
_method( LLVMGetNextGlobal ) _method( LLVMGetNextGlobal )

View file

@ -478,9 +478,9 @@ class Module(llvm.Ownable, llvm.Cacheable):
return _make_type(ptr, kind) return _make_type(ptr, kind)
return None 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.""" """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): def get_global_variable_named(self, name):
"""Return a GlobalVariable object for the given name.""" """Return a GlobalVariable object for the given name."""
@ -1337,10 +1337,10 @@ class GlobalValue(Constant):
class GlobalVariable(GlobalValue): class GlobalVariable(GlobalValue):
@staticmethod @staticmethod
def new(module, ty, name): def new(module, ty, name, addrspace=0):
check_is_module(module) check_is_module(module)
check_is_type(ty) 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 @staticmethod
def get(module, name): def get(module, name):