blob: f046e5dfb02aaac3a417acc8d0c35a252400c8f1 [file] [log] [blame]
Chris Lattner36eba3a2006-01-18 19:37:44 +00001//===- PPCInstrInfo.h - PowerPC 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
Chris Lattnerbfca1ab2005-10-14 23:51:18 +000017#include "PPC.h"
Chris Lattner2121f3c2005-10-14 22:44:13 +000018#include "llvm/Target/TargetInstrInfo.h"
Chris Lattner6f3b9542005-10-14 23:59:06 +000019#include "PPCRegisterInfo.h"
Misha Brukman116f9272004-08-17 04:55:41 +000020
21namespace llvm {
Chris Lattner2121f3c2005-10-14 22:44:13 +000022
Nate Begeman6cca84e2005-10-16 05:39:50 +000023class PPCInstrInfo : public TargetInstrInfo {
24 const PPCRegisterInfo RI;
Misha Brukman116f9272004-08-17 04:55:41 +000025public:
Nate Begeman6cca84e2005-10-16 05:39:50 +000026 PPCInstrInfo();
Misha Brukman116f9272004-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 Lattnerbb53acd2006-02-02 20:12:32 +000042 unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const;
Chris Lattnerc327d712006-02-02 20:16:12 +000043 unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const;
Chris Lattnerbb53acd2006-02-02 20:12:32 +000044
Chris Lattnerc37a2f12005-09-09 18:17:41 +000045 // commuteInstruction - We can commute rlwimi instructions, but only if the
46 // rotate amt is zero. We also have to munge the immediates a bit.
47 virtual MachineInstr *commuteInstruction(MachineInstr *MI) const;
48
Misha Brukman116f9272004-08-17 04:55:41 +000049 static unsigned invertPPCBranchOpcode(unsigned Opcode) {
50 switch (Opcode) {
51 default: assert(0 && "Unknown PPC branch opcode!");
52 case PPC::BEQ: return PPC::BNE;
53 case PPC::BNE: return PPC::BEQ;
54 case PPC::BLT: return PPC::BGE;
55 case PPC::BGE: return PPC::BLT;
56 case PPC::BGT: return PPC::BLE;
57 case PPC::BLE: return PPC::BGT;
Chris Lattner15e76422006-01-18 19:35:21 +000058 case PPC::BNU: return PPC::BUN;
59 case PPC::BUN: return PPC::BNU;
Misha Brukmanb4402432005-04-21 23:30:14 +000060 }
Misha Brukman116f9272004-08-17 04:55:41 +000061 }
62};
63
64}
65
66#endif