Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 1 | //===- 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 Brukman | 0145881 | 2004-08-11 00:11:25 +0000 | [diff] [blame^] | 14 | #ifndef POWERPC_INSTRUCTIONINFO_H |
| 15 | #define POWERPC_INSTRUCTIONINFO_H |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 16 | |
Misha Brukman | 8aebe9f | 2004-07-27 18:34:11 +0000 | [diff] [blame] | 17 | #include "PowerPC.h" |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 18 | #include "PowerPCRegisterInfo.h" |
Misha Brukman | 8aebe9f | 2004-07-27 18:34:11 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetInstrInfo.h" |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
| 22 | |
Misha Brukman | 5b57081 | 2004-08-10 22:47:03 +0000 | [diff] [blame] | 23 | namespace PPCII { |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 24 | 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 | |
| 65 | class PowerPCInstrInfo : public TargetInstrInfo { |
| 66 | const PowerPCRegisterInfo RI; |
| 67 | public: |
| 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 Brukman | 6b4ea88 | 2004-07-16 20:50:55 +0000 | [diff] [blame] | 75 | |
| 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 Brukman | 8aebe9f | 2004-07-27 18:34:11 +0000 | [diff] [blame] | 83 | |
| 84 | static unsigned invertPPCBranchOpcode(unsigned Opcode) { |
| 85 | switch (Opcode) { |
Misha Brukman | 5b57081 | 2004-08-10 22:47:03 +0000 | [diff] [blame] | 86 | 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 Brukman | 8aebe9f | 2004-07-27 18:34:11 +0000 | [diff] [blame] | 93 | } |
| 94 | } |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | } |
| 98 | |
| 99 | #endif |