Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 1 | //===-- SPU.h - Top-level interface for Cell SPU Target ----------*- C++ -*-==// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 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. |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains the entry points for global functions defined in the LLVM |
| 11 | // Cell SPU back-end. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_TARGET_IBMCELLSPU_H |
| 16 | #define LLVM_TARGET_IBMCELLSPU_H |
| 17 | |
Chandler Carruth | 1ec7df1 | 2009-10-26 01:35:46 +0000 | [diff] [blame] | 18 | #include "llvm/System/DataTypes.h" |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetMachine.h" |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
| 22 | class SPUTargetMachine; |
| 23 | class FunctionPass; |
David Greene | 302008d | 2009-07-14 20:18:05 +0000 | [diff] [blame] | 24 | class formatted_raw_ostream; |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 25 | |
| 26 | FunctionPass *createSPUISelDag(SPUTargetMachine &TM); |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 27 | |
Scott Michel | 7b5f7ed | 2007-12-15 00:38:50 +0000 | [diff] [blame] | 28 | /*--== Utility functions/predicates/etc used all over the place: --==*/ |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 29 | //! Predicate test for a signed 10-bit value |
| 30 | /*! |
| 31 | \param Value The input value to be tested |
| 32 | |
| 33 | This predicate tests for a signed 10-bit value, returning the 10-bit value |
| 34 | as a short if true. |
| 35 | */ |
Duncan Sands | 4338863 | 2008-10-08 07:44:52 +0000 | [diff] [blame] | 36 | template<typename T> |
| 37 | inline bool isS10Constant(T Value); |
| 38 | |
| 39 | template<> |
| 40 | inline bool isS10Constant<short>(short Value) { |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 41 | int SExtValue = ((int) Value << (32 - 10)) >> (32 - 10); |
| 42 | return ((Value > 0 && Value <= (1 << 9) - 1) |
Scott Michel | 5a6f17b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 43 | || (Value < 0 && (short) SExtValue == Value)); |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Duncan Sands | 4338863 | 2008-10-08 07:44:52 +0000 | [diff] [blame] | 46 | template<> |
| 47 | inline bool isS10Constant<int>(int Value) { |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 48 | return (Value >= -(1 << 9) && Value <= (1 << 9) - 1); |
| 49 | } |
| 50 | |
Duncan Sands | 4338863 | 2008-10-08 07:44:52 +0000 | [diff] [blame] | 51 | template<> |
| 52 | inline bool isS10Constant<uint32_t>(uint32_t Value) { |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 53 | return (Value <= ((1 << 9) - 1)); |
| 54 | } |
| 55 | |
Duncan Sands | 4338863 | 2008-10-08 07:44:52 +0000 | [diff] [blame] | 56 | template<> |
| 57 | inline bool isS10Constant<int64_t>(int64_t Value) { |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 58 | return (Value >= -(1 << 9) && Value <= (1 << 9) - 1); |
| 59 | } |
| 60 | |
Duncan Sands | 4338863 | 2008-10-08 07:44:52 +0000 | [diff] [blame] | 61 | template<> |
| 62 | inline bool isS10Constant<uint64_t>(uint64_t Value) { |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 63 | return (Value <= ((1 << 9) - 1)); |
| 64 | } |
Scott Michel | 7b5f7ed | 2007-12-15 00:38:50 +0000 | [diff] [blame] | 65 | |
| 66 | //! Predicate test for an unsigned 10-bit value |
| 67 | /*! |
| 68 | \param Value The input value to be tested |
Scott Michel | 7b5f7ed | 2007-12-15 00:38:50 +0000 | [diff] [blame] | 69 | */ |
| 70 | inline bool isU10Constant(short Value) { |
| 71 | return (Value == (Value & 0x3ff)); |
| 72 | } |
| 73 | |
| 74 | inline bool isU10Constant(int Value) { |
| 75 | return (Value == (Value & 0x3ff)); |
| 76 | } |
| 77 | |
| 78 | inline bool isU10Constant(uint32_t Value) { |
| 79 | return (Value == (Value & 0x3ff)); |
| 80 | } |
| 81 | |
| 82 | inline bool isU10Constant(int64_t Value) { |
| 83 | return (Value == (Value & 0x3ff)); |
| 84 | } |
| 85 | |
| 86 | inline bool isU10Constant(uint64_t Value) { |
| 87 | return (Value == (Value & 0x3ff)); |
| 88 | } |
Daniel Dunbar | 0b0441e | 2009-07-18 23:03:22 +0000 | [diff] [blame] | 89 | |
Scott Michel | cb8509c | 2010-02-25 01:53:17 +0000 | [diff] [blame] | 90 | //! Predicate test for a signed 14-bit value |
| 91 | /*! |
| 92 | \param Value The input value to be tested |
| 93 | */ |
| 94 | template<typename T> |
| 95 | inline bool isS14Constant(T Value); |
| 96 | |
| 97 | template<> |
| 98 | inline bool isS14Constant<short>(short Value) { |
| 99 | return (Value >= -(1 << 13) && Value <= (1 << 13) - 1); |
| 100 | } |
| 101 | |
| 102 | template<> |
| 103 | inline bool isS14Constant<int>(int Value) { |
| 104 | return (Value >= -(1 << 13) && Value <= (1 << 13) - 1); |
| 105 | } |
| 106 | |
| 107 | template<> |
| 108 | inline bool isS14Constant<uint32_t>(uint32_t Value) { |
| 109 | return (Value <= ((1 << 13) - 1)); |
| 110 | } |
| 111 | |
| 112 | template<> |
| 113 | inline bool isS14Constant<int64_t>(int64_t Value) { |
| 114 | return (Value >= -(1 << 13) && Value <= (1 << 13) - 1); |
| 115 | } |
| 116 | |
| 117 | template<> |
| 118 | inline bool isS14Constant<uint64_t>(uint64_t Value) { |
| 119 | return (Value <= ((1 << 13) - 1)); |
| 120 | } |
| 121 | |
| 122 | //! Predicate test for a signed 16-bit value |
| 123 | /*! |
| 124 | \param Value The input value to be tested |
| 125 | */ |
| 126 | template<typename T> |
| 127 | inline bool isS16Constant(T Value); |
| 128 | |
| 129 | template<> |
| 130 | inline bool isS16Constant<short>(short Value) { |
| 131 | return true; |
| 132 | } |
| 133 | |
| 134 | template<> |
| 135 | inline bool isS16Constant<int>(int Value) { |
| 136 | return (Value >= -(1 << 15) && Value <= (1 << 15) - 1); |
| 137 | } |
| 138 | |
| 139 | template<> |
| 140 | inline bool isS16Constant<uint32_t>(uint32_t Value) { |
| 141 | return (Value <= ((1 << 15) - 1)); |
| 142 | } |
| 143 | |
| 144 | template<> |
| 145 | inline bool isS16Constant<int64_t>(int64_t Value) { |
| 146 | return (Value >= -(1 << 15) && Value <= (1 << 15) - 1); |
| 147 | } |
| 148 | |
| 149 | template<> |
| 150 | inline bool isS16Constant<uint64_t>(uint64_t Value) { |
| 151 | return (Value <= ((1 << 15) - 1)); |
| 152 | } |
| 153 | |
Daniel Dunbar | 0b0441e | 2009-07-18 23:03:22 +0000 | [diff] [blame] | 154 | extern Target TheCellSPUTarget; |
| 155 | |
Scott Michel | 610589f | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | // Defines symbolic names for the SPU instructions. |
| 159 | // |
| 160 | #include "SPUGenInstrNames.inc" |
| 161 | |
| 162 | #endif /* LLVM_TARGET_IBMCELLSPU_H */ |