[llvm] r254075 - [WebAssembly] Codegen support for ISD::ExternalSymbol
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 25 09:59:24 PST 2015
This doesn't implement memcpy; it just implements ISD::ExternalSymbol
support, which memcpy happens to be a user of. When we have a real libc,
memcpy will indeed be resolved to a definition in libc.
On Wed, Nov 25, 2015 at 9:51 AM, JF Bastien <jfb at google.com> wrote:
> Could you comment on how this interacts with:
>
> http://reviews.llvm.org/rL251534
>
>
> Your intent is just to allow user-called memcpy? Is it a temporary thing
> until we do proper linking and have a real libc?
>
> On Wed, Nov 25, 2015 at 8:44 AM, Dan Gohman via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: djg
>> Date: Wed Nov 25 10:44:29 2015
>> New Revision: 254075
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=254075&view=rev
>> Log:
>> [WebAssembly] Codegen support for ISD::ExternalSymbol
>>
>> Modified:
>> llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
>> llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
>> llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
>> llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.h
>> llvm/trunk/test/CodeGen/WebAssembly/global.ll
>>
>> Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp?rev=254075&r1=254074&r2=254075&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
>> (original)
>> +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp Wed Nov
>> 25 10:44:29 2015
>> @@ -114,6 +114,7 @@ WebAssemblyTargetLowering::WebAssemblyTa
>> 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::Lower
>> 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::Lower
>> 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
>>
>> Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td?rev=254075&r1=254074&r2=254075&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td (original)
>> +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td Wed Nov 25
>> 10:44:29 2015
>> @@ -125,8 +125,10 @@ def CONST_F64 : I<(outs F64:$res), (ins
>> [(set F64:$res, fpimm:$imm)],
>> "f64.const\t$res, $imm">;
>>
>> -def : Pat<(i32 (WebAssemblywrapper tglobaladdr :$dst)),
>> - (CONST_I32 tglobaladdr :$dst)>;
>> +def : Pat<(i32 (WebAssemblywrapper tglobaladdr:$dst)),
>> + (CONST_I32 tglobaladdr:$dst)>;
>> +def : Pat<(i32 (WebAssemblywrapper texternalsym:$dst)),
>> + (CONST_I32 texternalsym:$dst)>;
>>
>> def JUMP_TABLE : I<(outs I32:$dst), (ins tjumptable_op:$addr),
>> [(set I32:$dst, (WebAssemblywrapper
>> tjumptable:$addr))],
>>
>> Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp?rev=254075&r1=254074&r2=254075&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
>> (original)
>> +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp Wed Nov
>> 25 10:44:29 2015
>> @@ -34,6 +34,11 @@ WebAssemblyMCInstLower::GetGlobalAddress
>> return Printer.getSymbol(MO.getGlobal());
>> }
>>
>> +MCSymbol *
>> +WebAssemblyMCInstLower::GetExternalSymbolSymbol(const MachineOperand
>> &MO) const {
>> + return Printer.GetExternalSymbolSymbol(MO.getSymbolName());
>> +}
>> +
>> MCOperand WebAssemblyMCInstLower::LowerSymbolOperand(const
>> MachineOperand &MO,
>> MCSymbol *Sym)
>> const {
>>
>> @@ -90,6 +95,9 @@ void WebAssemblyMCInstLower::Lower(const
>> case MachineOperand::MO_GlobalAddress:
>> MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
>> break;
>> + case MachineOperand::MO_ExternalSymbol:
>> + MCOp = LowerSymbolOperand(MO, GetExternalSymbolSymbol(MO));
>> + break;
>> }
>>
>> OutMI.addOperand(MCOp);
>>
>> Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.h?rev=254075&r1=254074&r2=254075&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.h (original)
>> +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.h Wed Nov 25
>> 10:44:29 2015
>> @@ -44,6 +44,7 @@ public:
>> MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym)
>> const;
>>
>> MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
>> + MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
>> };
>> }
>>
>>
>> Modified: llvm/trunk/test/CodeGen/WebAssembly/global.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/global.ll?rev=254075&r1=254074&r2=254075&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/WebAssembly/global.ll (original)
>> +++ llvm/trunk/test/CodeGen/WebAssembly/global.ll Wed Nov 25 10:44:29 2015
>> @@ -18,6 +18,18 @@ define i32 @foo() {
>> ret i32 %a
>> }
>>
>> +; CHECK-LABEL: call_memcpy:
>> +; CHECK-NEXT: .param i32, i32, i32{{$}}
>> +; CHECK-NEXT: .result i32{{$}}
>> +; CHECK-NEXT: i32.const $push0=, memcpy{{$}}
>> +; CHECK-NEXT: call_indirect $pop0, $0, $1, $2{{$}}
>> +; CHECK-NEXT: return $0{{$}}
>> +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture
>> readonly, i32, i32, i1)
>> +define i8* @call_memcpy(i8* %p, i8* nocapture readonly %q, i32 %n) {
>> + tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %p, i8* %q, i32 %n, i32
>> 1, i1 false)
>> + ret i8* %p
>> +}
>> +
>> ; CHECK: .type g, at object
>> ; CHECK: .align 2{{$}}
>> ; CHECK-NEXT: g:
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151125/65bdd7cd/attachment.html>
More information about the llvm-commits
mailing list