summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2015-12-04 17:16:07 +0000
committerDan Gohman <dan433584@gmail.com>2015-12-04 17:16:07 +0000
commit85dbdda1ed303acd949aa01e44667062dfc778ca (patch)
treea018d3d6527dc2cce4eedd9e7de98f3c2821f48c /llvm/lib
parent2d822e73fa0b1265b27339a796e7417b76f61efa (diff)
downloadbcm5719-llvm-85dbdda1ed303acd949aa01e44667062dfc778ca.tar.gz
bcm5719-llvm-85dbdda1ed303acd949aa01e44667062dfc778ca.zip
[WebAssembly] Factor out the list of supported calling conventions.
llvm-svn: 254728
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index c54ffb0654a..79d7cbbefa2 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -257,6 +257,16 @@ static void fail(SDLoc DL, SelectionDAG &DAG, const char *msg) {
DiagnosticInfoUnsupported(DL, *MF.getFunction(), msg, SDValue()));
}
+// Test whether the given calling convention is supported.
+static bool
+CallingConvSupported(CallingConv::ID CallConv) {
+ // We currently support the language-independent target-independent
+ // conventions.
+ return CallConv == CallingConv::C ||
+ CallConv == CallingConv::Fast ||
+ CallConv == CallingConv::Cold;
+}
+
SDValue
WebAssemblyTargetLowering::LowerCall(CallLoweringInfo &CLI,
SmallVectorImpl<SDValue> &InVals) const {
@@ -267,8 +277,7 @@ WebAssemblyTargetLowering::LowerCall(CallLoweringInfo &CLI,
MachineFunction &MF = DAG.getMachineFunction();
CallingConv::ID CallConv = CLI.CallConv;
- if (CallConv != CallingConv::C && CallConv != CallingConv::Fast &&
- CallConv != CallingConv::Cold)
+ if (!CallingConvSupported(CallConv))
fail(DL, DAG,
"WebAssembly doesn't support language-specific or target-specific "
"calling conventions yet");
@@ -367,7 +376,7 @@ SDValue WebAssemblyTargetLowering::LowerReturn(
const SmallVectorImpl<SDValue> &OutVals, SDLoc DL,
SelectionDAG &DAG) const {
assert(Outs.size() <= 1 && "WebAssembly can only return up to one value");
- if (CallConv != CallingConv::C)
+ if (!CallingConvSupported(CallConv))
fail(DL, DAG, "WebAssembly doesn't support non-C calling conventions");
if (IsVarArg)
fail(DL, DAG, "WebAssembly doesn't support varargs yet");
@@ -399,7 +408,7 @@ SDValue WebAssemblyTargetLowering::LowerFormalArguments(
SmallVectorImpl<SDValue> &InVals) const {
MachineFunction &MF = DAG.getMachineFunction();
- if (CallConv != CallingConv::C)
+ if (!CallingConvSupported(CallConv))
fail(DL, DAG, "WebAssembly doesn't support non-C calling conventions");
if (IsVarArg)
fail(DL, DAG, "WebAssembly doesn't support varargs yet");
OpenPOWER on IntegriCloud