Massive check in. This changes the "-fast" flag to "-O#" in llc. If you want to
[oota-llvm.git] / lib / Target / CellSPU / SPU.h
1 //===-- SPU.h - Top-level interface for Cell SPU Target ----------*- C++ -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
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
18 #include "llvm/Support/DataTypes.h"
19
20 namespace llvm {
21   class SPUTargetMachine;
22   class FunctionPass;
23   class raw_ostream;
24
25   FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
26   FunctionPass *createSPUAsmPrinterPass(raw_ostream &o,
27                                         SPUTargetMachine &tm,
28                                         unsigned OptLevel, bool verbose);
29
30   /*--== Utility functions/predicates/etc used all over the place: --==*/
31   //! Predicate test for a signed 10-bit value
32   /*!
33     \param Value The input value to be tested
34
35     This predicate tests for a signed 10-bit value, returning the 10-bit value
36     as a short if true.
37    */
38   template<typename T>
39   inline bool isS10Constant(T Value);
40
41   template<>
42   inline bool isS10Constant<short>(short Value) {
43     int SExtValue = ((int) Value << (32 - 10)) >> (32 - 10);
44     return ((Value > 0 && Value <= (1 << 9) - 1)
45             || (Value < 0 && (short) SExtValue == Value));
46   }
47
48   template<>
49   inline bool isS10Constant<int>(int Value) {
50     return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
51   }
52
53   template<>
54   inline bool isS10Constant<uint32_t>(uint32_t Value) {
55     return (Value <= ((1 << 9) - 1));
56   }
57
58   template<>
59   inline bool isS10Constant<int64_t>(int64_t Value) {
60     return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
61   }
62
63   template<>
64   inline bool isS10Constant<uint64_t>(uint64_t Value) {
65     return (Value <= ((1 << 9) - 1));
66   }
67
68   //! Predicate test for an unsigned 10-bit value
69   /*!
70     \param Value The input value to be tested
71
72     This predicate tests for an unsigned 10-bit value, returning the 10-bit value
73     as a short if true.
74    */
75   inline bool isU10Constant(short Value) {
76     return (Value == (Value & 0x3ff));
77   }
78
79   inline bool isU10Constant(int Value) {
80     return (Value == (Value & 0x3ff));
81   }
82
83   inline bool isU10Constant(uint32_t Value) {
84     return (Value == (Value & 0x3ff));
85   }
86
87   inline bool isU10Constant(int64_t Value) {
88     return (Value == (Value & 0x3ff));
89   }
90
91   inline bool isU10Constant(uint64_t Value) {
92     return (Value == (Value & 0x3ff));
93   }
94 }
95
96 // Defines symbolic names for the SPU instructions.
97 //
98 #include "SPUGenInstrNames.inc"
99
100 #endif /* LLVM_TARGET_IBMCELLSPU_H */