@@ -411,10 +411,6 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
411411 setOperationAction (ISD::INTRINSIC_W_CHAIN, MVT::Other, Custom);
412412 setOperationAction (ISD::INTRINSIC_VOID, MVT::Other, Custom);
413413
414- // Allow converting function ptrs in address space 0 to Wasm funcref (address
415- // space 20)
416- setOperationAction (ISD::ADDRSPACECAST, MVT::funcref, Custom);
417-
418414 setMaxAtomicSizeInBitsSupported (64 );
419415
420416 // Always convert switches to br_tables unless there is only one case, which
@@ -1760,8 +1756,6 @@ SDValue WebAssemblyTargetLowering::LowerOperation(SDValue Op,
17601756 return LowerMUL_LOHI (Op, DAG);
17611757 case ISD::UADDO:
17621758 return LowerUADDO (Op, DAG);
1763- case ISD::ADDRSPACECAST:
1764- return LowerADDRSPACECAST (Op, DAG);
17651759 }
17661760}
17671761
@@ -1905,58 +1899,6 @@ SDValue WebAssemblyTargetLowering::LowerUADDO(SDValue Op,
19051899 return DAG.getMergeValues (Ops, DL);
19061900}
19071901
1908- SDValue WebAssemblyTargetLowering::LowerADDRSPACECAST (SDValue Op,
1909- SelectionDAG &DAG) const {
1910- SDLoc DL (Op);
1911-
1912- AddrSpaceCastSDNode *ACN = cast<AddrSpaceCastSDNode>(Op.getNode ());
1913-
1914- if (ACN->getSrcAddressSpace () !=
1915- WebAssembly::WasmAddressSpace::WASM_ADDRESS_SPACE_DEFAULT ||
1916- ACN->getDestAddressSpace () !=
1917- WebAssembly::WasmAddressSpace::WASM_ADDRESS_SPACE_FUNCREF)
1918- return SDValue ();
1919-
1920- if (ACN->getValueType (0 ) != MVT::funcref) {
1921- reportFatalInternalError (" Cannot addrspacecast to funcref addrspace with "
1922- " results other than MVT::funcref" );
1923- }
1924-
1925- SDValue Src = ACN->getOperand (0 );
1926-
1927- // Lower addrspacecasts of direct/constant function ptrs to ref.func
1928- if (auto *GA = dyn_cast<GlobalAddressSDNode>(
1929- Src->getOpcode () == WebAssemblyISD::Wrapper ? Src->getOperand (0 )
1930- : Src)) {
1931- auto *GV = GA->getGlobal ();
1932-
1933- if (const Function *F = dyn_cast<Function>(GV)) {
1934- SDValue FnAddress = DAG.getTargetGlobalAddress (F, DL, MVT::i32 );
1935-
1936- SDValue RefFuncNode =
1937- DAG.getNode (WebAssemblyISD::REF_FUNC, DL, MVT::funcref, FnAddress);
1938- return RefFuncNode;
1939- }
1940- }
1941-
1942- // Lower everything else to a table.get from the indirect function table
1943- const MachineFunction &MF = DAG.getMachineFunction ();
1944-
1945- MVT PtrVT = getPointerTy (MF.getDataLayout ());
1946-
1947- MCSymbolWasm *Table =
1948- WebAssembly::getOrCreateFunctionTableSymbol (MF.getContext (), Subtarget);
1949- SDValue TableSym = DAG.getMCSymbol (Table, PtrVT);
1950-
1951- SDValue TableSlot = Op.getOperand (0 );
1952-
1953- SDValue Result (DAG.getMachineNode (WebAssembly::TABLE_GET_FUNCREF, DL,
1954- MVT::funcref, TableSym, TableSlot),
1955- 0 );
1956-
1957- return Result;
1958- }
1959-
19601902SDValue WebAssemblyTargetLowering::Replace128Op (SDNode *N,
19611903 SelectionDAG &DAG) const {
19621904 assert (Subtarget->hasWideArithmetic ());
0 commit comments