blob: a6a911067fd836946b91f580a0463cbaea9d00b3 [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
20namespace llvm {
21 class SPUTargetMachine;
22 class FunctionPass;
Owen Andersoncb371882008-08-21 00:14:44 +000023 class raw_ostream;
Scott Michela589a082007-12-03 23:14:43 +000024
25 FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
Owen Andersoncb371882008-08-21 00:14:44 +000026 FunctionPass *createSPUAsmPrinterPass(raw_ostream &o, SPUTargetMachine &tm);
Scott Michela589a082007-12-03 23:14:43 +000027
Scott Michelec2a08f2007-12-15 00:38:50 +000028 /*--== Utility functions/predicates/etc used all over the place: --==*/
Scott Michela589a082007-12-03 23:14:43 +000029 //! 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 Sands43d9c8c2008-10-08 07:44:52 +000036 template<typename T>
37 inline bool isS10Constant(T Value);
38
39 template<>
40 inline bool isS10Constant<short>(short Value) {
Scott Michela589a082007-12-03 23:14:43 +000041 int SExtValue = ((int) Value << (32 - 10)) >> (32 - 10);
42 return ((Value > 0 && Value <= (1 << 9) - 1)
Scott Michel7f9ba9b2008-01-30 02:55:46 +000043 || (Value < 0 && (short) SExtValue == Value));
Scott Michela589a082007-12-03 23:14:43 +000044 }
45
Duncan Sands43d9c8c2008-10-08 07:44:52 +000046 template<>
47 inline bool isS10Constant<int>(int Value) {
Scott Michela589a082007-12-03 23:14:43 +000048 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
49 }
50
Duncan Sands43d9c8c2008-10-08 07:44:52 +000051 template<>
52 inline bool isS10Constant<uint32_t>(uint32_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000053 return (Value <= ((1 << 9) - 1));
54 }
55
Duncan Sands43d9c8c2008-10-08 07:44:52 +000056 template<>
57 inline bool isS10Constant<int64_t>(int64_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000058 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
59 }
60
Duncan Sands43d9c8c2008-10-08 07:44:52 +000061 template<>
62 inline bool isS10Constant<uint64_t>(uint64_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000063 return (Value <= ((1 << 9) - 1));
64 }
Scott Michelec2a08f2007-12-15 00:38:50 +000065
66 //! Predicate test for an unsigned 10-bit value
67 /*!
68 \param Value The input value to be tested
69
70 This predicate tests for an unsigned 10-bit value, returning the 10-bit value
71 as a short if true.
72 */
73 inline bool isU10Constant(short Value) {
74 return (Value == (Value & 0x3ff));
75 }
76
77 inline bool isU10Constant(int Value) {
78 return (Value == (Value & 0x3ff));
79 }
80
81 inline bool isU10Constant(uint32_t Value) {
82 return (Value == (Value & 0x3ff));
83 }
84
85 inline bool isU10Constant(int64_t Value) {
86 return (Value == (Value & 0x3ff));
87 }
88
89 inline bool isU10Constant(uint64_t Value) {
90 return (Value == (Value & 0x3ff));
91 }
Scott Michela589a082007-12-03 23:14:43 +000092}
93
94// Defines symbolic names for the SPU instructions.
95//
96#include "SPUGenInstrNames.inc"
97
98#endif /* LLVM_TARGET_IBMCELLSPU_H */