blob: bbc0be4cd56fc808904bd2296c27595f7493d780 [file] [log] [blame]
Misha Brukman116f9272004-08-17 04:55:41 +00001//===- PPC32InstrInfo.h - PowerPC32 Instruction Information -----*- C++ -*-===//
Misha Brukmanb4402432005-04-21 23:30:14 +00002//
Misha Brukman116f9272004-08-17 04:55:41 +00003// 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.
Misha Brukmanb4402432005-04-21 23:30:14 +00007//
Misha Brukman116f9272004-08-17 04:55:41 +00008//===----------------------------------------------------------------------===//
9//
10// This file contains the PowerPC implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef POWERPC32_INSTRUCTIONINFO_H
15#define POWERPC32_INSTRUCTIONINFO_H
16
17#include "PowerPCInstrInfo.h"
18#include "PPC32RegisterInfo.h"
19
20namespace llvm {
21
22class PPC32InstrInfo : public TargetInstrInfo {
23 const PPC32RegisterInfo RI;
24public:
25 PPC32InstrInfo();
26
27 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
28 /// such, whenever a client has an instance of instruction info, it should
29 /// always be able to get register info as well (through this method).
30 ///
31 virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
32
33 //
34 // Return true if the instruction is a register to register move and
35 // leave the source and dest operands in the passed parameters.
36 //
37 virtual bool isMoveInstr(const MachineInstr& MI,
38 unsigned& sourceReg,
39 unsigned& destReg) const;
40
Chris Lattnerc37a2f12005-09-09 18:17:41 +000041 // commuteInstruction - We can commute rlwimi instructions, but only if the
42 // rotate amt is zero. We also have to munge the immediates a bit.
43 virtual MachineInstr *commuteInstruction(MachineInstr *MI) const;
44
Misha Brukman116f9272004-08-17 04:55:41 +000045 static unsigned invertPPCBranchOpcode(unsigned Opcode) {
46 switch (Opcode) {
47 default: assert(0 && "Unknown PPC branch opcode!");
48 case PPC::BEQ: return PPC::BNE;
49 case PPC::BNE: return PPC::BEQ;
50 case PPC::BLT: return PPC::BGE;
51 case PPC::BGE: return PPC::BLT;
52 case PPC::BGT: return PPC::BLE;
53 case PPC::BLE: return PPC::BGT;
Misha Brukmanb4402432005-04-21 23:30:14 +000054 }
Misha Brukman116f9272004-08-17 04:55:41 +000055 }
56};
57
58}
59
60#endif