2004-02-25 19:28:19 +00:00
|
|
|
//===- SparcV8InstrInfo.cpp - SparcV8 Instruction Information ---*- C++ -*-===//
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-02-25 19:28:19 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-02-25 19:28:19 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the SparcV8 implementation of the TargetInstrInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SparcV8InstrInfo.h"
|
2004-07-25 06:19:04 +00:00
|
|
|
#include "SparcV8.h"
|
2004-02-25 19:28:19 +00:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
|
|
|
#include "SparcV8GenInstrInfo.inc"
|
2004-02-29 05:59:33 +00:00
|
|
|
using namespace llvm;
|
2004-02-25 19:28:19 +00:00
|
|
|
|
|
|
|
SparcV8InstrInfo::SparcV8InstrInfo()
|
2004-02-29 06:31:44 +00:00
|
|
|
: TargetInstrInfo(SparcV8Insts, sizeof(SparcV8Insts)/sizeof(SparcV8Insts[0])){
|
2004-02-25 19:28:19 +00:00
|
|
|
}
|
|
|
|
|
2004-12-11 05:19:03 +00:00
|
|
|
static bool isZeroImmed (const MachineOperand &op) {
|
|
|
|
return (op.isImmediate() && op.getImmedValue() == 0);
|
|
|
|
}
|
|
|
|
|
2004-07-25 06:19:04 +00:00
|
|
|
/// Return true if the instruction is a register to register move and
|
|
|
|
/// leave the source and dest operands in the passed parameters.
|
|
|
|
///
|
|
|
|
bool SparcV8InstrInfo::isMoveInstr(const MachineInstr &MI,
|
|
|
|
unsigned &SrcReg, unsigned &DstReg) const {
|
2004-12-11 05:19:03 +00:00
|
|
|
// We look for 3 kinds of patterns here:
|
|
|
|
// or with G0 or 0
|
|
|
|
// add with G0 or 0
|
|
|
|
// fmovs or FpMOVD (pseudo double move).
|
|
|
|
if (MI.getOpcode() == V8::ORrr || MI.getOpcode() == V8::ADDrr) {
|
|
|
|
if (MI.getOperand(1).getReg() == V8::G0) {
|
|
|
|
DstReg = MI.getOperand(0).getReg();
|
|
|
|
SrcReg = MI.getOperand(2).getReg();
|
|
|
|
return true;
|
|
|
|
} else if (MI.getOperand (2).getReg() == V8::G0) {
|
|
|
|
DstReg = MI.getOperand(0).getReg();
|
|
|
|
SrcReg = MI.getOperand(1).getReg();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else if (MI.getOpcode() == V8::ORri || MI.getOpcode() == V8::ADDri) {
|
2005-12-18 06:40:34 +00:00
|
|
|
if (isZeroImmed(MI.getOperand(2)) && MI.getOperand(1).isRegister()) {
|
2004-12-11 05:19:03 +00:00
|
|
|
DstReg = MI.getOperand(0).getReg();
|
|
|
|
SrcReg = MI.getOperand(1).getReg();
|
|
|
|
return true;
|
2004-07-25 06:19:04 +00:00
|
|
|
}
|
2004-09-29 16:45:47 +00:00
|
|
|
} else if (MI.getOpcode() == V8::FMOVS || MI.getOpcode() == V8::FpMOVD) {
|
2004-07-25 06:19:04 +00:00
|
|
|
SrcReg = MI.getOperand(1).getReg();
|
|
|
|
DstReg = MI.getOperand(0).getReg();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|