blob: 01c513ac5ed27cacdeb4e1d46bbd991dba8d53e3 [file] [log] [blame]
Brian Gaekee785e532004-02-25 19:28:19 +00001//===- SparcV8InstrInfo.cpp - SparcV8 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 SparcV8 implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#include "SparcV8InstrInfo.h"
Chris Lattner1d6dc972004-07-25 06:19:04 +000015#include "SparcV8.h"
Brian Gaekee785e532004-02-25 19:28:19 +000016#include "llvm/CodeGen/MachineInstrBuilder.h"
17#include "SparcV8GenInstrInfo.inc"
Chris Lattner1ddf4752004-02-29 05:59:33 +000018using namespace llvm;
Brian Gaekee785e532004-02-25 19:28:19 +000019
20SparcV8InstrInfo::SparcV8InstrInfo()
Chris Lattnerdce363d2004-02-29 06:31:44 +000021 : TargetInstrInfo(SparcV8Insts, sizeof(SparcV8Insts)/sizeof(SparcV8Insts[0])){
Brian Gaekee785e532004-02-25 19:28:19 +000022}
23
Chris Lattner1d6dc972004-07-25 06:19:04 +000024/// Return true if the instruction is a register to register move and
25/// leave the source and dest operands in the passed parameters.
26///
27bool SparcV8InstrInfo::isMoveInstr(const MachineInstr &MI,
28 unsigned &SrcReg, unsigned &DstReg) const {
29 if (MI.getOpcode() == V8::ORrr) {
30 if (MI.getOperand(1).getReg() == V8::G0) { // X = or G0, Y -> X = Y
31 DstReg = MI.getOperand(0).getReg();
32 SrcReg = MI.getOperand(2).getReg();
Brian Gaeke9b8ed0e2004-09-29 03:28:15 +000033 return true;
Chris Lattner1d6dc972004-07-25 06:19:04 +000034 }
Brian Gaeke9ed92042004-09-29 16:45:47 +000035 } else if (MI.getOpcode() == V8::FMOVS || MI.getOpcode() == V8::FpMOVD) {
Chris Lattner1d6dc972004-07-25 06:19:04 +000036 SrcReg = MI.getOperand(1).getReg();
37 DstReg = MI.getOperand(0).getReg();
38 return true;
39 }
40 return false;
41}