mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-31 11:50:07 +00:00
Merge branch 'master' into new-matrix-type
This commit is contained in:
@@ -99,7 +99,7 @@ LLVMValueRef llvm_const_cast(LLVMValueRef val, LLVMTypeRef dst) {
|
||||
return LLVMConstNull(dst);
|
||||
}
|
||||
|
||||
GB_ASSERT_MSG(LLVMSizeOf(dst) == LLVMSizeOf(src), "%s vs %s", LLVMPrintTypeToString(dst), LLVMPrintTypeToString(src));
|
||||
GB_ASSERT_MSG(lb_sizeof(dst) == lb_sizeof(src), "%s vs %s", LLVMPrintTypeToString(dst), LLVMPrintTypeToString(src));
|
||||
LLVMTypeKind kind = LLVMGetTypeKind(dst);
|
||||
switch (kind) {
|
||||
case LLVMPointerTypeKind:
|
||||
|
||||
@@ -3111,11 +3111,7 @@ lbValue lb_build_expr(lbProcedure *p, Ast *expr) {
|
||||
}
|
||||
|
||||
LLVMTypeRef func_type = LLVMGetElementType(lb_type(p->module, t));
|
||||
LLVMValueRef the_asm = LLVMGetInlineAsm(func_type,
|
||||
cast(char *)asm_string.text, cast(size_t)asm_string.len,
|
||||
cast(char *)constraints_string.text, cast(size_t)constraints_string.len,
|
||||
ia->has_side_effects, ia->is_align_stack, dialect
|
||||
);
|
||||
LLVMValueRef the_asm = llvm_get_inline_asm(func_type, asm_string, constraints_string, ia->has_side_effects, ia->has_side_effects, dialect);
|
||||
GB_ASSERT(the_asm != nullptr);
|
||||
return {the_asm, t};
|
||||
case_end;
|
||||
|
||||
@@ -1382,22 +1382,12 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv,
|
||||
if (build_context.metrics.arch == TargetArch_386 ||
|
||||
build_context.metrics.arch == TargetArch_amd64) {
|
||||
LLVMTypeRef func_type = LLVMFunctionType(LLVMVoidTypeInContext(p->module->ctx), nullptr, 0, false);
|
||||
LLVMValueRef the_asm = LLVMGetInlineAsm(func_type,
|
||||
cast(char *)"pause", 5,
|
||||
cast(char *)"", 0,
|
||||
/*HasSideEffects*/true, /*IsAlignStack*/false,
|
||||
LLVMInlineAsmDialectATT
|
||||
);
|
||||
LLVMValueRef the_asm = llvm_get_inline_asm(func_type, str_lit("pause"), {});
|
||||
GB_ASSERT(the_asm != nullptr);
|
||||
LLVMBuildCall2(p->builder, func_type, the_asm, nullptr, 0, "");
|
||||
} else if (build_context.metrics.arch == TargetArch_arm64) {
|
||||
LLVMTypeRef func_type = LLVMFunctionType(LLVMVoidTypeInContext(p->module->ctx), nullptr, 0, false);
|
||||
LLVMValueRef the_asm = LLVMGetInlineAsm(func_type,
|
||||
cast(char *)"yield", 5,
|
||||
cast(char *)"", 0,
|
||||
/*HasSideEffects*/true, /*IsAlignStack*/false,
|
||||
LLVMInlineAsmDialectATT
|
||||
);
|
||||
LLVMValueRef the_asm = llvm_get_inline_asm(func_type, str_lit("yield"), {});
|
||||
GB_ASSERT(the_asm != nullptr);
|
||||
LLVMBuildCall2(p->builder, func_type, the_asm, nullptr, 0, "");
|
||||
}
|
||||
@@ -2008,10 +1998,8 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv,
|
||||
constraints = gb_string_appendc(constraints, regs[i]);
|
||||
constraints = gb_string_appendc(constraints, "}");
|
||||
}
|
||||
size_t asm_string_size = gb_strlen(asm_string);
|
||||
size_t constraints_size = gb_string_length(constraints);
|
||||
|
||||
inline_asm = LLVMGetInlineAsm(func_type, asm_string, asm_string_size, constraints, constraints_size, true, false, LLVMInlineAsmDialectATT);
|
||||
inline_asm = llvm_get_inline_asm(func_type, make_string_c(asm_string), make_string_c(constraints));
|
||||
}
|
||||
break;
|
||||
case TargetArch_386:
|
||||
@@ -2042,10 +2030,7 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv,
|
||||
constraints = gb_string_appendc(constraints, ",rm");
|
||||
}
|
||||
|
||||
size_t asm_string_size = gb_strlen(asm_string);
|
||||
size_t constraints_size = gb_string_length(constraints);
|
||||
|
||||
inline_asm = LLVMGetInlineAsm(func_type, asm_string, asm_string_size, constraints, constraints_size, true, false, LLVMInlineAsmDialectATT);
|
||||
inline_asm = llvm_get_inline_asm(func_type, make_string_c(asm_string), make_string_c(constraints));
|
||||
}
|
||||
break;
|
||||
case TargetArch_arm64:
|
||||
@@ -2068,10 +2053,8 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv,
|
||||
constraints = gb_string_appendc(constraints, regs[i]);
|
||||
constraints = gb_string_appendc(constraints, "}");
|
||||
}
|
||||
size_t asm_string_size = gb_strlen(asm_string);
|
||||
size_t constraints_size = gb_string_length(constraints);
|
||||
|
||||
inline_asm = LLVMGetInlineAsm(func_type, asm_string, asm_string_size, constraints, constraints_size, true, false, LLVMInlineAsmDialectATT);
|
||||
|
||||
inline_asm = llvm_get_inline_asm(func_type, make_string_c(asm_string), make_string_c(constraints));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1483,8 +1483,6 @@ lbValue lb_soa_struct_cap(lbProcedure *p, lbValue value) {
|
||||
return lb_emit_struct_ev(p, value, cast(i32)n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
lbValue lb_emit_mul_add(lbProcedure *p, lbValue a, lbValue b, lbValue c, Type *t) {
|
||||
lbModule *m = p->module;
|
||||
|
||||
@@ -1675,4 +1673,16 @@ LLVMValueRef llvm_vector_mul_add(lbProcedure *p, LLVMValueRef a, LLVMValueRef b,
|
||||
LLVMValueRef y = llvm_vector_add(p, x, c);
|
||||
return y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LLVMValueRef llvm_get_inline_asm(LLVMTypeRef func_type, String const &str, String const &clobbers, bool has_side_effects=true, bool is_align_stack=false, LLVMInlineAsmDialect dialect=LLVMInlineAsmDialectATT) {
|
||||
return LLVMGetInlineAsm(func_type,
|
||||
cast(char *)str.text, cast(size_t)str.len,
|
||||
cast(char *)clobbers.text, cast(size_t)clobbers.len,
|
||||
/*HasSideEffects*/true, /*IsAlignStack*/false,
|
||||
dialect
|
||||
#if LLVM_VERSION_MAJOR >= 13
|
||||
, /*CanThrow*/false
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user