Add @(no_red_zone) for procedures

This commit is contained in:
gingerBill
2022-02-23 11:23:27 +00:00
parent 3d209798c9
commit 493bc653b5
5 changed files with 21 additions and 0 deletions

View File

@@ -826,6 +826,14 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
}
e->Procedure.optimization_mode = cast(ProcedureOptimizationMode)ac.optimization_mode;
if (ac.no_red_zone) {
if (!is_arch_wasm()) {
e->Procedure.no_red_zone = true;
} else {
error(e->token, "@(no_red_zone) is not supported on this target architecture");
}
}
if (ac.objc_name.len || ac.objc_is_class_method || ac.objc_type) {
if (ac.objc_name.len == 0 && ac.objc_is_class_method) {
error(e->token, "@(objc_name) is required with @(objc_is_class_method)");

View File

@@ -3128,6 +3128,13 @@ DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
}
}
return true;
} else if (name == "no_red_zone") {
if (value != nullptr) {
error(elem, "Expected no value for '%.*s'", LIT(name));
} else {
ac->no_red_zone = true;
}
return true;
}
return false;
}

View File

@@ -117,6 +117,7 @@ struct AttributeContext {
bool test : 1;
bool init : 1;
bool set_cold : 1;
bool no_red_zone : 1;
u32 optimization_mode; // ProcedureOptimizationMode
String objc_class;

View File

@@ -226,6 +226,7 @@ struct Entity {
bool is_foreign;
bool is_export;
bool generated_from_polymorphic;
bool no_red_zone;
ProcedureOptimizationMode optimization_mode;
} Procedure;
struct {

View File

@@ -135,6 +135,10 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body)
lb_add_attribute_to_proc(m, p->value, "naked");
}
if (entity->Procedure.no_red_zone) {
lb_add_attribute_to_proc(m, p->value, "noredzone");
}
switch (p->inlining) {
case ProcInlining_inline:
lb_add_attribute_to_proc(m, p->value, "alwaysinline");