blob: 9bb199a16e1f64ddb9d3eb3100618edd5b9c04fa [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);
Bill Wendling57f0db82009-02-24 08:30:20 +000026 FunctionPass *createSPUAsmPrinterPass(raw_ostream &o,
27 SPUTargetMachine &tm,
Bill Wendlingc69d56f2009-04-28 01:04:53 +000028 bool fast, bool verbose);
Scott Michela589a082007-12-03 23:14:43 +000029
Scott Michelec2a08f2007-12-15 00:38:50 +000030 /*--== Utility functions/predicates/etc used all over the place: --==*/
Scott Michela589a082007-12-03 23:14:43 +000031 //! 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 */
Duncan Sands43d9c8c2008-10-08 07:44:52 +000038 template<typename T>
39 inline bool isS10Constant(T Value);
40
41 template<>
42 inline bool isS10Constant<short>(short Value) {
Scott Michela589a082007-12-03 23:14:43 +000043 int SExtValue = ((int) Value << (32 - 10)) >> (32 - 10);
44 return ((Value > 0 && Value <= (1 << 9) - 1)
Scott Michel7f9ba9b2008-01-30 02:55:46 +000045 || (Value < 0 && (short) SExtValue == Value));
Scott Michela589a082007-12-03 23:14:43 +000046 }
47
Duncan Sands43d9c8c2008-10-08 07:44:52 +000048 template<>
49 inline bool isS10Constant<int>(int Value) {
Scott Michela589a082007-12-03 23:14:43 +000050 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
51 }
52
Duncan Sands43d9c8c2008-10-08 07:44:52 +000053 template<>
54 inline bool isS10Constant<uint32_t>(uint32_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000055 return (Value <= ((1 << 9) - 1));
56 }
57
Duncan Sands43d9c8c2008-10-08 07:44:52 +000058 template<>
59 inline bool isS10Constant<int64_t>(int64_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000060 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
61 }
62
Duncan Sands43d9c8c2008-10-08 07:44:52 +000063 template<>
64 inline bool isS10Constant<uint64_t>(uint64_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000065 return (Value <= ((1 << 9) - 1));
66 }
Scott Michelec2a08f2007-12-15 00:38:50 +000067
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 }
Scott Michela589a082007-12-03 23:14:43 +000094}
95
96// Defines symbolic names for the SPU instructions.
97//
98#include "SPUGenInstrNames.inc"
99
100#endif /* LLVM_TARGET_IBMCELLSPU_H */