Sparc.h revision be8cc2a3dedeb7685f07e68cdc4b9502eb97eb2b
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//===-- Sparc.h - Top-level interface for Sparc representation --*- C++ -*-===//
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//                     The LLVM Compiler Infrastructure
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file is distributed under the University of Illinois Open Source
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// License. See LICENSE.TXT for details.
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//===----------------------------------------------------------------------===//
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file contains the entry points for global functions defined in the LLVM
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Sparc back-end.
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
13e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch//===----------------------------------------------------------------------===//
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef TARGET_SPARC_H
167dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#define TARGET_SPARC_H
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <cassert>
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace llvm {
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  class FunctionPass;
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  class TargetMachine;
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  class SparcTargetMachine;
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  class raw_ostream;
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FunctionPass *createSparcISelDag(SparcTargetMachine &TM);
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FunctionPass *createSparcCodePrinterPass(raw_ostream &OS, TargetMachine &TM,
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                           unsigned OptLevel, bool Verbose);
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FunctionPass *createSparcDelaySlotFillerPass(TargetMachine &TM);
30424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FunctionPass *createSparcFPMoverPass(TargetMachine &TM);
31424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)} // end namespace llvm;
32424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
33424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Defines symbolic names for Sparc registers.  This defines a mapping from
34424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// register name to register number.
35424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)//
36424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "SparcGenRegisterNames.inc"
37424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
38424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Defines symbolic names for the Sparc instructions.
39424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)//
40424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "SparcGenInstrNames.inc"
41424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
42424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
43424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace llvm {
44424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // Enums corresponding to Sparc condition codes, both icc's and fcc's.  These
45424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // values must be kept in sync with the ones in the .td file.
46424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  namespace SPCC {
47424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    enum CondCodes {
48424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      //ICC_A   =  8   ,  // Always
49424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      //ICC_N   =  0   ,  // Never
50424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_NE  =  9   ,  // Not Equal
51424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_E   =  1   ,  // Equal
52424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_G   = 10   ,  // Greater
53424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_LE  =  2   ,  // Less or Equal
54424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_GE  = 11   ,  // Greater or Equal
55424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_L   =  3   ,  // Less
56424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_GU  = 12   ,  // Greater Unsigned
57424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_LEU =  4   ,  // Less or Equal Unsigned
58424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_CC  = 13   ,  // Carry Clear/Great or Equal Unsigned
59424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_CS  =  5   ,  // Carry Set/Less Unsigned
60424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_POS = 14   ,  // Positive
61424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_NEG =  6   ,  // Negative
62424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_VC  = 15   ,  // Overflow Clear
63424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ICC_VS  =  7   ,  // Overflow Set
64424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
65424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      //FCC_A   =  8+16,  // Always
66424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      //FCC_N   =  0+16,  // Never
67424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_U   =  7+16,  // Unordered
68424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_G   =  6+16,  // Greater
69424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_UG  =  5+16,  // Unordered or Greater
70424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_L   =  4+16,  // Less
71424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_UL  =  3+16,  // Unordered or Less
72424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_LG  =  2+16,  // Less or Greater
73424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_NE  =  1+16,  // Not Equal
74424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_E   =  9+16,  // Equal
75424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_UE  = 10+16,  // Unordered or Equal
76424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_GE  = 11+16,  // Greater or Equal
77424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_UGE = 12+16,  // Unordered or Greater or Equal
78424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_LE  = 13+16,  // Less or Equal
79424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_ULE = 14+16,  // Unordered or Less or Equal
80424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      FCC_O   = 15+16   // Ordered
81424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    };
82424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  }
83424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
84424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  inline static const char *SPARCCondCodeToString(SPCC::CondCodes CC) {
85424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    switch (CC) {
86424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    default: assert(0 && "Unknown condition code");
87424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_NE:  return "ne";
88424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_E:   return "e";
89424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_G:   return "g";
90424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_LE:  return "le";
91424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_GE:  return "ge";
92424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_L:   return "l";
93424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_GU:  return "gu";
94424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_LEU: return "leu";
95424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_CC:  return "cc";
96424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_CS:  return "cs";
97424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_POS: return "pos";
98424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_NEG: return "neg";
99424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::ICC_VC:  return "vc";
100e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    case SPCC::ICC_VS:  return "vs";
101e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    case SPCC::FCC_U:   return "u";
102e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    case SPCC::FCC_G:   return "g";
103e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    case SPCC::FCC_UG:  return "ug";
104e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    case SPCC::FCC_L:   return "l";
105424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    case SPCC::FCC_UL:  return "ul";
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    case SPCC::FCC_LG:  return "lg";
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    case SPCC::FCC_NE:  return "ne";
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    case SPCC::FCC_E:   return "e";
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    case SPCC::FCC_UE:  return "ue";
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    case SPCC::FCC_GE:  return "ge";
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    case SPCC::FCC_UGE: return "uge";
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    case SPCC::FCC_LE:  return "le";
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    case SPCC::FCC_ULE: return "ule";
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    case SPCC::FCC_O:   return "o";
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // end namespace llvm
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)