| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 1 | //===-- Sparc.h - Top-level interface for Sparc representation --*- C++ -*-===// | 
|  | 2 | // | 
|  | 3 | //                     The LLVM Compiler Infrastructure | 
|  | 4 | // | 
| Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source | 
|  | 6 | // License. See LICENSE.TXT for details. | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 7 | // | 
|  | 8 | //===----------------------------------------------------------------------===// | 
|  | 9 | // | 
|  | 10 | // This file contains the entry points for global functions defined in the LLVM | 
|  | 11 | // Sparc back-end. | 
|  | 12 | // | 
|  | 13 | //===----------------------------------------------------------------------===// | 
|  | 14 |  | 
|  | 15 | #ifndef TARGET_SPARC_H | 
|  | 16 | #define TARGET_SPARC_H | 
|  | 17 |  | 
| Evan Cheng | bc153d4 | 2011-07-14 20:59:42 +0000 | [diff] [blame] | 18 | #include "MCTargetDesc/SparcMCTargetDesc.h" | 
| Torok Edwin | 56d0659 | 2009-07-11 20:10:48 +0000 | [diff] [blame] | 19 | #include "llvm/Support/ErrorHandling.h" | 
| Bill Wendling | 026e5d7 | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 20 | #include "llvm/Target/TargetMachine.h" | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 21 |  | 
|  | 22 | namespace llvm { | 
|  | 23 | class FunctionPass; | 
| Dan Gohman | 2c836cf | 2008-10-03 16:55:19 +0000 | [diff] [blame] | 24 | class SparcTargetMachine; | 
| David Greene | a31f96c | 2009-07-14 20:18:05 +0000 | [diff] [blame] | 25 | class formatted_raw_ostream; | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 26 |  | 
| Dan Gohman | 2c836cf | 2008-10-03 16:55:19 +0000 | [diff] [blame] | 27 | FunctionPass *createSparcISelDag(SparcTargetMachine &TM); | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 28 | FunctionPass *createSparcDelaySlotFillerPass(TargetMachine &TM); | 
| Venkatraman Govindaraju | 2ea4c28 | 2013-10-08 07:15:22 +0000 | [diff] [blame] | 29 | FunctionPass *createSparcJITCodeEmitterPass(SparcTargetMachine &TM, | 
|  | 30 | JITCodeEmitter &JCE); | 
| Daniel Dunbar | 67038c1 | 2009-07-18 23:03:22 +0000 | [diff] [blame] | 31 |  | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 32 | } // end namespace llvm; | 
|  | 33 |  | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 34 | namespace llvm { | 
|  | 35 | // Enums corresponding to Sparc condition codes, both icc's and fcc's.  These | 
|  | 36 | // values must be kept in sync with the ones in the .td file. | 
|  | 37 | namespace SPCC { | 
|  | 38 | enum CondCodes { | 
|  | 39 | //ICC_A   =  8   ,  // Always | 
|  | 40 | //ICC_N   =  0   ,  // Never | 
|  | 41 | ICC_NE  =  9   ,  // Not Equal | 
|  | 42 | ICC_E   =  1   ,  // Equal | 
|  | 43 | ICC_G   = 10   ,  // Greater | 
|  | 44 | ICC_LE  =  2   ,  // Less or Equal | 
|  | 45 | ICC_GE  = 11   ,  // Greater or Equal | 
|  | 46 | ICC_L   =  3   ,  // Less | 
|  | 47 | ICC_GU  = 12   ,  // Greater Unsigned | 
|  | 48 | ICC_LEU =  4   ,  // Less or Equal Unsigned | 
|  | 49 | ICC_CC  = 13   ,  // Carry Clear/Great or Equal Unsigned | 
|  | 50 | ICC_CS  =  5   ,  // Carry Set/Less Unsigned | 
|  | 51 | ICC_POS = 14   ,  // Positive | 
|  | 52 | ICC_NEG =  6   ,  // Negative | 
|  | 53 | ICC_VC  = 15   ,  // Overflow Clear | 
|  | 54 | ICC_VS  =  7   ,  // Overflow Set | 
| Venkatraman Govindaraju | a54533ed | 2013-06-04 18:33:25 +0000 | [diff] [blame] | 55 |  | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 56 | //FCC_A   =  8+16,  // Always | 
|  | 57 | //FCC_N   =  0+16,  // Never | 
|  | 58 | FCC_U   =  7+16,  // Unordered | 
|  | 59 | FCC_G   =  6+16,  // Greater | 
|  | 60 | FCC_UG  =  5+16,  // Unordered or Greater | 
|  | 61 | FCC_L   =  4+16,  // Less | 
|  | 62 | FCC_UL  =  3+16,  // Unordered or Less | 
|  | 63 | FCC_LG  =  2+16,  // Less or Greater | 
|  | 64 | FCC_NE  =  1+16,  // Not Equal | 
|  | 65 | FCC_E   =  9+16,  // Equal | 
|  | 66 | FCC_UE  = 10+16,  // Unordered or Equal | 
|  | 67 | FCC_GE  = 11+16,  // Greater or Equal | 
|  | 68 | FCC_UGE = 12+16,  // Unordered or Greater or Equal | 
|  | 69 | FCC_LE  = 13+16,  // Less or Equal | 
|  | 70 | FCC_ULE = 14+16,  // Unordered or Less or Equal | 
| Chris Lattner | aa237256 | 2006-05-24 17:04:05 +0000 | [diff] [blame] | 71 | FCC_O   = 15+16   // Ordered | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 72 | }; | 
|  | 73 | } | 
| Venkatraman Govindaraju | a54533ed | 2013-06-04 18:33:25 +0000 | [diff] [blame] | 74 |  | 
| Chris Lattner | 71f5513 | 2006-11-03 01:11:05 +0000 | [diff] [blame] | 75 | inline static const char *SPARCCondCodeToString(SPCC::CondCodes CC) { | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 76 | switch (CC) { | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 77 | case SPCC::ICC_NE:  return "ne"; | 
|  | 78 | case SPCC::ICC_E:   return "e"; | 
|  | 79 | case SPCC::ICC_G:   return "g"; | 
|  | 80 | case SPCC::ICC_LE:  return "le"; | 
|  | 81 | case SPCC::ICC_GE:  return "ge"; | 
|  | 82 | case SPCC::ICC_L:   return "l"; | 
|  | 83 | case SPCC::ICC_GU:  return "gu"; | 
|  | 84 | case SPCC::ICC_LEU: return "leu"; | 
|  | 85 | case SPCC::ICC_CC:  return "cc"; | 
|  | 86 | case SPCC::ICC_CS:  return "cs"; | 
|  | 87 | case SPCC::ICC_POS: return "pos"; | 
|  | 88 | case SPCC::ICC_NEG: return "neg"; | 
|  | 89 | case SPCC::ICC_VC:  return "vc"; | 
|  | 90 | case SPCC::ICC_VS:  return "vs"; | 
|  | 91 | case SPCC::FCC_U:   return "u"; | 
|  | 92 | case SPCC::FCC_G:   return "g"; | 
|  | 93 | case SPCC::FCC_UG:  return "ug"; | 
|  | 94 | case SPCC::FCC_L:   return "l"; | 
|  | 95 | case SPCC::FCC_UL:  return "ul"; | 
|  | 96 | case SPCC::FCC_LG:  return "lg"; | 
|  | 97 | case SPCC::FCC_NE:  return "ne"; | 
|  | 98 | case SPCC::FCC_E:   return "e"; | 
|  | 99 | case SPCC::FCC_UE:  return "ue"; | 
|  | 100 | case SPCC::FCC_GE:  return "ge"; | 
|  | 101 | case SPCC::FCC_UGE: return "uge"; | 
|  | 102 | case SPCC::FCC_LE:  return "le"; | 
|  | 103 | case SPCC::FCC_ULE: return "ule"; | 
|  | 104 | case SPCC::FCC_O:   return "o"; | 
| Benjamin Kramer | 233149c | 2012-01-10 20:47:20 +0000 | [diff] [blame] | 105 | } | 
|  | 106 | llvm_unreachable("Invalid cond code"); | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 107 | } | 
| Venkatraman Govindaraju | 1116868 | 2013-11-24 20:23:25 +0000 | [diff] [blame] | 108 |  | 
|  | 109 | inline static unsigned HI22(int64_t imm) { | 
|  | 110 | return (unsigned)((imm >> 10) & ((1 << 22)-1)); | 
|  | 111 | } | 
|  | 112 |  | 
|  | 113 | inline static unsigned LO10(int64_t imm) { | 
|  | 114 | return (unsigned)(imm & 0x3FF); | 
|  | 115 | } | 
|  | 116 |  | 
|  | 117 | inline static unsigned HIX22(int64_t imm) { | 
|  | 118 | return HI22(~imm); | 
|  | 119 | } | 
|  | 120 |  | 
|  | 121 | inline static unsigned LOX10(int64_t imm) { | 
|  | 122 | return ~LO10(~imm); | 
|  | 123 | } | 
|  | 124 |  | 
| Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 125 | }  // end namespace llvm | 
|  | 126 | #endif |