mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-14 01:34:35 +00:00
#side_effects -> #volatile; Remove dead code
This commit is contained in:
@@ -882,7 +882,7 @@ gb_internal void check_mnemonic(AsmCtx *asm_ctx, CheckerContext *ctx, Entity *tm
|
||||
|
||||
tmpl_entity->AsmTemplate.clobber_cc |= clobber.implies_clobber_cc();
|
||||
tmpl_entity->AsmTemplate.clobber_memory |= clobber.implies_clobber_memory();
|
||||
tmpl_entity->AsmTemplate.has_side_effects |= clobber.implies_side_effects();
|
||||
tmpl_entity->AsmTemplate.is_volatile |= clobber.implies_side_effects();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1284,7 +1284,7 @@ gb_internal void check_asm_template(AsmCtx *asm_ctx, CheckerContext *ctx, Entity
|
||||
entity->type = type;
|
||||
|
||||
|
||||
bool has_side_effects = false;
|
||||
bool is_volatile = false;
|
||||
bool is_align_stack = false;
|
||||
auto *clobber_registers_set = &entity->AsmTemplate.clobber_registers_set;
|
||||
|
||||
@@ -1297,11 +1297,11 @@ gb_internal void check_asm_template(AsmCtx *asm_ctx, CheckerContext *ctx, Entity
|
||||
ast_node(clobber, AsmClobber, clobber_);
|
||||
|
||||
if (clobber->value == nullptr) {
|
||||
if (clobber->name.string == "side_effects") {
|
||||
if (has_side_effects) {
|
||||
error(clobber->name, "#side_effects has already been defined as an asm specification");
|
||||
if (clobber->name.string == "volatile") {
|
||||
if (is_volatile) {
|
||||
error(clobber->name, "#volatile has already been defined as an asm specification");
|
||||
}
|
||||
has_side_effects = true;
|
||||
is_volatile = true;
|
||||
} else if (clobber->name.string == "align_stack") {
|
||||
if (is_align_stack) {
|
||||
error(clobber->name, "#align_stack has already been defined as an asm specification");
|
||||
@@ -1347,7 +1347,7 @@ gb_internal void check_asm_template(AsmCtx *asm_ctx, CheckerContext *ctx, Entity
|
||||
|
||||
entity->AsmTemplate.clobber_cc = clobber_cc;
|
||||
entity->AsmTemplate.clobber_memory = clobber_memory;
|
||||
entity->AsmTemplate.has_side_effects = has_side_effects;
|
||||
entity->AsmTemplate.is_volatile = is_volatile;
|
||||
entity->AsmTemplate.is_align_stack = is_align_stack;
|
||||
}
|
||||
|
||||
|
||||
@@ -12683,53 +12683,6 @@ gb_internal ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast
|
||||
}
|
||||
case_end;
|
||||
|
||||
case_ast_node(ia, InlineAsmExpr, node);
|
||||
if (c->curr_proc_decl == nullptr) {
|
||||
error(node, "Inline asm expressions are only allowed within a procedure body");
|
||||
}
|
||||
|
||||
auto param_types = array_make<Type *>(heap_allocator(), ia->param_types.count);
|
||||
Type *return_type = nullptr;
|
||||
for_array(i, ia->param_types) {
|
||||
param_types[i] = check_type(c, ia->param_types[i]);
|
||||
}
|
||||
if (ia->return_type != nullptr) {
|
||||
return_type = check_type(c, ia->return_type);
|
||||
}
|
||||
Operand x = {};
|
||||
check_expr(c, &x, ia->asm_string);
|
||||
if (x.mode != Addressing_Constant || !is_type_string(x.type)) {
|
||||
error(x.expr, "Expected a constant string for the inline asm main parameter");
|
||||
}
|
||||
check_expr(c, &x, ia->constraints_string);
|
||||
if (x.mode != Addressing_Constant || !is_type_string(x.type)) {
|
||||
error(x.expr, "Expected a constant string for the inline asm constraints parameter");
|
||||
}
|
||||
|
||||
Scope *scope = create_scope(c->info, c->scope);
|
||||
scope->flags |= ScopeFlag_Proc;
|
||||
|
||||
Type *params = alloc_type_tuple();
|
||||
Type *results = alloc_type_tuple();
|
||||
if (param_types.count != 0) {
|
||||
slice_init(¶ms->Tuple.variables, heap_allocator(), param_types.count);
|
||||
for_array(i, param_types) {
|
||||
params->Tuple.variables[i] = alloc_entity_param(scope, blank_token, param_types[i], false, true);
|
||||
}
|
||||
}
|
||||
if (return_type != nullptr) {
|
||||
slice_init(&results->Tuple.variables, heap_allocator(), 1);
|
||||
results->Tuple.variables[0] = alloc_entity_param(scope, blank_token, return_type, false, true);
|
||||
}
|
||||
|
||||
|
||||
Type *pt = alloc_type_proc(scope, params, param_types.count, results, return_type != nullptr ? 1 : 0, false, ProcCC_InlineAsm);
|
||||
o->type = pt;
|
||||
o->mode = Addressing_Value;
|
||||
o->expr = node;
|
||||
return Expr_Expr;
|
||||
case_end;
|
||||
|
||||
case Ast_DistinctType:
|
||||
case Ast_TypeidType:
|
||||
case Ast_PolyType:
|
||||
@@ -13567,40 +13520,6 @@ gb_internal gbString write_expr_to_string(gbString str, Ast *node, bool shorthan
|
||||
str = gb_string_appendc(str, "}");
|
||||
case_end;
|
||||
|
||||
case_ast_node(ia, InlineAsmExpr, node);
|
||||
str = gb_string_appendc(str, "asm(");
|
||||
for_array(i, ia->param_types) {
|
||||
if (i > 0) {
|
||||
str = gb_string_appendc(str, ", ");
|
||||
}
|
||||
str = write_expr_to_string(str, ia->param_types[i], shorthand);
|
||||
}
|
||||
str = gb_string_appendc(str, ")");
|
||||
if (ia->return_type != nullptr) {
|
||||
str = gb_string_appendc(str, " -> ");
|
||||
str = write_expr_to_string(str, ia->return_type, shorthand);
|
||||
}
|
||||
if (ia->has_side_effects) {
|
||||
str = gb_string_appendc(str, " #side_effects");
|
||||
}
|
||||
if (ia->is_align_stack) {
|
||||
str = gb_string_appendc(str, " #stack_align");
|
||||
}
|
||||
if (ia->dialect) {
|
||||
str = gb_string_appendc(str, " #");
|
||||
str = gb_string_appendc(str, inline_asm_dialect_strings[ia->dialect]);
|
||||
}
|
||||
str = gb_string_appendc(str, " {");
|
||||
if (shorthand) {
|
||||
str = gb_string_appendc(str, "...");
|
||||
} else {
|
||||
str = write_expr_to_string(str, ia->asm_string, shorthand);
|
||||
str = gb_string_appendc(str, ", ");
|
||||
str = write_expr_to_string(str, ia->constraints_string, shorthand);
|
||||
}
|
||||
str = gb_string_appendc(str, "}");
|
||||
case_end;
|
||||
|
||||
case_ast_node(at, AsmTemplate, node);
|
||||
str = gb_string_appendc(str, "asm");
|
||||
{
|
||||
|
||||
@@ -340,7 +340,7 @@ struct Entity {
|
||||
} Label;
|
||||
struct {
|
||||
Ast *node;
|
||||
bool has_side_effects;
|
||||
bool is_volatile;
|
||||
bool is_align_stack;
|
||||
|
||||
bool clobber_cc;
|
||||
|
||||
@@ -484,7 +484,7 @@ struct lbAsmGenerate_amd64 : lbAsmGenerate {
|
||||
fn_ty,
|
||||
asm_string, cast(size_t)gb_string_length(asm_string),
|
||||
constraints, cast(size_t)gb_string_length(constraints),
|
||||
/*HasSideEffects*/ tmpl_entity->AsmTemplate.has_side_effects,
|
||||
/*HasSideEffects*/ tmpl_entity->AsmTemplate.is_volatile,
|
||||
/*IsAlignStack*/ tmpl_entity->AsmTemplate.is_align_stack,
|
||||
LLVMInlineAsmDialectATT,
|
||||
/*CanThrow*/ false);
|
||||
|
||||
@@ -4733,39 +4733,6 @@ gb_internal lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) {
|
||||
case_ast_node(ie, MatrixIndexExpr, expr);
|
||||
return lb_addr_load(p, lb_build_addr(p, expr));
|
||||
case_end;
|
||||
|
||||
case_ast_node(ia, InlineAsmExpr, expr);
|
||||
Type *t = type_of_expr(expr);
|
||||
GB_ASSERT(is_type_asm_proc(t));
|
||||
|
||||
String asm_string = {};
|
||||
String constraints_string = {};
|
||||
|
||||
TypeAndValue tav;
|
||||
tav = type_and_value_of_expr(ia->asm_string);
|
||||
GB_ASSERT(is_type_string(tav.type));
|
||||
GB_ASSERT(tav.value.kind == ExactValue_String);
|
||||
asm_string = tav.value.value_string;
|
||||
|
||||
tav = type_and_value_of_expr(ia->constraints_string);
|
||||
GB_ASSERT(is_type_string(tav.type));
|
||||
GB_ASSERT(tav.value.kind == ExactValue_String);
|
||||
constraints_string = tav.value.value_string;
|
||||
|
||||
|
||||
LLVMInlineAsmDialect dialect = LLVMInlineAsmDialectATT;
|
||||
switch (ia->dialect) {
|
||||
case InlineAsmDialect_Default: dialect = LLVMInlineAsmDialectATT; break;
|
||||
case InlineAsmDialect_ATT: dialect = LLVMInlineAsmDialectATT; break;
|
||||
case InlineAsmDialect_Intel: dialect = LLVMInlineAsmDialectIntel; break;
|
||||
default: GB_PANIC("Unhandled inline asm dialect"); break;
|
||||
}
|
||||
|
||||
LLVMTypeRef func_type = lb_type_internal_for_procedures_raw(p->module, t);
|
||||
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;
|
||||
}
|
||||
|
||||
GB_PANIC("lb_build_expr: %.*s", LIT(ast_strings[expr->kind]));
|
||||
|
||||
@@ -331,13 +331,6 @@ gb_internal Ast *clone_ast(Ast *node, AstFile *f) {
|
||||
n->AutoCast.expr = clone_ast(n->AutoCast.expr, f);
|
||||
break;
|
||||
|
||||
case Ast_InlineAsmExpr:
|
||||
n->InlineAsmExpr.param_types = clone_ast_array(n->InlineAsmExpr.param_types, f);
|
||||
n->InlineAsmExpr.return_type = clone_ast(n->InlineAsmExpr.return_type, f);
|
||||
n->InlineAsmExpr.asm_string = clone_ast(n->InlineAsmExpr.asm_string, f);
|
||||
n->InlineAsmExpr.constraints_string = clone_ast(n->InlineAsmExpr.constraints_string, f);
|
||||
break;
|
||||
|
||||
case Ast_BadStmt: break;
|
||||
case Ast_EmptyStmt: break;
|
||||
case Ast_ExprStmt:
|
||||
@@ -1072,32 +1065,6 @@ gb_internal Ast *ast_auto_cast(AstFile *f, Token token, Ast *expr) {
|
||||
}
|
||||
|
||||
|
||||
gb_internal Ast *ast_inline_asm_expr(AstFile *f, Token token, Token open, Token close,
|
||||
Array<Ast *> const ¶m_types,
|
||||
Ast *return_type,
|
||||
Ast *asm_string,
|
||||
Ast *constraints_string,
|
||||
bool has_side_effects,
|
||||
bool is_align_stack,
|
||||
InlineAsmDialectKind dialect) {
|
||||
|
||||
Ast *result = alloc_ast_node(f, Ast_InlineAsmExpr);
|
||||
result->InlineAsmExpr.token = token;
|
||||
result->InlineAsmExpr.open = open;
|
||||
result->InlineAsmExpr.close = close;
|
||||
result->InlineAsmExpr.param_types = slice_from_array(param_types);
|
||||
result->InlineAsmExpr.return_type = return_type;
|
||||
result->InlineAsmExpr.asm_string = asm_string;
|
||||
result->InlineAsmExpr.constraints_string = constraints_string;
|
||||
result->InlineAsmExpr.has_side_effects = has_side_effects;
|
||||
result->InlineAsmExpr.is_align_stack = is_align_stack;
|
||||
result->InlineAsmExpr.dialect = dialect;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
gb_internal Ast *ast_bad_stmt(AstFile *f, Token begin, Token end) {
|
||||
Ast *result = alloc_ast_node(f, Ast_BadStmt);
|
||||
result->BadStmt.begin = begin;
|
||||
@@ -2691,7 +2658,7 @@ gb_internal Ast *parse_asm_template(AstFile *f) {
|
||||
Token hash = expect_token(f, Token_Hash);
|
||||
Token name = expect_token(f, Token_Ident);
|
||||
|
||||
if (name.string == "side_effects" ||
|
||||
if (name.string == "volatile" ||
|
||||
name.string == "align_stack") {
|
||||
Ast *clobber = alloc_ast_node(f, Ast_AsmClobber);
|
||||
clobber->AsmClobber.token = hash;
|
||||
|
||||
@@ -571,17 +571,6 @@ AST_KIND(_ExprBegin, "", bool) \
|
||||
}) \
|
||||
AST_KIND(TypeCast, "type cast", struct { Token token; Ast *type, *expr; }) \
|
||||
AST_KIND(AutoCast, "auto_cast", struct { Token token; Ast *expr; }) \
|
||||
AST_KIND(InlineAsmExpr, "inline asm expression", struct { \
|
||||
Token token; \
|
||||
Token open, close; \
|
||||
Slice<Ast *> param_types; \
|
||||
Ast *return_type; \
|
||||
Ast *asm_string; \
|
||||
Ast *constraints_string; \
|
||||
bool has_side_effects; \
|
||||
bool is_align_stack; \
|
||||
InlineAsmDialectKind dialect; \
|
||||
}) \
|
||||
AST_KIND(MatrixIndexExpr, "matrix index expression", struct { Ast *expr, *row_index, *column_index; Token open, close; }) \
|
||||
AST_KIND(_ExprEnd, "", bool) \
|
||||
AST_KIND(_StmtBegin, "", bool) \
|
||||
|
||||
@@ -71,7 +71,6 @@ gb_internal Token ast_token(Ast *node) {
|
||||
case Ast_TypeAssertion: return ast_token(node->TypeAssertion.expr);
|
||||
case Ast_TypeCast: return node->TypeCast.token;
|
||||
case Ast_AutoCast: return node->AutoCast.token;
|
||||
case Ast_InlineAsmExpr: return node->InlineAsmExpr.token;
|
||||
|
||||
case Ast_BadStmt: return node->BadStmt.begin;
|
||||
case Ast_EmptyStmt: return node->EmptyStmt.token;
|
||||
@@ -254,7 +253,6 @@ Token ast_end_token(Ast *node) {
|
||||
case Ast_TypeAssertion: return ast_end_token(node->TypeAssertion.type);
|
||||
case Ast_TypeCast: return ast_end_token(node->TypeCast.expr);
|
||||
case Ast_AutoCast: return ast_end_token(node->AutoCast.expr);
|
||||
case Ast_InlineAsmExpr: return node->InlineAsmExpr.close;
|
||||
|
||||
case Ast_BadStmt: return node->BadStmt.end;
|
||||
case Ast_EmptyStmt: return node->EmptyStmt.token;
|
||||
|
||||
Reference in New Issue
Block a user