blob: 4555fda9a42cabc52250cafb1191453d23f21dcf [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//
5// This file was developed by a team from the Computer Systems Research
Scott Michel2466c372007-12-05 01:40:25 +00006// Department at The Aerospace Corporation and is distributed under the
7// University of Illinois Open Source License. See LICENSE.TXT for details.
Scott Michela589a082007-12-03 23:14:43 +00008//
9//===----------------------------------------------------------------------===//
10//
11// This file contains the entry points for global functions defined in the LLVM
12// Cell SPU back-end.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_TARGET_IBMCELLSPU_H
17#define LLVM_TARGET_IBMCELLSPU_H
18
19#include <iosfwd>
20
21namespace llvm {
22 class SPUTargetMachine;
23 class FunctionPass;
24
25 FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
26 FunctionPass *createSPUAsmPrinterPass(std::ostream &o, SPUTargetMachine &tm);
27
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 */
36 inline bool isS10Constant(short Value) {
37 int SExtValue = ((int) Value << (32 - 10)) >> (32 - 10);
38 return ((Value > 0 && Value <= (1 << 9) - 1)
39 || (Value < 0 && (short) SExtValue == Value));
40 }
41
42 inline bool isS10Constant(int Value) {
43 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
44 }
45
46 inline bool isS10Constant(uint32_t Value) {
47 return (Value <= ((1 << 9) - 1));
48 }
49
50 inline bool isS10Constant(int64_t Value) {
51 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
52 }
53
54 inline bool isS10Constant(uint64_t Value) {
55 return (Value <= ((1 << 9) - 1));
56 }
Scott Michelec2a08f2007-12-15 00:38:50 +000057
58 //! Predicate test for an unsigned 10-bit value
59 /*!
60 \param Value The input value to be tested
61
62 This predicate tests for an unsigned 10-bit value, returning the 10-bit value
63 as a short if true.
64 */
65 inline bool isU10Constant(short Value) {
66 return (Value == (Value & 0x3ff));
67 }
68
69 inline bool isU10Constant(int Value) {
70 return (Value == (Value & 0x3ff));
71 }
72
73 inline bool isU10Constant(uint32_t Value) {
74 return (Value == (Value & 0x3ff));
75 }
76
77 inline bool isU10Constant(int64_t Value) {
78 return (Value == (Value & 0x3ff));
79 }
80
81 inline bool isU10Constant(uint64_t Value) {
82 return (Value == (Value & 0x3ff));
83 }
Scott Michela589a082007-12-03 23:14:43 +000084}
85
86// Defines symbolic names for the SPU instructions.
87//
88#include "SPUGenInstrNames.inc"
89
90#endif /* LLVM_TARGET_IBMCELLSPU_H */