diff --git a/core/math/math.odin b/core/math/math.odin index ca344afeb..36102c76d 100644 --- a/core/math/math.odin +++ b/core/math/math.odin @@ -36,7 +36,7 @@ RAD_PER_DEG :: TAU/360.0; DEG_PER_RAD :: 360.0/TAU; -@(default_calling_convention="pure_none") +@(default_calling_convention="none") foreign _ { @(link_name="llvm.sqrt.f32") sqrt_f32 :: proc(x: f32) -> f32 ---; diff --git a/core/odin/ast/ast.odin b/core/odin/ast/ast.odin index d51f482a3..6570c0128 100644 --- a/core/odin/ast/ast.odin +++ b/core/odin/ast/ast.odin @@ -22,9 +22,7 @@ Proc_Calling_Convention :: enum i32 { C_Decl, Std_Call, Fast_Call, - Pure, None, - Pure_None, Foreign_Block_Default = -1, } diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index fab822e1e..3c0be0856 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -1907,13 +1907,8 @@ string_to_calling_convention :: proc(s: string) -> ast.Proc_Calling_Convention { case "fast", "fastcall": return .Fast_Call; - case "pure": - return .Pure; case "none": return .None; - case "pure_none": - return .Pure_None; - } return .Invalid; } diff --git a/core/runtime/core.odin b/core/runtime/core.odin index c90839aaa..5b176205b 100644 --- a/core/runtime/core.odin +++ b/core/runtime/core.odin @@ -25,13 +25,11 @@ Calling_Convention :: enum u8 { Invalid = 0, Odin = 1, Contextless = 2, - Pure = 3, - CDecl = 4, - Std_Call = 5, - Fast_Call = 6, + CDecl = 3, + Std_Call = 4, + Fast_Call = 5, - None = 7, - Pure_None = 8, + None = 6, } Type_Info_Enum_Value :: distinct i64; diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin index d4f00475a..563f5a32b 100644 --- a/examples/demo/demo.odin +++ b/examples/demo/demo.odin @@ -1971,22 +1971,6 @@ relative_data_types :: proc() { 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() { when true { the_basics(); @@ -2019,6 +2003,5 @@ main :: proc() { union_maybe(); explicit_context_definition(); relative_data_types(); - pure_procedures(); } } diff --git a/examples/demo_insert_semicolon/demo.odin b/examples/demo_insert_semicolon/demo.odin index 807a2bed1..57e5a98b7 100644 --- a/examples/demo_insert_semicolon/demo.odin +++ b/examples/demo_insert_semicolon/demo.odin @@ -1971,22 +1971,6 @@ relative_data_types :: proc() { 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() { when true { the_basics() @@ -2019,6 +2003,5 @@ main :: proc() { union_maybe() explicit_context_definition() relative_data_types() - pure_procedures() } } diff --git a/src/check_decl.cpp b/src/check_decl.cpp index aed830530..c41090ecc 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -1180,9 +1180,6 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty case ProcCC_None: error(body, "Procedures with the calling convention \"none\" are not allowed a body"); break; - case ProcCC_PureNone: - error(body, "Procedures with the calling convention \"pure_none\" are not allowed a body"); - break; } } diff --git a/src/check_expr.cpp b/src/check_expr.cpp index e17d23ed9..42e434f85 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1162,11 +1162,6 @@ Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Typ if (e->flags & EntityFlag_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; 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 (pt->kind == Type_Proc && pt->Proc.calling_convention == ProcCC_Odin) { 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); return kind; } - if (c->curr_proc_calling_convention == ProcCC_Pure) { - error(node, "'context' is not allowed within a \"pure\" procedure"); - } else { - if (unparen_expr(c->assignment_lhs_hint) == node) { - c->scope->flags |= ScopeFlag_ContextDefined; - } + if (unparen_expr(c->assignment_lhs_hint) == node) { + c->scope->flags |= ScopeFlag_ContextDefined; + } - if ((c->scope->flags & ScopeFlag_ContextDefined) == 0) { - error(node, "'context' has not been defined within this scope"); - // Continue with value - } + if ((c->scope->flags & ScopeFlag_ContextDefined) == 0) { + error(node, "'context' has not been defined within this scope"); + // Continue with value } init_core_context(c->checker); diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 5e403134e..4c805481e 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1403,11 +1403,6 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { case_end; 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) { case Token_Eq: { // 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_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++) { Entity *e = entities[i]; diff --git a/src/check_type.cpp b/src/check_type.cpp index 94bbcae28..bf3c72499 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -2172,7 +2172,7 @@ Type *type_to_abi_compat_param_type(gbAllocator a, Type *original_type, ProcCall return t_rawptr; } - if (cc == ProcCC_None || cc == ProcCC_PureNone || cc == ProcCC_InlineAsm) { + if (is_calling_convention_none(cc)) { 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_ARCH == "amd64") { if (is_type_integer_128bit(single_type)) { - if (cc == ProcCC_None || cc == ProcCC_PureNone) { + if (is_calling_convention_none(cc)) { return original_type; } else { 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) { return false; } - if (cc == ProcCC_None || cc == ProcCC_PureNone || cc == ProcCC_InlineAsm) { + if (is_calling_convention_none(cc)) { return false; } @@ -2442,7 +2442,6 @@ void set_procedure_abi_types(Type *type) { switch (type->Proc.calling_convention) { case ProcCC_Odin: case ProcCC_Contextless: - case ProcCC_Pure: if (is_type_pointer(new_type) && !is_type_pointer(e->type) && !is_type_proc(e->type)) { 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 != ""; } - 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; if (optional_ok) { if (result_count != 2) { diff --git a/src/ir_print.cpp b/src/ir_print.cpp index 5093b13e6..905d18b79 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -1451,13 +1451,11 @@ void ir_print_calling_convention(irFileBuffer *f, irModule *m, ProcCallingConven switch (cc) { case ProcCC_Odin: 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, ""); 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_None: ir_write_str_lit(f, ""); break; - case ProcCC_PureNone: ir_write_str_lit(f, ""); break; default: GB_PANIC("unknown calling convention: %d", cc); } } diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 77d4b42b0..587dd6203 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -924,7 +924,6 @@ namespace lbAbiAarch64 { LB_ABI_INFO(lb_get_abi_info) { switch (calling_convention) { case ProcCC_None: - case ProcCC_PureNone: case ProcCC_InlineAsm: { lbFunctionType *ft = gb_alloc_item(heap_allocator(), lbFunctionType); diff --git a/src/parser.cpp b/src/parser.cpp index 4039c5dbe..7ae1810ec 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -3218,8 +3218,6 @@ Ast *parse_results(AstFile *f, bool *diverging) { ProcCallingConvention string_to_calling_convention(String s) { if (s == "odin") return ProcCC_Odin; 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 == "c") return ProcCC_CDecl; if (s == "stdcall") return ProcCC_StdCall; diff --git a/src/parser.hpp b/src/parser.hpp index da363bee9..b038b3b45 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -206,13 +206,11 @@ enum ProcCallingConvention { ProcCC_Invalid = 0, ProcCC_Odin = 1, ProcCC_Contextless = 2, - ProcCC_Pure = 3, - ProcCC_CDecl = 4, - ProcCC_StdCall = 5, - ProcCC_FastCall = 6, + ProcCC_CDecl = 3, + ProcCC_StdCall = 4, + ProcCC_FastCall = 5, - ProcCC_None = 7, - ProcCC_PureNone = 8, + ProcCC_None = 6, ProcCC_InlineAsm = 9, diff --git a/src/types.cpp b/src/types.cpp index b1d69079b..aec6de8bd 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -903,7 +903,6 @@ Type *alloc_type_named(String name, Type *base, Entity *type_name) { bool is_calling_convention_none(ProcCallingConvention calling_convention) { switch (calling_convention) { case ProcCC_None: - case ProcCC_PureNone: case ProcCC_InlineAsm: return true; } @@ -3610,15 +3609,10 @@ gbString write_type_to_string(gbString str, Type *type) { case ProcCC_FastCall: str = gb_string_appendc(str, " \"fastcall\" "); break; - case ProcCC_PureNone: - str = gb_string_appendc(str, " \"pure_none\" "); break; case ProcCC_None: str = gb_string_appendc(str, " \"none\" "); break; - case ProcCC_Pure: - str = gb_string_appendc(str, " \"pure\" "); - break; // case ProcCC_VectorCall: // str = gb_string_appendc(str, " \"vectorcall\" "); // break;