blob: c64fe3bee940bdf09fe81ef8f57a8424a51e9e1a [file] [log] [blame]
Misha Brukman2a8350a2005-02-05 02:24:26 +00001//===- AlphaInstrInfo.cpp - Alpha Instruction Information -------*- C++ -*-===//
Misha Brukman4633f1c2005-04-21 23:13:11 +00002//
Andrew Lenharth304d0f32005-01-22 23:41:55 +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//
Andrew Lenharth304d0f32005-01-22 23:41:55 +00008//===----------------------------------------------------------------------===//
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>
19using namespace llvm;
20
21AlphaInstrInfo::AlphaInstrInfo()
22 : TargetInstrInfo(AlphaInsts, sizeof(AlphaInsts)/sizeof(AlphaInsts[0])) { }
23
24
25bool AlphaInstrInfo::isMoveInstr(const MachineInstr& MI,
26 unsigned& sourceReg,
27 unsigned& destReg) const {
Andrew Lenharth304d0f32005-01-22 23:41:55 +000028 MachineOpCode oc = MI.getOpcode();
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +000029 if (oc == Alpha::BIS || oc == Alpha::CPYSS || oc == Alpha::CPYST) {
30 // or r1, r2, r2
31 // cpys(s|t) r1 r2 r2
Andrew Lenharth304d0f32005-01-22 23:41:55 +000032 assert(MI.getNumOperands() == 3 &&
33 MI.getOperand(0).isRegister() &&
34 MI.getOperand(1).isRegister() &&
35 MI.getOperand(2).isRegister() &&
36 "invalid Alpha BIS instruction!");
37 if (MI.getOperand(1).getReg() == MI.getOperand(2).getReg()) {
38 sourceReg = MI.getOperand(1).getReg();
39 destReg = MI.getOperand(0).getReg();
40 return true;
41 }
42 }
43 return false;
44}
Chris Lattner40839602006-02-02 20:12:32 +000045
46unsigned
47AlphaInstrInfo::isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const {
48 switch (MI->getOpcode()) {
49 case Alpha::LDL:
50 case Alpha::LDQ:
51 case Alpha::LDBU:
52 case Alpha::LDWU:
53 case Alpha::LDS:
54 case Alpha::LDT:
55 if (MI->getOperand(1).isFrameIndex()) {
56 FrameIndex = MI->getOperand(1).getFrameIndex();
57 return MI->getOperand(0).getReg();
58 }
59 break;
60 }
61 return 0;
62}
63