blob: e975caf88b4a36937b41e2655cb1b5538c54415c [file] [log] [blame]
Misha Brukman5dfe3a92004-06-21 16:55:25 +00001//===- PowerPCInstrInfo.h - PowerPC Instruction Information -----*- 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 file contains the PowerPC implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
Misha Brukman01458812004-08-11 00:11:25 +000014#ifndef POWERPC_INSTRUCTIONINFO_H
15#define POWERPC_INSTRUCTIONINFO_H
Misha Brukman5dfe3a92004-06-21 16:55:25 +000016
Misha Brukman8aebe9f2004-07-27 18:34:11 +000017#include "PowerPC.h"
Misha Brukman5dfe3a92004-06-21 16:55:25 +000018#include "PowerPCRegisterInfo.h"
Misha Brukman8aebe9f2004-07-27 18:34:11 +000019#include "llvm/Target/TargetInstrInfo.h"
Misha Brukman5dfe3a92004-06-21 16:55:25 +000020
21namespace llvm {
22
Misha Brukman5b570812004-08-10 22:47:03 +000023namespace PPCII {
Misha Brukman5dfe3a92004-06-21 16:55:25 +000024 enum {
25 ArgCountShift = 0,
26 ArgCountMask = 7,
27
28 Arg0TypeShift = 3,
29 Arg1TypeShift = 8,
30 Arg2TypeShift = 13,
31 Arg3TypeShift = 18,
32 Arg4TypeShift = 23,
33 VMX = 1<<28,
34 PPC64 = 1<<29,
35 ArgTypeMask = 31
36 };
37
38 enum {
39 None = 0,
40 Gpr = 1,
41 Gpr0 = 2,
42 Simm16 = 3,
43 Zimm16 = 4,
44 PCRelimm24 = 5,
45 Imm24 = 6,
46 Imm5 = 7,
47 PCRelimm14 = 8,
48 Imm14 = 9,
49 Imm2 = 10,
50 Crf = 11,
51 Imm3 = 12,
52 Imm1 = 13,
53 Fpr = 14,
54 Imm4 = 15,
55 Imm8 = 16,
56 Disimm16 = 17,
57 Disimm14 = 18,
58 Spr = 19,
59 Sgr = 20,
60 Imm15 = 21,
61 Vpr = 22
62 };
63}
64
65class PowerPCInstrInfo : public TargetInstrInfo {
66 const PowerPCRegisterInfo RI;
67public:
68 PowerPCInstrInfo();
69
70 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
71 /// such, whenever a client has an instance of instruction info, it should
72 /// always be able to get register info as well (through this method).
73 ///
74 virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
Misha Brukman6b4ea882004-07-16 20:50:55 +000075
76 //
77 // Return true if the instruction is a register to register move and
78 // leave the source and dest operands in the passed parameters.
79 //
80 virtual bool isMoveInstr(const MachineInstr& MI,
81 unsigned& sourceReg,
82 unsigned& destReg) const;
Misha Brukman8aebe9f2004-07-27 18:34:11 +000083
84 static unsigned invertPPCBranchOpcode(unsigned Opcode) {
85 switch (Opcode) {
Misha Brukman5b570812004-08-10 22:47:03 +000086 default: assert(0 && "Unknown PPC branch opcode!");
87 case PPC::BEQ: return PPC::BNE;
88 case PPC::BNE: return PPC::BEQ;
89 case PPC::BLT: return PPC::BGE;
90 case PPC::BGE: return PPC::BLT;
91 case PPC::BGT: return PPC::BLE;
92 case PPC::BLE: return PPC::BGT;
Misha Brukman8aebe9f2004-07-27 18:34:11 +000093 }
94 }
Misha Brukman5dfe3a92004-06-21 16:55:25 +000095};
96
97}
98
99#endif