2010-01-29 01:21:04 +01:00
|
|
|
//===- EDEmitter.cpp - Generate instruction descriptions for ED -*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This tablegen backend is responsible for emitting a description of each
|
|
|
|
// instruction in a format that the enhanced disassembler can use to tokenize
|
|
|
|
// and parse instructions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-02-10 00:06:35 +01:00
|
|
|
#include "AsmWriterInst.h"
|
2010-01-29 01:21:04 +01:00
|
|
|
#include "CodeGenTarget.h"
|
2010-04-13 23:21:57 +02:00
|
|
|
#include "llvm/MC/EDInstInfo.h"
|
2010-01-29 01:21:04 +01:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Support/Format.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2012-06-11 17:37:55 +02:00
|
|
|
#include "llvm/TableGen/Record.h"
|
|
|
|
#include "llvm/TableGen/TableGenBackend.h"
|
2010-01-29 01:21:04 +01:00
|
|
|
#include <string>
|
2010-04-08 02:48:21 +02:00
|
|
|
#include <vector>
|
2010-01-29 01:21:04 +01:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
// TODO: There's a suspiciously large amount of "table" data in this
|
|
|
|
// backend which should probably be in the TableGen file itself.
|
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Support classes for emitting nested C data structures //
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
// TODO: These classes are probably generally useful to other backends;
|
|
|
|
// add them to TableGen's "helper" API's.
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
namespace {
|
|
|
|
class EnumEmitter {
|
|
|
|
private:
|
|
|
|
std::string Name;
|
|
|
|
std::vector<std::string> Entries;
|
|
|
|
public:
|
|
|
|
EnumEmitter(const char *N) : Name(N) {
|
|
|
|
}
|
|
|
|
int addEntry(const char *e) {
|
|
|
|
Entries.push_back(std::string(e));
|
|
|
|
return Entries.size() - 1;
|
|
|
|
}
|
|
|
|
void emit(raw_ostream &o, unsigned int &i) {
|
|
|
|
o.indent(i) << "enum " << Name.c_str() << " {" << "\n";
|
|
|
|
i += 2;
|
|
|
|
|
|
|
|
unsigned int index = 0;
|
|
|
|
unsigned int numEntries = Entries.size();
|
|
|
|
for (index = 0; index < numEntries; ++index) {
|
|
|
|
o.indent(i) << Entries[index];
|
|
|
|
if (index < (numEntries - 1))
|
|
|
|
o << ",";
|
|
|
|
o << "\n";
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
i -= 2;
|
|
|
|
o.indent(i) << "};" << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
void emitAsFlags(raw_ostream &o, unsigned int &i) {
|
|
|
|
o.indent(i) << "enum " << Name.c_str() << " {" << "\n";
|
|
|
|
i += 2;
|
|
|
|
|
|
|
|
unsigned int index = 0;
|
|
|
|
unsigned int numEntries = Entries.size();
|
|
|
|
unsigned int flag = 1;
|
|
|
|
for (index = 0; index < numEntries; ++index) {
|
|
|
|
o.indent(i) << Entries[index] << " = " << format("0x%x", flag);
|
|
|
|
if (index < (numEntries - 1))
|
|
|
|
o << ",";
|
|
|
|
o << "\n";
|
|
|
|
flag <<= 1;
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
i -= 2;
|
|
|
|
o.indent(i) << "};" << "\n";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // End anonymous namespace
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
namespace {
|
|
|
|
class ConstantEmitter {
|
|
|
|
public:
|
|
|
|
virtual ~ConstantEmitter() { }
|
|
|
|
virtual void emit(raw_ostream &o, unsigned int &i) = 0;
|
|
|
|
};
|
|
|
|
} // End anonymous namespace
|
2010-01-29 01:21:04 +01:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
namespace {
|
|
|
|
class LiteralConstantEmitter : public ConstantEmitter {
|
|
|
|
private:
|
|
|
|
bool IsNumber;
|
|
|
|
union {
|
|
|
|
int Number;
|
|
|
|
const char* String;
|
2010-01-29 01:21:04 +01:00
|
|
|
};
|
2012-06-11 17:37:55 +02:00
|
|
|
public:
|
|
|
|
LiteralConstantEmitter(int number = 0) :
|
|
|
|
IsNumber(true),
|
|
|
|
Number(number) {
|
|
|
|
}
|
|
|
|
void set(const char *string) {
|
|
|
|
IsNumber = false;
|
|
|
|
Number = 0;
|
|
|
|
String = string;
|
|
|
|
}
|
|
|
|
bool is(const char *string) {
|
|
|
|
return !strcmp(String, string);
|
|
|
|
}
|
|
|
|
void emit(raw_ostream &o, unsigned int &i) {
|
|
|
|
if (IsNumber)
|
|
|
|
o << Number;
|
|
|
|
else
|
|
|
|
o << String;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // End anonymous namespace
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
namespace {
|
|
|
|
class CompoundConstantEmitter : public ConstantEmitter {
|
|
|
|
private:
|
|
|
|
unsigned int Padding;
|
|
|
|
std::vector<ConstantEmitter *> Entries;
|
|
|
|
public:
|
|
|
|
CompoundConstantEmitter(unsigned int padding = 0) : Padding(padding) {
|
|
|
|
}
|
|
|
|
CompoundConstantEmitter &addEntry(ConstantEmitter *e) {
|
|
|
|
Entries.push_back(e);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
~CompoundConstantEmitter() {
|
|
|
|
while (Entries.size()) {
|
|
|
|
ConstantEmitter *entry = Entries.back();
|
|
|
|
Entries.pop_back();
|
|
|
|
delete entry;
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
2012-06-11 17:37:55 +02:00
|
|
|
}
|
|
|
|
void emit(raw_ostream &o, unsigned int &i) {
|
|
|
|
o << "{" << "\n";
|
|
|
|
i += 2;
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
unsigned int index;
|
|
|
|
unsigned int numEntries = Entries.size();
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
unsigned int numToPrint;
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
if (Padding) {
|
|
|
|
if (numEntries > Padding) {
|
|
|
|
fprintf(stderr, "%u entries but %u padding\n", numEntries, Padding);
|
|
|
|
llvm_unreachable("More entries than padding");
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
2012-06-11 17:37:55 +02:00
|
|
|
numToPrint = Padding;
|
|
|
|
} else {
|
|
|
|
numToPrint = numEntries;
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
for (index = 0; index < numToPrint; ++index) {
|
|
|
|
o.indent(i);
|
|
|
|
if (index < numEntries)
|
|
|
|
Entries[index]->emit(o, i);
|
|
|
|
else
|
|
|
|
o << "-1";
|
|
|
|
|
|
|
|
if (index < (numToPrint - 1))
|
|
|
|
o << ",";
|
|
|
|
o << "\n";
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
i -= 2;
|
|
|
|
o.indent(i) << "}";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // End anonymous namespace
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
class FlagsConstantEmitter : public ConstantEmitter {
|
|
|
|
private:
|
|
|
|
std::vector<std::string> Flags;
|
|
|
|
public:
|
|
|
|
FlagsConstantEmitter() {
|
|
|
|
}
|
|
|
|
FlagsConstantEmitter &addEntry(const char *f) {
|
|
|
|
Flags.push_back(std::string(f));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
void emit(raw_ostream &o, unsigned int &i) {
|
|
|
|
unsigned int index;
|
|
|
|
unsigned int numFlags = Flags.size();
|
|
|
|
if (numFlags == 0)
|
|
|
|
o << "0";
|
|
|
|
|
|
|
|
for (index = 0; index < numFlags; ++index) {
|
|
|
|
o << Flags[index].c_str();
|
|
|
|
if (index < (numFlags - 1))
|
|
|
|
o << " | ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // End anonymous namespace
|
2010-01-29 01:21:04 +01:00
|
|
|
|
2010-02-10 03:47:08 +01:00
|
|
|
/// populateOperandOrder - Accepts a CodeGenInstruction and generates its
|
|
|
|
/// AsmWriterInst for the desired assembly syntax, giving an ordered list of
|
|
|
|
/// operands in the order they appear in the printed instruction. Then, for
|
|
|
|
/// each entry in that list, determines the index of the same operand in the
|
|
|
|
/// CodeGenInstruction, and emits the resulting mapping into an array, filling
|
|
|
|
/// in unused slots with -1.
|
2010-01-29 01:21:04 +01:00
|
|
|
///
|
|
|
|
/// @arg operandOrder - The array that will be populated with the operand
|
|
|
|
/// mapping. Each entry will contain -1 (invalid index
|
|
|
|
/// into the operands present in the AsmString) or a number
|
|
|
|
/// representing an index in the operand descriptor array.
|
2010-02-10 03:47:08 +01:00
|
|
|
/// @arg inst - The instruction to use when looking up the operands
|
|
|
|
/// @arg syntax - The syntax to use, according to LLVM's enumeration
|
2012-06-11 17:37:55 +02:00
|
|
|
static void populateOperandOrder(CompoundConstantEmitter *operandOrder,
|
|
|
|
const CodeGenInstruction &inst,
|
|
|
|
unsigned syntax) {
|
2010-01-29 01:21:04 +01:00
|
|
|
unsigned int numArgs = 0;
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-02-10 03:47:08 +01:00
|
|
|
AsmWriterInst awInst(inst, syntax, -1, -1);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-02-10 03:47:08 +01:00
|
|
|
std::vector<AsmWriterOperand>::iterator operandIterator;
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-02-10 03:47:08 +01:00
|
|
|
for (operandIterator = awInst.Operands.begin();
|
|
|
|
operandIterator != awInst.Operands.end();
|
|
|
|
++operandIterator) {
|
2010-10-05 22:35:57 +02:00
|
|
|
if (operandIterator->OperandType ==
|
2010-02-10 03:47:08 +01:00
|
|
|
AsmWriterOperand::isMachineInstrOperand) {
|
2010-04-08 02:48:21 +02:00
|
|
|
operandOrder->addEntry(
|
|
|
|
new LiteralConstantEmitter(operandIterator->CGIOpNo));
|
2010-02-10 03:47:08 +01:00
|
|
|
numArgs++;
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Support functions for handling X86 instructions //
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
#define SET(flag) { type->set(flag); return 0; }
|
2010-01-29 01:21:04 +01:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
#define REG(str) if (name == str) SET("kOperandTypeRegister");
|
|
|
|
#define MEM(str) if (name == str) SET("kOperandTypeX86Memory");
|
|
|
|
#define LEA(str) if (name == str) SET("kOperandTypeX86EffectiveAddress");
|
|
|
|
#define IMM(str) if (name == str) SET("kOperandTypeImmediate");
|
|
|
|
#define PCR(str) if (name == str) SET("kOperandTypeX86PCRelative");
|
2010-01-29 01:21:04 +01:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
/// X86TypeFromOpName - Processes the name of a single X86 operand (which is
|
|
|
|
/// actually its type) and translates it into an operand type
|
2010-01-29 01:21:04 +01:00
|
|
|
///
|
2010-04-08 02:48:21 +02:00
|
|
|
/// @arg flags - The type object to set
|
2010-01-29 01:21:04 +01:00
|
|
|
/// @arg name - The name of the operand
|
2010-04-08 02:48:21 +02:00
|
|
|
static int X86TypeFromOpName(LiteralConstantEmitter *type,
|
2010-01-29 01:21:04 +01:00
|
|
|
const std::string &name) {
|
|
|
|
REG("GR8");
|
|
|
|
REG("GR8_NOREX");
|
|
|
|
REG("GR16");
|
2011-10-06 08:44:41 +02:00
|
|
|
REG("GR16_NOAX");
|
2010-01-29 01:21:04 +01:00
|
|
|
REG("GR32");
|
2011-10-06 08:44:41 +02:00
|
|
|
REG("GR32_NOAX");
|
2010-01-29 01:21:04 +01:00
|
|
|
REG("GR32_NOREX");
|
2010-03-14 06:15:39 +01:00
|
|
|
REG("GR32_TC");
|
2010-01-29 01:21:04 +01:00
|
|
|
REG("FR32");
|
|
|
|
REG("RFP32");
|
|
|
|
REG("GR64");
|
2011-10-06 08:44:41 +02:00
|
|
|
REG("GR64_NOAX");
|
2010-03-14 06:15:39 +01:00
|
|
|
REG("GR64_TC");
|
2010-01-29 01:21:04 +01:00
|
|
|
REG("FR64");
|
|
|
|
REG("VR64");
|
|
|
|
REG("RFP64");
|
|
|
|
REG("RFP80");
|
|
|
|
REG("VR128");
|
2010-07-09 20:27:43 +02:00
|
|
|
REG("VR256");
|
2010-01-29 01:21:04 +01:00
|
|
|
REG("RST");
|
|
|
|
REG("SEGMENT_REG");
|
|
|
|
REG("DEBUG_REG");
|
2010-05-06 22:59:00 +02:00
|
|
|
REG("CONTROL_REG");
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
IMM("i8imm");
|
|
|
|
IMM("i16imm");
|
|
|
|
IMM("i16i8imm");
|
|
|
|
IMM("i32imm");
|
|
|
|
IMM("i32i8imm");
|
2011-07-28 01:01:50 +02:00
|
|
|
IMM("u32u8imm");
|
2010-04-08 02:48:21 +02:00
|
|
|
IMM("i64imm");
|
|
|
|
IMM("i64i8imm");
|
|
|
|
IMM("i64i32imm");
|
|
|
|
IMM("SSECC");
|
2012-04-03 07:20:24 +02:00
|
|
|
IMM("AVXCC");
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
// all R, I, R, I, R
|
2010-01-29 01:21:04 +01:00
|
|
|
MEM("i8mem");
|
|
|
|
MEM("i8mem_NOREX");
|
|
|
|
MEM("i16mem");
|
|
|
|
MEM("i32mem");
|
2010-03-14 06:15:39 +01:00
|
|
|
MEM("i32mem_TC");
|
2010-01-29 01:21:04 +01:00
|
|
|
MEM("f32mem");
|
|
|
|
MEM("ssmem");
|
|
|
|
MEM("opaque32mem");
|
|
|
|
MEM("opaque48mem");
|
|
|
|
MEM("i64mem");
|
2010-03-14 06:15:39 +01:00
|
|
|
MEM("i64mem_TC");
|
2010-01-29 01:21:04 +01:00
|
|
|
MEM("f64mem");
|
|
|
|
MEM("sdmem");
|
|
|
|
MEM("f80mem");
|
|
|
|
MEM("opaque80mem");
|
|
|
|
MEM("i128mem");
|
2010-07-20 01:32:44 +02:00
|
|
|
MEM("i256mem");
|
2010-01-29 01:21:04 +01:00
|
|
|
MEM("f128mem");
|
2010-07-09 20:27:43 +02:00
|
|
|
MEM("f256mem");
|
2010-01-29 01:21:04 +01:00
|
|
|
MEM("opaque512mem");
|
2012-07-18 06:11:12 +02:00
|
|
|
// Gather
|
|
|
|
MEM("vx32mem")
|
|
|
|
MEM("vy32mem")
|
|
|
|
MEM("vx64mem")
|
|
|
|
MEM("vy64mem")
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
// all R, I, R, I
|
2010-01-29 01:21:04 +01:00
|
|
|
LEA("lea32mem");
|
|
|
|
LEA("lea64_32mem");
|
|
|
|
LEA("lea64mem");
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
// all I
|
2010-07-08 00:27:31 +02:00
|
|
|
PCR("i16imm_pcrel");
|
2010-04-24 00:17:17 +02:00
|
|
|
PCR("i32imm_pcrel");
|
|
|
|
PCR("i64i32imm_pcrel");
|
2010-01-29 01:21:04 +01:00
|
|
|
PCR("brtarget8");
|
|
|
|
PCR("offset8");
|
|
|
|
PCR("offset16");
|
|
|
|
PCR("offset32");
|
|
|
|
PCR("offset64");
|
|
|
|
PCR("brtarget");
|
2010-12-13 20:31:11 +01:00
|
|
|
PCR("uncondbrtarget");
|
2010-11-11 21:05:40 +01:00
|
|
|
PCR("bltarget");
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2011-02-04 20:47:15 +01:00
|
|
|
// all I, ARM mode only, conditional/unconditional
|
|
|
|
PCR("br_target");
|
|
|
|
PCR("bl_target");
|
2010-01-29 01:21:04 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef REG
|
|
|
|
#undef MEM
|
|
|
|
#undef LEA
|
|
|
|
#undef IMM
|
|
|
|
#undef PCR
|
2010-04-08 02:48:21 +02:00
|
|
|
|
|
|
|
#undef SET
|
2010-01-29 01:21:04 +01:00
|
|
|
|
|
|
|
/// X86PopulateOperands - Handles all the operands in an X86 instruction, adding
|
|
|
|
/// the appropriate flags to their descriptors
|
|
|
|
///
|
|
|
|
/// @operandFlags - A reference the array of operand flag objects
|
|
|
|
/// @inst - The instruction to use as a source of information
|
|
|
|
static void X86PopulateOperands(
|
2010-04-13 23:21:57 +02:00
|
|
|
LiteralConstantEmitter *(&operandTypes)[EDIS_MAX_OPERANDS],
|
2010-01-29 01:21:04 +01:00
|
|
|
const CodeGenInstruction &inst) {
|
|
|
|
if (!inst.TheDef->isSubClassOf("X86Inst"))
|
|
|
|
return;
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
unsigned int index;
|
2010-11-01 05:03:32 +01:00
|
|
|
unsigned int numOperands = inst.Operands.size();
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
for (index = 0; index < numOperands; ++index) {
|
2010-11-01 05:03:32 +01:00
|
|
|
const CGIOperandList::OperandInfo &operandInfo = inst.Operands[index];
|
2010-01-29 01:21:04 +01:00
|
|
|
Record &rec = *operandInfo.Rec;
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2011-01-26 03:03:48 +01:00
|
|
|
if (X86TypeFromOpName(operandTypes[index], rec.getName()) &&
|
|
|
|
!rec.isSubClassOf("PointerLikeRegClass")) {
|
2010-01-29 01:21:04 +01:00
|
|
|
errs() << "Operand type: " << rec.getName().c_str() << "\n";
|
|
|
|
errs() << "Operand name: " << operandInfo.Name.c_str() << "\n";
|
2010-10-12 02:21:05 +02:00
|
|
|
errs() << "Instruction name: " << inst.TheDef->getName().c_str() << "\n";
|
2010-01-29 01:21:04 +01:00
|
|
|
llvm_unreachable("Unhandled type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// decorate1 - Decorates a named operand with a new flag
|
|
|
|
///
|
|
|
|
/// @operandFlags - The array of operand flag objects, which don't have names
|
|
|
|
/// @inst - The CodeGenInstruction, which provides a way to translate
|
|
|
|
/// between names and operand indices
|
|
|
|
/// @opName - The name of the operand
|
|
|
|
/// @flag - The name of the flag to add
|
2010-04-08 02:48:21 +02:00
|
|
|
static inline void decorate1(
|
2010-04-13 23:21:57 +02:00
|
|
|
FlagsConstantEmitter *(&operandFlags)[EDIS_MAX_OPERANDS],
|
2010-04-08 02:48:21 +02:00
|
|
|
const CodeGenInstruction &inst,
|
|
|
|
const char *opName,
|
|
|
|
const char *opFlag) {
|
2010-01-29 01:21:04 +01:00
|
|
|
unsigned opIndex;
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-11-01 05:03:32 +01:00
|
|
|
opIndex = inst.Operands.getOperandNamed(std::string(opName));
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
operandFlags[opIndex]->addEntry(opFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DECORATE1(opName, opFlag) decorate1(operandFlags, inst, opName, opFlag)
|
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
#define MOV(source, target) { \
|
|
|
|
instType.set("kInstructionTypeMove"); \
|
|
|
|
DECORATE1(source, "kOperandFlagSource"); \
|
|
|
|
DECORATE1(target, "kOperandFlagTarget"); \
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
#define BRANCH(target) { \
|
|
|
|
instType.set("kInstructionTypeBranch"); \
|
|
|
|
DECORATE1(target, "kOperandFlagTarget"); \
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
#define PUSH(source) { \
|
|
|
|
instType.set("kInstructionTypePush"); \
|
|
|
|
DECORATE1(source, "kOperandFlagSource"); \
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
#define POP(target) { \
|
|
|
|
instType.set("kInstructionTypePop"); \
|
|
|
|
DECORATE1(target, "kOperandFlagTarget"); \
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
#define CALL(target) { \
|
|
|
|
instType.set("kInstructionTypeCall"); \
|
|
|
|
DECORATE1(target, "kOperandFlagTarget"); \
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
#define RETURN() { \
|
|
|
|
instType.set("kInstructionTypeReturn"); \
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// X86ExtractSemantics - Performs various checks on the name of an X86
|
2010-10-05 22:35:57 +02:00
|
|
|
/// instruction to determine what sort of an instruction it is and then adds
|
2010-01-29 01:21:04 +01:00
|
|
|
/// the appropriate flags to the instruction and its operands
|
|
|
|
///
|
2010-04-08 02:48:21 +02:00
|
|
|
/// @arg instType - A reference to the type for the instruction as a whole
|
2010-01-29 01:21:04 +01:00
|
|
|
/// @arg operandFlags - A reference to the array of operand flag object pointers
|
|
|
|
/// @arg inst - A reference to the original instruction
|
2010-04-08 02:48:21 +02:00
|
|
|
static void X86ExtractSemantics(
|
|
|
|
LiteralConstantEmitter &instType,
|
2010-04-13 23:21:57 +02:00
|
|
|
FlagsConstantEmitter *(&operandFlags)[EDIS_MAX_OPERANDS],
|
2010-04-08 02:48:21 +02:00
|
|
|
const CodeGenInstruction &inst) {
|
2010-01-29 01:21:04 +01:00
|
|
|
const std::string &name = inst.TheDef->getName();
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
if (name.find("MOV") != name.npos) {
|
|
|
|
if (name.find("MOV_V") != name.npos) {
|
|
|
|
// ignore (this is a pseudoinstruction)
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("MASK") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
// ignore (this is a masking move)
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("r0") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
// ignore (this is a pseudoinstruction)
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("PS") != name.npos ||
|
2010-01-29 01:21:04 +01:00
|
|
|
name.find("PD") != name.npos) {
|
|
|
|
// ignore (this is a shuffling move)
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("MOVS") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
// ignore (this is a string move)
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("_F") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
// TODO handle _F moves to ST(0)
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("a") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
// TODO handle moves to/from %ax
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("CMOV") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
MOV("src2", "dst");
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("PC") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
MOV("label", "reg")
|
2010-04-08 02:48:21 +02:00
|
|
|
} else {
|
2010-01-29 01:21:04 +01:00
|
|
|
MOV("src", "dst");
|
|
|
|
}
|
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
if (name.find("JMP") != name.npos ||
|
|
|
|
name.find("J") == 0) {
|
|
|
|
if (name.find("FAR") != name.npos && name.find("i") != name.npos) {
|
|
|
|
BRANCH("off");
|
2010-04-08 02:48:21 +02:00
|
|
|
} else {
|
2010-01-29 01:21:04 +01:00
|
|
|
BRANCH("dst");
|
|
|
|
}
|
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
if (name.find("PUSH") != name.npos) {
|
2010-09-09 00:13:08 +02:00
|
|
|
if (name.find("CS") != name.npos ||
|
|
|
|
name.find("DS") != name.npos ||
|
|
|
|
name.find("ES") != name.npos ||
|
|
|
|
name.find("FS") != name.npos ||
|
|
|
|
name.find("GS") != name.npos ||
|
|
|
|
name.find("SS") != name.npos) {
|
2010-04-08 02:48:21 +02:00
|
|
|
instType.set("kInstructionTypePush");
|
2010-01-29 01:21:04 +01:00
|
|
|
// TODO add support for fixed operands
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("F") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
// ignore (this pushes onto the FP stack)
|
2010-06-23 22:00:58 +02:00
|
|
|
} else if (name.find("A") != name.npos) {
|
|
|
|
// ignore (pushes all GP registoers onto the stack)
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name[name.length() - 1] == 'm') {
|
2010-01-29 01:21:04 +01:00
|
|
|
PUSH("src");
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("i") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
PUSH("imm");
|
2010-04-08 02:48:21 +02:00
|
|
|
} else {
|
2010-01-29 01:21:04 +01:00
|
|
|
PUSH("reg");
|
|
|
|
}
|
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
if (name.find("POP") != name.npos) {
|
|
|
|
if (name.find("POPCNT") != name.npos) {
|
|
|
|
// ignore (not a real pop)
|
2010-09-09 00:13:08 +02:00
|
|
|
} else if (name.find("CS") != name.npos ||
|
|
|
|
name.find("DS") != name.npos ||
|
|
|
|
name.find("ES") != name.npos ||
|
|
|
|
name.find("FS") != name.npos ||
|
|
|
|
name.find("GS") != name.npos ||
|
|
|
|
name.find("SS") != name.npos) {
|
2010-04-08 02:48:21 +02:00
|
|
|
instType.set("kInstructionTypePop");
|
2010-01-29 01:21:04 +01:00
|
|
|
// TODO add support for fixed operands
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("F") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
// ignore (this pops from the FP stack)
|
2010-06-23 22:00:58 +02:00
|
|
|
} else if (name.find("A") != name.npos) {
|
|
|
|
// ignore (pushes all GP registoers onto the stack)
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name[name.length() - 1] == 'm') {
|
2010-01-29 01:21:04 +01:00
|
|
|
POP("dst");
|
2010-04-08 02:48:21 +02:00
|
|
|
} else {
|
2010-01-29 01:21:04 +01:00
|
|
|
POP("reg");
|
|
|
|
}
|
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
if (name.find("CALL") != name.npos) {
|
|
|
|
if (name.find("ADJ") != name.npos) {
|
|
|
|
// ignore (not a call)
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("SYSCALL") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
// ignore (doesn't go anywhere we know about)
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("VMCALL") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
// ignore (rather different semantics than a regular call)
|
2012-02-18 09:19:49 +01:00
|
|
|
} else if (name.find("VMMCALL") != name.npos) {
|
|
|
|
// ignore (rather different semantics than a regular call)
|
2010-04-08 02:48:21 +02:00
|
|
|
} else if (name.find("FAR") != name.npos && name.find("i") != name.npos) {
|
2010-01-29 01:21:04 +01:00
|
|
|
CALL("off");
|
2010-04-08 02:48:21 +02:00
|
|
|
} else {
|
2010-01-29 01:21:04 +01:00
|
|
|
CALL("dst");
|
|
|
|
}
|
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
if (name.find("RET") != name.npos) {
|
|
|
|
RETURN();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef MOV
|
|
|
|
#undef BRANCH
|
|
|
|
#undef PUSH
|
|
|
|
#undef POP
|
|
|
|
#undef CALL
|
|
|
|
#undef RETURN
|
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Support functions for handling ARM instructions //
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define SET(flag) { type->set(flag); return 0; }
|
|
|
|
|
|
|
|
#define REG(str) if (name == str) SET("kOperandTypeRegister");
|
|
|
|
#define IMM(str) if (name == str) SET("kOperandTypeImmediate");
|
|
|
|
|
|
|
|
#define MISC(str, type) if (name == str) SET(type);
|
|
|
|
|
|
|
|
/// ARMFlagFromOpName - Processes the name of a single ARM operand (which is
|
|
|
|
/// actually its type) and translates it into an operand type
|
|
|
|
///
|
|
|
|
/// @arg type - The type object to set
|
|
|
|
/// @arg name - The name of the operand
|
|
|
|
static int ARMFlagFromOpName(LiteralConstantEmitter *type,
|
|
|
|
const std::string &name) {
|
|
|
|
REG("GPR");
|
Many Thumb2 instructions can reference the full ARM register set (i.e.,
have 4 bits per register in the operand encoding), but have undefined
behavior when the operand value is 13 or 15 (SP and PC, respectively).
The trivial coalescer in linear scan sometimes will merge a copy from
SP into a subsequent instruction which uses the copy, and if that
instruction cannot legally reference SP, we get bad code such as:
mls r0,r9,r0,sp
instead of:
mov r2, sp
mls r0, r9, r0, r2
This patch adds a new register class for use by Thumb2 that excludes
the problematic registers (SP and PC) and is used instead of GPR
for those operands which cannot legally reference PC or SP. The
trivial coalescer explicitly requires that the register class
of the destination for the COPY instruction contain the source
register for the COPY to be considered for coalescing. This prevents
errant instructions like that above.
PR7499
llvm-svn: 109842
2010-07-30 04:41:01 +02:00
|
|
|
REG("rGPR");
|
2011-08-10 00:48:45 +02:00
|
|
|
REG("GPRnopc");
|
2011-08-24 19:46:13 +02:00
|
|
|
REG("GPRsp");
|
2010-06-16 00:08:33 +02:00
|
|
|
REG("tcGPR");
|
2010-04-08 02:48:21 +02:00
|
|
|
REG("cc_out");
|
|
|
|
REG("s_cc_out");
|
|
|
|
REG("tGPR");
|
|
|
|
REG("DPR");
|
|
|
|
REG("DPR_VFP2");
|
|
|
|
REG("DPR_8");
|
2012-03-28 23:20:32 +02:00
|
|
|
REG("DPair");
|
2010-05-06 08:36:08 +02:00
|
|
|
REG("SPR");
|
|
|
|
REG("QPR");
|
|
|
|
REG("QQPR");
|
2010-05-14 04:13:41 +02:00
|
|
|
REG("QQQQPR");
|
2011-10-19 01:02:30 +02:00
|
|
|
REG("VecListOneD");
|
2012-03-05 20:33:30 +01:00
|
|
|
REG("VecListDPair");
|
2012-03-05 22:43:40 +01:00
|
|
|
REG("VecListDPairSpaced");
|
2011-10-21 22:02:19 +02:00
|
|
|
REG("VecListThreeD");
|
2011-10-21 22:35:01 +02:00
|
|
|
REG("VecListFourD");
|
2011-11-30 02:09:44 +01:00
|
|
|
REG("VecListOneDAllLanes");
|
2012-03-06 23:01:44 +01:00
|
|
|
REG("VecListDPairAllLanes");
|
2012-03-07 00:10:38 +01:00
|
|
|
REG("VecListDPairSpacedAllLanes");
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
IMM("i32imm");
|
2011-12-22 23:19:05 +01:00
|
|
|
IMM("fbits16");
|
|
|
|
IMM("fbits32");
|
2011-01-13 08:58:56 +01:00
|
|
|
IMM("i32imm_hilo16");
|
2010-04-08 02:48:21 +02:00
|
|
|
IMM("bf_inv_mask_imm");
|
2011-01-18 21:45:56 +01:00
|
|
|
IMM("lsb_pos_imm");
|
|
|
|
IMM("width_imm");
|
2010-04-08 02:48:21 +02:00
|
|
|
IMM("jtblock_operand");
|
|
|
|
IMM("nohash_imm");
|
2011-01-13 22:46:02 +01:00
|
|
|
IMM("p_imm");
|
2012-04-18 15:02:55 +02:00
|
|
|
IMM("pf_imm");
|
2011-01-13 22:46:02 +01:00
|
|
|
IMM("c_imm");
|
2011-10-12 19:34:41 +02:00
|
|
|
IMM("coproc_option_imm");
|
2011-02-14 14:09:44 +01:00
|
|
|
IMM("imod_op");
|
|
|
|
IMM("iflags_op");
|
2010-04-08 02:48:21 +02:00
|
|
|
IMM("cpinst_operand");
|
2010-10-13 23:00:04 +02:00
|
|
|
IMM("setend_op");
|
2010-04-08 02:48:21 +02:00
|
|
|
IMM("cps_opt");
|
|
|
|
IMM("vfp_f64imm");
|
|
|
|
IMM("vfp_f32imm");
|
2010-08-12 22:46:17 +02:00
|
|
|
IMM("memb_opt");
|
2010-04-08 02:48:21 +02:00
|
|
|
IMM("msr_mask");
|
|
|
|
IMM("neg_zero");
|
|
|
|
IMM("imm0_31");
|
2010-10-15 19:15:16 +02:00
|
|
|
IMM("imm0_31_m1");
|
2011-07-26 01:09:14 +02:00
|
|
|
IMM("imm1_16");
|
2011-07-23 01:16:18 +02:00
|
|
|
IMM("imm1_32");
|
2010-06-11 23:34:50 +02:00
|
|
|
IMM("nModImm");
|
2011-10-18 00:26:03 +02:00
|
|
|
IMM("nImmSplatI8");
|
2011-10-18 01:09:09 +02:00
|
|
|
IMM("nImmSplatI16");
|
2011-10-18 02:22:00 +02:00
|
|
|
IMM("nImmSplatI32");
|
2011-10-18 18:18:11 +02:00
|
|
|
IMM("nImmSplatI64");
|
2011-10-18 02:22:00 +02:00
|
|
|
IMM("nImmVMOVI32");
|
2011-11-15 03:12:34 +01:00
|
|
|
IMM("nImmVMOVF32");
|
2011-12-07 02:07:24 +01:00
|
|
|
IMM("imm8");
|
|
|
|
IMM("imm16");
|
|
|
|
IMM("imm32");
|
|
|
|
IMM("imm1_7");
|
|
|
|
IMM("imm1_15");
|
|
|
|
IMM("imm1_31");
|
2011-12-03 00:34:39 +01:00
|
|
|
IMM("imm0_1");
|
|
|
|
IMM("imm0_3");
|
2011-07-14 00:01:08 +02:00
|
|
|
IMM("imm0_7");
|
|
|
|
IMM("imm0_15");
|
2011-06-28 01:54:06 +02:00
|
|
|
IMM("imm0_255");
|
2010-04-08 02:48:21 +02:00
|
|
|
IMM("imm0_4095");
|
2011-07-13 21:24:09 +02:00
|
|
|
IMM("imm0_65535");
|
2011-07-19 21:13:28 +02:00
|
|
|
IMM("imm0_65535_expr");
|
2011-07-26 18:24:27 +02:00
|
|
|
IMM("imm24b");
|
2011-07-20 23:40:26 +02:00
|
|
|
IMM("pkh_lsl_amt");
|
|
|
|
IMM("pkh_asr_amt");
|
2010-04-08 02:48:21 +02:00
|
|
|
IMM("jt2block_operand");
|
2011-08-24 23:22:15 +02:00
|
|
|
IMM("t_imm0_1020s4");
|
|
|
|
IMM("t_imm0_508s4");
|
2010-04-08 02:48:21 +02:00
|
|
|
IMM("pclabel");
|
2010-12-01 20:47:31 +01:00
|
|
|
IMM("adrlabel");
|
2010-12-14 23:28:03 +01:00
|
|
|
IMM("t_adrlabel");
|
2010-12-14 01:36:49 +01:00
|
|
|
IMM("t2adrlabel");
|
2010-08-16 20:27:34 +02:00
|
|
|
IMM("shift_imm");
|
2011-09-26 23:06:22 +02:00
|
|
|
IMM("t2_shift_imm");
|
2010-10-28 00:49:00 +02:00
|
|
|
IMM("neon_vcvt_imm32");
|
2011-03-08 00:38:41 +01:00
|
|
|
IMM("shr_imm8");
|
|
|
|
IMM("shr_imm16");
|
|
|
|
IMM("shr_imm32");
|
|
|
|
IMM("shr_imm64");
|
2011-03-18 18:42:55 +01:00
|
|
|
IMM("t2ldrlabel");
|
2011-08-04 01:50:40 +02:00
|
|
|
IMM("postidx_imm8");
|
2011-08-04 20:24:14 +02:00
|
|
|
IMM("postidx_imm8s4");
|
2011-08-08 22:42:17 +02:00
|
|
|
IMM("imm_sr");
|
|
|
|
IMM("imm1_31");
|
2011-10-08 01:56:00 +02:00
|
|
|
IMM("VectorIndex8");
|
|
|
|
IMM("VectorIndex16");
|
|
|
|
IMM("VectorIndex32");
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
MISC("brtarget", "kOperandTypeARMBranchTarget"); // ?
|
2010-12-13 20:31:11 +01:00
|
|
|
MISC("uncondbrtarget", "kOperandTypeARMBranchTarget"); // ?
|
2010-12-10 19:21:33 +01:00
|
|
|
MISC("t_brtarget", "kOperandTypeARMBranchTarget"); // ?
|
2010-12-10 18:13:40 +01:00
|
|
|
MISC("t_bcctarget", "kOperandTypeARMBranchTarget"); // ?
|
2010-12-09 20:01:46 +01:00
|
|
|
MISC("t_cbtarget", "kOperandTypeARMBranchTarget"); // ?
|
2010-11-11 21:05:40 +01:00
|
|
|
MISC("bltarget", "kOperandTypeARMBranchTarget"); // ?
|
2011-02-04 20:47:15 +01:00
|
|
|
|
|
|
|
MISC("br_target", "kOperandTypeARMBranchTarget"); // ?
|
|
|
|
MISC("bl_target", "kOperandTypeARMBranchTarget"); // ?
|
2011-08-27 01:32:08 +02:00
|
|
|
MISC("blx_target", "kOperandTypeARMBranchTarget"); // ?
|
2011-02-04 20:47:15 +01:00
|
|
|
|
2010-12-09 00:01:43 +01:00
|
|
|
MISC("t_bltarget", "kOperandTypeARMBranchTarget"); // ?
|
2010-12-09 01:39:08 +01:00
|
|
|
MISC("t_blxtarget", "kOperandTypeARMBranchTarget"); // ?
|
2011-07-22 01:38:37 +02:00
|
|
|
MISC("so_reg_imm", "kOperandTypeARMSoRegReg"); // R, R, I
|
|
|
|
MISC("so_reg_reg", "kOperandTypeARMSoRegImm"); // R, R, I
|
|
|
|
MISC("shift_so_reg_reg", "kOperandTypeARMSoRegReg"); // R, R, I
|
|
|
|
MISC("shift_so_reg_imm", "kOperandTypeARMSoRegImm"); // R, R, I
|
2010-04-08 02:48:21 +02:00
|
|
|
MISC("t2_so_reg", "kOperandTypeThumb2SoReg"); // R, I
|
|
|
|
MISC("so_imm", "kOperandTypeARMSoImm"); // I
|
2010-10-13 21:56:10 +02:00
|
|
|
MISC("rot_imm", "kOperandTypeARMRotImm"); // I
|
2010-04-08 02:48:21 +02:00
|
|
|
MISC("t2_so_imm", "kOperandTypeThumb2SoImm"); // I
|
|
|
|
MISC("so_imm2part", "kOperandTypeARMSoImm2Part"); // I
|
|
|
|
MISC("pred", "kOperandTypeARMPredicate"); // I, R
|
|
|
|
MISC("it_pred", "kOperandTypeARMPredicate"); // I
|
2010-10-27 00:37:02 +02:00
|
|
|
MISC("addrmode_imm12", "kOperandTypeAddrModeImm12"); // R, I
|
|
|
|
MISC("ldst_so_reg", "kOperandTypeLdStSOReg"); // R, R, I
|
2011-08-04 01:50:40 +02:00
|
|
|
MISC("postidx_reg", "kOperandTypeARMAddrMode3Offset"); // R, I
|
2010-04-08 02:48:21 +02:00
|
|
|
MISC("addrmode2", "kOperandTypeARMAddrMode2"); // R, R, I
|
2011-08-04 01:50:40 +02:00
|
|
|
MISC("am2offset_reg", "kOperandTypeARMAddrMode2Offset"); // R, I
|
|
|
|
MISC("am2offset_imm", "kOperandTypeARMAddrMode2Offset"); // R, I
|
2010-04-08 02:48:21 +02:00
|
|
|
MISC("addrmode3", "kOperandTypeARMAddrMode3"); // R, R, I
|
|
|
|
MISC("am3offset", "kOperandTypeARMAddrMode3Offset"); // R, I
|
2010-11-03 02:01:43 +01:00
|
|
|
MISC("ldstm_mode", "kOperandTypeARMLdStmMode"); // I
|
2010-04-08 02:48:21 +02:00
|
|
|
MISC("addrmode5", "kOperandTypeARMAddrMode5"); // R, I
|
|
|
|
MISC("addrmode6", "kOperandTypeARMAddrMode6"); // R, R, I, I
|
|
|
|
MISC("am6offset", "kOperandTypeARMAddrMode6Offset"); // R, I, I
|
2010-11-30 01:00:42 +01:00
|
|
|
MISC("addrmode6dup", "kOperandTypeARMAddrMode6"); // R, R, I, I
|
2011-05-09 19:47:27 +02:00
|
|
|
MISC("addrmode6oneL32", "kOperandTypeARMAddrMode6"); // R, R, I, I
|
2010-04-08 02:48:21 +02:00
|
|
|
MISC("addrmodepc", "kOperandTypeARMAddrModePC"); // R, I
|
2011-08-02 20:07:32 +02:00
|
|
|
MISC("addr_offset_none", "kOperandTypeARMAddrMode7"); // R
|
2010-04-08 02:48:21 +02:00
|
|
|
MISC("reglist", "kOperandTypeARMRegisterList"); // I, R, ...
|
2010-11-17 05:32:08 +01:00
|
|
|
MISC("dpr_reglist", "kOperandTypeARMDPRRegisterList"); // I, R, ...
|
|
|
|
MISC("spr_reglist", "kOperandTypeARMSPRRegisterList"); // I, R, ...
|
2010-04-08 02:48:21 +02:00
|
|
|
MISC("it_mask", "kOperandTypeThumbITMask"); // I
|
2011-03-24 22:04:58 +01:00
|
|
|
MISC("t2addrmode_reg", "kOperandTypeThumb2AddrModeReg"); // R
|
2011-09-08 01:39:14 +02:00
|
|
|
MISC("t2addrmode_posimm8", "kOperandTypeThumb2AddrModeImm8"); // R, I
|
2011-09-07 22:58:57 +02:00
|
|
|
MISC("t2addrmode_negimm8", "kOperandTypeThumb2AddrModeImm8"); // R, I
|
2010-04-08 02:48:21 +02:00
|
|
|
MISC("t2addrmode_imm8", "kOperandTypeThumb2AddrModeImm8"); // R, I
|
|
|
|
MISC("t2am_imm8_offset", "kOperandTypeThumb2AddrModeImm8Offset");//I
|
|
|
|
MISC("t2addrmode_imm12", "kOperandTypeThumb2AddrModeImm12"); // R, I
|
|
|
|
MISC("t2addrmode_so_reg", "kOperandTypeThumb2AddrModeSoReg"); // R, R, I
|
|
|
|
MISC("t2addrmode_imm8s4", "kOperandTypeThumb2AddrModeImm8s4"); // R, I
|
2011-09-09 20:37:27 +02:00
|
|
|
MISC("t2addrmode_imm0_1020s4", "kOperandTypeThumb2AddrModeImm8s4"); // R, I
|
2010-10-05 22:35:57 +02:00
|
|
|
MISC("t2am_imm8s4_offset", "kOperandTypeThumb2AddrModeImm8s4Offset");
|
2010-04-08 02:48:21 +02:00
|
|
|
// R, I
|
|
|
|
MISC("tb_addrmode", "kOperandTypeARMTBAddrMode"); // I
|
2011-07-11 19:57:30 +02:00
|
|
|
MISC("t_addrmode_rrs1", "kOperandTypeThumbAddrModeRegS1"); // R, R
|
|
|
|
MISC("t_addrmode_rrs2", "kOperandTypeThumbAddrModeRegS2"); // R, R
|
|
|
|
MISC("t_addrmode_rrs4", "kOperandTypeThumbAddrModeRegS4"); // R, R
|
|
|
|
MISC("t_addrmode_is1", "kOperandTypeThumbAddrModeImmS1"); // R, I
|
|
|
|
MISC("t_addrmode_is2", "kOperandTypeThumbAddrModeImmS2"); // R, I
|
|
|
|
MISC("t_addrmode_is4", "kOperandTypeThumbAddrModeImmS4"); // R, I
|
2010-04-08 02:48:21 +02:00
|
|
|
MISC("t_addrmode_rr", "kOperandTypeThumbAddrModeRR"); // R, R
|
|
|
|
MISC("t_addrmode_sp", "kOperandTypeThumbAddrModeSP"); // R, I
|
2010-12-08 02:57:09 +01:00
|
|
|
MISC("t_addrmode_pc", "kOperandTypeThumbAddrModePC"); // R, I
|
2011-09-20 00:21:13 +02:00
|
|
|
MISC("addrmode_tbb", "kOperandTypeThumbAddrModeRR"); // R, R
|
|
|
|
MISC("addrmode_tbh", "kOperandTypeThumbAddrModeRR"); // R, R
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef REG
|
|
|
|
#undef MEM
|
2011-07-11 19:57:30 +02:00
|
|
|
#undef MISC
|
2010-04-08 02:48:21 +02:00
|
|
|
|
|
|
|
#undef SET
|
|
|
|
|
|
|
|
/// ARMPopulateOperands - Handles all the operands in an ARM instruction, adding
|
|
|
|
/// the appropriate flags to their descriptors
|
|
|
|
///
|
|
|
|
/// @operandFlags - A reference the array of operand flag objects
|
|
|
|
/// @inst - The instruction to use as a source of information
|
|
|
|
static void ARMPopulateOperands(
|
2010-04-13 23:21:57 +02:00
|
|
|
LiteralConstantEmitter *(&operandTypes)[EDIS_MAX_OPERANDS],
|
2010-04-08 02:48:21 +02:00
|
|
|
const CodeGenInstruction &inst) {
|
|
|
|
if (!inst.TheDef->isSubClassOf("InstARM") &&
|
|
|
|
!inst.TheDef->isSubClassOf("InstThumb"))
|
|
|
|
return;
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
unsigned int index;
|
2010-11-01 05:03:32 +01:00
|
|
|
unsigned int numOperands = inst.Operands.size();
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-13 23:21:57 +02:00
|
|
|
if (numOperands > EDIS_MAX_OPERANDS) {
|
2010-10-05 22:35:57 +02:00
|
|
|
errs() << "numOperands == " << numOperands << " > " <<
|
2010-04-13 23:21:57 +02:00
|
|
|
EDIS_MAX_OPERANDS << '\n';
|
2010-04-08 02:48:21 +02:00
|
|
|
llvm_unreachable("Too many operands");
|
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
for (index = 0; index < numOperands; ++index) {
|
2010-11-01 05:03:32 +01:00
|
|
|
const CGIOperandList::OperandInfo &operandInfo = inst.Operands[index];
|
2010-04-08 02:48:21 +02:00
|
|
|
Record &rec = *operandInfo.Rec;
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
if (ARMFlagFromOpName(operandTypes[index], rec.getName())) {
|
2010-04-08 11:42:29 +02:00
|
|
|
errs() << "Operand type: " << rec.getName() << '\n';
|
|
|
|
errs() << "Operand name: " << operandInfo.Name << '\n';
|
2010-10-12 02:21:05 +02:00
|
|
|
errs() << "Instruction name: " << inst.TheDef->getName() << '\n';
|
2011-11-30 02:15:55 +01:00
|
|
|
throw("Unhandled type in EDEmitter");
|
2010-04-08 02:48:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BRANCH(target) { \
|
|
|
|
instType.set("kInstructionTypeBranch"); \
|
|
|
|
DECORATE1(target, "kOperandFlagTarget"); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/// ARMExtractSemantics - Performs various checks on the name of an ARM
|
2010-10-05 22:35:57 +02:00
|
|
|
/// instruction to determine what sort of an instruction it is and then adds
|
2010-04-08 02:48:21 +02:00
|
|
|
/// the appropriate flags to the instruction and its operands
|
|
|
|
///
|
|
|
|
/// @arg instType - A reference to the type for the instruction as a whole
|
|
|
|
/// @arg operandTypes - A reference to the array of operand type object pointers
|
|
|
|
/// @arg operandFlags - A reference to the array of operand flag object pointers
|
|
|
|
/// @arg inst - A reference to the original instruction
|
|
|
|
static void ARMExtractSemantics(
|
|
|
|
LiteralConstantEmitter &instType,
|
2010-04-13 23:21:57 +02:00
|
|
|
LiteralConstantEmitter *(&operandTypes)[EDIS_MAX_OPERANDS],
|
|
|
|
FlagsConstantEmitter *(&operandFlags)[EDIS_MAX_OPERANDS],
|
2010-04-08 02:48:21 +02:00
|
|
|
const CodeGenInstruction &inst) {
|
|
|
|
const std::string &name = inst.TheDef->getName();
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
if (name == "tBcc" ||
|
|
|
|
name == "tB" ||
|
|
|
|
name == "t2Bcc" ||
|
|
|
|
name == "Bcc" ||
|
|
|
|
name == "tCBZ" ||
|
|
|
|
name == "tCBNZ") {
|
|
|
|
BRANCH("target");
|
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
if (name == "tBLr9" ||
|
|
|
|
name == "BLr9_pred" ||
|
|
|
|
name == "tBLXi_r9" ||
|
|
|
|
name == "tBLXr_r9" ||
|
|
|
|
name == "BLXr9" ||
|
|
|
|
name == "t2BXJ" ||
|
|
|
|
name == "BXJ") {
|
|
|
|
BRANCH("func");
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
unsigned opIndex;
|
2010-11-01 05:03:32 +01:00
|
|
|
opIndex = inst.Operands.getOperandNamed("func");
|
2010-04-08 02:48:21 +02:00
|
|
|
if (operandTypes[opIndex]->is("kOperandTypeImmediate"))
|
|
|
|
operandTypes[opIndex]->set("kOperandTypeARMBranchTarget");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef BRANCH
|
2010-01-29 01:21:04 +01:00
|
|
|
|
2010-10-05 22:35:57 +02:00
|
|
|
/// populateInstInfo - Fills an array of InstInfos with information about each
|
2010-01-29 01:21:04 +01:00
|
|
|
/// instruction in a target
|
|
|
|
///
|
|
|
|
/// @arg infoArray - The array of InstInfo objects to populate
|
|
|
|
/// @arg target - The CodeGenTarget to use as a source of instructions
|
|
|
|
static void populateInstInfo(CompoundConstantEmitter &infoArray,
|
|
|
|
CodeGenTarget &target) {
|
2010-03-19 01:34:35 +01:00
|
|
|
const std::vector<const CodeGenInstruction*> &numberedInstructions =
|
|
|
|
target.getInstructionsByEnumValue();
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
unsigned int index;
|
|
|
|
unsigned int numInstructions = numberedInstructions.size();
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
for (index = 0; index < numInstructions; ++index) {
|
|
|
|
const CodeGenInstruction& inst = *numberedInstructions[index];
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2011-10-10 20:30:16 +02:00
|
|
|
CompoundConstantEmitter *infoStruct = new CompoundConstantEmitter;
|
|
|
|
infoArray.addEntry(infoStruct);
|
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
LiteralConstantEmitter *instType = new LiteralConstantEmitter;
|
|
|
|
infoStruct->addEntry(instType);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
|
|
|
LiteralConstantEmitter *numOperandsEmitter =
|
2010-11-01 05:03:32 +01:00
|
|
|
new LiteralConstantEmitter(inst.Operands.size());
|
2010-01-29 01:21:04 +01:00
|
|
|
infoStruct->addEntry(numOperandsEmitter);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
CompoundConstantEmitter *operandTypeArray = new CompoundConstantEmitter;
|
|
|
|
infoStruct->addEntry(operandTypeArray);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-13 23:21:57 +02:00
|
|
|
LiteralConstantEmitter *operandTypes[EDIS_MAX_OPERANDS];
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
CompoundConstantEmitter *operandFlagArray = new CompoundConstantEmitter;
|
|
|
|
infoStruct->addEntry(operandFlagArray);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-13 23:21:57 +02:00
|
|
|
FlagsConstantEmitter *operandFlags[EDIS_MAX_OPERANDS];
|
2010-10-05 22:35:57 +02:00
|
|
|
|
|
|
|
for (unsigned operandIndex = 0;
|
|
|
|
operandIndex < EDIS_MAX_OPERANDS;
|
2010-04-08 02:48:21 +02:00
|
|
|
++operandIndex) {
|
|
|
|
operandTypes[operandIndex] = new LiteralConstantEmitter;
|
|
|
|
operandTypeArray->addEntry(operandTypes[operandIndex]);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
operandFlags[operandIndex] = new FlagsConstantEmitter;
|
|
|
|
operandFlagArray->addEntry(operandFlags[operandIndex]);
|
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
unsigned numSyntaxes = 0;
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2011-10-10 22:15:49 +02:00
|
|
|
// We don't need to do anything for pseudo-instructions, as we'll never
|
|
|
|
// see them here. We'll only see real instructions.
|
|
|
|
// We still need to emit null initializers for everything.
|
|
|
|
if (!inst.isPseudo) {
|
|
|
|
if (target.getName() == "X86") {
|
|
|
|
X86PopulateOperands(operandTypes, inst);
|
|
|
|
X86ExtractSemantics(*instType, operandFlags, inst);
|
|
|
|
numSyntaxes = 2;
|
|
|
|
}
|
|
|
|
else if (target.getName() == "ARM") {
|
|
|
|
ARMPopulateOperands(operandTypes, inst);
|
|
|
|
ARMExtractSemantics(*instType, operandTypes, operandFlags, inst);
|
|
|
|
numSyntaxes = 1;
|
|
|
|
}
|
2010-04-08 02:48:21 +02:00
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
|
|
|
CompoundConstantEmitter *operandOrderArray = new CompoundConstantEmitter;
|
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
infoStruct->addEntry(operandOrderArray);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
|
|
|
for (unsigned syntaxIndex = 0;
|
|
|
|
syntaxIndex < EDIS_MAX_SYNTAXES;
|
2010-04-13 23:21:57 +02:00
|
|
|
++syntaxIndex) {
|
2010-10-05 22:35:57 +02:00
|
|
|
CompoundConstantEmitter *operandOrder =
|
2010-04-13 23:21:57 +02:00
|
|
|
new CompoundConstantEmitter(EDIS_MAX_OPERANDS);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
operandOrderArray->addEntry(operandOrder);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
if (syntaxIndex < numSyntaxes) {
|
2010-02-10 03:47:08 +01:00
|
|
|
populateOperandOrder(operandOrder, inst, syntaxIndex);
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
|
|
|
}
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
infoStruct = NULL;
|
2010-01-29 01:21:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-13 23:21:57 +02:00
|
|
|
static void emitCommonEnums(raw_ostream &o, unsigned int &i) {
|
2010-04-08 02:48:21 +02:00
|
|
|
EnumEmitter operandTypes("OperandTypes");
|
|
|
|
operandTypes.addEntry("kOperandTypeNone");
|
|
|
|
operandTypes.addEntry("kOperandTypeImmediate");
|
|
|
|
operandTypes.addEntry("kOperandTypeRegister");
|
|
|
|
operandTypes.addEntry("kOperandTypeX86Memory");
|
|
|
|
operandTypes.addEntry("kOperandTypeX86EffectiveAddress");
|
|
|
|
operandTypes.addEntry("kOperandTypeX86PCRelative");
|
|
|
|
operandTypes.addEntry("kOperandTypeARMBranchTarget");
|
2011-07-22 01:38:37 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeARMSoRegReg");
|
|
|
|
operandTypes.addEntry("kOperandTypeARMSoRegImm");
|
2010-04-08 02:48:21 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeARMSoImm");
|
2010-10-13 21:56:10 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeARMRotImm");
|
2010-04-08 02:48:21 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeARMSoImm2Part");
|
|
|
|
operandTypes.addEntry("kOperandTypeARMPredicate");
|
2010-10-27 00:37:02 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeAddrModeImm12");
|
|
|
|
operandTypes.addEntry("kOperandTypeLdStSOReg");
|
2010-04-08 02:48:21 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeARMAddrMode2");
|
|
|
|
operandTypes.addEntry("kOperandTypeARMAddrMode2Offset");
|
|
|
|
operandTypes.addEntry("kOperandTypeARMAddrMode3");
|
|
|
|
operandTypes.addEntry("kOperandTypeARMAddrMode3Offset");
|
2010-11-03 02:01:43 +01:00
|
|
|
operandTypes.addEntry("kOperandTypeARMLdStmMode");
|
2010-04-08 02:48:21 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeARMAddrMode5");
|
|
|
|
operandTypes.addEntry("kOperandTypeARMAddrMode6");
|
|
|
|
operandTypes.addEntry("kOperandTypeARMAddrMode6Offset");
|
2011-03-24 22:04:58 +01:00
|
|
|
operandTypes.addEntry("kOperandTypeARMAddrMode7");
|
2010-04-08 02:48:21 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeARMAddrModePC");
|
|
|
|
operandTypes.addEntry("kOperandTypeARMRegisterList");
|
2010-11-17 05:32:08 +01:00
|
|
|
operandTypes.addEntry("kOperandTypeARMDPRRegisterList");
|
|
|
|
operandTypes.addEntry("kOperandTypeARMSPRRegisterList");
|
2010-04-08 02:48:21 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeARMTBAddrMode");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumbITMask");
|
2011-07-11 19:57:30 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeThumbAddrModeImmS1");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumbAddrModeImmS2");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumbAddrModeImmS4");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumbAddrModeRegS1");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumbAddrModeRegS2");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumbAddrModeRegS4");
|
2010-04-08 02:48:21 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeThumbAddrModeRR");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumbAddrModeSP");
|
2010-12-08 02:57:09 +01:00
|
|
|
operandTypes.addEntry("kOperandTypeThumbAddrModePC");
|
2011-03-24 22:04:58 +01:00
|
|
|
operandTypes.addEntry("kOperandTypeThumb2AddrModeReg");
|
2010-04-08 02:48:21 +02:00
|
|
|
operandTypes.addEntry("kOperandTypeThumb2SoReg");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumb2SoImm");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8Offset");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumb2AddrModeImm12");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumb2AddrModeSoReg");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8s4");
|
|
|
|
operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8s4Offset");
|
|
|
|
operandTypes.emit(o, i);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
o << "\n";
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
EnumEmitter operandFlags("OperandFlags");
|
|
|
|
operandFlags.addEntry("kOperandFlagSource");
|
|
|
|
operandFlags.addEntry("kOperandFlagTarget");
|
|
|
|
operandFlags.emitAsFlags(o, i);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
o << "\n";
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-08 02:48:21 +02:00
|
|
|
EnumEmitter instructionTypes("InstructionTypes");
|
|
|
|
instructionTypes.addEntry("kInstructionTypeNone");
|
|
|
|
instructionTypes.addEntry("kInstructionTypeMove");
|
|
|
|
instructionTypes.addEntry("kInstructionTypeBranch");
|
|
|
|
instructionTypes.addEntry("kInstructionTypePush");
|
|
|
|
instructionTypes.addEntry("kInstructionTypePop");
|
|
|
|
instructionTypes.addEntry("kInstructionTypeCall");
|
|
|
|
instructionTypes.addEntry("kInstructionTypeReturn");
|
|
|
|
instructionTypes.emit(o, i);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-01-29 01:21:04 +01:00
|
|
|
o << "\n";
|
2010-04-13 23:21:57 +02:00
|
|
|
}
|
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
void EmitEnhancedDisassemblerInfo(RecordKeeper &RK, raw_ostream &OS) {
|
|
|
|
emitSourceFileHeader("Enhanced Disassembler Info", OS);
|
2010-04-13 23:21:57 +02:00
|
|
|
unsigned int i = 0;
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-13 23:21:57 +02:00
|
|
|
CompoundConstantEmitter infoArray;
|
2012-06-11 17:37:55 +02:00
|
|
|
CodeGenTarget target(RK);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2010-04-13 23:21:57 +02:00
|
|
|
populateInstInfo(infoArray, target);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
emitCommonEnums(OS, i);
|
2010-10-05 22:35:57 +02:00
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
OS << "static const llvm::EDInstInfo instInfo"
|
|
|
|
<< target.getName() << "[] = ";
|
|
|
|
infoArray.emit(OS, i);
|
|
|
|
OS << ";" << "\n";
|
2010-04-13 23:21:57 +02:00
|
|
|
}
|
2012-06-11 17:37:55 +02:00
|
|
|
|
|
|
|
} // End llvm namespace
|