Move up dwarf writer initialization in common AsmPrinter class.
[oota-llvm.git] / lib / Target / CellSPU / SPU.h
1 //===-- SPU.h - Top-level interface for Cell SPU Target ----------*- C++ -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
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
18 #include "llvm/Support/DataTypes.h"
19 #include "llvm/Target/TargetMachine.h"
20
21 namespace llvm {
22   class SPUTargetMachine;
23   class FunctionPass;
24   class raw_ostream;
25
26   FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
27   FunctionPass *createSPUAsmPrinterPass(raw_ostream &o,
28                                         SPUTargetMachine &tm,
29                                         CodeGenOpt::Level OptLevel,
30                                         bool verbose);
31
32   /*--== Utility functions/predicates/etc used all over the place: --==*/
33   //! 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    */
40   template<typename T>
41   inline bool isS10Constant(T Value);
42
43   template<>
44   inline bool isS10Constant<short>(short Value) {
45     int SExtValue = ((int) Value << (32 - 10)) >> (32 - 10);
46     return ((Value > 0 && Value <= (1 << 9) - 1)
47             || (Value < 0 && (short) SExtValue == Value));
48   }
49
50   template<>
51   inline bool isS10Constant<int>(int Value) {
52     return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
53   }
54
55   template<>
56   inline bool isS10Constant<uint32_t>(uint32_t Value) {
57     return (Value <= ((1 << 9) - 1));
58   }
59
60   template<>
61   inline bool isS10Constant<int64_t>(int64_t Value) {
62     return (Value >= -(1 << 9) && Value <= (1 << 9) - 1);
63   }
64
65   template<>
66   inline bool isS10Constant<uint64_t>(uint64_t Value) {
67     return (Value <= ((1 << 9) - 1));
68   }
69
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   }
96 }
97
98 // Defines symbolic names for the SPU instructions.
99 //
100 #include "SPUGenInstrNames.inc"
101
102 #endif /* LLVM_TARGET_IBMCELLSPU_H */