blob: 6c2b8ec9747a8712a07e7ba0c0f0b50a1beb09e7 [file] [log] [blame]
Sanjiv Gupta0e687712008-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
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000016#include "PIC16ISelDAGToDAG.h"
Sanjiv Gupta0e687712008-05-13 09:02:57 +000017#include "llvm/Support/Debug.h"
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000018
Sanjiv Gupta0e687712008-05-13 09:02:57 +000019using namespace llvm;
20
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000021/// createPIC16ISelDag - This pass converts a legalized DAG into a
Sanjiv Gupta0e687712008-05-13 09:02:57 +000022/// PIC16-specific DAG, ready for instruction scheduling.
23FunctionPass *llvm::createPIC16ISelDag(PIC16TargetMachine &TM) {
24 return new PIC16DAGToDAGISel(TM);
25}
26
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000027
28/// InstructionSelect - This callback is invoked by
29/// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
30void PIC16DAGToDAGISel::InstructionSelect() {
31 DEBUG(BB->dump());
32 SelectRoot(*CurDAG);
33 CurDAG->RemoveDeadNodes();
34}
35
36/// Select - Select instructions not customized! Used for
37/// expanded, promoted and normal instructions.
38SDNode* PIC16DAGToDAGISel::Select(SDValue N) {
39
40 // Select the default instruction.
41 SDNode *ResNode = SelectCode(N);
42
43 return ResNode;
44}
45
46
47// SelectDirectAddr - Match a direct address for DAG.
48// A direct address could be a globaladdress or externalsymbol.
49bool PIC16DAGToDAGISel::SelectDirectAddr(SDValue Op, SDValue N,
50 SDValue &Address) {
51 // Return true if TGA or ES.
52 if (N.getOpcode() == ISD::TargetGlobalAddress
53 || N.getOpcode() == ISD::TargetExternalSymbol) {
54 Address = N;
55 return true;
56 }
57
58 return false;
59}