forked from OSchip/llvm-project
parent
d8a9d66d50
commit
744ad106c3
|
@ -85,6 +85,7 @@ static SmallString<32> Name(const WebAssemblyInstrInfo *TII,
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebAssemblyAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
void WebAssemblyAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||||
|
DEBUG(dbgs() << "EmitInstruction: " << *MI << '\n');
|
||||||
SmallString<128> Str;
|
SmallString<128> Str;
|
||||||
raw_svector_ostream OS(Str);
|
raw_svector_ostream OS(Str);
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,6 @@ WebAssemblyTargetLowering::LowerCall(CallLoweringInfo &CLI,
|
||||||
|
|
||||||
SmallVectorImpl<ISD::OutputArg> &Outs = CLI.Outs;
|
SmallVectorImpl<ISD::OutputArg> &Outs = CLI.Outs;
|
||||||
SmallVectorImpl<SDValue> &OutVals = CLI.OutVals;
|
SmallVectorImpl<SDValue> &OutVals = CLI.OutVals;
|
||||||
Type *retTy = CLI.RetTy;
|
|
||||||
bool IsStructRet = (Outs.empty()) ? false : Outs[0].Flags.isSRet();
|
bool IsStructRet = (Outs.empty()) ? false : Outs[0].Flags.isSRet();
|
||||||
if (IsStructRet)
|
if (IsStructRet)
|
||||||
fail(DL, DAG, "WebAssembly doesn't support struct return yet");
|
fail(DL, DAG, "WebAssembly doesn't support struct return yet");
|
||||||
|
@ -217,7 +216,6 @@ WebAssemblyTargetLowering::LowerCall(CallLoweringInfo &CLI,
|
||||||
fail(DL, DAG, "WebAssembly doesn't support more than 1 returned value yet");
|
fail(DL, DAG, "WebAssembly doesn't support more than 1 returned value yet");
|
||||||
|
|
||||||
SmallVectorImpl<ISD::InputArg> &Ins = CLI.Ins;
|
SmallVectorImpl<ISD::InputArg> &Ins = CLI.Ins;
|
||||||
ArgListTy &Args = CLI.getArgs();
|
|
||||||
bool IsVarArg = CLI.IsVarArg;
|
bool IsVarArg = CLI.IsVarArg;
|
||||||
if (IsVarArg)
|
if (IsVarArg)
|
||||||
fail(DL, DAG, "WebAssembly doesn't support varargs yet");
|
fail(DL, DAG, "WebAssembly doesn't support varargs yet");
|
||||||
|
@ -227,27 +225,29 @@ WebAssemblyTargetLowering::LowerCall(CallLoweringInfo &CLI,
|
||||||
unsigned NumBytes = CCInfo.getNextStackOffset();
|
unsigned NumBytes = CCInfo.getNextStackOffset();
|
||||||
|
|
||||||
auto PtrVT = getPointerTy(MF.getDataLayout());
|
auto PtrVT = getPointerTy(MF.getDataLayout());
|
||||||
auto Zero = DAG.getConstant(0, CLI.DL, PtrVT, true);
|
auto Zero = DAG.getConstant(0, DL, PtrVT, true);
|
||||||
auto NB = DAG.getConstant(NumBytes, CLI.DL, PtrVT, true);
|
auto NB = DAG.getConstant(NumBytes, DL, PtrVT, true);
|
||||||
Chain = DAG.getCALLSEQ_START(Chain, NB, CLI.DL);
|
Chain = DAG.getCALLSEQ_START(Chain, NB, DL);
|
||||||
|
|
||||||
SmallVector<SDValue, 16> Ops;
|
SmallVector<SDValue, 16> Ops;
|
||||||
Ops.push_back(Chain);
|
Ops.push_back(Chain);
|
||||||
Ops.push_back(CLI.Callee);
|
Ops.push_back(Callee);
|
||||||
Ops.append(CLI.OutVals.begin(), CLI.OutVals.end());
|
Ops.append(OutVals.begin(), OutVals.end());
|
||||||
|
|
||||||
SmallVector<EVT, 8> Tys;
|
SmallVector<EVT, 8> Tys;
|
||||||
for (const auto &In : CLI.Ins)
|
for (const auto &In : Ins)
|
||||||
Tys.push_back(In.VT);
|
Tys.push_back(In.VT);
|
||||||
Tys.push_back(MVT::Other);
|
Tys.push_back(MVT::Other);
|
||||||
SDVTList TyList = CLI.DAG.getVTList(Tys);
|
SDVTList TyList = DAG.getVTList(Tys);
|
||||||
SDValue Res = CLI.DAG.getNode(WebAssemblyISD::CALL, CLI.DL, TyList, Ops);
|
SDValue Res = DAG.getNode(WebAssemblyISD::CALL, DL, TyList, Ops);
|
||||||
InVals.push_back(Res);
|
if (!Ins.empty()) {
|
||||||
Chain = Res.getValue(1);
|
InVals.push_back(Res);
|
||||||
|
Chain = Res.getValue(1);
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: handle CLI.RetSExt and CLI.RetZExt?
|
// FIXME: handle CLI.RetSExt and CLI.RetZExt?
|
||||||
|
|
||||||
Chain = CLI.DAG.getCALLSEQ_END(Chain, NB, Zero, SDValue(), CLI.DL);
|
Chain = DAG.getCALLSEQ_END(Chain, NB, Zero, SDValue(), DL);
|
||||||
|
|
||||||
return Chain;
|
return Chain;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
target datalayout = "e-p:32:32-i64:64-v128:8:128-n32:64-S128"
|
target datalayout = "e-p:32:32-i64:64-v128:8:128-n32:64-S128"
|
||||||
target triple = "wasm32-unknown-unknown"
|
target triple = "wasm32-unknown-unknown"
|
||||||
|
|
||||||
declare void @nullary()
|
declare void @void_nullary()
|
||||||
|
declare void @int32_nullary()
|
||||||
|
|
||||||
; CHECK-LABEL: call_nullary:
|
; CHECK-LABEL: call_void_nullary:
|
||||||
; CHECK-NEXT: (call @foo)
|
; CHECK-NEXT: (call @foo)
|
||||||
; CHECK-NEXT: (return)
|
; CHECK-NEXT: (return)
|
||||||
define void @call_nullary() {
|
define void @call_void_nullary() {
|
||||||
call void @nullary()
|
call void @void_nullary()
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue