blob: 41650ee33e563b49b4c72fa602005b8b22f50bc7 [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.
27 FIRST_NUMBER = ISD::BUILTIN_OP_END+PIC16::INSTRUCTION_LIST_END,
28
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.
67 virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
68
69 SDOperand LowerGlobalAddress(SDOperand Op, SelectionDAG &DAG);
70 SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG);
71 SDOperand LowerRET(SDOperand Op, SelectionDAG &DAG);
72 SDOperand LowerFrameIndex(SDOperand Op, SelectionDAG &DAG);
73 SDOperand LowerBR_CC(SDOperand Op, SelectionDAG &DAG);
74
75 SDOperand RemoveHiLo(SDNode *, SelectionDAG &DAG,
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +000076 DAGCombinerInfo &DCI) const;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000077 SDOperand LowerADDSUB(SDNode *, SelectionDAG &DAG,
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +000078 DAGCombinerInfo &DCI) const;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000079 SDOperand LowerLOAD(SDNode *, SelectionDAG &DAG,
80 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;
85 virtual SDOperand PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
86
87 // utility function.
88 const SDOperand *findLoadi8(const SDOperand &Src, SelectionDAG &DAG) const;
89 };
90} // namespace llvm
91
92#endif // PIC16ISELLOWERING_H