bf26d74758f2250102f5d2d4083faab1db99b91a
[oota-llvm.git] / lib / Target / X86 / X86InstrInfo.cpp
1 //===- X86InstrInfo.cpp - X86 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 X86 implementation of the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "X86InstrInfo.h"
15 #include "X86.h"
16 #include "llvm/CodeGen/MachineInstrBuilder.h"
17
18 #include "X86GenInstrInfo.inc"
19
20 using namespace llvm;
21
22 X86InstrInfo::X86InstrInfo()
23   : TargetInstrInfo(X86Insts, sizeof(X86Insts)/sizeof(X86Insts[0]), 0) {
24 }
25
26
27 bool X86InstrInfo::isMoveInstr(const MachineInstr& MI,
28                                unsigned& sourceReg,
29                                unsigned& destReg) const {
30   MachineOpCode oc = MI.getOpcode();
31   if (oc == X86::MOVrr8 || oc == X86::MOVrr16 || oc == X86::MOVrr32 ||
32       oc == X86::FpMOV) {
33       assert(MI.getNumOperands() == 2 &&
34              MI.getOperand(0).isRegister() &&
35              MI.getOperand(1).isRegister() &&
36              "invalid register-register move instruction");
37       sourceReg = MI.getOperand(1).getReg();
38       destReg = MI.getOperand(0).getReg();
39       return true;
40   }
41   return false;
42 }