diff options
author | Dan Gohman <dan433584@gmail.com> | 2015-11-25 16:44:29 +0000 |
---|---|---|
committer | Dan Gohman <dan433584@gmail.com> | 2015-11-25 16:44:29 +0000 |
commit | 2c8fe6a428668f8fdbdb88d98104f591ff142ad8 (patch) | |
tree | 2521f21bfc3622c0fbdc9f6495e00b2377ca1acd /llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | |
parent | 7bca3db8b9763ac71f4c3e7d9c18b074e6ed1c00 (diff) | |
download | llvm-2c8fe6a428668f8fdbdb88d98104f591ff142ad8.zip llvm-2c8fe6a428668f8fdbdb88d98104f591ff142ad8.tar.gz llvm-2c8fe6a428668f8fdbdb88d98104f591ff142ad8.tar.bz2 |
[WebAssembly] Codegen support for ISD::ExternalSymbol
llvm-svn: 254075
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index 06a141c..4febdb0 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -114,6 +114,7 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering( computeRegisterProperties(Subtarget->getRegisterInfo()); setOperationAction(ISD::GlobalAddress, MVTPtr, Custom); + setOperationAction(ISD::ExternalSymbol, MVTPtr, Custom); setOperationAction(ISD::JumpTable, MVTPtr, Custom); for (auto T : {MVT::f32, MVT::f64}) { @@ -412,6 +413,8 @@ SDValue WebAssemblyTargetLowering::LowerOperation(SDValue Op, return SDValue(); case ISD::GlobalAddress: return LowerGlobalAddress(Op, DAG); + case ISD::ExternalSymbol: + return LowerExternalSymbol(Op, DAG); case ISD::JumpTable: return LowerJumpTable(Op, DAG); case ISD::BR_JT: @@ -433,6 +436,16 @@ SDValue WebAssemblyTargetLowering::LowerGlobalAddress(SDValue Op, DAG.getTargetGlobalAddress(GA->getGlobal(), DL, VT)); } +SDValue WebAssemblyTargetLowering::LowerExternalSymbol(SDValue Op, + SelectionDAG &DAG) const { + SDLoc DL(Op); + const auto *ES = cast<ExternalSymbolSDNode>(Op); + EVT VT = Op.getValueType(); + assert(ES->getTargetFlags() == 0 && "WebAssembly doesn't set target flags"); + return DAG.getNode(WebAssemblyISD::Wrapper, DL, VT, + DAG.getTargetExternalSymbol(ES->getSymbol(), VT)); +} + SDValue WebAssemblyTargetLowering::LowerJumpTable(SDValue Op, SelectionDAG &DAG) const { // There's no need for a Wrapper node because we always incorporate a jump |