Custom lower all BUILD_VECTOR's so that we can compile vec_splat_u8(8) into
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9InstrInfo.h
1 //===-- SparcV9InstrInfo.h - Define TargetInstrInfo for SparcV9 -*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This class contains information about individual instructions.
11 // Also see the SparcV9MachineInstrDesc array, which can be found in
12 // SparcV9TargetMachine.cpp.
13 // Other information is computed on demand, and most such functions
14 // default to member functions in base class TargetInstrInfo.
15 //
16 //===----------------------------------------------------------------------===//
17
18 #ifndef SPARCV9INSTRINFO_H
19 #define SPARCV9INSTRINFO_H
20
21 #include "llvm/Target/TargetInstrInfo.h"
22 #include "llvm/CodeGen/MachineInstr.h"
23 #include "SparcV9Internals.h"
24 #include "SparcV9RegisterInfo.h"
25
26 namespace llvm {
27
28 /// SparcV9InstrInfo - TargetInstrInfo specialized for the SparcV9 target.
29 ///
30 struct SparcV9InstrInfo : public TargetInstrInfo {
31   const SparcV9RegisterInfo RI;
32 public:
33   SparcV9InstrInfo()
34     : TargetInstrInfo(SparcV9MachineInstrDesc, V9::NUM_TOTAL_OPCODES) { }
35
36   /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
37   /// such, whenever a client has an instance of instruction info, it should
38   /// always be able to get register info as well (through this method).
39   ///
40   virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
41
42   // All immediate constants are in position 1 except the
43   // store instructions and SETxx.
44   //
45   virtual int getImmedConstantPos(MachineOpCode opCode) const {
46     bool ignore;
47     if (this->maxImmedConstant(opCode, ignore) != 0) {
48       // 1st store opcode
49       assert(! this->isStore((MachineOpCode) V9::STBr - 1));
50       // last store opcode
51       assert(! this->isStore((MachineOpCode) V9::STXFSRi + 1));
52
53       if (opCode == V9::SETHI)
54         return 0;
55       if (opCode >= V9::STBr && opCode <= V9::STXFSRi)
56         return 2;
57       return 1;
58     }
59     else
60       return -1;
61   }
62
63   virtual bool hasResultInterlock(MachineOpCode opCode) const
64   {
65     // All UltraSPARC instructions have interlocks (note that delay slots
66     // are not considered here).
67     // However, instructions that use the result of an FCMP produce a
68     // 9-cycle stall if they are issued less than 3 cycles after the FCMP.
69     // Force the compiler to insert a software interlock (i.e., gap of
70     // 2 other groups, including NOPs if necessary).
71     return (opCode == V9::FCMPS || opCode == V9::FCMPD || opCode == V9::FCMPQ);
72   }
73 };
74
75 } // End llvm namespace
76
77 #endif