1 //===-- ZPUISelDAGToDAG.cpp - A dag to dag inst selector for ZPU --------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines an instruction selector for the ZPU target.
12 //===----------------------------------------------------------------------===//
14 #define DEBUG_TYPE "ZPU-isel"
16 #include "ZPURegisterInfo.h"
17 #include "ZPUTargetMachine.h"
18 #include "llvm/GlobalValue.h"
19 #include "llvm/Instructions.h"
20 #include "llvm/Intrinsics.h"
21 #include "llvm/Support/CFG.h"
22 #include "llvm/Type.h"
23 #include "llvm/CodeGen/MachineConstantPool.h"
24 #include "llvm/CodeGen/MachineFunction.h"
25 #include "llvm/CodeGen/MachineFrameInfo.h"
26 #include "llvm/CodeGen/MachineInstrBuilder.h"
27 #include "llvm/CodeGen/MachineRegisterInfo.h"
28 #include "llvm/CodeGen/SelectionDAGISel.h"
29 #include "llvm/Target/TargetMachine.h"
30 #include "llvm/Support/Debug.h"
31 #include "llvm/Support/ErrorHandling.h"
32 #include "llvm/Support/raw_ostream.h"
35 //===----------------------------------------------------------------------===//
36 // Instruction Selector Implementation
37 //===----------------------------------------------------------------------===//
39 //===----------------------------------------------------------------------===//
40 // ZPUDAGToDAGISel - ZPU specific code to select ZPU machine
41 // instructions for SelectionDAG operations.
42 //===----------------------------------------------------------------------===//
45 class ZPUDAGToDAGISel
: public SelectionDAGISel
{
47 /// TM - Keep a reference to ZPUTargetMachine.
51 explicit ZPUDAGToDAGISel(ZPUTargetMachine
&tm
) :
56 virtual const char *getPassName() const {
57 return "ZPU DAG->DAG Pattern Instruction Selection";
62 // Include the pieces autogenerated from the target description.
63 #include "ZPUGenDAGISel.inc"
65 SDNode
*SelectStore(SDNode
*N
);
66 SDNode
*SelectOperand(SDNode
*N
);
68 /// getTargetMachine - Return a reference to the TargetMachine, casted
69 /// to the target-specific type.
70 const ZPUTargetMachine
&getTargetMachine() {
71 return static_cast<const ZPUTargetMachine
&>(TM
);
73 SDNode
*Select(SDNode
*N
);
76 /// getInstrInfo - Return a reference to the TargetInstrInfo, casted
77 /// to the target-specific type.
78 const ZPUInstrInfo
*getInstrInfo() {
79 return getTargetMachine().getInstrInfo();
81 bool SelectAddr(SDValue N
, SDValue
&Out
);
84 SDNode
*ZPUDAGToDAGISel::SelectOperand(SDNode
*N
) {
88 SDNode
*ZPUDAGToDAGISel::SelectStore(SDNode
*N
) {
89 StoreSDNode
*SN
= cast
<StoreSDNode
>(N
);
91 SDValue value
= N
->getOperand(0);
92 // SDValue *address = N->getOperand(1);
94 return value
.getNode();
98 /* Translate normal instructions into ZPU instructions */
99 SDNode
*ZPUDAGToDAGISel::Select(SDNode
*N
) {
100 unsigned Opcode
= N
->getOpcode();
101 DebugLoc dl
= N
->getDebugLoc();
103 // If we have a custom node, we already have selected!
104 if (N
->isMachineOpcode()) {
111 // return SelectStore(N);
114 return SelectCode(N
);
117 /// SelectAddr - returns true if it is able pattern match an addressing mode.
118 /// It returns the operands which make up the maximal addressing mode it can
119 /// match by reference.
120 bool ZPUDAGToDAGISel::SelectAddr(SDValue N
, SDValue
&Out
) {
127 /// createZPUISelDag - This pass converts a legalized DAG into a
128 /// ZPU-specific DAG, ready for instruction scheduling.
129 FunctionPass
*llvm::createZPUISelDag(ZPUTargetMachine
&TM
) {
130 return new ZPUDAGToDAGISel(TM
);