Implement printing more, implement opcode output more
[oota-llvm.git] / lib / Target / X86 / X86InstrInfo.cpp
1 //===- X86InstrInfo.cpp - X86 Instruction Information ---------------===//
2 //
3 // This file contains the X86 implementation of the MachineInstrInfo class.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #include "X86InstrInfo.h"
8 #include "llvm/CodeGen/MachineInstr.h"
9 #include <iostream>
10
11 // X86Insts - Turn the InstrInfo.def file into a bunch of instruction
12 // descriptors
13 //
14 static const MachineInstrDescriptor X86Insts[] = {
15 #define I(ENUM, NAME, BASEOPCODE, FLAGS, TSFLAGS)   \
16              { NAME,                    \
17                -1, /* Always vararg */  \
18                ((TSFLAGS) & X86II::Void) ? -1 : 0,  /* Result is in 0 */ \
19                0, false, 0, 0, TSFLAGS, FLAGS, TSFLAGS },
20 #include "X86InstrInfo.def"
21 };
22
23 X86InstrInfo::X86InstrInfo()
24   : MachineInstrInfo(X86Insts, sizeof(X86Insts)/sizeof(X86Insts[0]), 0) {
25 }
26
27
28 static unsigned char BaseOpcodes[] = {
29 #define I(ENUM, NAME, BASEOPCODE, FLAGS, TSFLAGS) BASEOPCODE,
30 #include "X86InstrInfo.def"
31 };
32
33 // getBaseOpcodeFor - This function returns the "base" X86 opcode for the
34 // specified opcode number.
35 //
36 unsigned char X86InstrInfo::getBaseOpcodeFor(unsigned Opcode) const {
37   assert(Opcode < sizeof(BaseOpcodes)/sizeof(BaseOpcodes[0]) &&
38          "Opcode out of range!");
39   return BaseOpcodes[Opcode];
40 }