-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathVSelectionDAGInfo.cpp
More file actions
129 lines (113 loc) · 5.32 KB
/
VSelectionDAGInfo.cpp
File metadata and controls
129 lines (113 loc) · 5.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//===-- VSelectionDAGInfo.cpp - VTM SelectionDAG Info ---------===//
//
// The Shang HLS frameowrk //
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the VSelectionDAGInfo class.
//
//===----------------------------------------------------------------------===//
#include "VTargetMachine.h"
#include "llvm/LLVMContext.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/Support/CommandLine.h"
#define DEBUG_TYPE "vtm-selectiondag-info"
#include "llvm/Support/Debug.h"
using namespace llvm;
cl::opt<bool> EnableMemSCM("vtm-enable-memscm",
cl::init(true), cl::Hidden);
VSelectionDAGInfo::VSelectionDAGInfo(const VTargetMachine &TM)
: TargetSelectionDAGInfo(TM) {
}
VSelectionDAGInfo::~VSelectionDAGInfo() {
}
static SDValue EmitMemSCM(unsigned Cmd, SelectionDAG &DAG, DebugLoc dl,
SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3,
unsigned Align, bool isVolatile,
MachinePointerInfo DstPtrInfo,
MachinePointerInfo SrcPtrInfo) {
if (!EnableMemSCM) return SDValue();
// Emit the memset command on the membus.
LLVMContext *Cntx = DAG.getContext();
EVT CmdVT = EVT::getIntegerVT(*Cntx, VFUMemBus::CMDWidth);
SDValue SDOps[] = {// The chain.
Chain,
// Dst pointer and num.
Op1, Op3,
// CMD
DAG.getTargetConstant(Cmd, CmdVT),
// Byte enable.
DAG.getTargetConstant(VFUMemBus::SeqBegin, MVT::i8)};
unsigned DataWidth = getFUDesc<VFUMemBus>()->getDataWidth();
MVT DataVT = EVT::getIntegerVT(*DAG.getContext(), DataWidth).getSimpleVT();
SDValue MemsetCmd0 =
DAG.getMemIntrinsicNode(VTMISD::MemAccess, dl,
// Result and the chain.
DAG.getVTList(DataVT, MVT::Other),
// SDValue operands
SDOps, array_lengthof(SDOps),
// Memory operands.
/*FIXME*/MVT::i8, DstPtrInfo, Align, isVolatile,
false, true);
unsigned AddrWidth = getFUDesc<VFUMemBus>()->getAddrWidth();
SDOps[0] = MemsetCmd0.getValue(1);
if (Cmd == VFUMemBus::CmdMemSet) {
SDOps[1] = DAG.getTargetConstant(0, EVT::getIntegerVT(*Cntx, AddrWidth));
// Value, according to memset fills the block of memory using the
// unsigned char conversion of this value.
SDOps[2] = VTargetLowering::getTruncate(DAG, dl, Op2, 8);
} else {
// Source pointer.
SDOps[1] = Op2;
SDOps[2] = DAG.getTargetConstant(0, EVT::getIntegerVT(*Cntx, DataWidth));
}
SDOps[4] = DAG.getTargetConstant(VFUMemBus::SeqEnd, MVT::i8);
SDValue MemsetCmd1 =
DAG.getMemIntrinsicNode(VTMISD::MemAccess, dl,
// Result and the chain.
DAG.getVTList(DataVT, MVT::Other),
// SDValue operands
SDOps, array_lengthof(SDOps),
// Memory operands.
/*FIXME*/MVT::i8, SrcPtrInfo, Align, isVolatile,
false, true);
// Return the chain.
return MemsetCmd1.getValue(1);
}
SDValue
VSelectionDAGInfo::EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl,
SDValue Chain,
SDValue Op1, SDValue Op2,
SDValue Op3, unsigned Align,
bool isVolatile,
MachinePointerInfo DstPtrInfo) const{
return EmitMemSCM(VFUMemBus::CmdMemSet, DAG, dl,
Chain, Op1, Op2, Op3,
Align, isVolatile, DstPtrInfo, MachinePointerInfo());
}
SDValue
VSelectionDAGInfo::EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl,
SDValue Chain,
SDValue Op1, SDValue Op2,
SDValue Op3, unsigned Align,
bool isVolatile, bool AlwaysInline,
MachinePointerInfo DstPtrInfo,
MachinePointerInfo SrcPtrInfo) const{
return EmitMemSCM(VFUMemBus::CmdMemCpy, DAG, dl,
Chain, Op1, Op2, Op3,
Align, isVolatile, DstPtrInfo, SrcPtrInfo);
}
SDValue
VSelectionDAGInfo::EmitTargetCodeForMemmove(SelectionDAG &DAG, DebugLoc dl,
SDValue Chain,
SDValue Op1, SDValue Op2,
SDValue Op3, unsigned Align, bool isVolatile,
MachinePointerInfo DstPtrInfo,
MachinePointerInfo SrcPtrInfo)const{
return EmitMemSCM(VFUMemBus::CmdMemMove, DAG, dl,
Chain, Op1, Op2, Op3,
Align, isVolatile, DstPtrInfo, SrcPtrInfo);
}