make instcombine only rewrite a chain of computation
[oota-llvm.git] / lib / MC / MCInst.cpp
1 //===- lib/MC/MCInst.cpp - MCInst implementation --------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/MC/MCInst.h"
11 #include "llvm/MC/MCExpr.h"
12 #include "llvm/Support/raw_ostream.h"
13
14 using namespace llvm;
15
16 void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
17   OS << "<MCOperand ";
18   if (!isValid())
19     OS << "INVALID";
20   else if (isReg())
21     OS << "Reg:" << getReg();
22   else if (isImm())
23     OS << "Imm:" << getImm();
24   else if (isExpr()) {
25     OS << "Expr:(";
26     getExpr()->print(OS, MAI);
27     OS << ")";
28   } else
29     OS << "UNDEFINED";
30   OS << ">";
31 }
32
33 void MCOperand::dump() const {
34   print(errs(), 0);
35   errs() << "\n";
36 }
37
38 void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
39   OS << "<MCInst " << getOpcode();
40   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
41     OS << " ";
42     getOperand(i).print(OS, MAI);
43   }
44   OS << ">";
45 }
46
47 void MCInst::dump() const {
48   print(errs(), 0);
49   errs() << "\n";
50 }