Commit 92bdd522 authored by Eduardo Souza's avatar Eduardo Souza

Remove gen_llvm_type_global.

parent 1ccc19f8
Pipeline #5679 canceled with stages
......@@ -912,12 +912,12 @@ unsafe fn create_llvm_function_type(
let mut llvm_arg_types = vec![];
for arg_ty in &function_sig.arg_tys {
llvm_arg_types
.push(gen_llvm_type_global(llvm_internal_context, arg_ty));
.push(gen_llvm_type(llvm_internal_context, arg_ty));
}
let mut llvm_ret_types = vec![];
for ret_ty in &function_sig.ret_tys {
llvm_ret_types.push(gen_llvm_type_global(llvm_internal_context, ret_ty))
llvm_ret_types.push(gen_llvm_type(llvm_internal_context, ret_ty))
}
// Mu functions return a tuple of values
......@@ -1137,145 +1137,6 @@ pub unsafe fn gen_llvm_type(
}
}
/// Fields of globals should not be in addrspace(1)
pub unsafe fn gen_llvm_type_global(
llvm_internal_context: &mut AOTLLVMInternalContext,
arg_ty: &P<MuType>
) -> LLVMTypeRef {
match &arg_ty.v {
MuType_::Double => LLVMDoubleType(),
MuType_::Float => LLVMFloatType(),
MuType_::Void => LLVMVoidType(),
MuType_::Int(size) => match size {
1 => LLVMInt1Type(),
8 => LLVMInt8Type(),
16 => LLVMInt16Type(),
32 => LLVMInt32Type(),
64 => LLVMInt64Type(),
128 => LLVMInt128Type(),
n => LLVMIntType(*n as c_uint)
},
MuType_::Struct(tag) => {
let struct_map = STRUCT_TAG_MAP.read().unwrap();
let struct_ty: &StructType_ = struct_map
.get(&arg_ty.get_struct_hybrid_tag().unwrap())
.unwrap();
let struct_name = format!("{}\0", tag);
if llvm_internal_context.struct_map.contains_key(tag) {
let struct_type =
llvm_internal_context.struct_map.get(tag).unwrap();
*struct_type
} else {
let context =
LLVMGetModuleContext(llvm_internal_context.module);
let struct_type = LLVMStructCreateNamed(
context,
struct_name.as_str().as_ptr() as *const c_char
);
llvm_internal_context
.struct_map
.insert(tag.clone(), struct_type);
let mut struct_types = vec![];
for ty in struct_ty.get_tys() {
struct_types
.push(gen_llvm_type_global(llvm_internal_context, ty));
}
LLVMStructSetBody(
struct_type,
struct_types.as_mut_ptr(),
struct_types.len() as u32,
false as LLVMBool
);
struct_type
}
}
MuType_::Hybrid(_) => {
let hybrid_map = HYBRID_TAG_MAP.read().unwrap();
let hybrid_ty: &HybridType_ = hybrid_map
.get(&arg_ty.get_struct_hybrid_tag().unwrap())
.unwrap();
if hybrid_ty.get_fix_tys().is_empty() {
return LLVMArrayType(
gen_llvm_type_global(
llvm_internal_context,
hybrid_ty.get_var_ty()
),
0
);
}
let mut struct_types = vec![];
for ty in hybrid_ty.get_fix_tys() {
struct_types
.push(gen_llvm_type_global(llvm_internal_context, ty));
}
let var_type = LLVMArrayType(
gen_llvm_type_global(
llvm_internal_context,
hybrid_ty.get_var_ty()
),
0
);
struct_types.push(var_type);
LLVMStructType(
struct_types.as_mut_ptr(),
struct_types.len() as u32,
false as LLVMBool
)
}
MuType_::Array(mu_type, size) => {
let internal_type =
gen_llvm_type_global(llvm_internal_context, mu_type);
LLVMArrayType(internal_type, *size as u32)
}
MuType_::IRef(mu_type) => {
if mu_type.is_void() {
LLVMPointerType(LLVMInt8Type(), 0)
} else {
let internal_type =
gen_llvm_type(llvm_internal_context, mu_type);
LLVMPointerType(internal_type, 0)
}
}
MuType_::Ref(mu_type) => {
if mu_type.is_void() {
LLVMPointerType(LLVMInt8Type(), 0)
} else {
let internal_type =
gen_llvm_type(llvm_internal_context, mu_type);
LLVMPointerType(internal_type, 0)
}
}
MuType_::UPtr(mu_type) => {
if mu_type.is_void() {
LLVMPointerType(LLVMInt8Type(), 0)
} else {
let internal_type =
gen_llvm_type(llvm_internal_context, mu_type);
LLVMPointerType(internal_type, 0)
}
}
MuType_::FuncRef(sig) => LLVMPointerType(
create_llvm_function_type(llvm_internal_context, sig),
0
),
_ => {
println!("{:?}", arg_ty);
unimplemented!()
}
}
}
unsafe fn gen_llvm_block(
llvm_internal_context: &AOTLLVMInternalContext,
function: LLVMValueRef,
......
......@@ -340,7 +340,7 @@ def fncptr_from_rpy_func_llvm(rpy_fnc, llargtypes, llrestype, mode=ctypes.RTLD_G
kwargs.setdefault('suplibdir', str(bin_dir))
kwargs.setdefault('no_ovf', True)
libaotmu_dir = os.path.join(os.getenv('MU_LLVM_ZEBU', ''), 'target', 'debug', 'deps')
libaotmu_dir = os.path.join(os.getenv('MU_LLVM_ZEBU', ''), 'target', 'debug')
eci = ExternalCompilationInfo(libraries=['mu_aot_llvm'],
library_dirs=[libaotmu_dir])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment