From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752720AbbGaKUd (ORCPT ); Fri, 31 Jul 2015 06:20:33 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:55454 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029AbbGaKUa (ORCPT ); Fri, 31 Jul 2015 06:20:30 -0400 From: Wang Nan To: CC: , , Subject: [LLVM PATCH] BPF: add FRAMEADDR support Date: Fri, 31 Jul 2015 10:20:13 +0000 Message-ID: <1438338013-184461-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <55BB4B8A.5000207@huawei.com> References: <55BB4B8A.5000207@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After this patch now BPF backend support __builtin_frame_address() and __builtin_dwarf_cfa(). Signed-off-by: Wang Nan --- lib/Target/BPF/BPFISelLowering.cpp | 20 ++++++++++++++++++++ lib/Target/BPF/BPFISelLowering.h | 1 + 2 files changed, 21 insertions(+) diff --git a/lib/Target/BPF/BPFISelLowering.cpp b/lib/Target/BPF/BPFISelLowering.cpp index 58498a1..f1934a2 100644 --- a/lib/Target/BPF/BPFISelLowering.cpp +++ b/lib/Target/BPF/BPFISelLowering.cpp @@ -169,6 +169,9 @@ BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM, MaxStoresPerMemset = MaxStoresPerMemsetOptSize = 128; MaxStoresPerMemcpy = MaxStoresPerMemcpyOptSize = 128; MaxStoresPerMemmove = MaxStoresPerMemmoveOptSize = 128; + + // support __builtin_frame_address(0) + setOperationAction(ISD::FRAMEADDR, MVT::i32, Custom); } SDValue BPFTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const { @@ -179,6 +182,8 @@ SDValue BPFTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const { return LowerGlobalAddress(Op, DAG); case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG); + case ISD::FRAMEADDR: + return LowerFRAMEADDR(Op, DAG); default: llvm_unreachable("unimplemented operand"); } @@ -509,6 +514,21 @@ SDValue BPFTargetLowering::LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const { return DAG.getNode(BPFISD::SELECT_CC, DL, VTs, Ops); } +SDValue BPFTargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const { + EVT VT = Op.getValueType(); + unsigned FrameReg = BPF::R11; + unsigned Depth = cast(Op.getOperand(0))->getZExtValue(); + + if (Depth != 0) { + SDLoc DL(Op); + MachineFunction &MF = DAG.getMachineFunction(); + DiagnosticInfoUnsupported Err(DL, *MF.getFunction(), + "only frame 0 address can be fetched", SDValue()); + DAG.getContext()->diagnose(Err); + } + return DAG.getRegister(FrameReg, VT); +} + const char *BPFTargetLowering::getTargetNodeName(unsigned Opcode) const { switch ((BPFISD::NodeType)Opcode) { case BPFISD::FIRST_NUMBER: diff --git a/lib/Target/BPF/BPFISelLowering.h b/lib/Target/BPF/BPFISelLowering.h index ec71dca..e4bf73d 100644 --- a/lib/Target/BPF/BPFISelLowering.h +++ b/lib/Target/BPF/BPFISelLowering.h @@ -50,6 +50,7 @@ private: SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const; SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; + SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const; // Lower the result values of a call, copying them out of physregs into vregs SDValue LowerCallResult(SDValue Chain, SDValue InFlag, -- 1.8.3.4