blob: da92dcf20f721db036b826175f54fe510c79d955 [file] [log] [blame]
Nate Begeman21e463b2005-10-16 05:39:50 +00001//===- PPCInstrInfo.h - PowerPC32 Instruction Information -------*- C++ -*-===//
Misha Brukmanb5f662f2005-04-21 23:30:14 +00002//
Misha Brukmanf2ccb772004-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 Brukmanb5f662f2005-04-21 23:30:14 +00007//
Misha Brukmanf2ccb772004-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
Chris Lattner26689592005-10-14 23:51:18 +000017#include "PPC.h"
Chris Lattner617742b2005-10-14 22:44:13 +000018#include "llvm/Target/TargetInstrInfo.h"
Chris Lattner16e71f22005-10-14 23:59:06 +000019#include "PPCRegisterInfo.h"
Misha Brukmanf2ccb772004-08-17 04:55:41 +000020
21namespace llvm {
Chris Lattner617742b2005-10-14 22:44:13 +000022
Nate Begeman21e463b2005-10-16 05:39:50 +000023class PPCInstrInfo : public TargetInstrInfo {
24 const PPCRegisterInfo RI;
Misha Brukmanf2ccb772004-08-17 04:55:41 +000025public:
Nate Begeman21e463b2005-10-16 05:39:50 +000026 PPCInstrInfo();
Misha Brukmanf2ccb772004-08-17 04:55:41 +000027
28 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
29 /// such, whenever a client has an instance of instruction info, it should
30 /// always be able to get register info as well (through this method).
31 ///
32 virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
33
34 //
35 // Return true if the instruction is a register to register move and
36 // leave the source and dest operands in the passed parameters.
37 //
38 virtual bool isMoveInstr(const MachineInstr& MI,
39 unsigned& sourceReg,
40 unsigned& destReg) const;
41
Chris Lattner043870d2005-09-09 18:17:41 +000042 // commuteInstruction - We can commute rlwimi instructions, but only if the
43 // rotate amt is zero. We also have to munge the immediates a bit.
44 virtual MachineInstr *commuteInstruction(MachineInstr *MI) const;
45
Misha Brukmanf2ccb772004-08-17 04:55:41 +000046 static unsigned invertPPCBranchOpcode(unsigned Opcode) {
47 switch (Opcode) {
48 default: assert(0 && "Unknown PPC branch opcode!");
49 case PPC::BEQ: return PPC::BNE;
50 case PPC::BNE: return PPC::BEQ;
51 case PPC::BLT: return PPC::BGE;
52 case PPC::BGE: return PPC::BLT;
53 case PPC::BGT: return PPC::BLE;
54 case PPC::BLE: return PPC::BGT;
Misha Brukmanb5f662f2005-04-21 23:30:14 +000055 }
Misha Brukmanf2ccb772004-08-17 04:55:41 +000056 }
57};
58
59}
60
61#endif