blob: e13e6cd065fccf75026d4614255b99cd1d4ab582 [file] [log] [blame]
Sanjiv Gupta09bb4202008-05-13 09:02:57 +00001//===-- PIC16ISelDAGToDAG.cpp - A dag to dag inst selector for PIC16 ------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines an instruction selector for the PIC16 target.
11//
12//===----------------------------------------------------------------------===//
13
14#define DEBUG_TYPE "pic16-isel"
15
Edwin Török4d9756a2009-07-08 20:53:28 +000016#include "llvm/Support/ErrorHandling.h"
17#include "llvm/Support/raw_ostream.h"
Sanjiv Gupta085ae4f2008-11-19 11:00:54 +000018#include "PIC16ISelDAGToDAG.h"
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000019#include "llvm/Support/Debug.h"
Sanjiv Gupta085ae4f2008-11-19 11:00:54 +000020
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000021using namespace llvm;
22
Sanjiv Gupta085ae4f2008-11-19 11:00:54 +000023/// createPIC16ISelDag - This pass converts a legalized DAG into a
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000024/// PIC16-specific DAG, ready for instruction scheduling.
25FunctionPass *llvm::createPIC16ISelDag(PIC16TargetMachine &TM) {
26 return new PIC16DAGToDAGISel(TM);
27}
28
Sanjiv Gupta085ae4f2008-11-19 11:00:54 +000029
30/// InstructionSelect - This callback is invoked by
31/// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
32void PIC16DAGToDAGISel::InstructionSelect() {
Sanjiv Gupta085ae4f2008-11-19 11:00:54 +000033 SelectRoot(*CurDAG);
34 CurDAG->RemoveDeadNodes();
35}
36
37/// Select - Select instructions not customized! Used for
38/// expanded, promoted and normal instructions.
39SDNode* PIC16DAGToDAGISel::Select(SDValue N) {
40
41 // Select the default instruction.
42 SDNode *ResNode = SelectCode(N);
43
44 return ResNode;
45}
46
47
48// SelectDirectAddr - Match a direct address for DAG.
49// A direct address could be a globaladdress or externalsymbol.
50bool PIC16DAGToDAGISel::SelectDirectAddr(SDValue Op, SDValue N,
51 SDValue &Address) {
52 // Return true if TGA or ES.
53 if (N.getOpcode() == ISD::TargetGlobalAddress
54 || N.getOpcode() == ISD::TargetExternalSymbol) {
55 Address = N;
56 return true;
57 }
58
59 return false;
60}