1354362524a72b3fa43a6c09380b7ae3b2380cbbaJuergen Ributzka//=- HexagonMachineFunctionInfo.h - Hexagon machine function info -*- C++ -*-=//
2b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
3b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//                     The LLVM Compiler Infrastructure
4b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
5b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// This file is distributed under the University of Illinois Open Source
6b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// License. See LICENSE.TXT for details.
7b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
8b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//===----------------------------------------------------------------------===//
9b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
10b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#ifndef HexagonMACHINEFUNCTIONINFO_H
11b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#define HexagonMACHINEFUNCTIONINFO_H
12b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
13b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "llvm/CodeGen/MachineFunction.h"
1436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include <map>
15b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
16b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumnamespace llvm {
17b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
18b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  namespace Hexagon {
19b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    const unsigned int StartPacket = 0x1;
20b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    const unsigned int EndPacket = 0x2;
21b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
22b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
23b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
24b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// Hexagon target-specific information for each MachineFunction.
25b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumclass HexagonMachineFunctionInfo : public MachineFunctionInfo {
26b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // SRetReturnReg - Some subtargets require that sret lowering includes
27b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // returning the value of the returned struct in a register. This field
28b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // holds the virtual register into which the sret argument is passed.
29b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  unsigned SRetReturnReg;
30b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  std::vector<MachineInstr*> AllocaAdjustInsts;
31b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  int VarArgsFrameIndex;
32b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  bool HasClobberLR;
336ea706e40e841c148bc47bcac4dcca5e0f0245ebJyotsna Verma  bool HasEHReturn;
34b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  std::map<const MachineInstr*, unsigned> PacketInfo;
35354362524a72b3fa43a6c09380b7ae3b2380cbbaJuergen Ributzka  virtual void anchor();
36b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
37b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumpublic:
386ea706e40e841c148bc47bcac4dcca5e0f0245ebJyotsna Verma  HexagonMachineFunctionInfo() : SRetReturnReg(0), HasClobberLR(0),
396ea706e40e841c148bc47bcac4dcca5e0f0245ebJyotsna Verma    HasEHReturn(false) {}
40b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
41b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  HexagonMachineFunctionInfo(MachineFunction &MF) : SRetReturnReg(0),
426ea706e40e841c148bc47bcac4dcca5e0f0245ebJyotsna Verma                                                    HasClobberLR(0),
436ea706e40e841c148bc47bcac4dcca5e0f0245ebJyotsna Verma                                                    HasEHReturn(false) {}
44b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
45b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  unsigned getSRetReturnReg() const { return SRetReturnReg; }
46b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
47b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
48b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  void addAllocaAdjustInst(MachineInstr* MI) {
49b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    AllocaAdjustInsts.push_back(MI);
50b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
51b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  const std::vector<MachineInstr*>& getAllocaAdjustInsts() {
52b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return AllocaAdjustInsts;
53b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
54b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
55b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  void setVarArgsFrameIndex(int v) { VarArgsFrameIndex = v; }
56b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  int getVarArgsFrameIndex() { return VarArgsFrameIndex; }
57b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
58b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  void setStartPacket(MachineInstr* MI) {
59b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    PacketInfo[MI] |= Hexagon::StartPacket;
60b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
61b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  void setEndPacket(MachineInstr* MI)   {
62b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    PacketInfo[MI] |= Hexagon::EndPacket;
63b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
64b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  bool isStartPacket(const MachineInstr* MI) const {
65b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return (PacketInfo.count(MI) &&
66b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum            (PacketInfo.find(MI)->second & Hexagon::StartPacket));
67b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
68b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  bool isEndPacket(const MachineInstr* MI) const {
69b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return (PacketInfo.count(MI) &&
70b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum            (PacketInfo.find(MI)->second & Hexagon::EndPacket));
71b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
72b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  void setHasClobberLR(bool v) { HasClobberLR = v;  }
73b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  bool hasClobberLR() const { return HasClobberLR; }
74b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
756ea706e40e841c148bc47bcac4dcca5e0f0245ebJyotsna Verma  bool hasEHReturn() const { return HasEHReturn; };
766ea706e40e841c148bc47bcac4dcca5e0f0245ebJyotsna Verma  void setHasEHReturn(bool H = true) { HasEHReturn = H; };
77b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum};
78b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum} // End llvm namespace
79b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
80b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#endif
81