aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-04-28 10:49:30 +0100
committergingerBill <bill@gingerbill.org>2021-04-28 10:49:30 +0100
commit24fce21d9055ac4cd2124c0fe5396f430e99f24f (patch)
tree86e9b95d03038af2a63d10d760afa34940be2eca /src
parentafe185ee227b8d4540e4dc11b382eae0671575d2 (diff)
Add "naked" calling convention (removes prologue and epilogue)
Diffstat (limited to 'src')
-rw-r--r--src/docs_writer.cpp3
-rw-r--r--src/llvm_backend.cpp4
-rw-r--r--src/llvm_backend.hpp1
-rw-r--r--src/parser.cpp1
-rw-r--r--src/parser.hpp3
-rw-r--r--src/types.cpp3
6 files changed, 14 insertions, 1 deletions
diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp
index f4fd02376..03ea25930 100644
--- a/src/docs_writer.cpp
+++ b/src/docs_writer.cpp
@@ -697,6 +697,9 @@ OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
case ProcCC_None:
calling_convention = str_lit("none");
break;
+ case ProcCC_Naked:
+ calling_convention = str_lit("naked");
+ break;
case ProcCC_InlineAsm:
calling_convention = str_lit("inline-assembly");
break;
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp
index 74d5bbe01..f81077b47 100644
--- a/src/llvm_backend.cpp
+++ b/src/llvm_backend.cpp
@@ -2588,6 +2588,10 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity) {
lb_add_attribute_to_proc(m, p->value, "noreturn");
}
+ if (pt->Proc.calling_convention == ProcCC_Naked) {
+ lb_add_attribute_to_proc(m, p->value, "naked");
+ }
+
switch (p->inlining) {
case ProcInlining_inline:
lb_add_attribute_to_proc(m, p->value, "alwaysinline");
diff --git a/src/llvm_backend.hpp b/src/llvm_backend.hpp
index e8811a91e..cd6a99c20 100644
--- a/src/llvm_backend.hpp
+++ b/src/llvm_backend.hpp
@@ -472,6 +472,7 @@ lbCallingConventionKind const lb_calling_convention_map[ProcCC_MAX] = {
lbCallingConvention_X86_FastCall, // ProcCC_FastCall,
lbCallingConvention_C, // ProcCC_None,
+ lbCallingConvention_C, // ProcCC_Naked,
lbCallingConvention_C, // ProcCC_InlineAsm,
};
diff --git a/src/parser.cpp b/src/parser.cpp
index a7e4c9162..a6764de08 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -3220,6 +3220,7 @@ ProcCallingConvention string_to_calling_convention(String s) {
if (s == "fastcall") return ProcCC_FastCall;
if (s == "fast") return ProcCC_FastCall;
if (s == "none") return ProcCC_None;
+ if (s == "naked") return ProcCC_Naked;
return ProcCC_Invalid;
}
diff --git a/src/parser.hpp b/src/parser.hpp
index 8c2eadb46..93c0363ab 100644
--- a/src/parser.hpp
+++ b/src/parser.hpp
@@ -215,8 +215,9 @@ enum ProcCallingConvention {
ProcCC_FastCall = 5,
ProcCC_None = 6,
+ ProcCC_Naked = 7,
- ProcCC_InlineAsm = 7,
+ ProcCC_InlineAsm = 8,
ProcCC_MAX,
diff --git a/src/types.cpp b/src/types.cpp
index 56081acc8..7b5b81c43 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -3618,6 +3618,9 @@ gbString write_type_to_string(gbString str, Type *type) {
case ProcCC_None:
str = gb_string_appendc(str, " \"none\" ");
break;
+ case ProcCC_Naked:
+ str = gb_string_appendc(str, " \"naked\" ");
+ break;
// case ProcCC_VectorCall:
// str = gb_string_appendc(str, " \"vectorcall\" ");
// break;