Remove "pure" and "pure_none" calling conventions

This commit is contained in:
gingerBill
2021-02-23 13:10:23 +00:00
parent a652c24ac3
commit 28ed310f31
15 changed files with 18 additions and 111 deletions
-3
View File
@@ -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;
}
}
+6 -23
View File
@@ -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);
-11
View File
@@ -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];
+3 -9
View File
@@ -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) {
-2
View File
@@ -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);
}
}
-1
View File
@@ -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);
-2
View File
@@ -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;
+4 -6
View File
@@ -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,
-6
View File
@@ -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;