Mark barrier instructions. Execution does not fall through uncond branches
[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 struct SparcV9InstrInfo : public TargetInstrInfo {
29   const SparcV9RegisterInfo RI;
30 public:
31   SparcV9InstrInfo();
32
33   /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
34   /// such, whenever a client has an instance of instruction info, it should
35   /// always be able to get register info as well (through this method).
36   ///
37   virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
38
39   // All immediate constants are in position 1 except the
40   // store instructions and SETxx.
41   // 
42   virtual int getImmedConstantPos(MachineOpCode opCode) const {
43     bool ignore;
44     if (this->maxImmedConstant(opCode, ignore) != 0) {
45       // 1st store opcode
46       assert(! this->isStore((MachineOpCode) V9::STBr - 1));
47       // last store opcode
48       assert(! this->isStore((MachineOpCode) V9::STXFSRi + 1));
49
50       if (opCode == V9::SETSW || opCode == V9::SETUW ||
51           opCode == V9::SETX  || opCode == V9::SETHI)
52         return 0;
53       if (opCode >= V9::STBr && opCode <= V9::STXFSRi)
54         return 2;
55       return 1;
56     }
57     else
58       return -1;
59   }
60
61   virtual bool hasResultInterlock(MachineOpCode opCode) const
62   {
63     // All UltraSPARC instructions have interlocks (note that delay slots
64     // are not considered here).
65     // However, instructions that use the result of an FCMP produce a
66     // 9-cycle stall if they are issued less than 3 cycles after the FCMP.
67     // Force the compiler to insert a software interlock (i.e., gap of
68     // 2 other groups, including NOPs if necessary).
69     return (opCode == V9::FCMPS || opCode == V9::FCMPD || opCode == V9::FCMPQ);
70   }
71 };
72
73 } // End llvm namespace
74
75 #endif