blob: 77a062e0e2e3f4d97a21abfd5a7a441b08667a36 [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"
Bill Wendling98a366d2009-04-29 23:29:43 +000019#include "llvm/Target/TargetMachine.h"
Scott Michela589a082007-12-03 23:14:43 +000020
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);
Bill Wendling57f0db82009-02-24 08:30:20 +000027 FunctionPass *createSPUAsmPrinterPass(raw_ostream &o,
28 SPUTargetMachine &tm,
Bill Wendling98a366d2009-04-29 23:29:43 +000029 CodeGenOpt::Level OptLevel,
30 bool verbose);
Scott Michela589a082007-12-03 23:14:43 +000031
Scott Michelec2a08f2007-12-15 00:38:50 +000032 /*--== Utility functions/predicates/etc used all over the place: --==*/
Scott Michela589a082007-12-03 23:14:43 +000033 //! Predicate test for a signed 10-bit value
34 /*!
35 \param Value The input value to be tested
36
37 This predicate tests for a signed 10-bit value, returning the 10-bit value
38 as a short if true.
39 */
Duncan Sands43d9c8c2008-10-08 07:44:52 +000040 template<typename T>
41 inline bool isS10Constant(T Value);
42
43 template<>
44 inline bool isS10Constant<short>(short Value) {
Scott Michela589a082007-12-03 23:14:43 +000045 int SExtValue = ((int) Value << (32 - 10)) >> (32 - 10);
46 return ((Value > 0 && Value <= (1 << 9) - 1)
Scott Michel7f9ba9b2008-01-30 02:55:46 +000047 || (Value < 0 && (short) SExtValue == Value));
Scott Michela589a082007-12-03 23:14:43 +000048 }
49
Duncan Sands43d9c8c2008-10-08 07:44:52 +000050 template<>
51 inline bool isS10Constant<int>(int Value) {
Scott Michela589a082007-12-03 23:14:43 +000052 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
53 }
54
Duncan Sands43d9c8c2008-10-08 07:44:52 +000055 template<>
56 inline bool isS10Constant<uint32_t>(uint32_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000057 return (Value <= ((1 << 9) - 1));
58 }
59
Duncan Sands43d9c8c2008-10-08 07:44:52 +000060 template<>
61 inline bool isS10Constant<int64_t>(int64_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000062 return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
63 }
64
Duncan Sands43d9c8c2008-10-08 07:44:52 +000065 template<>
66 inline bool isS10Constant<uint64_t>(uint64_t Value) {
Scott Michela589a082007-12-03 23:14:43 +000067 return (Value <= ((1 << 9) - 1));
68 }
Scott Michelec2a08f2007-12-15 00:38:50 +000069
70 //! Predicate test for an unsigned 10-bit value
71 /*!
72 \param Value The input value to be tested
73
74 This predicate tests for an unsigned 10-bit value, returning the 10-bit value
75 as a short if true.
76 */
77 inline bool isU10Constant(short Value) {
78 return (Value == (Value & 0x3ff));
79 }
80
81 inline bool isU10Constant(int Value) {
82 return (Value == (Value & 0x3ff));
83 }
84
85 inline bool isU10Constant(uint32_t Value) {
86 return (Value == (Value & 0x3ff));
87 }
88
89 inline bool isU10Constant(int64_t Value) {
90 return (Value == (Value & 0x3ff));
91 }
92
93 inline bool isU10Constant(uint64_t Value) {
94 return (Value == (Value & 0x3ff));
95 }
Scott Michela589a082007-12-03 23:14:43 +000096}
97
98// Defines symbolic names for the SPU instructions.
99//
100#include "SPUGenInstrNames.inc"
101
102#endif /* LLVM_TARGET_IBMCELLSPU_H */