mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Remove "pure" and "pure_none" calling conventions
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ RAD_PER_DEG :: TAU/360.0;
|
|||||||
DEG_PER_RAD :: 360.0/TAU;
|
DEG_PER_RAD :: 360.0/TAU;
|
||||||
|
|
||||||
|
|
||||||
@(default_calling_convention="pure_none")
|
@(default_calling_convention="none")
|
||||||
foreign _ {
|
foreign _ {
|
||||||
@(link_name="llvm.sqrt.f32")
|
@(link_name="llvm.sqrt.f32")
|
||||||
sqrt_f32 :: proc(x: f32) -> f32 ---;
|
sqrt_f32 :: proc(x: f32) -> f32 ---;
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ Proc_Calling_Convention :: enum i32 {
|
|||||||
C_Decl,
|
C_Decl,
|
||||||
Std_Call,
|
Std_Call,
|
||||||
Fast_Call,
|
Fast_Call,
|
||||||
Pure,
|
|
||||||
None,
|
None,
|
||||||
Pure_None,
|
|
||||||
|
|
||||||
Foreign_Block_Default = -1,
|
Foreign_Block_Default = -1,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1907,13 +1907,8 @@ string_to_calling_convention :: proc(s: string) -> ast.Proc_Calling_Convention {
|
|||||||
case "fast", "fastcall":
|
case "fast", "fastcall":
|
||||||
return .Fast_Call;
|
return .Fast_Call;
|
||||||
|
|
||||||
case "pure":
|
|
||||||
return .Pure;
|
|
||||||
case "none":
|
case "none":
|
||||||
return .None;
|
return .None;
|
||||||
case "pure_none":
|
|
||||||
return .Pure_None;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return .Invalid;
|
return .Invalid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,13 +25,11 @@ Calling_Convention :: enum u8 {
|
|||||||
Invalid = 0,
|
Invalid = 0,
|
||||||
Odin = 1,
|
Odin = 1,
|
||||||
Contextless = 2,
|
Contextless = 2,
|
||||||
Pure = 3,
|
CDecl = 3,
|
||||||
CDecl = 4,
|
Std_Call = 4,
|
||||||
Std_Call = 5,
|
Fast_Call = 5,
|
||||||
Fast_Call = 6,
|
|
||||||
|
|
||||||
None = 7,
|
None = 6,
|
||||||
Pure_None = 8,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Type_Info_Enum_Value :: distinct i64;
|
Type_Info_Enum_Value :: distinct i64;
|
||||||
|
|||||||
@@ -1971,22 +1971,6 @@ relative_data_types :: proc() {
|
|||||||
fmt.println(rel_slice[1]);
|
fmt.println(rel_slice[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pure_procedures :: proc() {
|
|
||||||
fmt.println("\n#pure procedures");
|
|
||||||
|
|
||||||
square :: proc "pure" (x: int) -> int {
|
|
||||||
return x*x + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
do_math :: proc "pure" (x: int) -> int {
|
|
||||||
// Only "pure" procedure calls are allowed within a "pure" procedure
|
|
||||||
return square(x) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
x := do_math(5);
|
|
||||||
fmt.println(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
when true {
|
when true {
|
||||||
the_basics();
|
the_basics();
|
||||||
@@ -2019,6 +2003,5 @@ main :: proc() {
|
|||||||
union_maybe();
|
union_maybe();
|
||||||
explicit_context_definition();
|
explicit_context_definition();
|
||||||
relative_data_types();
|
relative_data_types();
|
||||||
pure_procedures();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1971,22 +1971,6 @@ relative_data_types :: proc() {
|
|||||||
fmt.println(rel_slice[1])
|
fmt.println(rel_slice[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
pure_procedures :: proc() {
|
|
||||||
fmt.println("\n#pure procedures")
|
|
||||||
|
|
||||||
square :: proc "pure" (x: int) -> int {
|
|
||||||
return x*x + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
do_math :: proc "pure" (x: int) -> int {
|
|
||||||
// Only "pure" procedure calls are allowed within a "pure" procedure
|
|
||||||
return square(x) + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
x := do_math(5)
|
|
||||||
fmt.println(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
when true {
|
when true {
|
||||||
the_basics()
|
the_basics()
|
||||||
@@ -2019,6 +2003,5 @@ main :: proc() {
|
|||||||
union_maybe()
|
union_maybe()
|
||||||
explicit_context_definition()
|
explicit_context_definition()
|
||||||
relative_data_types()
|
relative_data_types()
|
||||||
pure_procedures()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1180,9 +1180,6 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty
|
|||||||
case ProcCC_None:
|
case ProcCC_None:
|
||||||
error(body, "Procedures with the calling convention \"none\" are not allowed a body");
|
error(body, "Procedures with the calling convention \"none\" are not allowed a body");
|
||||||
break;
|
break;
|
||||||
case ProcCC_PureNone:
|
|
||||||
error(body, "Procedures with the calling convention \"pure_none\" are not allowed a body");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-23
@@ -1162,11 +1162,6 @@ Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Typ
|
|||||||
if (e->flags & EntityFlag_Value) {
|
if (e->flags & EntityFlag_Value) {
|
||||||
o->mode = Addressing_Value;
|
o->mode = Addressing_Value;
|
||||||
}
|
}
|
||||||
if (c->curr_proc_calling_convention == ProcCC_Pure) {
|
|
||||||
if (e->scope->flags & (ScopeFlag_Global|ScopeFlag_File|ScopeFlag_Pkg)) {
|
|
||||||
error(n, "Global variables are not allowed within a \"pure\" procedure, got '%.*s'", LIT(e->token.string));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Entity_Procedure:
|
case Entity_Procedure:
|
||||||
@@ -7816,14 +7811,6 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
if (c->curr_proc_calling_convention == ProcCC_Pure) {
|
|
||||||
if (pt->kind == Type_Proc && pt->Proc.calling_convention != ProcCC_Pure && pt->Proc.calling_convention != ProcCC_PureNone) {
|
|
||||||
error(call, "Only \"pure\" procedure calls are allowed within a \"pure\" procedure");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (pt->kind == Type_Proc && pt->Proc.calling_convention == ProcCC_Odin) {
|
if (pt->kind == Type_Proc && pt->Proc.calling_convention == ProcCC_Odin) {
|
||||||
init_core_context(c->checker);
|
init_core_context(c->checker);
|
||||||
@@ -8168,17 +8155,13 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
|
|||||||
error(node, "'context' is only allowed within procedures %p", c->curr_proc_decl);
|
error(node, "'context' is only allowed within procedures %p", c->curr_proc_decl);
|
||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
if (c->curr_proc_calling_convention == ProcCC_Pure) {
|
if (unparen_expr(c->assignment_lhs_hint) == node) {
|
||||||
error(node, "'context' is not allowed within a \"pure\" procedure");
|
c->scope->flags |= ScopeFlag_ContextDefined;
|
||||||
} else {
|
}
|
||||||
if (unparen_expr(c->assignment_lhs_hint) == node) {
|
|
||||||
c->scope->flags |= ScopeFlag_ContextDefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((c->scope->flags & ScopeFlag_ContextDefined) == 0) {
|
if ((c->scope->flags & ScopeFlag_ContextDefined) == 0) {
|
||||||
error(node, "'context' has not been defined within this scope");
|
error(node, "'context' has not been defined within this scope");
|
||||||
// Continue with value
|
// Continue with value
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init_core_context(c->checker);
|
init_core_context(c->checker);
|
||||||
|
|||||||
@@ -1403,11 +1403,6 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
|
|||||||
case_end;
|
case_end;
|
||||||
|
|
||||||
case_ast_node(as, AssignStmt, node);
|
case_ast_node(as, AssignStmt, node);
|
||||||
if (ctx->curr_proc_calling_convention == ProcCC_Pure) {
|
|
||||||
error(node, "Assignment statements are not allowed within a \"pure\" procedure");
|
|
||||||
// Continue
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (as->op.kind) {
|
switch (as->op.kind) {
|
||||||
case Token_Eq: {
|
case Token_Eq: {
|
||||||
// a, b, c = 1, 2, 3; // Multisided
|
// a, b, c = 1, 2, 3; // Multisided
|
||||||
@@ -2142,12 +2137,6 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
|
|||||||
check_init_variables(ctx, entities, entity_count, vd->values, str_lit("variable declaration"));
|
check_init_variables(ctx, entities, entity_count, vd->values, str_lit("variable declaration"));
|
||||||
check_arity_match(ctx, vd, false);
|
check_arity_match(ctx, vd, false);
|
||||||
|
|
||||||
if (ctx->curr_proc_calling_convention == ProcCC_Pure) {
|
|
||||||
if (vd->values.count == 0) {
|
|
||||||
error(node, "Variable declarations without assignment are not allowed within \"pure\" procedures");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (isize i = 0; i < entity_count; i++) {
|
for (isize i = 0; i < entity_count; i++) {
|
||||||
Entity *e = entities[i];
|
Entity *e = entities[i];
|
||||||
|
|
||||||
|
|||||||
+3
-9
@@ -2172,7 +2172,7 @@ Type *type_to_abi_compat_param_type(gbAllocator a, Type *original_type, ProcCall
|
|||||||
return t_rawptr;
|
return t_rawptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cc == ProcCC_None || cc == ProcCC_PureNone || cc == ProcCC_InlineAsm) {
|
if (is_calling_convention_none(cc)) {
|
||||||
return new_type;
|
return new_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2312,7 +2312,7 @@ Type *type_to_abi_compat_result_type(gbAllocator a, Type *original_type, ProcCal
|
|||||||
if (build_context.ODIN_OS == "windows") {
|
if (build_context.ODIN_OS == "windows") {
|
||||||
if (build_context.ODIN_ARCH == "amd64") {
|
if (build_context.ODIN_ARCH == "amd64") {
|
||||||
if (is_type_integer_128bit(single_type)) {
|
if (is_type_integer_128bit(single_type)) {
|
||||||
if (cc == ProcCC_None || cc == ProcCC_PureNone) {
|
if (is_calling_convention_none(cc)) {
|
||||||
return original_type;
|
return original_type;
|
||||||
} else {
|
} else {
|
||||||
return alloc_type_simd_vector(2, t_u64);
|
return alloc_type_simd_vector(2, t_u64);
|
||||||
@@ -2378,7 +2378,7 @@ bool abi_compat_return_by_pointer(gbAllocator a, ProcCallingConvention cc, Type
|
|||||||
if (abi_return_type == nullptr) {
|
if (abi_return_type == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (cc == ProcCC_None || cc == ProcCC_PureNone || cc == ProcCC_InlineAsm) {
|
if (is_calling_convention_none(cc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2442,7 +2442,6 @@ void set_procedure_abi_types(Type *type) {
|
|||||||
switch (type->Proc.calling_convention) {
|
switch (type->Proc.calling_convention) {
|
||||||
case ProcCC_Odin:
|
case ProcCC_Odin:
|
||||||
case ProcCC_Contextless:
|
case ProcCC_Contextless:
|
||||||
case ProcCC_Pure:
|
|
||||||
if (is_type_pointer(new_type) && !is_type_pointer(e->type) && !is_type_proc(e->type)) {
|
if (is_type_pointer(new_type) && !is_type_pointer(e->type) && !is_type_proc(e->type)) {
|
||||||
e->flags |= EntityFlag_ImplicitReference;
|
e->flags |= EntityFlag_ImplicitReference;
|
||||||
}
|
}
|
||||||
@@ -2540,11 +2539,6 @@ bool check_procedure_type(CheckerContext *ctx, Type *type, Ast *proc_type_node,
|
|||||||
type->Proc.has_named_results = first->token.string != "";
|
type->Proc.has_named_results = first->token.string != "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result_count == 0 && cc == ProcCC_Pure) {
|
|
||||||
error(proc_type_node, "\"pure\" procedures must have at least 1 return value");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool optional_ok = (pt->tags & ProcTag_optional_ok) != 0;
|
bool optional_ok = (pt->tags & ProcTag_optional_ok) != 0;
|
||||||
if (optional_ok) {
|
if (optional_ok) {
|
||||||
if (result_count != 2) {
|
if (result_count != 2) {
|
||||||
|
|||||||
@@ -1451,13 +1451,11 @@ void ir_print_calling_convention(irFileBuffer *f, irModule *m, ProcCallingConven
|
|||||||
switch (cc) {
|
switch (cc) {
|
||||||
case ProcCC_Odin: ir_write_str_lit(f, ""); break;
|
case ProcCC_Odin: ir_write_str_lit(f, ""); break;
|
||||||
case ProcCC_Contextless: ir_write_str_lit(f, ""); break;
|
case ProcCC_Contextless: ir_write_str_lit(f, ""); break;
|
||||||
case ProcCC_Pure: ir_write_str_lit(f, ""); break;
|
|
||||||
// case ProcCC_CDecl: ir_write_str_lit(f, "ccc "); break;
|
// case ProcCC_CDecl: ir_write_str_lit(f, "ccc "); break;
|
||||||
case ProcCC_CDecl: ir_write_str_lit(f, ""); break;
|
case ProcCC_CDecl: ir_write_str_lit(f, ""); break;
|
||||||
case ProcCC_StdCall: ir_write_str_lit(f, "cc 64 "); break;
|
case ProcCC_StdCall: ir_write_str_lit(f, "cc 64 "); break;
|
||||||
case ProcCC_FastCall: ir_write_str_lit(f, "cc 65 "); break;
|
case ProcCC_FastCall: ir_write_str_lit(f, "cc 65 "); break;
|
||||||
case ProcCC_None: ir_write_str_lit(f, ""); break;
|
case ProcCC_None: ir_write_str_lit(f, ""); break;
|
||||||
case ProcCC_PureNone: ir_write_str_lit(f, ""); break;
|
|
||||||
default: GB_PANIC("unknown calling convention: %d", cc);
|
default: GB_PANIC("unknown calling convention: %d", cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -924,7 +924,6 @@ namespace lbAbiAarch64 {
|
|||||||
LB_ABI_INFO(lb_get_abi_info) {
|
LB_ABI_INFO(lb_get_abi_info) {
|
||||||
switch (calling_convention) {
|
switch (calling_convention) {
|
||||||
case ProcCC_None:
|
case ProcCC_None:
|
||||||
case ProcCC_PureNone:
|
|
||||||
case ProcCC_InlineAsm:
|
case ProcCC_InlineAsm:
|
||||||
{
|
{
|
||||||
lbFunctionType *ft = gb_alloc_item(heap_allocator(), lbFunctionType);
|
lbFunctionType *ft = gb_alloc_item(heap_allocator(), lbFunctionType);
|
||||||
|
|||||||
@@ -3218,8 +3218,6 @@ Ast *parse_results(AstFile *f, bool *diverging) {
|
|||||||
ProcCallingConvention string_to_calling_convention(String s) {
|
ProcCallingConvention string_to_calling_convention(String s) {
|
||||||
if (s == "odin") return ProcCC_Odin;
|
if (s == "odin") return ProcCC_Odin;
|
||||||
if (s == "contextless") return ProcCC_Contextless;
|
if (s == "contextless") return ProcCC_Contextless;
|
||||||
if (s == "pure") return ProcCC_Pure;
|
|
||||||
if (s == "pure_none") return ProcCC_PureNone;
|
|
||||||
if (s == "cdecl") return ProcCC_CDecl;
|
if (s == "cdecl") return ProcCC_CDecl;
|
||||||
if (s == "c") return ProcCC_CDecl;
|
if (s == "c") return ProcCC_CDecl;
|
||||||
if (s == "stdcall") return ProcCC_StdCall;
|
if (s == "stdcall") return ProcCC_StdCall;
|
||||||
|
|||||||
+4
-6
@@ -206,13 +206,11 @@ enum ProcCallingConvention {
|
|||||||
ProcCC_Invalid = 0,
|
ProcCC_Invalid = 0,
|
||||||
ProcCC_Odin = 1,
|
ProcCC_Odin = 1,
|
||||||
ProcCC_Contextless = 2,
|
ProcCC_Contextless = 2,
|
||||||
ProcCC_Pure = 3,
|
ProcCC_CDecl = 3,
|
||||||
ProcCC_CDecl = 4,
|
ProcCC_StdCall = 4,
|
||||||
ProcCC_StdCall = 5,
|
ProcCC_FastCall = 5,
|
||||||
ProcCC_FastCall = 6,
|
|
||||||
|
|
||||||
ProcCC_None = 7,
|
ProcCC_None = 6,
|
||||||
ProcCC_PureNone = 8,
|
|
||||||
|
|
||||||
ProcCC_InlineAsm = 9,
|
ProcCC_InlineAsm = 9,
|
||||||
|
|
||||||
|
|||||||
@@ -903,7 +903,6 @@ Type *alloc_type_named(String name, Type *base, Entity *type_name) {
|
|||||||
bool is_calling_convention_none(ProcCallingConvention calling_convention) {
|
bool is_calling_convention_none(ProcCallingConvention calling_convention) {
|
||||||
switch (calling_convention) {
|
switch (calling_convention) {
|
||||||
case ProcCC_None:
|
case ProcCC_None:
|
||||||
case ProcCC_PureNone:
|
|
||||||
case ProcCC_InlineAsm:
|
case ProcCC_InlineAsm:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -3610,15 +3609,10 @@ gbString write_type_to_string(gbString str, Type *type) {
|
|||||||
case ProcCC_FastCall:
|
case ProcCC_FastCall:
|
||||||
str = gb_string_appendc(str, " \"fastcall\" ");
|
str = gb_string_appendc(str, " \"fastcall\" ");
|
||||||
break;
|
break;
|
||||||
case ProcCC_PureNone:
|
|
||||||
str = gb_string_appendc(str, " \"pure_none\" ");
|
|
||||||
break;
|
break;
|
||||||
case ProcCC_None:
|
case ProcCC_None:
|
||||||
str = gb_string_appendc(str, " \"none\" ");
|
str = gb_string_appendc(str, " \"none\" ");
|
||||||
break;
|
break;
|
||||||
case ProcCC_Pure:
|
|
||||||
str = gb_string_appendc(str, " \"pure\" ");
|
|
||||||
break;
|
|
||||||
// case ProcCC_VectorCall:
|
// case ProcCC_VectorCall:
|
||||||
// str = gb_string_appendc(str, " \"vectorcall\" ");
|
// str = gb_string_appendc(str, " \"vectorcall\" ");
|
||||||
// break;
|
// break;
|
||||||
|
|||||||
Reference in New Issue
Block a user