blob: a08bb1e5b61f5f4c6c9576e60cefb0fc938688ff [file] [log] [blame]
Andrew Lenharth9690a4f2005-09-02 18:46:02 +00001//===-- 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
Andrew Lenharthb0316ea2006-06-21 13:37:27 +000018#include "llvm/ADT/VectorExtras.h"
Andrew Lenharth9690a4f2005-09-02 18:46:02 +000019#include "llvm/Target/TargetLowering.h"
20#include "llvm/CodeGen/SelectionDAG.h"
21#include "Alpha.h"
22
23namespace llvm {
24
Andrew Lenharth7b698672005-10-20 00:28:31 +000025 namespace AlphaISD {
26 enum NodeType {
27 // Start the numbering where the builting ops and target ops leave off.
28 FIRST_NUMBER = ISD::BUILTIN_OP_END+Alpha::INSTRUCTION_LIST_END,
Andrew Lenharth6db615d2005-11-30 07:19:56 +000029 //These corrospond to the identical Instruction
Andrew Lenharth873ed822005-11-30 16:10:29 +000030 ITOFT_, FTOIT_, CVTQT_, CVTQS_, CVTTQ_,
Andrew Lenharth46214882005-12-24 05:36:33 +000031
32 /// GPRelHi/GPRelLo - These represent the high and low 16-bit
Andrew Lenharth5b18ed92005-12-24 08:29:32 +000033 /// parts of a global address respectively.
34 GPRelHi, GPRelLo,
35
36 /// RetLit - Literal Relocation of a Global
37 RelLit,
Andrew Lenharth46214882005-12-24 05:36:33 +000038
Andrew Lenharth0fce6132005-12-25 01:34:27 +000039 /// GlobalBaseReg - used to restore the GOT ptr
Andrew Lenharth46214882005-12-24 05:36:33 +000040 GlobalBaseReg,
Andrew Lenharthf570fee2006-06-13 18:27:39 +000041
42 /// GlobalRetAddr - used to restore the return address
43 GlobalRetAddr,
Chris Lattner2c00db82006-01-27 23:39:00 +000044
45 /// CALL - Normal call.
46 CALL,
Andrew Lenharth46214882005-12-24 05:36:33 +000047
Andrew Lenharth0fce6132005-12-25 01:34:27 +000048 /// DIVCALL - used for special library calls for div and rem
Andrew Lenharth80528492006-06-12 18:09:24 +000049 DivCall,
50
51 /// return flag operand
52 RET_FLAG
Andrew Lenharth0fce6132005-12-25 01:34:27 +000053
Andrew Lenharth7b698672005-10-20 00:28:31 +000054 };
55 }
56
Andrew Lenharth9690a4f2005-09-02 18:46:02 +000057 class AlphaTargetLowering : public TargetLowering {
58 int VarArgsOffset; // What is the offset to the first vaarg
59 int VarArgsBase; // What is the base FrameIndex
60 unsigned GP; //GOT vreg
61 unsigned RA; //Return Address
Andrew Lenharth6db615d2005-11-30 07:19:56 +000062 bool useITOF;
Andrew Lenharth9690a4f2005-09-02 18:46:02 +000063 public:
64 AlphaTargetLowering(TargetMachine &TM);
Andrew Lenharth6db615d2005-11-30 07:19:56 +000065
66 /// LowerOperation - Provide custom lowering hooks for some operations.
67 ///
68 virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
Nate Begeman595ec732006-01-28 03:14:31 +000069 virtual SDOperand CustomPromoteOperation(SDOperand Op, SelectionDAG &DAG);
Andrew Lenharth81b108c2006-01-16 19:53:25 +000070
71 //Friendly names for dumps
72 const char *getTargetNodeName(unsigned Opcode) const;
73
Andrew Lenharth9690a4f2005-09-02 18:46:02 +000074 /// LowerCallTo - This hook lowers an abstract call to a function into an
75 /// actual call.
76 virtual std::pair<SDOperand, SDOperand>
77 LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, unsigned CC,
78 bool isTailCall, SDOperand Callee, ArgListTy &Args,
79 SelectionDAG &DAG);
80
Andrew Lenharthb0316ea2006-06-21 13:37:27 +000081 ConstraintType getConstraintType(char ConstraintLetter) const;
82
83 std::vector<unsigned>
84 getRegClassForInlineAsmConstraint(const std::string &Constraint,
85 MVT::ValueType VT) const;
86
Andrew Lenharth9690a4f2005-09-02 18:46:02 +000087 void restoreGP(MachineBasicBlock* BB);
88 void restoreRA(MachineBasicBlock* BB);
Andrew Lenharth5a990412005-10-22 22:06:58 +000089 unsigned getVRegGP() { return GP; }
90 unsigned getVRegRA() { return RA; }
Andrew Lenharth6db615d2005-11-30 07:19:56 +000091 bool hasITOF() { return useITOF; }
Andrew Lenharth9690a4f2005-09-02 18:46:02 +000092 };
93}
94
95#endif // LLVM_TARGET_ALPHA_ALPHAISELLOWERING_H