summaryrefslogtreecommitdiffstats
path: root/clang/include
diff options
context:
space:
mode:
authorRoman Levenstein <rlevenstein@apple.com>2016-03-16 18:00:46 +0000
committerRoman Levenstein <rlevenstein@apple.com>2016-03-16 18:00:46 +0000
commit35aa5cecf25162f4a88cdf1dbfe3f8fc3ed1a91c (patch)
treecd10e5f88885e6322f34eff7c85816a107616cbc /clang/include
parentbe37e62e0ceb6ba6777b8bd50924a4cc4cfa3f7d (diff)
downloadbcm5719-llvm-35aa5cecf25162f4a88cdf1dbfe3f8fc3ed1a91c.tar.gz
bcm5719-llvm-35aa5cecf25162f4a88cdf1dbfe3f8fc3ed1a91c.zip
Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end
Till now, preserve_mostcc/preserve_allcc calling convention attributes were only available at the LLVM IR level. This patch adds attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end. The code was mostly written by Juergen Ributzka. I just added support for the AArch64 target and tests. Differential Revision: http://reviews.llvm.org/D18025 llvm-svn: 263647
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang-c/Index.h2
-rw-r--r--clang/include/clang/AST/Type.h2
-rw-r--r--clang/include/clang/Basic/Attr.td10
-rw-r--r--clang/include/clang/Basic/AttrDocs.td67
-rw-r--r--clang/include/clang/Basic/Specifiers.h4
5 files changed, 84 insertions, 1 deletions
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 9c5c6807b29..a564af88b28 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -2971,6 +2971,8 @@ enum CXCallingConv {
CXCallingConv_X86_64SysV = 11,
CXCallingConv_X86VectorCall = 12,
CXCallingConv_Swift = 13,
+ CXCallingConv_PreserveMost = 14,
+ CXCallingConv_PreserveAll = 15,
CXCallingConv_Invalid = 100,
CXCallingConv_Unexposed = 200
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 6c3fd805df6..2e02ad1ea0f 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -3740,6 +3740,8 @@ public:
attr_inteloclbicc,
attr_ms_abi,
attr_sysv_abi,
+ attr_preserve_most,
+ attr_preserve_all,
attr_ptr32,
attr_ptr64,
attr_sptr,
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index f50cb296ada..f07f30d9960 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1399,6 +1399,16 @@ def Pascal : InheritableAttr {
let Documentation = [Undocumented];
}
+def PreserveMost : InheritableAttr {
+ let Spellings = [GNU<"preserve_most">];
+ let Documentation = [PreserveMostDocs];
+}
+
+def PreserveAll : InheritableAttr {
+ let Spellings = [GNU<"preserve_all">];
+ let Documentation = [PreserveAllDocs];
+}
+
def Target : InheritableAttr {
let Spellings = [GCC<"target">];
let Args = [StringArgument<"featuresStr">];
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index 4e80a8db096..4e2df24d4d5 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2172,3 +2172,70 @@ a global variable of the class type. Therefor, the old code could keep using
the old manged name and the new code will use the new mangled name with tags.
}];
}
+
+def PreserveMostDocs : Documentation {
+ let Category = DocCatCallingConvs;
+ let Content = [{
+On X86-64 and AArch64 targets, this attribute changes the calling convention of
+a function. The ``preserve_most`` calling convention attempts to make the code
+in the caller as unintrusive as possible. This convention behaves identically
+to the ``C`` calling convention on how arguments and return values are passed,
+but it uses a different set of caller/callee-saved registers. This alleviates
+the burden of saving and recovering a large register set before and after the
+call in the caller. If the arguments are passed in callee-saved registers,
+then they will be preserved by the callee across the call. This doesn't
+apply for values returned in callee-saved registers.
+
+- On X86-64 the callee preserves all general purpose registers, except for
+ R11. R11 can be used as a scratch register. Floating-point registers
+ (XMMs/YMMs) are not preserved and need to be saved by the caller.
+
+The idea behind this convention is to support calls to runtime functions
+that have a hot path and a cold path. The hot path is usually a small piece
+of code that doesn't use many registers. The cold path might need to call out to
+another function and therefore only needs to preserve the caller-saved
+registers, which haven't already been saved by the caller. The
+`preserve_most` calling convention is very similar to the ``cold`` calling
+convention in terms of caller/callee-saved registers, but they are used for
+different types of function calls. ``coldcc`` is for function calls that are
+rarely executed, whereas `preserve_most` function calls are intended to be
+on the hot path and definitely executed a lot. Furthermore ``preserve_most``
+doesn't prevent the inliner from inlining the function call.
+
+This calling convention will be used by a future version of the Objective-C
+runtime and should therefore still be considered experimental at this time.
+Although this convention was created to optimize certain runtime calls to
+the Objective-C runtime, it is not limited to this runtime and might be used
+by other runtimes in the future too. The current implementation only
+supports X86-64 and AArch64, but the intention is to support more architectures
+in the future.
+ }];
+}
+
+def PreserveAllDocs : Documentation {
+ let Category = DocCatCallingConvs;
+ let Content = [{
+On X86-64 and AArch64 targets, this attribute changes the calling convention of
+a function. The ``preserve_all`` calling convention attempts to make the code
+in the caller even less intrusive than the ``preserve_most`` calling convention.
+This calling convention also behaves identical to the ``C`` calling convention
+on how arguments and return values are passed, but it uses a different set of
+caller/callee-saved registers. This removes the burden of saving and
+recovering a large register set before and after the call in the caller. If
+the arguments are passed in callee-saved registers, then they will be
+preserved by the callee across the call. This doesn't apply for values
+returned in callee-saved registers.
+
+- On X86-64 the callee preserves all general purpose registers, except for
+ R11. R11 can be used as a scratch register. Furthermore it also preserves
+ all floating-point registers (XMMs/YMMs).
+
+The idea behind this convention is to support calls to runtime functions
+that don't need to call out to any other functions.
+
+This calling convention, like the ``preserve_most`` calling convention, will be
+used by a future version of the Objective-C runtime and should be considered
+experimental at this time.
+ }];
+}
+
diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h
index 9be0d5aaafd..8857e0df565 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -239,7 +239,9 @@ namespace clang {
CC_IntelOclBicc, // __attribute__((intel_ocl_bicc))
CC_SpirFunction, // default for OpenCL functions on SPIR target
CC_SpirKernel, // inferred for OpenCL kernels on SPIR target
- CC_Swift // __attribute__((swiftcall))
+ CC_Swift, // __attribute__((swiftcall))
+ CC_PreserveMost, // __attribute__((preserve_most))
+ CC_PreserveAll, // __attribute__((preserve_all))
};
/// \brief Checks whether the given calling convention supports variadic
OpenPOWER on IntegriCloud