From 1951dce526cca48df403afbb46de939be15acb73 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 4 Dec 2015 17:16:07 +0000 Subject: [PATCH] [WebAssembly] Factor out the list of supported calling conventions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254728 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../WebAssembly/WebAssemblyISelLowering.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index c54ffb0654a..79d7cbbefa2 100644 --- a/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/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 &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 &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 &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"); -- 2.34.1