All that just to lower div and rem
[oota-llvm.git] / lib / Target / Alpha / AlphaISelLowering.h
1 //===-- AlphaISelLowering.h - Alpha DAG Lowering Interface ------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Andrew Lenharth and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the interfaces that Alpha uses to lower LLVM code into a
11 // selection DAG.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_TARGET_ALPHA_ALPHAISELLOWERING_H
16 #define LLVM_TARGET_ALPHA_ALPHAISELLOWERING_H
17
18 #include "llvm/Target/TargetLowering.h"
19 #include "llvm/CodeGen/SelectionDAG.h"
20 #include "Alpha.h"
21
22 namespace llvm {
23
24   namespace AlphaISD {
25     enum NodeType {
26       // Start the numbering where the builting ops and target ops leave off.
27       FIRST_NUMBER = ISD::BUILTIN_OP_END+Alpha::INSTRUCTION_LIST_END,
28       //These corrospond to the identical Instruction
29       ITOFT_, FTOIT_, CVTQT_, CVTQS_, CVTTQ_,
30
31       /// GPRelHi/GPRelLo - These represent the high and low 16-bit
32       /// parts of a global address respectively.
33       GPRelHi, GPRelLo, 
34
35       /// RetLit - Literal Relocation of a Global
36       RelLit,
37
38       /// GlobalBaseReg - used to restore the GOT ptr
39       GlobalBaseReg,
40
41       /// DIVCALL - used for special library calls for div and rem
42       DivCall,
43
44     };
45   }
46
47   class AlphaTargetLowering : public TargetLowering {
48     int VarArgsOffset;  // What is the offset to the first vaarg
49     int VarArgsBase;    // What is the base FrameIndex
50     unsigned GP; //GOT vreg
51     unsigned RA; //Return Address
52     bool useITOF;
53   public:
54     AlphaTargetLowering(TargetMachine &TM);
55     
56     /// LowerOperation - Provide custom lowering hooks for some operations.
57     ///
58     virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
59     
60     /// LowerArguments - This hook must be implemented to indicate how we should
61     /// lower the arguments for the specified function, into the specified DAG.
62     virtual std::vector<SDOperand>
63     LowerArguments(Function &F, SelectionDAG &DAG);
64
65     /// LowerCallTo - This hook lowers an abstract call to a function into an
66     /// actual call.
67     virtual std::pair<SDOperand, SDOperand>
68     LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, unsigned CC,
69                 bool isTailCall, SDOperand Callee, ArgListTy &Args,
70                 SelectionDAG &DAG);
71
72     virtual SDOperand LowerVAStart(SDOperand Chain, SDOperand VAListP,
73                                    Value *VAListV, SelectionDAG &DAG);
74     virtual SDOperand LowerVACopy(SDOperand Chain, SDOperand SrcP, Value *SrcV,
75                                   SDOperand DestP, Value *DestV,
76                                   SelectionDAG &DAG);
77     virtual std::pair<SDOperand,SDOperand>
78       LowerVAArg(SDOperand Chain, SDOperand VAListP, Value *VAListV,
79                  const Type *ArgTy, SelectionDAG &DAG);
80
81     void restoreGP(MachineBasicBlock* BB);
82     void restoreRA(MachineBasicBlock* BB);
83     unsigned getVRegGP() { return GP; }
84     unsigned getVRegRA() { return RA; }
85     bool hasITOF() { return useITOF; }
86   };
87 }
88
89 #endif   // LLVM_TARGET_ALPHA_ALPHAISELLOWERING_H