blob: a4cdbce6bf11af7ae0cc93e7922b8f7cd795805e [file] [log] [blame]
Duraid Madina9b9d45f2005-03-17 18:17:03 +00001//===- IA64InstrInfo.cpp - IA64 Instruction Information -----------*- C++ -*-===//
Misha Brukman4633f1c2005-04-21 23:13:11 +00002//
Duraid Madina9b9d45f2005-03-17 18:17:03 +00003// 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.
Misha Brukman4633f1c2005-04-21 23:13:11 +00007//
Duraid Madina9b9d45f2005-03-17 18:17:03 +00008//===----------------------------------------------------------------------===//
9//
10// This file contains the IA64 implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#include "IA64InstrInfo.h"
15#include "IA64.h"
16#include "IA64InstrBuilder.h"
17#include "llvm/CodeGen/MachineInstrBuilder.h"
18#include "IA64GenInstrInfo.inc"
19using namespace llvm;
20
21IA64InstrInfo::IA64InstrInfo()
22 : TargetInstrInfo(IA64Insts, sizeof(IA64Insts)/sizeof(IA64Insts[0])) {
23}
24
25
26bool IA64InstrInfo::isMoveInstr(const MachineInstr& MI,
27 unsigned& sourceReg,
28 unsigned& destReg) const {
29 MachineOpCode oc = MI.getOpcode();
30 if (oc == IA64::MOV || oc == IA64::FMOV) {
Duraid Madinabadf0d92006-01-25 02:23:38 +000031 // TODO: this doesn't detect predicate moves
Duraid Madina9b9d45f2005-03-17 18:17:03 +000032 assert(MI.getNumOperands() == 2 &&
33 /* MI.getOperand(0).isRegister() &&
34 MI.getOperand(1).isRegister() && */
35 "invalid register-register move instruction");
36 if( MI.getOperand(0).isRegister() &&
Misha Brukman7847fca2005-04-22 17:54:37 +000037 MI.getOperand(1).isRegister() ) {
Duraid Madina9b9d45f2005-03-17 18:17:03 +000038 // if both operands of the MOV/FMOV are registers, then
39 // yes, this is a move instruction
40 sourceReg = MI.getOperand(1).getReg();
41 destReg = MI.getOperand(0).getReg();
42 return true;
43 }
44 }
45 return false; // we don't consider e.g. %regN = MOV <FrameIndex #x> a
46 // move instruction
47}
48
Chris Lattner11533e22006-10-24 16:44:55 +000049void IA64InstrInfo::InsertBranch(MachineBasicBlock &MBB,MachineBasicBlock *TBB,
50 MachineBasicBlock *FBB,
51 const std::vector<MachineOperand> &Cond)const {
52 // Can only insert uncond branches so far.
53 assert(Cond.empty() && !FBB && TBB && "Can only handle uncond branches!");
54 BuildMI(&MBB, IA64::BRL_NOTCALL, 1).addMBB(TBB);
55}