1 //===-- MSP430ISelDAGToDAG.cpp - A dag to dag inst selector for MSP430 ----===//
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 MSP430 target.
12 //===----------------------------------------------------------------------===//
15 #include "MSP430ISelLowering.h"
16 #include "MSP430TargetMachine.h"
17 #include "llvm/DerivedTypes.h"
18 #include "llvm/Function.h"
19 #include "llvm/Intrinsics.h"
20 #include "llvm/CallingConv.h"
21 #include "llvm/Constants.h"
22 #include "llvm/CodeGen/MachineFrameInfo.h"
23 #include "llvm/CodeGen/MachineFunction.h"
24 #include "llvm/CodeGen/MachineInstrBuilder.h"
25 #include "llvm/CodeGen/MachineRegisterInfo.h"
26 #include "llvm/CodeGen/SelectionDAG.h"
27 #include "llvm/CodeGen/SelectionDAGISel.h"
28 #include "llvm/Target/TargetLowering.h"
29 #include "llvm/Support/Compiler.h"
30 #include "llvm/Support/Debug.h"
35 /// MSP430DAGToDAGISel - MSP430 specific code to select MSP430 machine
36 /// instructions for SelectionDAG operations.
39 class MSP430DAGToDAGISel : public SelectionDAGISel {
40 MSP430TargetLowering &Lowering;
41 const MSP430Subtarget &Subtarget;
44 MSP430DAGToDAGISel(MSP430TargetMachine &TM)
45 : SelectionDAGISel(TM),
46 Lowering(*TM.getTargetLowering()),
47 Subtarget(*TM.getSubtargetImpl()) { }
49 virtual void InstructionSelect();
51 virtual const char *getPassName() const {
52 return "MSP430 DAG->DAG Pattern Instruction Selection";
55 // Include the pieces autogenerated from the target description.
56 #include "MSP430GenDAGISel.inc"
59 SDNode *Select(SDValue Op);
61 } // end anonymous namespace
63 /// createMSP430ISelDag - This pass converts a legalized DAG into a
64 /// MSP430-specific DAG, ready for instruction scheduling.
66 FunctionPass *llvm::createMSP430ISelDag(MSP430TargetMachine &TM) {
67 return new MSP430DAGToDAGISel(TM);
70 /// InstructionSelect - This callback is invoked by
71 /// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
72 void MSP430DAGToDAGISel::InstructionSelect() {
75 // Select target instructions for the DAG.
78 CurDAG->RemoveDeadNodes();
81 SDNode *MSP430DAGToDAGISel::Select(SDValue Op) {
82 return SelectCode(Op);