blob: 776b9bfb0832214cde0633027b731be0b399897d [file] [log] [blame]
Scott Michela589a082007-12-03 23:14:43 +00001//===-- SPU.h - Top-level interface for Cell SPU Target ----------*- C++ -*-==//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Scott Michela589a082007-12-03 23:14:43 +00007//
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 Sands43d9c8c2008-10-08 07:44:52 +000018#include "llvm/Support/DataTypes.h"
Scott Michela589a082007-12-03 23:14:43 +000019#include <iosfwd>
20
21namespace llvm {
22 class SPUTargetMachine;
23 class FunctionPass;
Owen Andersoncb371882008-08-21 00:14:44 +000024 class raw_ostream;
Scott Michela589a082007-12-03 23:14:43 +000025
26 FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
Owen Andersoncb371882008-08-21 00:14:44 +000027 FunctionPass *createSPUAsmPrinterPass(raw_ostream &o, SPUTargetMachine &tm);
Scott Michela589a082007-12-03 23:14:43 +000028
Scott Michelec2a08f2007-12-15 00:38:50 +000029 /*--== Utility functions/predicates/etc used all over the place: --==*/
Scott Michela589a082007-12-03 23:14:43 +000030 //! Predicate test for a signed 10-bit value
31 /*!
32 \param Value The input value to be tested
33
34 This predicate tests for a signed 10-bit value, returning the 10-bit value
35 as a short if true.
36 */
Duncan Sands43d9c8c2008-10-08 07:44:52 +000037 template<typename T>
38 inline bool isS10Constant(T Value);
39
40 template<>
41 inline bool isS10Constant<short>(short Value) {
Scott Michela589a082007-12-03 23:14:43 +000042 int SExtValue = ((int) Value << (32 - 10)) >> (32 - 10);
43 return ((Value > 0 && Value <= (1 << 9) - 1)
Scott Michel7f9ba9b2008-01-30 02:55:46 +000044 || (Value < 0 && (short) SExtValue == Value));
Scott Michela589a082007-12-03 23:14:43 +000045 }
46
Duncan Sands43d9c8c2008-10-08 07:44:52 +000047 template<>
48 inline bool isS10Constant<int>(int Value) {
Scott Michela589a082007-12-03 23:14:43 +000049 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
50 }
51
Duncan Sands43d9c8c2008-10-08 07:44:52 +000052 template<>
53 inline bool isS10Constant<uint32_t>(uint32_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000054 return (Value <= ((1 << 9) - 1));
55 }
56
Duncan Sands43d9c8c2008-10-08 07:44:52 +000057 template<>
58 inline bool isS10Constant<int64_t>(int64_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000059 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
60 }
61
Duncan Sands43d9c8c2008-10-08 07:44:52 +000062 template<>
63 inline bool isS10Constant<uint64_t>(uint64_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000064 return (Value <= ((1 << 9) - 1));
65 }
Scott Michelec2a08f2007-12-15 00:38:50 +000066
67 //! Predicate test for an unsigned 10-bit value
68 /*!
69 \param Value The input value to be tested
70
71 This predicate tests for an unsigned 10-bit value, returning the 10-bit value
72 as a short if true.
73 */
74 inline bool isU10Constant(short Value) {
75 return (Value == (Value & 0x3ff));
76 }
77
78 inline bool isU10Constant(int Value) {
79 return (Value == (Value & 0x3ff));
80 }
81
82 inline bool isU10Constant(uint32_t Value) {
83 return (Value == (Value & 0x3ff));
84 }
85
86 inline bool isU10Constant(int64_t Value) {
87 return (Value == (Value & 0x3ff));
88 }
89
90 inline bool isU10Constant(uint64_t Value) {
91 return (Value == (Value & 0x3ff));
92 }
Scott Michela589a082007-12-03 23:14:43 +000093}
94
95// Defines symbolic names for the SPU instructions.
96//
97#include "SPUGenInstrNames.inc"
98
99#endif /* LLVM_TARGET_IBMCELLSPU_H */