blob: fa3537c6482c2064f9c90adebac3e68b71ebeee1 [file] [log] [blame]
Chris Lattner055c9652002-10-29 21:05:24 +00001//===- X86InstrInfo.cpp - X86 Instruction Information ---------------===//
Chris Lattner72614082002-10-25 22:55:53 +00002//
Chris Lattner33f53b52002-10-29 20:48:56 +00003// This file contains the X86 implementation of the MachineInstrInfo class.
Chris Lattner72614082002-10-25 22:55:53 +00004//
5//===----------------------------------------------------------------------===//
6
Chris Lattner055c9652002-10-29 21:05:24 +00007#include "X86InstrInfo.h"
Chris Lattner9bbf4392002-10-29 17:43:19 +00008#include "llvm/CodeGen/MachineInstr.h"
9#include <iostream>
Chris Lattner72614082002-10-25 22:55:53 +000010
Chris Lattner055c9652002-10-29 21:05:24 +000011// X86Insts - Turn the InstrInfo.def file into a bunch of instruction
Chris Lattner72614082002-10-25 22:55:53 +000012// descriptors
13//
Chris Lattner9bbf4392002-10-29 17:43:19 +000014static const MachineInstrDescriptor X86Insts[] = {
Chris Lattner6aab9cf2002-11-18 05:37:11 +000015#define I(ENUM, NAME, BASEOPCODE, FLAGS, TSFLAGS) \
Chris Lattnerb752e9a2002-10-30 01:15:31 +000016 { NAME, \
17 -1, /* Always vararg */ \
18 ((TSFLAGS) & X86II::Void) ? -1 : 0, /* Result is in 0 */ \
19 0, false, 0, 0, TSFLAGS, FLAGS, TSFLAGS },
Chris Lattner055c9652002-10-29 21:05:24 +000020#include "X86InstrInfo.def"
Chris Lattner72614082002-10-25 22:55:53 +000021};
22
Chris Lattner055c9652002-10-29 21:05:24 +000023X86InstrInfo::X86InstrInfo()
Chris Lattner9bbf4392002-10-29 17:43:19 +000024 : MachineInstrInfo(X86Insts, sizeof(X86Insts)/sizeof(X86Insts[0]), 0) {
Chris Lattner72614082002-10-25 22:55:53 +000025}
26
27
Chris Lattnerf21dfcd2002-11-18 06:56:24 +000028static 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//
36unsigned char X86InstrInfo::getBaseOpcodeFor(unsigned Opcode) const {
37 assert(Opcode < sizeof(BaseOpcodes)/sizeof(BaseOpcodes[0]) &&
38 "Opcode out of range!");
39 return BaseOpcodes[Opcode];
40}