Scott Michel | a589a08 | 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 | 4ee451d | 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 | a589a08 | 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 | |
Duncan Sands | 43d9c8c | 2008-10-08 07:44:52 +0000 | [diff] [blame] | 18 | #include "llvm/Support/DataTypes.h" |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetMachine.h" |
Scott Michel | a589a08 | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
| 22 | class SPUTargetMachine; |
| 23 | class FunctionPass; |
David Greene | 7184781 | 2009-07-14 20:18:05 +0000 | [diff] [blame^] | 24 | class formatted_raw_ostream; |
Scott Michel | a589a08 | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 25 | |
| 26 | FunctionPass *createSPUISelDag(SPUTargetMachine &TM); |
David Greene | 7184781 | 2009-07-14 20:18:05 +0000 | [diff] [blame^] | 27 | FunctionPass *createSPUAsmPrinterPass(formatted_raw_ostream &o, |
Bill Wendling | 57f0db8 | 2009-02-24 08:30:20 +0000 | [diff] [blame] | 28 | SPUTargetMachine &tm, |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 29 | bool verbose); |
Scott Michel | a589a08 | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 30 | |
Scott Michel | ec2a08f | 2007-12-15 00:38:50 +0000 | [diff] [blame] | 31 | /*--== Utility functions/predicates/etc used all over the place: --==*/ |
Scott Michel | a589a08 | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 32 | //! Predicate test for a signed 10-bit value |
| 33 | /*! |
| 34 | \param Value The input value to be tested |
| 35 | |
| 36 | This predicate tests for a signed 10-bit value, returning the 10-bit value |
| 37 | as a short if true. |
| 38 | */ |
Duncan Sands | 43d9c8c | 2008-10-08 07:44:52 +0000 | [diff] [blame] | 39 | template<typename T> |
| 40 | inline bool isS10Constant(T Value); |
| 41 | |
| 42 | template<> |
| 43 | inline bool isS10Constant<short>(short Value) { |
Scott Michel | a589a08 | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 44 | int SExtValue = ((int) Value << (32 - 10)) >> (32 - 10); |
| 45 | return ((Value > 0 && Value <= (1 << 9) - 1) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 46 | || (Value < 0 && (short) SExtValue == Value)); |
Scott Michel | a589a08 | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Duncan Sands | 43d9c8c | 2008-10-08 07:44:52 +0000 | [diff] [blame] | 49 | template<> |
| 50 | inline bool isS10Constant<int>(int Value) { |
Scott Michel | a589a08 | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 51 | return (Value >= -(1 << 9) && Value <= (1 << 9) - 1); |
| 52 | } |
| 53 | |
Duncan Sands | 43d9c8c | 2008-10-08 07:44:52 +0000 | [diff] [blame] | 54 | template<> |
| 55 | inline bool isS10Constant<uint32_t>(uint32_t Value) { |
Scott Michel | a589a08 | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 56 | return (Value <= ((1 << 9) - 1)); |
| 57 | } |
| 58 | |
Duncan Sands | 43d9c8c | 2008-10-08 07:44:52 +0000 | [diff] [blame] | 59 | template<> |
| 60 | inline bool isS10Constant<int64_t>(int64_t Value) { |
Scott Michel | a589a08 | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 61 | return (Value >= -(1 << 9) && Value <= (1 << 9) - 1); |
| 62 | } |
| 63 | |
Duncan Sands | 43d9c8c | 2008-10-08 07:44:52 +0000 | [diff] [blame] | 64 | template<> |
| 65 | inline bool isS10Constant<uint64_t>(uint64_t Value) { |
Scott Michel | a589a08 | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 66 | return (Value <= ((1 << 9) - 1)); |
| 67 | } |
Scott Michel | ec2a08f | 2007-12-15 00:38:50 +0000 | [diff] [blame] | 68 | |
| 69 | //! Predicate test for an unsigned 10-bit value |
| 70 | /*! |
| 71 | \param Value The input value to be tested |
| 72 | |
| 73 | This predicate tests for an unsigned 10-bit value, returning the 10-bit value |
| 74 | as a short if true. |
| 75 | */ |
| 76 | inline bool isU10Constant(short Value) { |
| 77 | return (Value == (Value & 0x3ff)); |
| 78 | } |
| 79 | |
| 80 | inline bool isU10Constant(int Value) { |
| 81 | return (Value == (Value & 0x3ff)); |
| 82 | } |
| 83 | |
| 84 | inline bool isU10Constant(uint32_t Value) { |
| 85 | return (Value == (Value & 0x3ff)); |
| 86 | } |
| 87 | |
| 88 | inline bool isU10Constant(int64_t Value) { |
| 89 | return (Value == (Value & 0x3ff)); |
| 90 | } |
| 91 | |
| 92 | inline bool isU10Constant(uint64_t Value) { |
| 93 | return (Value == (Value & 0x3ff)); |
| 94 | } |
Scott Michel | a589a08 | 2007-12-03 23:14:43 +0000 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | // Defines symbolic names for the SPU instructions. |
| 98 | // |
| 99 | #include "SPUGenInstrNames.inc" |
| 100 | |
| 101 | #endif /* LLVM_TARGET_IBMCELLSPU_H */ |