blob: 7be8147bc55abf1f2c6744951de4c84493be03c1 [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
Torok Edwindac237e2009-07-08 20:53:28 +000016#include "llvm/Support/ErrorHandling.h"
Chris Lattnerbebe68e2010-02-22 22:14:47 +000017#include "PIC16ISelDAGToDAG.h"
Sanjiv Gupta0e687712008-05-13 09:02:57 +000018using namespace llvm;
19
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000020/// createPIC16ISelDag - This pass converts a legalized DAG into a
Sanjiv Gupta0e687712008-05-13 09:02:57 +000021/// PIC16-specific DAG, ready for instruction scheduling.
22FunctionPass *llvm::createPIC16ISelDag(PIC16TargetMachine &TM) {
23 return new PIC16DAGToDAGISel(TM);
24}
25
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000026
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000027/// Select - Select instructions not customized! Used for
28/// expanded, promoted and normal instructions.
Dan Gohmaneeb3a002010-01-05 01:24:18 +000029SDNode* PIC16DAGToDAGISel::Select(SDNode *N) {
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000030
31 // Select the default instruction.
32 SDNode *ResNode = SelectCode(N);
33
34 return ResNode;
35}
36
37
38// SelectDirectAddr - Match a direct address for DAG.
39// A direct address could be a globaladdress or externalsymbol.
Chris Lattner52a261b2010-09-21 20:31:19 +000040bool PIC16DAGToDAGISel::SelectDirectAddr(SDValue N, SDValue &Address) {
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000041 // Return true if TGA or ES.
42 if (N.getOpcode() == ISD::TargetGlobalAddress
43 || N.getOpcode() == ISD::TargetExternalSymbol) {
44 Address = N;
45 return true;
46 }
47
48 return false;
49}