1 //===-- SPU.h - Top-level interface for Cell SPU Target ----------*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the entry points for global functions defined in the LLVM
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TARGET_IBMCELLSPU_H
16 #define LLVM_TARGET_IBMCELLSPU_H
18 #include "llvm/System/DataTypes.h"
19 #include "llvm/Target/TargetMachine.h"
22 class SPUTargetMachine;
24 class formatted_raw_ostream;
26 FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
28 /*--== Utility functions/predicates/etc used all over the place: --==*/
29 //! Predicate test for a signed 10-bit value
31 \param Value The input value to be tested
33 This predicate tests for a signed 10-bit value, returning the 10-bit value
37 inline bool isS10Constant(T Value);
40 inline bool isS10Constant<short>(short Value) {
41 int SExtValue = ((int) Value << (32 - 10)) >> (32 - 10);
42 return ((Value > 0 && Value <= (1 << 9) - 1)
43 || (Value < 0 && (short) SExtValue == Value));
47 inline bool isS10Constant<int>(int Value) {
48 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
52 inline bool isS10Constant<uint32_t>(uint32_t Value) {
53 return (Value <= ((1 << 9) - 1));
57 inline bool isS10Constant<int64_t>(int64_t Value) {
58 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
62 inline bool isS10Constant<uint64_t>(uint64_t Value) {
63 return (Value <= ((1 << 9) - 1));
66 //! Predicate test for an unsigned 10-bit value
68 \param Value The input value to be tested
70 inline bool isU10Constant(short Value) {
71 return (Value == (Value & 0x3ff));
74 inline bool isU10Constant(int Value) {
75 return (Value == (Value & 0x3ff));
78 inline bool isU10Constant(uint32_t Value) {
79 return (Value == (Value & 0x3ff));
82 inline bool isU10Constant(int64_t Value) {
83 return (Value == (Value & 0x3ff));
86 inline bool isU10Constant(uint64_t Value) {
87 return (Value == (Value & 0x3ff));
90 //! Predicate test for a signed 14-bit value
92 \param Value The input value to be tested
95 inline bool isS14Constant(T Value);
98 inline bool isS14Constant<short>(short Value) {
99 return (Value >= -(1 << 13) && Value <= (1 << 13) - 1);
103 inline bool isS14Constant<int>(int Value) {
104 return (Value >= -(1 << 13) && Value <= (1 << 13) - 1);
108 inline bool isS14Constant<uint32_t>(uint32_t Value) {
109 return (Value <= ((1 << 13) - 1));
113 inline bool isS14Constant<int64_t>(int64_t Value) {
114 return (Value >= -(1 << 13) && Value <= (1 << 13) - 1);
118 inline bool isS14Constant<uint64_t>(uint64_t Value) {
119 return (Value <= ((1 << 13) - 1));
122 //! Predicate test for a signed 16-bit value
124 \param Value The input value to be tested
127 inline bool isS16Constant(T Value);
130 inline bool isS16Constant<short>(short Value) {
135 inline bool isS16Constant<int>(int Value) {
136 return (Value >= -(1 << 15) && Value <= (1 << 15) - 1);
140 inline bool isS16Constant<uint32_t>(uint32_t Value) {
141 return (Value <= ((1 << 15) - 1));
145 inline bool isS16Constant<int64_t>(int64_t Value) {
146 return (Value >= -(1 << 15) && Value <= (1 << 15) - 1);
150 inline bool isS16Constant<uint64_t>(uint64_t Value) {
151 return (Value <= ((1 << 15) - 1));
154 extern Target TheCellSPUTarget;
158 // Defines symbolic names for the SPU instructions.
160 #include "SPUGenInstrNames.inc"
162 #endif /* LLVM_TARGET_IBMCELLSPU_H */