blob: e14a0c2cb3c6236dc4df8bcb7ea4bcf70c4d3a34 [file] [log] [blame]
Sanjiv Gupta0e687712008-05-13 09:02:57 +00001//===-- PIC16ISelLowering.h - PIC16 DAG Lowering Interface ------*- C++ -*-===//
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 the interfaces that PIC16 uses to lower LLVM code into a
11// selection DAG.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef PIC16ISELLOWERING_H
16#define PIC16ISELLOWERING_H
17
Sanjiv Gupta0e687712008-05-13 09:02:57 +000018#include "PIC16.h"
19#include "PIC16Subtarget.h"
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +000020#include "llvm/CodeGen/SelectionDAG.h"
21#include "llvm/Target/TargetLowering.h"
Sanjiv Gupta0e687712008-05-13 09:02:57 +000022
23namespace llvm {
24 namespace PIC16ISD {
25 enum NodeType {
26 // Start the numbering from where ISD NodeType finishes.
Dan Gohman0ba2bcf2008-09-23 18:42:32 +000027 FIRST_NUMBER = ISD::BUILTIN_OP_END,
Sanjiv Gupta0e687712008-05-13 09:02:57 +000028
29 // used for encapsulating the expanded nodes into one node.
30 Package,
31
32 // Get the Higher 16 bits from a 32-bit immediate
33 Hi,
34
35 // Get the Lower 16 bits from a 32-bit immediate
36 Lo,
37
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +000038 Cmp, // PIC16 Generic Comparison instruction.
39 Branch, // PIC16 Generic Branch Instruction.
40 BTFSS, // PIC16 BitTest Instruction (Skip if set).
41 BTFSC, // PIC16 BitTest Instruction (Skip if clear).
Sanjiv Gupta0e687712008-05-13 09:02:57 +000042
43 // PIC16 comparison to be converted to either XOR or SUB
44 // Following instructions cater to those convertions.
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +000045 XORCC,
46 SUBCC,
Sanjiv Gupta0e687712008-05-13 09:02:57 +000047
48 // Get the Global Address wrapped into a wrapper that also captures
49 // the bank or page.
50 Wrapper,
51 SetBank,
52 SetPage
53 };
54 }
55
56 //===--------------------------------------------------------------------===//
57 // TargetLowering Implementation
58 //===--------------------------------------------------------------------===//
59 class PIC16TargetLowering : public TargetLowering
60 {
61 public:
62 typedef std::map<SDNode *, SDNode *> NodeMap_t;
63
64 explicit PIC16TargetLowering(PIC16TargetMachine &TM);
65
66 /// LowerOperation - Provide custom lowering hooks for some operations.
Dan Gohman475871a2008-07-27 21:46:04 +000067 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
Sanjiv Gupta0e687712008-05-13 09:02:57 +000068
Dan Gohman475871a2008-07-27 21:46:04 +000069 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG);
70 SDValue LowerFORMAL_ARGUMENTS(SDValue Op, SelectionDAG &DAG);
71 SDValue LowerRET(SDValue Op, SelectionDAG &DAG);
72 SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG);
73 SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG);
Sanjiv Gupta0e687712008-05-13 09:02:57 +000074
Dan Gohman475871a2008-07-27 21:46:04 +000075 SDValue RemoveHiLo(SDNode *, SelectionDAG &DAG,
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +000076 DAGCombinerInfo &DCI) const;
Dan Gohman475871a2008-07-27 21:46:04 +000077 SDValue LowerADDSUB(SDNode *, SelectionDAG &DAG,
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +000078 DAGCombinerInfo &DCI) const;
Dan Gohman475871a2008-07-27 21:46:04 +000079 SDValue LowerLOAD(SDNode *, SelectionDAG &DAG,
Sanjiv Gupta0e687712008-05-13 09:02:57 +000080 DAGCombinerInfo &DCI) const;
81
82 /// getTargetNodeName - This method returns the name of a target specific
83 // DAG node.
84 virtual const char *getTargetNodeName(unsigned Opcode) const;
Dan Gohman475871a2008-07-27 21:46:04 +000085 virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000086
87 // utility function.
Dan Gohman475871a2008-07-27 21:46:04 +000088 const SDValue *findLoadi8(const SDValue &Src, SelectionDAG &DAG) const;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000089 };
90} // namespace llvm
91
92#endif // PIC16ISELLOWERING_H