Misha Brukman | 2a8350a | 2005-02-05 02:24:26 +0000 | [diff] [blame] | 1 | //===- AlphaInstrInfo.cpp - Alpha Instruction Information -------*- C++ -*-===// |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 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 Alpha implementation of the TargetInstrInfo class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "Alpha.h" |
| 15 | #include "AlphaInstrInfo.h" |
| 16 | #include "AlphaGenInstrInfo.inc" |
| 17 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 18 | #include <iostream> |
| 19 | using namespace llvm; |
| 20 | |
| 21 | AlphaInstrInfo::AlphaInstrInfo() |
| 22 | : TargetInstrInfo(AlphaInsts, sizeof(AlphaInsts)/sizeof(AlphaInsts[0])) { } |
| 23 | |
| 24 | |
| 25 | bool AlphaInstrInfo::isMoveInstr(const MachineInstr& MI, |
| 26 | unsigned& sourceReg, |
| 27 | unsigned& destReg) const { |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 28 | MachineOpCode oc = MI.getOpcode(); |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 29 | if (oc == Alpha::BIS || oc == Alpha::CPYS) { // or r1, r2, r2 // cpys r1 r2 r2 |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 30 | assert(MI.getNumOperands() == 3 && |
| 31 | MI.getOperand(0).isRegister() && |
| 32 | MI.getOperand(1).isRegister() && |
| 33 | MI.getOperand(2).isRegister() && |
| 34 | "invalid Alpha BIS instruction!"); |
| 35 | if (MI.getOperand(1).getReg() == MI.getOperand(2).getReg()) { |
| 36 | sourceReg = MI.getOperand(1).getReg(); |
| 37 | destReg = MI.getOperand(0).getReg(); |
| 38 | return true; |
| 39 | } |
| 40 | } |
| 41 | return false; |
| 42 | } |