summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2016-03-03 06:39:32 +0000
committerJohn McCall <rjmccall@apple.com>2016-03-03 06:39:32 +0000
commit477f2bb0d53c070d63f992d15000575154fcd586 (patch)
tree65fd844b20fbb6c46c1424fe808246f69fa3d209 /clang/lib/AST
parenteb3413e43a88264494cbf8404c253b622fcb195d (diff)
downloadbcm5719-llvm-477f2bb0d53c070d63f992d15000575154fcd586.tar.gz
bcm5719-llvm-477f2bb0d53c070d63f992d15000575154fcd586.zip
Semantic analysis for the swiftcall calling convention.
I've tried to keep the infrastructure behind parameter ABI treatments fairly general. llvm-svn: 262587
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ItaniumMangle.cpp17
-rw-r--r--clang/lib/AST/Type.cpp3
-rw-r--r--clang/lib/AST/TypePrinter.cpp20
3 files changed, 39 insertions, 1 deletions
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 71c94104ccc..5e079960ae1 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2167,6 +2167,9 @@ StringRef CXXNameMangler::getCallingConvQualifierName(CallingConv CC) {
case CC_SpirKernel:
// FIXME: we should be mangling all of the above.
return "";
+
+ case CC_Swift:
+ return "swiftcall";
}
llvm_unreachable("bad calling convention");
}
@@ -2195,8 +2198,20 @@ CXXNameMangler::mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo PI) {
// Note that these are *not* substitution candidates. Demanglers might
// have trouble with this if the parameter type is fully substituted.
+ switch (PI.getABI()) {
+ case ParameterABI::Ordinary:
+ break;
+
+ // All of these start with "swift", so they come before "ns_consumed".
+ case ParameterABI::SwiftContext:
+ case ParameterABI::SwiftErrorResult:
+ case ParameterABI::SwiftIndirectResult:
+ mangleVendorQualifier(getParameterABISpelling(PI.getABI()));
+ break;
+ }
+
if (PI.isConsumed())
- Out << "U11ns_consumed";
+ mangleVendorQualifier("ns_consumed");
}
// <type> ::= <function-type>
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 6cd6c2a0060..efa2595f6d2 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2655,6 +2655,7 @@ StringRef FunctionType::getNameForCallConv(CallingConv CC) {
case CC_IntelOclBicc: return "intel_ocl_bicc";
case CC_SpirFunction: return "spir_function";
case CC_SpirKernel: return "spir_kernel";
+ case CC_Swift: return "swiftcall";
}
llvm_unreachable("Invalid calling convention.");
@@ -2995,6 +2996,7 @@ bool AttributedType::isQualifier() const {
case AttributedType::attr_stdcall:
case AttributedType::attr_thiscall:
case AttributedType::attr_pascal:
+ case AttributedType::attr_swiftcall:
case AttributedType::attr_vectorcall:
case AttributedType::attr_inteloclbicc:
case AttributedType::attr_ms_abi:
@@ -3048,6 +3050,7 @@ bool AttributedType::isCallingConv() const {
case attr_fastcall:
case attr_stdcall:
case attr_thiscall:
+ case attr_swiftcall:
case attr_vectorcall:
case attr_pascal:
case attr_ms_abi:
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index f6dbc78c471..47f60acb1d1 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -629,6 +629,20 @@ void TypePrinter::printFunctionProtoBefore(const FunctionProtoType *T,
}
}
+llvm::StringRef clang::getParameterABISpelling(ParameterABI ABI) {
+ switch (ABI) {
+ case ParameterABI::Ordinary:
+ llvm_unreachable("asking for spelling of ordinary parameter ABI");
+ case ParameterABI::SwiftContext:
+ return "swift_context";
+ case ParameterABI::SwiftErrorResult:
+ return "swift_error_result";
+ case ParameterABI::SwiftIndirectResult:
+ return "swift_indirect_result";
+ }
+ llvm_unreachable("bad parameter ABI kind");
+}
+
void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
raw_ostream &OS) {
// If needed for precedence reasons, wrap the inner part in grouping parens.
@@ -644,6 +658,9 @@ void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
auto EPI = T->getExtParameterInfo(i);
if (EPI.isConsumed()) OS << "__attribute__((ns_consumed)) ";
+ auto ABI = EPI.getABI();
+ if (ABI != ParameterABI::Ordinary)
+ OS << "__attribute__((" << getParameterABISpelling(ABI) << ")) ";
print(T->getParamType(i), OS, StringRef());
}
@@ -707,6 +724,8 @@ void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
case CC_SpirKernel:
// Do nothing. These CCs are not available as attributes.
break;
+ case CC_Swift:
+ OS << " __attribute__((swiftcall))";
}
}
@@ -1309,6 +1328,7 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
case AttributedType::attr_fastcall: OS << "fastcall"; break;
case AttributedType::attr_stdcall: OS << "stdcall"; break;
case AttributedType::attr_thiscall: OS << "thiscall"; break;
+ case AttributedType::attr_swiftcall: OS << "swiftcall"; break;
case AttributedType::attr_vectorcall: OS << "vectorcall"; break;
case AttributedType::attr_pascal: OS << "pascal"; break;
case AttributedType::attr_ms_abi: OS << "ms_abi"; break;
OpenPOWER on IntegriCloud